akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(x) (x).begin(),(x).end()
template <class T> inline bool chmin(T &a, T b) {if (a > b){a = b;return true;}return false;}
template <class T> inline bool chmax(T &a, T b) {if (a < b){a = b;return true;}return false;}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int w,h,n; cin>>w>>h>>n;
    int to, bo, le, ri;
    to = h, le=0, bo=0, ri=w;
    rep(i,n){
        int x,y,a;cin>>x>>y>>a;
        if(a==1){
            le=max(le, x);
            if(le>=ri){
                cout<<0<<endl;
                return 0;
            }
        }else if(a==2){
            ri=min(ri, x);
            if(le>=ri){
                cout<<0<<endl;
                return 0;
            }
        }else if(a==3){
            bo=max(bo, y);
            if(bo>=to){
                cout<<0<<endl;
                return 0;
            }
        }else{
            to=min(to, y);
            if(bo>=to){
                cout<<0<<endl;
                return 0;
            }
        }
    }
    cout<<max(((ri-le)*(to-bo)), 0)<<endl;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**6) #再帰関数の上限
import math
from copy import copy, deepcopy
from operator import itemgetter

from bisect import bisect_left, bisect, bisect_right#2分探索
#bisect_left(l,x), bisect(l,x)#aはソート済みである必要あり。aの中からx未満の要素数を返す。rightだと以下
from collections import deque 
#deque(l), pop(), append(x), popleft(), appendleft(x)
##listでqueの代用をするとO(N)の計算量がかかってしまうので注意
#dequeを使うときはpython3を使う、pypyはダメ
from collections import Counter#文字列を個数カウント辞書に、
#S=Counter(l),S.most_common(x),S.keys(),S.values(),S.items()
from itertools import accumulate#累積和
#list(accumulate(l))
from heapq import heapify,heappop,heappush
#heapify(q),heappush(q,a),heappop(q) #q=heapify(q)としないこと、返り値はNone

def input(): return sys.stdin.readline()[:-1]
def printl(li): print(*li, sep="\n")
def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds

#mod = 10**9+7
#w.sort(key=itemgetter(1),reversed=True)  #二個目の要素で降順並び替え

X = int(input())
#N, K = map(int, input().split())
#L = [int(input()) for i in range(N)]
#A = list(map(int, input().split()))
#S = [list(map(int, input().split())) for i in range(N)]


for A in range(-120,120):
    for B in range(-120,120):
        if A**5-B**5==X: 
            print(A,B)
            exit()
    

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

#define ld long double
#define ll long long
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define MP make_pair
#define test cout<<"test"<<endl;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ll INF = 1e18;
const ll zero=0;
void chmin(ll &a,ll b){if(a>b)a=b;}
void chmax(ll &a,ll b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void pmod(ll &a,ll b,ll c){a=(b+c)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void qmod(ll &a,ll b,ll c){a=(b*c)%MOD;}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
void ans(bool x,ll y,ll z){if(x)cout<<y<<endl;else cout<<z<<endl;}
void ans(bool x,string y,string z){if(x)cout<<y<<endl;else cout<<z<<endl;}   
ll gcd(ll x,ll y){ll r;while((r=x%y)!=0){x=y;y=r;}return y;}

int main(){
  ll i,j,o;
  ll res=0,res1=INF,res2=-INF,buf=0,buf1=0,buf2=0,buf3=0,buf4=0,sum=0;
  bool judge = true;
  ll n,k;cin>>n>>k;
  if(k>(n-1)*(n-2)/2)cout<<-1<<endl;
  else{
    cout<<n*(n-1)/2-k<<endl;
    for(i=2;i<=n;i++)cout<<1 spa i<<endl;
    buf=k;
    for(i=2;i<=n-1;i++){
      for(j=i+1;j<=n;j++){
        if(buf>0)buf--;
        else cout<<i spa j<<endl;
      }
    } 
  }
  return 0;
}

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

int x, y, z, w;
vector<long long> a, b, c, v;
vector<int> u;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> x >> y >> z >> w;
	a.resize(x); b.resize(y); c.resize(z);
	for(auto &i:a) cin >> i;
	for(auto &i:b) cin >> i;
	for(auto &i:c) cin >> i;
	for(auto &i:b) for(auto &j:c) v.push_back(i+j);
	v.push_back(-1e18);
	sort(v.rbegin(), v.rend());
	u.resize(x, 0);
	for(int i=0; i<w; ++i){
		long long p = 0, q = a[0] + v[u[0]];
		for(int j=1; j<x; ++j){
			if(q < a[j] + v[u[j]]){
				p = j;
				q = a[j] + v[u[j]];
			}
		}
		cout << q << "\n";
		++u[p];
	}
}

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

int main() {
    int n;
    cin >> n;
    int mx = 0;
    int h;
    int a = 0;
    for (int i = 0; i < n; i++) {
        cin >> h;
        if (mx <= h) {
            a++;
            mx = h;
        }
    }
    cout << a << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define is_in(i, s) (s.find(i) != s.end())
#define all(x) (x).begin(),(x).end()
typedef long long ll;
typedef pair<int,int> P;

#define MAX_N 1000000005


int main() {
	ll a = 100;
	ll x;
	cin >> x;
	ll y=0;
	while(a<x){
		a = a*1.01;
		y++;
	}
	cout << y << endl;
    return 0;
}



Measured memory_bytes: 3592
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <numeric>
#include <sstream>
#include <iostream>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <cassert>
#include <cctype>
#include <cstdio>
#include <cassert>
using namespace std;

#define EPS 1e-12
#define ull unsigned long long
#define ll long long
#define VI vector<ll>
#define PII pair<ll, ll> 
#define VVI vector<vector<ll> >
#define VVVI vector<vector<vector<ll>>>
#define VVVVI vector<vector<vector<vector<ll>>>>
#define REP(i,n) for(ll i=0,_n=(n);(i)<(ll)_n;++i)
#define REPR(i,n) for(ll i=(ll)(n)-1;0<=(i);--i)
#define RANGE(i,a,b) for(ll i=(ll)a,_b=(ll)(b);(i)<_b;++i)
#define RANGER(i,a,b) for(ll i=(ll)(b)-1,_a=(ll)(a);(_a)<=i;--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define ALLR(c) (c).rbegin(), (c).rend()
#define PB push_back
#define MP(a, b) make_pair(a, b)
#define POPCOUNT __builtin_popcount
#define POPCOUNTLL __builtin_popcountll
#define CLEAR(table, v) memset(table, v, sizeof(table));
#define UNIFORM_DOUBLE(a, b) (((b-a)*(double)rand()/RAND_MAX)+a) // [a, b) 
#define UNIFORM_LL(a, b) (ll)UNIFORM_DOUBLE(a, b) // [a, b) 
#define IN(v, lo, hi) ((lo)<=(v) && (v)<(hi))
#define DD(v) cout<<#v<<": "<<v<<endl
#define FI first
#define SE second
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const map<T0, T1>& v) { for( typename map<T0, T1>::const_iterator p = v.begin(); p!=v.end(); p++ ){os << p->first << ": " << p->second << " ";} return os; }
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const pair<T0, T1>& v) { os << v.first << ": " << v.second << " "; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<T>& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << " "; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const set<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const deque<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<vector<T> >& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << endl; } return os; }
template<typename T>void maxUpdate(T& a, T b) {a = max(a, b);}
template<typename T>void minUpdate(T& a, T b) {a = min(a, b);}

#define MOD 1000000007LL
#define INF (1LL<<60)

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll N,A,B;
	while(cin>>N>>A>>B) {
		ll ans = 100000000;
		REP(i, N+1) {
			ll lans = i*A+(N-i>0?B:0);
			minUpdate(ans, lans);
		}
		
		cout<<ans<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 256
import itertools

N = int(input())

ans = 0
for d in range(3, 10):
    for p in itertools.product(["3", "5", "7"], repeat=d):
        s = "".join(p)
        if set(s) != {"3", "5", "7"}:
            continue
        if int(s) > N:
            break
        ans += 1
print(ans)

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


int main(){
    long long int N;
    long long int A,B;
    int sum=0;
    bool flag=true;
    string s;
    cin>>s;
    vector<int> a(N);
    map<int,int>ball;

    if(s.at(2)==s.at(3) && s.at(4)==s.at(5)){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }


}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <string>
#include <cctype>
#include <stack>
#include <queue>
#include <vector>
#include <cstdlib>
#include <list>
#define _USE_MATH_DEFINES
#include <math.h>

using namespace std;

int main() {

	int n;
	int F[44];
	cin >> n;

	F[0] = F[1] = 1;

	for (int i = 2; i <= n; i++)
		F[i] = F[i - 1] + F[i - 2];
	cout << F[n] << endl;

	return 0;
}

Measured memory_bytes: 3100
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;
int main()
{
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	printf("%d",b+min(c,a+b+1));
	return 0;
}

Measured memory_bytes: 256
class Dice(object):
    def __init__(self, s1, s2, s3, s4, s5, s6):
        self.s1 = s1
        self.s2 = s2
        self.s3 = s3
        self.s4 = s4
        self.s5 = s5
        self.s6 = s6
    def east(self):
        prev_s6 = self.s6
        self.s6 = self.s3
        self.s3 = self.s1
        self.s1 = self.s4
        self.s4 = prev_s6
    def west(self):
        prev_s6 = self.s6
        self.s6 = self.s4
        self.s4 = self.s1
        self.s1 = self.s3
        self.s3 = prev_s6
    def north(self):
        prev_s6 = self.s6
        self.s6 = self.s5
        self.s5 = self.s1
        self.s1 = self.s2
        self.s2 = prev_s6
    def south(self):
        prev_s6 = self.s6
        self.s6 = self.s2
        self.s2 = self.s1
        self.s1 = self.s5
        self.s5 = prev_s6
    def rotate(self):
        prev_s2 = self.s2
        self.s2 = self.s4
        self.s4 = self.s5
        self.s5 = self.s3
        self.s3 = prev_s2
    def top(self):
        return self.s1
    def front(self):
        return self.s2
    def right(self):
        return self.s3

    def isSameDice(self, anotherDice):
        for i in range(6):
            if i % 2 == 0:
                self.north()
            else:
                self.west()
            for j in range(4):
                self.rotate()
                if self.s1 == anotherDice.s1 and \
                   self.s2 == anotherDice.s2 and \
                   self.s3 == anotherDice.s3 and \
                   self.s4 == anotherDice.s4 and \
                   self.s5 == anotherDice.s5 and \
                   self.s6 == anotherDice.s6:
                    return True
        return False


dices = []
n = int(input())
for i in range(n):
    s1, s2, s3, s4, s5, s6 = map(int, input().split())
    dices.append(Dice(s1, s2, s3, s4, s5, s6))

flag = False
for i in range(n):
    j = i+1
    while j < n:
        if dices[i].isSameDice(dices[j]):
            flag = True
            break
        j += 1

if flag:
    print("No")
else:
    print("Yes")


Measured memory_bytes: 5612
import sys
from heapq import *
input = sys.stdin.readline

N, M = map(int, input().split())
L = [[int(v) for v in input().split()] for _ in range(N)]

L.sort(key = lambda x:(x[0]))
    
m = []
index = 0
ans = 0
for i in range(1, M + 1):
    c = 0
    for j in range(index, N):
        c += 1
        if L[j][0] <= i:
            heappush(m, -L[j][1])
        else:
            index = j
            c = 0
            break
    index += c
    
    if len(m) != 0:
        ans += heappop(m) * -1

print(ans)

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

using namespace std;

#define WA(x) #x << " = " << x << '\n'
#define FOR(i, n) for(int i = 0; i < (int) n; i++)
#define FORT(i, a, b) for(int i = a; i < (int) b; i++)
#define all(v) v.begin(), v.end()
#define PB push_back
#define F first
#define S second

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;

const ll MOD = 1000000007;

#define MAX 400000

ll fat[MAX+5], inv[MAX+5];

ll binExp(ll a, ll p){
	ll ans = 1;
	while(p){
		if(p&1)
			ans = ans * a % MOD;
		a = a * a % MOD;
		p>>=1;
	}
	return ans;
}


ll comb(ll a, ll b){
	ll ans = fat[a] * inv[b] % MOD;
	ans = ans * inv[a-b] % MOD;
	return ans;
}

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

	fat[0] = inv[0] = 1;
	for(int i = 1 ; i < MAX+5; i++){
		fat[i] = i * fat[i-1] % MOD;
		inv[i] = binExp(fat[i], MOD-2);
	}

	ll n, k; cin >> n >> k;

	ll ans = comb(2*n-1, n);



	if(k < n-1){
		ans = 0;
		for(int i = 0; i <= k; i++){
			ll add = comb(n, i) * comb(n-1, i) % MOD;
			ans = (ans + add) % MOD;
		}
	}else
		ans = comb(2*n-1, n);


	cout << ans << '\n';

	return 0;
}

Measured memory_bytes: 6528
import java.util.Scanner;

class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int work = 0;
        while(true){
            int num1 = scan.nextInt();
            int num2 = scan.nextInt();
            if(num1 == 0 && num2 == 0){
                break;
            }else{
                if(num1 > num2){
                    work = num1;
                    num1 = num2;
                    num2 = work;
                    System.out.println(num1 +" "+ num2);
                }else{
                    System.out.println(num1 +" "+ num2);
                }
            }
        }
    }
}


Measured memory_bytes: 36192
#include "bits/stdc++.h"
 
using ll = long long;
using namespace std;


void solveCase() {
   int n;
   cin >> n;
   vector <int> v(n);
   for(auto &e: v) {
      cin >> e;
   }
   int evn = 0;
   int odd = 0;
   
   for(auto &e: v) {
      if(e % 2 == 0) evn++;
      else odd++;
   }

   if(evn % 2 == 1) {
      if(odd % 2 == 0) {
         cout << "YES" << endl;
      } else {
         cout << "NO" << endl;
      }
   } else {
      if(odd % 2 == 0) {
         cout << "YES" << endl;
      } else {
         cout << "NO" << endl;
      }
   }
}

 
int main() {
   cin.tie(0);
   cin.sync_with_stdio(0);
   
   int testcase = 1;
   // cin >> testcase;
 
   for(int i = 0; i < testcase; i++) {
      solveCase();
   }
 
   return 0;
}

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

int main() {
	int n, m;
	cin >> n >> m;
	vector<long long>a(n);
	for (int i = 0; i < n; i++)cin >> a.at(i);
	vector<vector<int>>cb(m, vector<int>(2));
	for (int i = 0; i < m; i++)cin >> cb.at(i).at(1) >> cb.at(i).at(0);
	sort(a.begin(), a.end());
	sort(cb.begin(), cb.end());
	reverse(cb.begin(), cb.end());
	vector<long long>z;
	int count = 0;
	for (int i = 0; i < m; i++) {
		if (count == n)break;
		for (int j = 0; j < cb.at(i).at(1); j++) {
			z.push_back(cb.at(i).at(0));
			count++;
			if (count == n)break;
		}
	}
	for (int i = 0; i < min(a.size(),z.size()); i++) a.at(i) = max(a.at(i), z.at(i));
	long long ans = 0;
	for (int i = 0; i < n; i++)ans += a.at(i);
	cout << ans << endl;
}

Measured memory_bytes: 7672
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <math.h>
#include <queue>
#include <set>
#include <map>
#include <stack>

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;

vector<int> E[26];
ll N,M;
map<int,vector<int>> m;
string s,t;
bool found = true;
ll ans = 0;
vector<int>::iterator position;
vector<int> e;


 
 
int main(){
    cin >> s >> t;
    N = s.size();
    M = t.size();
    for(int i=0;i<N;i++){
        int a = s[i] -'a';
        E[a].push_back(i);
    }
    ll j=-1;
    for(int i=0;i<M;i++){
        int b = t[i] -'a';
        if(E[b].empty()){
            found = false;
            break;
        }
        position = upper_bound(E[b].begin(), E[b].end(), j);
        ll k = *position;
        if(position== E[b].end()){
            k = E[b][0];
            ans+=1;
        }
        j = k;
    }
    ans = ans*N + j+1;
    if(found){
      cout << ans << endl;
    }else{
        cout << -1 << endl;
    }
    
}


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

using namespace std;

template <class T> void mini(T &l, T r) {l = min(l, r);}
template <class T> void maxi(T &l, T r) {l = max(l, r);}

string to_string(string s) {
  return '"' + s + '"';
}
 
string to_string(const char* s) {
  return to_string((string) s);
}
 
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
 
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
 
void debug_out() { cerr << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
 
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

using llint = int;

const int N = 4010, B = 1e9 + 7;

llint c[N][N];
llint d[N][N];
llint tmp[N][N];
llint tmpd[N][N];

void add(llint &a, llint b) {
  a = (a + b) % B;
  if (a < 0) a += B;
}

llint mul(llint a, llint b) {
  a %= B;
  b %= B;
  return 1ll * a * b % B;
}

void run() {
  for (int i = 0; i < N; ++i) {
    for (int j = 0; j <= i; ++j) {
      if (j == 0) c[i][j] = 1;
      else c[i][j] = (c[i - 1][j] + c[i - 1][j - 1]) % B;
    }
  }
  //debug(c[2][0], c[2][1]);

  for (int i = 0; i < N; ++i) {
    d[i][0] = c[i][0];
    for (int j = 1; j < N; ++j) {
      d[i][j] = (d[i][j - 1] + c[i][j]) % B;
    }
  }

  for (int q = 0; q < N; ++q) {
    for (int s = 1; s < N; ++s) {
      tmp[q][s] = d[q - 1][min(s - 1, q - 1)];
    }
  }

  for (int q = 0; q < N; ++q) {
    for (int s = 1; s < N; ++s) {
      tmpd[q][s] = (tmpd[q][s - 1] + tmp[q][s]) % B;
    }
  }
  debug(d[2][1]);
  debug(tmp[3][2]);
  debug(tmpd[3][2]);

  int a, b;
  scanf("%d%d", &a, &b);

  llint ans = 0;

  for (int p = 0; p <= a; ++p) {
    for (int q = 0; q <= b - 1; ++q) {
      if (p + q <= a) {
        if (q == 0) add(ans, 1);
        else {
          //t = p + q + 1
          //debug(p, q, c[b - 1][q], tmpd[q][p + 1], mul(c[b - 1][q], tmpd[q][p + 1]));
          add(ans, mul(c[b - 1][q], tmpd[q][p + 1]));
        }
      }
    }
  }

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

int main() {
  run();
  return 0;
}


Measured memory_bytes: 251520
a, b = map(int, input().split())
if a > 0 and b > 0: ans = "Positive"
elif a < 0 and b < 0:
  if (abs(a-b) + 1) % 2 == 0:
    ans = "Positive"
  else:
    ans = "Negative"
else:
  ans = "Zero"
print(ans)

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        long K = sc.nextLong();
        long[] A = new long[N];
        for(int i = 0; i < N; i++) A[i] = sc.nextLong();
        int[] cnt = new int[50];
        // Aの各桁に1がいくつ立っているか数える
        for(int i = 0; i < 50; i++){
            for(int j = 0; j < N; j++){
                cnt[i] += (A[j] >> i) & 1;
            }
        }
        long ans = 0;
        boolean free = false;
        for(int i = 49; i >= 0; i--){
            long pow = (long)Math.pow(2, i);
            long one = (long)cnt[i];
            long zero = (long)(N - cnt[i]);
            // Kのｉ桁目が１の場合、ｉ桁目は１でも０でもよく、
            // Ａのｉ桁目に１が立っている方が少なければｉ桁目は１を立てる
            // Ａのｉ桁目に１が立っている方が多ければ（同数含む）ｉ桁目は０とする
            // Kのｉ桁目が１でｉ桁目を０とすると、ｉ-１桁目以降は１でも０でも自由に選べる
            // Kのｉ桁目が０の場合、それまでに自由に選べるようになっていなければ０しか選べない
            if(free){
                ans += pow * Math.max(one, zero);
            }else{
                if(((K >> i) & 1) == 1){
                    if(one < zero){
                        ans += pow * zero;
                    }else{
                        ans += pow * one;
                        free = true;
                    }
                }else{
                    ans += pow * one;
                }
            }
        }

        System.out.println(ans);
        sc.close();
    }

}


Measured memory_bytes: 60528
#include<iostream>
#include<string>
using namespace std;
int check(string& s,int point){
	if(point>=s.size()) return 0;
	if(point>=s.size()-4) return 1;
	if(s[point]=='d'&&s[point+1]=='r'&&s[point+2]=='e'&&s[point+3]=='a'&&s[point+4]=='m'){
		if(check(s,point+5)==0) return 0;
		if(point>=s.size()-6) return 1;
		if(s[point+5]=='e'&&s[point+6]=='r'){
			if(check(s,point+7)==0) return 0;
		}
		return 1;
	}
	if(s[point]=='e'&&s[point+1]=='r'&&s[point+2]=='a'&&s[point+3]=='s'&&s[point+4]=='e'){
		if(check(s,point+5)==0) return 0;
		if(point>=s.size()-5) return 1;
		if(s[point+5]=='r'){
			if(check(s,point+6)==0) return 0;
		}
		return 1;
	}
	return 1;
}
int main(){
	string s;
	cin>>s;
	if(check(s,0)==0){
		cout<<"YES"<<endl;
	}else{
		cout<<"NO"<<endl;
	}
	return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define _ << ' ' <<
using namespace std;
using ll = long long;

int a[100000];
int sol;

int main()
{
    int n, c, k;
    cin >> n >> c >> k;
    for (int i = 0; i < n; ++i)
        cin >> a[i];

    sort(a, a + n);
    int p = 0, q = 0;
    while (q < n)
    {
        while (q + 1 < n && q - p + 1 < c && a[q + 1] - a[p] <= k)
            q++;
        sol++;
        p = ++q;
    }
    cout << sol;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define INF 1e9
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

int main(){
    double h,a;
    cin>>h>>a;
    cout<<ceil(h/a)<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <cmath>
#include <chrono>
using namespace std;

int main(int argc, const char * argv[]) {
    
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int N;
    cin >> N;
    map<int, int> mp;
    for (int i = 0; i < N; i++) {
        int a;
        cin >> a;
        mp[a]++;
    }
    
    int cnt = 0;
    for (auto itr : mp) {
        if (itr.second % 2 == 1) cnt++;
    }
    cout << cnt << endl;
    
    return 0;
}


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


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

  int N;
  cin >> N;
  if(N % 2 == 1){
    cout << 0 << endl;
    return 0;
  }
  if(N <= 9){
    cout << 0 << endl;
    return 0;
  }

  int res = 10;
  int ans = 0;
  while(N >= res){
    ans += N/res;

    res *= 5;
  }

  cout << ans << endl;

}

Measured memory_bytes: 256
N = int(input())
# = str(input())
# = map(int, input().split())
# = list(map(int, input().split()))
S = [str(input()) for i in range(N)]
# = [list(map(int, input().split())) for i in range(N)]

print("AC x", S.count("AC"))
print("WA x", S.count("WA"))
print("TLE x", S.count("TLE"))
print("RE x", S.count("RE"))


Measured memory_bytes: 16296
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <string>
#include <unordered_map>

using namespace std;

int n;
vector<string> s;
unordered_map<string, int> m;
long ans = 0;

void check()
{
    for (int i = 0; i < n; ++i) {
        sort(s[i].begin(), s[i].end());
    }
    for (int i = 0; i < n; ++i) {
        if (m.find(s[i]) == m.end())
            m[s[i]] = 1;
        else {
            ans += m[s[i]];
            m[s[i]] += 1;
        }
    }
}

int main()
{
    cin >> n;
    s.resize(n);
    for (int i = 0; i < n; ++i) cin >> s[i];
    check();

    printf("%ld\n", ans);

    return 0;
}


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

vector<bool> seen;

void dfs(const vector<vector<ll>> &G, vector<ll> &val, int v){
  seen[v] = true;

  for(ll next_v : G[v]){
    if(seen[next_v]) continue;
    val[next_v] += val[v];
    dfs(G, val, next_v);
  }
}

int main(){
  ll N,Q;
  cin >> N >> Q;
  vector<vector<ll>> G(N);
  for(ll i=0;i<N-1;++i){
    ll a,b;
    cin >> a >> b; a--,b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  vector<ll> val(N,0);
  for(ll i=0;i<Q;++i){
    ll p,x;
    cin >> p >> x;
    p--;
    val[p] += x;
  }
  seen.assign(N,false);
  dfs(G, val, 0);
  for(int i=0;i<N;++i) cout << val[i] << endl;
}

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

int main(){
  int N, M;
   
  cin >> N; vector<string> s(N);
  rep(i, N) cin >> s[i];
  cin >> M; vector<string> t(M);
  rep(i, M) cin >> t[i];
  
  int max = 0;
  string check;
  
  rep(i, N){
    check = s[i];
    int ans = 0;
    rep(j, N) if(check == s[j]) ans++;
    rep(k, M) if(check == t[k]) ans--;
    if(max < ans) max = ans;
  }
  
  
  rep(i, M){
    check = t[i];
    int ans = 0;
    rep(j, N) if(check == s[j]) ans++;
    rep(k, M) if(check == t[k]) ans--;
    if(max < ans) max = ans;
  }
  
  cout << max << endl;
  
}


Measured memory_bytes: 256
import sys
import math

N = 1000000
primes = [1] * (N//2)
primes[0] = 0

for i in range(3,int(math.sqrt(N)),2):
    if primes[i//2]:
        primes[(i*i)//2::i] = [0] * len(primes[(i*i)//2::i])

for i in sys.stdin:
    n = int(i)
    if n == 1:
        print(0)
    elif n == 2:
        print(1)
    else:
        print(sum(primes[0:(n+1)//2])+1)

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

int main(){
    int a[114514];
    for(int i=0;i<4;i++){
        int x;
        cin>>x;
        
        a[x]++;
    }
    if(a[1]==1&&a[9]==1&&a[7]==1&&a[4]==1){
        cout<<"YES"<<endl;
    }
    else{
        cout<<"NO"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
//For ordered_set
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define MOD 1000000007
#define test int t; cin>>t; while(t--)
#define init(arr,val) memset(arr,val,sizeof(arr))
#define loop(i,a,b) for(int i=a;i<b;i++)
#define loopr(i,a,b) for(int i=a;i>=b;i--)
#define loops(i,a,b,step) for(int i=a;i<b;i+=step)
#define looprs(i,a,b,step) for(int i=a;i>=b;i-=step)
#define ull unsigned long long int
#define ll long long int
#define P pair
#define PLL pair<long long, long long>
#define PII pair<int, int>
#define PUU pair<unsigned long long int, unsigned long long int>
#define L list
#define V vector
#define D deque
#define ST set
#define MS multiset
#define M map
#define UM unordered_map
#define mp make_pair
#define pb push_back
#define pf push_front
#define MM multimap
#define F first
#define S second
#define IT iterator
#define RIT reverse_iterator
#define FAST ios_base::sync_with_stdio(false);cin.tie();cout.tie();
#define FILE_READ_IN freopen("input.txt","r",stdin);
#define FILE_READ_OUT freopen("output.txt","w",stdout);
#define all(a) a.begin(),a.end()
using namespace std;
// For ordered_set
using namespace __gnu_pbds;
template <typename T>
using ord_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
const ll maxn = 1e5;
const ll inf = 1e9;
const double pi = acos(-1);

void solve(){
    ll n;
    cin >> n;
    n = n % 1000;
  	if(n==0)
      cout << 0 << "\n";
   	else cout << abs(1000 - n) << "\n";
}

int main(){
   int t = 1;
   //cin >> t;
   while(t--){
       solve();
   }
   return 0;
}


Measured memory_bytes: 3640
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
#define maxn 2005
using namespace std;

int n,m,i,j,k,f[maxn][maxn],g[maxn][maxn];
int t,w,d[maxn*maxn][2],vis[maxn][maxn];
int em,e[maxn*2],nx[maxn*2],ls[maxn],dep[maxn][maxn];

void insert(int x,int y){
	em++; e[em]=y; nx[em]=ls[x]; ls[x]=em; 
	em++; e[em]=x; nx[em]=ls[y]; ls[y]=em;
}

void dfs(int x,int p,int st){
	dep[st][x]=dep[st][p]+1;
	for(int i=ls[x];i;i=nx[i]) if (e[i]!=p)
		dfs(e[i],x,st);
}

void cover(int x,int p,int st,int v){
	f[st][x]=v;
	if (g[st][x]){
		if (!vis[x][v]) 
			w++,d[w][0]=v,d[w][1]=x,vis[x][v]=vis[v][x]=1;
	}
	for(int i=ls[x];i;i=nx[i]) if (e[i]!=p)
		cover(e[i],x,st,v);
}

void doit(int x,int y){
	g[x][y]=1;
	for(int i=ls[y];i;i=nx[i]) if (dep[x][e[i]]>dep[x][y])	
		cover(e[i],y,x,y);
}

int tot,dfn[maxn],sz[maxn],cnt,E[maxn][2];
void getdfn(int x,int p){
	dfn[x]=++tot,sz[x]=1;
	for(int i=ls[x];i;i=nx[i]) if (e[i]!=p)
		getdfn(e[i],x),sz[x]+=sz[e[i]];
}

int fa[maxn];
int father(int x){return (fa[x]==x)?x:fa[x]=father(fa[x]);}
void link(int x,int y){
	if (father(x)!=father(y))
		fa[fa[x]]=fa[y];
}

int main(){
	scanf("%d%d",&n,&m);
	for(i=1;i<n;i++) scanf("%d%d",&j,&k),insert(j,k);
	for(i=1;i<=n;i++) dfs(i,0,i);
	while (m--){
		int x,y; scanf("%d%d",&x,&y);
		if (!vis[x][y]) w++,d[w][0]=x,d[w][1]=y,vis[x][y]=vis[y][x]=1;
		while (t<w){
			t++,x=d[t][0],y=d[t][1];
			while (f[x][y]) x=f[x][y];
			while (f[y][x]) y=f[y][x];
			if (!g[x][y]) doit(x,y);
			if (!g[y][x]) doit(y,x);
		}
	}
	for(i=1;i<=n;i++) for(j=i+1;j<=n;j++)
		if (g[i][j]&&!f[i][j]&&!f[j][i])
			cnt++,E[cnt][0]=i,E[cnt][1]=j;
	int ans=0;
	for(int st=1;st<=n;st++){
		tot=0,memset(dfn,0,sizeof(dfn));
		getdfn(st,0);
		for(i=1;i<=n;i++) fa[i]=i;
		for(i=1;i<=cnt;i++) {
			if (dfn[E[i][0]]>dfn[E[i][1]]) swap(E[i][0],E[i][1]);
			if (dfn[E[i][1]]>=dfn[E[i][0]]&&dfn[E[i][1]]<dfn[E[i][0]]+sz[E[i][0]])
				link(E[i][0],E[i][1]);
		}
		for(i=1;i<=n;i++) if (father(i)==father(st)&&i!=st)	
			ans++;
	}
	printf("%d",ans/2);
}

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

struct Dinic{
  const Int INF=1<<28;
  
  struct edge {
    Int to,cap,rev;
    edge(){}
    edge(Int to,Int cap,Int rev):to(to),cap(cap),rev(rev){}
  };

  Int n;
  vector<vector<edge> > G;
  vector<map<Int,Int> > M;
  vector<Int> level,iter;

  Dinic(){}
  Dinic(Int sz):n(sz),G(n),M(n),level(n),iter(n){}
  
  void add_edge(Int from,Int to,Int cap){
    M[from][to]=G[from].size();
    M[to][from]=G[to].size();
    G[from].push_back(edge(to,cap,G[to].size()));
    // undirected
    //G[to].push_back(edge(from,cap,G[from].size()-1));
    // directed
    G[to].push_back(edge(from,0,G[from].size()-1));
  }
  
  void bfs(Int s){
    fill(level.begin(),level.end(),-1);
    queue<Int> que;
    level[s]=0;
    que.push(s);
    while(!que.empty()){
      Int v=que.front();que.pop();
      for(Int i=0;i<(Int)G[v].size();i++){
	edge &e = G[v][i];
	if(e.cap>0&&level[e.to]<0){
	  level[e.to]=level[v]+1;
	  que.push(e.to);
	}
      }
    }
  }
  
  Int dfs(Int v,Int t,Int f){
    if(v==t) return f;
    for(Int &i=iter[v];i<(Int)G[v].size();i++){
      edge &e=G[v][i];
      if(e.cap>0&&level[v]<level[e.to]){
	Int d = dfs(e.to,t,min(f,e.cap));
	if(d>0){
	  e.cap-=d;
	  G[e.to][e.rev].cap+=d;
	  return d;
	}
      }
    }
    return 0;
  }
  
  Int flow(Int s,Int t,Int lim){
    Int fl=0;
    for(;;){
      bfs(s);
      if(level[t]<0||lim==0) return fl;
      fill(iter.begin(),iter.end(),0);
      Int f;
      while((f=dfs(s,t,lim))>0){
	fl+=f;
	lim-=f;
      }
    }
  }

  Int flow(Int s,Int t){
    return flow(s,t,INF);
  }

  //cap==1 only
  bool back_edge(Int s,Int t,Int from, Int to){
    for(Int i=0;i<(Int)G[from].size();i++) {
      edge& e=G[from][i];
      if(e.to==to) {
	if(e.cap==0&&flow(from,to,1)==0) {
	  flow(from,s,1);
	  flow(t,to,1);
	  return 1;
	}
      }
    }
    return 0;
  }
};



template <typename T>
vector<T> dijkstra(Int s,vector<vector<pair<Int, T> > > & G,T INF){
  using P = pair<T, Int>;
  Int n=G.size();
  vector<T> d(n,INF);
  vector<Int> b(n,-1);
  priority_queue<P,vector<P>,greater<P> > q;
  d[s]=0;
  q.emplace(d[s],s);
  while(!q.empty()){
    P p=q.top();q.pop();
    Int v=p.second;
    if(d[v]<p.first) continue;
    for(auto& e:G[v]){
      Int u=e.first;
      T c=e.second;
      if(d[u]>d[v]+c){
	d[u]=d[v]+c;
	b[u]=v;
	q.emplace(d[u],u);
      }
    }
  }
  return d;
}

//INSERT ABOVE HERE
signed main(){
  Int n,m,s,t;
  cin>>n>>m>>s>>t;
  s--;t--;

  using P = pair<Int, Int>;
  vector<vector<P> > G(n);
  vector<vector<P> > rG(n);
  map<P, Int> C;
  for(Int i=0;i<m;i++){
    Int u,v,d,c;
    cin>>u>>v>>d>>c;
    u--;v--;
    G[u].emplace_back(v,d);
    rG[v].emplace_back(u,d);
    C[P(u,v)]=c;
  }

  const Int INF = 1e15;
  auto ds=dijkstra(s,G,INF);
  auto dt=dijkstra(t,rG,INF);

  Dinic f(n);
  for(Int v=0;v<n;v++){
    for(auto p:G[v]){
      Int u,d;
      tie(u,d)=p;
      if(ds[v]+d==ds[u]&&ds[v]+d+dt[u]==ds[t]){
	f.add_edge(v,u,C[P(v,u)]);
      }
    }
  }

  cout<<f.flow(s,t)<<endl;
  return 0;
}



Measured memory_bytes: 3348
#include<iostream>
#include<algorithm>
#include<vector>
#include<numeric>
#include<string>
#include<cmath>
#include<set>
#include<queue>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cctype>
#include<map>
#include<cstring>
#include<bitset>
#include<cassert>
 
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,a,b) for (int (i)=a;(i)<(b);(i)++)
#define all(x) (x).begin(),(x).end()
 
using namespace std;
using ll = long long int;
 
const int inf = 1001001000;
const long long int Inf = 1001001001001001000;
 
template<typename T>
void print(vector<T> a){
	for (auto x:a){
		cout << x << " ";
	}
	cout << endl;
}
 
template<typename T>
void print2d(vector<vector<T>> a){
	for (auto v:a){
		for (auto x:v){
			cout << x << " ";
		}
		cout << endl;
	}
}
 
 
 
int main()
{
	int a, b;
	cin >> a >> b;
	if(a*b==15)
		cout << "*" << endl;
	else if(a+b==15){
		cout << "+" << endl;
	} else {
		cout << "x" << endl;
	}
	return 0;
}

Measured memory_bytes: 3588
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAX=100005;
int n,c,k;
ll A[MAX];
bool check(int pos)
{
    ll s=A[pos];
    for(int i=0;i<n;i++)
    {
        if(i==pos)
            continue;
         if(A[i]<=2*s)
            s+=A[i];
         else
            return false;
    }
       return true;

}
int main()
{
    while(~scanf("%d",&n))
    {
        ll sum=0;
        for(int i=0;i<n;i++)
             scanf("%lld",A+i);


       sort(A,A+n);

        int ans=n;
        int l=0,r=n-1;
		while(l<=r)
		{
			int mid=(l+r)>>1;
			if (check(mid))
				r=mid-1,ans=mid;
			else
				l=mid+1;
		}
		printf("%d\n",n-ans);



    }

    return 0;
}


Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){for(auto &e:t) fill_v(e,v);}
/*
 <url:https://atcoder.jp/contests/abc163/tasks/abc163_d>
 問題文============================================================
 D - Sum of Large Numbers
 =================================================================
 解説=============================================================
 
 ================================================================
 */

const ll MAX_N = 3e6 + 10;
const ll MOD = 1e9+7;
ll Inv[MAX_N];
ll fact[MAX_N];
ll factInv[MAX_N];
void Inv_init(){
    Inv[1] = 1;
    for(int i = 2; i < MAX_N; i++) {
        Inv[i] = Inv[MOD%i] * (MOD - MOD/i) % MOD;
    }
}
void fact_init(){
    fact[0] = fact[1] = factInv[0] = factInv[1] = 1;
    for(int i = 2; i < MAX_N; i++){
        fact[i] = (fact[i-1] * i) % MOD;
        factInv[i] = (factInv[i-1] * Inv[i])%MOD;
    }
}

// a^b % MOD;
ll powmod(ll a,ll b) {ll res=1;a%=MOD; for(;b;b>>=1){if(b&1)res=res*a%MOD;a=a*a%MOD;}return res;}
// 逆元 1/a % MOD
ll inversemod(ll a) { return powmod(a,MOD - 2);}

// 1 以上 N 以下の N 個の整数の中から，相異なる K 個の整数を選ぶパターンの数
ll nCr(int n,int r) {
    if(n < r) return 0;
    return (fact[n] * (factInv[r] * factInv[n-r] % MOD)) % MOD;
}

void init(){
    Inv_init();
    fact_init();
}

template<class Type>
Type solve(Type res = Type()){
    init();
    
    ll N,K; cin >> N >> K;
    
    // 少ない方からK個とる場合の総和
    ll L = K*(K-1)/2 % MOD;
    for(ll i = K-1; i <= N;i++){
        // 全部とる場合の総和
        ll R = i*(i+1)/2 % MOD;
        (res += (R-L+1+MOD)%MOD)%=MOD;
    }
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    // solve(0);
    cout << fixed << setprecision(15) << solve<ll>() << endl;
    return 0;
}


Measured memory_bytes: 73960
def countdays m, d
    sum = 0
    days = [31,29,31,30,31,30,31,31,30,31,30,31]
    0.upto(m-2){|i| sum += days[i]}
    sum += d
    sum
end

yobi = ["Wednesday", "Thursday", "Friday", "Saturday", "Sunday", "Monday", "Tuesday"]

while true
    m, d = gets.chomp.split.map(&:to_i)
    break if m == 0
    puts yobi[countdays(m, d) % 7]
end


Measured memory_bytes: 6860
using System;
using System.Linq;
using System.Collections.Generic;

namespace C
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var a = Console.ReadLine().Split().Select(double.Parse).OrderBy(x=>x).ToArray();

            Console.WriteLine(check(a));


        }

        private static string check(double[] a)
        {
            for (int i = 0; i < a.Length-1; i++)
            {
                if (a[i] == a[i+1])
                {
                    return "NO";
                }

            }

            return "YES";
        }
    }
}


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

// #define int long long
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

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



signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll n; string s; cin>>n>>s;
  ll l=0,r=0;
  rep(i,n){
    if(s[i]==')'){
      if(r==0) continue;
      r--;
    }else{
      r++;
    }
  }
  rep(i,r) s.push_back(')');
  
  n=s.size();
  l=0,r=0;
  rrep(i,n){
    if(s[i]==')'){
      l++;
    }else{
      if(l==0) continue;
      l--;
    }
  }
  string tmp="";
  rep(i,l) tmp+='(';
  cout<<tmp+s<<endl;
}

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

int main(void) {
  int length, i;
  scanf(" %d", &length);
  int *list = (int *) malloc(length * sizeof(int));
  for (i = 0; i < length; i++)
    scanf(" %d", list + i);
  for (i = length - 1; i >= 0; i--) {
    printf("%d", list[i]);
    if (i)
      printf(" ");
  }
  printf("\n");
  return 0;
}



Measured memory_bytes: 2076
#include<stdio.h>

#define MAX 100000

int parent(int i){return i/2;}
int left(int i){return i*2;}
int right(int i){return i*2+1;}


int main(){
int H,i,A[MAX+1];


  scanf("%d",&H);
  for(i=1;i<=H;i++){
scanf("%d",&A[i]);
  }

for(i=1;i<=H-1;i++){
printf("node %d: key = %d, ",i,A[i]);
if(parent(i)>=1)printf("parent key = %d, ",A[parent(i)]);
if(left(i)<=H)printf("left key = %d, ",A[left(i)]);
if(right(i)<=H)printf("right key = %d, ",A[right(i)]);
printf("\n");
}
printf("node %d: key = %d, ",i,A[i]);
if(parent(i)>=1)printf("parent key = %d, ",A[parent(i)]);
if(left(i)<=H)printf("left key = %d, ",A[left(i)]);
if(right(i)<=H)printf("right key = %d, ",A[right(i)]);
printf("\n");
return 0;
}

Measured memory_bytes: 608
#d
k=int(input())

tree = list(range(1,10))
ans = [tree[:]]
koremade= 0
while koremade<=k:
    tree_next = []
    for t in tree:
        t_last = t%10
        if t_last==9:
            tt = [t*10+t%10-1, t*10+t%10]
        elif t_last==0:
            tt = [t*10+t%10, t*10+t%10+1]
        else:
            tt = [t*10+t%10-1, t*10+t%10, t*10+t%10+1]
        tree_next.extend(tt)
    tree=tree_next[:]
    ans.append(tree_next)
    koremade = sum(len(aa) for aa in ans)
#    print(koremade,k)

fans = []
for aa in ans:
    fans.extend(aa)
print(fans[k-1])

Measured memory_bytes: 53616
c = [list(map(int,input().split())) for _ in range(3)]

a = [0] * 3
b = [0] * 3

for i in range(101):
    flag = True
    a[0] = i
    b[0] = c[0][0]-a[0]
    b[1] = c[0][1]-a[0]
    b[2] = c[0][2]-a[0]
    a[1] = c[1][0]-b[0]
    a[2] = c[2][0]-b[0]
    for j in range(1,3):
        for k in range(1,3):
            if a[j] + b[k] != c[j][k]:
                flag = False
                break
        else:continue
        break
    
    if flag:
        break
    
if flag:
    print('Yes')
else:
    print('No')
    

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

int main() {
  int N;
  vector<int64_t> lucas_num(90);
  cin >> N;
  lucas_num.at(0) = 2;
  lucas_num.at(1) = 1;
  if(N>1){
    for(int i = 2; i <= N; i++){
      lucas_num.at(i) = lucas_num.at(i-1) + lucas_num.at(i-2);
    }
  }
  cout << (int64_t)lucas_num.at(N) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#ifndef ONLINE_JUDGE
#define cin fin
#define cout fout
#endif
using namespace std;
ifstream fin("in.txt");
ofstream fout("out.txt");
int n,m;
const double pi=acos(-1);
int main(){
	cin>>n;
	cout<<pi*2*n;
}

Measured memory_bytes: 3796
#include <bits/stdc++.h>
 
using namespace std;
 
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl;
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}
typedef long long ll;
#define int ll
 
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(int)(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const long double pi = 3.1415926535897932384626433832795028841971L;
#define Sp(p) cout<<setprecision(25)<< fixed<<p<<endl;
//int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
//int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
vi dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
vi dx2 = { 1,1,0,-1,-1,-1,0,1 }, dy2 = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
// const ll MOD = 1000000007;
const ll MOD = 998244353;
// #define mp make_pair
//#define endl '\n'


signed main() {
    fio();
    int n;
    cin >> n;
    vi num(1000111);
    vi a(n);
    rep (i, n) {
        cin >> a[i];
        num[a[i]]++;
    }

    int ans = 0;
    rep (i, n) {
        if (num[a[i]] >= 2) continue;

        bool flag = true;
        for (int j = 1; j * j <= a[i]; j++) {
            if (a[i] % j == 0) {
                int x = j;
                int y = a[i] / j;
                int nn = num[x];
                if (x == a[i]) nn--;
                if (nn > 0) {
                    flag = false;
                    break;
                }
                nn = num[y];
                if (y == a[i]) nn--;
                if (nn > 0) {
                    flag = false;
                    break;
                }
            }
        }
        if (flag) {
            ans++;
            // DEBUG(a[i]);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 12672
def main():
    N, M = map(int, input().split())
    S = []
    for _ in range(M):
        S.append(tuple(map(int, input().split())))

    for i in range(0, 10**N):
        k = str(i)
        count = 0
        if len(k) < N:
            continue
        for s, c in S:
            if k[s-1] == str(c):
                count += 1
        if count == M:
            print(i)
            return 0
    print(-1)

    return 0


if __name__ == '__main__':
    main()

Measured memory_bytes: 3064