akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <vector>
#include <cstring>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <bitset>

using namespace std;

typedef pair<int,int> ii;
typedef vector<int> vi;
#define REP(i, a, b) for(int i = int(a); i <= int(b); i++)
#define LOOP(i, v) for(int i = 0; i < v.size(); i++)
#define EPS 1e-9
#define INF 1e12
#define debug(x) cerr << "DEBUG : " << (#x) << " => " << (x) << endl

int main()
{
  int N;
  
  scanf("%d\n", &N);
  
  string s;
  
  getline(cin, s);
  
  long long int dp[20][20];
  long long int ans;
  
  REP(b, 0, (1 << N)-1)
  {
    string x, y;
    REP(i, 0, N-1)
    {
      if(b & (1 << i)) x.push_back(s[2*N-1-i]);
      else y.push_back(s[2*N-1-i]);
    }
    
    dp[0][0] = 1;
    
    REP(l, 1, N)
    {
      for(int a = 0; a <= x.size() && a <= l; a++)
      {
        int aa = l-a;
        dp[l][a] = 0;
        if(a >= 1 && x[a-1] == s[l-1])
        {
          dp[l][a] += dp[l-1][a-1];
        }
        if(aa >= 1 && y[aa-1] == s[l-1])
        {
          dp[l][a] += dp[l-1][a];
        }
      }
    }
    for(int a = 0; a <= x.size() && a <= N; a++) ans += dp[N][a];
  }
  
  cout << ans << endl;
    
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <functional>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main(void){
    int a, b;
    cin >> a >> b;
    FOR(x,1,10000){
        if (x *  8 / 100 != a) continue;
        if (x * 10 / 100 != b) continue;
        cout << x << endl;
        return 0;
    }
    cout << -1 << endl;
    return 0;
}


Measured memory_bytes: 256
// 解き直し.
// https://img.atcoder.jp/data/agc/004/editorial.pdf
#include <bits/stdc++.h>
using namespace std;
using vvi = vector<vector<int>>;
using P = pair<int, int>;
#define repex(i, a, b, c) for(int i = a; i < b; i += c)
#define repx(i, a, b) repex(i, a, b, 1)
#define rep(i, n) repx(i, 0, n)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define a first
#define b second
#define pb push_back
int bef[101010];  // テレポーターの情報.
int cur[101010];  // テレポーターの情報(コピー).
int d[101010];    // 首都 からの 距離 を 保存.
int memo[101010]; // 訪問済みフラグ.

// グラフを幅優先探索する.
// https://ja.wikipedia.org/wiki/幅優先探索
// ※bfsの動作確認用.
// @param G: グラフ.
// @param s: グラフの探索開始頂点.
// @param d: 探索開始地点からの距離.
// @return: 特に無し.
void bfs(vvi &G, int s, int* d){
    // 1. 空のキュー.
    queue<int> q;
    
    // 2. 訪問済みフラグ設定.
    d[s] = 0; // スタート地点は, 距離ゼロを指定.
    
    // 3. 探索地点 s をキュー q に追加.
    q.push(s);
    while(!q.empty()){
        // 4. キューから取り出す.
        int u = q.front();
        q.pop();
        
        // 5. 取り出した要素を処理.
        for(auto &e : G[u]){
            // 6. 訪問済であれば, 処理をスキップ.
            if(d[e] > 0)            continue;
            if(d[e] == 0 && e != s) d[e] = d[u] + 1, q.push(e);
        }
    }
    return;
}

int main(){
    
    // 1. 入力情報.
    int N, K, ans = 0;
    scanf("%d %d", &N, &K);
    vvi G(N);
    rep(i, N){
        scanf("%d", &bef[i]);
        bef[i]--;
        cur[i] = bef[i];
        if(i == 0){
            if(bef[i]) cur[i] = 100000; // 首都から出る辺は首都へ戻る自己ループ.
            continue;
        }
        G[i].pb(bef[i]);
        G[bef[i]].pb(i);
    }
    
    // 2. 首都 から 各頂点までの距離を計算.
    bfs(G, 0, d);
    
    // 3. 首都 から 遠い順に並び替え.
    priority_queue<P> pq;
    repx(i, 1, N) pq.push({d[i], i});
    // while(!pq.empty()){
    //     P p = pq.top();
    //     pq.pop();
    //     printf("dist=%d v=%d\n", p.a, p.b);
    // }
    
    // 4. テレポーターの転送先変更.
    // -> 首都から遠い町から, 首都に向かって, 進み, 
    // (K - 1)進んだら, 終了 を 繰り返す.
    while(!pq.empty()){
        // 頂点を一つ取得.
        P v = pq.top();
        pq.pop();
        
        // 訪問済みか確認, 未訪問なら訪問済みへ.
        if(memo[v.b]) continue;
        memo[v.b] = 1;
        
        // 親頂点へ繰り返し移動.
        int move = 0;
        int c = v.b;    // 子頂点.
        int p = bef[c]; // 親頂点.
        while(p > 0 && !memo[p]){
            if(move == K - 1) break;
            move++;        // 移動距離.
            memo[p] = 1;   // 訪問済みに設定.
            c = p;         // 子頂点.
            p = bef[c];    // 親頂点.
        }
        
        // テレポーターの転送先が, 首都でない場合は, 首都に変更.
        if(p && move == K - 1) cur[c] = 100000;
    }
    // rep(i, N) printf("%d ", bef[i]);
    // puts("");
    // rep(i, N) printf("%d ", cur[i]);
    // puts("");
    
    // 5. テレポーターの転送先変更回数を確認.
    rep(i, N) if(bef[i] != cur[i]) ans++;
    printf("%d\n", ans);
    return 0;
    
}

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

#define ll long long
#define pb push_back
#define N 1000000007
#define nmax 200001
#define pll pair<ll,ll>
#define fill_nums(A,n) for(ll i=0;i<n;i++) scanf("%lld",&A[i]);
#define fill_edges(adj,m) for(ll i=0;i<m;i++) {ll a, b; scanf("%lld %lld",&a,&b); adj[a-1].pb(b-1); adj[b-1].pb(a-1);}
#define fill_direct(adj,m) for(ll i=0;i<m;i++) {ll a, b; scanf("%lld %lld",&a,&b); adj[a-1].pb(b-1);}

ll extended_gcd(ll a, ll b, ll &x, ll &y) {
	if(a==0) {
		x = 0;
		y = 1;
		return b;
	}

	ll x1,y1;
	ll gcd = extended_gcd(b%a,a,x1,y1);

	x = y1 - (b/a)*x1;
	y = x1;

	return gcd;
}

int main() {
    
   	ll n; cin>>n;
   	vector<pair<ll,ll>> vec(n);
   	for(int i=0;i<n;i++) {
   		scanf("%lld",&vec[i].first);
   	}

   	for(int i=0;i<n;i++) {
   		scanf("%lld",&vec[i].second);
   	}

   	vector<ll> vals(n,0); 

   	ll base = 1;
   	while(base<n)
   		base*=2;

   	vector<ll> tree(2*base,0);
   	ll maxi = 0;
   	for(int i=0;i<n;i++) {
   		
   		ll a = vec[i].first;
   		ll b = vec[i].second;

   		ll best = 0, x = base+a-1;

   		while(x>1) {
   			if(x%2==1)
   				best = max(best, tree[x-1]);
   			x/=2;
   		}
   		
   		vals[a-1] = b+best;

		x = base+a-1;

   		while(x>=1) {
   			tree[x] = max(vals[a-1], tree[x]);
   			x/=2;
   		}	
   		
   		maxi = max(maxi, vals[a-1]);
   	}

   	cout<<maxi<<endl;

	return 0;
}


 

Measured memory_bytes: 9088
s=input()
if s=="SUN":
    print("7")
if s=="MON":
    print("6")
if s=="TUE":
    print("5")
if s=="WED":
    print("4")
if s=="THU":
    print("3")
if s=="FRI":
    print("2")
if s=="SAT":
    print("1")


Measured memory_bytes: 3060
#include<stdio.h>
#include<stdlib.h>

int main() {
	/*
	 参加者N人
	 初期ポイントK
	 問題数Q
	 */
	/*変数宣言*/
	int N, K, Q;
	int point[100000]; //全員分のポイント
	int x; //受け取り用
	int kq; //K-Q用

	/*変数受け取り*/
	scanf("%d %d %d", &N, &K, &Q);

	/*初期持ち点から正解者分の点数を引いたものを格納*/
	kq = K - Q;
	for (int i = 1; i <= N; ++i) {
		point[i] = kq;
	}

	/*正解者に+1*/
	for (int i = 0; i < Q; ++i) {
		scanf("%d", &x);
		point[x]++;
	}

	/*出力*/
	for (int i = 1; i <= N; ++i) {
		/*printf("%dのポイントは%d\n",i,point[i]);*/
		if (point[i] <= 0) {
			printf("No\n");
		} else {
			printf("Yes\n");
		}
	}

	return 0;
}


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

int main(){
    int ans;
    vector<int> a(3);
    for(int i=0;i<3;i++) cin >> a[i];
    sort(a.begin(),a.end());
    ans=a[0]-a[2];
    cout << abs(ans) << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void) {
	int a, b;

	cin >> a >> b;

	if (a > b) {
		cout << "a > b" << endl;
	}
	else if (a < b) {
		cout << "a < b" << endl;
	}
	else if (a == b) {
		cout << "a == b" << endl;
	}

	return 0;
}

Measured memory_bytes: 3096
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#define mkp make_pair
#define pr(num) cout << num << "\n"
#define max(a, b) ((a)>(b) ? (a):(b))
#define min(a, b) ((a)<(b) ? (a):(b))
#define INF 1000000000000000000
#define MOD 1000000007LL
#define MAX 100010
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef map<ll, ll> Map;

ll H, W, K;

bool check(ll k) {
    bool ok=true;
    
    for (ll l = 0; l < W - 2; ++l) {
        if (((k >> l) & 1) && ((k >> (l + 1)) & 1)) {
            ok = false;
        }
    }
    return ok;
}

int main() {
    cin >> H >> W >> K;
    K--;
    ll dp[H+1][W];
    memset(dp, 0, sizeof(dp));
    dp[0][0]=1;
    
    for (ll i = 0; i < H; ++i) {
        for (ll j = 0; j < W; ++j) {
            for (ll k = 0; k < 1 << (W - 1); ++k) {
                // Check if two horizontal lines are connecting
                // 2 つの横線がつながっていないか調べる
                bool ok = check(k);
                
                if (!ok) continue;
                
                if (j >= 1 && ((k >> (j - 1)) & 1)) {
                    // The case which goes left
                    // 左方向に横線をたどるケース
                    dp[i + 1][j - 1] += dp[i][j];
                    dp[i + 1][j - 1] %= MOD;
                }
                else if (j <= W - 2 && ((k >> j) & 1)) {
                    // The case which goes right
                    // 右方向に横線をたどるケース
                    dp[i + 1][j + 1] += dp[i][j];
                    dp[i + 1][j + 1] %= MOD;
                }
                else {
                    // The case which goes straight
                    // 横線をたどらないケース
                    dp[i + 1][j] += dp[i][j];
                    dp[i + 1][j] %= MOD;
                }
                
            }
        }
    }
    cout << dp[H][K] << '\n';
    return 0;
}


Measured memory_bytes: 256
/***
**                      ALLAHU AKBAR
**
**     Author: Khairul Anam Mubin
**     Bangladesh University of Business and Technology,
**     Dept. of CSE.
***/
#include <bits/stdc++.h>
using namespace std;
 
#define F            first
#define S            second  
#define Fin          freopen("input.txt","r",stdin)
#define Fout         freopen("output.txt","w",stdout)
#define Precision(a) cout << fixed << setprecision(a)
#define FasterIO     ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); 
#define Faster       cin.tie(0);cout.tie(0); 
#define Test         int test;cin >> test;for(int tc = 1; tc <= test; tc++)
#define dbg          int nnn = 1; cout << nnn++ << " : debug\n";
 
#define MOD          998244353
#define INF9         2147483647
#define INF18        9223372036854775806
#define eps          1e-8 
 
const double pi = 2 * acos(0.0);
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

template <typename T> T Sqr(T x) { T n = x * x ; return n ;}
template <typename T> T Pow(T B,T P){ if(P==0) return 1; if(P&1) return B*Pow(B,P-1);  else return Sqr(Pow(B,P/2));}
template <typename T> T Abs(T a) {if(a<0)return -a;else return a;}
template <typename T> void Print(T ar[] , int a , int b) {for (int i = a; i + 1 <= b ; i++)cout << ar[i] << " ";cout << ar[b] << "\n";}
template <typename T> void Print(T ar[] , int n) {for (int i = 0; i + 1 < n; i++)cout << ar[i] << " ";cout << ar[n - 1] << "\n";} 
template <typename T> void Print(const vector<T> &v) {for (int i = 0; i + 1 < v.size() ; i++) cout << v[i] << " ";cout << v.back() << "\n";}

int main(int argc, char const *argv[])
{
    FasterIO
    map <string , int> mp;
    Test {
        string s; cin >> s;
        mp[s]++;
    }
    cout << "AC x " << mp["AC"] << "\n";
    cout << "WA x " << mp["WA"] << "\n";
    cout << "TLE x " << mp["TLE"] << "\n";
    cout << "RE x " << mp["RE"] << "\n";
    return 0;
}

Measured memory_bytes: 3664
#include <stdio.h>

int main(void) {
	long long i,j,n,d[128][32]={0},m;
	scanf("%lld",&n);
	scanf("%lld",&m);
	d[1][m] = 1;
	for(i = 2;i <= n-1;i++){
		scanf("%lld",&m);
		for(j = 0;j <= 20;j++){
			if(0 <= j + m && j + m <= 20){d[i][j+m]+=d[i-1][j];}
			if(0 <= j - m && j - m <= 20){d[i][j-m]+=d[i-1][j];}
		}
	}
	scanf("%lld",&m);
	printf("%lld\n",d[n-1][m]);
	return 0;
}

Measured memory_bytes: 640
#include<iostream>
using namespace std;
int main()
{
    int i,j;
    char str[3][3];
    for(i=0;i<3;i++)
    {
        for(j=0;j<3;j++)
        {
            cin>>str[i][j];
        }
    }
    for(i=0;i<3;i++)
    {
        for(j=0;j<3;j++)
        {
            if(i==j)
            cout<<str[i][j];
        }
    }
    cout<<endl;
    return 0;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
int main() {
		ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,m,val,ans=0;
    cin>>n>>m;
    for(int i=0;i<m;i++){
					cin>>val;
					ans += val;
		} 
		if(ans > n)cout<<"-1\n";
		else cout<<n-ans<<endl;
}


Measured memory_bytes: 3644
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
	int n; cin >> n;
	int a[11];
	int count = 1;
	int ans = 1;
	for(int i=0;i<n;i++){
		cin >> a[i];
		ans = ans*3;
		if(a[i]%2==0){
			count = count*2;
		}
	}
	cout << ans-count << endl;
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCorder
{
	public class Program
	{
		static void Main(string[] args)
		{
			Scanner cin = new Scanner();
			int a = cin.Int();
			int b = cin.Int();
			int c = cin.Int();
			int d = Math.Max(0, a - b);
			Console.WriteLine(Math.Max(0, c - d));
		}
	}

	public class Scanner
	{
		private readonly char[] delimiter_ = new char[] { ' ' };
		private string[] buf_;
		private int index_;
		
		public Scanner()
		{
			buf_ = new string[0];
			index_ = 0;
		}

		public string Next()
		{
			if (index_ < buf_.Length) {
				return buf_[index_++];
			}

			string st = Console.ReadLine();
			while (st == "") {
				st = Console.ReadLine();
			}

			buf_ = st.Split(delimiter_, StringSplitOptions.RemoveEmptyEntries);
			if (buf_.Length == 0) {
				return Next();
			}

			index_ = 0;
			return buf_[index_++];
		}

		public int Int()
		{
			return int.Parse(Next());
		}
		public int[] ArrayInt(int N, int add = 0)
		{
			int[] Array = new int[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Int() + add;
			}
			return Array;
		}

		public long Long()
		{
			return long.Parse(Next());
		}

		public long[] ArrayLong(int N, long add = 0)
		{
			long[] Array = new long[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Long() + add;
			}
			return Array;
		}

		public double Double()
		{
			return double.Parse(Next());
		}

		public double[] ArrayDouble(int N, double add = 0)
		{
			double[] Array = new double[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Double() + add;
			}
			return Array;
		}
	}
}


Measured memory_bytes: 11092
#include <iostream>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <queue>
#include <stack>
using namespace std;
#define rep(i,n) for (int i = 0; i <n; i++) 
 
int main(void){
   int n;
   std::cin >> n;
   vector<pair<int,int>>work(n);
   
   rep(i,n){
       cin>>work[i].second>>work[i].first;
   }
   sort(work.begin(),work.end());
   long long t=0;
   rep(i,n){
       t+=work[i].second;
       if(t>work[i].first){cout<<"No"<<endl;return 0;}
   }
   cout<<"Yes"<<endl;
}


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

int main(){
  string s1, s2;
  cin >>s1 >>s2;
  int length=min(s1.size(), s2.size());
  for(int i=0; i<length; i++){
    cout << s1[i] << s2[i];
  }
  if(s1.size()<s2.size()) cout << s2[s2.size()-1];
  else if(s1.size()>s2.size())cout << s1[s1.size()-1];
  cout <<endl;
}

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

#define rep(i, s, n) for(int i = s; i < n; ++i)
#define rrep(i, n) for(int i = n - 1; i > -1; --i)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
using namespace std;
const long long INF = 1000000000;
const int MOD = 1000000007;
typedef long long ll;
typedef pair<int, int> P;

int main() {
    string s, t;
    cin >> s >> t;
    int ans = 0;
    if(s[0] == t[0]) ans++;
    if(s[1] == t[1]) ans++;
    if(s[2] == t[2]) ans++;
    cout << ans << endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
int main() {
	cin.tie(0); ios::sync_with_stdio(false);
	int N;
	while (cin >> N, N) {
		int l = 1, r = 1;
		int sum = 1;
		int ans = 0;
		while (true) {
			//cout << l << " " << r << " " << sum << endl;
			if (sum < N) {
				r++; if (r > N)break;
				sum += r;
				continue;
			}
			if (sum == N) {
				if (r - l > 0) ans++;
				r++;  if (r > N) break;
				sum += r;
			}
			if (sum > N) {
				sum -= l; l++;
			}
		}
		cout << ans << endl;
	}
}

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

using namespace std;

#define rep(i,n) for(int i=0;i<(int)(n);i++)
void sort2array(double *a,long *b,long n){
    for(int i=0;i<n;i++){
        b[i]=i;
    }
    sort(b,b+n,[a](long i,long j)->bool {return a[i]<a[j];} );
}
//bを何回足せばaを超えるか
int wtover(int a,int b){
    if(a%b>0)return (a/b)+1;
    else return a/b;
}
const int INF=100000001,ID_MAX=20;
int bi_e[ID_MAX]={0};
//2進数表示したときの最高桁
int bi_max(long n){
    int m=0;
    for(m;pow(2,m)<=n;m++);m=m-1;
    return m;
}
//bi_eに二進数表示したやつを代入
void bi_exs(long n){
    rep(i,ID_MAX){
        bi_e[i]=0;
    }
    if(n<pow(2,ID_MAX)){
        int m=bi_max(n);
        long l;
        for(m;m>-1;m--){
            l=pow(2,m);
            bi_e[m]=n/l;
            n=n%l;
        }
    }
}
//x^n mod m (nが負の時は０)
long myPow(long x, long n, long m){
  if(n<0)return 0;
  if(n == 0)
    return 1;
  if(n % 2 == 0)
    return myPow(x * x % m, n / 2, m);
  else
    return x * myPow(x, n - 1, m) % m;
}

const int N_MAX=394;
int n,s[N_MAX],l[N_MAX],p[N_MAX],m,w[N_MAX],dp[N_MAX][N_MAX]={0},res[N_MAX];

int main(){
    int i;
    //入力
    cin>>n;
    rep(i,n){
        cin>>s[i+1]>>l[i+1]>>p[i+1];
    }
    cin>>m;
    rep(i,m){
        cin>>w[i];
    }
    //処理
    bool tof=false;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=N_MAX-1;j++){
            int res=dp[i-1][j];
            if(j>=s[i]){
                for(int k=s[i];k<=min(l[i],j);k++){
                    res=max(res,dp[i][j-k]+p[i]);
                }
            }
            dp[i][j]=res;
        }
    }
    //出力
    rep(i,m){
        res[i]=dp[n][w[i]];
        if(res[i]==0){
            cout<<"-1"<<endl;
            return 0;
        }
    }
    rep(i,m){
        cout<<res[i]<<endl;
    }
}


Measured memory_bytes: 3692
#include <stdio.h>

int rank[3];

int main(void)
{
	int mou[10];
	int i, n, idx;
	char b[10];
	
	for (i = 0; i < 10; i++){
		scanf("%d", &mou[i]);
		b[i] = 0;
	}
	
	for (i = 0; i < 3; i++){
		idx = 0;
		for(n = 0; n < 10; n++){
			if (b[n] == 0 && rank[i] < mou[n]){
				rank[i] = mou[n];
				idx = n;
			}
			if (n == 9){
				b[idx] = 1;
			}
		}
		printf("%d\n", rank[i]);
	}
	
	return (0);
}

Measured memory_bytes: 600
#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;
typedef long long ll;
ll inf = 1e10;
ll w[105], v[105];
ll dp[105][100005];
ll a[200005];
int main() {
	ll n, W;
	cin >> n >> W;
	ll sum=0;
	for (int i = 0; i < n; i++) {
		cin >> w[i] >> v[i];
		sum += v[i];
	}

	for (int i = 0; i < n; i++) {
		for (int j = 0; j <= sum; j++) {
			dp[i][j] = inf;
		}
	}
	dp[0][0] = 0;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j <= sum; j++) {
			if (j >= v[i]) {
				dp[i + 1][j] = min(dp[i][j], dp[i][j - v[i]] + w[i]);
			}
			else {
				dp[i + 1][j] = dp[i][j];
			}
		}
	}

	int ans = 0;
	for (int i = 0; i <= sum; i++) {
		if (dp[n][i] <= W) {
			ans = i;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 80640
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
constexpr int MOD = 1000000007;
constexpr int INF = 2147483647;
int main()
{
    string S, T;
    cin >> S >> T;
    int A, B;
    cin >> A >> B;
    string U;
    cin >> U;
    if(S == U) {
        A--;
    } else {
        B--;
    }
    cout << A << " " << B << endl;
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use {
   proconio::{fastout, input, marker::*},
   std::cmp::*,
   std::collections::*,
};

#[fastout]
fn main() {
   input! {
      n: usize,
   }

   let mut ans = 1;
   let mut prime = vec![1; n + 1];
   for i in 2..=n {
      if prime[i] != 1 {
         ans += prime[i] * i;
         continue;
      }
      ans += 2 * i;

      for j in 2..=n / i {
         let mut c = 2;
         let mut k = j;
         while k % i == 0 {
            c += 1;
            k /= i;
         }
         prime[i * j] *= c;
      }
   }

   println!("{}", ans);
}


Measured memory_bytes: 80204
n, m = map(int, input().split())
A = list(map(int, input().split()))
total = sum(A)
limit = total / 4 / m
#print(limit)
counter = 0
for a in A:
  if a >= limit:
    counter += 1
    #print(counter)
    
if counter >= m:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 38256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<stack>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<double,double> pdd;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef set<int> si;
typedef map<int, int> mii;
#define INF (1<<29)


int d[10][10];
int v=10;

void warshall(){
    for(int k=0; k<v; k++) {
        for (int i=0; i<v; i++) {
            for (int j=0; j<v; j++) {
                d[i][j]=min(d[i][j], d[i][k]+d[k][j]);
            }
        }
    }
}

int main(){
    int h,w;
    cin>>h>>w;
    int wall[h+1][w+1];

    int tmp;
    for(int i=0; i<10; i++){
        for(int j=0; j<10; j++){
            cin>>d[i][j];
        }
    }
    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            cin>>wall[i][j];
        }
    }


    warshall();
    int ans=0;
    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            if(wall[i][j] == -1){
                continue;
            }
            ans += d[ wall[i][j] ][1];
        }
    }
    cout<<ans<<endl;
    return 0;
}


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

#define F first
#define S second
#define PB push_back

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;
typedef priority_queue<int> HEAP;
typedef priority_queue<int, vector<int>, greater<int> > RHEAP;

const int N = 100010, M = 1010;

int n, m;
int a[N], p[N];

int find(int x)
{
	if (x != p[x]) p[x] = find(p[x]);
	return p[x];
}

int main()
{
	scanf("%d%d", &n, &m);
	for (int i = 0; i <= n; i ++ ) p[i] = i;
	for (int i = 1; i <= n; i ++ ) scanf("%d", &a[i]);
	
	while (m -- )
	{
		int l, r;
		scanf("%d%d", &l, &r);
		
		int pa = find(l), pb = find(r);
		p[pa] = pb;
	}
	
	int res = 0;
	for (int i = 1; i <= n; i ++ )
	{
		int pa = find(i), pb = find(a[i]);
		res += pa == pb;
	}
	printf("%d\n", res);
	return 0;
}

Measured memory_bytes: 1024
import math

N = int(input())
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())

def main():
    print(int(math.ceil(N / min([A, B, C, D, E]))) + 4)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
# input here
_INPUT = """\
127
"""
"""
K = int(input())
H, W, K = map(int, input().split())
a = list(map(int, input().split()))
xy = [list(map(int, input().split())) for i in range(N)]
p = tuple(map(int,input().split()))
"""
def main():
    N = int(input())

    dp = [float('inf')] * (N+1)
    dp[0] = 0
    a,b,c = 1,6,9

    for i in range(N+1):
        if i >= b*6:
            b *= 6
        if i >= c*9:
            c *= 9
        if i < b:
            dp[i] = i
        elif i < c:
             dp[i] = min(dp[i-1]+1, dp[i-b]+1)
        else:
            dp[i] = min(dp[i-1]+1,dp[i-b]+1,dp[i-c]+1)
    
    print(dp[N])
            
            
if __name__ == '__main__':
    import io
    import sys
    import math
    import itertools
    from collections import deque

    # sys.stdin = io.StringIO(_INPUT)
    main()

Measured memory_bytes: 69084
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <time.h>

#define _CRT_SECURE_NO_WARNINGS
#define TLong long long
#define TBMod 1000000007

typedef struct{
	TLong b;
	TLong c;
} BC;

int ASC(const int *a,const int *b){
	return (*a - *b);
}

int DESC(const int *p,const int *q){
	return ((BC *)q)->c - ((BC *)p)->c;
}

int main(int argc, char const *argv[])
{
	TLong n,m;
	TLong a[100003];
	BC bc[100003];
	TLong max = 0,sum = 0;
	TLong cnt = 0,pcnt = 0;

	scanf("%lld%lld",&n,&m);
	for (TLong i = 0; i < n; ++i)	scanf("%lld",&a[i]);
	for (TLong i = 0; i < m; ++i)	scanf("%lld%lld",&bc[i].b, &bc[i].c);
	qsort(a,n,sizeof(TLong),ASC);
	qsort(bc,m,sizeof(BC),DESC);

	for (TLong i = 0; i < n; ++i)
	{
		if(pcnt >= bc[cnt].b){
			++cnt;
			pcnt = 0;
			if(cnt >= m)	break;
		}
		if(a[i] < bc[cnt].c) a[i] = bc[cnt].c;
		else break;
		++pcnt;
	}
	for (TLong i = 0; i < n; ++i)	sum += a[i];
	printf("%lld\n", sum);
	return 0;
}


Measured memory_bytes: 4088
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int A, B, C;
  cin>>A>>B>>C;
  cout<<C<<" "<<A<<" "<<B<<endl;
}



Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define gt(n) scanf("%d", &n)
#define gtll(n) scanf("%ld", &n)
#define out(n) printf("%d", n)
#define outll(n) printf("%ld", n)
#define loop(n) for(int i=0; i<n; i++)
#define MAXX 1001
#define mem(x, y) memset(x, y, sizeof(x))
#define loop1(n) for(int i=1; i<=n; i++)
#define ll long long
#define pb push_back
#define pi acos(-1)
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
//(only in c)char[33];itoa(n,buffer,base);printf("%s",buffer);
#define dec_to_bin(n) std::string binary = std::bitset<64>(n).to_string();
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL)
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
int main()
{
fast;
ll n;
cin>>n;
ll a[n+7],b[n+7];
a[0]=0;
for(ll i=1;i<=n+1;i++){
cin>>a[i];
}
b[0]=0;
for(ll i=1;i<=n;i++){
cin>>b[i];
}
ll sum=0,m;
for(ll i=1;i<=n;i++){
 m=min(a[i],b[i-1]+b[i]);
ll rem=min(0LL,(b[i-1])-a[i]);
ll k=b[i]+rem;
b[i]=max(0LL,k);
sum+=m;
//cout<<m<<endl;
}
//cout<<m<<endl;
 m=min(a[n+1],b[n]);
//ll rem=b[i]+b[i-1]-a[i];
//b[i-1]=max(0,rem);
//cout<<m<<endl;
sum+=m;
cout<<sum<<endl;
return 0;
}


Measured memory_bytes: 1792
s = [f for f in open(0).read().split() if '#' in f]
s = [''.join([s[j][i] for j in range(len(s))]) for i in range(len(s[0]))]
s = [f for f in s if '#' in f]
s = [''.join([s[j][i] for j in range(len(s))]) for i in range(len(s[0]))]
print(*s, sep='\n')

Measured memory_bytes: 3064
#include <iostream>

using namespace std;

int main()
{
    int m;
    cin>>m;
    for(int l = 1; l <= m; ++l)
    {
        int llast = 0;
        int rlast = 0;
        int tmp;
        bool flag = true;
        for(int i = 0; i < 10; ++i)
        {
            cin>>tmp;
            if(tmp > llast)
            {
                if(tmp > rlast)
                {
                    if(tmp - llast < tmp - rlast)
                        llast = tmp;
                    else
                        rlast = tmp;
                }
                else
                    llast = tmp;
            }
            else if(tmp > rlast)
                rlast = tmp;
            else
                flag = false;
        }
        if(flag)
            cout<<"YES"<<endl;
        else
            cout<<"NO"<<endl;
    }
}


Measured memory_bytes: 3004
#include <bits/stdc++.h>
using namespace std;
typedef complex<double> pt;
#define pb push_back
#define mp make_pair
pt P[1005];
int n;
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		double x,y; scanf("%lf%lf",&x,&y);
		P[i] = pt(x,y) * polar(1.0,1e-5);
	}
	if(n<=3){
		puts("Possible"); return 0;
	}
	vector<pair<double,int> >vec;
	for(int i=2;i<=n;i++){
		vec.pb(mp(arg(P[i]-P[1]),i));
	}
	sort(vec.begin(),vec.end());
	//for(int i=0;i<vec.size();i++) cout << vec[i].first << endl;
	for(int i=1;i<vec.size();i++){
		if(vec[i].first-vec[i-1].first > 3.141592653589793-1e-10){
			goto ok;
		}
	}
	if(vec[vec.size()-1].first-vec[0].first < 3.141592653589793+1e-10){
		goto ok;
	}
	puts("Impossible"); return 0; ok:;
	vec.clear();
	for(int i=1;i<n;i++){
		vec.pb(mp(arg(P[i]-P[n]),i));
	}
	sort(vec.begin(),vec.end());
	//for(int i=0;i<vec.size();i++) cout << vec[i].first << endl;
	for(int i=1;i<vec.size();i++){
		if(vec[i].first-vec[i-1].first > 3.141592653589793-1e-10){
			goto ok2;
		}
	}
	if(vec[vec.size()-1].first-vec[0].first < 3.141592653589793+1e-10){
		goto ok2;
	}
	puts("Impossible"); return 0; ok2:; //puts("OK");
	for(int i=2;i<n;i++){
		vec.clear();
		for(int j=1;j<=n;j++){
			if(i==j) continue;
			vec.pb(mp(arg(P[j]-P[i]),j));
		}
		sort(vec.begin(),vec.end());
		//for(int j=0;j<vec.size();j++) cout << vec[j].first << " " << vec[j].second << " "; cout << endl;
		for(int j=1;j<vec.size();j++){
			if( ((vec[j].second<i) ^ (vec[j-1].second<i)) == 1){
				bool p = (vec[j].second<i); int cnt = 1;
				for(int k=(j+1)%vec.size();k!=j;k=(k+1)%vec.size()){
					if( (vec[k].second<i) != p){
						if( (p==1&&cnt==i-1) || (p==0&&cnt==n-i) ){
						    //cout << j << " " << k << endl;
							//j..(k+vec.size()-1)%vec.size()
							double A = vec[(k+vec.size()-1)%vec.size()].first-vec[j].first; if(A<0) A+=2*3.1415926535897932;
							//k%vec.size()...(j+vec.size()-1)%vec.size()
							double B = vec[j-1].first-vec[k].first; if(B<0) B+=2*3.1415926535897932;
							//cout << A << " " << B << endl;
							//cout << vec[(k+vec.size()-1)%vec.size()].first << " " << vec[j].first << endl;
							if(A > 3.141592653589793+1e-10 || B > 3.141592653589793+1e-10){
								puts("Impossible"); return 0;
							}
							goto nxt;
						}
						else{
							puts("Impossible");
							return 0;
						}
					}
					cnt++;
				}
			}
		}
		nxt:;
	}
	puts("Possible");
}

Measured memory_bytes: 3496
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin() , v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)


int main(){
    int n, a, b; cin >> n >> a >> b;
    int ans = 0;
    if(a + b - n < 0){
        ans = 0;
    } else {
        ans = a + b - n;
    }
    cout << min(a, b) << " "  << ans << endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int v, w; };

ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int main() {
	int N, M, X; cin >> N >> M >> X;
	vector<int> H(N);
	for (int u = 0; u < N; u++)
		cin >> H[u];
	vector<vector<edge> > G(N);
	while (M--) {
		int A, B, T; cin >> A >> B >> T;
		A--; B--;
		if (H[A] >= T) {
			edge e = {B, T};
			G[A].push_back(e);
		}
		if (H[B] >= T) {
			edge _e = {A, T};
			G[B].push_back(_e);
		}
	}
	vector<ll> d(N, LLONG_MAX);
	d[0] = 0;
	priority_queue<ll_i, vector<ll_i>, greater<ll_i> > pq;
	pq.push(ll_i(0, 0));
	while (!pq.empty()) {
		ll_i p = pq.top(); pq.pop();
		int u = p.second;
		if (d[u] < p.first) continue;
		for (int i = 0; i < G[u].size(); i++) {
			edge e = G[u][i];
			ll x = max(d[u] + e.w, (ll)X - H[e.v]);
			if (x < d[e.v]) {
				d[e.v] = x;
				pq.push(ll_i(x, e.v));
			}
		}
	}
	cout << (d[N - 1] < LLONG_MAX ? d[N - 1] * 2 + H[N - 1] - X : -1) << endl;
}

Measured memory_bytes: 13072
import java.util.*;
import java.awt.geom.Point2D;
import java.awt.*;
import static java.lang.System.*;
import static java.lang.Math.*;
//Loopで使う文字列の長さは固定！
//intで大丈夫？オーバーフローしない？
//Loop回数は本当に10⁹以内になってる？Loopは回る？？
public class Main {
    public static void main(String[]$){
        Scanner sc = new Scanner(in);
        int H=sc.nextInt();
        int W=sc.nextInt();
        char[][] a=new char[H][W];
        for (int i = 0; i < H; i++) {
            String s=sc.next();
            for (int j = 0; j < W; j++) {
                a[i][j]=s.charAt(j);
            }
        }
        for (int i = 0; i < H; i++) {
            int c=0;
            for (int j = 0; j < W; j++) {
                if(a[i][j]=='.')c++;
            }
            if(c==W){
                for (int j = 0; j < W; j++) {
                    a[i][j]='-';
                }
            }
        }
        for (int i = 0; i < W; i++) {
            int c=0;
            for (int j = 0; j < H; j++) {
                if(a[j][i]=='.'||a[j][i]=='-')c++;
            }
            if(c==H){
                for (int j = 0; j <H; j++) {
                    a[j][i]='-';
                }
            }
        }
        String[] ans=new String[H];
        for (int i = 0; i <H; i++) {
            ans[i]="";
        }
        for (int i = 0; i < H; i++) {
            for (int j = 0; j < W; j++) {
                ans[i]+=Character.toString(a[i][j]);
            }
        }
        for (int i = 0; i < H; i++) {
            ans[i]=ans[i].replaceAll("-", "");
        }
        for (int i = 0; i < H; i++) {
            if(!ans[i].equals(""))out.println(ans[i]);
        }
    }
    static long power(long x,int n){
        long mod=1000000007;
        long ans=1;
        while (n>0) {
            if((n&1)==1){
                ans=(ans*x)%mod;
            }
            x=(x*x)%mod;
            n>>=1;
        }
        return ans;
    }
    //最大公約数
    static int gcd (int a, int b) {
        int temp;
        while((temp = a%b)!=0) {
            a = b;
            b = temp;
        }
        return b;
    }
//※最小公倍数はa*b/gcd(a,b)である
}


Measured memory_bytes: 30704
#include <iostream>
#include<algorithm>
#include<string>
#include<map>
#include<iomanip>
#include<vector>
#include<cmath>
#define mod 1000000007
#define pa(a,b) make_pair(a,b)
#define LL  long long int
using namespace std;
int buf[50];
inline void write(int x)
{
	int p=0;
	do{
		buf[p++]=x%10;
		x/=10;
	}while(x>0);
	for(int i=p-1;i>=0;i--)putchar('0'+buf[i]);
}
long long int read_int(){
	char r;
	bool start=false,neg=false;
	long long int ret=0;
	while(true){
		r=getchar();
		if((r-'0'<0 || r-'0'>9) && r!='-' && !start){
			continue;
		}
		if((r-'0'<0 || r-'0'>9) && r!='-' && start){
			break;
		}
		if(start)ret*=10;
		start=true;
		if(r=='-')neg=true;
		else ret+=r-'0';
	}
	if(!neg)
		return ret;
	else
		return -ret;
}
int main()
{
    int r,g,b; cin>>r>>g>>b; int num=r*100+g*10+b;
    num%4==0 ? cout<<"YES" : cout<<"NO";
}


Measured memory_bytes: 256
#include <stdio.h>
int main()
{
	int INPUT_NEEDTIME,MULTIPLE;
	double NEEDTIME ;
  	
  	scanf("%d %d",&INPUT_NEEDTIME,&MULTIPLE);
  
	NEEDTIME = (double)INPUT_NEEDTIME / (double)MULTIPLE ;
  
	printf("%f",NEEDTIME);
	return 0;
}

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

#define REP(i,n) for(ll i = 0;i < n;++i)
#define PB(s) push_back(s)
#define ST(n) sort(n.begin(),n.end())

using namespace std;
typedef long long ll;
ll gcd(ll m,ll n){
    ll k;
     while( (k = m % n) != 0 ) {
            m = n;
            n = k;
    }
    return n;
}
int main(void){
    ll a,b,c,d,ans;
    cin>>a>>b>>c>>d;
    ans=b-a+1;
    ans-=b/c-(a-1)/c;
    ans-=b/d-(a-1)/d;
    ans+=b/(c*d/gcd(c,d))-(a-1)/(c*d/gcd(c,d));
    cout<<ans<<endl;
}


Measured memory_bytes: 256
n=int(input())
a=list(map(lambda x:int(x),input().split()))
flag=True
number=0
while flag:
    flag=False
    for j in range(n-1,0,-1):
        if a[j]<a[j-1]:
            a[j],a[j-1]=a[j-1],a[j]
            number=number+1
            flag=True

for k in range(n-1):
    print(a[k],end=" ")
print(a[n-1])
print(number)





Measured memory_bytes: 5612
import std.stdio, std.conv, std.string, std.range, std.algorithm, std.array,
  std.functional, std.container, std.typecons;

enum MOD = 1000000007;

ulong _c(ulong n, ulong k) {
  if(k == 0 || k == n) return 1;
  if(k < 0 || n < k) return 0;
  return (c(n-1, k) + c(n-1, k-1)) % MOD;
}
alias c = memoize!_c;

void main() {
  auto input = readln.split.to!(int[]);
  int N = input[0], K = input[1];

  ulong calc(int i) {
   return (c(N-K+1, i) * c(K-1, i-1)) % MOD;
  }

  foreach(i; 1..(K+1)) {
    calc(i).writeln;
  }
}


Measured memory_bytes: 245756
#include <iostream>

using namespace std;
int main(void)
{
    int n;
    int a, b;

    cin >> n >> a >> b;

    char c[6];
    int sum = 0;
    int ans = 0;
    for (int i=1; i<=n; i++) {
        sprintf(c, "%d", i);
        sum = 0;
        for (int j = 0; j < 6; j++) {
            if (c[j] == '\0') {
                break;
            }
            sum += c[j] - '0';
        }
        if (a <= sum && sum <= b) {
            ans += i;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
//#include <ext/pb_ds/assoc_container.hpp>
#include <bits/stdc++.h>
using namespace std;
//using namespace __gnu_pbds;
//template <class c, class cmp = less<c> > using ordered_set = tree<c, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...) 
#endif
template<class T> ostream& operator<<(ostream &os, vector<T> V) {os << "[ "; for(auto v : V) os << v << " "; return os << "]";}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {return os << "(" << P.first << "," << P.second << ")";}
template <typename T,typename U>pair<T,U> operator+(const pair<T,U> & l,const std::pair<T,U> & r) { return {l.first+r.first,l.second+r.second};}
typedef long long int ll;
const ll mod =1e9+7;
const int maxn = 300002;
#define endl '\n'
#define int ll
#define ld long double
#define all(x) (x).begin(),(x).end()

int32_t main()
{ 
  IOS

  int n;
  cin>>n;
  int a[n+1];
  int xr = 0;
  for(int i = 1;i<=n;i++){
      cin>>a[i];
      xr^=a[i];
  }
  if(n%2 == 0){
      for(int i =1;i<=n;i++){
          cout<<(xr^a[i])<<" ";
      }
  }
  
}

Measured memory_bytes: 5212
#include<iostream>
#include<cmath>
#include<iomanip>
using namespace std; int DIGITS = 1919;
long double X, Y, R, X1, Y1, X2, Y2; int Q;
struct Point { long double px, py; }; struct Segment { Point p1, p2; };
Point Minus(Point a, Point b) { Point G; G.px = a.px - b.px; G.py = a.py - b.py; return G; }
Point Times(Point a, long double b) { Point J; J.px = a.px*b; J.py = a.py*b; return J; }
long double norm(Point a) { return a.px*a.px + a.py*a.py; }
long double dot(const Point& a, const Point& b) { return a.px * b.px + a.py * b.py; }
long double crs(const Point& a, const Point& b) { return a.px * b.py - a.py * b.px; }
Point prj(Segment a, Point b) {
	Point c = Minus(a.p2, a.p1); Point D = Times(c, dot(Minus(b, a.p1), c));
	D = Times(D, 1.0 / norm(c)); return Minus(D, Times(a.p1, -1));
}
int main() {
	cin >> X >> Y >> R >> Q; Point H; H.px = X; H.py = Y;
	for (int i = 0; i < Q; i++) {
		cin >> X1 >> Y1 >> X2 >> Y2; Point A1, A2; A1.px = X1; A1.py = Y1; A2.px = X2; A2.py = Y2;
		Segment S; S.p1 = A1; S.p2 = A2; Point I = prj(S, H); Point K = Minus(A2, A1); K = Times(K, 1 / sqrt(norm(K)));
		double base = sqrt(R*R - norm(Minus(I, H))); K = Times(K, base);
		Point L[2]; L[0] = Minus(I, K); L[1] = Minus(I, Times(K, -1));
		if (L[0].px > L[1].px) { swap(L[0], L[1]); }
		else if (L[0].px == L[1].px && L[0].py > L[1].py) { swap(L[0], L[1]); }
		cout << fixed << setprecision(DIGITS) << L[0].px << ' ' << fixed << setprecision(DIGITS) << L[0].py << ' ';
		cout << fixed << setprecision(DIGITS) << L[1].px << ' ' << fixed << setprecision(DIGITS) << L[1].py << endl;
	}
	return 0;
}

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

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


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

int r[6][3][4] =
  {
    {
      {3,2,10,11},
      {21,23,17,19},
      {20,22,16,18}
    },
    {
      {19,18,26,27},
      {20,10,25,35},
      {28,11,17,34}
    },
    {
      {21,20,28,29},
      {22,11,27,43},
      {30,3,19,35}
    },
    {
      {35,34,42,43},
      {28,26,24,30},
      {29,27,25,31}
    },
    {
      {23,22,30,31},
      {16,3,29,42},
      {24,2,21,43}
    },
    {
      {17,16,24,25},
      {18,2,31,34},
      {26,10,23,42}
    }
  };

int c[128];
const int H = 6;
const int W = 8;

int main() {
  c['U'] = 0;
  c['F'] = 1;
  c['R'] = 2;
  c['D'] = 3;
  c['B'] = 4;
  c['L'] = 5;
  string s;
  char G[H][W+1] = {
    "..rr....",
    "..rr....",
    "ggyybbww",
    "ggyybbww",
    "..oo....",
    "..oo...."
  };
  cin >> s;
  for(int i = 0; i < s.size(); ++i) {
    int m = c[s[i]];
    for(int j = 0; j < 3; ++j) {
      int pi = r[m][j][0] / W;
      int pj = r[m][j][0] % W;
      char tmp = G[pi][pj];
      for(int k = 1; k < 4; ++k) {
        int ai = r[m][j][k] / W;
        int aj = r[m][j][k] % W;
        G[pi][pj] = G[ai][aj];
        pi = ai;
        pj = aj;
      }
      G[pi][pj] = tmp;
    }
  }

  for(int i = 0; i < H; ++i) {
    cout << G[i] << endl;
  }

  return 0;
}

Measured memory_bytes: 1180
class Stack:
    MAX = 101

    def __init__(self):
        self.S = [None] * self.__class__.MAX
        self.top = 0

    def is_empty(self):
        return self.top == 0

    def is_full(self):
        return self.top >= self.__class__.MAX - 1

    def push(self, x):
        self.top += 1
        self.S[self.top] = x

    def pop(self):
        self.top -= 1
        return self.S[self.top + 1]


arr = [str(s) for s in input().split()]
stack = Stack()
for s in arr:
    if s in ["+", "-", "*"]:
        stack.push(
            eval("".join(map(str, [stack.pop(), s, stack.pop()][::-1]))))
    else:
        stack.push(int(s))

print(stack.pop())



Measured memory_bytes: 5612
#include<iostream>
#include<math.h>
#include<iomanip>
using namespace std;

double calc_distance(double xi, double xj, double yi, double yj){
  return sqrt (  (double) ( ( (xi - xj) * (xi - xj) ) + ( (yi - yj) * (yi - yj) ) ) );
}

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

  int x[n];
  int y[n];
  for(int i=0;i<n;i++){
    int xi, yi;
    cin >> xi >> yi;
    x[i] = xi;
    y[i] = yi;
  }
  
  double distance = 0;
  
  for (int i=0;i<n;i++){
    for (int j=0;j<i+1;j++){
      distance += calc_distance(x[i], x[j], y[i], y[j]);
    }
  }

 cout << setprecision(10) << distance / (double) n * 2.0 << endl;
 //cout << distance / (double) n * 2.0 << endl;
  
  return 0;
}


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

int main(){
  string s;
  cin >> s;
  int n=s.size();
  bool flag=true;
  for(int i=0;i<n/2;i++){
    if(s[i]==s[n-i-1]){
      continue;
    }else{
      flag=false;
    }
  }
  string tmp;
  tmp=s.substr(0,(n-1)/2);
  for(int i=0;i<tmp.size()/2;i++){
    if(tmp[i]==tmp[tmp.size()-i-1]){
      continue;
    }else{
      flag=false;
    }
  }
  tmp=s.substr((n+2)/2,n/2);
  for(int i=0;i<(tmp.size())/2;i++){
    if(tmp[i]==tmp[tmp.size()-i-1]){
      continue;
    }else{
      flag=false;
    }
  }
  if(flag){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pii pair<ll int,ll int>
#define PI 2*acos(0)
#define INF 1e8
#define mx 200005
using namespace std;
const ll int p=1000000007;
//vector<ll > prime;
//bool mark[mx];
ll int mod(ll int a,ll int b)
{
    ll int m=a%b;
    if(m<0) m=(b<0)?(m-b):(m+b);
    return m;
}
ll maxpow(ll n)
{
    return (n & (~(n-1)));
}
bool isPrime(ll n)
{
    if(n<2) return false;
    if(n==2) return true;
    if(n%2==0) return false;
    for(ll i=3;i*i<=n;i+=2){
        if(n%i==0) return false;
    }
    return true;
}
/*void init()
{
    mark[1]=1;
    int i,j,limit=sqrt(mx*1.0)+2;
    prime.push_back(2);
    for(i=4;i<mx;i+=2) mark[i]=1;
    mark[2]=0;
    for(i=3;i<mx;i+=2){
        if(!mark[i]){
            prime.push_back(i);
            if(i<=limit){
                for(j=i*i;j<mx;j+=2*i){
                    mark[j]=1;
                }
            }
        }
    }
}
/*
ll maxdiv(ll n)
{
    ll i,ans=1;
    for(i=0;i<prime.size();i++){
        if(n%prime[i]==0){
            ans=n/prime[i];break;
            //return ans;
        }
    }
    return ans;
}*/
ll lcm(ll a,ll b)
{
    ll ans=a*b;
    return (ans/__gcd(a,b));
}
// ax+by and a>b
ll gcd(ll a,ll b,ll &x,ll &y)
{
    if(b==0){
        x=1;
        y=0;
        return a;
    }
    ll x1,y1;
    ll d=gcd(b,mod(a,b),x1,y1);
    x=y1;
    y=x1-y1*(a/b);
    return d;
}
ll abso(ll a)
{
    if(a>=0) return a;
    return -a;
}
ll cnt;
vector<ll>g[mx];
bool vis[mx];
void dfs(ll u)
{
    cnt++;
    vis[u]=1;
    for(int i=0;i<g[u].size();i++){
        ll v=g[u][i];
        if(!vis[v]) dfs(v);
    }
}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    ll i,n,m,u,v;
    cin>>n>>m;
    for(i=0;i<m;i++){
        cin>>u>>v;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    ll ans=-1;
    for(i=1;i<=n;i++){
        if(!vis[i]){
            cnt=0;
            dfs(i);
            ans=max(ans,cnt);
        }
    }
    cout<<ans;
    return 0;
}
//1028C


Measured memory_bytes: 20976
use std::io;
use std::io::{stdout, Write};
use std::cmp;

fn main() {
    let mut X = String::new();
    io::stdin().read_line(&mut X);
    let mut vecA :Vec<isize> = X.trim().split_whitespace().map(|e| e.parse::<isize>().unwrap()).collect();
    for i in 0..vecA.len(){
        if vecA[i] == 0 {
            println!("{}", i+1);
            return ()
        }
    }
}

Measured memory_bytes: 2136
/*
	Created by : imay_10
	" It won't be EASY, but I'll make it "
*/

#include<bits/stdc++.h>
using namespace std;

typedef long long int ll;
const int mod = 1e9+7;
const ll inf = 1e18;
const double pi = 3.1415926535897932384626;

// Utility for fast exponentiation
ll mpow(ll a,ll b,ll m){
    ll res=1;
    //a%=m;
    while(b){
    	if(b%2) res=res*a%m;
		a=a*a%m;
		b/=2;
	}
	return res;
}

// Utility for modular inverse
ll inv(ll a,ll m){
	return mpow(a,m-2,m);
}

// Utility for GCD Calculation
ll gcd(ll a,ll b){
	if(b==0) return a;
	return gcd(b,a%b);
}

// Utility for binomial coefficient
ll ncr(ll n,ll k)
{
    if(n<k)
        return 0;
    ll C[n + 1][k + 1];
    ll i,j;
    for(i=0;i<=n;i++){
        for(j=0;j<=min(i,k);j++){
            if (j==0 || j==i)
                C[i][j]=1;
            else
                C[i][j]=(C[i-1][j-1]+C[i-1][j])%mod;
        }
    }
    return C[n][k];
}

void solve(){
	//code
	int k;
	cin>>k;
	int a[32]={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};
	cout<<a[k-1];
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	
	solve();
 	return 0;
}


Measured memory_bytes: 3540