akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
  
int A[100000],od[100000];
char C[100000];
  
int Partition(int A[],char C[],int od[],int p,int r){
  int t1,t2,tM,tm,tC,tc;
  int i,j,x,stability,n;
    
  x = A[r];
  i = p-1;
  for(j = p ; j < r ; j++){
    if(A[j] <= x){
      i = i+1; 
      t1 = A[i];
      tM = C[i];
      tC = od[i];
        
      A[i] = A[j];
      C[i] = C[j];
      od[i] = od[j];
       
      A[j] = t1;
      C[j] = tM;
      od[j] = tC;
    }
  }
  t2 = A[i+1];
  tm = C[i+1];
  tc = od[i+1];
    
  A[i+1] = A[r];
  C[i+1] = C[r];
  od[i+1] = od[r];
    
  A[r] = t2;
  C[r] = tm;
  od[r] = tc;
    
  return i+1;
}
  
void Quicksort(int A[],char C[],int od[],int p,int r){
  int q;
    
  if(p < r){
    q = Partition(A,C,od,p,r);
    Quicksort(A,C,od,p,q-1);
    Quicksort(A,C,od,q+1,r);
  }
}
  
int main(){
  int n,i,stability=0;
  scanf("%d",&n);
  for(i = 0 ; i < n ; i++){
    scanf(" %c%d",&C[i],&A[i]);
  }  
  for(i = 0 ; i < n ; i++){
    od[i] = i;
  }
  Quicksort(A,C,od,0,n-1);
  for(i = 0 ; i < n-1 ; i++){
    if(A[i] == A[i+1]){
      if(od[i] > od[i+1]){
        stability = 1;
        break;
      }
    }  
  }
  if(stability == 1){
    printf("Not stable\n");
  }
  else printf("Stable\n");
    
  for(i = 0 ; i < n ; i++){
    printf("%c %d\n",C[i],A[i]);
  }
    
  return 0;
}

Measured memory_bytes: 1484
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = a; i <= b; ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)

using namespace std;

const int maxn = 2e5 + 10;

int n;
int a[maxn], b[maxn], c[maxn];

void add(int &x, int y) { x = (x + y) % 2; }
void sub(int &x, int y) { x = (x - y % 2 + 2) % 2; }

bool can(int p) {
    int T = 1 << p;
    REP(i, n) c[i] = b[i] % (T << 1);
    sort(c, c + n);
    int cnt = 0;
    REP(i, n) {
        int cc = lower_bound(c, c + n, 2 * T - a[i] % (2 * T)) - c;
        add(cnt, cc);
        cc = lower_bound(c, c + n, T - a[i] % (2 * T)) - c;
        sub(cnt, cc);
        cc = lower_bound(c, c + n, 3 * T - a[i] % (2 * T)) - c;
        add(cnt, n - cc);
    }
    return cnt;
}

int main() {
    scanf("%d", &n);
    REP(i, n) scanf("%d", a + i);
    REP(i, n) scanf("%d", b + i);

    int answer = 0;
    REP(i, 29) if (can(i)) answer |= 1 << i;
    printf("%d\n", answer);

    return 0;
}

Measured memory_bytes: 2560
#include <iostream>

int main()
{
	int a[10];
	int work = 0;

	for(int i = 0;i < 10;i++)
	{
		std::cin >> a[i];
		if(a[i] > 10000)
		{
			std::cout << "値が大きすぎます" << std::endl;
			i -= 1;
		}
	}
	/*そうだ、バブルソートやろう*/

	for(int j = 0;j < 10;j++)
	{
		for(int k = 9;k > j;k--)
		{
			if(a[k] > a[k-1])
			{
				work = a[k-1];
				a[k-1] = a[k];
				a[k] = work;
			}
		}
	}

	std::cout << a[0] << std::endl;
	std::cout << a[1] << std::endl;
	std::cout << a[2] << std::endl;



	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <map>
#include <set>

using namespace std;

int n,m;
long long ans;
int cnt[15];
int k[15];
int s[15][15];
int p[15];

int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++)
	{
		scanf("%d",&k[i]);
		for(int j=1;j<=k[i];j++)
		{
			scanf("%d",&s[i][j]);
		}
	}
	for(int i=1;i<=m;i++) scanf("%d",&p[i]);
	int shu=(1<<n);
	for(int i=0;i<shu;i++)
	{
		bool flag=true;
		for(int j=1;j<=m;j++)
		{
			int tot=0;
			for(int q=1;q<=k[j];q++)
			{
				if((i>>(s[j][q]-1))&1) tot++;
			}
			if(tot%2!=p[j]) flag=false;
		}
		if(flag) ans++;
	}
	printf("%lld",ans);
	return 0;
}











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

int main(){
  long K,N;
  cin >> K >> N;
  vector<int> A(N);
  
  for(long i=0;i<N;i++){
    cin >> A.at(i);
  }
  A.push_back(A.at(0)+K);
  int maxi=0;
  for(long i=0;i<N;i++){
    maxi = max(maxi,A.at(i+1)-A.at(i));
  }
  cout << K - maxi << endl;
  return 0;
}

Measured memory_bytes: 1792
import copy
N, M = map(int, input().split())
l = list()
m_list = []
for i in range(N):
    l.append([])
for i in range(M):
    a, b = map(int, input().split())
    m_list.append([a-1, b-1])
    l[a-1].append(b-1)
    l[b-1].append(a-1)

def f(l, s, e):
    m = [False] * len(l)
    m[s] = True
    q = []
    for nn in l[s]:
        q.append(nn)
        m[nn] = True
    while len(q) > 0:
        n = q[-1]
        q = q[:-1]
        for nn in l[n]:
            if m[nn] == False:
                m[nn] = True
                q.append(nn)
    return m[e]

sum = 0
for m in m_list:
    new_l = copy.deepcopy(l)
    new_l[m[0]].remove(m[1])
    new_l[m[1]].remove(m[0])
    if not f(new_l, m[0], m[1]):
        sum = sum + 1
print(sum)

Measured memory_bytes: 3572
#include<stdio.h>
int a[1000];

void pre()
{
    a[1] = 1;
    for(int i = 2; i <= 999; i++)
        a[i] = a[i-1] + i;
}

int main()
{
    int m,n;
    scanf("%d%d",&m,&n);
    int tmp = n - m;
    pre();
    printf("%d\n",a[tmp]-n);
    return 0;
}


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

int main(void) {
	char s[10];
	cin >> s[0] >> s[1] >> s[2] >> s[3];
	bool con = false;
	if (s[0] == s[1] || s[1] == s[2] || s[2] == s[3]) con = true;
	(con) ? cout << "Bad" : cout << "Good"; 
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,k;
	cin>>n>>k;
	int a[n];
	for(int i=0;i<n;i++) cin>>a[i];
	sort(a,a+n);
	int sum=0;
	for(int i=0;i<k;i++) sum+=a[i];
	cout<<sum<<"\n";
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define MOD (1000000007)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).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; }

int gcd(int a, int b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}

const ll INF = 1LL << 60;

int main(){
  int n; cin >> n;
  vvi G(n, vi(26));
  rep(i, n){
    string s; cin >> s;
    for(char c : s) G[i][c-'a']++;
  }

  vi C(26, 100);
  rep(i, n) rep(c, 26) chmin(C[c],G[i][c]);

  string ans;
  rep(c, 26) rep(i, C[c]) ans += (char)('a'+ c);
  std::cout << ans << '\n';
}


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

#define MAX_V 1000

using namespace std;

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

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

    sort(v, v+N);

    double ave = 0;
    for(int i=0; i<N; i++){
        if(i==0){
            ave += v[i];
            continue;
        }

        ave = (ave + v[i])/(double)2;
    }

    cout << ave;

    return 0;

}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<climits>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<numeric>
#include<map>
#include<set>
#define REP(i,m,n) for(int i = m; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define LL long long
template<class T> void chmax(T & a, T b) { if (a < b) { a = b; } }
template<class T> void chmin(T& a, T b) { if (a > b) { a = b; } }
using namespace std;

const long long LLINF = 1LL << 60;

class StringOperation {
public:
	StringOperation(){
	}

	string apply_command(string target_str,string command) {
		if (command == "replace") {
			return replace(target_str);
		}
		else if (command == "reverse") {
			return reverse(target_str);
		}
		else if (command == "print") {
			return print(target_str);
		}
	}

private:
	string replace(string target_str) {
		int a, b;
		string p;
		cin >> a >> b >> p;

		return target_str.replace(target_str.begin() + a, target_str.begin() + b + 1, p);
	}

	string reverse(string target_str) {
		int a, b;
		cin >> a >> b;
		
		string tmp;
		for (int i =  b; i >= a; i--) {
			tmp.push_back(target_str[i]);
		}

		return target_str.replace(target_str.begin() + a, target_str.begin() + b + 1, tmp);
	}

	string print(string target_str) {
		int a, b;
		cin >> a >> b;
		cout << target_str.substr(a, b - a + 1) << endl;

		return target_str;
	}
};

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

	int Q;
	cin >> Q;

	rep(i,Q) {
		string command;
		cin >> command;

		StringOperation so;
		str = so.apply_command(str,command);
	}
	
	return 0;
}


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

int main(){
    int ma=1e9+7;
    int n;cin>>n;
    ll ans=1;
    int x[1100]={};
    for(int i=1;i<=n;++i){
        int num=i;
        for(int j=2;j<=i;++j){
            while(num%j==0){
                x[j]++;
                num/=j;
            }
        }
    }
    for(int i=2;i<=n;++i){
        ans=((ans%ma)*(x[i]+1)%ma)%ma;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
# define ll int64_t
# define str string
# define rep(i,n) for(ll i=0;i<n;i++)
# define rrep(i,n) for(ll i=1;i<=n;i++)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define mod 1000000007
# define PI 3.141592653589793
# define vec vector
#define dump(x) cerr<<#x<<"="<<x<<endl
using namespace std;



#define INF 2000000000
#define MAX_V 10



bool compare_by_b(pair<string,ll> a,pair<string,ll> b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}

bool my_compare(pair<ll,ll> a,pair<ll,ll> b){
    if(a.first != b.first) return a.first<b.first;
    if(a.second != b.second) return a.second>b.second;
    else return true;
}

ll modpow(ll a,ll n,ll mod1) {
    ll res=1;
    while(n>0){
        if(n&1) res=res*a%mod1;
        a = a*a%mod1;
        n >>= 1;
    }
    return res;
}

ll factorial(ll n){
    ll x=1;
    rrep(i,n) (x*=i)%=mod;
    return x;
}

ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b,a%b));
}

ll lcm(ll a,ll b){
   return a/gcd(a,b)*b;
}
const ll MAX = 5100000;
const ll MOD = 1000000007;
 
ll fac[MAX], finv[MAX], inv[MAX];
 
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
ll COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

using graph = vector<vector<ll>>;
pair<pair<ll,ll>,ll> p[100010];

bool isUru(ll Y){
    if(Y%400==0){ return true;}
    else if(Y%100==0){ return false;}
    else if(Y%4==0){ return true;}
    else{ return false; }
}



int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll a,b,h,m;
    cin>>a>>b>>h>>m;
    
    double ra=(0.5*m + 30.0*h),rb=(6.0*m);
    double A=min(abs(ra-rb),360-abs(ra-rb));
    cout<<fixed<<setprecision(15)<<sqrt(a*a+b*b-(2*a*b*cos(PI/180*A)))<<endl;
    return 0;
}

Measured memory_bytes: 4144
a=[list(map(int,input().split())) for i in range(3)]

n=int(input())

b=list(int(input()) for i in range(n))

c=[[0]*3 for i in range(3)]

for i in range(3):
    for j in range(3):
        c[i][j]=False
        for k in range(n):
            if a[i][j]==b[k]:
                c[i][j]=True

answer="No"

for i in range(3):
    if (c[i][0] and c[i][1] and c[i][2]):
        answer="Yes"
    if (c[0][i] and c[1][i] and c[2][i]):
        answer="Yes"
if (c[0][0] and c[1][1] and c[2][2]):
    answer="Yes"
if (c[0][2] and c[1][1] and c[2][0]):
    answer="Yes"

print(answer)

Measured memory_bytes: 3064
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

 
public class Main {
    public static void main(String[] args) {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        try {
	    String str=reader.readLine();
	    String s[]=str.split(" ");

	    int a=Integer.parseInt(s[0]);
	    int b=Integer.parseInt(s[1]);
	    int c=Integer.parseInt(s[2]);
	    int d=Integer.parseInt(s[3]);

	    int e=a*b;
	    int f=c*d;

	    if(e<f){
		System.out.println(f);
	    }else{
		System.out.println(e);
	    }
	    
	    reader.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    static int gcd (int a, int b){
	return b>0?gcd(b,a%b):a;
    }
    static int lcm (int a, int b) {
	return a*b/gcd(a,b);
    }
}


Measured memory_bytes: 21204
unittest
{
	assert( [ "2 2 2 8", "4 6", "1 5", "3 8" ].solve == "19\n17\n15\n14\n13\n12\n10\n8" );
	assert( [ "3 3 3 5", "1 10 100", "2 20 200", "1 10 100" ].solve == "400\n310\n310\n301\n301" );
	assert( [ "10 10 10 20", "7467038376 5724769290 292794712 2843504496 3381970101 8402252870 249131806 6310293640 6690322794 6082257488", "1873977926 2576529623 1144842195 1379118507 6003234687 4925540914 3902539811 3326692703 484657758 2877436338", "4975681328 8974383988 2882263257 7690203955 514305523 6679823484 4263279310 585966808 3752282379 620585736" ].solve == "23379871545\n22444657051\n22302177772\n22095691512\n21667941469\n21366963278\n21287912315\n21279176669\n21160477018\n21085311041\n21059876163\n21017997739\n20703329561\n20702387965\n20590247696\n20383761436\n20343962175\n20254073196\n20210218542\n20150096547" );
}



import std.algorithm;
import std.container;
import std.conv;
import std.format;
import std.range;
import std.stdio;

void main()
{
	stdin.byLineCopy.solve.writeln;
}

auto solve( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto x = 0L;
	auto y = 0L;
	auto z = 0L;
	auto k = 0L;
	input.front.formattedRead!"%s %s %s %s"( x, y, z, k );
	input.popFront;
	auto as = input.front.split.to!( long[] );
	input.popFront;
	auto bs = input.front.split.to!( long[] );
	input.popFront;
	auto cs = input.front.split.to!( long[] );
	as.sort!( ( a, b ) => b < a );
	bs.sort!( ( a, b ) => b < a );
	cs.sort!( ( a, b ) => b < a );
	
	auto rbt = redBlackTree!( ( a, b ) => b < a, true )( as.front + bs.front + cs.front );
	auto ai = 0L;
	auto bi = 0L;
	auto ci = 0L;
	while( ai + 1 < as.length || bi + 1 < bs.length || ci + 1 < cs.length )
	{
		auto m = ( rbt.length == k ) ? rbt.back : 0L;
		auto a = ( ai + 1 < as.length ) ? as[ ai + 1 ] + bs.front + cs.front : 0L;
		auto b = ( bi + 1 < bs.length ) ? bs[ bi + 1 ] + as.front + cs.front : 0L;
		auto c = ( ci + 1 < cs.length ) ? cs[ ci + 1 ] + as.front + bs.front : 0L;
		if( a <= m && b <= m && c <= m ) break;
		if( b <= a && c <= a )
		{
			ai++;
			solve2( rbt, k, [ as, bs, cs ], [ ai, bi, ci ] );
		}
		else if( a <= b && c <= b )
		{
			bi++;
			solve2( rbt, k, [ bs, as, cs ], [ bi, ai, ci ] );
		}
		else if( a <= c && b <= c )
		{
			ci++;
			solve2( rbt, k, [ cs, bs, as ], [ ci, bi, ai ] );
		}
	}
	return rbt[].map!( ( a ) => a.to!( string ) ).join( "\n" );
}

void solve2( RBT )( ref RBT rbt, long k, long[][ 3 ] abcs, long[ 3 ] ps )
{
	auto a = abcs[ 0 ][ ps[ 0 ] ];
	foreach( b; abcs[ 1 ][ 0L .. ps[ 1 ] + 1 ] )
	{
		foreach( c; abcs[ 2 ][ 0L .. ps[ 2 ] + 1 ] )
		{
			auto t = a + b + c;
			if( rbt.length == k && t <= rbt.back ) break;
			rbt.insert( t );
			if( k < rbt.length ) rbt.removeBack;
		}
	}
}


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

int main(){
	int x, y;
	while(1){
		cin>>x>>y;
		if(x == 0 && y == 0) break;
		if(x > y) swap(x,y);
		cout<<x<<" "<<y<<endl;
	}
	return 0;
}


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

int main(){
	int n;
	int a[110000];
	cin>>n;
	for(int i=0; i<n; i++) cin>>a[i];
	sort(a, a+n);
	int ans1=a[n-1], ans2=0;
	for(int i=0; i<n; i++){
		if(min(ans1-ans2, ans1-(ans1-ans2))<min(ans1-a[i], ans1-(ans1-a[i]))) ans2=a[i];
	}
	cout<<ans1<<' '<<ans2<<endl;
	return 0;
}


Measured memory_bytes: 640
N,K=gets.split.map(&:to_i)
as=gets.split.map(&:to_i)
dp=Array.new(K+1,nil)
for i in 0..K
    if 0<=i && i<=as[0]-1
        dp[i]=false
    else
        dp[i]=false
        dp[i]=true if as.any?{|x|i-x>=0 && dp[i-x]==false}
    end
end
puts dp[K] ? "First" : "Second"


Measured memory_bytes: 2556
#include <bits/stdc++.h>
using namespace std;
 #define MAX 1000000000005
 #define ll long long int
 int main()
 {    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
   ll t;

        long long int m,sum=0,k=0,i,j,x=0,sum1=0,l,kk,y,z,e,f,q=MAX,r=MAX,n;
           ll b,c=0,d,zz=1;
             cin>>n;
              ll a[1000000]={1};
             for(i=2;i<=1000000;i++)
             {for(j=i;j<=1000000;j+=i)
                 a[j]++;
             }
             for(i=1;i<n;i++)
                sum+=a[i]+1;
             cout<<sum<<endl;
 }



Measured memory_bytes: 11408
#include <stdio.h>

int main(void)
{
  int r, D, x;
  scanf("%d %d %d", &r, &D, &x);
  for(int i = 0; i < 10; i ++){
    x = r * x - D;
    printf("%d\n", x);
  }
  return 0;
}


Measured memory_bytes: 128
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<string>
#include<algorithm>
using namespace std;
const int MaxN = 3000;

int a[MaxN + 5][MaxN + 5],ans[MaxN * MaxN + 5],DDa[MaxN * MaxN + 5],DDb[MaxN* MaxN + 5];

int main()
{
	int h,w,d,q,biu,l,r;
	while(~scanf("%d %d %d",&h,&w,&d))
	{
		for(int i = 1;i <= h;i++)
		{
			for(int j = 1;j <= w;j++)
			{
				scanf("%d",&a[i][j]);
				DDa[a[i][j]] = i;
				DDb[a[i][j]] = j;
			}
		}
		memset(ans,0,sizeof(ans));
		for(int i = 1;i <= h*w;i++)
		{
			biu = i+d;
			if(biu > h*w) break;
			if(DDa[i] > DDa[biu])
			{
				if(DDb[i]>DDb[biu]) ans[biu] += DDa[i]-DDa[biu]+DDb[i]-DDb[biu];
				else ans[biu] += DDa[i]-DDa[biu]+DDb[biu]-DDb[i];
			}
			else 
			{
				if(DDb[i]>DDb[biu]) ans[biu] += DDa[biu]-DDa[i]+DDb[i]-DDb[biu];
				else ans[biu] += DDa[biu]-DDa[i] + DDb[biu]-DDb[i];
			}
			ans[biu] += ans[i];
		}
		scanf("%d",&q);
		for(int i = 1;i <= q;i++)
		{
			scanf("%d %d",&l,&r);
			printf("%d\n",ans[r]-ans[l]);
		}
	}
	return 0;
}

Measured memory_bytes: 44416
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define int long long
constexpr long long INF = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

    int N;
    cin>>N;
    int a[N];
    int x=0;
    rep(i,N){
        cin>>a[i];
        x=x^a[i];
    }
    rep(i,N){
        int y=x^a[i];
        cout << y<<endl;
    }


    



}


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

using namespace std;

typedef long long ll;

const int N = 200100;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    int best = a[0];
    for (int i = 1; i < n; ++i) {
        if (min(a[i], a[n - 1] - a[i]) > min(best, a[n - 1] - best)) {
            best = a[i];
        }
    }
    cout << a[n - 1] << ' ' << best;
    return 0;
}

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

struct Card {char suit, value;};

void bubble(struct Card A[],int N){
  for (int i = 0; i < N; i++){
    for(int j = N-1;j >= i +1; j--){
      if(A[j].value < A[j -1].value){
	Card t = A[j];A[j] = A[j-1]; A[j -1] = t;
      }}}}

void selection(struct Card A[], int N){
  for(int i =0; i< N;i++){
    int minj = i;
    for(int j = i; j < N; j++){
      if(A[j].value < A[minj].value) minj = j;
    }
    Card t = A[i]; A[i] = A[minj]; A[minj] = t;
  }
}

void print(struct Card A[], int N){
  for(int i =0; i < N; i++){
    if(i > 0) cout<< " ";
    cout << A[i].suit << A[i].value;
  }
  cout << endl;
}

bool isStable(struct Card C1[], struct Card C2[], int N){
  for(int i = 0; i < N; i++){
    if(C1[i].suit != C2[i].suit) return false;
  }
  return true;
}

int main(){
  Card C1[100],C2[100];
  int N;
  char ch;

  cin >> N;
  for(int i = 0; i < N; i++){
    cin>>C1[i].suit >> C1[i].value;
  }

  for(int i = 0; i <N; i++) C2[i] = C1[i];

  bubble(C1, N);
  selection(C2, N);

  print(C1,N);
  cout << "Stable" << endl;
  print(C2,N);
  if(isStable(C1,C2,N)){
    cout << "Stable" << endl;
  }
 else{
   cout << "Not stable" << endl;
 }
return 0;
}
    



  



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

int N, K;

int main () {
  cin >> N >> K;
  int ans = 1;
  rep(i,N) {
    ans = min(ans*2, ans+K);
  }
  cout << ans << endl;
  return 0;
}


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

bool binary_search(vector<int> a, int x){
	int left = 0, right = a.size() - 1;

	while (left <= right){
		int mid = (left + right) / 2;
		if (a[mid] == x) return true;
		else if (a[mid] < x) left = mid + 1;
		else right = mid - 1;
	}
	return false;
}

int main()
{
	vector<int> vec(19);
	int cnt = 0;
	for (auto& x : vec) x = cnt++;
	int n;
	cnt = 0;
	while (cin >> n){
		for (int i = 0; i < 10; i++){
			for (int j = 0; j < 10; j++){
				if (binary_search(vec, n - i - j)){
					if (n - i - j < 10) cnt += n - i - j + 1;
					else cnt += 19 - n + i + j;
				}
			}
		}
		cout << cnt << "\n";
		cnt = 0;
	}
	cout.flush();
}

Measured memory_bytes: 1200
#include <bits/stdc++.h>
using namespace std;
#define REP(i, m, n) for(int i = m; i < n; i++)
#define rep(i, n) REP(i, 0, n)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define dup(x, y) (((x) + (y)-1) / (y)) //整数型のまま切り上げ演算する
#define PI 3.14159265359
typedef long long LL;
template <class T> inline void chmax(T &a, T b) {
    if(a < b) {
        a = b;
    }
}
template <class T> inline void chmin(T &a, T b) {
    if(a > b) {
        a = b;
    }
}
template <class T> inline T gcd(T x, T y) {
    if(y == 0) {
        return x;
    } else if(x == 0) {
        return y;
    }
    return gcd(y, x % y);
}
template <class T> inline T lcm(T x, T y) { return (x * y) / gcd(x, y); }
template <class T> inline void print_vector(vector<T> vec) {
    for(int i = 0; i < vec.size(); i++) {
        cout << vec[i] << " ";
    }
    cout << endl;
}
const LL MOD = 1e9 + 7;
const LL LLINF = 1LL << 60;
const int INF = 1 << 30;

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

    vector<int> n(4);
    rep(i, 4) n[i] = ABCD[i] - '0';

    if(n[0] + n[1] + n[2] + n[3] == 7) {
        printf("%d+%d+%d+%d=7\n", n[0], n[1], n[2], n[3]);
    } else if(n[0] - n[1] + n[2] + n[3] == 7) {
        printf("%d-%d+%d+%d=7\n", n[0], n[1], n[2], n[3]);
    } else if(n[0] + n[1] - n[2] + n[3] == 7) {
        printf("%d+%d-%d+%d=7\n", n[0], n[1], n[2], n[3]);
    } else if(n[0] + n[1] + n[2] - n[3] == 7) {
        printf("%d+%d+%d-%d=7\n", n[0], n[1], n[2], n[3]);
    } else if(n[0] - n[1] - n[2] + n[3] == 7) {
        printf("%d-%d-%d+%d=7\n", n[0], n[1], n[2], n[3]);
    } else if(n[0] - n[1] + n[2] - n[3] == 7) {
        printf("%d-%d+%d-%d=7\n", n[0], n[1], n[2], n[3]);
    } else if(n[0] + n[1] - n[2] - n[3] == 7) {
        printf("%d+%d-%d-%d=7\n", n[0], n[1], n[2], n[3]);
    } else if(n[0] - n[1] - n[2] - n[3] == 7) {
        printf("%d-%d-%d-%d=7\n", n[0], n[1], n[2], n[3]);
    }
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define ff first
#define ss second
#define ll long long
#define vi vector<int>
#define vii vector<vi>
#define vs vector<string>
#define vss vector<vs>
#define pii pair<int, int>
#define all(x) x.begin(), x.end()
#define rep(i, a, n) for (ll i = (a); i < (n); ++i)
#define repr(i, a, n) for (ll i = (n); i >= (a); --i)
using namespace std;
const int INF(1 << 30);
const ll LLINF(1LL << 55LL);
const int pi = 3.1415926536;
const int MOD = 1000000007;
const int MAX = 510000;

void Main() {
  char a, b;
  cin >> a >> b;
  if (a < b)
    puts("<");
  else if (a > b)
    puts(">");
  else
    puts("=");
}

int main() {
  std::cin.tie(nullptr);                  // 標準入出力高速化
  std::ios_base::sync_with_stdio(false);  // CとC++の入出力出力を非同期
  std::cout << std::fixed << std::setprecision(15);  // 小数を10進数表示
  Main();
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>

int main()
{
  
  int n; std::cin >> n;
  std::vector<int> l(n);
  for (int i = 0; i < n; ++i) std::cin >> l[i];
  std::sort(l.begin(), l.end()); 
  
  int ans = 0;
  for(int i = 0; i < n; i++)
  {
    for(int j = i+1; j < n; j++)
    {
      int k = std::distance(l.begin(),std::lower_bound(l.begin(), l.end(), l[i]+l[j]));
      
      ans += std::max(k-(j+1),0);
    }
  }
  std::cout << ans << std::endl;
  
}





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

const int maxN = 405, mod = 998244353;

int n, a[maxN + 1], b[maxN + 1], sa, sb;
int f[2][maxN + 1][maxN + 1];
int fac[maxN + 1], inv[maxN + 1];

inline int ADD(int x, int y) { return x + y >= mod ? x + y - mod : x + y; }

inline int SUB(int x, int y) { return x - y < 0 ? x - y + mod : x - y; }

inline int mpow(int a, int x)
{
	int ans = 1;
	while(x)
	{
		if(x & 1) ans = 1ll * ans * a % mod;
		a = 1ll * a * a % mod;
		x >>= 1;
	}
	return ans;
}

int main()
{
	scanf("%d", &n);
	for(int i = 1; i <= n; i++) 
		scanf("%d %d", &a[i], &b[i]), sa += a[i], sb += b[i];

	fac[0] = 1;
	for(int i = 1; i <= sb; i++) fac[i] = 1ll * fac[i - 1] * i % mod;
	inv[sb] = mpow(fac[sb], mod - 2);
	for(int i = sb - 1; i >= 0; i--) inv[i] = 1ll * inv[i + 1] * (i + 1) % mod;

	int now = 0;
	f[now][0][0] = mod - 1;
	for(int i = 1; i <= n; i++)
	{
		now ^= 1;
		for(int s = 0; s <= sa; s++)
			for(int x = 0; x <= sb; x++)
			{
				f[now][s][x] = f[now ^ 1][s][x];
				if(s < a[i]) continue;
				for(int t = 0, w = 1; t < b[i] && t <= x; t++, w = 1ll * w * a[i] % mod)
					f[now][s][x] = SUB(f[now][s][x], 1ll * w * inv[t] % mod * f[now ^ 1][s - a[i]][x - t] % mod);			   }	
	}

	int ans = 0;
	for(int s = 0; s <= sa; s++)
	{
		int INV = mpow(s, mod - 2);
		for(int x = 0, t = INV; x <= sb; x++, t = 1ll * t * INV % mod)
			ans = ADD(ans, 1ll * t * fac[x] % mod * f[now][s][x] % mod);
	}

	ans = 1ll * ans * sa % mod;
	printf("%d", ans);
	return 0;
}


Measured memory_bytes: 1536
#define MYDEBUG
//
#include <bits/stdc++.h>
#ifdef MYDEBUG
#define dbp(x) cout<<#x<<": "<<x<<endl
#define dbp2(x,y) cout<<#x<<","<<#y<<": "<<x<<","<<y<<endl
#define dbp3(x,y,z) cout<<#x<<","<<#y<<","<<#z<<": "<<x<<","<<y<<","<<z<<endl
#define dbp4(w,x,y,z) cout<<#w<<","<<#x<<","<<#y<<","<<#z<<": "<<w<<","<<x<<","<<y<<","<<z<<endl
#define ifcin(x) std::ifstream cin(x)
#else
#define dbp(x)
#define dbp2(x,y)
#define dbp3(x,y,z)
#define dbp4(w,x,y,z)
#define ifcin(x)
#endif
#define ll long long
#define all(x) x.begin(), x.end()
#define rep(i, from, to) for(int i=from; i<to; ++i)
#define REP(i, from, to) for(int i=from; i<=to; ++i)
using namespace std;
template<typename T>
ostream& operator<<(ostream& out, const vector<T>& v) {
  out << "[";
  size_t last = v.size() - 1;
  for (size_t i = 0; i < v.size(); ++i) {
    out << v[i];
    if (i != last) {
      out << ",";
    }
  }
  out << "]";
  return out;
}
template<typename T>
ostream& operator<<(ostream& out, const vector<vector<T> >& v) {
  for (size_t i = 0; i < v.size(); ++i) {
    out << v[i] << endl;
  }
  return out;
}
template<typename T1, typename T2>
ostream& operator<<(ostream& out, const pair<T1, T2>& p) {
  out << "{" << p.first << "," << p.second << "}";
  return out;
}

static const int M = 1046597;
static const int L = 12;
char T[M][L];
char com[6], word[L];
int getChar(char ch) {
  if (ch == 'A') {
    return 1;
  } else if (ch == 'C') {
    return 2;
  } else if (ch == 'G') {
    return 3;
  } else {
    return 4;
  }
}

int getKey(char str[]) {
  int key = 0, p = 1;
  rep(i,0,(int) strlen(str))
  {
    key += p * getChar(str[i]);
    key *= 5; //左シフト(5進数)
  }
  return key;
}

int h1(int key) {
  return key % M;
}

//mとh2は互いに素に
int h2(int key) {
  //素数Mより小さい数はみなMと互いに素
  //h2の周期はM未満であればなんでも可
  //1を加えるのはkey%(M-1)==0のときにずれなくなるのを防ぐため
  //この関数は1 ~ M-1の間の値をとる
  return 1 + (key % (M - 1));
}

int insert(char str[]) {
  int key, i, h;
  key = getKey(str);
  for (i = 0;; ++i) {
    h = (h1(key) + i * h2(key)) % M;
    if (strcmp(T[h], str) == 0) {
      return 1; //すでに格納済
    } else if (strlen(T[h]) == 0) {
      strcpy(T[h], str);
      return 0;
    }
  }
  return 0;
}

bool find(char str[]) {
  ll key, i, h;
  key = getKey(str);
  for (i = 0;; ++i) {
    h = (h1(key) + i * h2(key)) % M;
    if (strcmp(T[h], str) == 0) {
      return true;
    } else if (strlen(T[h]) == 0) {
      return false;
    }
  }
  return false;
}

void solve() {
  rep(i,0,M)
  {
    T[i][0] = '\0'; //すべて空文字列で初期化
  }
  int n;
  scanf("%d", &n);
  rep(i,0,n)
  {
    scanf("%s %s", com, word);
    if (com[0] == 'i') {
      insert(word);
    } else {
      if (find(word)) {
        printf("yes\n");
      } else {
        printf("no\n");
      }
    }
  }
}
int main() {
  solve();
  return 0;
}



Measured memory_bytes: 15420
#include <stdio.h>

int     main(void)
{
    int i;
    int x;
    
    i = 1;
    while (1)
    {
        scanf("%d",&x);
        if (x != 0)
            printf("Case %d: %d\n",i,x);
        if (x == 0)
            break;
        i++;
    }
    return (0);
}


Measured memory_bytes: 2084
n = int(input())
ph = 0
pl = 10**10
mh = -10**10
ml = 10**10
for _ in range(n):
  x,y = map(int,input().split())
  ph = max(ph,x+y)
  pl = min(pl,x+y)
  mh = max(mh,x-y)
  ml = min(ml,x-y)
print(max(ph-pl,mh-ml))

Measured memory_bytes: 9128
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n;i++)
typedef long long ll;
  
int main() {
   int n;
  cin>>n;
  vector<int> a(n);
  rep(i,n) cin>>a[i];
  
  sort(a.begin(),a.end());
  double ave=a[0];
  
  for(int i=1; i<n ;i++){
    ave = (ave+a[i])/2;
  }
  cout << ave;
    
    
  
return 0;


}

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

int main() {
    int n, W;
    scanf("%d %d", &n, &W);
    vector<int> w(n), v(n);
    for (int i=0; i<n; i++) {
        scanf("%d %d", &w[i], &v[i]);

    }
    const int INF = (int)1e9+5;
    vector<int> dp(100005, INF);
    vector<int> temp(100005, INF);
    temp[0] = 0;
    dp[0] = 0;
    for (int i=1; i<=n; i++) {
        // vector<int> temp(dp.begin(), dp.end());
        for (int j=v[i-1]; j<=100000; j++) {
            temp[j] = min(dp[j], w[i-1]+dp[j-v[i-1]]);
        }
        for (int i=0; i<=100000; i++) {
            dp[i]=temp[i];
        }
    }
    int ind = 0;
    for (int i=0; i<=100000; i++) {
        // printf("dp[%d] = %d\n", i, dp[i]);
        if (dp[i]<=W) ind = i;
    }

    printf("%d\n", ind);
}

Measured memory_bytes: 1024
/*
   Author: Shivam Shukla
*/
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pair<ll,ll> > vpll;
 
const int MOD=1e9+7;
const int MAX=1e5+5;
const double PI= acos(-1.0);
const long double EPS=1e-10;
const int64_t INF=1e18+10;
 
#define fastio() ios_base::sync_with_stdio(false);cin.tie(0), cout.tie(0)
#define trace(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vi vector<int>
#define vl vector<ll>
#define vs vector<str>
#define vc(x) vector<x>
#define mapll map<ll,ll>
#define mapib map<int,bool>
#define mapiv map<int,vector>
#define mapsi map<string,int>
#define rep(i,j,k) for(ll i=j;i<k;i++)
#define down(i,j,k) for(ll i=j;i>=k;i--)
#define repa(i,n) for(ll i=0;i<n;i++)
#define dowa(i,n) for(ll i=n;i>=0;i--)
#define reps(i,j,k,s) for(ll i=j;i<k;i+=s)
#define downs(i,j,k,s) for(ll i=j;i>=k;i-=s)
#define trv(i,x) for(auto i:x)
#define pb push_back
#define eb emplace_back
#define sz(x) (int)x.size()
#define ff first
#define ss second
#define str string 
#define dub double
#define pqmax priority_queue<ll>
#define pqmin priority_queue<ll,vl,greater<ll> >
 
template<typename t> t lcm(t a, t b) {return (a*b)/__gcd(a,b);}
template<typename t> t gcd(t a, t b) {return __gcd(a,b);}
template<typename t> t mul_mod(t a, t b, t m){t res=((a%m)*(b%m)%m); return res;}
template<typename t> t add_mod(t a, t b, t m){t res=((a%m)+(b%m))%m; return res;}
template<typename t> t pow_mod(t a,t b,t m) {t res=1;while(b){if(b&1) res=mul_mod(res,a,m);a=mul_mod(a,a,m), b>>=1;} return res%m;}
template<typename t> vc(t) num_vec(t num) {t res; while (num) res.pb(num%10), num/=10; return res;}
template<typename t> t vec_num(t vec) {t res=0; ll mul=1; repa(i,sz(vec)) res=vec[i]*mul, mul*=10; return res;}
 

int32_t main(int argc,char** argv){
	fastio();
	auto tstart= clock();
 
	
    int n, m; cin >> n >> m;
    vpii d(m); repa(i,m) cin >> d[i].ff >> d[i].ss;

    vi di(n, -1);

    repa(i, m) {
       if (di[d[i].ff - 1] == -1)
       	  di[d[i].ff - 1] = d[i].ss;

       else if(di[d[i].ff - 1] != d[i].ss)
          return cout << -1 << endl, 0;	   
    } 
    
    if (di[0] == -1 && n > 1)
    	 di[0] = 1;

    repa(i, n)
       if (di[i] == -1)
          di[i] = 0;

    if (di[0] == 0 && n > 1)
    	return cout << -1 << endl, 0;

    trv(i,di) 
       cout << i;

    cerr<<setprecision(2)<<fixed<<"Time elapsed: "<<(double)(clock() - tstart)/CLOCKS_PER_SEC<<endl; 
    return 0; 
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define Y second
#define pb emplace_back
#define FOR(i,a,b) for(int (i)=(a);i<(b);++(i))
#define EFOR(i,a,b) for(int (i)=(a);i<=(b);++(i))
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define reps(X,S,Y) for (int (X) = S;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define rreps(X,S,Y) for (int (X) = (Y)-1;(X) >= (S);--(X))
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define eb emplace_back
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef ll LL;
typedef pii PII;
typedef pll PLL;
template<class T> using vv=vector<vector<T>>;
template<class T> inline bool MX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}
const ll MOD=998244353;

int N;
int X;
LL conv[6145];
LL memo[6145][6145];
LL num[6145][6145];
LL num2[6145][6145];

LL Comb(int n, int r) {
  if (n < 0 || r < 0 || n < r) return 0;
  if (n == r || r == 0) return 1;
  if (memo[n][r] != -1) return memo[n][r];
  return memo[n][r] = (Comb(n-1, r) + Comb(n-1, r-1)) % MOD;
}

LL f(int s, int t) {
  return Comb(s+t, t);
}

LL Conv(int l, int r) {
  assert(l <= r);
  LL ret = conv[r];
  if (l > 0) ret += MOD-conv[l-1];
  return ret%MOD;
}

int main() {
  fill(memo[0], memo[6145], -1);
  scanf("%d%d", &N, &X);

  rep(i, N+1) {
    conv[i] = f(N-i, i);
    if (i > 0) conv[i] = (conv[i-1]+conv[i]) % MOD;
  }

  num[0][0] = 1;
  num2[0][0] = 1;
  reps(k, 1, N+1) {
    rep(S, X+1) {
      if (S >= 2) num[k][S] += num[k-1][S-2];
      if (S >= 1) num[k][S] += num[k-1][S-1];
      if (S >= 2) num2[k][S] += num2[k-1][S-2];
      if (S >= 1) num2[k][S] += num2[k-1][S-1];
      num[k][S] += num[k-1][S];
      num[k][S] %= MOD;
      num2[k][S] %= MOD;
    }
  }

  LL ans = 0;
  rep(k, N+1) {
    if (X%2 == 1 && k*2 > X) {
      ans += f(k, N-k);
      ans %= MOD;
    }
  }

  rep(S, X) {
    ans += num[N][S];
    ans %= MOD;
  } 

  reps(k, 1, N+1) {
    int d = X-2-2*k;
    if (d >= 0) {
      rep(g, N+1) {
        int r = N-(k+g+2);
        int l = max(N-(2*k+g+1), 0);
        if (r < 0) continue;

        ans += num2[g][d] * Conv(l, r);
        ans %= MOD;
      }
    }
  }
  printf("%lld\n", ans);
}


Measured memory_bytes: 586368
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;

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

int main(){
    int n,k;
    cin>>n>>k;
    vector<int> x(n);
    for(int i=0;i<n;i++){
        cin>>x[i];
    }
    vector<int>::iterator up,low;

    up = lower_bound(x.begin(),x.end(),0);
    int sum = 1e9;

        for(int i=0,j=i+k-1; j < n ;i++,j++){
           chmin(sum, x[i+k-1]-x[i]+min(abs(x[i+k-1]),abs(x[i])));
        }

    cout<<sum<<endl;
    return 0;
}


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

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

int main()
{
    long H, W;
    cin >> H >> W;
    long long tmp = H * W;
    if(H == 1 || W == 1)
    {
        cout << 1 << endl;
        return 0;
    }
    if(tmp % 2 == 1)
    {
        cout << (tmp / 2 + 1) << endl;
    }
    else
    {
        cout << (tmp / 2) << endl;
    }
    
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int h = sc.nextInt();
        int a = sc.nextInt();
        int cnt = 0;
        while (h > 0) {
            h -= a;
            cnt++;
        }
        System.out.println(cnt);
        sc.close();
    }
}


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

int main(void){
    // Your code here!
    int N;cin>>N;
    int D[N][2];
    int count=0;
    for(int i=0;i<N;i++){
        cin>>D[i][0]>>D[i][1];
        if(D[i][0]==D[i][1]){
            count++;
            if(count==3){
                cout<<"Yes"<<endl;
                return 0;
            }
        }
        else{
            count=0;
        }
    }
    cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 3632
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define repLRE(i, l, r) for (ll i = (l); i <= (r); ++i)
#define rrepLRE(i, l, r) for (ll i = (l); i >= (r); --i)
#define Sort(v) sort(v.begin(), v.end())
#define rSort(v) sort(v.rbegin(), v.rend())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

ll dx[9] = {-1, 1, 0, 0, -1, -1, 1, 1, 0};
ll dy[9] = {0, 0, -1, 1, -1, 1, -1, 1, 0};

/* Macros reg. ends here */

const ll INF = 1LL << 50;

vvP to;
vll dist;

void dfs(ll v, ll par){
  for(auto p : to[v]){
    ll u = p.first;
    if(u == par) continue;
    dist[u] = dist[v] + p.second;
    dfs(u, v);
  }
}

int main() {
  // ios_base::sync_with_stdio(0), c
  cout << fixed << setprecision(15);

  ll n;
  cin >> n;

  to.resize(n);
  rep(i, n-1){
    ll a, b, c;
    cin >> a >> b >> c;
    a--, b--;
    to[a].emplace_back(b, c);
    to[b].emplace_back(a, c);
  }

  ll q, k;
  cin >> q >> k;
  k--;
  dist.resize(n);
  dist[k] = 0;
  dfs(k, -1);
  rep(i, q){
    ll x, y;
    cin >> x >> y;
    x--, y--;
    cout << dist[x] + dist[y] << endl;
  }

  return 0;
}


Measured memory_bytes: 15588
#include <iostream>

using namespace std;

const long MOD = 1000000007;
typedef pair<int, int> P;

long lcm(long a, long b){
    if(b>a){
        long t = a;
        a = b;
        b = t;
    }

    long sa = a;
    long sb = b;

    // ここでr=1で初期化しておかないと、直後のr!=0がtrueになってしまうことがある
    long r = 1;
    while(r!=0){
        r = a % b;
        a = b;
        b = r;
    }

    long gcd = a;

    return gcd;

}

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

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

    int l[N+1];
    l[0] = A[0];
    for(int i=1; i<N; i++){
        l[i] = lcm(A[i], l[i-1]);
    }

    int r[N];
    r[N-1] = A[N-1];
    for(int i=N-2; i>=0; i--){
        r[i] = lcm(r[i+1], A[i]);
    }

    int ans;
    for(int i=0; i<N; i++){
        int t;
        if(i-1<0) t = r[i+1];
        else if(i+1>=N) t = l[i-1];
        else t = lcm(r[i+1], l[i-1]);
        ans = max(ans, t);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1408
import heapq

def main():
    N, M, S = map(int, input().split())
    AB = [[] for _ in range(N)]
    maxA = 0
    for _ in range(M):
        u, v, a, b = map(int, input().split())
        AB[u - 1].append((a, b, v - 1))
        AB[v - 1].append((a, b, u - 1))
        maxA = max(maxA, a)
    for i in range(N):
        AB[i].sort()

    CD = [tuple(map(int, input().split())) for _ in range(N)]
    maxS = N * maxA
    cur = [(0, 0, S)]  # (time, station, silver)
    T = [-1] * N
    tc = N
    P = [-1] * N
    while tc:
        t, u, s = heapq.heappop(cur)
        if s <= P[u]:
            continue
        P[u] = s
        if T[u] == -1:
            T[u] = t
            tc -= 1
        for a, b, v in AB[u]:
            if s < a:
                break
            if P[v] < s - a:
                heapq.heappush(cur, (t + b, v, s - a))
        if s != maxS:
            c, d = CD[u]
            min_a = AB[u][0][0]
            k = max(1, (min_a - s + c  - 1) // c)
            heapq.heappush(cur, (t + k * d, u, min(s + k * c, maxS)))
    print('\n'.join(map(str, T[1:])))

main()


Measured memory_bytes: 9332
import sys

input = sys.stdin.buffer.readline
in_n = lambda: int(input())
in_nn = lambda: map(int, input().split())
in_s = lambda: input().rstrip().decode('utf-8')
in_map = lambda: [s == ord('.') for s in input() if s != ord('\n')]

MOD = 10**9 + 7
INF = 8 * 10**18


def main():

    N = in_n()
    S = in_s()

    ans = 0
    for i in range(1, N - 1):
        v1 = set(S[:i])
        v2 = set(S[i:])
        ans = max(ans, len(v1 & v2))

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9208
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
using namespace std;
vector<double> i;
vector<int> u;
vector<int> o;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  double a=0,b,c,d=0,e=0,f=0,g;
  string s;
  cin >>a;
  for(int n=0;n<a;n++){
    cin >>b;
    i.push_back(b);
  }
  sort(i.begin(),i.end());
  d=i[0];
  for(int n=1;n<a;n++){
    d=(d+i[n])/2;
  }
  cout <<fixed<<d<<'\n';
  return (0);
}


Measured memory_bytes: 256
/*
    Author : DemonStar
*/

#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
#define ordered_set tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define all(x) x.begin(), x.end()
#define loop(i, n) for(ll i = 0; i < n; i++)
#define pl pair<ll, ll>
#define vl vector<ll>
#define endl '\n'
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i : x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}

#ifdef LOCAL
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};


template <typename T, typename TT>
ostream &operator<<(ostream &os, const pair<T, TT> &t) {
    return os << t.first << " " << t.second;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &t) {
    for (auto &i : t) os << i << " ";
    return os;
}
template <typename T>
istream &operator>>(istream &is, vector<T> &v) {
    for (T &t : v) is >> t;
    return is;
}
template <typename T1, typename T2>
istream &operator>>(istream &is, vector<pair<T1, T2>> &v) {
    for (pair<T1, T2> &t : v) is >> t.first >> t.second;
    return is;
}

const ll mod = 1e9 + 7;

int main()
{

#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    ll n, k;
    cin >> n >> k;
    vl v(n);
    cin >> v;
    sort(all(v));
    ll s = 0;
    for (int i = 0; i < k; i++) s += v[i];
    cout << s << endl;

#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s";
#endif


    return 0;
}

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

using namespace std;

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

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

    map<ll, ll> map;
    map[0] = 0;
    ll n = 1;
    while (true) {
        ll m = pow(n, 5);
        ll t = map[m - X];
        ll tt = pow(t, 5);
        if (m - tt == X) {
            cout << n << " " << t << endl;
            break;
        }
        map[m] = n;
        map[-m] = -n;
        n++;
    }
    return 0;
}

Measured memory_bytes: 4080