akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<queue>
#include<set>
#include<cassert>
#include<tuple>

using namespace std;
#define repeat(i,n) for(int i=0;i<(n);i++)
using pii=pair<int, int>;

struct Data{
   int v;
   pii s;
   Data(int vv, pii ss){v=vv; s=ss;}
};

bool operator<(const Data &l, const Data &r){
   return l.v<r.v;
}

struct SegmentTree{

   int sz;
   const int inf=1e9;
   vector<pii> seg;
   SegmentTree(int N){
      sz=1;
      while(sz<N) sz*=2;
      seg.resize(2*sz-1, {inf, -1});
   }

   void init(vector<int> &a, int ev){
      repeat(i, a.size()){
         if((i+ev)%2==1) seg[i+sz-1]={a[i], i};
         else seg[i+sz-1]={inf, i};
      }
      for(int i=sz-2; i>=0; i--){
         seg[i]=mrg(seg[2*i+1], seg[2*i+2]);
      }
   }

   pii mrg(pii l, pii r){
      pii rt;
      rt.first=min(l.first, r.first);
      rt.second=(l.first<r.first?l.second:r.second);
      return rt;
   }

   pii mi(int a, int b, int i, int l, int r){
      if(a<=l and r<=b){
         return seg[i];
      }else if(b<=l or r<=a){
         return {inf, -1};
      }else{
         int m=(r+l)/2;
         auto vl=mi(a, b, 2*i+1, l, m);
         auto vr=mi(a, b, 2*i+2, m, r);
         return mrg(vl, vr);
      }
   }

   pii mi(int a, int b){
      return mi(a, b, 0, 0, sz);
   }

   void out(){
      repeat(i, sz){
         cout<< seg[i+sz-1].first<< " ";
      }cout<< endl;
   }

};

int main(){

   int N; cin>> N;
   vector<int> a(N);
   repeat(i, N) cin>> a[i], a[i]--;

   SegmentTree st[2](N);
   st[0].init(a, 1); st[1].init(a, 0);
   /*
   priority_queue<tuple<int, int, int>> Q; // min, l, r
   Q.push(make_tuple(-st[0].mi(0, N).first, 0, N));
   */
   set<tuple<int, int, int>> S;
   S.insert(make_tuple(-st[0].mi(0, N).first, 0, N));
   vector<int> q;
   // st[0].out(); st[1].out();
   while(not S.empty()){
      int v, i, j;
      /*
      tie(v, i, j)=Q.top(); Q.pop();
      */
      tie(v, i, j)=*S.begin(); S.erase(S.begin());
      auto ev=st[i%2].mi(i, j);
      auto od=st[(i+1)%2].mi(ev.second+1, j);
      // cout<< v<< " "<< i<< " "<< j<< endl;
      assert(j-i>=2);
      assert((i+ev.second)%2==0);
      assert((i+od.second)%2==1);
      q.push_back(ev.first); q.push_back(od.first);
      if(i<ev.second){
         auto e=st[i%2].mi(i, ev.second);
         S.insert(make_tuple(e.first, i, ev.second));
      }
      if(od.second+1<j){
         auto e=st[(od.second+1)%2].mi(od.second+1, j);
         S.insert(make_tuple(e.first, od.second+1, j));
      }
      if(ev.second+1<od.second){
         auto e=st[(ev.second+1)%2].mi(ev.second+1, od.second);
         S.insert(make_tuple(e.first, ev.second+1, od.second));
      }
   }

   repeat(i, N){
      if(i){
         cout<< " "<< q[i]+1;
      }else{
         cout<< q[i]+1;
      }
   }cout<< endl;

   return 0;
}


Measured memory_bytes: 13812
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using vec = vector<ll>;
using vect = vector<double>;
using Graph = vector<vector<ll>>;
#define loop(i, n) for (ll i = 0; i < n; i++)
#define Loop(i, m, n) for (ll i = m; i < n; i++)
#define pool(i, n) for (ll i = n; i >= 0; i--)
#define Pool(i, m, n) for (ll i = n; i >= m; i--)
#define mod 1000000007ll
#define flagcount __builtin_popcount
#define flag(x) (1 << x)
#define flagadd(bit, x) bit |= flag(x)
#define flagpop(bit, x) bit &= ~flag(x)
#define flagon(bit, i) bit &flag(i)
#define flagoff(bit, i) !(bit & (1 << i))
#define all(v) v.begin(), v.end()
#define low2way(v, x) lower_bound(all(v), x)
#define high2way(v, x) upper_bound(all(v), x)
#define idx_lower(v, x) (distance(v.begin(), low2way(v, x)))  //配列vでx未満の要素数を返す
#define idx_upper(v, x) (distance(v.begin(), high2way(v, x))) //配列vでx以下の要素数を返す
#define idx_lower2(v, x) (v.size() - idx_lower(v, x))         //配列vでx以上の要素数を返す
#define idx_upper2(v, x) (v.size() - idx_upper(v, x))         //配列vでxより大きい要素の数を返す
#define putout(a) cout << a << endl
#define Gput(a, b) G[a].push_back(b)
#define Sum(v) accumulate(all(v), 0ll)
#define gcd(x, y) __gcd(x, y)
ll ctoi(char c)
{
    if (c >= '0' && c <= '9')
    {
        return c - '0';
    }
    return 0;
}
template <typename T>
T lcm(T x, T y)
{
    T z = gcd(x, y);
    return x * y / z;
}
template <typename T>
bool primejudge(T n)
{
    if (n < 2)
        return false;
    else if (n == 2)
        return true;
    else if (n % 2 == 0)
        return false;
    double sqrtn = sqrt(n);
    for (T i = 3; i < sqrtn + 1; i++)
    {
        if (n % i == 0)
        {
            return false;
        }
        i++;
    }
    return true;
}
//場合によって使い分ける
//const ll dx[4]={1,0,-1,0};
//const ll dy[4]={0,1,0,-1};
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//2次元配列の宣言
//vector<vector<ll>> field(h, vector<ll>(w));
long long modpow(long long a, long long n)
{
    long long res = 1;
    while (n > 0)
    {
        if (n & 1)
            res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
int main()
{
    cout << fixed << setprecision(30);
    ll n;
    cin >> n;
    vec a0(63, 0), a1(63, 0);
    loop(i, n)
    {
        ll A;
        cin >> A;
        loop(j, 63)
        {
            ll mod2 = A % 2;
            if (mod2 == 0)
                a0[j]++;
            else
                a1[j]++;
            A /= 2;
        }
    }
    ll ans = 0;
    loop(j, 63)
    {
        ans += modpow(2, j) * ((a0[j] * a1[j]) % mod);
        ans %= mod;
    }
    putout(ans);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
#include <chrono>
#include<assert.h>
#define MAX 1000001
#define pii pair<int, int>
#define F first
#define S second
#define MIN3POS(a, b, c) (a) =< (b) ? ((a) =< (c) ? 1 : 3) : ((b) =< (c) ? 2 : 3)
#define MAX3POS(a,b,c) (a) >= (b) ? ((a) >= (c) ? 1 : 3) : ((b) >= (c) ? 2:3)
#define endl '\n'
#define int long long
#define forn(i, n) for (long long i = 0; i < long long(n); ++i)
#define IOS   ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
inline bool is_palindrome(const string &s) { return std::equal(s.begin(), s.end(), s.rbegin()); }
struct knap{
    int num,weight;
};
int32_t main()
{
auto start = chrono::high_resolution_clock::now();
IOS
int n,we;
cin>>n>>we;
vector<int> dp(we+1,0);
for(int i=0;i<n;i++){
    int weight,value;
    cin>>weight>>value;
    for (int j = we - weight; j >=0; j--)
    {
        dp[j+weight] = max(dp[j+weight],dp[j] + value);
    }
}
cout<<dp[we];
auto end = chrono::high_resolution_clock::now();
double time_taken = chrono::duration_cast<chrono::nanoseconds>(end - start).count();
time_taken *= 1e-9;
//cout << fixed << time_taken;
return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <algorithm>

const int maxn = 123;
int dp[maxn][maxn];
std::string s[maxn];
int h, w;

int main(int argc, char *argv[]) {  
	std::ios::sync_with_stdio(false);
	std::cin.tie(0); 
	std::cin >> h >> w;
	for (int i = 0; i < h; i++) {
		std::cin >> s[i];
	}
	dp[0][0] = int(s[0][0] == '#');
	for (int i = 1; i < h; i++) {
		dp[i][0] = dp[i-1][0] + int(s[i][0] != s[i-1][0]);
	}
	for (int j = 1; j < w; j++) {
		dp[0][j] = dp[0][j-1] + int(s[0][j] != s[0][j-1]);
	}
	for (int i = 1; i < h; i++) {
		for (int j = 1; j < w; j++) {
			dp[i][j] = std::min(dp[i-1][j] + int(s[i][j] != s[i-1][j]), dp[i][j-1] + int(s[i][j] != s[i][j-1]));
		}
	}
//	for (int i = 0; i < h; i++) {
//		for (int j = 0; j < w; j++) {
//			std::cout << dp[i][j] << " \n"[j==w-1];
//		}
//	}
	std::cout << (dp[h-1][w-1]+1)/2 << '\n';
}

Measured memory_bytes: 384
#import pysnooper
#import numpy
#import os,re,sys,operator
from collections import Counter,deque
#from operator import itemgetter
#from itertools import accumulate,combinations,groupby,combinations_with_replacement,permutations
from sys import stdin,setrecursionlimit
#from copy import deepcopy
import heapq
#import math
#import string
setrecursionlimit(10**6)
input=stdin.readline

s=[]
heapq.heapify(s)

while 1:
    c,*n=input().split()
    if c=="end":
        break
    elif c=="insert":
        k=int(n[0])
        heapq.heappush(s,-k)
    else:
        print(-heapq.heappop(s))


Measured memory_bytes: 45880
#include<iostream>
#include<string>
using namespace std;
int main(){
	string a;
	while(true){
		int count=0;
	    cin>>a;
		if(a=="#")
			break;
		bool right=true,mae;
		for(int i=0;i<a.size();i++){
			mae=right;
			if(a[i]=='y'||a[i]=='u'||a[i]=='i'||a[i]=='o'||a[i]=='p'||a[i]=='h'||a[i]=='j'||a[i]=='k'||a[i]=='l'||a[i]=='n'||a[i]=='m'){
				right=true;
			}
			else{
				right=false;
			}
			if(i!=0&&mae!=right)
				count++;
		}
		cout<<count<<endl;
	}
	return 0;
}

Measured memory_bytes: 1184
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define INF 1000000
using namespace std;
typedef pair<int, bool> P;
int main()
{
    int N, M;
    cin >> N >> M;
    //cout << vec[3] << endl;
    vector<bool> flag(N + 1);
    vector<int> e(M + 1);
    rep(i, M) cin >> e[i];
    for (int i = M - 1; i >= 0; i--)
    {
        if (flag[e[i]])
            continue;
        flag[e[i]] = true;
        cout << e[i] << endl;
    }
    for (int i = 1; i <= N; i++)
    {
        if (!flag[i])
            cout << i << endl;
    }
    return 0;
}


Measured memory_bytes: 3344
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
#define SIZE_OF_ARRAY(a) (sizeof(a)/sizeof(a[0]))

unsigned GetDigit(unsigned num){
    return std::to_string(num).length();
}



int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int ans = 0;
    string ans2;
    int N,M,X;
    cin >> N >> M >> X;
    int a[M];
    for(int i = 0;i < M;i++){
        cin >> a[i];
    }
    int cost = 0,cost2 = 0;
    int j = 0;
    for(int i = X;i < N;i++){
        root :
        if(i == a[j]){
            cost++;
            j++;
        }else if(i > a[j]){
            j++;
            goto root;
        }
    }
    j = 0;
    for(int i = 0;i <= X;i++){
        root2 :
        if(i == a[j]){
            cost2++;
            j++;
        }else if(i > a[j]){
            j++;
            goto root2;
        }
    }
    cout << min(cost,cost2) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl '\n'
using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    stack<int> s;
    long long int N;
    cin >> N;
    while(N > 0){
        int num;
        num = N % 26;
        if(num == 0)
            num +=26;
        N -= num;
        s.push(num);
        N /= 26;
    }
    while(s.size()){
        cout << char(s.top()+96);
        s.pop();
    }


    return 0;
}



Measured memory_bytes: 3604
#include <iostream>

int main()
{
  int A,B, ret;
  ret = 0;

  std::cin >> A >> B;

  for(size_t i = 0;
      i < 2;
      ++i)
    {
      if(A > B)
        {
          ret += A;
          --A;
        }
      else
        {
          ret += B;
          --B;
        }
    }
  std::cout << ret << std::endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<vector>
#include<set>
#include<algorithm>
#include<tuple>
#include<utility>
#include<cctype>
#include<climits>
#include<map>
#include<queue>
#include<functional>

using namespace std;

#define REP(i,n) for(int i=0;i<n;++i)
#define RUP(a,b) ((a+b-1)/(b))
#define ENT "\n"
#define REV(v) reverse(v.begin(),v.end())

typedef long long ll;
typedef tuple<int,int,bool> Tb;


int atcoder(){
    //入力
    int n;
    cin >> n;
    //出力
    cout << 1110-n << ENT;
    return 0;
}

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


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
typedef unsigned int ui;
int main(){
	int n,a,b;
	vector<int> G[100000];
	cin >> n;
	int i,j;
	for (i = 0; i < n - 1; i++) {
		cin >> a >> b; a--; b--;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	vector<int> q1,q2;
	int count1 = 0; int count2 = 0; int used[100000] = {};
	q1.push_back(0); q2.push_back(n-1); used[0] = 1; used[n - 1] = 1;
	while (!((q1.empty())&&q2.empty())) {
		int len = q1.size();
		for (i = 0; i < len; i++) {
			int le = G[q1[i]].size();
			for (j = 0; j < le; j++) {
				if (used[G[q1[i]][j]] == 0) {
					used[G[q1[i]][j]] = 1; q1.push_back(G[q1[i]][j]); count1++;
				}
			}
		}
		for (i = 0; i < len; i++) {
			q1.erase(q1.begin());
		}
		len = q2.size();
		for (i = 0; i < len; i++) {
			int le = G[q2[i]].size();
			for (j = 0; j < le; j++) {
				if (used[G[q2[i]][j]] == 0) {
					used[G[q2[i]][j]] = 1; q2.push_back(G[q2[i]][j]); count2++;
				}
			}
		}
		for (i = 0; i < len; i++) {
			q2.erase(q2.begin());
		}
	}
	if (count1 > count2) {
		cout << "Fennec" << endl;
	}
	else cout << "Snuke" << endl;
	return 0;
}

Measured memory_bytes: 6528
#include<stdio.h>

int main(){
int a,b,c,i;
  i=3;
  scanf("%d %d %d",&a,&b,&c);
  if(a==b){
    i--;
  }
  if(a==c){
    i--;
  }
  else if(b==c){
    i--;
  }
  printf("%d",i);
  return 0;
}

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

#define ll long long

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll a, b, c;
	cin >> a >> b >> c;
	if (c>=a && c<=b){
		cout << "Yes" << endl;
	} else { cout << "No" << endl; }
}


Measured memory_bytes: 256
#include<math.h>

int main(){
	int number[5],i,j,t;
	
	while(0<=scanf("%d",&number[0])){
		for(i=1;i<5;i++){
			scanf("%d",&number[i]);
		}
		
		for(i=0;i<5;i++){
			for(j=i;j<5;j++){
				if(number[i]<number[j]){
					t=number[i];
					number[i]=number[j];
					number[j]=t;
				}
			}
		}
		
		for(i=0;i<4;i++){
			printf("%d ",number[i]);
		}
	
		printf("%d\n",number[4]);
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ' '
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define in3(n, m, l) cin >> n >> m >> l
#define out(n) cout << n
const ll mei = (ll)1e9 + 7;

int main(){
  ll a, b;
  in2(a, b);
  out(a - b + 1);
  memi;
}

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

int main()
{
    double dRadius = 0.0;
    double dArea = 0.0;
    double dCir = 0.0;
    
    cin >> dRadius;
    
    dArea = M_PI * dRadius * dRadius;
    dCir = 2 * M_PI * dRadius;
    
    cout << setiosflags(ios::fixed) << setprecision(6) << dArea << " ";
    cout << setiosflags(ios::fixed) << setprecision(6) << dCir << endl;
    
    return 0;
}


Measured memory_bytes: 3284
/* fucklove - when you give everything to someone and it's stil not enough */
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <numeric>
#include <unordered_map>
#include <unordered_set>

 
using namespace std;
 
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
 
typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector<int> vi;
 
const ll N=1e3 + 5 ,  INF = 1e6 + 10 , md=1e9+7;
 
int gcd(int a, int b) { if (b == 0) return a; return gcd(b, a % b);} 
int takemod(int a, int mod ){a%=mod;if(a<0)a+=mod;return a;}
int fast_exp(int base, int expo, int mod ) {
	int res=1;
	while(expo>0) {
		if(expo&1) res=(res*base)%mod;
		base=(base*base)%mod;
		expo>>=1;}
	return res;}
int modinv(int a, int mod ){return takemod(fast_exp(takemod(a,mod), mod-2, mod), mod);}


int main()
{
	fast_cin();
	int t=1;
//	cin >> t;
	while(t--){
		string s; cin>>s;
		int len=s.length();
		string res="";
		for(int i=0;i<len;i++){
			res+="x";
		}

		cout <<res<<endl;

	
	}
	return 0;
}
 

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int a, b, c, d;
	scanf("%d%d%d%d", &a, &b, &c, &d);

	if ( (a-c)*(a-c) <= d*d ) {
		printf("Yes\n");
	} else if ( (a-b)*(a-b) <= d*d && (b-c)*(b-c) <= d*d ) {
		printf("Yes\n");
	} else {
		printf("No\n");
	}
	return 0;
}


Measured memory_bytes: 128
# -*- coding: utf-8 -*-
import math
    
def abs(num):
    if num < 0:
        return -num
    else:
        return num

###
# main
if(__name__ == '__main__'):
    # input
    a, b, c, d = map(int, input().split(" "))

    num_t = c // b
    if c % b != 0:
        num_t += 1
    
    num_a = a // d
    if a % d != 0:
        num_a += 1
    
    if num_t <= num_a:
        print("Yes")
    else:
        print("No")
    
# else:
    # do nothing

Measured memory_bytes: 9144
#include<iostream>
#include<algorithm>
#include<math.h>
#include<set>
#include<vector>
#include<map>
#include <numeric>
typedef long l;
typedef long long ll;
using namespace std;
int main(){
int a,b,c;
cin>>a>>b>>c;
cout<<(a+b)*c/2<<endl;
}

Measured memory_bytes: 256
def check(b, i, j, x, y):
 if i < 0 or j < 0 or i == x or j == y:
  return 0
 if b[i][j] == "#":
  return 1
 return 0

bounds = raw_input().split(" ")
x = int(bounds[0])
y = int(bounds[1])
board = [None] * x
for i in range(0, x):
 k = raw_input()
 board[i] = [None] * y
 for j in range(0, y):
  board[i][j] = k[j]

for i in range(0, x):
 for j in range(0, y):
  if board[i][j] == ".":
   p = 0
   p += check(board, i-1, j-1, x, y)
   p += check(board, i-1, j  , x, y)
   p += check(board, i-1, j+1, x, y)
   p += check(board, i  , j-1, x, y)
   p += check(board, i  , j+1, x, y)
   p += check(board, i+1, j-1, x, y)
   p += check(board, i+1, j  , x, y)
   p += check(board, i+1, j+1, x, y)
   board[i][j] = p
 z = ""
 for j in range(0, y):
  z += str(board[i][j])
 print(z)

Measured memory_bytes: 2696
#include <vector>
#include <iostream>
int main() {
	std::vector<int> v(150000, 0);
	v[0] = v[1] = 1;
	v[2] = 0;
	for (int i = 2; i < 150000; i++) {
		if (v[i] == 0) {
			for (int j = i * 2; j < 150000; j += i) {
				v[j] = 1;
			}
		}
	}
	int X;
	
	std::cin >> X;
	for (int i = X; i < 150000; i++) {
		if (v[i] == 0) {
			std::cout << i << std::endl;
			return 0;
		}
	}
	return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
#define oo 0x3f3f3f3f
#define ooLL 0x3f3f3f3f3f3f3f3f
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define fastio() ios_base::sync_with_stdio(false); cin.tie(NULL)
const int mod = 1e9+7;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<pair<int,int>> vii;
typedef pair<int,int> pii;
 
int main(){
    int k, a, b;
    scanf("%d%d%d", &k, &a, &b);
    bool ok = false;
    for(int i = a; i <= b ; ++i) if(i % k == 0) ok = true;
    if(ok) printf("OK\n");
    else printf("NG\n");
    return 0;
}

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

int main(){
    int s, w;
    cin >> s >> w;
    if (s > w) cout << "safe" << endl;
    else cout << "unsafe" << endl;
    return 0;
}


Measured memory_bytes: 3636
import sys
input = sys.stdin.readline

N, T = map(int, input().split())
vw = [[int(i) for i in input().split()] for _ in range(N)]
vw.sort()

M = [0] * N
for i in range(N - 1, -1, -1) :
    M[i] = max(M[i], vw[i][1])
        
dp = [-float('inf')] * T
dp[0] = 0
ret = 0

for n, (w, v) in enumerate(vw) :
    for i in range(T-1, w-1, -1) :
        dp[i] = max(dp[i], dp[i-w]+v)
    
    if n + 1 < N :
        ret = max(ret, max(dp) + M[n + 1])
    else :
        ret = max(ret, max(dp))
    
print(ret)

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

map<int, int> solve(int n) {
  map<int, int> res;
  for (int i=2; i*i<=n; i++) {
    while (n%i==0) {
      ++res[i];
      n/=i;
    }
  }
  if (n!=1) res[n]=1;
  return res;
}

int main() {
  int n; cin>>n;
  map<int, int> A=solve(n);
  cout<<n<<":";
  for (auto itr=A.begin(); itr!=A.end(); itr++) {
    cout<<" ";
    int loop=(itr->second);
    rep(i, loop) {
      if (i) cout<<" ";
      cout<<(itr->first);
    }
  }
  cout<<endl;
}



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

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define ALL(v) (v).begin(), (v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x, n) bitset<n>(x)
#define PI 3.14159265358979323846
 
typedef long long ll;
typedef pair< int, int > P;   
typedef pair< ll, P > PP;

//-----------------------------------------------------------------------------

ll n;
const int MAX_N = 1000010;
const int MOD = 1e9 + 7;
ll fact[MAX_N], inv_fact[MAX_N];

ll mypow(ll a, int b) {
	ll res = 1;
	while (b > 0) {
		if (b & 1) (res *= a) %= MOD;
		(a *= a) %= MOD;
		b >>= 1;
	}
	return res;
}

void prv_calc() {
	fact[0] = 1;
	FOR(i, 1, MAX_N) fact[i] = fact[i - 1] * i % MOD;
	inv_fact[MAX_N - 1] = mypow(fact[MAX_N - 1], MOD - 2);
	RREP(i, MAX_N - 1) inv_fact[i] = (inv_fact[i + 1] * (i + 1)) % MOD;
}

ll comb(ll N, ll R) {
	if (R < 0 || N < R) return 0;
	return fact[N] * inv_fact[R] % MOD * inv_fact[N - R] % MOD;
}

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

	prv_calc();

	cin >> n;
	ll ans = 0, prv = 0, cur = 0;
	FOR(i, (n + 1) / 2, n) {
		cur = comb(i - 1, n - i - 1) * fact[i] % MOD * fact[n - i - 1] % MOD;
		(ans += (cur - prv + MOD) % MOD * i % MOD) %= MOD;
		prv = cur;
	}
	cout << ans << endl;

    return 0;
}


Measured memory_bytes: 15872
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)

using namespace std;

int main(){

	int x,y,s;

	while(1){
		cin>>x>>y>>s;
		if(x==0 && y==0 && s==0) break;
		int ans = -1;
		for(int i=1; i<1000; i++){
			for(int j=1; j<1000; j++){
				if((i*(100+x))/100 + (j*(100+x))/100 != s) continue;
				ans = max(ans , (i*(100+y))/100 + (j*(100+y)/100));
			}
		}
		cout<<ans<<endl;
	}

	return 0;
}

Measured memory_bytes: 3016
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.Runtime.InteropServices;
using System.Text;

namespace AtCoder.ABC
{
    class QuestionA
    {
        public static void Main(string[] args)
        {
            var xkd = Console.ReadLine().Split(" ").Select(x => long.Parse(x)).ToArray();
            var x = xkd[0];
            var k = xkd[1];
            var d = xkd[2];

            var absX = new BigInteger(Math.Abs(x));

            var K = new BigInteger(k);
            var D = new BigInteger(d);

            if(K * D <= absX) {
                Console.WriteLine(absX - (K * D));
                return;
			}

            var s = absX / D;

            if(K % 2 == 0) {
                if(s % 2 != 0) {
                    s--;
				}
			} else {
                if (s % 2 != 1) {
                    s++;
                }
            }

            var q = absX % D;

            var maxPlus = absX - (s * D);

            if(maxPlus < 0) {
                maxPlus *= -1;
			}

            var maxMinus = maxPlus - D - D;

            if(maxMinus < 0) {
                maxMinus *= -1;
			}

            if(s + 2 > K) {
                maxMinus = maxPlus;
			}

            if(maxPlus < maxMinus) {
                Console.WriteLine(maxPlus);
			} else {
                Console.WriteLine(maxMinus);
            }
        }
    }
}



Measured memory_bytes: 28504
#include<stdio.h>

int n, h[100001], i, x = 0;

int main()
{
	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		scanf("%d", &h[i]);
		if (i > 0 && h[i] > h[i - 1]) {
			h[i]--;
		}
		if (h[i] < h[i - 1]) {
			x++;
		}
	}
	if (x == 0) {
		printf("Yes\n");
	}
	else {
		printf("No\n");
	}

	return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
int n,A[501][501];
int s(int a,int b,int c){
    if(a==b) return 0;
    if(a+1==b){
        A[a][b]=c;
        return 0;
    }
    int d=(a+b)/2;
    for(int i=a;i<=d;i++)for(int j=d+1;j<=b;j++) A[i][j]=c;
    s(a,d,c+1);
    s(d+1,b,c+1);
}
int main(){
    cin>>n;
    s(1,n,1);
    for(int i=1;i<=n;i++){for(int j=i+1;j<=n;j++) cout<<A[i][j]<<" ";cout<<endl;}
}

Measured memory_bytes: 1408
#include<iostream>
#include<cstdio>
#include<stack>
#include<queue>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<vector>
#include<math.h>
#include<tuple>
#include<string.h>
#include <numeric> 
#include<unordered_map>
using namespace std; 
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define pp(...) "\033[94m [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "]\033[0m"
#define pp1(...) "\033[1;47;35m" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "]\033[0m"
#define dg(x) debug() << pp1(x)
#define dg1(x) debug() << pp(x)
#define dg2(x,y) debug() << pp(x) pp(y)
#define dg3(x,y,z) debug() << pp(x) pp(y) pp(z)
#define dg4(w,x,y,z) debug() << pp(w) pp(x) pp(y) pp(z)
#define int long long
#define all(x) x.begin() , x.end()
#define clr(x) memset(x , 0 , sizeof x);
#define sz(x) (int)x.size()
template<typename T> void db(T x ){ debug() <<">>> " <<  x; }
template<typename T> void db(T x , T y){ debug() <<">>> " <<  x <<" , "<< y; }
template<typename T> void db(T x , T y , T z){ debug() <<">>> "<< x <<" , "<< y <<" , "<< z; }
template<typename T> void db(T x , T y , T z , T a){ debug() <<">>> "<< x <<" , " << y <<" , "<< z <<" , "<< a; }
const int xx = 2e5;
const int Mod = 1e9 + 7;
const int inf = 1e18;
const int Maxn = 20010;

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

  int N;
  cin >> N;
  priority_queue<int> a , cur;
  for(int i = 0; i < N; i++) {
    int x;
    cin >> x;
    a.push(x);
  }

  int x = a.top();
  a.pop();
  int y = a.top();
  a.pop();
  int ans = x;
  cur.push(y);
  while(!a.empty()) {
    int T = cur.top();
    cur.pop();
    if(a.size() >= 2) {
      int p1 = a.top(); a.pop();
      int p2 = a.top(); a.pop();
      ans += 2 * T ;
      cur.push(p1);
      cur.push(p2);
    }
    else {
      ans += T;
      break;
    }
  }
  cout << ans << '\n';
}

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

#define pb push_back
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define ll long long
#define ii pair<int,int>
#define vi vector<int>
#define vll vector<ll>
#define vii vector<ii>

using namespace std;

const int maxn = 1e5+10;
const int INF = 1e9+10;

vi g[maxn];
int du[maxn],dv[maxn];
map<int,vi> mp1,mp2;

void bfs(int u,int v){
	for(int i=0;i<maxn;++i){
		du[i]=dv[i]=INF;
	}
	du[u]=0;
	dv[v]=0;
	queue<int> q;
	q.push(u);
	while(!q.empty()){
		int x=q.front();
		q.pop();
		for(auto &w:g[x]){
			if(du[x]+1 < du[w]){
				du[w] = du[x]+1;
				mp1[du[x]+1].pb(w);
				q.push(w);
			}
		}
	}
	q.push(v);
	while(!q.empty()){
		int x=q.front();
		q.pop();
		for(auto &w:g[x]){
			if(dv[x]+1 < dv[w]){
				dv[w] = dv[x]+1;
				mp2[dv[x]+1].pb(w);
				q.push(w);
			}
		}
	}
}

int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	//#ifndef ONLINE_JUDGE
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	//#endif
	int n,u,v;
	cin>>n>>u>>v;
	for(int i=1;i<n;++i){
		int a,b;
		cin>>a>>b;
		g[a].pb(b);
		g[b].pb(a);
	}
	for(int i=1;i<=n;++i){
		sort(all(g[i]));
	}
	bfs(u,v);
	int ans=0;
	for(int i=1;i<=n;++i){
		if(du[i]<=dv[i]){
			ans=max(ans,dv[i]);
		}
	}
	cout<<ans-1<<endl;
	return 0;
}

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

int main() {
  int h, w;
  cin >> h >> w;

  vector<vector<char>> board(h, vector<char> (w));
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      cin >> board[i][j];
    }
  }

  vector<vector<int>> visited(h, vector<int> (w, 0));
  int dx[4] = {1,-1,0,0};
  int dy[4] = {0,0,1,-1};

  ll ans = 0;
  queue<pair<int,int>> que;
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if(visited[i][j] || board[i][j] == '.') continue;
      que.emplace(i, j);
      visited[i][j] = 1;
      ll cnt_blk = 1;
      ll cnt_wht = 0;
      while(!que.empty()) {
        int curx = que.front().first;
        int cury = que.front().second;
        que.pop();

        for (int k = 0; k < 4; k++) {
          int nx = curx + dx[k];
          int ny = cury + dy[k];

          if(nx < h && nx >= 0 && ny < w && ny >= 0 &&
             board[curx][cury] != board[nx][ny] && !visited[nx][ny]) {
            que.emplace(nx, ny);
            visited[nx][ny] = 1;
            if(board[nx][ny] == '#') cnt_blk++;
            else cnt_wht++;
          }
        }
      }
      ans += cnt_blk * cnt_wht;
    }
  }
  cout << ans << '\n';
}

Measured memory_bytes: 1152
import std.stdio;
import std.c.stdio;
import std.algorithm;
import std.string;
import std.functional;
import std.array;
import std.conv;
import std.math;
import std.typecons;
import std.regex;
import std.range;

void main(){

    int[] tn;
    double[] tt;
    for(int i=0;i<3;i++){
	double[] time;
	int[] num;
	for(int j=0;j<8;j++){
	    auto s = readln().split();
	    time ~= to!double(s[1]);
	    num ~= to!int(s[0]);
	}
	sort(zip(time,num));
	printf("%d %.2f\n",num[0],time[0]);
	printf("%d %.2f\n",num[1],time[1]);
	tn ~= num[2];
	tt ~= time[2];
    }
    sort(zip(tt,tn));
    printf("%d %.2f\n",tn[0],tt[0]);
    printf("%d %.2f\n",tn[1],tt[1]);
}

Measured memory_bytes: 2520
#include <bits/stdc++.h>
using namespace std ;
#define ll long long
int d()
{
    int t ;
    scanf( "%d", &t ) ;
    return t ;
}
ll lld()
{
    ll t ;
    scanf( "%lld", &t ) ;
    return t ;
}
const long long N = 1e6,OO=0x3f3f3f3f;

ll arr[103],n,k;
ll v[103];
ll dp[102][N];
ll solve(int i,int sum){
    if(i==n)
        return 0;
    if(dp[i][sum]!=-1)return dp[i][sum];

    ll choice1=-1;
    if(arr[i]+sum<=k)
    choice1=v[i]+solve(i+1,sum+arr[i]);
    ll choice2=solve(i+1,sum);
    return dp[i][sum]=max(choice1,choice2);
}
int main()
{
     n=lld();k=lld();
    for(int i=0;i<n;i++)
        scanf("%lld %lld",arr+i,v+i);
    memset(dp,-1,sizeof dp);
    cout<<solve(0,0);
}


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

using namespace std;
using ll=long long;
using ld=long double;
using P=pair<ll,ll>;
#define FOR(i,n,m) for(ll i=n; i<(ll)m;i++)
#define FORr(i,n,m) for(ll i=n; i>(ll)m; i--)
#define FORm(i,m) for(auto i=m.begin();i!=m.end();i++)
#define VEC2(x,a,b) vector<vector<ll>> x = vector<vector<ll>>(a,vector<ll>(b,0))
#define sortAl(v) sort(v.begin(),v.end())
#define sortAlr(v) sort(v.begin(),v.end()); reverse(v.begin(),v.end())
#define cinv(v,n,m) FOR(i,n,m) cin>>v.at(i)
#define coutv(v,n,m) FOR(i,n,m) cout<<v.at(i) <<" "; cout<<end
#define cout(n) cout<<fixed<<setprecision(n)
int main(){
  ll N,K;
  cin>>N>>K;
  vector<ll> v(N);
  vector<ll> key;
  cinv(v,0,N);
  sortAl(v);
  ll inst=-1;
  FOR(i,1,N){
    if(v[i]!=v[i-1]){
      key.push_back(i-1-inst);
      inst=i-1;
    }
  }
  key.push_back(N-1-inst);
  sortAlr(key);
  ll res=0;
  FOR(i,K,key.size()){
    res+=key[i];
  }
  cout<<res<<endl;
}


Measured memory_bytes: 3956
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n-1; i >= 0; i--)
#define ALL(x) x.begin(),x.end()
using ll = long long;
using pll = pair<ll, ll>;
using pii = pair<int, int>;
using vl = vector<ll>;
using vi = vector<int>;
const ll INF = 1e18;
const ll mod = 1e9+7;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

ll f[101001];

ll power(int m, int n) { // m^n（繰り返し自乗法）
    if (n == 0) return 1;
    if (n % 2 == 1) return power(m, n-1) * m % mod;
    ll r = power(m, n/2);
    return r * r % mod;
}


ll inv(ll a, ll b) { // 逆元を利用してa/bのmodを返す
    return a * power(b, mod-2) % mod;
}

ll fact(int n) { // 階乗
    if (f[n] != 0) return f[n];
    if (n == 0) return f[n] = 1;
    return f[n] = n * fact(n-1) % mod;
}


ll perm(int n, int r) { // nPr
    if (n < r) return 0;
    return inv(f[n], f[n-r]);
}


ll comb(int n, int r) { // nCr
    if (n < r) return 0;
    return inv(perm(n, r), f[r]);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    fact(101000);
    ll r = 1;
    for (int i = 2; i <= m; i++) {
        int cnt = 0;
        if (m % i == 0) {
            while (m % i == 0) {
                m /= i;
                cnt++;
            }
            // cout << cnt << "\n";
            r *= comb(cnt+n-1, cnt);
            r %= mod;
        }
    }
    cout << r << "\n";
}

Measured memory_bytes: 7544
a, b = map(int, input().split())
even_a = a%2 == 0
even_b = b%2 == 0
if even_a and even_b:
    print((((b - a)//2)%2)^b)
elif even_a:
    print(((b+1 - a)//2)%2)
elif even_b:
    print((((b - (a+1))//2)%2)^a^b)
else:
    print((((b - a)//2)%2)^a)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
using namespace std;
typedef long long ll;

int main()
{
  int N;
  int a[110000];
  bool res=false;
  cin >> N;

  rep(i,N) cin >> a[i];

  int odd=0;
  int mul4=0;
  rep(i,N){
    if(a[i]%2==1) odd++;
    if(a[i]%4==0) mul4++;
  }

  if(mul4 >= odd) res=true;
  else if(N == mul4 + odd && mul4+1==odd) res=true;

  if(res) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define maxn 200010
using namespace std;
int n, fac[maxn], inv[maxn];
int C(int n, int m) {return (ll)fac[n] * inv[m] % mod * inv[n - m] % mod;}
int calc(int a, int k)
{
	int ans = 1;
	while (k)
	{
		if (k % 2) ans = (ll)ans * a % mod;
		a = (ll)a * a % mod;
		k /= 2;
	}
	return ans;
}
int main()
{
	int res = 0, a, b, c, p1, p2;
	cin >> n >> a >> b >> c;
	fac[0] = 1;
	for (int i = 1; i <= 2 * n; i++)
		fac[i] = (ll)fac[i - 1] * i % mod;
	inv[2 * n] = calc(fac[2 * n], mod - 2);
	for (int i = 2 * n - 1; i >= 0; i--)
		inv[i] = inv[i + 1] * ((ll)i + 1) % mod;
	a = (ll)a * calc(100, mod - 2) % mod;
	b = (ll)b * calc(100, mod - 2) % mod;
	p1 = (ll)a * calc((a + b) % mod, mod - 2) % mod;
	p2 = (1 - p1 + mod) % mod;
	for (int i = 0; i <= n - 1; i++)
	{
		int gl = (ll)calc(p2, i) * calc(p1, n) % mod * C(i + n - 1, i) % mod;
		res = (res + gl * ((ll)n + i) % mod) % mod;
	}
	for (int i = 0; i <= n - 1; i++)
	{
		int gl = (ll)calc(p1, i) * calc(p2, n) % mod * C(i + n - 1, i) % mod;
		res = (res + gl * ((ll)n + i) % mod) % mod;
	}
	res = (ll)res * calc((a + b) % mod, mod - 2) % mod;
	cout << res << endl;
	return 0;
}

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

int main()
{
    int N, Y;
    std::cin >> N >> Y;
    bool isFound = false;

    int a, b;
    for (a = 0; a <= N; a++){
        for (b = 0; b <= N - a; b++){
            if(Y == 10000 * a + 5000 * b + 1000 * (N - a - b)){
                isFound = true;
                break;
            }
        }

        if (isFound){ break; }
    }

    if (isFound){
        std::cout << a << " " << b << " " << N - a - b << std::endl;
    } else {
        std::cout << "-1 -1 -1" << std::endl;
    }
    return 0;
}

Measured memory_bytes: 256
(defun in (Ti=1 Ci hd.tl)
  (let ((hd (car hd.tl))
        (tl (cdr hd.tl)))
       (if Ti=1
           (push Ci hd)
           (progn 
             (rplacd (cdr hd.tl) (list Ci))
             (setf tl (cdr tl))))
       (cons hd tl) ))

(let ((hd (concatenate 'list (read-line))))
     (defvar hd.tl (cons hd (last hd))))
(defvar Q (read))
(defvar rev nil)

(loop repeat Q do
      (if (= (read) 1)
          (setf rev (not rev))
          (setf hd.tl 
                (in (eq rev (= (read) 2))
                    (read-char) hd.tl))))

(mapc #'princ (if rev 
                  (nreverse (car hd.tl))
                  (car hd.tl) ))

Measured memory_bytes: 62120
#include <bits/stdc++.h>
using namespace std;
int main() {
    int x, y, d30 = 0, d31 = 0, d29 = 0;
    cin >> x >> y;
    if (x == 2) d29++;
    else if (x == 4 || x == 6 || x == 9 || x == 11) d30++;
    else d31++;
    if (y == 2) d29++;
    else if (y == 4 || y == 6 || y == 9 || y == 11) d30++;
    else d31++;
    if (d30 == 2 || d31 == 2) cout << "Yes";
    else cout << "No";
}

Measured memory_bytes: 3588
#include <stdio.h>

int main(){

  int A = 0, B = 0, C = 0;

  scanf("%d %d %d", &A, &B, &C);

  int res = C - ( A - B );

  if( res < 0 ){
    printf("0");
  }
  else if( res >= 0 ){
    printf("%d", res);
  }

  return 0;

}


Measured memory_bytes: 128
fn read_multi<T: std::str::FromStr>() -> Vec<T> {
    let mut s = std::string::String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}

fn main() {
    let vn: Vec<i32> = read_multi(); //i32
    //println!("{:?}", vn);

    let mut res: String = ":(".to_string();
    //println!("{:?}", res);

    if vn[0] <= 8 && vn[1] <= 8 {
        res = "Yay!".to_string();
    }
    println!("{}", res);
}


Measured memory_bytes: 2108
from sys import exit, stdin
A = [list(map(int, stdin.readline().rstrip().split())) for _ in range(3)]
bin_A = [[0]*3 for _ in range(3)]
N = int(stdin.readline().rstrip())
B = [int(stdin.readline().rstrip()) for _ in range(N)]
for i in range(N):
    for j in range(3):
        for k in range(3): 
            if A[j][k] == B[i]:
                bin_A[j][k] = 1
ans = 'No'
for i in range(3):
    if bin_A[i][0] + bin_A[i][1] + bin_A[i][2] == 3:
        ans = 'Yes'
for j in range(3):
    if bin_A[0][j] + bin_A[1][j] + bin_A[2][j] == 3:
        ans = 'Yes'
if bin_A[0][0] + bin_A[1][1] + bin_A[2][2] == 3:
    ans = 'Yes'
if bin_A[0][2] + bin_A[1][1] + bin_A[2][0] == 3:
    ans = 'Yes'
print(ans)

Measured memory_bytes: 3064
object Main extends App {
  import collection.mutable.PriorityQueue
  val sc = new java.util.Scanner(System.in)
  val N = sc.nextInt
  val As = Array.fill(3*N)(sc.nextLong)

  def f(xs: Array[Long], ys: Array[Long]): Array[Long] = {
    val pq = new PriorityQueue[Long]()(Ordering.Long.reverse) ++ xs
    ys.scanLeft(pq.sum) { (s, y) =>
      pq += y
      s + y - pq.dequeue}
  }

  val List(as1, as2, as3) = As.grouped(N).toList
  val ans = f(as1, as2).zip(f(as3.map(a => -a), as2.map(a => -a).reverse).reverse).map(t => t._1 + t._2).max
  println(ans)
}

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

//int _; 

int n,m,a[100020],sum=0;
bool ans[100020];

int main()
{
	//for(scanf("%d",&_);_;_--)
	cin >> n >> m;
	for(int i=0;i<n;i++)
	{
		cin >> a[i];
		ans[i]=true;
	}
	for(int i=0;i<m;i++)
	{
		int b,c;
		cin >> b >> c;
		b--;
		c--;
		if(a[b] >= a[c])
			ans[c]=false;
		if(a[c] >= a[b])
			ans[b]=false; 
	}
	for(int i=0;i<n;i++)
		if(ans[i])
			sum++;
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 4164
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <climits>
#include <iomanip>

using namespace std;

#define FAST       			ios_base :: sync_with_stdio(false); cin.tie(NULL); 
#define endl "\n"

typedef long long int  ll;


int main()
{
	FAST;
	int w,a,b;
	cin >> w >> a >> b;
	
	if(b < a)
	{
		int ans = a-b-w;
		if(ans < 0)
			ans = 0;
		cout << abs(ans);
	}
	else
	{
		int ans = b-a-w;
		if(ans < 0)
			ans = 0;
		cout << abs(ans);
	}

	return 0;
}

Measured memory_bytes: 256
X, N = map(int, input().split())
if N > 0:
    P = list(map(int, input().split()))
    res = float('Inf')
    A = [0]*101
    for n in range(N):
        A[P[n]-1] += 1
    cnt = 1
    man = float('Inf')
    for a in A:
        if a == 0:
            total = abs(X - cnt)
            if res > total:
                res = total
                man = cnt
        cnt += 1
    if abs(X - 0) <= res:
        man = 0
    print(man)
else:
    print(X)

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

typedef long long ll;
const int MAX_N = 100000;

int main() {
  int n;
  ll a[MAX_N];

  std::cin >> n;
  for(int i = 0; i < n; ++i) {
    std::cin >> a[i];
  }
  std::sort(a, a + n);

  std::cout << a[n - 1] << " ";
  ll dif = 1LL << 62, ans;
  double c = a[n - 1] / 2.0;
  for(int i = 0; i < n - 1; ++i) {
    if(std::abs(a[i] - c) < dif) {
      ans = a[i];
      dif = std::abs(ans - c);
    }
  }
  std::cout << ans << std::endl;
}


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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main()
{
  int N, M;
  cin >> N >> M;
  vector<P> p;
  REP(i, N)
  {
    int A, B;
    cin >> A >> B;
    p.push_back(make_pair(A, B));
  }
  sort(ALL(p));
  long ans = 0;
  REP(i, N)
  {
    int buy = min(M, (int)p[i].second);
    M -= buy;
    ans += buy * p[i].first;
    if (M == 0)
      break;
  }
  cout << ans << endl;
  return 0;
}

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

using namespace std;

int a[100000];

int main(){
	int n;
	scanf("%d",&n);
	a[0]=0;
	a[n+1]=0;
	int sum=0;
	for(int i=1;i<=n;i++)
	scanf("%d",&a[i]);
	for(int i=1;i<=n+1;i++)
	{
		sum+=abs(a[i]-a[i-1]);
	}
	
	for(int i=1;i<=n;i++)
	{
		int ans=sum;
		if(a[i-1]<=a[i] && a[i]<=a[i+1]);
		else if(a[i-1]>=a[i] && a[i]>=a[i+1]);
		else {
			ans-=abs(a[i-1]-a[i]);
			ans-=abs(a[i]-a[i+1]);
			ans+=abs(a[i-1]-a[i+1]);
		}
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 1664
#include<iostream>
using namespace std;
int main(){
    int A,B,C,K;
    cin >> A >> B >> C >> K;
    int k = 0;
    while(A>=B){
        if(k==K) break;
        B = B * 2;
        k++;
    }
    while(B>=C){
        if(k==K) break;
        C = C * 2;
        k++;
    }
    if(A<B&&B<C){
        cout << "Yes";
    }
    else{
        cout << "No";
    }
}

Measured memory_bytes: 3628
import sys

class BIT:
	'''NOTES: 1-origin-indexed
	'''
	def __init__(self, itemCount):
		self.itemCount = itemCount
		self.items = [0 for i in range(itemCount+1)]

	def add(self, i, value):
		while i <= self.itemCount:
			self.items[i] += value
			i += (i & (-i))

	def sumFromStart(self, end):
		summary = 0
		i = end
		while i > 0:
			summary += self.items[i]
			i -= (i & (-i))
		return summary

	def sum(self, start,end):
		summary = self.sumFromStart(end) - self.sumFromStart(start-1)
		return summary

def input(): return sys.stdin.readline()

N,Q = map(int,input().split())

C=list(map(int,input().split()))

# Query取得-rightでソート
# dtypeQuery = [("index", int), ("start", int), ("end", int)]
queries=[[0,0,0] for _ in range(Q)]
# #rights=[[] for _ in range(N+1)]

for q in range(Q):
	l,r=map(int,input().split())
	#queries[q] = (q,l,r)
	queries[q][0] = q
	queries[q][1] = l
	queries[q][2] = r
	#queries=np.sort(queries,order="end")

#queries=np.array(sys.stdin.buffer.read().split(),int).reshape(Q,2)

queries.sort(key=lambda x: x[2])
# print(queries)
#orderByR=np.argsort(queries[:,1])

# 答え配列
ans=[0]*Q
# 各色の現在の一番右のindex
mostRightColorIndex = [0]*(N+1)
# bit indexed tree
bitree=BIT(N)
# 左からBITと現在色の更新をしながら、クエリのrightに到達したときにBITにクエリ発行する
qindex = 0
for n in range(N):
	# 外側のループでは、全部の色をループ

	if Q <= qindex:
		break

	if 0 < mostRightColorIndex[C[n]]:
		# ループ中の場所の色のindexが既にある場合(=過去に、同じ色が登録されていた場合)
		# 今回で、同じ色の一番右側の要素はループ中の要素になる
		# 前登録したこの色の一番右のindexを一度BITから抜く(↓で再度登録される)
		bitree.add(mostRightColorIndex[C[n]], -1 )

	# この要素の色の一番右のindexを、BITに登録
	mostRightColorIndex[C[n]] = n+1
	bitree.add(n+1, 1)

	# while qindex < Q and n+1 == queries[qindex][2]:
	while qindex < Q and n+1 == queries[qindex][2]:
		# 今のBITが次のクエリ発行するための状態(n==query.right)だったら、クエリ発行
		tmpIndex = queries[qindex][0] #sortByR[qindex
		start = queries[qindex][1]
		end = queries[qindex][2]
		ans[tmpIndex]=bitree.sum(start,end)
		# print(tmpIndex,start,end,ans[tmpIndex])
		qindex += 1


for q in range(Q):
	print(ans[q])


Measured memory_bytes: 220748
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace __gnu_pbds;
using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef pair <ll, ll> pll;
typedef pair <int, int> pii;

typedef tree <ll, null_type, less <ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// order_of_key(val): returns the number of values less than val
// find_by_order(k): returns an iterator to the kth largest element (0-based)

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(a) a.begin(), a.end()
#define sz(a) (ll)(a.size())
#define endl "\n"

template <class Ch, class Tr, class Container>
basic_ostream <Ch, Tr> & operator << (basic_ostream <Ch, Tr> & os, Container const& x) 
{
    os << "{ ";
    for(auto& y : x) 
    {
        os << y << " ";
    }
    return os << "}";
}

template <class X, class Y>
ostream & operator << (ostream & os, pair <X, Y> const& p) 
{
    return os << "[" << p.ff << ", " << p.ss << "]";
}

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

    return gcd(b, a%b);
}

ll modexp(ll a, ll b, ll c)
{   
    a%=c;

    ll ans = 1;

    while(b)
    {
        if(b&1)
        {
            ans = (ans*a)%c;
        }

        a = (a*a)%c;
        b >>= 1;
    }

    return ans;
}

const ll L = 1e5+5;

ll lcm(ll a, ll b)
{
    return ((a/gcd(a, b))*b);
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);

    ll a, b;
    cin >> a >> b;

    cout << lcm(a, b) << endl;

    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>

using namespace std;

int main() {
  int t[26] = {0};
  string l;
  while (getline(cin, l)) {
    for (size_t i = 0; i < l.size(); ++i) {
      const char c = l[i];
      if (c >= 'a' && c <= 'z') {
        t[c - 0x61] += 1;
      } else if (c >= 'A' && c <= 'Z') {
        t[c + 0x20 - 0x61] += 1;
      }
    }
  }

  for (int i = 0; i < 26; ++i) {
    printf("%c : %d\n", i + 0x61, t[i]);
  }
  return 0;
}

Measured memory_bytes: 1188
#include <iostream>
#include <vector>
    using namespace std;
    int main(){
      int n; cin >> n;
      vector<int> p;
      for(int i=0; i<n; i++){
        int c; cin >> c;
        p.push_back(c);
      }
      int cnt = 0;
      for(int i=1; i<n-1; i++){
        if((p[i-1] < p[i] && p[i] < p[i+1]) || (p[i-1] > p[i] && p[i] > p[i+1])) cnt++;
      }
      cout << cnt << endl;
      return 0;
    }

Measured memory_bytes: 256