akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;

const int mod = 998244353;
template<typename T>
T add(T x) {
  return x;
}
template<typename T, typename... Ts>
T add(T x, Ts... y) {
  T res = x + add(y...);
  if (res >= mod)
    res -= mod;
  return res;
}
template<typename T, typename... Ts>
T sub(T x, Ts... y) {
  return add(x, mod - add(y...));
}
template<typename T, typename... Ts>
void udd(T &x, Ts... y) {
  x = add(x, y...);
}
template<typename T>
T mul(T x) {
  return x;
}
template<typename T, typename... Ts>
T mul(T x, Ts... y) {
  return (x * 1ll * mul(y...)) % mod;
}
template<typename T, typename... Ts>
void uul(T &x, Ts... y) {
  x = mul(x, y...);
}
int bin(int a, ll deg) {
  int r = 1;
  while (deg) {
    if (deg & 1)
      uul(r, a);
    deg >>= 1;
    uul(a, a);
  }
  return r;
}
int inv(int x) {
  assert(x);
  return bin(x, mod - 2);
}

const int maxn = 200200;
vector<pair<int, int>> g[maxn];
int used[maxn];
int col[maxn];
int n;
string r;
bool fail;

void dfs(int u) {
  for (auto p : g[u]) {
    int v = p.first, c = p.second;
    int nc = col[u] ^ c;
    if (used[v] != -1) {
      if (nc != col[v]) {
        fail = true;
      }
      continue;
    }
    col[v] = nc;
    used[v] = used[u];
    dfs(v);
  }
}

int calc(int d) {
  //cerr << "calc " << d << '\n';
  for (int i = 0; i < n; ++i) {
    g[i].clear();
    used[i] = -1;
  }
  fail = false;
  for (int i = 0; i < n; ++i) {
    g[i].emplace_back((i + d) % n, ((i + d) / n) % 2);
  }
  int deg = 0;
  for (int i = n - 1; i >= 0; --i) {
    if (used[i] == -1) {
      ++deg;
      col[i] = r[i] == '1';
      used[i] = i;
      dfs(i);
    }
    if (fail) {
      return 0;
    }
  }
  int res = 0;
  for (int i = n - 1; i >= 0; --i) {
    if (col[i] == 1 && r[i] == '0') {
      return res;
    }
    if (col[i] == 0 && r[i] == '1') {
      break;
    }
    if (used[i] == i) {
      --deg;
      if (col[i] == 1) {
        //cerr << "KEK " << deg << '\n';
        udd(res, bin(2, deg));
      }
    }
  }
  udd(res, bin(2, deg));
  return res;
}

signed main() {
#ifdef LOCAL
  assert(freopen("c.in", "r", stdin));
#endif
  cin >> n;
  cin >> r;
  reverse(r.begin(), r.end());
  vector<pair<int, int>> res;
  for (int d = 1; d <= 2 * n; ++d) {
    if ((2 * n) % d != 0) {
      continue;
    }
    int cnt = calc(d);
    res.emplace_back(d, cnt);
  }
  for (int i = 0; i < (int) res.size(); ++i) {
    for (int j = i + 1; j < (int) res.size(); ++j) {
      if (res[j].first % res[i].first) {
        continue;
      }
      res[j].second = sub(res[j].second, res[i].second);
    }
  }
  int ans = 0;
  for (auto p : res) {
    udd(ans, mul(p.first, p.second));
  }
  cout << ans << '\n';
}


Measured memory_bytes: 19204
#include<iostream>
#include<cstring>
#include<cstdio>
#include<queue>
#include<vector>
#include<utility>
#include<map>
#define MAX_W 16 + 5
#define MAX_N 3 + 2
#define INF 0x3f3f3f3f

using namespace std;
typedef pair<int, int> P;

int w, h, n;
char m[MAX_W][MAX_W];
int d[MAX_N][MAX_W][MAX_W];
int dir[MAX_N];
map<int, int>::iterator it;
int x[] = {0, 1, -1, 0,  0}; //不動/下/上/右/左
int y[] = {0, 0,  0, 1, -1};
int ct = 0;

int hstar(int cur){
	int res = 0;
	for(int i = 0; i < n; i++){
		int sx = (cur >> 4) & 0xf;
		int sy =  cur & 0xf;
		cur >>= 8;
		res = max(res, d[i][sx][sy]);
	}
	return res;
}
int check(int cur, int *dir){
	int sxy[3], nxy[3], nxt = 0;
	for(int i = 0; i < 3; i++){
		sxy[i] = (cur >> (i * 8)) & 0xff;
		int nx = ((sxy[i] >> 4) & 0xf) + x[dir[i]];
		int ny = (sxy[i] & 0xf) + y[dir[i]];
		nxy[i] = (nx << 4) | ny;
	}
	for(int i = 0; i < n; i++){
		int nx = (nxy[i] >> 4) & 0xf;
		int ny = nxy[i] & 0xf;
		if(m[nx][ny] == '#') return 0; //hit the wall
		for(int j = i + 1; j < n; j++){
			if((nxy[i] == nxy[j]) || (nxy[i] == sxy[j] && sxy[i] == nxy[j])) return 0; // overlap && switch
		}
		nxt |= (nxy[i] << (i * 8));
	}
	return nxt;
}
// void show(int cur){
	// for(int i = 0; i < n; i++){
		// int sx = cur >> 4 & 0xf;
		// int sy = cur & 0xf;
		// cur >>= 8;
		// printf("%c : (%d, %d)\n", i + 'a', sx, sy);
	// }
// }
int solve(){
	memset(d, 0x3f, sizeof(d));
	//BFS
	for(int i = 0; i < n; i++){
		int sx, sy;
		for(int j = 0; j < w * h; j++){
			if(m[j / w][j % w] == i + 'A'){
				sx = j / w, sy = j % w;
				break;
			}
		}
		queue<P> que;
		que.push(make_pair(sx, sy));
		d[i][sx][sy] = 0;
		while(!que.empty()){
			P p = que.front(); que.pop();
			for(int j = 1; j < 5; j++){
				int nx = p.first + x[j];
				int ny = p.second + y[j];
				if(m[nx][ny] != '#' && d[i][nx][ny] > d[i][p.first][p.second] + 1){
					d[i][nx][ny] = d[i][p.first][p.second] + 1;
					que.push(make_pair(nx, ny));
				}
			}
		}
	}
	int cur = 0, end = 0;
	for(int i = 0; i < n; i++){
		for(int j = 0; j < w * h; j++){
			if(m[j / w][j % w] == i + 'a'){
				cur |= ((j / w) << (8 * i + 4));
				cur |= ((j % w) << (8 * i));
			}
			if(m[j / w][j % w] == i + 'A'){
				end |= ((j / w) << (8 * i + 4));
				end |= ((j % w) << (8 * i));
			}
		}
	}
	priority_queue<P, vector<P>, greater<P> > que;
	map<int, int> mp;
	mp[cur] = 0;
	que.push(make_pair(hstar(cur), cur));
	while(!que.empty()){
		cur = que.top().second; que.pop();
		
		if(cur == end) return mp[cur];
		
		ct++;
		
		for(int i = 0; i < 5; i++){
		    dir[0] = i;
			for(int j = 0; j < (n < 2 ? 1 : 5); j++){
				dir[1] = j;
				for(int k = 0; k < (n < 3 ? 1 : 5); k++){
					dir[2] = k;
					int nx = check(cur, dir);
					
					if(nx > 0){ //確認下一步是合法的
						if(mp.find(nx) == mp.end() || mp[nx] > mp[cur] + 1){
							mp[nx] = mp[cur] + 1;
							que.push(make_pair(mp[nx] + hstar(nx), nx)); //d(v) + h*(v)
						}
					}
					
				}
			}
		}
	}
	return -1;
}
int main(){
	while(scanf("%d %d %d\n", &w, &h, &n) != EOF && (w || h || n)){
		for(int i = 0; i < h; i++){
			scanf("%[^\n]%*c", m[i]);
		}
		ct = 0;
		cout << solve() << endl;
		//printf("ct = %d\n", ct);
	}
	
	return 0;
}


Measured memory_bytes: 54120
#include <stdio.h>
#define NIL -1

struct Node {
  int p;
  int l;
  int r;
};
  
int n,D[100000];
struct Node ori[100000];

int rec(int ,int );
void result(int );

int main()
{
  int i,j,a,b,c,l,r,z=0,w,g;
  
  scanf("%d",&n);
  for(i=0;i<n;i++) ori[i].p=ori[i].l=ori[i].r=NIL;
  
  while(z<n){
    scanf("%d%d",&a,&b);
    for(j=0;j<b;j++){
      scanf("%d",&c);
      if(j==0) ori[a].l=c;
      else ori[l].r=c;
      l=c;
      ori[c].p=a;
    }
    z++;
  }

  for(i=0;i<n;i++){
    if(ori[i].p==NIL) r=i;
  }

  rec(r,0);

  for(i=0;i<n;i++){
     printf("node %d:",i);
  printf(" parent = %d,",ori[i].p);
  printf(" depth = %d,",D[i]);

  if(ori[i].p==NIL) printf(" root, ");
  else if(ori[i].l==NIL) printf(" leaf, ");
  else printf(" internal node, ");

  printf("[");
  
  for(g=0,w=ori[i].l;w!=NIL;g++,w=ori[w].r){
    if(g>0) printf(", ");
    printf("%d",w);
  } 
  printf("]\n");
  }
  
  return 0;
}

int rec(int u,int p){
  D[u]=p;
  if(ori[u].r!=NIL) rec(ori[u].r,p);
  if(ori[u].l!=NIL) rec(ori[u].l,p+1);
}

    
    
  



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

using namespace std;

int main(void)
{
    string s;
    cin >> s;

    int ans = 0, cnt = 0;
    for (auto c : s)
    {
        if (c == 'R')
            ++cnt;
        else
        {
            ans = max(cnt, ans);
            cnt = 0;
        }
    }
    ans = max(cnt, ans);

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3624
# -*- coding: utf-8 -*-
n, a, b = map(int,input().split())

ans = 0
for i in range(1, n + 1):
    tmp = str(i)
    su = 0
    for j in tmp:
        su += int(j)
    #print(i, su)
    if a <= su <= b:
        ans += i
print(ans)


Measured memory_bytes: 2940
import java.util.*;

public class Main {
  
  public static void main (String[] args){
  
  	Scanner scanner = new Scanner (System.in);
  
  	int a = scanner.nextInt();
    int b = scanner.nextInt();
    
    int average = (a+b)/2;
    
    if ((a+b)%2 != 0){
      average++;
    }
    
    System.out.println(average);
  }
}

Measured memory_bytes: 21844
#include<cstdio>

int d;
int n;
int count=0;

int main()
{
	while(scanf("%d",&d)!=EOF)
	{
		count=0;
		n=600/d;
		for(int i=0;i<n;i++)
		{
			count+=d*(i*d)*(i*d);
		}	
		printf("%d\n",count);
	}
	return 0;
}

Measured memory_bytes: 0
import sys
n, m, k = map(int, input().split())
mod = 998244353

# 隣り合ったブロックを異なる色で塗ると何通りあるか
# 隣り合ったブロック通しで同じ色にする場所をn-1箇所から選ぶ(combination)

# combinationを計算する
def combination(n, r, p):
    if r < 0 or r > n:
        return 0
    r = min(r, n-r)
    return (f[n]*f_inverse[r]*f_inverse[n-r])%p

f = [1, 1] # n!を計算する
f_inverse = [1, 1]# n!の逆元を計算する
n_inverse = [0, 1] # nの逆元
for i in range(2, n+1):
    f.append((f[i-1]*i)%mod)
    n_inverse.append( (-1*(mod//i)*n_inverse[mod%i])%mod )
    f_inverse.append((f_inverse[i-1]*n_inverse[i])%mod)

# c = m * ((m-1)**(n-1))
# L = []
# for i in range(k+1):
#     L.append(c)
#     c=c//(m-1)

def pow_m(k):
    if k == 0:
        return 1
    elif k%2==0:
        return (pow_m(k//2)**2)%mod
    else:
        return (m-1)*(pow_m(k//2)**2)%mod

count = 0
for i in range(k+1):
    # print(count, c, combination(n-1, i, mod))
    count += combination(n-1, i, mod) * m * pow_m(n-1-i)#L[i]
    count %= mod
    
print(count)

Measured memory_bytes: 32788
#include <iostream>

int main(int argc, char* argv[]) {
  int N, A, B;
  std::cin >> N >> A >> B;
  if ((B - A - 1) % 2) {  // 奇数
    std::cout << "Alice" << std::endl;
  } else {
    std::cout << "Borys" << std::endl;
  }
  return 0;
}

Measured memory_bytes: 256
// 2013/09/10 Tazoe

#include <iostream>
using namespace std;

int main()
{
	int t1, t2, t3, t4;
	cin >> t1;
	cin >> t2;
	cin >> t3;
	cin >> t4;

	int total = t1+t2+t3+t4;

	int x = total/60;	// 分
	int y = total%60;	// 秒

	cout << x << '\n';
	cout << y << '\n';

	return 0;
}

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

int main(){
    int w,h,n;
    cin >> w >> h >> n;
    int wl=0,wr=w,hu=h,hd=0;
    for(int ix=0;ix<n;ix++){
        int x,y,a; cin >> x >> y >> a;
        if(a == 1){
            wl = max(wl,x);
        }
        if(a == 2){
            wr = min(wr,x);
        }
        if(a == 3){
            hd = max(hd,y);
        }
        if(a == 4){
            hu = min(hu,y);
        }
    }
    if(wl>wr) wl=wr=0;
    if(hd>hu) hu=hd=0;
    cout << (wr-wl)*(hu-hd) << endl;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
 
 
 
int main() {
   
  
   string s;
   cin>>s;
   int i;
   string s1=s;
   string s2=s;
   
   int cnt1=0,cnt2=0,max1=0,max2=0;
   for(i=0;i<s1.length();++i)
      {
          if(s1[i]=='?')
              s1[i]='D';
      }
      
  
    for(i=0;i<s1.length();++i)
     {
         if(s1[i]=='D')
            cnt1++;
            
       else if(i<=s1.length()-2 && s1[i]=='P' && s1[i+1]=='D')    
             cnt2++;
     }
     
    max1=cnt1+cnt2;
    
    cnt1=0;
    cnt2=0;
    
    for(i=0;i<s2.length();++i)
      {
          if(s2[i]=='?')
             {
                if(i==0)
                  {
                      if(s2[i+1]=='D')
                         {
                            s2[i]='P';
                         }
                    
                     else
                       s2[i]='D';
                  }
                 
               else  if(s2[i-1]=='P')
                    s2[i]='D';
                    
                 else
                    s2[i]='P';
                    
             }
             
             
      }
     
      
       
     for(i=0;i<s2.length();++i)
      {
         if(s2[i]=='D')
            cnt1++;
            
       else if(i<=s2.length()-2 && s2[i]=='P' && s2[i+1]=='D')    
             cnt2++;   
      }
      
      max2=cnt1+cnt2;
      
      
      if(max1>=max2)
         cout<<s1;
         
      else
         cout<<s2;
       
     
	return 0;
}


Measured memory_bytes: 3848
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#include <iomanip>
#include <map>
#include <cstdlib>
#include <cctype>
#include <ctype.h>
#include <math.h>
#define ll long long
char toupper(char c);
char toupper(char c)
{
    return (c - 0x20);
}

using namespace std;
int main()
{
  string to;
  cin >> to;
  map<string,int> yo;
  yo["SUN"]=7;
  yo["MON"]=6;
  yo["TUE"]=5;
  yo["WED"]=4;
  yo["THU"]=3;
  yo["FRI"]=2;
  yo["SAT"]=1;
  int niti = yo[to];
  cout << niti << endl;

return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
const int maxn = 100001;
const int maxk = 20;
#define is_anc(a, b) (in[a] < in[b] and out[a] >= out[b])
struct info{
	int v, c, w;
};
struct query{
	int id, c, w, y;
};
int n, anc[maxn][maxk], in[maxn], out[maxn], depth[maxn], m;
long long ans[maxn];
vector < info > edge[maxn];
vector < query > ask[maxn];
void dfs(int now, int last = 1){
	static int t = 0;
	static int d = 0;
	depth[now] = d++;
	in[now] = t++;
	anc[now][0] = last;
	for(int i = 1;i < maxk;++i)anc[now][i] = anc[anc[now][i - 1]][i - 1];
	for(auto &i : edge[now])
		if(last != i.v)dfs(i.v, now);
	out[now] = t;
	--d;
}
int get_lca(int a, int b){
	if(depth[a] > depth[b])swap(a, b);
	if(is_anc(a, b))return a;
	for(int i = maxk - 1;i > -1;--i)
		if(!is_anc(anc[b][i], a))b = anc[b][i];
	return anc[b][0];
}
void dfs2(int now, int last = 1){
	static long long total_w = 0;
	static long long q_of[maxn] = {};
	static long long w_of[maxn] = {};
	for(auto &i : ask[now]){
		ans[i.id] += (total_w - w_of[i.c] + q_of[i.c] * i.y) * i.w;
	}
	for(auto &i : edge[now]){
		if(i.v != last){
			++q_of[i.c];
			w_of[i.c] += i.w;
			total_w += i.w;
			dfs2(i.v, now);
			--q_of[i.c];
			w_of[i.c] -= i.w;
			total_w -= i.w;
		}
	}
}
int main(){
	ios_base::sync_with_stdio(0), cin.tie(0);
	cin >> n >> m;
	for(int a, b, c, d, i = 1;i < n;++i){
		cin >> a >> b >> c >> d;
		edge[a].push_back({b, c, d});
		edge[b].push_back({a, c, d});
	}
	dfs(1);
	for(int i = 0, x, y, u, v, lca;i < m;++i){
        cin >> x >> y >> u >> v;
		lca = get_lca(u, v);
		ask[u].push_back({i, x, 1, y});
		ask[v].push_back({i, x, 1, y});
		ask[lca].push_back({i, x, -2, y});
	}
	dfs2(1);
	for(int i = 0;i < m;++i)cout << ans[i] << '\n';
}


Measured memory_bytes: 30708
using System;

namespace AOJ.Volume0
{
    class NationalBudget
    {
        public static void Main()
        {
            int cnt = int.Parse(Console.ReadLine().Trim());
            for (int i = 0; i < cnt; i++)
            {
                // 2つの数字を読み込む
                string str_1 = Console.ReadLine();
                string str_2 = Console.ReadLine();

                // 80桁のチェック
                if (str_1.Length > 80 || str_2.Length > 80)
                {
                    Console.WriteLine("overflow");
                    continue;
                }
                // 1桁ずつ計算していく
                string output = "";
                bool carry = false;
                while (str_1.Length > 0 || str_2.Length > 0)
                {
                    // 数字を切り出す
                    int num_1, num_2;
                    if (str_1.Length == 0) { num_1 = 0; }
                    else { num_1 = int.Parse(str_1.Substring(str_1.Length - 1, 1)); }

                    if (str_2.Length == 0) { num_2 = 0; }
                    else { num_2 = int.Parse(str_2.Substring(str_2.Length - 1, 1)); }

                    // 繰り上がり
                    if (carry) { num_1++; }

                    // 計算
                    string tmp = (num_1 + num_2).ToString();
                    if (tmp.Length > 1)
                    {
                        carry = true;
                        tmp = tmp.Substring(1);
                    }
                    else
                    {
                        carry = false;
                    }
                    output = tmp + output;

                    // 後ろの桁を捨てる
                    str_1 = str_1.Length > 0 ? str_1.Substring(0, str_1.Length - 1) : string.Empty;
                    str_2 = str_2.Length > 0 ? str_2.Substring(0, str_2.Length - 1) : string.Empty;
                }
                // 最後の繰り上がり
                if (carry) { output = "1" + output; }
                if (output.Length > 80) { Console.WriteLine("overflow"); }
                else { Console.WriteLine(output); }
            }
        }
    }
}

Measured memory_bytes: 5768
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

typedef long long lint;

using namespace std;

int main(){
  int N;
  cin>>N;
  int V[N],C[N];
  REP(i,N)cin>>V[i];
  REP(i,N)cin>>C[i];
  int ans=0;
  REP(i,N)ans+=(max(0,V[i]-C[i]));
  cout<<ans<<endl;
  return 0;
}


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

#define rep( i, n ) for( int i = 0; i < ( n ); i++ )
#define PI 3.14159265
typedef long long ll;

int main( void ) {
    int m, f, r;
    while( 1 ) {
        cin >> m >> f >> r;
        if( m == -1 && f == -1 && r == -1 ) break;

        if( m == -1 | f == -1 ) {
            cout << 'F' << endl;
            continue;
        }

        if( m + f >= 80 )
            cout << 'A';
        else if( m + f >= 65 )
            cout << 'B';
        else if( m + f >= 50 )
            cout << 'C';
        else if( m + f >= 30 ) {
            if( r >= 50 ) cout << 'C';
            else cout << 'D';
        } else
            cout << 'F';

        cout << endl;
    }
    return 0;
}



Measured memory_bytes: 3080
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String n = sc.next();
		int x = Character.getNumericValue(n.charAt(n.length() - 1));

		if (x == 2 || x == 4
				|| x == 5 || x == 7
				|| x == 9) {
			System.out.println("hon");
		} else if (x == 3) {
			System.out.println("bon");
		} else {
			System.out.println("pon");
		}

		sc.close();
	}

}


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

int main(){
  int i,j;ll cnt=0;
  int n,p;
  cin>>n>>p;
  int a[n];
  for(i=0;i<n;i++)cin>>a[i];
  for(i=0;i<n;i++){
    if(a[i]%2==1)cnt++;
  }
  if(cnt==0){
    if(p==0)cnt=2;
    else cnt=0;
  }else cnt=1;
  ll prod=1;
  for(i=0;i<n-1;i++){
    prod*=2;
  }
  cout<<prod*cnt;
}

Measured memory_bytes: 256
import sys

n = int(input())
t, a = map(int, input().split())
H = list(map(int, input().split()))

ans_a = sys.maxsize

for i, h in enumerate(H):
    num = i + 1
    tmp = abs(t - h * 0.006 - a)
    if ans_a > tmp:
        ans_a = tmp
        ans = num
    # print(ans_a, tmp, ans)

print(ans)

Measured memory_bytes: 3060
N = int(input())
L = list(map(int, input().split()))
count = 0

for i in range(len(L)):
#  print(i)
  for j in range(i + 1, len(L)):
#    print('	:' + str(j))
    for k in range(j + 1, len(L)):
#      print('		:' + str(k))
#      print(tmp)
      if L[i] != L[j] and L[i] != L[k] and L[j] != L[k]:
        tmp = [L[i] ,L[j], L[k]]
        tmp.sort()
        if tmp[0] + tmp[1] > tmp[2]:
          count += 1
print(count)

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

#define times(n, i)      uptil(0, n, i)
#define rtimes(n, i)     downto((n) - 1, 0, i)
#define upto(f, t, i)    for(int _##i = (t), i = (f); i <= _##i; i++)
#define uptil(f, t, i)   for(int _##i = (t), i = (f); i <  _##i; i++)
#define downto(f, t, i)  for(int _##i = (t), i = (f); i >= _##i; i--)
#define downtil(f, t, i) for(int _##i = (t), i = (f); i >  _##i; i--)
typedef long double LD;
#define long long long

#if defined(EBUG) && !defined(ONLINE_JUDGE)
#define debug true
#define ln << endl
#else
#define debug false
#define ln << '\n'
#endif
#define tb << '\t'
#define sp << ' '



signed main() { // long: 64bit
    if(!debug) {
        cin.tie(0);
        ios::sync_with_stdio(0);
    }

    map<int, bool> said;
    int N; cin >> N;

    times(N, i) {
        int A; cin >> A;
        said[A] = !said[A];
    }

    int ans = 0;
    for(auto p: said) {
        ans += p.second;
    }
    cout << ans;

    return 0;
}


Measured memory_bytes: 4992
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class MainClass
{
	public const long Giri = 1000000007;
	public const long DpInf = 99999999999999;

	public static void Main(string[] args)
	{
		var s = Input();
		var a = s[0].ToLong();
		var b = s[1].ToLong();
		var c = s[2].ToLong();
		var k = s[3].ToLong();
		
		var q = new long[]{a, b, c};
		var v = new int[]{1, 0, -1};
		if(a == b && b == c && c==0)
		{
			Console.WriteLine(0);
			return;
		}
		
		
		if(a+b >= k)
		{
			Console.WriteLine(Math.Min(a, k));
			return;
		}
		
		
		Console.WriteLine(a-(k-a-b));
	}
	
	
	static long GCD(long a, long b)
	{
		var v = new[] { a, b };
		while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; }
		return v[0];
	}
	public static string[] Input() { return Console.ReadLine().Split(); }
}

public static class Smarter
{
	public static int ToInt(this string str) { return int.Parse(str); }
	public static long ToLong(this string str) { return long.Parse(str); }
	public static int[] ToInt(this string[] str, int offset = 0)
	{
		var r = new int[str.Length];
		for(int i = 0; i < str.Length; i++) r[i] = str[i].ToInt() + offset;
		return r;
	}
}

Measured memory_bytes: 27488
#include <iostream>
using namespace std;
using ll = long long;

#define rep(i,n) for(int i=0;i<(n);++i)

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  int N, K; cin >> N >> K;
  ll R, S, P; cin >> R >> S >> P;
  string T; cin >> T;

  ll ans = 0;
  char T2[N];
  rep(i, N) {
    if (i-K >= 0 && T[i] == T2[i-K]) {
      T2[i] = 'x';
      continue;
    }

    if (T[i] == 'r')
      ans += P;
    if (T[i] == 's')
      ans += R;
    if (T[i] == 'p')
      ans += S;
    T2[i] = T[i];
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 640
#include <iostream>

using namespace std;
static const int MOD = 1e9 + 7;


//modの逆元、つまり
//a/b ≡ a*(b') (mod p)となるようなb'を求める
//拡張Euclid互除法
long long modinv(long long a, long long m) {
  long long b = m;
  long long u = 1;
  long long v = 0;

  while (b){
    long long t = a / b;
    a -= t * b;
    swap(a, b);
    u -= t * v;
    swap(u, v);
  }
  u %= m;
  if (u < 0) {
    u += m;
  }
  return u;
}

long long comb(int n, int k){
  long long c = 1; //denominator
  long long d = 1;//numerator

  for (int i = 0; i < k; i++) {
    c = (c * (n-i)) % MOD;
    d = (d * (k-i)) % MOD;
  }
  return (c * modinv(d, MOD)) % MOD;
  //これだとダメだった
  //理由: modしたものの割り算は計算できない
  //return c/d;

}

int main() {

  int k, n;
  cin >> n >> k;
  long long cnt;

  for (int i = 0; i < k; i++) {
    cnt = (comb(k-1, i) * comb(n-k+1, i+1)) % MOD;
    cout << cnt << endl;
  }
  return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#include<stack>
#include<queue>
#include<cmath>
#include<functional>
#include<string>
#include<vector>
#include<cstring>
#include<utility>
#include<set>
#include<map>

#define ll long long
#define ull unsigned long long
#define MOD 1000000007
#define MAX 2e9
#define pii pair<int, int>
#define pll pair<ll, ll>
#define all(v) v.begin(), v.end()
const double PI = acos(-1);

using namespace std;
int A[300001];
int tr[1200010];

int mx(int x, int s, int e, int l, int r) {
	if (s > r || e < l) return 0;
	if (s >= l && e <= r) return tr[x];
	else return max(mx(x * 2, s, (s + e) / 2, l, r), mx(x * 2 + 1, (s + e) / 2 + 1, e, l, r));
}
void update(int x, int s, int e, int i, int val) {
	if (i < s || i > e) return ;
	tr[x] = max(val, tr[x]);
	if(s != e){
		update(x * 2, s, (s + e) / 2, i, val);
		update(x * 2 + 1, (s + e) / 2 + 1, e, i, val);
	}
}
int main(void) {
	ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	//	freopen("input.txt", "r", stdin);

	int N, K; cin >> N >> K;
	int ans = 0;
	for (int i = 1; i <= N; i++) {
		cin >> A[i];
		A[i]++;
		int cnt = mx(1, 1, 300001, max(0, A[i] - K), min(300001, A[i] + K)) + 1;
		update(1, 1, 300001, A[i], cnt);
		ans = max(ans, cnt);
	}
	cout << ans;

}


Measured memory_bytes: 8920
#include <bits/stdc++.h>
 
const double pi = 3.141592653589793238462643383279;
using namespace std;
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
 
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a)*(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
 
//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007
 
 
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
 
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
 
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)

//ここから編集
template<typename T>
struct SegmentTree{

  vector<T> node;
  int n0;
  SegmentTree(vector<T>& v){
    int n = v.size();
    n0 = 1;
    while(n0 < n) n0 <<= 1;
    node.assign(2*n0,0);

    for(int i=0; i<n; i++) node[i+n0-1] = v[i];
    for(int i=n0-2; i>=0; i--) node[i] = GCD(node[i*2+1], node[i*2+2]);
  }

  void update(int k, T x){
    k += n0-1;
    node[k] = x;

    while(k > 0){
      k = (k-1)/2;
      node[k] = GCD(node[k*2+1], node[k*2+2]);
    }
  }

  T query(int a, int b, int k, int l, int r){
    if(r <= a || b <= l) return 0;
    
    if(a <= l && r <= b) return node[k];
    else{

      T vl = query(a, b, 2*k+1, l, (l+r)/2);
      T vr = query(a, b, 2*k+2, (l+r)/2, r);
      return GCD(vl, vr);
    }
  
  }

  T query(int l, int r){
    return query(l, r, 0, 0, n0);
  }
  
  T GCD(T a, T b){ return (b == 0)?a:GCD(b, a%b); }
};

int GCD(int a, int b){
  if(b == 0) return a;
  return GCD(b, a%b);
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(5);
  

  int N; cin >> N;
  vector<int> a(N);
  REP(i,N) cin >> a[i];
  SegmentTree<int> seg(a);

  int ans = 1;
  for(int i=0; i<N; i++){
    if(i == 0){
      ans = max(ans, seg.query(1, N));
    }else if(i == N-1){
      ans = max(ans, seg.query(0, i));
    }else{
      
      ans = max(ans, GCD(seg.query(0, i), seg.query(i+1, N)));
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4408
#include<bits/stdc++.h>
#define  forn(i, n)  for(int i=0; i < (int)n; i++)
using namespace std ;
// #define INPUT_OUTPUT { \
//  freopen("input.txt","r",stdin) ; \
//  freopen("output.txt","w",stdout) ; \
// }
void solve() {
   float n;
   cin >> n;
   cout << ceil(n/2);   
}
int main() {
  // INPUT_OUTPUT ;
  int t=1;
  //cin >> t ;
  while(t--) solve() ;
  return 0 ;
}

Measured memory_bytes: 256
#include<stdio.h>
main(){

  int d,i,S=0;

  while (1){

    if(scanf("%d",&d) == EOF){
      break;
    }

    for(i=1;(i*d)<=(600-d);i++){
      S += d*d*d*i*i;
    }
    
    printf("%d\n",S);
    S=0;

  }

  return 0;
}

Measured memory_bytes: 596
#include <stdio.h>

int gcd(int x, int y) {
	int a, b, d;
	if (x < y) {
		d = x;
		x = y;
		y = d;
	}
	//x??????????????§??????
	a = x;
	b = y;
	while (1) {
		if (a % b == 0) {
			return b;
			break;
		} else {
			d = a;
			a = b;
			b = d % b;
		}
	}
}

int main() {
	int x, y;

	scanf("%d %d", &x, &y);
	printf("%d\n", gcd(x, y));

	return 0;
}

Measured memory_bytes: 592
from collections import defaultdict

N = int(input())
mem = defaultdict()
mem["AC"] = 0
mem["WA"] = 0
mem["TLE"] = 0
mem["RE"] = 0
for i in range(N):
    inp = input()
    mem[inp] += 1
print("AC x " + str(mem["AC"]))
print("WA x " + str(mem["WA"]))
print("TLE x " + str(mem["TLE"]))
print("RE x " + str(mem["RE"]))


Measured memory_bytes: 9500
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define rrep(i, n) for(int i=((int)(n));i>0;i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)	
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define REVSORT(c) SORT(c);REVERSE(c)
#define ALL(x) (x).begin(),(x).end()
#define INF 1e9
const long long MOD = 1000000007;
typedef long long ll;

int main(){
	string S;
	cin >> S;
	S[3] = '8';
	cout << S << endl;
}

Measured memory_bytes: 256
/*____________________________Definitions__________________________*/
#include <bits/stdc++.h>
using namespace std;
#define fastIO ios_base::sync_with_stdio(0); cin.tie(0);
typedef long long ll;
typedef vector<int> vi;
#define Rep(i, a, b) for (int i=a; i<(b); i++)
#define trav(a,x) for(auto& a : x)
#define nl '\n'
#define ri(n) int n; scanf("%d", &n);
#define rll(n) ll n; scanf("%lld", &n);
/*__________________________________________________________________*/


int main() {

	fastIO
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int T = 1;
	while (T--) {
		/*_____________________Code Here____________________________*/
		string s;
		cin >> s ;
		int sum = 0;

		if (s == "RRR") {sum = 3;}
		else if (s == "RRS" || s == "SRR") {sum = 2;}
		else if (s == "SRS" || s == "SSR" || s == "RSS" || s == "RSR") {sum = 1;}
		cout << sum << nl;


		/*_____________________End Here____________________________*/
	}
	return 0;
}



Measured memory_bytes: 3640
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define repr(e,x) for(auto& e:x)
using namespace std;
typedef long long ll;
typedef long double ld;
//typedef pair<int,int> P;
int const INF=1001001001;
ll const LINF=1001001001001001001;
ll const MOD=1000000007;

int N;
int A[100002];

int main(){
    cin>>N;
    repn(i,N) cin>>A[i];
    A[0]=0;
    A[N+1]=0;

    int sum=0;
    repn(i,N+1){
        sum+=abs(A[i]-A[i-1]);
    }

    repn(i,N){
        int ans=sum;
        ans-=abs(A[i-1]-A[i])+abs(A[i]-A[i+1]);
        ans+=abs(A[i-1]-A[i+1]);
        cout<<ans<<endl;
    }
}

Measured memory_bytes: 3992
import scala.math._

object Main extends App {

  val YES = "YES"
  val Yes = "Yes"
  val NO = "NO"
  val No = "No"

  val input: Array[Array[Int]] = Array.ofDim(6, 6000000)
  ///////////////////////////////////////////

  val sc = new java.util.Scanner(System.in)
  val n, m, c = sc.nextInt
//  val b = sc.nextInt
//  val a = List.fill(n)(sc.nextInt)
  val b = List.fill(m)(sc.nextInt)
//  val c = List.fill(n - 1)(sc.nextInt)
  val list = List.fill(n, m)(sc.nextInt)

  val sumB = b.sum

  val ans = list.map{ nested =>
    nested.foldLeft((0, 0)) { case ((acc, index), in) =>
      (acc + in * b(index), index + 1)
    }._1
  }.count(_ + c > 0)

  println(ans)

  ///////////////////////////////////////////

  def bigIterator(start: BigInt, end: BigInt, step: BigInt = 1) =
    Iterator.iterate(start)(_ + step).takeWhile(_ <= end)

  def lcm(a :Int, b :Int): Int =
    a / gcd(a, b) * b

  def lcm(a :Long, b :Long): Long =
    a / gcd(a, b) * b

  def gcd(a: Int, b: Int): Int =
    if (b == 0) a else gcd(b, a % b)

  def gcd(a: Long, b: Long): Long =
    if (b == 0) a else gcd(b, a % b)

  def setOrUpdated[A, B](a: Map[A, B], key: A, value: B, f: (B, B) => B) =
    a.get(key) match {
      case Some(v) => a.updated(key, f(value, v))
      case _ => a + (key -> value)
    }
}

Measured memory_bytes: 169412
import scala.io.StdIn._
import scala.math._

object Main {
  def distance(s: String): Double = {
    val Array(x1, y1, x2, y2) = s.split(" ").map(_.toDouble)
    sqrt(pow(abs(x1 - x2), 2) + pow(abs(y1 - y2), 2))
  }

  def main(args: Array[String]): Unit = {
    val point = readLine()
    println(distance(point))
  }
}

Measured memory_bytes: 43808
#include <stdlib.h>
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
using ll=long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
inline constexpr ll gcd(ll a,ll b){if(!a||!b)return 0;while(b){ll c=b;b=a%b;a=c;}return a;}
inline constexpr ll lcm(ll a,ll b){if(!a||!b)return 0;return a*b/gcd(a,b);}
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
const long long INF=1LL << 60;
long long a,b;
long long dp[100200][110];
long long w[110],v[110];

int main() {
    long long a;
    cin>>a;
    string aaa=to_string(a);
    int leng=aaa.size();
    long long sum=0;

    for(int bit =0;bit<(1<<leng-1);bit++){
        long long temp=aaa.at(0)-'0';
        for(int i=0;i<leng-1;i++){
            if(bit&(1<<i)){
               sum+=temp;
               temp=aaa.at(i+1)-'0';
            }
            else{
                temp*=10;
                temp+=aaa.at(i+1)-'0';               
            }
        }
        sum+=temp;
    }

    cout<<sum<<endl;
}


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

#define int long long

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int N;
  cin >> N;

  vector<int> d(N);
  for ( int i = 0; i < N; i++ ) {
    cin >> d[i];
  }

  int ans = 0;
  for ( int i = 0; i < N; i++ ) {
    for ( int j = i+1; j < N; j++ ) {
      ans += d[i]*d[j];
    }
  }

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


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <time.h>
#define ll long long
#define double long double
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl
#define COYE cout<<"YES"<<endl
#define COYe cout<<"Yes"<<endl
#define COye cout<<"yes"<<endl
#define CONO cout<<"NO"<<endl
#define CONo cout<<"No"<<endl
#define COno cout<<"no"<<endl
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MAX 5100000
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;}
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
bool CAN=true;
using namespace std;

int main(){
  ll X,Y;
  cin>>X>>Y;
  if(X>=0){
    if(X<=Y) cout<<Y-X<<endl;
    else if(0<Y) cout<<2+X-Y<<endl;
    else if(-X<=Y) cout<<1+X+Y<<endl;
    else cout<<-X-Y+1<<endl;
  }
  else{
    if(-X<=Y) cout<<X+Y+1<<endl;
    else if(0<Y) cout<<-X-Y+1<<endl;
    else if(X<=Y) cout<<Y-X<<endl;
    else cout<<2+X-Y<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i,a,b) for (int i = (a); i < (b); i++ )
typedef pair<int,int> P;
typedef long long ll;
const int INF = 100000000;
const double PI=3.14159265358979323846;

int main () {
    ll N ;
    cin >> N ;

    ll A[N],B[N];

    rep(i,0,N) {
        cin >> A[i] >> B[i];
    }
    ll ans = 0;
    for (int i=N-1; i>=0; i--) {
        A[i] += ans;
        if (A[i]%B[i]==0) {
            continue;
        }
        else {
            ll tmp;
            tmp = (A[i]/B[i]+1)*B[i]-A[i];
            A[i] += tmp;
            ans += tmp;
        }
    }

    cout << ans << endl;
}








Measured memory_bytes: 1792
s1 = list(input())
s2 = list(input())
for i in range(len(s1)):
    if s1 == s2:
        print("Yes")
        exit()
    temp = s2[0]
    for j in range(1, len(s1)):
        s2[j - 1] = s2[j]
        if j == len(s2) - 1:
            s2[j] = temp
print("No")

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


#define ll long long



#define biggestFactor (n)      for (ll j = 2; j <= sqrt(n); j++){if (n % j == 0){cout << n / j << "\n";break;}}
                               //First find smallest factor and then divide that factor and the answer itself is biggest factor
                          
using namespace std;


int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    ll n, d;
    cin >> n >> d;
    ll ax[n], ay[n];
    ll cnt = 0;
    for (ll i = 0; i < n; i++)
    {
        cin >> ax[i] >> ay[i];
        if (sqrt(ax[i] * ax[i] + ay[i]* ay[i])<=d)
        {
            cnt++;
        }
    }
    cout << cnt << "\n";
	return 0;
}

Measured memory_bytes: 6788
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); i++) 
#define all(v) begin(v),end(v)
using ll = long long;

int main() {
  char a;cin>>a;
  if(a>='a')cout<<'a'<<endl;
  else cout<<"A"<<endl;
}

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

int main(){

    int n[5];
    int k;
    int r;


    for(int i=0; i<5;i++){
        cin >> n[i];
    }

    cin >> k;

    int flag = 0;

    for(int i=0; i<5;i++){
        for(int j=0; j<5; j++){

            if(n[i] - n[j] < 0){
                r = n[j]-n[i];
            } else {
                r = n[i]-n[j];
            }

            if(r > k){
                flag = 1;
            }
        }
    }

    if(flag == 1){
        cout << ":(" << endl;
    } else {
        cout << "Yay!" << endl;
    }

}

Measured memory_bytes: 256
#include <iostream>
    using namespace std;
    int main(void){
      string a,b;
      cin>>a>>b;
      
      if(a==b){
          cout<<"H"<<endl;
      }
      
      else if(a=="D"&&b=="H"){
          cout<<"D"<<endl;
      }
      
      else if(a=="H"&&b=="D"){
          cout<<"D"<<endl;
      }
    }

Measured memory_bytes: 3456
#include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

// 隣接リスト
class ConnectNodeInfo{
	vector<vector<pair<ll,ll>>> graph;
public:
	ConnectNodeInfo(int node_num){
		graph.resize(node_num);
	}
	void AddNonDirectionalConnection(ll u,ll v,ll w){
		graph[u].emplace_back(v,w);
		graph[v].emplace_back(u,w);
	}
	void AddDirectionalConnection(ll u,ll v,ll w){
		graph[u].emplace_back(v,w);
	}
	vector<pair<ll,ll>>& operator[](ll index){
		return graph[index];
	}
	size_t size(){return graph.size();}
};

class WarshallFloyd{
	vector<vector<ll>> dist;
public:
	void CalcShortestPath(ConnectNodeInfo& connect){
		int V = connect.size();
		dist.resize(V,vector<ll>(V,1LL<<60));

		REP(i,V){
			dist[i][i]=0;
			int U = connect[i].size();
			REP(j,U){
				dist[i][connect[i][j].first] = connect[i][j].second;
			}
		}

		REP(k,V){
			REP(i,V){
				REP(j,V){
					if(dist[i][k]!=(1LL<<60) && dist[k][j]!=(1LL<<60)){
						dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
					}
				}
			}
		}
	}
	bool HasNegativeLoop(){
		bool flag = false;
		for(int i=0,ei=dist.size();i<ei;i++){
			if(dist[i][i]<0){
				flag = true;
				break;
			}
		}
		return flag;
	}
	ll CalcDiameter(){
		ll diameter = -(1LL<<60);
		int V = dist.size();
		REP(i,V){
			REP(j,V){
				if(dist[i][j]<1LL<<60){
					diameter = max(diameter,dist[i][j]);
				}
			}
		}
		return diameter;
	}
	ll GetDistance(int i,int j){
		return dist[i][j];
	}
};
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);

	int N=in(),M=in(),L=in();
	ConnectNodeInfo connect(N),connect2(N);
	REP(i,M){
		int A=in()-1,B=in()-1,C=in();
		//if(C>L) continue;
		connect.AddNonDirectionalConnection(A,B,C);
	}
	WarshallFloyd WF;
	WF.CalcShortestPath(connect);

	REP(i,N){
		for(int j=i;j<N;j++){
			if(WF.GetDistance(i,j)<=L){
				connect2.AddNonDirectionalConnection(i,j,1);
			}
		}
	}
	WarshallFloyd WF2;
	WF2.CalcShortestPath(connect2);

	int Q=in();
	REP(i,Q){
		int S=in()-1,T=in()-1;
		auto d = WF2.GetDistance(S,T);
		if(d>=(1LL<<60)) out(-1);
		else{
			out(d-1);
		}
	}

	return 0;
}


Measured memory_bytes: 6784
#include<bits/stdc++.h>
 
using namespace std;
 
typedef long long int ll;
#define pb push_back
#define mp make_pair
#define N 200005
 
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	
	set<string> s;

	int n,i;
	cin>>n;
	string p;
	for(i=0;i<n;i++){
		cin>>p;
		s.insert(p);
	}

	cout<<(int)s.size()<<endl;
	return 0;
}

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

int main()
{
    int n, k;
    cin >> n >> k;
    double count = 0.000000000000;
    int two;
    long long x;

    for (int i = 1; i <= n; i++)
    {
        if (i >= k)
        {
            count +=(double)1 / n;
        }
        else
        {
            two = n;
            x = i;
            for (int j = 0; j < 20; j++)
            {
                x *= 2;
                two *= 2;
                if (x >= k)
                {
                    count +=(double)1/two;
                    break;
                }
            }
            //cout<<'!'<<endl;
        }
    }
    cout << fixed << setprecision(13);
    cout << count  <<endl;
}


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

#define pb push_back
#define SZ(x) ((int)x.size())

const int N = 2010 ;

int vis[N], ok[N][N], in[N], a[N] ;
vector <int> g[N] ;
int n ;

void dfs(int rt) {
	vis[rt] = 1 ;
	for (int i = 1; i <= n; i++)
	if (!vis[i] && ok[rt][i]) {
		in[i]++ ;
		g[rt].pb(i) ;
		dfs(i) ;
	}
}

void Top() {
	priority_queue <int> q ;
	for (int i = 1;  i <= n; i++) if (!in[i]) q.push(i) ;
	while (!q.empty()) {
		int now = q.top() ;
		q.pop() ;
		cout << a[now] << " " ;
		for (int i = 0; i < SZ(g[now]); i++) q.push(g[now][i]) ;
	}
}

signed main(){
	scanf("%d", &n) ;
	for (int i = 1; i <= n; i++) scanf("%d", &a[i]) ;
	sort(a + 1, a + n + 1) ;
	for (int i = 1; i <= n; i++)
	for (int j = i + 1; j <= n; j++)
	if (__gcd(a[i], a[j]) != 1) ok[i][j] = ok[j][i] = 1 ;
	for (int i = 1; i <= n; i++) if (!vis[i]) dfs(i) ;//连通块
	Top() ;
}

Measured memory_bytes: 16256
//@author yash2040
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define ll long long
#define int long long
#define pb push_back
#define mod 1000000007
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
int32_t main()
{
	fast();
	int t=1;
//	cin>>t;
	while(t--)
	{
		int n;
		cin>>n;
		vector<int> v,v1;
		for(int i=0;i<n;i++)
		{
			int x,y;
			cin>>x>>y;
			v.pb(x+y);
			v1.pb(x-y);
		}	
		sort(v.begin(),v.end());
		sort(v1.begin(),v1.end());
		cout<<max(v[v.size()-1]-v[0],v1[v1.size()-1]-v1[0])<<endl;
	}
}








Measured memory_bytes: 6688
#include <bits/stdc++.h>
#include<vector>
using namespace std;
#define rep(i, n)        for(int i=0; i<(int)(n); ++i)
int main() {
  long long int  a,b,c,d,f=2019;
  cin>>a>>b;
  if(b-a>=2019){
    cout<<0;
    return 0;
  }
  for(long long int i=a;i<=b-1;i++){
    for(long long int j=i+1;j<=b;j++){;
      d=i*j%2019;
      f=min(d,f);
    }
  }
  cout<<f;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <math.h>
#include <vector>
#include <algorithm>
#include <functional>
#include <numeric>
#include <string.h>

using namespace std;

#define REP(i,n) for (int i = 0; i < n; i++)

int main() {

	int N, M;
	char c[56][56];

	scanf("%d %d", &N, &M);

	REP(i, N) scanf("%s", c[i]);

	int best = 114514810;
	for (int w = 1; w <= N - 2; w++) {
		for (int b = w + 1; b <= N - 1; b++) {
			int count = 0;
			REP(i, N) {
				if (i < w) {
					REP(j, M) {
						if (c[i][j] != 'W') count++;
					}
				}
				else if (i < b) {
					REP(j, M) {
						if (c[i][j] != 'B') count++;
					}
				}
				else {
					REP(j, M) {
						if (c[i][j] != 'R') count++;
					}
				}
			}
			best = min(count, best);
		}
	}

	printf("%d\n", best);

	return 0;
}

Measured memory_bytes: 2696
#include <stdio.h>
#include <math.h>
#define EPS 0.0000000002
#define MAX 1010001000

typedef struct point{
    double x, y;
}point;

typedef struct line{
    point st, en;
}line;

double norm(point a);
double norm2(point a);
double distans(point a, point b);
point sum_vector(point a, point b);
point diff_vector(point a, point b);
point minus_vector(point a);
double dot(point a, point b);
double prod(point a, point b);

point reflection(line a, point p);
point pv(line a, point p);

point reflection(line a, point p)
{
    //直線aについて点pと線対称な点を返す
    return sum_vector(pv(a, p), diff_vector(pv(a, p), p));
}

point pv(line a, point p)
{
    //直線ab上に点pから垂線を下ろしたときの点h//
    point h;
    double k = dot(diff_vector(a.st, p), diff_vector(a.st, a.en))
                / dot(diff_vector(a.en, a.st), diff_vector(a.en, a.st));
    h.x = k * (a.en.x - a.st.x) + a.st.x;
    h.y = k * (a.en.y - a.st.y) + a.st.y;
    return h;
}

double norm(point a)
{
    //原点からの距離
    return sqrt((a.x * a.x) + (a.y * a.y));
}

double norm2(point a)
{
    //原点からの距離の二乗
    return (a.x * a.x) + (a.y * a.y);
}

double distans(point a, point b)
{
    //二点間の距離
    point tmp = sum_vector(b, minus_vector(a));
    return norm(tmp);
}

point sum_vector(point a, point b)
{
    //ベクトルの和
    a.x += b.x;
    a.y += b.y;
    return a;
}

point diff_vector(point a, point b)
{
    //ベクトルの差
    a.x -= b.x;
    a.y -= b.y;
    return a;
}

point minus_vector(point a)
{
    //逆ベクトル
    a.x *= -1;
    a.y *= -1;
    return a;
}

double dot(point a, point b)
{
    //内積
    return (a.x * b.x) + (a.y * b.y);
}

double prod(point a, point b)
{
    //外積
    return (a.x * b.y) - (b.x * a.y);
}

///////////////////////////////////////

int main(void)
{
    point p;
    line ab;
    int n, i;

    scanf("%lf%lf%lf%lf%d", &ab.st.x, &ab.st.y, &ab.en.x, &ab.en.y, &n);
    for (i = 0; i < n; i++) {
        scanf("%lf%lf", &p.x, &p.y);
        p = reflection(ab, p);
        printf("%.10lf %.10lf\n", p.x, p.y);
    }

    return 0;

}

Measured memory_bytes: 664
#include<bits/stdc++.h>
#define int long long
const int INF = 1000000007;
using namespace std;

signed main(){
    
    int N, C; cin >> N >> C;
    vector<vector<int> > D(C, vector<int>(C, 0));
    for (int i = 0; i < C; ++i) for (int j = 0; j < C; ++j) cin >> D[i][j];
    vector<vector<int> > fi(N, vector<int>(N, 0));
    for (int i = 0; i < N; ++i) for (int j = 0; j < N; ++j) cin >> fi[i][j], --fi[i][j];
    
    vector<vector<int> > cost(3, vector<int>(C, 0));
    for (int c = 0; c < C; ++c) {
        for (int i = 0; i < N; ++i) {
            for (int j = 0; j < N; ++j) {
                cost[(i+j)%3][c] += D[fi[i][j]][c];
            }
        }
    }
    
    int res = INF;
    int c[3];
    for (c[0] = 0; c[0] < C; ++c[0]) {
        for (c[1] = 0; c[1] < C; ++c[1]) {
            if (c[1] == c[0]) continue;
            for (c[2] = 0; c[2] < C; ++c[2]) {
                if (c[2] == c[0] || c[2] == c[1]) continue;
                int tmp = 0;
                for (int it = 0; it < 3; ++it) tmp += cost[it][c[it]];
                res = min(res, tmp);
            }
        }
    }

    cout << res << endl;
    return 0;
}

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

using namespace std;

int C(int K, int N, vector<int>& A) {
	if (N == 2)
		return min(A[1] - A[0], K - A[1] + A[0]);
	int min_d = A[N - 1] - A[0];
	for (int i = 1; i < N; i++)
		min_d = min(K - A[i] + A[i - 1], min_d);
	return min_d;
}

int main() {
	int K, N;
	cin >> K >> N;
	vector<int> A(N);
	for (int i = 0; i < N; i++)
		cin >> A[i];
	cout << C(K, N, A);
	return 0;
}

Measured memory_bytes: 1024