akhauriyash/Code-Regression huggingface dataset:
# -*- coding: utf-8 -*-
import sys
from fractions import gcd

"""
問題文の式から、オイラーの定理
	a^{\phi(n)} = 1 mod n

よって、\phi(n) の最小公倍数を求めればよい
"""

def lcm(a, b):
    return a * b / gcd(a, b)

def interval(ax, mx):
	p = 1
	cnt = 0
	while True:
		p = (p * ax) % mx
		cnt += 1
		if p == 1:
			return cnt

for line in sys.stdin:
	dset = map(int, line.split())
	if not any(dset):
		break
	a1, m1, a2, m2, a3, m3 = dset
	e = [interval(a1, m1), interval(a2, m2), interval(a3, m3)]
	# 3つの循環の最小公倍数を求める
	e.sort(reverse=True)
	print reduce(lcm, e)

Measured memory_bytes: 5880
#include<stdio.h>
 
int main(void)
{
    int i;
    char ch;
    char str[1200];
    for(i=0;i<1200;i++){
        scanf("%c",&ch);
        if(65<=ch && ch<=90) ch+=32;
        else if(97<=ch && ch<=122) ch-=32;
        str[i]=ch;
        if(ch=='\n'){
            str[i+1]='\0';
            break;
        }
    }
    printf("%s",str);
    return 0;   
}   

Measured memory_bytes: 536
import java.util.Scanner;

class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int m = scan.nextInt();
        while (n != 0 || m != 0) {

            int toy[] = new int[n];
            for (int i = 0; i < n; i++) {
                toy[i] = scan.nextInt();
            }
            int max = 0;
            for (int d = 0; d < n; d++) {
                for (int g = 0; g < n; g++) {
                    if (d != g) {
                        int h = toy[d] + toy[g];
                        if (max < h && m >= h) {
                            max = h;

                        }
                    }
                }
            }
            if (max == 0) {
                System.out.println("NONE");
            } else {
                System.out.println(max);

            }
            n = scan.nextInt();
            m = scan.nextInt();

        }
    }
}



Measured memory_bytes: 51552
// 6/20 解き直し
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); ++i)

const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};

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

    combination comb(1000000);

    // if (n <= k + 1) {
    //     cout << comb(n + n - 1, n-1) << endl;
    // } else {
    //     // k < n - 1
    //     // cout << comb(n + k + 1, n-1) << endl;
    //     mint res = 0;

    //     // n個からi個の部屋の人が動く時
    //     for (int i = 2; i <= k + 1; i++) {
    //         res += comb(n, i) * comb(i+i-1, i-1);
    //     }

    //     cout << res.x << endl;
    // }

    mint res = 0;

    int zero = min(k, n-1);

    for (int i = 0; i <= k; i++) {
        // n人をn-i個の部屋に分ける
        // res += comb(n, i) * comb(n+n-i-1, n-i-1);
        res += comb(n, i) * comb(n-1, n-i-1);
    }

    cout << res.x << endl;
}

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

int main() {
    int n, m, c;
    cin >> n >> m >> c;
    vector<int> b(m);
    vector<vector<int>> a(n, vector<int>(m));
    int ans = 0;
    rep(i, m) cin >> b[i];
    rep(i, n) {
        int tmp = 0;
        rep(j, m) {
            cin >> a[i][j];
            tmp += b[j] * a[i][j];
        }
        if(tmp > -c) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import sys
from math import ceil, floor
from collections import deque, Counter, defaultdict
from fractions import gcd
from bisect import bisect_right
input = lambda: sys.stdin.readline().rstrip()


def eprint(s):
    sys.stderr.write('DEBUG: {}'.format(s))
    return


def main():
    n = int(input())
    Ls = list(map(int, input().split()))
    Ls.sort()
    cnt = 0
    for i in range(0,n-2):
        for j in range(i+1,n-1):
            #k以下なら良い
            k =  Ls[i] + Ls[j] -1
            # bisect_right(Ls, k)個の要素が左にある
            # 答え: bisect_right(Ls, k) - j
            cnt += max(bisect_right(Ls, k) - j-1, 0)
            # print(Ls, Ls[i],Ls[j],k, bisect_right(Ls,k)-j-1)
            #012
    print(cnt)
            

if __name__ == '__main__':
    main()

Measured memory_bytes: 69276
import sys
input = sys.stdin.readline
def main():
    N,M = map(int, input().split())
    A = list(map(int, input().split()))
    A.sort(reverse=True)
    th = (1 / (4*M)) * sum(A)
    ans = "Yes"
    for i in range(M):
        if A[i] < th:
            ans = "No"
            break
    print(ans)
if __name__ == "__main__":
    main()

Measured memory_bytes: 38460
A = []
for _ in range(3):
    A += list(map(int, input().split()))
C = [False for _ in range(9)]
N = int(input())

for _ in range(N):
    b = int(input())
    for i in range(9):
        if b == A[i]:
            C[i] = True
            break

bingo = False
for i in range(3):
    if C[i * 3] and C[i * 3 + 1] and C[i * 3 + 2]:
        bingo = True

    if C[i] and C[i + 3] and C[i + 6]:
        bingo = True

if C[0] and C[4] and C[8]:
    bingo = True

if C[2] and C[4] and C[6]:
    bingo = True

if bingo:
    print('Yes')
else:
    print('No')


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

int main() {


	while(true){
		string str;
		cin >> str;
		// cout << str << endl;

		if(str.compare("-") == 0){
			break;
		}

		// シャッフル回数
		int n = 0;
		cin >> n;

		int str_siz = str.size();
		for(int i = 0; i < n ; i++){
			int sfl;
			cin >> sfl;
			str = str.substr(sfl, str_siz - sfl) + str.substr(0, sfl);
		}

		cout << str << endl;
	}
	return 0;
}


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

typedef long long int ll;
using namespace std;

ll gcd(ll a, ll b) {
    if (a > b) {
        return gcd(b, a);
    }
    // a <= b
    ll r = b % a;
    if (r == 0LL) {
        return a;
    } else {
        return gcd(r, a);
    }
}

vector<bool> is_primes(int n) {
    vector<bool> is_prime(n + 1, true);
    is_prime[0] = false;
    is_prime[1] = false;
    int indicator = 2;
    while ((indicator * indicator) <= n) {
        if (!is_prime[indicator]) {
            indicator++;
            continue;
        }
        for (int i = 2; (i * indicator) <= n; i++) {
            is_prime[i * indicator] = false;
        }
        indicator++;
    }
    return is_prime;
}

int sqrt_int(ll n) {
        ll n_sqrt;
        // obtain sqrt
        for (n_sqrt = 1LL; n_sqrt < n; n_sqrt++) {
            if (n_sqrt * n_sqrt > n) {
                break;
            }
        }
        return (int) n_sqrt;
}
            
int main(int argc, char const *argv[])
{    
    ll a, b;
    cin >> a >> b;
    ll g = gcd(a, b);
    if (g == 1LL) {
        cout << 1 << endl;
        return 0;
    } else {
        // cout << g << endl;
        ll n = g;

        // primes of 1 - sqrt(n)
        int n_sqrt = sqrt_int(n);
        // cout << n_sqrt << endl;
        vector<bool> is_prime = is_primes(n_sqrt);

        // i == 1
        int ans = 1;
        bool flag = true;
        while (flag) {
            flag = false;
            for (ll p = 2LL; p <= (ll) n_sqrt; p++) {
                if (!is_prime[p]) {
                    continue;
                }
                if (n % p == 0LL) {
                    ans++;
                    while (n % p == 0) {
                        n = n / p;
                    }
                    flag = true;
                }
            }
        }
        if (n != 1LL) {
            // n is prime
            ans++;
        }
        cout << ans << endl;
        return 0;
    }
}


Measured memory_bytes: 384
//bismillahir rahmanir rahim            //Author:Fayed Anik
 
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
//using namespace __gnu_pbds;
 
//#define         ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define         ll                          long  long
#define         lf                          double
#define         pb(x)                       push_back(x)
#define         ull                         unsigned long long
#define         sfl(a)                      scanf("%lld",&a)
#define         sf(a)                       scanf("%d",&a)
#define         pf(a)                       printf("%d\n",a)
#define         pfl(a)                      printf("%lld\n",a)
#define         FOR(x,n)                    for(ll x=1;x<=n;++x)
#define         pii                         pair< ll , ll >
#define         mp(a,b)                     make_pair(a,b)
#define         UNIQUE(v)                   v.resize(distance(v.begin(),unique(v.begin(),v.end())))
#define         mod                         1000000007
#define         INF                         2e18
#define         EPS                         1e-15
#define         f1                          first
#define         f2                          second
#define         all(v)                      v.begin(),v.end()
#define         PI                          acos(-1)
#define         printminusone               printf("-1\n")
#define         bug                         printf("bug")
#define         FILEIN                      freopen("in.txt","r",stdin)
#define         FILEOUT                     freopen("out.txt","w",stdout)
 
//ll SET(ll mask,ll pos){ return mask = (mask | (1ll<<pos)); }
//ll RESET(ll mask,ll pos){ return mask = mask & ~(1ll<<pos); }
//bool CHECK(ll mask,ll pos) { return (bool) (mask & (1ll<<pos)); }
//priority_queue <ll, vector<ll>, greater<ll> > pq;
//int dx[]={0,0,1,-1,1,1,-1,-1};
//int dy[]={1,-1,0,0,1,-1,1,-1};


int main(){
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);   
    int n;
    sf(n);
    if(n>=30) printf("Yes\n");
    else printf("No\n");
    return 0;
}

Measured memory_bytes: 3712
import sys
input = sys.stdin.readline
n, k = map(int, input().split())
a = list(map(int, input().split()))
b = {}
r = s = m = 0
for i in range(k):
  s += a[i]
  if a[i] in b:
    pass
  else:
    d = a[i]
    b[d] = (d+1)/2.0
m = s
    
for i in range(n-k):
  s = s - a[i] + a[k+i]
  if a[k+i] in b:
    pass
  else:
    d = a[k+i]
    b[d] = (d+1)/2.0
  if m < s:
    m = s
    r = i+1
    
sp = 0.0
for i in range(k):
  sp += b[a[r+i]]
print(sp)

Measured memory_bytes: 24404
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e16;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

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;
}
int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
ll factorial(ll n) {
  if (n == 1) {
    return 1;
  }
  ll ans = factorial(n-1);
  return ans*n;
}
ll gcd(ll a, ll b) {
  if (b == 0) return a;
  return gcd(b, a%b);
}
ll lcm(ll a, ll b) {
  return (a/gcd(a, b))*b;
}
bool is_prime(ll n) {
  for (ll i = 2; i*i <= n; i++) {
    if (n%i == 0) return false;
  }
  return n != 1;
}
ll mod_pow(ll x, ll n, ll mod) {
  if (n == 0) return 1;
  ll res = mod_pow(x*x%mod, n/2, mod);
  if (n & 1) res = res * x % mod;
  return res;
}

int main() {
  string s;
  cin >> s;
  vector <ll> v(s.size(), 0);
  rep(i, s.size()) {
    if (s.at(i) == 'W') v.at(i) = 1;
  }
  rep(i, s.size()-1) v.at(i+1) += v.at(i);
  ll res = 0;
  rep(i, s.size()) {
    if (s.at(i) == 'B') {
      res += v.at(v.size()-1) - v.at(i);
    }
  }
  cout << res << endl;
}

Measured memory_bytes: 2180
N, K, Q = map(int, input().split())
p = [0] * (N+1)
for _ in range(Q):
  a = int(input())
  p[a] += 1

for i in range(1, N+1):
  if Q - p[i] < K:
    print('Yes')
  else:
    print('No')
  

Measured memory_bytes: 4680
n,k=map(int,input().split())
a=list(map(int,input().split()))

inf=float('inf')

ans=inf

for i in range(2**n):
  iro=0
  ch=0
  cost=0
  h_max=a[0]
  for j in range(n):
    if (i>>j)&1:
      iro+=1
      if j==0:
        ch+=1
  if iro==k and ch==1:
    for j in range(1,n):
      if (i>>j)&1:
        if h_max<a[j]:
          h_max=a[j]
        else:
          cost+=(h_max+1)-a[j]
          h_max+=1
      else:
        if h_max<a[j]:
          cost+=(a[j]+1)-h_max
          h_max=a[j]+1
    ans=min(ans,cost)
  
print(ans)
        
    
    

Measured memory_bytes: 68116
(defn main [& args]
  (let [n (read)
        m (read)]
    (let [ab (into [] (for [i (range n)] [(read) (read)]))
          cd (into [] (for [i (range m)] [(read) (read)]))]
      (doseq [i (range n)]
        (let [min_  (atom 100000000000)
              index (atom 0)]
          (doseq [j (range m)]
            (let [distance (+ (Math/abs (- ((ab i) 0) ((cd j) 0)))
                              (Math/abs (- ((ab i) 1) ((cd j) 1))))]
              (when (> @min_ distance)
                (reset! min_ distance)
                (reset! index j))))
          (println (+ @index 1)))))))
(main)


Measured memory_bytes: 86360
//{{{
#include <bits/stdc++.h>
using namespace std;
#define repX(a,b,c,x,...) x
#define repN(a) repX a
#define rep(...) repN((__VA_ARGS__,rep3,rep2,loop))(__VA_ARGS__)
#define rrep(...) repN((__VA_ARGS__,rrep3,rrep2))(__VA_ARGS__)
#define loop(n) rep2(i_,n)
#define rep2(i,n) rep3(i,0,n)
#define rep3(i,begin,end) for(int i=(int)(begin),i##_end=(int)(end);i<i##_end;++i)
#define rrep2(i,n) rrep3(i,n,0)
#define rrep3(i,begin,end) for(int i=(int)(begin-1),i##_end=(int)(end);i>=i##_end;--i)
#define foreach(x,a) for(auto&x:a)
using ll=long long;
const ll mod=(ll)1e9+7;
//}}}

int main(){
  int N, A, B;
  cin >> N >> A >> B;
  int ans = min(A, B);
  int ans2 = max(0, A + B - N);
  cout << ans << " " << ans2 << endl;
  return 0;
}


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

long long int gcd(long long int x, long long int y)
{
	if (y == 0) { return x; }
	return gcd(y, x % y);
}

int main(void)
{
	int n, x, l[110];
	cin >> n >> x;
	for (int i = 0; i < n; i++) { cin >> l[i]; }
	int sum = 0,count = 1;
	while (1)
	{
		sum += l[count - 1];
		if (sum > x) { break; }
		count++;
	}
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
    double min=(double)(1ll<<32);
    double max=0;
    double h;
    while (scanf("%lf", &h) != EOF) {
        if (min > h) min = h;
        if (max < h) max = h;
    }
    printf("%f\n", max-min);
    return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
using namespace std;
int f[5][5]={0};
int main() {
	cin>>f[1][1]>>f[1][2]>>f[2][2];
	int sum=f[2][2]*3;
	f[1][3]=sum-f[1][1]-f[1][2];
	f[3][3]=sum-f[1][1]-f[2][2];
	f[2][3]=sum-f[1][3]-f[3][3];
	f[2][1]=sum-f[2][2]-f[2][3];
	f[3][1]=sum-f[1][1]-f[2][1];
	f[3][2]=sum-f[1][2]-f[2][2];
	for(int i=1;i<=3;i++) {
		for(int j=1;j<=3;j++)
			cout<<f[i][j]<<" ";
		cout<<endl;
	}
	return 0;
}

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

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 //10^12
#define MOD 1000000007 //10^9+7
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define MAXR 100000 //10^5:最大のrange(素数列挙などで使用)
ll dis_list[2000+5];

int main(){
    int N,X,Y;
    int dis;
    cin >> N >> X >> Y;
    FOR(i,1,N-1) {
        FOR(j,i+1,N) {
            dis = min(j-i, min(abs(X-i)+abs(j-Y)+1, abs(X-j)+abs(i-Y)+1));
            dis_list[dis] += 1;
        }
    }
    FOR(i,1,N-1) {
        cout << dis_list[i] << endl;
    }

}


Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <algorithm>
using namespace std;
#define SIZE 1000010

int main(void){
  int N;
  cin>>N;
  int* A=(int*)malloc(sizeof(int)*N);
  for(int i=0;i<N;i++){
    cin>>A[i];
  }
  sort(A,A+N);

  bool* ok=(bool*)malloc(sizeof(bool)*SIZE);
  for(int i=0;i<SIZE;i++){
    ok[i]=true;
  }
  for(int i=0;i<N;i++){
    if(!ok[A[i]]){
      continue;
    }
    if(i<N-1 and A[i]==A[i+1]){
      ok[A[i]]=false;
    }
    int k=2;
    while(k*A[i]<SIZE){
      ok[k*A[i]]=false;
      k++;
    }
  }
  int retval=0;
  for(int i=0;i<N;i++){
    if(ok[A[i]]){
      retval++;
    }
  }
  cout<<retval<<endl;
}


Measured memory_bytes: 5348
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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 (b<a) { a = b; return 1; } return 0; }
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void _main()
{
    set<int> sqs;
    for (int i = 1; i * i <= 1000000; ++i)
    {
        sqs.insert(i * i);
    }

    int N, D;
    cin >> N >> D;
    vector<vector<int>> ps(N, vector<int>(D));
    rep(i, 0, N) rep(j, 0, D)
    {
        cin >> ps[i][j];
    }

    int ans = 0;
    rep(i, 0, N) rep(j, i + 1, N)
    {
        int sqDist = 0;
        rep(k, 0, D)
        {
            sqDist += (ps[i][k] - ps[j][k]) * (ps[i][k] - ps[j][k]);
        }

        if (sqs.find(sqDist) != sqs.end())
        {
            ++ans;
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
class UnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n)]
        self.rank = [0]*(n)
    
    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]
    
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
        else:
            self.par[y] = x
        
        if self.rank[x] == self.rank[y]:
            self.rank[x] += 1
    
    def same_check(self, x, y):
        return self.find(x) == self.find(y)
    

N, M = map(int, input().split())
edge = [[int(_) for _ in input().split()] for _ in range(M)]
ans = 0

for i in range(M):
    uf = UnionFind(N+1)
    for j in range(M):
        if j == i:
            continue
        else:
            uf.union(edge[j][0], edge[j][1])
    
    if not uf.same_check(edge[i][0], edge[i][1]):
        ans += 1

print(ans)

Measured memory_bytes: 3064
#include <vector>
#include <list>
#include <map>
#include <string>
#include <iostream>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <utility>

using namespace std;
typedef long long ll;
typedef long double ld;

ll solve(void);

int main(void)
{
	while (solve())
	{
	}
	return 0;
}

ll solve(void)
{
	ll n, l;
	cin >> n >> l;

	ll min_abs = -1;
	ll di = 0;

	ll sum = 0;
	for (ll i = 0; i < n; i++)
		sum += l + i;

	for (ll i = 0; i < n; i++)
	{
		ll a = abs(i + l); 
		if (min_abs < 0 || min_abs > a)
		{
			min_abs = a;
			di = i;
		}
	}

	cout << sum - (di + l) << endl;

	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; ++i)
#define rrep(i, n) for(int i = n-1; i >= 0; --i)
#define fi first
#define se second
using namespace std;
using lint = long long;
using uint = unsigned int;
using ulint = unsigned long long;
using ldouble = long double;
using pii = pair<int, int>;
using pli = pair<lint, lint>;
using pdd = pair<double, double>;
using pld = pair<ldouble, ldouble>;
using v1i = vector<int>;
using v1li = vector<lint>;
using v2i = vector<vector<int>>;
using v2li = vector<vector<lint>>;
using v3i = vector<vector<vector<int>>>;
using v3li = vector<vector<vector<lint>>>;
using v1b = vector<bool>;
using v2b = vector<vector<bool>>;
using v3b = vector<vector<vector<bool>>>;
using v1c = vector<char>;
using v2c = vector<vector<char>>;
using v3c = vector<vector<vector<char>>>;
constexpr lint mod1 = 1e9+7;
constexpr lint mod2 = 998244353;

int main(){
  int f = 0, g = 1e9, h = (f+g)/2, n, k, d; cin >> n >> k;
  v1i v(n); rep(i, n){cin >> v[i]; v[i]--;}
  while(g - f > 0){
    int t = 0;
    rep(i, n) t += v[i] / (h+1);
    if(t <= k){
      d = h+1;
      g = h;
      h = (f+g)/2;
    }
    else{
      f = h+1;
      h = (f+g)/2;
    }
  }
  cout << d << endl;
}

Measured memory_bytes: 4048
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int di[] = {0, 0, 1, -1};
constexpr int dj[] = {1, -1, 0, 0};

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

    int n, k, d[110], a[110][110];

    cin >> n >> k;

    bool h[110];

    for (int i = 0; i < k; i++)
    {
        cin >> d[i];

        for (int j = 0; j < d[i]; j++)
        {
            cin >> a[i][j];
            h[a[i][j] - 1] = true;
        }
    }

    int res = 0;
    for (int i = 0; i < n; i++)
    {
        res += !h[i];
    }

    cout << res << endl;

    return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
#define REPi(i, a, b) for(int i=int(a); i<int(b); i++)
#define MEMS(a,b) memset(a,b,sizeof(a))
#define mp make_pair
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 (b<a) { a=b; return 1; } return 0; }
const ll MOD = 1e9+7;

int main(){
    string S, T;
    cin >> S >> T;

    T.pop_back();
    if(S == T)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3596
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<cstdio>
#include<queue>
#include<deque>
#include<map>
#include<stack>
#include<set>
#include<utility>
using namespace std;
typedef pair<int,int> ii;
typedef long long ll;
typedef pair<ll,ll> p;
typedef unsigned long long int ull;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
const int MAXN=100000;
const int MAXE=100000;
const int MAXV=10000;
const int INF=1e9;
const ll MOD=1e9+7;

struct UnionFind{
    vector<int> par,rank;
    UnionFind(int n):par(n),rank(n,0){
        for(int i=0;i<n;++i) par[i]=i;
    }
    int root(int x){
        if(par[x]==x) return x;
        return par[x]=root(par[x]);
    }
    void unite(int x,int y){
        int rx=root(x),ry=root(y);
        if(rx==ry) return ;
        if(rank[rx]>rank[ry]) par[ry]=rx;
        else par[rx]=ry;
        if(rank[rx]==rank[ry]) rank[ry]++;
    }
    bool same(int x,int y){
        return root(x)==root(y);
    }
    int cnt(int n){
        int res=0;
        for(int i=0;i<n;++i){
            if(root(i)==i) res++;
        }
        return res;
    }
};

int main(){
    int N,M;cin>>N>>M;
    vector<vector<int> > G(N);
    for(int i=0;i<M;++i){
        int u,v;cin>>u>>v;u--;v--;
        G[u].push_back(v);
    }
    int s,t;cin>>s>>t;s--;t--;
    vector<vector<ll> > d(N,vector<ll>(3,-1));
    queue<ii> que;
    d[s][0]=0;
    que.push(ii(s,0));
    while(!que.empty()){
        ii p=que.front();que.pop();
        int u=p.first,parity=p.second;
        int np=(parity+1)%3;
        for(auto v:G[u]){
            if(d[v][np]>=0) continue;
            d[v][np]=d[u][parity]+1;
            que.push(ii(v,np));
        }
    }
    if(d[t][0]==-1) cout<<-1<<endl;
    else cout<<d[t][0]/3<<endl;
    return 0;
}

Measured memory_bytes: 14000
#include<iostream>

using namespace std;

int main(){
    int a,b;
    cin >> a>> b;
    long k;
    k = a + b;
    if(k%2 == 0){
        cout  << k/2 << endl;
    }else{
        cout << "IMPOSSIBLE" << endl;
    }

    return 0;
}

Measured memory_bytes: 384
#include<cstdio>
#include<cstdlib>
#include<cstring>

struct Node {
  int key;
  Node *next, *prev;
};

Node *nil;

Node* listSearch(int key) {
  Node *cur = nil->next;  // 番兵の次の要素から辿る
  while ( cur != nil && cur->key != key )
    cur = cur->next;
  return cur;
}

void init() {
  nil = (Node *)malloc(sizeof(Node));
  nil->next = nil;
  nil->prev = nil;
}

void printList() {
  Node *cur = nil->next;
  int isf = 0;
  while ( 1 ) {
    if ( cur == nil ) break;
    if ( isf++ > 0 ) printf(" ");
    printf("%d", cur->key);
    cur = cur->next;
  }
  printf("\n");
}

void deleteNode(Node *t) {
  if ( t == nil ) return;  // t が番兵の場合は処理しない
  t->prev->next = t->next;
  t->next->prev = t->prev;
  free(t);
}

void deleteFirst() {
  deleteNode(nil->next);
}

void deleteLast() {
  deleteNode(nil->prev);
}

void deleteKey(int key) {
  // 検索したノードを削除
  deleteNode(listSearch(key));
}

void insert(int key) {
  Node *x = (Node *)malloc(sizeof(Node));
  x->key = key;
  // 番兵の直後に要素を追加
  x->next = nil->next;
  nil->next->prev = x;
  nil->next = x;
  x->prev = nil;
}

int main() {
  int key, n, i;
  int size = 0;
  char com[20];
  int np = 0, nd = 0;
  scanf("%d", &n);
  init();
  for ( i = 0; i < n; i++ ) {
    scanf("%s%d", com, &key);  // より高速な入力関数を使用
    if ( com[0] == 'i' ) { insert(key); np++; size++; }
    else if ( com[0] == 'd' ) {
      if ( strlen(com) > 6 ) {
        if ( com[6] == 'F' ) deleteFirst();
        else if ( com[6] == 'L') deleteLast();
      } else {
        deleteKey(key); nd++;
      }
      size--;
    }
  }

  printList();

  return 0;
}


Measured memory_bytes: 33988
#include<stdio.h>
int main(void){
  int A,B;
  scanf("%d%d",&A,&B);
  if(A==1){
    if(B==2){
      printf("3");
    }
    if(B==3){
      printf("2");
    }
  }
  if(A==2){
    if(B==1){
      printf("3");
    }
    if(B==3){
      printf("1");
    }
  }
  if(A==3){
    if(B==1){
      printf("2");
    }
    if(B==2){
      printf("1");
    }
  }
  return 0;
}
  

Measured memory_bytes: 128
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {

	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			int x = sc.nextInt();
			int n = sc.nextInt();
			Set<Integer> p = new HashSet<>();

			for (int i = 0; i < n; i++) {
				p.add(sc.nextInt());
			}

			for (int i = 0; i < 100; i++) {
				if (!p.contains(x - i)) {
					System.out.println(x - i);
					return;
				} else if(!p.contains(x + i)) {
					System.out.println(x + i);
					return;
				}
			}
		}
	}
}


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

int main(){    
  
  int N;
  cin >> N;
  
  if(N/1 < 10 && N%1 == 0) cout << "Yes" << endl;
  
  else if(N/2 < 10 && N%2 == 0) cout << "Yes" << endl;
  
  else if(N/3 < 10 && N%3 == 0) cout << "Yes" << endl;
  
  else if(N/4 < 10 && N%4 == 0) cout << "Yes" << endl;
  
  else if(N/5 < 10 && N%5 == 0) cout << "Yes" << endl;
 
  else if(N/6 < 10 && N%6 == 0) cout << "Yes" << endl;
  
  else if(N/7 < 10 && N%7 == 0) cout << "Yes" << endl;
  
  else if(N/8 < 10 && N%8 == 0) cout << "Yes" << endl;
  
  else if(N/9 < 10 && N%9 == 0) cout << "Yes" << endl;
  
  else cout << "No" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a) for(int i = 0; i < a; i++)
#define all(v) v.begin(), v.end()
#define dcout cout << fixed << setprecision(15)
#define arep(i, a) for(auto i : a)
#define F first
#define S second
#define VE vector<int>
#define pb(x) push_back(x)
#define MOD 1000000007
#define INF 10000000000
#define int long long
#define KETA(n) floor(log10(n) + 1)
using namespace std;
signed main() {
    char c;
    cin >> c;
    if(c - 97 < 0)
        cout << "A";
    else
        cout << "a";
    return 0;
}

Measured memory_bytes: 3632
def main(a,b):
	count = 0
	
	while(a>0):
		count += a%10
		a = int(a/10)
			
	while(b>0):
		count += b%10
		b = int(b/10)
	return count

n = int(input())

result = main(n-1,1)
for i in range(2,n):
	a  = n - i
	b = i
	result = min(result, main(a,b))
		
print(result)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <iomanip>
#include <map>
#include <bitset>
#include <cstdio>
#include <set>
#include <stack>
#include <queue>
#include <cassert>
#include <numeric>
#define rep(i,n) Rep(i,0,n)
#define Rep(i,k,n) for(int i=k ; i<n ; i++)
#define rep1(i,n) for(int i=1 ; i<=n ; i++)
#define Rep1(i,k,n) for(int i=k ; i<=n ; i++)
#define vi vector<int>
#define vii vector<vector<int>>
#define mii map<int,int>
#define Sort(v) sort(v.begin(),v.end())
#define Reverse(v) reverse(v.begin(),v.end())
#define ALL(a)  (a).begin(),(a).end()
#define pb push_back
//#define int ll
typedef long long ll;

const int md = 1000000007;
const int INF = 1<<30;
using namespace std;

double inverse(int x){
    return (1.0)/x;
}


int main(){
    string s;
    cin >> s;

    map<char,int> m;

    rep(i,s.size()){
        m[s[i]]++;
    }

    bool f = true;

    for(auto x:m){
        if(x.second >= 2) f = false;
    }

    if(f) cout << "yes" << endl;
    else cout << "no" << endl;
}


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

int N, K;

int main(){
    cin >> N >> K;
    ll ans = 0;
    for(int i=K+1; i<=N; i++) {
        int p = N / i;
        int r = N % i;
        int c = p * (i - K);
        int d = max(0, r + 1 - K);
        ans += c + d;
        if (K == 0) ans--;
    }
    cout << ans << endl;
    return 0;
}

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

namespace ConsoleApp9
{   
    class Program
    {
        public static void Main(string[] args) {
            while (true)
            {
                string[] sss = Console.ReadLine().Split(' ');
                int a = int.Parse(sss[0]); int b = int.Parse(sss[1]);
                if (a==0&&b==0) { break; }
                for (int d =1;d<= a;d++)
                {
                    for (int c =1;c<=b;c++)
                    { int e = (c + d) % 2;
                        if (e == 0)
                            Console.Write("#");
                        else
                            Console.Write(".");
                    }
                    Console.WriteLine();
                }
                Console.WriteLine();
            }
        }
    }
}

Measured memory_bytes: 9008
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

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

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

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

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

  vector<int> A(N);
  rep(i, N) cin >> A[i];

  if (N == 2)
  {
    cout << std::max(A[0], A[1]) << endl;
    return 0;
  }

  std::sort(A.begin(), A.end());
  int mn = 1000000000;
  int mn2 = 1000000000;

  vector<int> L(N + 1);
  vector<int> R(N + 1);
  L[0] = 0;
  R[N] = 0;
  rep(i, N)
  {
    L[i + 1] = gcd(L[i], A[i]);
    R[N - i - 1] = gcd(R[N - i], A[N - i - 1]);
  }

  int mx = 0;
  rep(i, N)
  {
    int gcd_ = gcd(L[i], R[i + 1]);
    if (mx < gcd_)
      mx = gcd_;
  }

  cout << mx << endl;

  return 0;
}


Measured memory_bytes: 1408
N,K = map(int, input().split())
H = list(map(int, input().split()))
H = sorted(H, reverse=True)
H_sum = 0
if len(H) <= K:
  print(H_sum)
else:
  H = H[K:]
  for i in range(len(H)):
    H_sum += H[i]
  print(H_sum)

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

#n = int(input())
#l = list(map(int, input().split()))

'''
a=[]
b=[]
for i in range():
    A, B = map(int, input().split())
    a.append(A)   
    b.append(B)'''

n=int(input())
c=list(input().rstrip("\n"))
import collections
cc=collections.Counter(c)
ans=0
for i in range(cc["R"]):
    if c[i]=="W":
        ans+=1
print(ans)

Measured memory_bytes: 10816
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <utility>
#include <functional>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_map>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;
const int INF = (1<<30);
const int MOD = 1000000007;
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; }

void dump(const list<int> &list){
    bool isFirst = true;
    for(const auto &l : list){
        if(!isFirst) cout << " ";
        cout << l;
        isFirst = false;
    }
    cout << "\n";
}

int main() {
    int n,m;
    cin >> n >> m;
    list<int> L[n];
    int q, t, x;
    rep(i, m){
        cin >> q;
        switch (q)
        {
        case 0:
            cin >> t >> x;
            L[t].insert(L[t].end(), x);            
            break;
        case 1:
            cin >> t;
            dump(L[t]);
            break;
        default:
            cin >> t >> x;
            L[x].splice(L[x].end(), move(L[t]));
            L[t] = list<int>{};
            break;
        }
    }

    return 0;
}


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

int pow(int m){
	return m*m*m*m*m;
}

int main(){
	ll x,i,j;
	cin>>x;
	
	for(i=0;i<=5000;i++)
        for(j=-500;j<=5000;j++)
	        if(pow(i)-pow(j)==x){
		        cout<<i<<' '<<j;
		        return 0;
	        }
}

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

#if DEBUG && !ONLINE_JUDGE
    #include "/home/tushar_garg/Desktop/cpp/debug.h"
#else
    #define dbg(x...)
#endif

typedef     long long                            ll; 
typedef		long double							 ld;
typedef     pair<ll, ll>                         pl; 
typedef     vector<ll>                           vl;
typedef     vector<ld>                           vld;
typedef     vector<char>                         vc;
typedef     vector<bool>                         vb; 
typedef     vector<vl>                           vvl; 
typedef     vector<pl>                           vll; 
typedef     map<ll, ll>                          dict; 
typedef     map<ll, ll, greater <ll> >           sdict; 
typedef     map<char, ll>                        mcl;
typedef     priority_queue<ll>                   pqi;
typedef     priority_queue<pl>                   pqii;
typedef     priority_queue<ll, vl, greater<ll>>  pqmini;

#define rep(i, a, n) for (auto i=(a)-((a)>(n)); i!=(n)-((a)>(n)); i+=1-2*((a)>(n)))
#define trav(i, a) for(auto &i:a)
#define fi first 
#define se second 
#define mp make_pair 
#define pb push_back
#define eb emplace_back
#define flash ios_base::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr)
#define QuickSilver cin.exceptions(cin.failbit),setprecision(12),cout.precision(12);
#define fill(a, b) memset(a, b, sizeof(a)
#define get(a) rep(i,0,sz(a))cin>>a[i];
#define sz(a) (ll)(a.size())
#define all(a) a.begin(), a.end()
#define mod 1000000007

pl dfs(int s, int p, vl adj[]){
	pl ans={1, 1};
	for(int i:adj[s])
		if(i!=p){
			pl t=dfs(i, s, adj);
			ans.fi=(ans.fi*(t.fi+t.se))%mod;
			ans.se=(ans.se*t.fi)%mod;
		}
	return ans;
}

int main(){
	flash; QuickSilver;
	int n; cin>>n;
	vl adj[n];
	rep(i,0,n-1){
		int x,y; cin>>x>>y;
		x--; y--;
		adj[x].pb(y);
		adj[y].pb(x);
	}
	pl p=dfs(0, 0, adj);
	cout<<(p.fi+p.se)%mod<<"\n";
	return 0;
}

Measured memory_bytes: 12672
<?php
fscanf(STDIN, "%d %d", $L, $R);
$ans = PHP_INT_MAX;
for ($i = $L; $i < $R; $i++) {
    for ($j = $i + 1; $j <= $R; $j++) {
        $ans = min($ans, ($i * $j) % 2019);
        if ($ans === 0) break 2;
    }
}
echo $ans;


Measured memory_bytes: 4604
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#define REP(i,a) for (int i = 0;i < (a);++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(obj) (obj).begin,(obj).end()
#define SORT(list) sort(ALL((list)));
using namespace std;
using ll = long long;
int main(){
    ll a,b;
    cin >> a >> b;
    if((a+b)%2!=0){
        cout << "IMPOSSIBLE" << endl;
        return 0;
    }
    cout << (a+b)/2 << endl; 
    return 0;
}

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

int main() {
  char c;
  cin>>c;
  
  if ((c =='a')||(c=='e')||(c=='i')||(c=='o')||(c=='u'))
    cout<<"vowel"<<endl;
  else
    cout<<"consonant"<<endl;
  
  
}


Measured memory_bytes: 256
def main(n, a):
    box = [0] * n
    for i in range(n, 0, -1):
        if a[i - 1] != sum(box[i - 1 :: i]) % 2:
            box[i - 1] = 1

    box_indices = [i + 1 for i in range(n) if box[i] == 1]
    print(sum(box))
    print(*box_indices)


n = int(input())
a = list(map(int, input().split()))
main(n, a)

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

//a^n (mod m)
const long long mod = 1e9+7;


//mod mでの a の逆元を求める
long long modinv(long long a) {
    long long b = mod, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= mod; 
    if (u < 0) u += mod;
    return u;
}

signed main(){
    ios::sync_with_stdio(false);
	cin.tie(0);
    cout << fixed << setprecision(20);

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

    ll cnt[n]={};
    ll ans = 0;
    for(int i=0;i<n;i++){
        for(int j=0;j<i;j++){
            if(a[i]<a[j]) cnt[i]++;
        }
        ans += (k*cnt[i])%mod;
        ans %= mod;

        for(int j=n-1;j>i;j--){
            if(a[i]<a[j]) cnt[i]++;
        }
        ll t=cnt[i]*k;
        t%=mod;
        t*=(k-1);
        t%=mod;
        t*=modinv(2);
        t %= mod;
        ans+= t;
        
        ans %= mod;
    }
    cout<<ans<<endl;


    
}

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

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x){
  while(x->left!=NIL){
    x=x->left;
  }
  return x;
  //ok
}

Node treeMaximum(Node x){
  while(x->right!=NIL){
    x=x->right;
  }
  return x;
  //ok
}

Node treeSearch(Node u, int k){
  if(u==NIL || k==u->key){
    return u;
  }
  if(k<u->key){
    return treeSearch(u->left,k);
      }
  else{
    return treeSearch(u->right,k);
      }
  //ok
}

Node treeSuccessor(Node x){
  Node y;
  
  if(x->right!=NIL){
    return treeMinimum(x->right);
      }
  y=x->parent;
  while(y!=NIL && x==y->right){
    x=y;
    y=y->parent;
  }
  return y;
}
//treeSearch(root,x)を使っている
void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y
}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x!=NIL){
    y=x;
    if(z->key < x->key){
      x=x->left;
    }else{
      x=x->right;
    }
  }
  z->parent=y;

  if(y==NIL){
    root=z;
  }else if(z->key<y->key){
    y->left=z;
  }else{
    y->right=z;
  }
}

void inorder(Node u){
  if(u!=NIL){
    inorder(u->left);
      printf(" %d",u->key);
    inorder(u->right);
  }
}
void preorder(Node u){
  if(u==NIL){
    return;
  }
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;
}



Measured memory_bytes: 25128
N = int(input())
if N in [100,101,102,103,104,105]:
    print(1)
else:
    x = N%100
    xx = N//100
    y = x%5
    yy = x//5
    if y == 0 and xx-yy >= 0:
        print(1)
    elif  xx-yy>=1:
        print(1)
    else:
        print(0)

Measured memory_bytes: 3064
#include <stdio.h>

int main(void){
	int A,B,C,D;
	scanf("%d%d%d%d",&A,&B,&C,&D);
	int left,right,ans;
	//A-B の区間と C-Dの区間のかぶっているところを出す
	if(A<C)left = C;
	else left = A;
	if(B<D)right = B;
	else right = D;
	if( (right - left)<0)ans=0;
	else ans = right - left;
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Range(container) container.begin(), container.end()
#define RevRange(container) container.rbegin(), container.rend()
#define Cin(T, x) T x; cin >> x;
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i];
#define Cout(val) cout << (val) << "\n";
using namespace std;
using ll = long long;

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

int main(void){
    Cin(int, n);
    Cins(int, n, a);
    
    int d = gcd(a[0], a[1]);
    for(int i = 2; i < n; i ++) d = gcd(d, a[i]);
    Cout(d);
}



Measured memory_bytes: 640
N = int(input())
tmp = [input().split() for i in range(N)]
jpy = 0
btc = 0
for i in range(N):
    if tmp[i][1]=='JPY':
        jpy += int(tmp[i][0])
    elif tmp[i][1]=='BTC':
        btc += float(tmp[i][0])
print(jpy+btc*380000)

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

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define sz(obj) ((int)(obj).size())
#define pf push_front
#define pb push_back

int main()
{
  int n;
  cin >> n;
  int a[3] = {0};
  REP(i, n) cin >> a[i];
  if (n == 2){
    FOR(i, 1, min(a[0], a[1]) + 1){
      if (a[0] % i == 0 && a[1] % i == 0) cout << i << endl;
    }
  }
  else {
    FOR(i, 1, min(min(a[0], a[1]), a[2]) + 1){
      if (a[0] % i == 0 && a[1] % i == 0 && a[2] % i == 0) cout << i << endl;
    }
  }
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define P pair<ll, ll>
#define Graph vector<vector<ll>>
#define fi first
#define se second
constexpr ll mod = 1000000007;
constexpr ll INF = (1ll << 60);
constexpr double pi = 3.14159265358979323846;
template <typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return 1;}return 0;}
template <typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return 1;}return 0;}

int main(){
    ll n,k;cin>>n>>k;
    vector<ll> h(n);
    rep(i,n) cin>>h[i];
    
    sort(h.begin(),h.end(),greater<ll>());
    ll ans=INF;
    rep(i,n-k+1){
        chmin(ans,h[i]-h[i+k-1]);
    }

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

Measured memory_bytes: 4052
n, m = map(int, input().split())
h_list = list(map(int, input().split()))
road_dict = {a+1: set() for a in range(n)}
for i in range(m):
  a, b = map(int, input().split())
  if a in road_dict:
    road_dict[a].add(b)
  else:
    road_dict[a] = set([b])
  if b in road_dict:
    road_dict[b].add(a)
  else:
    road_dict[b] = set([a])
use_list = []
res = 0
for k, s in road_dict.items():
  k_height = h_list[k-1]
  if len(s) == 0:
    res += 1
  else:
    add_flg = True
    for v in list(s):
      v_height = h_list[v-1]
      if k_height > v_height:
        continue
      else:
        add_flg = False
        break
    if add_flg:
      res += 1
print(res)


Measured memory_bytes: 54000
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws java.io.IOException {
        try (BufferedReader reader = new BufferedReader(new InputStreamReader(System.in))) {
            final String s = reader.readLine();
            System.out.println(s.contains("2") ? "No" : "Yes");
        }
    }
}


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

char input[4];
int num[4];
int sign[] = {1, -1};
char signchar[] = {'+', '-'};

int main(){
    cin >> input;
    for (int i = 0; i < 4; i++) num[i] = input[i] - '0';

    for (int i = 0; i < 2; i++){
        for (int j = 0; j < 2; j++){
            for (int k = 0; k < 2; k++){
                int ans = num[0] + sign[i]*num[1] + sign[j]*num[2] +sign[k]*num[3];
                if (ans == 7){
                    cout << num[0] << signchar[i] << num[1] << signchar[j] << num[2] << signchar[k] << num[3] << "=7" << endl;
                    return 0;
                }
            }
        }
    }
    return 0;
}

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

const int N = 3e+3 + 5;
vector<int> adj[N];
int dist[N][N];
int countdis[N];
void bfs(int v)
{
    bool vis[N] = {0};
    queue<int> q;
    q.push(v);
    vis[v] = true;
    dist[v][v]=0;
    while(!q.empty())
    {
        int u=q.front();
        q.pop();
        for(auto it:adj[u])
            if(!vis[it])
            {
                vis[it]=true;
                dist[it][v]=dist[u][v]+1;
                countdis[dist[it][v]]++;
                q.push(it);
            }
    }
    return ;
}
int main()
{
    int n,x,y;
    cin>>n>>x>>y;
    for(int i=1;i<n;i++)
    {
        adj[i].push_back(i+1);
        adj[i+1].push_back(i);
    }
    adj[x].push_back(y);
    adj[y].push_back(x);
    for(int i=1;i<=n;i++)
        bfs(i);
    for(int i=1;i<n;i++)
        cout<<countdis[i]/2<<"\n";
}

Measured memory_bytes: 24960
n = int(input())
al = list(map(int,input().split()))

flag = False
before = -1
ans = 0
for a in al:
    if before == a:
        if flag == False:
            ans += 1
            flag = True
        else:
            flag = False
    else:
        flag = False
    before = a
print(ans)

Measured memory_bytes: 3060
import numpy as np
x, y, a, b, c = map(int, input().split())
p = sorted(list(map(int, input().split())))
q = sorted(list(map(int, input().split())))
r = sorted(list(map(int, input().split())))

filt_p = p[-x:]
filt_q = q[-y:]
filt_p.extend(filt_q)
filt_p.extend(r)
all_apples = sorted(filt_p)

ans = np.sum(np.array(all_apples)[-x-y:])

print(str(ans))

Measured memory_bytes: 34004