akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define i_7 (ll)(1E9+7)
#define i_5 (ll)(1E9+5)
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    else return c+i_7;
}
typedef pair<int,int> i_i;
typedef pair<ll,ll> l_l;
ll inf=(ll)1E17;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
long double EPS=1E-8;
////////////////////////////////////////



int main(){
    ll k,a,b;cin>>k>>a>>b;
    if(b<=a+2){
        cout<<k+1<<endl;
        return 0;
    }
    if(k+1<=a){
        cout<<k+1<<endl;
        return 0;
    }
    k-=a-1;
    ll ans=k/2*(b-a)+k%2+a;
    cout<<ans<<endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, n) for (int i = 1; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) cout << x << endl;
#define println(x) cout << x << endl;
using namespace std;
signed main()
{
    int n;
    cin >> n;
    vector<int> a(n-1);
    rep(i, n-1) cin >> a[i];
    vector<int> cnt(n);
    rep(i, n-1) {
        cnt[a[i]-1]++;
    }
    rep(i, n) {
        put(cnt[i])
    }
    return 0;
}

Measured memory_bytes: 4844
n = int(input())
a = list(map(int, input().split()))
b_1 = []
b_2 = []
b = []
for i in reversed(range(len(a))):
	if i % 2 != 0:
		b_1.append(a[i])
	else:
		b_2.append(a[i])
if len(a) % 2 == 0:
	b_2.reverse()
	b.extend(b_1)
	b.extend(b_2)
else:
	b_1.reverse()
	b.extend(b_2)
	b.extend(b_1)
for b_num in b:
	print(b_num, end = ' ')

Measured memory_bytes: 26020
#include<iostream>
#include<cstdio>
#include<cstring>
#include<queue>
using namespace std;
int main()
{
    long long n,step=-1,i;
    scanf("%lld",&n);
    for(i=1;i*i<=n;i++)
    {
        if(i*i<=n&&i*i>step)
        {
            step=i*i;
        }
    }
    printf("%lld\n",step);
}

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

using namespace std;

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

  int l=0, r=0;
  for (int i=0; i<n; i++) {
    if (str[i] == '(') r++;
    else r--;

    if (r<0) {
      l++;
      r++;
    }
  }

  for (int i=0; i<l; i++) {
    cout << '(';
  }
  cout << str;
  for (int i=0; i<r; i++) {
    cout << ')';
  }
  cout << endl;
  
	return 0;
}


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

#define ll long long

int main(){
    int lose = 0;
    string S;
    cin >> S;
    for(int i = 0; i < S.length(); i++){
        if(S[i] == 'x')lose++;
    }
    if(lose > 7)cout << "NO" << endl;
    else cout << "YES" << endl;
    return 0;
}

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

int main(){
  const int M = 1e5;
  bitset<M+1> is_prime(string(M+1,'1'));
  is_prime[0] = 0;
  is_prime[1] = 0;
  for(int i = 2; i*i <= M; ++i){
    if(!is_prime[i]) continue;
    for(int j = i; i*j <= M; ++j)
      is_prime[i*j] = 0;
  }
  vector<int> S(M+1,0);
  for(int i = 1; i <= M; ++i){
    S[i] += S[i-1];
    if(is_prime[i] and is_prime[(i+1)/2]) ++S[i];
  }
  int Q;
  cin >> Q;
  for(int i = 0; i < Q; ++i){
    int l, r;
    cin >> l >> r;
    cout << S[r] - S[l-1] << endl;
  }
  return 0;
}


Measured memory_bytes: 1152
#include<iostream>
#include<string>
#include<stdio.h>
#include<cctype>
#include<algorithm>
#include<climits>
#include<cmath>
#include<map>
#include<vector>
#define INF INT_MAX
using namespace std;

int X;

int main(){
	cin >> X;
	if (X < 600 && X >= 400){
		cout << 8 << endl;
	}
	if (X < 800 && X >= 600){
		cout << 7 << endl;
	}
	if (X < 1000 && X >= 800){
		cout << 6 << endl;
	}
	if (X < 1200 && X >= 1000){
		cout << 5 << endl;
	}
	if (X < 1400 && X >= 1200){
		cout << 4 << endl;
	}
	if (X < 1600 && X >= 1400){
		cout << 3 << endl;
	}
	if (X < 1800 && X >= 1600){
		cout << 2 << endl;
	}
	if (X < 2000 && X >= 1800){
		cout << 1 << endl;
	}
	
	return 0;
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
typedef long long ll;
#define INF 100000000
#define MOD 1000000007
int dx[4]={1,0,-1,0},dy[4]={0,-1,0,1};
using namespace std;
int main(void){
   string s,t;
   cin>>s>>t;
   int ans=0;
   for(int i=0;i<3;i++){
      if(s[i]==t[i]){
         ans++;
      }
   }
   cout<<ans<<endl;
   return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
const int maxn=3e5+100;
const int inf=1<<29;
int a[maxn],b[maxn];
int n;
char s[maxn];
int main()
{
    //freopen("1.txt","r",stdin);
    while (scanf("%d%s",&n,s)!=EOF)
    {
        memset(a,0,sizeof(a));
        memset(b,0,sizeof(b));
        if (s[0]=='E') a[0]++; else b[0]++;
        for (int i=1;i<n;i++)
        {
            a[i]=a[i-1]; b[i]=b[i-1];
            if (s[i]=='E') a[i]++; else b[i]++;
        }
        int ans=a[n-1];
        for (int i=1;i<n;i++)
            ans=min(ans,b[i]+a[n-1]-a[i]);
        printf("%d\n",ans);
    }
    return 0;
}


Measured memory_bytes: 2944
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int a,b,c;
int sum;
int ans=0;
bool ok[1000000000];
int main()
{
    cin>>a>>b>>c>>sum;
    for(int i=0;i<=a;i++)
    for(int j=0;j<=b;j++)
    for(int l=0;l<=c;l++)
    {
        if(500*i+100*j+50*l==sum) ans++;
        if(500*i+100*j+50*l>sum) break;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
from bisect import bisect, bisect_left
import sys
from collections import defaultdict
input = sys.stdin.readline
def inpl(): return list(map(int, input().split()))

N = int(input())
L = sorted(inpl())
ans = 0

for i in range(N):
    for j in range(i+1, N):
        a = L[i]
        b = L[j]
        l = max(bisect(L, b-a), j+1)
        r = bisect_left(L, a+b)
        ans += max(0, r-l)
print(ans)

Measured memory_bytes: 48220
import std.stdio, std.string, std.array, std.conv, std.algorithm;

void main() {
    int n = readln.chomp.to!int;
    int[] a = readln.chomp.split.to!(int[]);
    int q = readln.chomp.to!int;
    foreach (i; 0 .. q) {
        int[] tmp = readln.chomp.split.to!(int[]);
        int c = tmp[0], b = tmp[1], e = tmp[2];
        if (c) a[b..e].dup.sort.array[$-1].writeln;
        else a[b..e].dup.sort.array[0].writeln;
    }
}


Measured memory_bytes: 4276
from collections import deque, Counter, defaultdict
from itertools import chain, combinations
import json
# import numpy as np
import bisect
import sys
import math
import bisect
from functools import lru_cache

sys.setrecursionlimit(10 ** 8)

M = 10 ** 9 + 7
INF = 10 ** 17


def main():
    N = int(input())
    # A = [int(a) for a in input().split()]
    print(2*N*math.pi)

    # @lru_cache(None)
    # def f(i, j):
    #     if i < 0 or j < 0:
    #         return -INF
    #     if i == 0:
    #         return -INF
    #     if abs(j - i // 2 - 1) >= 2:
    #         return -INF
    #     if j == 0:
    #         return 0
    #     if j == 1:
    #         return max(A[:i])
    #     return max(A[i - 1] + f(i - 2, j - 1), f(i - 1, j))
    #
    # print(f(N, math.floor(N / 2)))


if __name__ == "__main__":
    main()


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

using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define eprintf(...) 42
#endif

int main()
{

    string s,pre="R";
    cin >> s;
    lint n, m,rcount=0,lcount=0;

    n = s.length();

    lint ans[n], tmp;

    REP(i,n)
    ans[i] = 0;

    REP(i, n)
    {
        if(s[i]=='R'){
            rcount += 1;
            ans[i] = 0;
        }else{
            ans[i - 1] += (rcount + 1) / 2;
            ans[i] += rcount / 2;
            rcount = 0;
        }
    }

    IREP(i, n)
    {

        //pre = s[i];
        //cout << s[i] << "\n";
        if (s[i] == 'L')
        {
            lcount += 1;
            //ns[i] = 0;
        }
        else
        {
            ans[i + 1] += (lcount + 1) / 2;
            ans[i] += lcount / 2;
            lcount = 0;
        }

        //pre = s[i];
    }

    REP(i,n)
    cout << ans[i] <<"\n";

    return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <map>
#include <string>

using namespace std;

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

	map<string, int> m;
	for (int i = 0; i < N; i++){
		string s;
		cin >> s;
		m[s]++;
	}

	cout << m.size() << endl;
	return 0;
}


Measured memory_bytes: 19212
N = int(input())


def dfs(A):
    if len(A)==len(str(N))+1:
        return 0
    
    cnt = 0
    if set(A) == set([3, 5, 7]):
            if int(''.join(map(str, A))) <= N:
#                 print(A)
                cnt = 1
                
    for i in [3, 5, 7]:
        A.append(i)
        cnt += dfs(A)
        A.pop()
    return cnt

cnt = 0
ans = dfs([])
print(ans)

Measured memory_bytes: 3064
import math
n,d=map(int,input().split())
ans=0
x=[]
for i in range(n):
  x.append(list(map(int,input().split())))
for i in range(n):
  for j in range(n):
    xx=0
    if i<j:
      for k in range(d):
        xx += (x[i][k]-x[j][k])**2
      if xx == int(math.sqrt(xx))*int(math.sqrt(xx)):
        ans+=1
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>

using namespace std;

const int MAX_N = 4;

int main()
{
	char s[MAX_N];
	int cA = 0, cB = 0;
	
	for (int i = 0; i < 3; i++)
	{
		cin >> s[i];
		if (s[i] == 'A')
		{
			cA++;
		}
		else cB++;
	}
	
	if (cA == 3 || cB == 3)
	{
		cout << "No\n";
	}
	else cout << "Yes\n";
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  int N, W;
  cin >> N >> W;
  int maxi = 1e5 + 1;
  vector<int> dp(maxi, 1e9 + 7), nextdp(maxi, 1e9 + 7);
  dp[0] = 0;

  rep(i, 0, N) {
    int w, v;
    cin >> w >> v;
    rep(j, 0, maxi) {
      if (j < v)
        chmin(nextdp[j], dp[j]);
      else
        chmin(nextdp[j], dp[j - v] + w);
    }
    dp = nextdp;
  }

  repr(i, 0, maxi) {
    if (dp[i] <= W) {
      cout << i << endl;
      return 0;
    }
  }
}


Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
	static int maxn = 100 + 10;
	public static void main(String[] args) 
	{
		Scanner cin = new Scanner(System.in);
		int n=cin.nextInt();
		int k=cin.nextInt();
		int ans=0;
		while(n!=0)
		{
			n/=k;
			ans++;
		}
		System.out.println(ans);
	}
	
}

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


#define ll long long int
#define ld long double
#define mod 1000000007
#define big 1e18+10
#define small -big
#define pb push_back
#define endl "\n"


template <typename T>

void prarr(T a)
{
     cerr << "[ ";
     
     for(auto i : a){
         cerr << i << " ";
     }
     
     cerr << "]" << endl;
}


#define trace(...) _er(#__VA_ARGS__, __VA_ARGS__)

template <typename Arg1>

void _er(const char* name, Arg1&& arg1){
	cerr << "[" << name << " : " << arg1 << "]" << endl;
}

template <typename Arg1, typename... Args>

void _er(const char* names, Arg1&& arg1, Args&&... args){
    
	const char* comma = strchr(names + 1, ',');
	cerr << "[" ; cerr.write(names, comma - names) << " : " << arg1 << "] ";
	_er(comma+2, args...);
}





void solve() {
        
        ll x;
        cin >> x;
        
        if(x >= 30) {
                cout << "Yes" << endl;
        } else {
                cout << "No" << endl;
        }
      
        
        
}


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

    int t = 1;
    //cin >> t;

    for(int i = 1; i <= t; i++) {  
   
         solve();
    }


    return 0;
        
}


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

ll solve() {
    ll K, T, a, m = 0;
    cin >> K >> T;
    for ( int i = 0; i < T; i++ ) {
        cin >> a;
        m = max(m, a);
    }
    ll ans = m - 1 - (K - m);
    if ( ans < 0 ) ans = 0;
    return ans;
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
import fractions
a,b,c,d = map(int,input().split())
w = b-a

def lcm(n, h):
    return (n * h) // fractions.gcd(n, h)

def slove(x, y, z):
	return (x//y) + (x//z) - (x//lcm(y,z))

print(w -(slove(b,c,d) - slove(a-1,c,d)) +1 )

Measured memory_bytes: 5852
<?php
list($n) = ints();
$l = ints();
sort($l);
$ans = 0;
for ($i = 0; $i < 2 * $n; $i += 2) $ans += $l[$i];
echo $ans;
function ints()
{
    return array_map('intval', explode(' ', trim(fgets(STDIN))));
}


Measured memory_bytes: 16316
N = int(input())
A = [int(a) for a in input().split()]
mod = 10 ** 9 + 7
ans = 0
#TLE
'''
for i in range(N - 1):
  for j in range(i+1, N):
    a = A[i] % mod
    b = A[j] % mod
    ans += (a * b) % mod
    ans = ans % mod
'''
tot = 0
for i in range(N):
  A[i] %= mod
  tot += A[i]
  tot %= mod
for i in range(N-1):
  tot -= A[i]
  ans += (A[i] * tot) % mod
  ans %= mod
print(ans)

Measured memory_bytes: 30740
import sys
from functools import lru_cache

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N, *A = map(int, read().split())

a, b = A[:2]
xor = 0
for x in A[2:]:
    xor ^= x

INF = 10**13

@lru_cache(None)
def F(a, b, xor):
    if (a & 1) ^ (b & 1) != (xor & 1):
        return INF
    if xor == 0:
        return INF if a < b else (a - b) // 2
    # 1の位を放置
    x = 2 * F(a // 2, b // 2, xor // 2)
    # 1の位を移動
    y = 2 * F((a - 1) // 2, (b + 1) // 2, xor // 2) + 1
    x = min(x, y)
    if x >= INF:
        x = INF
    return x

x = F(a, b, xor)
if x >= a:
    x = -1
print(x)

Measured memory_bytes: 67364
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>
#include <utility>
#include <tuple>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
using namespace std;
using ll = long long int;
using P = pair<ll, ll>;

// clang-format off
#ifdef _DEBUG_
#define dump(...) do{ cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; PPPPP(__VA_ARGS__); cerr << endl; } while(false)
template<typename T> void PPPPP(T t) { cerr << t; }
template<typename T, typename... S> void PPPPP(T t, S... s) { cerr << t << ", "; PPPPP(s...); }
#else
#define dump(...) do{ } while(false)
#endif
template<typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template<typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }
template<typename T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template<typename T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }
template<typename T> void print(T a) { cout << a << endl; }
template<typename T, typename... Ts> void print(T a, Ts... ts) { cout << a << ' '; print(ts...); }
template<typename T> istream &operator,(istream &in, T &t) { return in >> t; }
// clang-format on

#include <array>
template<size_t N>
class INDEX {
    array<size_t, N> arr;

public:
    template<typename... T>
    INDEX(T... _arr)
        : arr({{static_cast<size_t>(_arr)...}}) {}
    template<typename... T>
    size_t operator()(T... _arr) {
        size_t position[] = {static_cast<size_t>(_arr)...};
        static_assert(N == size(position));
        size_t res = 0, width = 1;
        for (int i = N - 1; i >= 0; i--) {
            res += width * position[i];
            width *= arr[i];
        }
        return res;
    }
};
template<typename... T>
auto Index(T... args) {
    unsigned int arr[] = {static_cast<unsigned int>(args)...};
    constexpr size_t N = size(arr);
    return INDEX<N>(args...);
}
template<typename T, typename... Args>
auto make_v_flat(T init, Args... args) {
    return vector<T>((1 * ... * args), init);
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n, t;
    cin, n, t;
    vector<int> a(n), b(n);
    REP(i, 0, n) {
        cin, a[i], b[i];
    }

    auto dp = make_v_flat(0, n + 1, t + 1, 2);
    auto index = Index(n + 1, t + 1, 2);

    REP(i, 0, n) {
        REP(j, 0, t + 1) {
            REP(k, 0, 2) {
                chmax(dp[index(i + 1, j, k)], dp[index(i, j, k)]);
                chmax(dp[index(i + 1, j, k)], dp[index(i, j, k)]);

                if (j + a[i] <= t) {
                    chmax(dp[index(i + 1, j + a[i], k)], dp[index(i, j, k)] + b[i]);
                }
            }

            if (j + 1 <= t) {
                chmax(dp[index(i + 1, j + 1, 1)], dp[index(i, j, 0)] + b[i]);
            }
        }
    }

    int ans = 0;
    REP(j, 0, t + 1) {
        REP(k, 0, 2) {
            chmax(ans, dp[index(n, j, k)]);
        }
    }
    print(ans);
    return 0;
}


Measured memory_bytes: 73624
n = int(input())
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())

import math
ans = math.ceil(n/a)
if a<=b:
    ans += 1
else:
    ans = math.ceil(n/b)+1
if b<=c:
    ans += 1
else:
    ans = math.ceil(n/min(c,a))+2
if c<=d:
    ans += 1
else:
    ans = math.ceil(n/min(d,b,a))+3
if d<=e:
    ans += 1
else:
    ans = math.ceil(n/min(e,a,b,c))+4
print(ans)

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

const ll MAXN = 200000;
const ll INF = 1001001001;
const ll MOD = 1000000007;

ll N, ans=0, tmp=0;
vector<ll> A;

signed main(){
    cin >> N;
    A.resize(N+1,0);
    for(int i=1;i<=100;i++) {
        for(int j=1;j<=100;j++) {
            for(int l=1;l<=100;l++) {
                tmp = i*i+j*j+l*l+i*j+j*l+l*i;
                if(tmp<=N) A[tmp]++;
            }
        }
    }
    for(int i=1;i<=N;i++) {
        cout << A[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 3632
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <utility>
#include <cstdio>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#define my_abs(x) ((x) < 0 ? -(x) : (x))
#define mp make_pair
#define pb push_back
#define X first
#define Y second
using namespace std; 
typedef long long ll; 
int main()
{
	// freopen("AGC020-A.in", "r", stdin); 
	int n, x, y; 
	scanf("%d%d%d", &n, &x, &y); 
	puts(y - x & 1 ? "Borys" : "Alice");
	return 0; 
}


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

using ld = long double;

signed main(){
  int n;cin>>n;
  vector<ld> x(n),y(n);
  for(int i=0;i<n;i++)cin>>x[i]>>y[i];
  vector<int> v(n);
  for(int i=0;i<n;i++)v[i]=i;
  ld ans=0;
  do{
    for(int i=1;i<n;i++){
      ans+=sqrt((x[v[i]]-x[v[i-1]])*(x[v[i]]-x[v[i-1]])+(y[v[i]]-y[v[i-1]])*(y[v[i]]-y[v[i-1]]));
    }
  }while (std::next_permutation(v.begin(), v.end()));
  for(ld i=1;i<=n;i++)ans/=i;
  cout<<fixed<<setprecision(12)<<ans<<endl;
}


Measured memory_bytes: 256
#http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_8_A
#????????????

def insert(root, insert_node):
    focus_node = root
    parent = None
    while not focus_node == None:
        parent = focus_node
        if focus_node["data"]  > insert_node["data"]:
            focus_node = focus_node["left"]
        else:
            focus_node = focus_node["right"]

    if parent["data"] > insert_node["data"]:
        parent["left"] = insert_node
    else:
        parent["right"] = insert_node

def get_preorder(node):
    if node == None:
        return []
    r = []
    r.append(str(node["data"]))
    r.extend(get_preorder(node["left"]))
    r.extend(get_preorder(node["right"]))

    return r
    
def get_inorder(node):
    if node == None:
        return []
    r = []
    r.extend(get_inorder(node["left"]))
    r.append(str(node["data"]))
    r.extend(get_inorder(node["right"]))

    return r
def print_tree(root):
    print(" " + " ".join(get_inorder(root)))
    print(" " + " ".join(get_preorder(root)))
    
def main():
    
    n_line = int(input())
    input_list = [input() for i in range(n_line)]
    root = {"left":None, "right": None, "data":int(input_list[0].split()[1])}

    for line in input_list[1:]:
        if line == "print":
            print_tree(root)
        else:
            node = {"left":None, "right": None, "data":int(line.split()[1])}
            insert(root, node)

if __name__ == "__main__":
    main()

Measured memory_bytes: 248312
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;
 
int main() {
  int n;
  cin >> n;
  
  vector<int> v(n);
  for (int i=0;i<n;i++){
    cin >> v[i];
  }
  std::sort(v.begin(),v.end());  
  int max = *std::max_element(v.begin(), v.end());
  v.erase(std::max_element(v.begin(), v.end()));
  int sum = std::accumulate(v.begin(), v.end(), 0);
  
  if(sum>max){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
module global_variables
  integer,parameter::max_n = 50
  integer s(0:max_n,0:max_n,0:max_n)
end module global_variables
program main
  use global_variables
  implicit none
  integer a,b,c,x,res
  integer i,j,k
  read *, a,b,c,x
  s = 0
  forall (i=0:a,j=0:b,k=0:c) s(i,j,k) = i*500 + j*100 + k*50
  print '(i0)', count(s == x)
end program main


Measured memory_bytes: 768
#include<cstdio>
using namespace std;
int main(){
  int n,m[9][9];
  char c[9][9];
  scanf("%d",&n);
  for(int i=0;i<n;i++){
    
    for(int j=0;j<9;j++){
      for(int k=0;k<9;k++){
	scanf("%d",&m[j][k]);
	c[j][k] = ' ';
      }
    }
    int dx[9] = {0,1,2,0,1,2,0,1,2};
    int dy[9] = {0,0,0,1,1,1,2,2,2};
    for(int l=0;l<9;l++){
      for(int j=0;j<8;j++){
	for(int k = j+1;k<9;k++){
	  if(m[l][j] == m[l][k]){
	    c[l][j] = '*';
	    c[l][k] = '*';
	  }
	  if(m[j][l] == m[k][l]){
	    c[j][l] = '*';
	    c[k][l] = '*';
	  }
	}
      }
    }
    
    for(int j=0;j<=6;j+=3){
      for(int k=0;k<=6;k+=3){
	for(int l=0;l<8;l++){
	  for(int o=l+1;o<9;o++){
	    if(m[j+ dy[l]][k+ dx[l]] == m[j+ dy[o]][k+ dx[o]]){
	      c[j+ dy[l]][k+ dx[l]] = '*';
	      c[j+ dy[o]][k+ dx[o]] = '*';
	    }
	  }
	}
      }
    }

    for(int j=0;j<9;j++){
      for(int k=0;k<9;k++){
	printf("%c%d",c[j][k],m[j][k]);
      }
      putchar('\n');
    }
    if(i != n-1) putchar('\n');
  }
  return (0);
}

Measured memory_bytes: 2740
#include <iostream>
#include <vector>

using namespace std;

const int INFTY = 1001001001;

int main()
{
    int N, M, L;
    cin >> N >> M >> L;
    vector<vector<int>> dist(N, vector<int>(N, INFTY));

    int a, b, c;
    for (int i = 0; i < M; ++i)
    {
        cin >> a >> b >> c;
        --a;
        --b;
        dist[a][b] = dist[b][a] = c;
    }
    for (int i = 0; i < N; ++i)
    {
        dist[i][i] = 0;
    }

    for (int k = 0; k < N; ++k)
    {
        for (int i = 0; i < N; ++i)
        {
            //if(dist[i][k] == INFTY) continue;
            for (int j = 0; j < N; ++j)
            {
                dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
                //if(dist[j][k] == INFTY) continue;
            }
        }
    }

    int Q;
    cin >> Q;
    vector<vector<int>> dist2(N, vector<int>(N, INFTY));
    for(int i=0;i<N;++i){
        for(int j=0;j<N;++j){
            if(dist[i][j] <= L) dist2[i][j] = 1;
        }
    }

    for (int k = 0; k < N; ++k)
    {
        for (int i = 0; i < N; ++i)
        {
            //if(dist[i][k] == INFTY) continue;
            for (int j = 0; j < N; ++j)
            {
                dist2[i][j] = min(dist2[i][j], dist2[i][k] + dist2[k][j]);
                //if(dist[j][k] == INFTY) continue;
            }
        }
    }

    int s, t, ans;
    for(int q=0;q<Q;++q){
        cin >> s >> t;
        --s;
        --t;
        ans = dist2[s][t] != INFTY ? dist2[s][t] - 1 : -1;
        cout << ans << endl;
    }
}


Measured memory_bytes: 1280
#include <iostream>

using namespace std;

int main(void) {
	int point[2][5];
	
	for(int i = 0; i < 2; i++) {
		for(int j = 0; j < 4; j++) {
		cin >> point[i][j];
		}
		point[i][4] = 0;
	}
	
	for(int i = 0; i < 2; i++) {
		for(int j = 0; j < 4; j++) {
			point[i][4] += point[i][j];
		}
	}
	
	if(point[0][4] >= point[1][4]) {
		cout << point[0][4] << endl;
	} else {
		cout << point[1][4] << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
typedef int q;
typedef double w;
typedef string s;
int main(){
    s a,b,c,d,l;
    cin>>a;
    b="A";
    c="T";
    d="C";
    l="G";
if(a==b){cout<<c;}
if(a==c){cout<<b;}
if(a==d){cout<<l;}
if(a==l){cout<<d;}
return 0;}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <numeric>
#include <algorithm>
#include <deque>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <iomanip>
#include <map>
#include <stack>
#include <queue>
#include <functional>
#include <climits>
#include <numeric>
#include <bitset>
#include <random>
#include <tuple>
#include <initializer_list>
#include <fstream>
#include <cctype>
#include <string>
bool may_yymm(const std::string& str) {
	const auto mm = std::stoi(str.substr(2));
	return 1 <= mm && mm <= 12;
}
bool may_mmyy(const std::string& str) {
	const auto mm = std::stoi(str.substr(0, 2));
	return 1 <= mm && mm <= 12;
}
int main() {
	std::string str; std::cin >> str;
	if (may_yymm(str) && may_mmyy(str)) {
		std::cout << "AMBIGUOUS\n";
	}
	else if (may_yymm(str)) {
		std::cout << "YYMM\n";
	}
	else if (may_mmyy(str)) {
		std::cout << "MMYY\n";
	}
	else {
		std::cout << "NA\n";
	}
}


Measured memory_bytes: 384
#!/usr/bin/env python3
import sys
INF = float("inf")


def solve(s: str):
    N = len(s)
    if (s[0] == s[-1]) ^ (N % 2 == 0):
        print("Second")
    else:
        print("First")

    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    s = next(tokens)  # type: str
    solve(s)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3316
using System;
using System.Linq;

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int[] input_int = input.Select(int.Parse).ToArray();
            //int[] sorted_int = input.OrderBy();
            Array.Sort(input_int);

            if(
                input_int[0] == 5 &&
                input_int[1] == 5 &&
                input_int[2] == 7
                )
                {
                    Console.WriteLine("YES");
                }
                else
                {
                    Console.WriteLine("NO");
                }
        }
    }
}


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

int main(){
    int n, a, b, c, d;
    string s;
    cin >> n >> a >> b >> c >> d >> s;
    s = "#" + s + "#";
    auto can_reach = [&](int start, int end) {
        for ( int i = start; i + 1 <= end; ++i ) {
            if ( s[i] == '#' && s[i+1] == '#' ) {
                return false;
            }
        }
        return true;
    };
    if (!can_reach(a, c) || !can_reach(b, d)) {
        cout << "No" << endl;
        return 0;
    }
    if ( c > d ) {
        bool snuke_can_over = false;
        for ( int i = b; i <= d; ++i ) {
            if ( s[i-1] == '.' && s[i] == '.' && s[i+1] == '.' ) {
                snuke_can_over = true;
            }
        }
        if (!snuke_can_over) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 772
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N = 2e5 + 5;
const ll MOD = 1e9 + 7;
#define all(x) x.begin(),x.end()
#define pii pair<int,int>
#define pis pair<ll,string>
#define F first
#define S second
#define LCM(a,b) ((a*b)/__gcd(a,b))
#define inf 1e15
#define test ll cse;cin>>cse;for(ll _i=1;_i<=cse;_i++)
#define PI 3.14159265
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const double EPS = 1E-9;
typedef vector< vector<double> > matrix;
typedef vector< vector<int> > array_2D;
typedef pair<int, pair<int, int> > ppi;
typedef vector<int> vi;

vector< int > adj[N];

ll h[N];
int main() {
    int n, m;

    cin >> n >> m;
    for(int i = 1; i <= n; i++) cin >> h[i];

    int u, v;
    for(int i = 1; i <= m; i++) {
        cin >> u >> v;

        adj[u].push_back(v);
        adj[v].push_back(u);
    }


    int cnt = 0;
    for(int i = 1; i <= n; i++) {
        bool f = true;

        for(auto &v: adj[i]) {
            if(h[v] >= h[i]) {
                f = false;
                break;
            }
        }

        if(f) {
            // cout << i << "\n";
            cnt++;
        }
    }

    cout << cnt << "\n";
    return 0;
}

Measured memory_bytes: 11864
#include<bits/stdc++.h>
long long n,p;
int i,ans=1,j;
int main(){
	scanf("%lld%lld",&n,&p);
	if(n==1)return printf("%lld\n",p),0;
	for(i=2;1ll*i*i<=p;++i)if(p%i==0){
		for(j=0;++j,p/=i,p%i==0;);
		for(;j>=n;j-=n,ans*=i);
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n,x,h,k,b;
int main() {
	//freopen("a.inp", "r", stdin);
	scanf("%d", &n);
	for(int i=0;i<n;i++) {
		scanf("%d", &x);
		if (x%4==0) {
			b++;
		}
		else if (x%2==0) {
			h ++;
		} else k ++;
	}
	if (h==0) {
		if (b >= k-1) cout<< "Yes" ;
		else cout<< "No";
	} else {
		if (b>=k) cout<< "Yes" ;
		else cout<< "No";
	}
}

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

int main(){
    int n,k;
    long ans=0;
    scanf("%d %d\n",&n,&k);
    long h[n];
    for(int i=0;i<n;i++){
        scanf("%ld",&h[i]);
    }

    sort(h,h+n,greater<long>());
    if(k>=n) ans=0;
    else{
    for(int i=k;i<n;i++) ans+=h[i];
    }
    printf("%ld\n",ans);
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int N = 2e5+5;
int n, a[N], b[N];
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> n;
    for(int i = 0; i < n; i++) {
        cin >> a[i] >> b[i];
    }
    sort(a, a+n);
    sort(b, b+n);
    reverse(b, b+n);
    if(n & 1) {
        cout << b[n/2]-a[n/2]+1;
    }
    else {
        pair<ll, ll> le = {a[n/2 - 1], b[n/2]};
        pair<ll, ll> re = {a[n/2], b[n/2 - 1]};
        cout << (le.second+re.second)-(le.first+re.first)+1;
    }
    return 0;
}

Measured memory_bytes: 5172
#include<bits/stdc++.h>
#define ll long long
using namespace std;
struct node {
	ll b,l,r,sum;
}p[100005];
ll n,x,tot=0,s[100005];
ll read() {
	char c=getchar(); ll x=0;
	while (c<'0' || c>'9') c=getchar();
	while (c>='0' && c<='9') {
		x=x*10+c-'0';
		c=getchar();
	}
	return x;
}
bool cmp(node x,node y) {
	return x.sum>y.sum;
}
bool check(ll t) {
	ll a=t/x,b=t%x;
	if (b>0) {
		for (ll i=1; i<=n; i++) {
			ll tmp=tot;
				tmp-=min(b,p[i].b)*p[i].l+max(b-p[i].b,0LL)*p[i].r;
			if (i<=a) tmp-=s[a+1]-p[i].sum;
			else tmp-=s[a];
			if (tmp<=0) return true;
		}	
	}
	else return tot<=s[a];
	return false;
}
int main() {
	n=read(),x=read();
	for (ll i=1; i<=n; i++) {
		p[i].b=read();
		p[i].l=read();
		p[i].r=read();
		tot+=1LL*p[i].b*p[i].l;
		p[i].sum=1LL*p[i].b*p[i].l+1LL*(x-p[i].b)*p[i].r;
	} 
	sort(p+1,p+n+1,cmp);
	for (ll i=1; i<=n; i++) s[i]=s[i-1]+p[i].sum; 
	ll l=0,r=1LL*n*x,mid;
	while (r-l>3) {
		mid=(l+r)/2;
		if (check(mid)) r=mid;
		else l=mid;
	}
	for (ll i=l; i<=r; i++) {
		if (check(i)) {
			printf("%lld\n", i);
			break;
		}
	}
	return 0;
}

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

namespace ABC
{
    class Program
    {
        static void Main(string[] args)
        {
            ABC124_B();
        }

        static void ABC124_B()
        {
            var N = int.Parse(Console.ReadLine());
            var H = Console.ReadLine().Split(' ').Select(int.Parse).ToList();

            var count = 1;
            for (var i = 1; i < N; i++)
            {
                var ok = true;
                for (var j = 0; j <= i; j++)
                {
                    if (H[j] > H[i])
                        ok = false;
                }
                if (ok)
                    count++;
            }
            Console.WriteLine(count);
        }
    }
}

Measured memory_bytes: 11220
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <iomanip>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<long double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

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

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }
#define INF 1LL<<60

int main() {
    int H, W;
    cin >> H >> W;
    vector<string> maze(H);
    REP(i, H) cin >> maze[i];
    int ans = 0;
    REP(i, H) {
        REP(j, W) {
            // (i, j)を始点としてBFS
            if(maze[i][j] == '#') continue;
            vector< vector<int> > dist(H, vector<int>(W, -1));
            queue<P> que;
            que.push(make_pair(i, j));
            dist[i][j] = 0;
            vector<P> drs = {make_pair(-1, 0), make_pair(1, 0), make_pair(0, 1), make_pair(0, -1)};
            while(!que.empty()) {
                P front = que.front();
                que.pop();

                for(P dr: drs) {
                    int y = front.first + dr.first;
                    int x = front.second + dr.second;
                    if(y < 0 || y >= H || x < 0 || x >= W || maze[y][x] == '#') continue;
                    if(dist[y][x] == -1) {
                        dist[y][x] = dist[front.first][front.second] + 1;
                        que.push(make_pair(y, x));
                    }
                }
            }

            REP(y, H) REP(x, W) ans = max(ans, dist[y][x]);

        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3620
import java.math.BigInteger;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();

		boolean[] chk = new boolean[10];
		Arrays.fill(chk, true);
		for (int i = 0; i < K; i++) {
			int a = sc.nextInt();
			chk[a] = false;
		}

		int ans = N;
		while (ans <= 1000000) {
			int i = ans;
			boolean flg = true;
			while (true) {
				int mod = i % 10;
				i = i / 10;
				if (chk[mod] == false) {
					flg = false;
					break;
				} else if (i == 0) {
					break;
				}
			}
			if (flg) {
				break;
			}
			ans++;
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 9552
import java.util.Scanner;

class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		Friend f;
		int n,nt;
		
		while(true){
			n = sc.nextInt();
			if(n == 0){
				break;
			}
			f = new Friend(n);
			
			for(int i=0;i<12;i++){
				f.setSavings(sc.nextInt(),sc.nextInt());
			}
			nt = f.getNextTrip();
			if(nt > 0){
				System.out.println(nt);
			}else{
				System.out.println("NA");
			}
		}
	}
}

class Friend{
	int monthCount;
	int[] savings;
	int money;
	
	Friend(int money){
		monthCount = 0;
		savings = new int[12];
		this.money = money;
	}
	
	public void setSavings(int m,int n){
		savings[monthCount] = m-n;
		monthCount++;
	}
	
	private int checkMoney(){
		for(int i=0;i<12;i++){
			money -= savings[i];
			if(money <= 0){
				return i+1;
			}
		}
		
		return 0;
	}
	
	public int getNextTrip(){
		return checkMoney();
	}
}

Measured memory_bytes: 34592
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main(){
	int N,ans=0;
	string S[200000];
	cin>>N;
	for(int i=0;i<N;i++)cin>>S[i];
	sort(S,S+N);
	for(int i=0;i<N;i++){
		if(i==0||S[i]!=S[i-1])ans++;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 9884
#include <iostream>
#include <cstdint>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int, int>> vpii;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
typedef vector<vector<ll>> vvll;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define irep(it, stl) for (auto it = stl.begin(); it != stl.end(); it++)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define mes(a) cout << (a) << endl
#define dmes(a, b) cout << (a) << " " << (b) << endl
#define re0 return 0
#define mp(p, q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define rSort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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;
}
struct io
{
    io()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
};
const int INF = INT_MAX;
const ll LLINF = 1LL << 60;
const ll MOD = 1000000007;
const double EPS = 1e-9;




signed main(void)
{
    ll n;
    cin >> n;
    ll a;
    ll r = 0;
    ll c = 0;
    
    rep(i, n) {
        cin >> a;
        if (a != c+1) {
            r++;
        } else {
            c++;
        }
    }
    if (c == 0) {
        mes(-1);
        re0;
    }
    mes(r);
}

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

long long solve(int arr[], int n) {
	long long dp[n + 1];
	dp[0] = 0;
	for (int i = 1; i < n; i++) {
		long long op1 = abs(arr[i - 1] - arr[i]) + dp[i - 1];
		long long op2 = (i == 1) ? INT_MAX : abs(arr[i - 2] - arr[i]) + dp[i - 2];
		dp[i] = min(op1, op2);
	}
	return dp[n - 1];



}
int main() {


#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);

	freopen("output.txt", "w", stdout);
#endif

	int arr[100000];
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> arr[i];
	}
	cout << solve(arr, n);


}

Measured memory_bytes: 4740
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
typedef long long int ll;

using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;

ll extgcd(ll a, ll b, ll &x, ll &y) {
  ll g = a; x = 1; y = 0;
  if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x;
  return g;
}
ll gcd(ll a, ll b) { ll x, y; return extgcd(a, b, x, y);}

class llm{
	ll n;
public:
	llm(){n = 0;}
	llm(ll n){this->n = (n >= 0) ? (n % MOD) : (MOD - 1 - (-n-1 % MOD));}
	operator ll() const {return n;}
	llm operator+(const llm &y) const{ return llm((ll)*this + (ll)y);}
	llm operator+=(const llm &y) { *this = *this + y; return *this;}
	llm operator-(const llm &y) const{ return llm((ll)*this - (ll)y);}
	llm operator-=(const llm &y) { *this = *this - y; return *this;}
	llm operator-() const{ return llm(0) - *this;}
	llm operator*(const llm &y) const{ return llm((ll)*this * (ll)y);}
	llm operator*=(const llm &y) { *this = *this * y; return *this;}
	llm operator/(const llm &y) const{ return *this * y.inv();}
	llm operator/=(const llm &y) { *this = *this / y; return *this;}
	llm inv() const{
		ll x, y;
		if (extgcd(n, MOD, x, y) == 1) return llm(x);
  		return llm(0); // unsolvable
	}
	friend istream& operator >> (istream& os, llm& x);
	friend ostream& operator << (ostream& os, const llm& x);
};
istream& operator >> (istream& is, llm& x){ll n; is >> n; x = llm(n); return is;}
ostream& operator << (ostream& os, const llm& x){os << (ll)x; return os;}

template<typename T> T comb(ll n, ll k){
	T ret = 1;
	for(ll i=1;i<=k;i++) ret = ret * T(n - k + i) / T(i);
	return ret;
}

ll N;
int a[512][512];

void solve(vector<int> &idx, int start){
	int m = idx.size();
	if (m <= 1) return;
	/*if (m%2){
		vector<int> rest;
		for(int i=1;i<m;i++){
			a[idx[0]][idx[i]] = start;
			a[idx[i]][idx[0]] = start;
			rest.pb(idx[i]);			
		}
		solve(rest, start+1);
	}else{*/
		vector<int> p, q;
		for(int i=0;i<m;i++){
			if (i%2) q.pb(idx[i]); else p.pb(idx[i]); 
		}
		for(auto i : p){
			for (auto j : q){
				a[i][j] = start;
				a[j][i] = start;
			}
		}
		solve(p, start+1);
		solve(q, start+1);
	//}
}


int main(void){
	cin >> N;

	vector<int> whole;
	for(int i=0;i<N;i++) whole.pb(i);
	solve(whole, 1);

	for(int i=0;i+1<N;i++){
		for(int j=i+1;j<N;j++){
			cout << a[i][j];
			if (j+1<N) cout << " ";
		}
		cout << endl;
	}

    return 0;
}


Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e5+5;
int n,tot,si[N],fa[N],f[N],head[N],nex[N<<1],to[N<<1],a[N];
void add(int u,int v){to[++tot]=v;nex[tot]=head[u];head[u]=tot;}
vector<int>v[N];
ll ans[N],s[N];
int top,st[N];
void dfs1(int u,int p)
{
    si[u]=1;fa[u]=p;
    for(int i=head[u];i;i=nex[i])
    {
        int v=to[i];if(v==p)continue;
        dfs1(v,u);
        si[u]+=si[v];
    }
}
void dfs2(int u,int p)
{
    if(u==1||a[u]==a[p]) f[u]=0;
    else
    {
        f[u]=si[u];
        if(v[a[u]].size())
        {
            f[st[v[a[u]].back()+1]]-=si[u];
        }
    }
    st[++top]=u;
    v[a[u]].push_back(top);
    for(int i=head[u];i;i=nex[i])
    {
        int v=to[i];if(v==p)continue;
        dfs2(v,u);
    }
    top--;
    v[a[u]].pop_back();
}
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
        scanf("%d",&a[i]),s[a[i]]--,s[i]+=n;
    for(int i=1;i<n;i++)
    {
        int u,v;scanf("%d%d",&u,&v);add(u,v);add(v,u);
    }
    dfs1(1,0);
    dfs2(1,0);
    for(int i=2;i<=n;i++)
    {
        if(f[i]==0) continue;
        int c=a[fa[i]];
        //cout<<"F "<<f[i]<<' '<<c<<' '<<s[c]<<endl;
        s[c]-=f[i];
        ans[c]+=(ll)f[i]*(f[i]-1)/2+f[i];
    }
    for(int i=1;i<=n;i++)
    {
        ans[i]+=(ll)s[i]*(s[i]-1)/2+s[i];
        printf("%lld\n",(ll)n*(n-1)/2+n-ans[i]);
    }
}



Measured memory_bytes: 38884
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <numeric>
#include <cmath>

#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
using P = pair<ll, ll>;

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

const ll MOD = 1000000007;
const int INF = 1<<30;
//const ll INF = (ll)1e18 + 1;

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


Measured memory_bytes: 256
import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;
import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;

// Sun and Moon
// 2013/03/23
public class Main{
	Scanner sc=new Scanner(System.in);

	long INF=1L<<60;

	int n;
	long[] as, bs;

	void run() throws Exception{
		n=sc.nextInt();
		as=new long[n];
		bs=new long[n];
		for(int i=0; i<n; i++){
			bs[i]=sc.nextLong();
			as[i]=sc.nextLong();
		}
		solve();
	}

	void solve() throws Exception{
		int m=5;

		long[] ps=new long[m];
		ps[0]=BigInteger.valueOf((int)1e3).nextProbablePrime().longValue();
		for(int i=1; i<m; i++){
			ps[i]=BigInteger.valueOf(ps[i-1]+1).nextProbablePrime().longValue();
		}

		for(int x=1; x<=1000; x++){
			int mod1=(int)ps[0], mod2=(int)ps[1];
			if(f(x, mod1)==0&&df(x, mod1)==0&&f(x, mod2)==0&&df(x, mod2)==0){
				println("Yes "+x);
				return;
			}
		}

		long min=INF;
		long[] A=new long[m], B=new long[m];
		fill(A, 1);

		@SuppressWarnings("unchecked")
		ArrayList<Integer>[] list=new ArrayList[m];
		for(int i=0; i<m; i++){
			list[i]=candidate((int)ps[i]);
		}
		for(int x0 : list[0]){
			for(int x1 : list[1]){
				for(int x2 : list[2]){
					for(int x3 : list[3]){
						for(int x4 : list[4]){
							B[0]=x0;
							B[1]=x1;
							B[2]=x2;
							B[3]=x3;
							B[4]=x4;
							long res=linearCongruence(A, B, ps);
							if(res!=-1&&res>0){
								min=min(min, res);
							}
						}
					}
				}
			}
		}
		if(min<INF){
			println("Yes "+min);
		}else{
			println("No");
		}
	}

	ArrayList<Integer> candidate(int p){
		ArrayList<Integer> list=new ArrayList<Integer>();
		for(int i=0; i<p; i++){
			if(f(i, p)==0&&df(i, p)==0){
				list.add(i);
			}
		}
		return list;
	}

	long linearCongruence(long[] A, long[] B, long[] M){
		long x=0, m=1;
		for(int i=0; i<A.length; i++){
			long a=A[i]*m, b=B[i]-A[i]*x, d=gcd(M[i], a);
			if(b%d!=0)
				return -1;
			x+=m*(mulMod(b/d, invMod(a/d, M[i]/d), (M[i]/d)));
			m*=M[i]/d;
		}
		return x%m;
	}

	long powMod(long x, long k, int mod){
		long res=1;
		for(; k!=0; k>>>=1){
			if((k&1)==1){
				res=res*x%mod;
			}
			x=x*x%mod;
		}
		return res;
	}

	long gcd(long a, long b){
		return a==0?b:gcd(b%a, a);
	}

	long invMod(long a, long mod){
		return powMod(a, mod-2, mod);
	}

	long mulMod(long x, long y, long mod){
		long res=0;
		for(; y!=0; y>>>=1){
			if((y&1)==1){
				res=(res+x)%mod;
			}
			x=(x+x)%mod;
		}
		return res;
	}

	long powMod(long x, long k, long mod){
		long res=1;
		for(; k!=0; k>>>=1){
			if((k&1)==1){
				res=mulMod(res, x, mod);
			}
			x=mulMod(x, x, mod);
		}
		return res;
	}

	long f(long x, int mod){
		long val=0;
		for(int i=0; i<n; i++){
			val=(val+as[i]%mod*powMod(x, bs[i], mod)%mod)%mod;
		}
		return val;
	}

	long df(long x, int mod){
		long val=0;
		for(int i=0; i<n; i++){
			if(bs[i]>0){
				val=(val+bs[i]%mod*as[i]%mod*powMod(x, bs[i]-1, mod)%mod)%mod;
			}
		}
		return val;
	}

	void println(String s){
		System.out.println(s);
	}

	public static void main(String[] args) throws Exception{
		new Main().run();
	}
}

Measured memory_bytes: 27036