akhauriyash/Code-Regression huggingface dataset:
/******************************************
* AUTHOR : SOMU KUMAR *
* INSTITUTION : IIT BHUBANESWAR *
******************************************/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define N 100005
#define MOD 1000000007
#define pb push_back
#define mk make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
//code here...............//
int d,t,s;
cin>>d>>t>>s;
if(s*t>=d)cout<<"Yes"<<endl;
else cout<<"No"<<endl;
return 0;
}

Measured memory_bytes: 3652
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
const int mod=5201314;
const int N=202202;
char s[N][11];
int md[mod];
int vis[N],be[N],sum[N],Next[N];
int t[N],ans[N];
int n,tot;
int cmp(int x,int y){	
	int g=strcmp(s[x],s[y]);
	return g<0;
}
void put(int num){
	int n=strlen(s[num]);
	for (int i=0; i<n; i++)
		sum[num]=(sum[num]*26+s[num][i]-'a')%mod; 
	if (md[sum[num]]==0)	md[sum[num]]=num;
	else{
		Next[num]=md[sum[num]];
		md[sum[num]]=num;
	}
}
int find(int num){
	if (be[num])	return t[be[num]];
	int sm=0;
	for (int i=md[sum[num]]; i; i=Next[i]){
		if (be[i])	continue;
		if (strcmp(s[i],s[num])==0)	be[i]=num,sm++;
	}
	return sm;
}

int main(){
	scanf("%d",&n);
	for (int i=1; i<=n; i++){
		scanf("%s",s[i]);
		put(i);
	}
	int mx=0;
	for (int i=1; i<=n; i++)	t[i]=find(i),mx=max(mx,t[i]);
	for (int i=1; i<=n; i++){
		if (mx==t[i]){
			if (vis[be[i]])	continue;
			vis[be[i]]=1;
			ans[++tot]=i;
		}
	}
	sort(ans+1,ans+1+tot,cmp);
	for (int i=1; i<=tot; i++)
		printf("%s\n",s[ans[i]]);
	return 0;
}

Measured memory_bytes: 29056
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace C_test_For_Atcorder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            var a = cin.ReadInt;
            var b = cin.ReadInt;
            WriteLine(a * b % 2 == 0 ? "Even" : "Odd");
        }
    }


    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue inputStream;

        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return (string)inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return (string)inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }

}

Measured memory_bytes: 11092
#include<iostream>
#include <vector>
#include <math.h>
#include <string>
#include <utility>
#include <unordered_map>
#include <unordered_set>
using namespace std;

int main() {
    long long a, b = 100;
    int t = 0;
    cin >> a;
    while (b < a) {
        b = 1.01 * b;
        t++;
    }
    cout << t << endl;
}

Measured memory_bytes: 3160
def d_nearest_card_game(N, Q, A, X):
    # 最初は、高橋くんは数字の大きなカードを、青木くんはxに近いものから取っていく。
    # するといつか高橋くんが取りたいカードが青木くんに取られているような状況になるので、
    # そこからは2人で値の大きなものから順に取っていく。
    # そのため、2人で順に取っていく領域の広さ(N/2通り)がわかればいい。
    # N/2通りなのは、順に取っていくフェイズの前に2人がそれぞれ固まった領域の
    # カードを取るフェイズがN/2回あるため。
    # (Nが偶数のとき。奇数のときは両者が両端から取っていって
    # 最後に高橋くんが真ん中のカードを取ることがありうる)

    # これらの場合について、境界となるxの値を先に求めておけば、各クエリに対して
    # どの場合に当たるのかを高速に判定できる。

    # 境界となるxは青木くんがまとめて取ることになる領域の左右端の中央にある。
    # 数列のインデックスを右から0-basedで付けていくと、
    # 高橋くんがまとめて取っている領域は 0, 1, ..., i
    # 青木くんがまとめて取っている領域は i+1, i+2, ..., 2i+1
    # 境界となるxは (A[i+1]+A[2i+2])//2 + 1

    # iの値が分かったときに高橋くんの得点を求めるには、
    # Aの累積和とAの右から偶数番目だけ取る累積和を求めておけばいい。
    import bisect

    a = A[::-1]  # 「右から」はわかりづらいので逆にする
    # 累積和と偶数番目だけ足す累積和
    cumsum, evensum = [0] * (N + 1), [0] * (N + 1)
    for k, a_k in enumerate(a):
        cumsum[k + 1] = cumsum[k] + a_k
        evensum[k + 1] = evensum[k] + (a_k if k % 2 == 0 else 0)

    # 得点が変化するxの境界とそのときの得点
    threshold, threshold_score = [], []
    for k in range((N - 1) // 2):
        threshold.append((a[k + 1] + a[2 * k + 2]) // 2 + 1)
        threshold_score.append((cumsum[k + 1] - cumsum[0]) + (evensum[N] - evensum[2 * k + 2]))

    # Aを逆にしたので、もう一度逆にする
    threshold = threshold[::-1]
    threshold_score = threshold_score[::-1]

    ans = []
    for x in X:
        idx = bisect.bisect_right(threshold, x)
        if idx == 0:
            ans.append(cumsum[(N + 1) // 2] - cumsum[0])
        else:
            ans.append(threshold_score[idx - 1])
    ans = '\n'.join(map(str, ans))
    return ans

N, Q = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
X = [int(input()) for _ in range(Q)]
print(d_nearest_card_game(N, Q, A, X))

Measured memory_bytes: 38772
#include <iostream>
//#include <iomanip>
//#include <string>
//#include <vector>
//#include <algorithm>
//#include <utility>
//#include <set>
//#include <map>
//#include <queue>
//#include <deque>
//#include <bitset>
//#include <math.h>
using namespace std ;
//using ll = long long ;
//using ld = long double ;
//using vll = vector<ll> ;
//using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;

//ll mod = 1000000007 ;
//long double pie = acos(-1) ;

//void yorn(bool a){if(a) cout << "Yes" << endl ; else cout << "No" << endl ;}
//void YorN(bool a){if(a) cout << "YES" << endl ; else cout << "NO" << endl ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void mysort(vector<long long> &a){sort(a.begin(),a.end()) ;}
//void myrev(vector<long long> &a){reverse(a.begin(),a.end()) ;}

int main(){
	int n ; cin >> n ;
	int s = 0 ;
	int x = n ;
	while(x>0){
		s += x%10 ;
		x /= 10 ;
	}
	cout << (n%s==0?"Yes":"No") << endl ;
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
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 ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
int64_t factorial(int64_t n) {
  if (n == 1) {
    return 1;
  }
  int64_t ans = factorial(n-1);
  return ans*n;
}
int64_t gcd(int64_t a, int64_t b) {
  if (a < b) {
    int64_t tmp = a;
    a = b;
    b = tmp;
  }
  int64_t r = a%b;
  while(r != 0) {
    a = b;
    b = r;
    r = a%b;
  }
  return b;
}

int main() {
  long long a, b, c, k;
  cin >> a >> b >> c >> k;
  if (k%2 == 0) {
    cout << a-b << endl;
  } else {
    cout << b-a << endl;
  }
}

Measured memory_bytes: 768
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author TM
 */


#include <bits/stdc++.h>

#define MOD 1e9+7

using namespace std;

class ERedAndGreenApples {
public:
  static void solve(std::istream &cin, std::ostream &cout) {
    int x, y, a, b, c;
    cin >> x >> y >> a >> b >> c;
    vector<int64_t> p_vec(a);
    vector<int64_t> q_vec(b);
    vector<int64_t> r_vec(c);
    priority_queue<int64_t> r_queue;
    for (int i = 0; i < a; ++i) cin >> p_vec[i];
    for (int i = 0; i < b; ++i)cin >> q_vec[i];
    for (int i = 0; i < c; ++i) cin >> r_vec[i];
    priority_queue<int64_t, vector<int64_t>, greater<int64_t >> q;
    sort(p_vec.begin(), p_vec.end(), greater<int64_t>());
    sort(q_vec.begin(), q_vec.end(), greater<int64_t>());
    sort(r_vec.begin(), r_vec.end());
    int64_t ans = 0;
    for (int j = 0; j < x; ++j) {
      q.push(p_vec[j]);
      ans += p_vec[j];
    }
    for (int j = 0; j < y; ++j) {
      q.push(q_vec[j]);
      ans += q_vec[j];
    }

    while (true) {
      int64_t r = r_vec.back();
      if (r_vec.empty())break;
      if (r > q.top()) {
        ans -= q.top();
        q.pop();
        r_vec.pop_back();
        ans += r;
      } else {
        break;
      }
    }
    cout << ans << endl;
  }
};


int main() {
  ERedAndGreenApples solver;
  std::istream &in(std::cin);
  std::ostream &out(std::cout);
  solver.solve(in, out);
  return 0;
}


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

int main(){
  int n, l;
  vector<string> v;

  cin >> n >> l;
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    v.push_back(s);
  }

  sort(v.begin(), v.end());

  string ans = "";
  for (int i = 0; i < n; i++) {
    ans += v[i];
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
a, b, c = map(int, input().split())
 
if a == 5:
  if (b == 5 and c == 7) or (c == 5 and b == 7):
    print("YES")
  else:
    print("NO")
if a == 7:
  if b == 5 and c == 5:
    print("YES")
  else:
    print("NO")

Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> H(N);
    rep(i, N) {
        cin >> H[i];
    }
    sort(H.begin(), H.end());
    long long a = 0;
    if (N > K) {
        cout << accumulate(H.begin(), H.end() - K, a) << endl;
    } else {
        cout << 0 << endl;
    }
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int cnt[39];

int main(){
  string s;
  cin>>s;
  for(int i=0;i<s.size();i++){
    cnt[s[i]-'a']++;
  }

  char ans='#';
  for(int i=25;i>=0;i--){
    if(cnt[i]==0){
      ans=(char)('a'+i);
    }
  }

  if(ans=='#'){
    cout<<"None"<<endl;
  }
  else{
    cout<<ans<<endl;
  }
  return(0);
}


Measured memory_bytes: 512
#include<iostream>

using namespace std;

int main(){
	int a, b, c, d;
	int sum,lol;
	cin >> a >> b >> c >> d;
	if(a>b){
	 sum = b;
	}
	else if(a<b){
	 sum = a;
	}
	else if(a==b){
	 sum = a;
	}
	if(c>d){
	 lol = d;
	}
	else if(c<d){
	 lol = c;
	}
	else if(c==d){
	 lol = c;
	}
	cout << lol+sum << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;

int main(){
  int N,M;
  cin >> N >> M;

  vector<int> oks(N+1,true);//壊れた床かどうかをみるvector.
  for(int i = 0;i < M;i++){
    int a; cin >> a;
    oks[a] = false;
  }

  vector<long long int> dp(N+1);//DP用のvector.
  dp[0] = 1;
  for(int now = 0;now < N;now++){//繰り返し足し上げる.(dp[2] = dp[1] + dp[0],dp[3] = dp[2] + dp[1] = d[1] + d[0] + d[0],...)
    
    for(int next = now + 1;next <= min(N,now + 2);next++){
      if(oks[next]){
        dp[next] += dp[now];
        dp[next] %= mod;
      }
    }
  }

  cout << dp[N] << endl;

  return 0;
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
#define ll long long
#define f  first
#define Tsetso ios_base::sync_with_stdio(0) ; cin.tie(0) ;
using namespace std;
const int  N = 1050, mod = 1e9+7, inf = 2e9 ;
char a[N][N];
ll dp[N][N];
int main()
{
    Tsetso
    int n, m ;
    cin >> n >> m ;
    for ( int i = 0 ; i < n ; i++)
        for ( int j = 0 ; j < m ; j++)
            cin >> a[i][j] ;
    for ( int i = 0 ; i < m ; i++)
        if (a[0][i] == '.')
            dp[0][i] = 1 ;
        else
            break;
    for ( int i = 1 ; i < n ; i++)
        if (a[i][0] == '.')
            dp[i][0] = 1 ;
        else
            break;
    for ( int i = 1 ; i < n ; i++ )
        for ( int j = 1 ; j < m ; j++)
            if (a[i][j] == '.')
                dp[i][j] = (dp[i][j-1]+dp[i-1][j])%mod ;
    cout << dp[n-1][m-1] ;
}


Measured memory_bytes: 12868
#include <iostream>
#include <algorithm>

using namespace std;

int main() {
    int n,m;
    cin >> n >> m;
    int c[m];
    int dp[n+1];
    dp[0] = 0;
    for(int i = 0; i < m; i++){
        cin >> c[i];
    }
    for(int i = 1; i <= n; i++){
        int tmp = 111111;
        for(int j = 0; j < m; j++){
            if(i-c[j] >= 0){
                tmp = min(dp[i-c[j]], tmp);
            }
        }
        tmp++;
        dp[i] = tmp;
    }
    
    cout << dp[n] << '\n';
    
}


Measured memory_bytes: 3316
#include<bits/stdc++.h>
 using namespace std;
 
 // #define  int           long long
 #define pb                push_back
 #define ppb               pop_back
 #define pf                push_front
 #define ppf               pop_front
 #define all(x)            (x).begin(),(x).end()
 #define uniq(v)           (v).erase(unique(all(v)),(v).end())
 #define sz(x)             (int)((x).size())
 #define fr                first
 #define sc                second
 #define pint              pair<int,int>
 #define rep(i,a,b)        for(int i=a;i<b;i++)
 #define mem1(a)           memset(a,-1,sizeof(a))
 #define mem0(a)           memset(a,0,sizeof(a))
 #define ppc               __builtin_popcount
 #define ppcll             __builtin_popcountll
 #define vint			   vector<int>
 #define vpint			   vector<pair<int,int>>
 #define mp                make_pair


 void reader() 
 { 
 #ifndef ONLINE_JUDGE 
 freopen("input.txt","r",stdin);
 freopen("output.txt","w",stdout); 
 #endif
 }
 
 void fastIO() {ios_base::sync_with_stdio(false); cin.tie(NULL);}
 
 
 
 void solve()
 {
 
 int d,t,s;
 cin>>d>>t>>s;
 if(s*t>=d)
 	cout<<"Yes";
 else
 	cout<<"No";
 
 
 cout<<"\n";
 }
 
 
 
 signed main()
 {
 	reader(); fastIO();
 	long long t=1;
 	//cin>>t;
 	while(t--) solve();
 	return 0;
 }

Measured memory_bytes: 3648
import java.util.Scanner;

/**
 * https://abc074.contest.atcoder.jp/tasks/arc083_a
 */
public class Main {

	static int A,B,C,D,E,F;
	static boolean[] wdp = new boolean[3001];
	static boolean[] sdp = new boolean[3001];
	
	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		A = sc.nextInt();
		B = sc.nextInt();
		C = sc.nextInt();
		D = sc.nextInt();
		E = sc.nextInt();
		F = sc.nextInt();
		sc.close();
		
		setWDP(0);
		setSDP(0);
		
		double max = 0;
		int ansW = 0;
		int ansS = 0;
		for(int i=0; i<=F/100; i++){
			int w = i*100;
			if(!wdp[w]) continue;
			int maxSugar = Math.min(F-w, i*E);
			for(int s=maxSugar; s>=0; s--){
				if(!sdp[s]) continue;
				double p = (double)(s)/(double)(w+s);
				if(max<=p){
					max = p;
					ansW = w;
					ansS = s;
				}
				break;
			}
		}		
		System.out.println(String.format("%d %d", ansW+ansS, ansS));
	}
	
	static void setWDP(int current){
		if(current>F || wdp[current]) return;
		wdp[current] = true;
		setWDP(current+A*100);
		setWDP(current+B*100);
	}
	
	static void setSDP(int current){
		if(current>F || sdp[current]) return;
		sdp[current] = true;
		setSDP(current+C);
		setSDP(current+D);
	}

}

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

#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_map>
#include <map>

#define INF 100000000
#define rep(i, a) for (int i = 0; i < (a); i++)
using namespace std;

int check(vector<int> v){
    int i;
    int flag = 1;
    for(i = 0; i < v.size(); i++){
        if(v[i] != i+1){
            flag = 0;
        }
    }

    return flag;
}

int main() {
    int n;
    cin >> n;
    vector<int> p(n);

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

    for(i = 0; i < n; i++){
        if(p[i] != i+1){
            swap(p[i], p[p[i]-1]);
            if(check(p) == 0){
                cout << "NO" << endl;
                return 0;
            }else{
                cout << "YES" << endl;
                return 0;
            }
        }
    }
    cout << "YES" << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define fr first
#define sc second
#define ll  long long
#define mp make_pair
#define mod 1000000007

using namespace std;

int main()  {
    int n;
    cin>>n;
    bool b= 1;
    int lt =0 ,lx=0,ly=0,y,x,t;
    for(int i=0 ;i <n ;i ++){
        scanf("%d%d%d",&t,&x,&y);
        ll r = abs(x-lx);
        r += abs(y-ly);
        if(r > t-lt){
            b = 0;
        }
        else{
            r -= t-lt;
            r *=-1;
            lt =t;
            if(r%2 != 0){
                b =0 ;
            }
            lx =x;
            ly =y;
        }

    }
    if(b){
        cout<<"Yes\n";
    }
    else cout<<"No\n";
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <climits>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <sstream>
#include <vector>
#include <map>
#include <set>
#include <complex>
#include <functional>
#include <utility>
#include <iterator>

#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, m, n) for(int i = (m); i < (int)(n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define INF 2000000000

#ifdef LOCAL
  #define dprintf(...) fprintf(stdout, __VA_ARGS__)
#else
  #define dprintf(...) 0
#endif

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef unsigned int uint;

//const double PI = 3.1415926535897932384626433832795;

int main() {
  int a, b;
  cin >> a >> b;

  if(a % 2 != b %2) {
    cout << "IMPOSSIBLE" << '\n';
  }
  else {
    cout << (a + b) / 2 << '\n';
  }

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))


const int MAX_N = 10010, MAX_W = 10010, MAX_V = 10010;

int N;
string s;
int cR = 0, cB = 0;

int main()
{
	cin >> N;
	cin >> s;
	for (int i = 0; i < N; i++)
	{
		if (s[i] == 'R')
		{
			cR++;
		}
		else
		{
			cB++;
		}
	}
	if (cR > cB)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i= (a); i < (b); ++i)
typedef long long ll;
typedef pair<int,int> P;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
struct Edge {
  ll to;
  ll cost;
};
int main() { int N;
  cin >> N;
  vector<int> d(N);
  REP(i, N) cin >> d[i];
  sort(d.begin(), d.end());
  cout << d[N / 2] - d[N / 2 - 1] << endl;
}

Measured memory_bytes: 640
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce


sys.setrecursionlimit(2147483647)
INF = 10 ** 13
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007



class UnionFind:
    def __init__(self, n):
        # 負  : 根であることを示す。絶対値はランクを示す
        # 非負: 根でないことを示す。値は親を示す
        self.table = [-1] * n
        self.size = [1] * n
        self.cycle = [0] * n
        self.group_num = n

    def root(self, x):
        if self.table[x] < 0:
            return x
        else:
            self.table[x] = self.root(self.table[x])
            return self.table[x]

    def is_same(self, x, y):
        return self.root(x) == self.root(y)

    def get_size(self, x):
        return self.size[self.root(x)]

    def unite(self, x, y):
        r1 = self.root(x)
        r2 = self.root(y)
        if r1 == r2:
            return
        # ランクの取得
        d1 = self.table[r1]
        d2 = self.table[r2]
        if d1 <= d2:
            self.table[r2] = r1
            self.size[r1] += self.size[r2]
            self.cycle[r1] += self.cycle[r2]
            if d1 == d2:
                self.table[r1] -= 1
        else:
            self.table[r1] = r2
            self.size[r2] += self.size[r1]
            self.cycle[r2] += self.cycle[r1]
        self.group_num -= 1


    def get_cycle(self, x):
        return self.cycle[self.root(x)]

    def add_cycle(self, x):
        self.cycle[self.root(x)] += 1
        return


n, h, w = LI()
uf = UnionFind(h + w)
ans = 0
rca = sorted(LIR(n), key=lambda x:x[2], reverse=True)
for r, c, a in rca:
    r -= 1; c -= 1
    if uf.is_same(r, h + c):
        if uf.get_cycle(r):
            continue
        else:
            uf.add_cycle(r)
            ans += a
    else:
        if uf.get_cycle(uf.root(r)) and uf.get_cycle(uf.root(h + c)):
            continue
        else:
            uf.unite(r, h + c)
            ans += a


print(ans)

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

set<char> digits;

bool check(int n) {
	stringstream ss;
	ss << n;
	string s = ss.str();
	for (int i = 0; i < s.size(); i++) {
		if(digits.count(s[i])) return 1;
	}
	return 0;
}

int main() {
#ifdef _DEBUG
	freopen("in" , "r", stdin );
	freopen("out", "w", stdout);
#endif
	ios::sync_with_stdio(0); cin.tie(0);
	int n, k; cin >> n >> k;
	for (int i = 0; i < k; i++) {
		char c; cin >> c;
		digits.insert(c);
	}
	while(check(n)) n++;
	cout << n << '\n';
}


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

int main(){
  int a, b, c, d, e;
  cin>>a>>b>>c>>d>>e;
  int x1 = a + d - 50;
  int x2 = a + e - 50;
  int x3 = b + d - 50;
  int x4 = b + e - 50;
  int x5 = c + d - 50;
  int x6 = c + e - 50;
  int x[6] = {x1, x2, x3, x4, x5, x6};
  int min = x[0];
  for(int i=0;i<6;i++){
    if(min > x[i]) min = x[i];
  }
  cout<<min<<endl;
	
  return 0;
}



Measured memory_bytes: 3096
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,s,e) for (int i=s;i<(e);i++)
#define All(v) (v).begin(),(v).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define fi first
#define se second
#define int long long
using namespace std;
typedef long long llint;
typedef pair<int, int> P;
const int MOD = (int)1e9 + 7;
const int INF = (int)1e18 * 5;

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

    int N;
    cin >> N;
    while(N != 0){
        vector<vector<int> > F(21, vector<int>(21, 0)); 
        REP(i, N){
            int x, y;
            cin >> x >> y;
            F[y][x] = 1;
        }
        int ans = N;

        int nx=10, ny=10;
        int M;
        cin >> M;
        REP(i, M){
            char d;
            int len;
            cin >> d >> len;

            switch(d){
                case 'N':
                FOR(y, ny, ny+len+1){
                    if(F[y][nx] == 1){
                        --ans;
                        F[y][nx] = 0;
                    }
                }
                ny += len;
                break;
                case 'S':
                for(int y=ny; y > ny-len-1; y--){
                    if(F[y][nx] == 1){
                        --ans;
                        F[y][nx] = 0;
                    }
                }
                ny -= len;
                break;
                case 'E':
                FOR(x, nx, nx+len+1){
                    if(F[ny][x] == 1){
                        --ans;
                        F[ny][x] = 0;
                    }
                }
                nx += len;
                break;
                case 'W':
                for(int x=nx; x > nx-len-1; x--){
                    if(F[ny][x] == 1){
                        --ans;
                        F[ny][x] = 0;
                    }
                }
                nx -= len;
                break;
            }
        }
        if(ans == 0) cout << "Yes\n";
        else cout << "No\n";
        cin >> N;
    }
    return 0;
}


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

int bubbleSort(int A[], int N) {
    int flag = 1;
    int tmp, c = 0;
    while (flag == 1) {
        flag = 0;
        for (int j = N-1; j >= 1; j--) {
            if (A[j] < A[j-1]) {
                tmp = A[j];
                A[j] = A[j-1];
                A[j-1] = tmp;
                flag = 1;
                c++;
            }
        }
    }
    for(int i = 0; i < N-1; i++) cout << A[i] << " ";
    cout << A[N-1] << endl;
    return c;
}

int main() {
    int N;
    cin >> N;
    int A[N];
    for (int i = 0; i < N; i++) cin >> A[i];

    int c = bubbleSort(A, N);
    cout << c << endl;
}


Measured memory_bytes: 3096
m, d = map(int, input().split())
res = 0
for i in range(1, m + 1):
    for j in range(1, d + 1):
        if j >= 20 and j%10 >= 2:
            if i == int(str(j)[1]) * int(str(j)[0]):
                res += 1
print(res)

Measured memory_bytes: 39280
#include<iostream>
using namespace std;
main(){
  int n,count=0,s,maxs,mins;
  while(1){
    cin>>n;
    if(n==0)break;
    cin>>s;
    count=count+s;
    maxs=s;
    mins=s;
    for(int i=1;i<n;i++){
      cin>>s;
      count=count+s;
      if(s>maxs){
	maxs=s;
      }
      else if(mins>s){
	mins=s;
      }
    }
    cout<<(count-maxs-mins)/(n-2)<<endl;
    count=0;
  }
}

Measured memory_bytes: 1160
import sys
def input(): return sys.stdin.readline().rstrip()

def main():
    K, N = map(int, input().split())
    A = list(map(int, input().split()))
    print(K - max([A[i+1] - A[i] for i in range(N-1)] + [K-A[N-1]+A[0]]))

if __name__ == '__main__':
    main()


Measured memory_bytes: 25928
def main():
    N = int(input())
    A = [int(x) for x in input().split()]

    import collections
    count = collections.Counter(A)
    s = sum(A)

    Q = int(input())
    for _ in range(Q):
        B, C = [int(x) for x in input().split()]
        if B not in count:
            print(s)
            continue
        c = count[B]
        del count[B]
        count[C] = count.get(C, 0) + c
        s = s - B*c + C*c
        print(s)
 
 
if __name__ == '__main__':
    import sys
    sys.setrecursionlimit(10000)
    main()

Measured memory_bytes: 21220
S = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
K = int(input())
print(S[K-1])

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
    int n;double *nam, ans;
    cin>>n;
    nam=new double[n];
    for(int i=0; i<n; i++)
        cin>>nam[i];
    sort(nam,nam+n);
    for(int i=0; i<n; i++)
    {
        nam[i+1]=(nam[i]+nam[i+1])/2;
    }
    cout << nam[n-1] << '\n';
}

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

#define rng(i, a, b) for (int i = int(a); i < int(b); i++)
#define rep(i, b) rng(i, 0, b)
#define gnr(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define per(i, b) gnr(i, 0, b)

using namespace std;

using ll = long long;
using P = pair<int, int>;

static const ll MOD = 998244353;

ll modPow(ll a, ll b) {
  ll res = 1;
  rep(i, b) {
    res = res * a % MOD;
  }
  return res;
}

int main() {
  int n;
  cin >> n;
  vector<int> d(n);
  rep(i, n) {
    int dd;
    cin >> dd;
//    if (i == 0 && dd != 0) {
//      cout << 0 << endl;
//      return 0;
//    }
    if (i != 0 && dd == 0) {
      cout << 0 << endl;
      return 0;
    }
    d.at(i) = dd;
  }
  map<int, int> mp;
  for (int dd : d) {
    mp[dd]++;
  }
  ll res = 1;
  rep(i, mp.size()) {
    ll tmp = (ll) mp[i];
    // 途中が0なら成立しない
    if (tmp == 0) {
      cout << 0 << endl;
      return 0;
    }
    if (i == 0) {
      continue;
    }
    ll tmp2 = (ll) mp[i - 1];
    res = res * modPow(tmp2, tmp) % MOD;
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 8176
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define rv(s) reverse(s.begin(),s.end());
 
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using vpii = vector<pii>;
using vs = vector<string>;
using vd = vector<double>;
using ul = unsigned long;

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

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; }

const int MAXN=1005; // 選手数
const int MAXV=MAXN*(MAXN-1)/2; // 頂点の最大数(試合数)

vi to[MAXV]; // DAGの辺を格納する. これはvector<int>型の配列

// 引数i, jは選手で、試合IDを取得する
int id[MAXN][MAXN];
int toId(int i, int j){
  if(i > j) swap(i,j); // i>jはi<jと同一の試合と判定する
  return id[i][j];
}

bool visited[MAXV]; // 頂点が探索済みかを判定する. dpのメモ化用
bool calculated[MAXV]; // 頂点が計算を終えたものかを判定する. 閉路検出用
int dp[MAXV]; // vからスタートした時の最長経路
int dfs(int v){
  if(visited[v]) {
    if(!calculated[v]) return -1; // 閉路判定
    return dp[v];
  }
  visited[v] = true;
  dp[v] = 1; // 頂点の個数
  for(int u: to[v]){ // 接続する頂点がない場合、ループを抜ける
    int res = dfs(u);
    if(res == -1) return -1;
    dp[v] = max(dp[v], res+1);
  }
  calculated[v] = true; // dfsの末端で計算終了判定を行う
  return dp[v];
}

int main()
{
  cin.tie( 0 );
  ios::sync_with_stdio( false );
  
  int n;
  cin>>n;
  
  vvi a(n, vi(n-1));
  rep(i, n){
    rep(j, n-1){
      cin >> a[i][j];
      a[i][j]--;
    }
  }
  
  int V=0; // 頂点数
  rep(i, n) rep(j, n) { // 各頂点(試合)に対してIDを割り振る
    if(i < j){
      id[i][j] = V++;
    }
  }
  
  rep(i, n) {
    rep(j, n-1) {
      a[i][j] = toId(i,a[i][j]); // a[i][j]つまり対戦相手を頂点IDに書き換える
    }
    rep(j, n-2) {
      to[a[i][j+1]].push_back(a[i][j]); // グラフの作成
    }
  }
  int ans = 0;
  rep(i, V){
    int res = dfs(i);
    if(res == -1){
      cout << -1 << endl;
      return 0;
    }
    ans = max(ans, res);
  }
  cout << ans << endl;
}

Measured memory_bytes: 38528
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(void){
  int a;
  char str[100],s[12],*p;
  
  fgets(str,sizeof(str),stdin);
  a=atoi(str);
  fgets(str,sizeof(str),stdin);
  p=strtok(str," \n");
  strcpy(s,p);
  
  if(a>=3200){
    printf("%s",s);
  }else{
    printf("red");
  }
  
  return 0;
}

Measured memory_bytes: 256
import math

n = int(input())
answers = []

def is_prime(n):
  for i in range(2, int(math.sqrt(n)) + 1):
    if n % i == 0:
      return False
  
  return True

start = 11
for i in range(n):
  for j in range(start, 55555, 5):
    if is_prime(j):
      answers += [str(j)]
      start = j + 5
      break

print(" ".join(answers))

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long int;
using ull = unsigned long long int;

int main() {
    int n;
    cin >> n;

    bool found = false;
    int count = 0;
    rep(i, n) {
        int d1, d2;
        cin >> d1 >> d2;
        if (d1 == d2) {
            ++count;
            if (count == 3) {
                found = true;
            }
        } else {
            count = 0;
        }
    }

    if (found) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


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

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

  int n;
  cin >> n;

  for (int i = 1; i <= 9; ++i) {
    for (int j = 1; j <= 9; ++j) {
      if (i * j == n) {
        cout << "Yes\n";
        return (0);
      }
    }
  }

  cout << "No\n";

  return (0);
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 110;
map<int,int> mp;
int main() {
	int n, x;

	cin >> n;
	int MAX1 = 0, MAX2 = 0;
	for(int i = 0; i < n; i ++) {
		scanf("%d", &x);
		if(mp.count(x)) {
			if(x > MAX1) {
				MAX2 = MAX1;
				MAX1 = x;
			} else if(x > MAX2) {
				if(x == MAX1 && mp[x] >= 3) {
					MAX2 = x;
				} else if(x < MAX1) MAX2 = x;
			}
		}
		mp[x] ++;
	}
	printf("%lld\n",1LL*MAX1*MAX2);
	return 0;
}

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

int main(){
    int n,h,m,s;
    cin >> n;
    h = n / 3600;
    m = n % 3600 / 60;
    s = n % 60;
    cout << h << ":" << m << ":" << s << endl;
    
}


Measured memory_bytes: 3104
s = input()
n = int(input())
for i in range(n):
    command = input().split()
    c1, c2 = int(command[1]), int(command[2])+1
    if command[0] == 'print':
        print(s[c1:c2])
    elif command[0] == 'reverse':
        s0 = list(s[c1:c2])
        s0.reverse()
        s1 = ''.join(s0)
        s = s[:c1]+s1+s[c2:]
    elif command[0] == 'replace':
        s = s[:c1]+command[3]+s[c2:]



Measured memory_bytes: 5620
import java.util.*;
import static java.lang.System.*;

public class Main {

	Scanner sc = new Scanner(in);
	
	void run() {
		int n;
		int a[];
		int ans;
		while (true) {
			n = sc.nextInt();
			if (n == 0) break;
			a = new int[n];
			for (int i = 0; i < n; i++)
				a[i] = sc.nextInt();
			Arrays.sort(a);
			ans = 0;
			for (int i = 1; i < n-1; i++) {
				ans += a[i];
			}
			System.out.println(ans/(n-2));
		}
		
	}
	
	public static void main(String[] args) {
		new Main().run();
	}

}

Measured memory_bytes: 20932
#include<bits/stdc++.h>
#define pb push_back
#define mod int(1e9+7)
#define N int(2e5+100)
#define ll long long int
#define pp pair<int,int>
#define pl pair<ll,ll>
#define fi first
#define si second
using namespace std;
ll n,u,v,par[N],size[N],ans[N];
ll dp[N],fact[N];
vector<ll>g[N];
ll power(ll x,ll n){
	if(n==0){
		return 1ll;
	}
	ll y=power(x,n/2);
	y=(y*y)%mod;
	if(n%2){
		return (x*y)%mod;
	}
	return y;
}
void pre(){
	fact[0]=1;
	for(ll i=1;i<N;i++){
		fact[i]=(i*fact[i-1])%mod;
	}
}
void dfs(ll s,ll p){
	par[s]=p;
	size[s]=1;
	for(ll i=0;i<g[s].size();i++){
		if(g[s][i]!=p){
			dfs(g[s][i],s);
			size[s]+=size[g[s][i]];
		}
	}
	return;
}
void dfs1(ll s,ll p){
	ll d=1ll;
	dp[s]=fact[size[s]-1];
	for(ll i=0;i<g[s].size();i++){
		if(g[s][i]!=p){
			dfs1(g[s][i],s);
			d=(d*fact[size[g[s][i]]])%mod;
			dp[s]=(dp[s]*dp[g[s][i]])%mod;
		}
	}
	dp[s]=(dp[s]*power(d,mod-2))%mod;
}
ll reRoot(ll s,ll p){
	if(p==-1 ) {
		return dp[s];
	}
	if(ans[s]){
		return ans[s];
	}
	ll dpp=reRoot(p,par[p]);
	ll dps=dp[s],szp=n-size[s],d;
	d=(fact[n-1]*dps)%mod;
	dpp=(dpp*power(d,mod-2))%mod;
	dpp=(dpp*fact[size[s]])%mod;
	dpp=(dpp*fact[szp-1])%mod;
	d=(fact[size[s]-1]*fact[szp])%mod;
	dps=(dps*power(d,mod-2))%mod;
	dps=(dps*dpp)%mod;
	dps=(dps*fact[n-1])%mod;
	ans[s]=dps;
	return ans[s];
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
	cin>>n;
	pre();
	for(ll i=1;i<n;i++){
		cin>>u>>v;
		g[v].pb(u);
		g[u].pb(v);
	}
	dfs(1,-1);
	dfs1(1,-1);
	ans[1]=dp[1];
	for(ll k=1;k<=n;k++){
		cout<<reRoot(k,par[k])<<endl;
	}
    return 0;
}



Measured memory_bytes: 22512
#define ll    long long
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin>>s;

       if(s[2]==s[3])
       {
           if(s[4]==s[5])
            cout<<"Yes"<<endl;
            else
                cout<<"No"<<endl;
       }
       else
        cout<<"No"<<endl;

return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef  long long ll;
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;}

template<class T> ll llpow(T x,T n){ll ans=1;while(n--){ans*=x;}return ans;}
template<class T> inline T gcd(T x,T y){if(y==0)return x; else {return gcd(y,x%y);}}
template<class T> inline T lcm(T x,T y){return x/gcd(x,y)*y;}

#define rep(i,n) for(ll i=0;i<(ll)n;i++)
#define rep2(i, begin_i, end_i) for (ll i = (ll)begin_i; i < (ll)end_i; i++)

long long INF = 1LL<<60;
int main(){
    string s[3];
    rep(i,3)cin>>s[i];
    int turn=0; //0:a,1:b,2:c
    int winner;
    int p[]={0,0,0};
    while(!(p[turn]==s[turn].size())){
        p[turn]++;
        turn=s[turn].at(p[turn]-1)-'a';
    }
    char ans='A'+turn;
    cout<<ans<<endl;
    return 0;
}




Measured memory_bytes: 256
stdin.ReadLine().ToCharArray()
|> fun a ->
    let x =
        Array.take 3 a |> Array.groupBy id |> Array.length

    let y =
        Array.rev a
        |> Array.take 3
        |> Array.groupBy id
        |> Array.length

    if x = 1 || y = 1 then "Yes" else "No"
|> printfn "%s"


Measured memory_bytes: 29704
import java.util.Arrays;
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int cnt = 0;
    int[] h = new int[N + 1];
    while (++cnt <= N) {
      h[cnt] = sc.nextInt();
    }
    int[] min = new int[N + 1];
    Arrays.fill(min, Integer.MAX_VALUE / 2);
    min[1] = 0;
    for (int i = 2; i < min.length; i++) {
      min[i] = Math.min(
              min[i-2] + Math.abs(h[i] - h[i-2]),
              min[i-1] + Math.abs(h[i]- h[i-1]));
    }
    System.out.println(min[N]);
  }
}

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

int main() {
    int k, n;
    cin >> k >> n;
    int longest = 0;
    vector<int> a(n);
    for (int i = 0; i < n; i++)
    {
        cin >> a.at(i);
    }

    for (int i = 0; i < n-1; i++)
    {
        longest = max(longest, (a.at(i+1) - a.at(i)));
    }
    longest = max(longest, k + a.at(0) - a.at(n-1));

    cout << k - longest << endl;
    
    
    return 0;
}

Measured memory_bytes: 1152
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
using namespace std;

#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define ldb ldouble

typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 18;
int MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;
#define szz(x) (int)(x).size()
#define rep(i, n) for(int i=0;i<n;i++)
#define Se second
#define Fi first

const int MX = 1<<18;
const int MM = 1000000007;

ll sum[30];
ll A[MX], B[MX];

int main()
{
	int N;
	scanf("%d", &N);
	for(int i = 1; i <= N; i++) scanf("%lld", A+i);
	for(int i = 1; i <= N; i++) scanf("%lld", B+i);

	int ans = 0;
	for(int t = 28; t >= 0; t--){
		int cur = 1<<t;
		vector<int> L, R;
		for(int i = 1; i <= N; i++){
			L.push_back(A[i]&(cur*2-1));
		}
		for(int i = 1; i <= N; i++){
			int v = B[i] & (cur*2-1);
			R.push_back(v);
		}
		sort(L.begin(), L.end(), greater<int>());
		sort(R.begin(), R.end());

		int l = 0, r = 0, ct = 0;
		for(int c : L){
			while(l < R.size() && R[l] < cur-c) l++;
			while(r < R.size() && R[r] < cur*2-c) r++;
			ct += r-l;
		}
		l = 0, r = 0;
		for(int c : L){
			while(l < R.size() && R[l] < cur*3-c) l++;
			while(r < R.size() && R[r] < cur*4-c) r++;
			ct += r-l;
		}
		if(ct%2) ans |= 1<<t;
	}
	printf("%d\n", ans);
}


Measured memory_bytes: 6508
#include <iostream>
#include <regex>
#include <stdio.h>
#include <string>

using namespace std;

int main() {
  int A, B;
  string S;
  cin >> A >> B >> S;
  regex rx(R"([0-9]{)" + to_string(A) + R"(}-[0-9]{)" + to_string(B) + R"(})");
  if (regex_match(S, rx)) {
    printf("Yes\n");
  } else {
    printf("No\n");
  }
}

Measured memory_bytes: 3184
// 見せてやるぜ、奇跡ってやつをよぉ……
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
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; }
#define DEBUG_VLL(vec) REP(sz, vec.size()) cerr<<vec[sz]<<(sz==vec.size()-1?'\n':' ');

const ll MOD = 1000000007;
const ll HIGHINF = (ll)1e18;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll m; cin >> m;
    vll d(m), c(m);
    REP(i, m) cin >> d[i] >> c[i];
    ll ans = accumulate(ALL(c), 0LL) - 1;
    ll tmp = 0;
    REP(i, m) {
        tmp += d[i] * c[i];
    }
    cout << ans + (tmp - 1) / 9 << '\n';
    return 0;
}


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

#define ll                     long long
#define loop( i,a)             for(i=0;i<a;i++)
#define loop1(i,a)             for(i=1;i<=a;i++)
#define ppp(a)                 cout<<a<<endl;
#define sscd(a)                scanf("%lf",&a)
#define sss(a)                 cin>>a
#define scc(a)                 scanf("%c",&a)
#define FOR(i,a,b)             for(i=a;i<b;i++)
#define FORE(i,a,b)            for(i=a;i<=b;i++)
#define reverses(s)            reverse(s.begin(),s.end())
#define inf                    9000000000000000
#define pii                    3.1415926536
#define pb(a)                  push_back(a)
#define pppp(a,b)              cout<<a<<"  "<<b;
#define newline                printf("\n");
#define sorted(a)               sort(a.begin(),a.end())


int main()
{
    ll n,y,m,r10k=0,r5k=0,r1k=0,nn,r;
    cin>>n>>y;
    m=y;
    r10k=m/10000;
    m=m%10000;
    r5k=m/5000;
    m=m%5000;
    r1k=m/1000;
    m=m%1000;
    if(m>0)
    {
        ppp("-1 -1 -1")
        return 0;
    }
    if(n<(r10k+r5k+r1k))
    {
        ppp("-1 -1 -1")
        return 0;
    }
    if(n==(r10k+r5k+r1k))
    {
        printf("%lld %lld %lld\n",r10k,r5k,r1k);
        return 0;
    }
    nn=y/1000;
    for(ll i=0;i<=20000;i++)
    {
        for(ll j=0;j<=10000;j++ )
        {
            if(i+j*5>nn)
                continue;
            if((nn-(i+5*j))%10==0)
            {
                if((i+j+(nn-(i+5*j))/10)==n)
                {
                    printf("%lld %lld %lld\n",(nn-(i+5*j))/10,j,i);
                    return 0;
                }
            }
        }
    }

        ppp("-1 -1 -1")

    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
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; }

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ for(auto it : P) { s << "<" << it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ for(auto it : P) { s << "<" << it.first << "->" << it.second << "> "; } return s << endl; }

bool isAGCT(char c) {
    return (c == 'A' || c == 'G' || c == 'C' || c == 'T');
}

int main() {
    string S;
    cin >> S;
    int res = 0;
    for (int i = 0; i < S.size();) {
        int j = i;
        while (j < S.size() && isAGCT(S[i]) == isAGCT(S[j])) ++j;
        if (isAGCT(S[i])) chmax(res, j - i);
        i = j;
    }
    cout << res << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 100000000;
#define rep1(i, n) for (ll i=0; i<(n); i++) 
#define rep2(i, k, n) for (ll i=k; i<(n); i++)
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() {
    ll n;
    cin >> n;
    vector<ll> a(n), b(n), c(n);
    rep1(i, n) cin >> a[i];
    rep1(i, n) cin >> b[i];
    rep1(i, n) cin >> c[i];
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    sort(c.begin(), c.end());
    ll ans = 0;
    rep1(i, n){
        ll cnt = 1;
        ll left = -1;
        ll right = n;
        while (right-left>1){
            ll mid = (left+right) / 2;
            if (a[mid]<b[i]) left = mid;
            else right = mid;
        }
        cnt *= right;
        left = -1;
        right = n;
        while (right-left>1){
            ll mid = (left+right) / 2;
            if (c[mid]<=b[i]) left = mid;
            else right = mid;
        }
        cnt *= n - right;
        ans += cnt;
    }
    cout << ans << endl;
    //printf("%.12f", ans);
}

Measured memory_bytes: 5612