akhauriyash/Code-Regression huggingface dataset:
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <array>
#include <bitset> 
#include <unordered_map>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> P;


void solve(long long N, long long K, std::vector<long long> p){
	LL v=0;
	LL ret=0;
	for(int i=0;i<N;i++){
		if(i-K>=0){
			v-=p[i-K]+1;
		}
		v+=p[i]+1;
		ret=max(ret,v);
	}
	cout << ret/2.0 << endl;

}

int main(){
	cout.precision(20);
#if 0
	vector<LL> t;
	LL S=200000;
	for(int i=0;i<S;i++){
		t.push_back(1000);
	}
	solve(S,S-1,t);
#endif
    long long N;
    scanf("%lld",&N);
    long long K;
    scanf("%lld",&K);
    std::vector<long long> p(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&p[i]);
    }
    solve(N, K, std::move(p));
    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <cmath>
#include <vector>
#include <algorithm>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <cctype>

using namespace std;
// for loop
#define F(i, L, R) for(int i = L; i < R; i++)
#define FE(i, L, R) for(int i = L; i <= R; i++)
// for (reversed)
#define FR(i, L, R) for(int i = L; i > R; i--)
#define FRE(i, L, R) for(int i = L; i >= R; i--)

// data types
#define ul unsigned long
#define ll long long
#define ull unsigned long long
#define ui unsigned int
#define us unsigned shoft

// vectors
typedef vector<int> vi;
typedef vector<long> vl;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
#define ALL(c) (c).begin(),(c).end()
#define last(vec) vec.size()-1
#define lastEle(vec) vec[last(vec)]
#define pb push_back
#define InputV(a, n) F(i,0,n){long l; cin >> l; a.pb(l);}

// debug
#define DBG(vari) cerr<<#vari<<" = "<<(vari)<<endl;
#define printA(a, L, R) FE(i, L, R) cout << a[i] << (i==R?'\n':' ')
#define printAF(a, L) printA(a, 0, L-1)
#define printV(a) printA(a, 0, a.size()-1)

// utils
#define char2int(c) (c-'0')
#define bit(x, i) (x&(1<<i))
#define space ' '
#define PI 3.14159265358979323

int main() {
    int n;
    cin >> n;
    vl data;
    InputV(data, n);
    int times = 0;
    F(i, 0, n){
        FRE(j, n-1, i+1){
            if(data[j] < data[j-1]){
                swap(data[j], data[j-1]);
                times++;
            }

        }
    }
    printV(data);
    cout << times << endl;
}



Measured memory_bytes: 3168
#include<iostream>
#include<string>
using namespace std;

int main(){
	string s; cin >> s;
	int ans = 0;
	for(int i = 0; i < s.size(); ++i){
		if(i & 1){
			if(s[i] == 'g'){
				++ans;
			}
		}else{
			if(s[i] == 'p'){
				--ans;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 512
#066A
# 1.値を正しく取得
a, b, c = (int(x) for x in input().split())

# 2.正しく処理
gokei1 = a + b
gokei2 = a + c
gokei3 = b + c

resalt=[gokei1,gokei2,gokei3]

print(min(resalt))

Measured memory_bytes: 9168
// binary search tree 2
// input command "insert", "print" or "find", print is output in-order tree walk and pre-order tree walk, find is output "yes" or "no"
#include<iostream>
#include<string>
typedef struct node{
  struct node *left, *right, *parent;
  int key;
}node;
node *T;
void Insert(int);
void Inorder(node*);
void Preorder(node*);
int Find(int);
void Free(node*);
int main(){
  int n, i, key;
  std::string func, ins="insert", pri="print", fin="find";
  T = new node;
  T->parent = T->left = T->right = NULL, T->key = -1;
  std::cin >> n;
  for(i=0; i<n; i++){
    std::cin >> func;
    if(func == ins){
      std::cin >> key;
      Insert(key);
    }
    else if(func == pri){
      Inorder(T); std::cout << "\n";
      Preorder(T); std::cout << "\n";
    }
    else if(func == fin){
      std::cin >> key;
      std::cout << (Find(key) ? "yes\n" : "no\n");
    }
  }
  Free(T);
  return 0;
}
void Inorder(node* X){
  if(X != NULL){
    Inorder(X->left);
    std::cout << " " << X->key;
    Inorder(X->right);
  }
}
void Preorder(node* X){
  if(X != NULL){
    std::cout << " " << X->key;
    Preorder(X->left);
    Preorder(X->right);
  }
}
void Free(node* X){
  if(X != NULL){
    Free(X->left);
    Free(X->right);
    delete X;
  }
}
void Insert(int key){
  node *x, *y, *S;
  if(T->key == -1){
    T->key = key;
    return;
  }
  S = new node;
  S->key = key;
  S->parent = S->left = S->right = NULL;
  x = T;
  while(x != NULL){
    y = x;
    if(key < x->key) x = x->left;
    else x = x->right;
  }
  S->parent = y;
  if(S->key < y->key) y->left = S;
  else y->right = S;
}
int Find(int key){
  node *X;
  for(X=T; X != NULL;){
    if(X->key > key) X = X->left;
    else if(X->key < key) X = X->right;
    else return 1;
  }
  return 0;
}

Measured memory_bytes: 21804
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
	vector<int>s, t;
	int n, q;
	cin >> n;
	for (int i = 0; i < n; i++){
		int a; cin >> a;
		s.push_back(a);
	}
	cin >> q;
	for (int i = 0; i < q; i++){
		int a; cin >> a;
		t.push_back(a);
	}
	int num = 0;
	for (int i = 0; i < q; i++){
		if (find(s.begin(), s.end(), t[i]) != s.end()) {
			num++;
		}
	}
	cout << num << endl;
	char c; cin >> c;
}

Measured memory_bytes: 3120
import java.util.*;
import java.lang.*;

class Main {
	public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        String s = sc.next();

        if(a >= 3200){
            System.out.println(s);
        } else {
            System.out.println("red");
        }


    }
}





Measured memory_bytes: 21716
l = input()
MOD = 10**9+7
dp = [[0 for i in range(len(l)+1)] for i in range(2)]
dp[0][0] = 1

for i in range(1, len(l)+1):
  if l[i-1]=="0":
    dp[0][i] = (dp[0][i]+dp[0][i-1])%MOD
    dp[1][i] = (dp[1][i]+dp[1][i-1])%MOD
    dp[1][i] = (dp[1][i]+dp[1][i-1]*2)%MOD
  else:
    dp[0][i] = (dp[0][i]+dp[0][i-1]*2)%MOD
    dp[1][i] = (dp[1][i]+dp[0][i-1])%MOD
    dp[1][i] = (dp[1][i]+dp[1][i-1])%MOD
    dp[1][i] = (dp[1][i]+dp[1][i-1]*2)%MOD

print((dp[0][len(l)]+dp[1][len(l)])%MOD)

Measured memory_bytes: 11136
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define int ll
#define pii pair<int,int>
#define fi first
#define se second
#define mp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define M 998244353

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1;

    while(t--)
    {
        int N;
        cin>>N;
        int ans=0;
        for(int i=1;i<=N;i++)
        
            for(int j=1;j<=N;j++)
                for(int k=1;k<=N;k++)
                {
                    int g=__gcd(i,j);
                    g=__gcd(g,k);
                    ans+=g;
                }
        
        cout<<ans;
    }

   return 0;

//    cout<<"Sum of x+y = " << z;
}


Measured memory_bytes: 3652
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <cmath>
using namespace std;

int main() {
    int N;
    cin >> N;
    vector<map<char,int> > mapVec;
    for(int i=0;i<N;i++){
        string str;
        cin >> str;
        map<char, int> char_map;
        for(int i=0;i<26;i++){
            char_map['a'+i] = 0;
        }
        for(int j=0;j<str.length();j++){
            char_map[str[j]] = char_map[str[j]]+1;
        }
        mapVec.push_back(char_map);
    }

    for(int i=1;i<mapVec.size();i++){
        for(auto itr=mapVec[i].begin();itr!=mapVec[i].end();itr++){
            mapVec[0][itr->first]=min(itr->second,mapVec[0][itr->first]);
        }
    }

    for(auto itr=mapVec[0].begin();itr!=mapVec[0].end();itr++){
        for(int i=0;i<itr->second;i++){
            cout << itr->first;
        }
    }

    cout << "" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
using namespace std; typedef long long ll; const int INF=1e9+7;
typedef pair<int,int> P;

int main() {
  ll a,b,c; cin>>a>>b>>c;
  ll an=b;
  an+=min(c,a+b+1);
  cout<<an<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
vector<vector<int>> c(100100,vector<int> (0));
int N;

//既に探索した部分をboolの配列で表現したところREとなった
//上記boolをやめて，一つ前のpositionをppで把握→ppを飛ばすとしても提出結果に変わりなし
//入力のN数に対して，用意していたcの配列の数が小さ過ぎました！凡ミス！
void DFS(int p,int ans,int pp,vector<int> &d){
  d.at(p)=ans;
  for(int i:c.at(p)){
    if(i==pp){continue;}
    DFS(i,ans+1,p,d);
  }
  return;
}

vector<int> dist(int p){
  vector<int> d(N);
  DFS(p,0,-1,d);
  return d;
}

int main(){
  int T,A,ans=0;
  
  cin>>N>>T>>A;
  T--;A--;
  
  int s,t;
  for(int i=0;i<N-1;i++){
    cin>>s>>t;
    s--;t--;
    c.at(s).push_back(t);
    c.at(t).push_back(s);
  }
  
  vector<int> Td(N),Ad(N);
  Td=dist(T);
  Ad=dist(A);
  
  for(int i=0;i<N;i++){
    if(Td[i]<Ad[i]){ans=max(ans,Ad[i]-1);}
  }
  cout<<ans;
}

Measured memory_bytes: 12024
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;

int main(){
	double x[20], y[20], a, b, c, s = 0.0, z;
	int i;
	for (i = 0; i < 20; i++){
		if (scanf("%lf,%lf", &x[i], &y[i]) == EOF) break;
	}
	for (int j = 1; j < i - 1; j++){
		a = sqrt((x[j] - x[0]) * (x[j] - x[0]) + (y[j] - y[0]) * (y[j] - y[0]));
		b = sqrt((x[j + 1] - x[0]) * (x[j + 1] - x[0]) + (y[j + 1] - y[0]) * (y[j + 1] - y[0]));
		c = sqrt((x[j + 1] - x[j]) * (x[j + 1] - x[j]) + (y[j + 1] - y[j]) * (y[j + 1] - y[j]));
		z = (a + b + c) / 2.0;
		s += sqrt(z * (z - a) * (z - b) * (z - c));
	}
	printf("%.5f\n",s);
	return 0;
}

Measured memory_bytes: 1240
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <cmath>
#include <iomanip>
using namespace std; 
typedef long long ll; typedef string str;

int main ()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); 
	
	ll n;
	cin >> n;
	
	str ans;
	
	while(n != 0)
	{
		n--;// why?
		ll r = n%26;
		n /= 26;
		ans.insert(ans.begin(),'a'+r);
	}
	
	cout << ans;
}


Measured memory_bytes: 3128
m=int(input())
N=input()
cnt=N.count('R')*N.count('G')*N.count('B')
#print(cnt)
for i in range(m-2):
  #print(i,'*',int((m+i)/2))
  for j in range(i+1,int((m+i-1)/2)+1):
    k=2*j-i
    #print(i,j,k)
    if N[k] != N[j] and N[j] != N[i] and N[i] != N[k]:
      #print(i,j,k)
      cnt-=1
print(cnt)

Measured memory_bytes: 67744
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp setprecision
#define pb(x) push_back(x)
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ld, ld> pdd;
const ll MOD = 1e9+7;
const ll MOD2 = 998244353;
const int inf = INT_MAX;
const ll INF = LLONG_MAX;
const string alpha = "abcdefghijklmnopqrstuvwxyz";

int main(){
    string s;
    cin >> s;
    int N = s.size();
    rep(i, N) s[i] = 'x';
    cout << s << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define rep(i, n) for(ll i = 0; i < (n); i++)
int main(){
  ll n,k;
  cin>>n>>k;
  vector<ll> v(n);
  rep(i,n) cin>>v[i];
  ll dp[n];
  rep(i,n) dp[i]=1e17;
  dp[0]=0;
  rep(i,n-1) rep(j,k) if(i>=j) dp[i+1]=min(dp[i+1],dp[i-j]+abs(v[i+1]-v[i-j]));
  cout<<dp[n-1]<<endl;
}

Measured memory_bytes: 1792
#include <iostream>

using namespace std;

int main(){
    char x, y;
    cin >> x >> y;

    if (x < y){
        cout << "<" << endl;
    }else if (x == y){
        cout << "=" << endl;
    }else{
        cout << ">" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <cstdint>
#include <cctype>
#include <numeric>
#include <bitset>
#include <functional>

using namespace std;

using ll =  long long;
using Pll = pair<ll, ll>;
using Pii = pair<int, int>;

constexpr int INF = 1 << 30;
constexpr ll LINF = 1LL << 60;
constexpr ll MOD = 1000000007;
constexpr long double EPS = 1e-10;
constexpr int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int n;
    cin >> n;
    vector<ll> a(n+1, 0LL);
    for(int i=1;i<=n;++i) {
        cin >> a[i];
    }
    vector<ll> b(a);
    for(int i=1;i<=n;++i) {
        b[i] += b[i-1];
        b[i] %= MOD;
    }

    ll ans = 0LL;
    for(int i=1;i<n;++i) {
        ans += (a[i] * (b[n] - b[i] + MOD) % MOD) % MOD;
        ans %= MOD;
    }

    cout << ans << endl;
}


Measured memory_bytes: 6364
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pll pair<long long,long long>
#define mod 1000000007
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);

ll power(ll a,ll b){
	ll ans=1;
	while(b>0){
		if(b%2!=0){
			ans=(ans*a)%mod;
		}
		a=(a*a)%mod;
		b>>=1;
	}
	return ans;
}

int main() {
	IOS;
	int t=1;
	//cin>>t;
	while(t--){
		int n,k;
		cin>>n>>k;
		int a[n];
		for(int i=0;i<n;i++)
			cin>>a[i];
		int i=0,j=0;
		int ma=0;
		int sum=0;
		while(j-i+1<=k){
			sum+=a[j];
			j++;
		}
		ma=sum;
		while(j<n){
			sum-=a[i];
			sum+=a[j];
			i++;
			j++;
			ma=max(ma,sum);
		}
		double z=ma;
		z=(z+k)/double(2);
		cout<<fixed<<setprecision(7)<<z;	
	}
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main() {
  int H, W;
  cin >> H >> W;
  vector<vector<char>> result(H * 2, vector<char>(W));
  for (int i = 0; i < H; ++i) {
    for (int j = 0; j < W; ++j) {
      char p;
      cin >> p;
      result[2*i][j] = p;
      result[2*i+1][j] = p;
    }
  }
  
  for (int i = 0; i < 2 * H; ++i) {
    for (int j = 0; j < W; ++j) {
      cout << result[i][j];
    }
    cout << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
	double n; cin >> n;
	double ans = 0.0;
	double cnt = 0.0;
	for(int i=1;i<=n;i++){
		if(i%2==1) cnt++;
	}
	ans = cnt/n;
	printf("%.10f\n", ans);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep0(i, n) for (long long i = 0; i < (long long)(n); i++)
#define rep1(i,n) for(long long i=1;i<=(long long)(n);i++)
#define all(v) v.begin(),v.end()
typedef long long ll;
#define out(i) cout<<(i)<<endl

int main() {
  int a,b;
  cin>>a>>b;
  cout<<a*b<<" "<<2*(a+b)<<endl;
}


Measured memory_bytes: 3092
#include <bits/stdc++.h>
#include<string>
using namespace std;
int main()
{
    string s;
    cin>>s;int c=0;
    int n = s.length();
    char a[n+1];
    strcpy(a, s.c_str());
    char b[2];
    for(int i=0;i<n;i++)
    {
        if(i==2){b[0]=a[i];}
        if(i==4){b[1]=a[i];}
        if(i==3 && b[0]==a[i]){c++;}
        if(i==5 && b[1]==a[i]){c++;}
    }
    if(c==2)
    cout<<"Yes"<<endl;
    else
    cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<queue>
#include<string.h>
using namespace std;
int a[100];
int main()
{
    int n,m;
    while(~scanf("%d%d",&n,&m),(n+m))
    {
        memset(a,0,sizeof(a));
        int ans=m,k=0,flag=0;
        while(1)
        {
            for(int i=0; i<n; i++)
            {
                if(ans>0)
                {
                    ans--;
                    a[i]++;
                }
                else
                {
                    if(a[i]>0)
                    {
                        ans=a[i];
                        a[i]=0;
                    }
                }
                if(a[i]==m)
                {
                    k=i;
                    flag=1;
                    break;
                }
            }
            if(flag==1)
                break;
        }
        printf("%d\n",k);
    }
    return 0;
}



Measured memory_bytes: 2600
#include <bits/stdc++.h>
using namespace std;

using ll = long long;
using ull = unsigned long long;
#define repi(n) for (long long i = 0; i < (n); ++i)
#define repj(n) for (long long j = 0; j < (n); ++j)
#define repk(n) for (long long k = 0; k < (n); ++k)
#define rep(i, a, b) for (auto i = (a); i < (b); ++i)
#define itr(itr) for (auto&& v : (itr))
#define updatemax(t, v) (t = std::max(t, (v)))
#define updatemin(t, v) (t = std::min(t, (v)))

vector<int> g[50];
bool isOnPath[50][50][50][50];  // 辺i-jがパスk-lに含まれるか

void addToIsOnPath(int i, int j, int k, int l) {
  // if (!isOnPath[i][j][k][l]) cout << "added:" << i << "-" << j << " [" << k << "-" << l << "]" << endl;
  isOnPath[i][j][k][l] = true;
  isOnPath[i][j][l][k] = true;
  isOnPath[j][i][k][l] = true;
  isOnPath[j][i][l][k] = true;
}
set<int> dfs(int p, int parent, int root) {
  vector<int> childs;
  vector<set<int>> sets;
  itr(g[p]) {
    if (v == parent) continue;
    childs.push_back(v);
    sets.push_back(dfs(v, p, root));
  }
  set<int> res;
  res.insert(p);
  repi(childs.size()) itr(sets[i]) res.insert(v);
  itr(res) if (parent >= 0) addToIsOnPath(parent, p, root, v);
  return res;
}

pair<int, int> constraints[20], edges[50];
int main() {
  int n, m;
  cin >> n;
  repi(n - 1) {
    int a, b;
    cin >> a >> b;
    --a;
    --b;
    g[a].push_back(b);
    g[b].push_back(a);
    edges[i] = {a, b};
  }
  cin >> m;
  repi(m) {
    cin >> constraints[i].first >> constraints[i].second;
    --constraints[i].first;
    --constraints[i].second;
  }
  repi(n) dfs(i, -1, i);
  ll res = 0;
  repi(1 << m) {
    int popn = 0;
    repj(m) if ((i >> j) & 1) popn++;
    ll rp = popn % 2 ? -1 : 1;
    repj(n - 1) {
      auto edge = edges[j];
      bool free = true;
      repk(m) {
        if (!((i >> k) & 1)) continue;
        auto constraint = constraints[k];
        if (isOnPath[edge.first][edge.second][constraint.first][constraint.second]) {
          free = false;
          break;
        }
      }
      if (free) rp *= 2;
    }
    // cout << "i:" << i << " rp:" << rp << endl;
    res += rp;
  }
  cout << res << endl;
}


Measured memory_bytes: 4208
a = list()
b = list()
for i in range(0,5):
    a.append(int(input()))
    b.append(a[i] % 10)

while True:
    if 0 in b:
        b.remove(0)
        b.append(10)
    else:
        break

print(sum(a)-sum(b)+40+min(b))

Measured memory_bytes: 3060
use proconio::{fastout, input};

#[fastout]
fn main() {
  input! {
    n:usize,
    mut d:[u32;n]
  }
  let dd: &mut [u32] = &mut d;
  dd.sort_by(|a, b| b.cmp(a));
  let mut v: Vec<u32> = vec![dd[0]];
  for i in 1..dd.len() {
    if dd[i] != dd[i - 1] {
      v.push(dd[i]);
    }
  }
  println!("{}", v.len());
}


Measured memory_bytes: 2168
#include <bits/stdc++.h>
using namespace std;
void debug() {cout<<endl;}
template<typename T,typename... Args>
void debug(T x,Args... args) {cout<<x<<" ";debug(args...);}
#define forn(i,a,b) for(int i=a;i<b;++i)
#define pb push_back
#define F first
#define S second
#define endl "\n"
typedef long long ll;
typedef pair<int, int> pii;

const int N = 17, M = 1<<N;
ll dp[M], cost[M];
int n, val[N][N];

ll f(int mask){
  if(mask == 0)return 0;
  ll &ans = dp[mask];
  if(ans != -1)return ans;
  ans = 0;
  for(int sub = mask; sub; sub = (sub-1)&mask){
    ans = max(ans, f(mask^sub)+cost[sub]);
  }
  return ans;
}

int main() {
  ios::sync_with_stdio(0); cin.tie(0);
  
  cin >> n;

  forn(i, 0, n){
    forn(j, 0, n){
      cin >> val[i][j];
    }
  }

  int mask = 1 << n;
  forn(sub, 0, mask){
    ll sum = 0;
    forn(i, 0, n){
      if(!(sub >> i & 1))continue;
      forn(j, i+1, n){
        if(!(sub >> j & 1))continue;
        sum += val[i][j];
      }
    }
    cost[sub] = sum;
  }
  
  memset(dp, -1, sizeof dp);
  cout << f(mask-1) << endl;



}





Measured memory_bytes: 5160
#include <bits/stdc++.h>
using namespace std;

int main(){
  int N; cin >> N;
  vector <int> V(N);
  
  for (int i = 0; i<N; ++i){
    cin >> V[i];
  }
  
  vector <int> C(N);
  for (int i=0; i<N; ++i){
    cin >> C[i];
  }
  
  int ans = 0;
  for (int i=0; i<N; ++i){
    if (V[i] > C[i]){
      ans += V[i] - C[i];
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, e) for(int (i) = 0; (i) < (e); ++(i))
#define FOR(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define ALL(c) (c).begin(), (c).end()
#define PRINT(x) cout << (x) << "\n"
using namespace std;
using ll = long long; using pint = pair<int, int>; using pll = pair<ll, ll>;
template<typename T> auto compare = [](T x, T y) -> bool{return (x < y);};
const long long MOD = 1000000007;

signed main(){
    int X;
    cin >> X;
    X -= 400;
    PRINT(8 - X / 200);
    return 0;
}

Measured memory_bytes: 3632
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<math.h>
#include<tuple>
#include<cctype>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repp(i,j,n) for (int i = (j); i < (n); i++)
#define Reo(i,j,n) for(int i=(j); i <= (n); i++)
using namespace std;
typedef long long ll;
int main() {
	ll n, m;
	cin >> n >> m;
	vector<ll>h(n);
	for(ll i=0;i<n;i++)cin >> h[i];
	vector<ll>a(m), b(m);
	for (ll i = 0; i < m; i++)cin >> a[i] >> b[i];
	vector<bool>flag(n , true);
	for (ll i = 0; i < m; i++) {
		if (h[a[i]-1] > h[b[i]-1] ) {
			flag[b[i]-1] = false;
		}
		else if (h[b[i]-1]>h[a[i]-1]) {
			flag[a[i]-1] = false;
		}
		else if(h[a[i]-1]==h[b[i]-1]) {
			flag[a[i]-1] = false;
			flag[b[i]-1] = false;
		}
	}
	ll ans = 0;
	for (ll i = 0; i < n; i++) {
		if (flag[i])ans++;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 5636
#include<bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
const int inf=1e9;
const ll Inf=1e18;
const int mod=1e9+7;
const int N=1e5+10;
int gi() {
    int x=0,o=1;char ch=getchar();
    while((ch<'0'||ch>'9')&&ch!='-') ch=getchar();
    if(ch=='-') o=-1,ch=getchar();
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    return x*o;
}
template<typename T> bool chkmax(T &a,T b) { return a<b?a=b,1:0; };
template<typename T> bool chkmin(T &a,T b) { return a>b?a=b,1:0; };
int add(int a,int b) { return a+b>=mod?a+b-mod:a+b; }
int sub(int a,int b) { return a-b<0?a-b+mod:a-b; }
void inc(int &a,int b) { a=(a+b>=mod?a+b-mod:a+b); }
void dec(int &a,int b) { a=(a-b<0?a-b+mod:a-b); }
int n,m,a[N],f[20][N],fac[N],inv[N],ifac[N];
int C(int n,int m) {
    if(n<0||m<0||n<m) return 0;
    return 1ll*fac[n]*ifac[m]%mod*ifac[n-m]%mod;
}
int main() {
    cin>>n>>m;
    for(int i=1;i<=m;i++) a[i]=gi();
    sort(a+1,a+m+1);
    fac[0]=1;for(int i=1;i<N;i++) fac[i]=1ll*fac[i-1]*i%mod;
    inv[1]=1;for(int i=2;i<N;i++) inv[i]=1ll*(mod-mod/i)*inv[mod%i]%mod;
    ifac[0]=1;for(int i=1;i<N;i++) ifac[i]=1ll*ifac[i-1]*inv[i]%mod;
    f[m+1][0]=1;
    for(int i=m;i;i--)
        for(int j=0;j<(1<<n);j++) {
            inc(f[i][j],f[i+1][j]);
            int p=(1<<n)-j;
            for(int k=0;k<n;k++) if(!(j>>k&1)) inc(f[i][j|(1<<k)],1ll*f[i+1][j]*C(p-a[i],(1<<k)-1)%mod*fac[1<<k]%mod);
        }
    int ans=0;
    for(int i=0;i<(1<<n);i++) {
        int t=__builtin_popcount(i);
        inc(ans,1ll*f[1][i]*fac[(1<<n)-1-i]%mod*((t&1)?mod-1:1)%mod);
    }
    ans=1ll*ans*(1<<n)%mod;
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 7936
N=int(input())
S=input()
ans=S.count("R")*S.count("G")*S.count("B")
for i in range(N):
    for j in range(i+1,N):
        k=2*j-i
        if k<N and S[k]!=S[i] and S[k]!=S[j] and S[j]!=S[i]:
            ans-=1
print(ans)

Measured memory_bytes: 9196
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func max(a int, b int) int {
	if a > b {
		return a
	}
	return b
}

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Scan()
	input := strings.Split(scanner.Text(), " ")
	var args [4]int
	for i, str := range input {
		args[i], _ = strconv.Atoi(str)
	}
	candidates := [4]int{args[0] * args[2], args[0] * args[3], args[1] * args[2], args[1] * args[3]}
	var result int = candidates[0]
	for _, c := range candidates {
		result = max(result, c)
	}
	fmt.Printf("%d", int(result))
}


Measured memory_bytes: 1744
N = int( input())
D = list( map( int, input().split()))
D.sort()
ans = 24
c = 1
A = []
B = []
now = 0
for i in range(N):
    if D[i] == now:
        c += 1
    if c == 2:
        ans = 0
    if i%2 == 0:
        A.append(D[i])
    else:
        B.append(D[i])
s = 0
if A:
    for a in A:
        ans = min(ans, a-s)
        s = a
s = 0
if B:
    for b in B:
        ans = min(ans, b-s)
        s=b
if A and B:
    ans = min( ans, 24-A[-1]-B[-1], A[-1]+B[-1])
print(ans)

Measured memory_bytes: 3064
#include<stdio.h>
#include<string.h>
#include<algorithm>
#define INF 1000000000

int N,W,dp[105][20005],v[105],w[105],i,j;

int dfs(int d,int nw)
{
	if(dp[d][nw]>0)return dp[d][nw];
	if(nw>W)return -INF;
	if(d==N)return 0;
	return dp[d][nw]=std::max(dfs(d+1,nw),dfs(d+1,nw+w[d])+v[d]);
}


int main()
{
	memset(dp,-1,sizeof(dp));
	scanf("%d%d",&N,&W);
	for(i=0;i<N;i++)scanf("%d%d",&v[i],&w[i]);
	//for(i=N;i>=0;i--)
	//{
	//	for(j=0;j<=W;j++)
	//	{
	//		if(i==N)dp[i][j]=0;
	//		else if(j<w[i])dp[i][j]=dp[i+1][j];
	//		else dp[i][j]=std::max(dp[i+1][j],dp[i+1][j-w[i]]+v[i]);
	//	}
	//}
	//printf("%d\n",dp[0][W]);
	printf("%d\n",dfs(0,0));
	return 0;
}

Measured memory_bytes: 9240
// https://atcoder.jp/contests/agc003/tasks/agc003_c

#include "algorithm"
#include "bitset"
#include "cmath"
#include "functional"
#include "iomanip"
#include "iostream"
#include "map"
#include "numeric"
#include "queue"
#include "set"
#include "string"
#include "vector"
#define rep(i, to) for (ll i = 0; i < (to); ++i)
#define rep1(i, to) for (ll i = 1; i <= (to); ++i)
#define repf(i, from, to) for (ll i = from; i < (to); ++i)
#define repr(i, from) for (ll i = from - 1; i >= 0; --i)
#define all(vec) vec.begin(), vec.end()
#define unless(cond) if (!(cond))
#define fi first
#define se second
using namespace std;
typedef long long ll;
template <typename T>
using V = vector<T>;
using VL = V<ll>;
using VVL = V<VL>;
template <typename T, typename U>
using P = pair<T, U>;
using PL = P<ll, ll>;
using VPL = V<PL>;
template <typename T>
inline bool chmax(T& a, T b);
template <typename T>
inline bool chmin(T& a, T b);
void print_ints(vector<ll> v);
template <typename T>
void drop(T a);

const ll INF = 1e18;

void solve() {
  ll N;
  cin >> N;

  VL as(N);
  rep(i, N) cin >> as[i];

  // 座標圧縮
  {
    VL bs(N);
    rep(i, N) bs[i] = as[i];

    sort(all(bs));

    rep(i, N) {
      ll a_i = lower_bound(bs.begin(), bs.end(), as[i]) - bs.begin();
      as[i] = a_i;
    }
  }

  ll diff_ct = 0;
  for (ll i = 0; i < N; i += 2) {
    if (as[i] % 2 == 1) diff_ct++;
  }

  cout << diff_ct << endl;
}

struct exit_exception : public std::exception {
  const char* what() const throw() { return "Exited"; }
};

#ifndef TEST
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  try {
    solve();
  } catch (exit_exception& e) {
  }

  return 0;
}
#endif

template <typename T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

template <typename T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

void print_ints(vector<ll> v) {
  rep(i, v.size()) {
    if (i > 0) {
      cout << " ";
    }

    cout << v[i];
  }

  cout << endl;
}

template <typename T>
void drop(T res) {
  cout << res << endl;
  throw exit_exception();
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int s[100001],t[100001];
int main() {
	string S,T;
	cin>>S>>T;
	for(int i=0;i<S.size();i++) {
		if(S[i]=='A') s[i+1]=2; else s[i+1]=1;
	}
	for(int i=1;i<=S.size();i++) {
		s[i]=(s[i]+s[i-1])%3;
	}
	for(int i=0;i<T.size();i++) {
		if(T[i]=='A') t[i+1]=2; else t[i+1]=1;
	}
	for(int i=1;i<=T.size();i++) {
		t[i]=(t[i]+t[i-1])%3;
	}
	int q;
	cin>>q;
	for(int i=0;i<q;i++) {
		int a,b,c,d;
		cin>>a>>b>>c>>d;
		if((s[b]-s[a-1]+3)%3==(t[d]-t[c-1]+3)%3) {
			cout<<"YES"<<endl;
		}else {
			cout<<"NO"<<endl;
		}
	}
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
#define rep(i, n) for (lli i = 0; i < (n); i++)
#define rrep(i, n) for (lli i = (n)-1; i >= 0; i--)
using namespace std;
using lli = long long int;
#define int long long int
void YESNO(bool), YesNo(bool);
template <class T1, class T2>
bool chmin(T1 &l, const T2 &r);
template <class T1, class T2>
bool chmax(T1 &l, const T2 &r);
lli dp[3005][3005] = {};
// dp[x][y] 先頭からx, 最後にy個取られた状態からスタートしたときの結果
// x+y+1番目の行動 x+y+1が奇数のとき 太郎くんが動く.
// dp[x+1][y]またはdp[x][y+1]に遷移
// dp[x][y] := max(dp[x+1][y]+a[x], dp[x][y+1]+a[n-1-y]) if x+y+1 is odd
// dp[x][y] := min(dp[x+1][y]-a[x], dp[x][y+1]-a[n-1-y]) if x+y+1 is even
int n;
vector<lli> a;
lli f(int x, int y)
{
  if (x + y == n)
    return 0;
  if (dp[x][y] != 1e18)
    return dp[x][y];
  if ((x + y) & 1)
    dp[x][y] = min(f(x + 1, y) - a[x], f(x, y + 1) - a[n - 1 - y]);
  else
    dp[x][y] = max(f(x + 1, y) + a[x], f(x, y + 1) + a[n - 1 - y]);
  return dp[x][y];
}
void solve(long long N)
{
  n = N;
  rep(i, N + 1) rep(j, N + 1) dp[i][j] = 1e18;
  cout << f(0, 0) << endl;
}

signed main()
{
  long long N;
  scanf("%lld", &N);
  a.resize(N);
  for (int i = 0; i < N; i++)
  {
    scanf("%lld", &a[i]);
  }
  solve(N);
  return 0;
}

// -- lib
void YESNO(bool b) { cout << (b ? "YES" : "NO") << endl; }
void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; }

template <class T1, class T2>
bool chmin(T1 &l, const T2 &r)
{
  return (l > r) ? (l = r, true) : false;
}

template <class T1, class T2>
bool chmax(T1 &l, const T2 &r)
{
  return (l < r) ? (l = r, true) : false;
}


Measured memory_bytes: 70912
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl "\n"

int main() {
	string s;
	cin>>s;
	auto it = s.end();
	char e = *(it-1);
	if(e=='s'){
		cout<<s;
		cout<<"es";
	} else {
		cout<<s<<"s";
	}

	return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const LL mod=1e9+7;
/*
51nod1785
好像set可以，
主要是中位数？我太年轻了。
要10的8次？
sum(a[i]-平均值sum(a[i]))^2/n
好像是数学题啊~
*/
const int N=1e5+10;
LL n;
int a[N];
LL f[N];
void init()
{
    f[0]=1;
    for(LL i=1;i<=100000;i++)
        f[i]=f[i-1]*i%mod;
}

int main()
{
    init();
    scanf("%lld",&n);
    for(int i=1;i<=n;i++)
        scanf("%d",&a[i]);
    LL ans=1;
    LL nn=0;
    LL b=1;
    LL num=0;
    for(LL i=2;i<=n;i++)
    {
        if(b+2<=a[i])
            b=b+2;
        else
        {
            ans=ans*(i-num)%mod;
            num++;
        }
//        printf("%d\n",b);
    }
//    printf("%lld\n",num);
    ans=ans*f[n-num]%mod;
    printf("%lld\n",ans);
    return 0;
}
/*

*/


Measured memory_bytes: 1408
#include<stdio.h>

int Bis(int a, int b, int c){
  int i;
  int sum = 0;

   for(i = 1; i <= c; i++){
     if(i % a == 0){
       sum += b;
     }
   }
   printf("%d\n",sum);

}

int main(){

  int A,B,T;
    scanf("%d",&A);
    scanf("%d",&B);
    scanf("%d",&T);
  
  Bis(A,B,T);

  return 0;
  

}

Measured memory_bytes: 128
#include <bits/stdc++.h>
//#include <tr1/unordered_map>
#define debug(x) (cout << "#x = " << (x) << endl)
#define lowbit(x) (x & -x)
#define Set(x, i) memset(x, i, sizeof x)
#define R register
#define For( i, j, k ) for(R int i = (j); i <= (k); ++i)
#define Rep( i, j, k ) for(R int i = (j); i >= (k); --i)
#define Cross( i, j, k ) for(R int i = (j); i; i = (k))
typedef long long ll;
using namespace std;
const ll N = 100011;
const ll INF = 5e16;

namespace IO {

	#define dd ch = getchar()
	inline ll read() {
		ll x = 0; bool f = 0; char dd;
		for (; !isdigit (ch); dd) f ^= (ch == '-');
		for (; isdigit (ch); dd)  x = x * 10 + (ch ^ 48);
		return f? -x: x;
	}
	#undef dd

	inline void write ( ll x ) {
		if (x < 0) putchar ('-'), x = -x;
		if (x > 9) write (x / 10); putchar (x % 10 | 48);
	}

	inline void wrn ( ll x ) { write(x); putchar (' '); }

	inline void wln ( ll x ) { write(x); putchar ('\n'); }

	inline void wlnn ( ll x, ll y ) { wrn(x); wln (y); }

}

using namespace IO;

namespace Cesare {
	
	int main() {
		ll n = read();
		return wln(ceil(n / 2.0) - 1), 0;
	}
	
}

int main()
{
	return Cesare :: main();
}

/*

*/



Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<stack>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<bitset>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define eFOR(i,a,n) for(ll (i)=(a);(i)<=(n);(i)++)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
constexpr auto INF = 1000000000;
constexpr auto LLINF = 1LL << 62;
constexpr auto mod = 1000000007;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; }return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; }return 0; }

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll n, k;
    cin >> n >> k;
    
    ll ans = 0;
    eFOR(i, 1, n) {
        ans += (n / i) * (max(i - k, 0LL));
        if (n % i)ans += max(n % i - k + 1, 0LL) - (!k ? 1 : 0);
    }
    cout << ans << "\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdio.h>

using namespace std;
#define inputInt(a) int a; cin >> a; 
#define inputInt2(a,b) int a; int b; cin >> a >> b; 
#define inputInt3(a,b,c) int a; int b; int c; cin >> a >> b >> c;
#define inputLong(a) long a;cin >> a; 
#define inputIntArray(a,N) int a[N];for(int i=0;i<N;i++){cin >> a[i];}
#define inputLongArray(a,N) long a[N];for(int i=0;i<N;i++){cin >> a[i];}
#define inputIntArray2(a,b,N) int a[N]; int b[N]; for(int i=0;i<N;i++){cin >> a[i] >> b[i];}
#define output(answer) cout << answer << endl;
#define fN(i,N)    for(int i=0; i<N; i++)
#define fSE(i,s,e) for(int i=s; i<=e; i++)
#define ll long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define FOR(i,N) for(int i=0; i<N; i++)
#define cinv(v,N) vector<int> v(N); for(int i=0; i<N; i++){ cin >> v[i]; }
#define mt make_tuple
const ll MOD2 = 998244353;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main()
{
  //input
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  ll N, A, B; cin >> N >> A >> B;
  
  //main
  if((abs(A-B))%2 == 0){
    cout << (abs(A-B))/2 << endl;
  }else{
    if(A>B){
      ll C = 0;
      C = A; A = B; B = C;
    }else{
      
    }
    
    if(A-1 <= N-B){
      cout << A+(B-A-1)/2 << endl;
    }else{
      cout << (N-B+1)+(N-(A+N-B+1))/2 << endl; 
    }
    
  }
  
  // output

  return 0;
}

Measured memory_bytes: 256
#include <memory.h>

#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>

using namespace std;

#define mod 1000000007

int main() {
	int x;
	cin >> x;
	long long int ans = 0;
	ans += 1000 * (x / 500);
	x %= 500;
	ans += 5 * (x / 5);
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define INF 1<<30
#define endl '\n'
#define maxn 100005
#define tc printf("Case %d: ", cs)
#define tcn printf("Case %d:\n", cs);
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
typedef long long ll;
const double PI = acos(-1.0);
#define dbg(x) cerr << #x << " = " << x << endl;
#define dbg2(x, y) cerr << #x << " = " << x << ", " << #y << " = " << y << endl;
#define dbg3(x, y, z) cerr << #x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << endl;
#define dbg4(w,x, y, z) cerr << #w << " = " << w << ", " <<#x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << endl;


int main()
{
    FASTIO
    /*
    //double start_time = clock();
#ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    freopen("error.txt", "w", stderr);
#endif
//*/
    int T;
    //cin >> T;
    T = 1;
    for (int cs = 1; cs <= T; cs++) {
        int n;
        cin >> n;
        vector<int> v(n);
        for (int i = 0; i < n; i++) cin >> v[i];
        int cnt = 0, ans = 0;
        for (int i = 0; i < n - 1; i++) {
            if (v[i] >= v[i + 1]) cnt++;
            else cnt = 0;
            ans = max(ans, cnt);
        }
        cout << ans << endl;
    }

    //double end_time = clock();
    //printf( "Time = %lf ms\n", ( (end_time - start_time) / CLOCKS_PER_SEC)*1000);
    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define N 100010
#define pp pair<int,int>
#define fi first
#define se second
using namespace std;
map<pp,int>Map;

int fa[N];
int Find(int x){return fa[x]==x?x:fa[x]=Find(fa[x]);}

int deg[N];

vector<int>q[N],G;

int tag[N];
pp ans[N];
int cnt;
int DFS(int x,int fa){
	// cout<<"!!"<<x<<" "<<fa<<endl;
	int sum=tag[x];
	for(int i=0;i<(int)q[x].size();i++){
		int to=q[x][i];
		if(to==fa)continue;
		sum^=DFS(to,x);
	}
	if(fa!=-1){
		if(Map[pp(fa,x)]){
			if(sum)printf("%d %d\n",x,fa);
			else printf("%d %d\n",fa,x);
		}
		else {
			if(sum)printf("%d %d\n",fa,x);
			else printf("%d %d\n",x,fa);
		}
	}
	return sum;
}
int main(){
	int n,m,a,b;
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)fa[i]=i;
	for(int i=1;i<=m;i++){
		scanf("%d%d",&a,&b);
		Map[pp(a,b)]=1;
		int g1=Find(a),g2=Find(b);
		if(g1!=g2)fa[g1]=g2,q[a].push_back(b),q[b].push_back(a);
		else ans[++cnt]=pp(a,b);
		deg[a]^=1;
	}
	for(int i=1;i<=n;i++)if(deg[i])G.push_back(i);
	if(G.size()%2!=0)return 0*printf("-1\n");
	for(int j=0;j<(int)G.size();j+=2){
		int to1=G[j],to2=G[j+1];
		tag[to1]^=1,tag[to2]^=1;
	}
	for(int i=1;i<=cnt;i++)printf("%d %d\n",ans[i].fi,ans[i].se);
	DFS(1,-1);
	return 0;
}

Measured memory_bytes: 26880
#include <bits/stdc++.h>
#define ft first
#define sc second
#define pt(sth) cout << sth << "\n"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
template<class T>bool chmax(T &a, const T &b) {if(a<b) {a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) {if(b<a) {a=b; return 1;} return 0;}
static const ll INF=1e18;
static const ll MAX=101010;
static const ll MOD=1e9+7;
//for(i=0; i<N; i++) cin >> a[i];


// D - Line++
class Edge {
public:
  ll t, w;
  Edge() {}
  Edge(ll t, ll w): t(t), w(w) {}
};

ll N, M;
vector<Edge> g[2222];
ll d[2222][2222];

void dijkstra(ll s) {
  ll i, u;
  ll clr[2222]={};
  priority_queue<pll> q;
  for(i=0; i<N; i++) d[s][i]=INF;
  d[s][s]=0;
  q.push({0, s});
    
  while(q.size()) {
    ll du=-q.top().ft;
    ll u=q.top().sc;
    q.pop();
    
    if(clr[u]) continue;
    clr[u]=1;
    
    for(i=0; i<g[u].size(); i++) {
      Edge e=g[u][i];
      
      chmin(d[s][e.t], du+e.w);
      q.push({-d[s][e.t], e.t});
    }
  }
}

int main(void) {
  ll i, j, k;
  
  ll X, Y;
  cin >> N >> X >> Y;
  X--; Y--;
  
  for(i=0; i<N-1; i++) {
    g[i].push_back(Edge(i+1, 1));
    g[i+1].push_back(Edge(i, 1));
  }
  
  g[X].push_back(Edge(Y, 1));
  g[Y].push_back(Edge(X, 1));
  
  for(i=0; i<N; i++) dijkstra(i);
  
  ll cnt[2222]={};
  for(i=0; i<N; i++) for(j=i+1; j<N; j++) cnt[d[i][j]]++;
  
  for(i=1; i<N; i++) pt(cnt[i]);
  
  
  
}




Measured memory_bytes: 38472
s['~~'];char*p,*q=s;c,a;main(){for(q+=read(0,p=s,1e6)-1;p<q;c--,p++)if(*p-'x'){for(;*--q-*p;c++)*q-'x'?c=a=-1,p=q-1:0;a+=fabs(c);c=1;}printf("%d",a);}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int max = 0;
		int N = scan.nextInt();
		int[] a = new int[N];
		int[] X = new int[100002];
		for(int i = 0; i < N; i++) {
			a[i] = scan.nextInt();
			X[a[i] - 1 + 1]++;
			X[a[i] + 1]++;
			X[a[i] + 1 + 1]++;
		}
		for(int i = 1; i < X.length; i++) {
			max = Math.max(X[i], max);
		}
		System.out.println(max);
		scan.close();

	}

}


Measured memory_bytes: 56388
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pint;

int main(){
    int a,b;
    cin>>a>>b;
    if(a+b<10) cout<<a+b<<endl;
    else cout<<"error"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T> void assign(V<T>& v, int n, const T& a = T()) { v.assign(n, a); }
template<class T, class... U> void assign(V<T>& v, int n, const U&... u) { v.resize(n); for (auto&& i : v) assign(i, u...); }

int main() {
  cin.tie(NULL); ios::sync_with_stdio(false);
  string s; cin >> s;
  string t = "CODEFESTIVAL2016";
  int res = 0;
  for (int i = 0; i < 16; i++) res += s[i] != t[i];
  cout << res << '\n';
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin>>N;
  map<int, int> toukou;
  for(int i=0; i<N; i++){
    int d;
    cin>>d;
    toukou[d]=i+1; //登校した順番に出席番号
  }
  cout << toukou[1];
  toukou.erase(1);
  for (auto p : toukou) {
    auto v = p.second;
    cout<< " " <<v;
  }
}


Measured memory_bytes: 5504
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

void
solver(long long n)
{
    long long q = (long long)sqrt((double)n);

    for (q; q>0; q--) {
        if (n%q==0) {
            printf("%lld\n", n/q-1+q-1);
            return;
        }
    }
}

int
main(int argc, char *argv[])
{
    long long n;

    scanf("%lld", &n);
    solver(n);
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9 + 7);

int main(void) {
	ll a;
	string b;
	cin >> a >> b;
	
	ll base = 100;
	ll bs = 0;
	for(int i = 0; i < (int)b.size(); ++i) {
		if( b[i] == '.' ) continue;
		
		if( b[i] != '0' ) bs += base * (int)(b[i] - '0');
		
		base /= 10;
	}
	
	cout << (a * bs) / 100 << endl;
	
	return 0;
}


Measured memory_bytes: 3592
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<bitset>
#include<queue>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
typedef long long ll;
int main(){
	ll n,k;
	cin >> n>>k;
	ll ans = 0;
	if (k==0) ans = n*n;
	else {
		FOR(i,k+1,n+1){
		//	if ((n-k)%i==0){
		//		ans += ((n-k)/i)*(i-k);
		//	}
		//	else {
				ll sub = (n-k)/i + 1;
				ans += sub*(i-k);
				ll subb = sub*i-n-1;
				if (subb>0) ans -= subb;
		//	}
		//	cout << ans << " " << subb << endl;
		}
	}

	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;

int main() {
  int N;
  long K;
  cin >> N >> K;
  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
    A.at(i)--;
  }
  
  vector<vector<int>> DP(63, vector<int>(N));
  for (int i = 0; i < N; i++) {
    DP.at(0).at(i) = A.at(i);
  }
  for (int i = 0; i + 1 < 63; i++) {
    for (int j = 0; j < N; j++) {
      DP.at(i + 1).at(j) = DP.at(i).at(DP.at(i).at(j));
    }
  }
  
  int now = 0;
  for (int i = 0; i < 63; i++) {
    if (K >> i & 1L) now = DP.at(i).at(now);
  }
  cout << now + 1 << "\n";
}

Measured memory_bytes: 54220
#include <bits/stdc++.h>
using namespace std;

int main(){
    long long int n;
    cin >> n;
    long long int sum = 0;

    for(int i = 1; i <= n; i++){
        if(i % 3 != 0 && i % 5 != 0){
            sum += i;
            //cout << i << endl;
        }
        /*if(i % 5 != 0){
            sum += i;
            cout << i << endl;
        }*/
    }

    cout << sum << endl;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
#define _MACRO(_1, _2, _3, NAME, ...) NAME
#define _repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define _rep(i,n) _repl(i,0,n)
#define rep(...) _MACRO(__VA_ARGS__, _repl, _rep)(__VA_ARGS__)
#define pb push_back
#define all(x) begin(x),end(x)
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#ifdef LOCAL
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cerr<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cerr<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream &o, const pair<T,U> &p){o<<"("<<p.first<<","<<p.second<<")";return o;}
template<class T> ostream& operator<<(ostream &o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}
#else
#define dbg(...) {}
#endif

bool solve(){
  int n;
  cin>>n;
  vector<string> v(n);
  rep(i,n) cin>>v[i];

  rep(i,1,n){
    rep(j,i) if(v[j]==v[i]) return false;
    if(v[i-1].back() != v[i][0]) return false;
  }

  return true;
}

int main(){
  cout << (solve() ? "Yes" : "No") << endl;
  return 0;
}


Measured memory_bytes: 256
n= input()
a=list(map(int,input().split()))
b=set()
b.update(a)
if(int(n)%2==0):
    q=len(b)
else:
    q=len(b)-1
if ( int(q)!= int(int(n)/2) or list(a).count(0) >1):
    print(0)
else:
    print(2**q%(10**9+7))

Measured memory_bytes: 14008
#include <stdio.h>
#include <iostream>
#include <stdlib.h>
#include <string.h>
#include <algorithm>
#include <vector>
#include <queue>
#include <math.h>
using namespace std;

//vector <pair <long long int,int>> p[8];
int n,m;
int main(void)
{
    cin >> n >> m;    
    if(n%m == 0){
        cout << 0;
    }else{
        cout << 1;
    }
    return 0;

}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    string s;
    cin>>s;
    int cont=0;
    for(int i=0;i<s.size();i++){
        if(s[i]!=s[s.size()-1-i])
            cont++;
    }
    cout<<cont/2<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	    ll n,k;
	    cin>>n>>k;
	    string s,s1;
	    cin>>s;
	    s1=s;
	    ll k1=k;
	    if(n==1)
	    {
	    	cout<<"0";
	    	return 0;
	    }
	    if(n==2)
	    {
	    	cout<<"1";
	    	return 0;
	    }
	    for(ll i=0;i<n;i++)
	    {
	    	ll l=i;
	    	ll r=i;
	    	if(k>0 && s[i]=='L')
	    	{
	    		while(r< n && s[r]=='L')
	    			r++;
	    		i=r-1;
	    		for(ll j=l;j<r;j++)
	    			s[j]='R';
	    		k--;
	    	}
	    }
	    for(ll i=0;i<n;i++)
	    {
	    	ll l=i;
	    	ll r=i;
	    	if(k1>0 && s1[i]=='R')
	    	{
	    		while(r<n && s1[r]=='R')
	    			r++;
	    		i=r-1;
	    		for(ll j=l;j<r;j++)
	    		{
	    			s1[j]='L';
	    		}
	    		k1--;
	    	}
	    }
	    ll count=0;
	    ll count1=0;
	    if(s[0]=='R' && s[1]=='R')
	    	count++;
	    if(s[n-1]=='L' && s[n-2]=='L')
	    	count++;
	    for(ll i=1;i<(n-1);i++)
    	{
    		if(s[i]=='L' && s[i-1]=='L')
    			count++;
    		if(s[i]=='R' && s[i+1]=='R')
    			count++;
    	}
	    if(s1[0]=='R' && s1[1]=='R')
	    	count1++;
	    if(s1[n-1]=='L' && s1[n-2]=='L')
	    	count1++;
	    for(ll i=1;i<(n-1);i++)
    	{
    		if(s1[i]=='L' && s1[i-1]=='L')
    			count1++;
    		if(s1[i]=='R' && s1[i+1]=='R')
    			count1++;
    	}
    	cout<<max(count,count1);
}

Measured memory_bytes: 512
A=[int(i) for i in input().split()]
B=[0]*3
B[0]=abs(A[1]-A[0])+abs(A[2]-A[0])
B[1]=abs(A[2]-A[1])+abs(A[0]-A[1])
B[2]=abs(A[0]-A[2])+abs(A[1]-A[2])
print(min(B))

Measured memory_bytes: 3064