akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 10000000000

struct unionfind{
	vector<int> data;
	vector<int> size;
	unionfind(int n){
		for(int i=0;i<n;i++){
			data.push_back(i);
			size.push_back(1);
		}
	}
	
	int find(int x){
		if(data[x]==x)return x;
		return data[x]=find(data[x]);
	}
	
	bool unite(int x,int y){
		x=find(x);y=find(y);
		if(x==y)return false;
		data[x]=y;
		size[y]+=size[x];
		return true;
	}
	
	bool check(int x,int y){
		return (find(x)==find(y));
	}
	
	int get_size(int x){
		int X = find(x);
		return size[X];
	}
};

int main(){
	
	int N,M;
	cin>>N>>M;
	
	vector<long long> D(N);
	
	long long mini = Inf;
	
	for(int i=0;i<N;i++){
		scanf("%lld",&D[i]);
		mini = min(mini,D[i]);
	}
	
	vector<bool> united(N,false);
	
	vector<vector<int>> E(N,vector<int>());
	
	map<pair<int,int>,int> mp;
	
	for(int i=0;i<M;i++){
		int a,b;
		scanf("%d %d",&a,&b);
		a--;b--;
		
		if(D[a]==D[b]){
			united[a]=true;
			united[b] = true;
		}
		
		E[a].push_back(b);
		E[b].push_back(a);
		mp[make_pair(a,b)] = i;
		mp[make_pair(b,a)] = i;
	}
	
	vector<int> L;
	queue<int> Q;
	vector<bool> used(N,false);
	
	for(int i=0;i<N;i++){
		if(united[i])L.push_back(i);
	}
	
	vector<int> ansE(M,1000000000);
	vector<char> ansC(N,'B');
	
	
	while(Q.size()!=0||L.size()!=0){
		if(Q.size()==0){
			if(used[L.back()]==false)Q.push(L.back());
			used[L.back()] = true;
			L.pop_back();
			continue;
		}
		int from = Q.front();
		Q.pop();
		
		for(int i=0;i<E[from].size();i++){
			int to = E[from][i];
			if(used[to])continue;
			if(D[to] == D[from]){
				if(ansC[from]=='B')ansC[to]='W';
				else ansC[to] = 'B';
				ansE[mp[make_pair(from,to)]] = D[to];
				used[to] = true;
				Q.push(to);
			}
			if(D[to] > D[from]){
				ansC[to] = ansC[from];
				ansE[mp[make_pair(from,to)]] = D[to]-D[from];
				used[to] = true;
				Q.push(to);
			}
		}
	}
	
	for(int i=0;i<N;i++){
		if(!used[i]){
			cout<<-1<<endl;
			return 0;
		}
	}
	
	
	
	for(int i=0;i<N;i++){
		cout<<ansC[i];
	}
	cout<<endl;
	
	for(int i=0;i<M;i++){
		cout<<ansE[i]<<endl;
	}
	
	return 0;
}


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

int Max(vector<int> x){
  if(x.size()==1){
    return x.at(0);
  }
  auto itr1=x.begin();
  auto itr2=itr1+1;
  *itr1=max(*itr1,*itr2);
  x.erase(itr2);
  return Max(x);
}

int main() {
 int K,N;
  cin>>K>>N;
  vector<int> a(N);
  int b;
  for(int i=0;i<N;i++){
    cin>>a.at(i);
  }
  b=K-a.at(N-1)+a.at(0);
  for(int i=0;i<N-1;i++){
    b=max(b,a.at(i+1)-a.at(i));
  }
  //b.at(N-1)=K-a.at(N-1)+a.at(0);
  cout<<K-b;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define x first
#define y second
#define pb push_back
#define eb emplace_back
#define all(a) (a).begin(),(a).end()
#define SZ(a) (int)(a).size()
#define FOR(i, a, b) for(int i=(a); i<=(b); ++i)
#define iFOR(i, a, b) for(int i=(a); i>=(b); --i)
#define make_unique(a) sort(all((a))), (a).resize(unique(all((a)))-(a).begin())

using namespace std;

typedef pair<int,int> PII;
typedef long long LL;
typedef unsigned long long UL; // ULLONG_MAX, %llu
typedef unsigned int UI; //UINT_MAX %u
typedef double DD;
typedef long double LD;
typedef pair<LL,LL> PLL;
typedef pair<DD,DD> PDD;
typedef vector<int> VI;
typedef vector<LL> VL;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin >> n;
    n %= 1000;
    cout << (1000-n)%1000;
	return 0;
}
/*
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 */


Measured memory_bytes: 3652
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <utility>
#include <cmath>
#include <map>
#include <set>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <random>
#include <deque>

#define INF_LL 1e18
#define INF 1e9

const int dx[8] = { 1,1,0,-1,-1,-1,0,1 };
const int dy[8] = { 0,1,1,1,0,-1,-1,-1 };

typedef long long ll;

using namespace std;


int main() {
  string a, b;
  cin >> a >> b;
  if (a.length() > b.length()) {
    cout << "GREATER";
  } else if (b.length() > a.length()) {
    cout << "LESS";
  } else {
    int i = 0;
    while (i < a.length()) {
      if ((int)a[i] > (int)b[i]) {
        cout << "GREATER";
        return 0;
      } else if ((int)a[i] < (int)b[i]) {
        cout << "LESS";
        return 0;
      }
      i++;
    }
    cout << "EQUAL";
  }

  return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define P pair<int,int>
#define PI 3.141592653589793
const int INF = 1001001001;
const ll MX = 1e18;
const int mod = 1000000007;

int main() {
	int n;
	cin >> n;
	vector<int> p(n);
	rep(i, n) cin >> p[i];
	int ans = 0;
	rep(i, n - 2) {
		vector<int> a(3);
		rep(j, 3) a[j] = p[i + j];
		sort(a.begin(), a.end());
		if (a[1] == p[i + 1]) ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 3612
#include <algorithm>
#include <cassert>
#include <cmath>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

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

template <typename T> inline int size(const T& x) { return x.size(); }

bool is_tanka(const vector<string>& words, int offset) {
    static const int TANKA[] = {5, 7, 5, 7, 7};

    int curr_idx = 0, curr_len = 0;
    FOR(i, offset, size(words)) {
        curr_len += size(words[i]);
        if (curr_len > TANKA[curr_idx])
            return false;
        if (curr_len == TANKA[curr_idx]) {
            curr_idx++;
            curr_len = 0;
            if (curr_idx == 5)
                return true;
        }
    }
    return false;
}

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

    int n;
    while (cin >> n, n) {
        vector<string> words(n);
        REP(i, n) cin >> words[i];

        REP(offset, n) {
            if (is_tanka(words, offset)) {
                cout << offset+1 << endl;
                break;
            }
        }
    }
}

Measured memory_bytes: 3208
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main() {

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

    if (a % k == 0) {
        printf("OK");
    } else {

        int sho = a / k;
        sho++;
        //printf("%d\n",sho);

        if (sho * k >= a && sho*k<=b) {
            printf("OK");
        } else {
            printf("NG");
        }


    }




    return 0;

}

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

using namespace std;

int n, a[205], b[205];

int p2 (int n)
{
    int a = 0;
    while (n > 1 && n % 2 == 0)
    {
        n /= 2;
        a++;
    }
    return a;
}

int main()
{
    cin >> n;
    for (int i = 1; i <= n; i++)
        cin >> a[i];
    for (int i = 1; i <= n; i++)
        b[i] = p2(a[i]);
    int m = b[1];
    for (int i = 1; i <= n; i++)
        if (b[i] < m) m = b[i];
    cout << m;
}

Measured memory_bytes: 256
#include<stdio.h>
 
int main(void)
 
{
 
int a,b,menseki,syuu;
 
scanf("%d",&a);
 
scanf("%d",&b);
 
menseki=a*b;
 
syuu=2*a+2*b;
 
printf("%d %d\n",menseki,syuu);
 
return 0;
 
}
 

Measured memory_bytes: 596
from collections import defaultdict
import bisect
s = input()
t = input()
ns = len(s)
nt = len(t)
word = defaultdict(int)
wordnum = defaultdict(int)
for i in range(ns):
  if word[s[i]] != 0:
    word[s[i]].append(i+1)
  else:
    word[s[i]] = [i+1]
  wordnum[s[i]] += 1
cnt = 0
pnt = 0
for i in range(nt):
  x = t[i]
  if word[x] != 0:
    pos = bisect.bisect_right(word[x],pnt)
    if pos == wordnum[x] or pnt>word[x][pos]:
      cnt += 1
    if pos == wordnum[x]:
      pnt = word[x][0]
    else:
      pnt = word[x][pos]
  else:
    print(-1)
    exit()
print(cnt*ns+pnt)

Measured memory_bytes: 47596
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
using namespace std;
using ll = long long;

int gcd(int a,int b){
    int t;
    while(b>0){
        t=b;
        b=a%b;
        a=t;
    }
    return a;
}

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

int main(){
    ll a,b,c,d,e,k,l,m,n,o=0,p,q,x,y,z,max1=0,ans;
    string s,t,u;
    cin>>a;
    
    
    cout<<3*a*a<<endl;
}






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

int T[17][17];
bool Vert[17][17];
bool Horiz[17][17];

void initialize(void);

void input_matatabi(void);

void calc_t(int x, int y);

int main(){
	int n, gx, gy, num_matatabi;
	cin >> n;
	for (int i = 0; i < n; i++) {
		initialize();
		cin >> gx >> gy;
		cin >> num_matatabi;
		for (int i = 0; i < num_matatabi; i++)
			input_matatabi();
		calc_t(gx + 1, gy + 1);
		if (T[gx + 1][gy + 1] == 0)
			cout << "Miserable Hokusai!" << endl;
		else 
			cout << T[gx + 1][gy + 1] << endl;
	}
}

void initialize(void) {
	for (int i = 0; i < 17; i++)
		for (int j = 0; j < 17; j++) {
			T[i][j] = 0;
			Vert[i][j] = true;
			Horiz[i][j] = true;
		}
	T[1][1] = 1;
}

void input_matatabi(void) {
	int x1, y1, x2, y2;
	cin >> x1 >> y1 >> x2 >> y2;
	if (x1 == x2)
		Vert[x1 + 1][min(y1, y2) + 1] = false;
	else
		Horiz[min(x1, x2) + 1][y1 + 1] = false;
}

void calc_t(int x, int y) {
	for (int i = 1; i < x + 1; i++)
		for (int j = 1; j < y + 1; j++) {
			if (Vert[i][j - 1])
				T[i][j] += T[i][j - 1];
			if (Horiz[i - 1][j])
				T[i][j] += T[i - 1][j];
		}
}

Measured memory_bytes: 1160
#include <iostream>

using namespace std;

int main() {
    int m, k;
    cin >> m >> k;
    if (k >= (1 << m) || (m == 1 && k == 1)) {
        cout << -1; return 0;
    }
    if (m == 1 && k == 0) {
        cout << "0 0 1 1"; return 0;
    }
    cout << k << ' ';
    for (int i = 0; i < (1 << m); ++i)
        if (i != k) cout << i << ' ';
    cout << k << ' ';
    for (int i = (1 << m) - 1; i >= 0; --i)
        if (i != k) cout << i << ' ';
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
#define REP(i,x,n) for(int i=x;i<(int)n;i++)
#define rep(i,n) REP(i,0,n)
#define sp(p) cout<<setprecision(16)<<fixed<<p<<endl;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define SORT(a) sort(all(a))
#define RSORT(a) sort(rall(a))
#define UNIQ(a) unique(all(a))
#define UNIQNUM(a) UNIQ(a)-a.begin()
#define UNIQIT(a) a.erase(UNIQ(a), a.end());
#define VOUT(v,i) rep(i,v.size())cout<<v[i]<<(i==v.size()-1?"\n":" ");
#define vout(v) VOUT(v,z);
#define vdbg(v,i) cout<<#v<<": ";for(int i=0;i<(int)v.size();i++){cout<<v[i]<<" ";}cout<<"\n";
#define vmin(v) *min_element(all(v))
#define vmax(v) *max_element(all(v))
#define vsum(v) accumulate(all(v), 0LL)
#define MOUT(m,r,c) rep(i,r){rep(j,c){cout<<m[i][j]<<" ";}cout<<endl;}
#define mout(m) MOUT(m,m.size(),m[0].size())
#define debg(a) cout<<#a<<": "<<a<<endl;
#define show(a) for(cont &y:a){for(cont &x:y){cout<<x<<" ";}cout<<endl;}
#define digit(a) to_string(a).length();
template<class T>inline int out(const T &t){ print(t); putchar('\n'); return 0; }
// template<class T>inline T gcd(T a,T b){if(b==0)return a; return(gcd(b,a%b));}
// template<class T>inline T lcm(T a,T b){return a/gcd(a,b)*b;}
bool is_palindrome(string s){return s == string(s.rbegin(),s.rend());}
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef vector<ll> V;
typedef vector<vector<ll>> VV;
// const long long MOD=1000000007;
const long long INF = 1e18;
#define EPS (1e-7)
#define PI (acos(-1))
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) { a = b; return true; }
    return false;
}
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) { a = b; return true; }
    return false;
}



int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    long long C;
    scanf("%lld",&C);
    long long K;
    scanf("%lld",&K);
    ll sum=0;
    if(K>=A){
        K-=A;
        sum+=A;
    }else{
        cout << K << endl;
        return 0;
    }
    if(K>=B){
        K-=B;
        sum+=0;
    }else{
        cout << sum << endl;
        return 0;
    }
    if(K>=C){
        sum-=C;
    }else{
        sum-=K;
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 3688
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

import itertools
import numpy as np
from functools import lru_cache
from operator import itemgetter

X = list(map(int,readline().split()))
Y = list(map(int,readline().split()))

for i in [1,3,5]:
    X[i] += 1
    Y[i] += 1

X1 = X[:2]; X2 = X[2:4]; X3 = X[4:]
Y1 = Y[:2]; Y2 = Y[2:4]; Y3 = Y[4:]

def cumprod(arr,MOD):
    L = len(arr); Lsq = int(L**.5+1)
    arr = np.resize(arr,Lsq**2).reshape(Lsq,Lsq)
    for n in range(1,Lsq):
        arr[:,n] *= arr[:,n-1]; arr[:,n] %= MOD
    for n in range(1,Lsq):
        arr[n] *= arr[n-1,-1]; arr[n] %= MOD
    return arr.ravel()[:L]

def make_fact(U,MOD):
    x = np.arange(U,dtype=np.int64); x[0] = 1
    fact = cumprod(x,MOD)
    x = np.arange(U,0,-1,dtype=np.int64); x[0] = pow(int(fact[-1]),MOD-2,MOD)
    fact_inv = cumprod(x,MOD)[::-1]
    return fact,fact_inv

U = 2 * 10 ** 6 + 10
MOD = 10**9 + 7
fact, fact_inv = make_fact(U,MOD)

@lru_cache(8)
def make_comb(n):
    return fact[n] * fact_inv[:n+1] % MOD * fact_inv[:n+1][::-1] % MOD

answer = 0
tasks = []
for p in itertools.product([0,1],repeat=6):
    x1,x2,x3,y1,y2,y3 = [A[i] for A,i in zip([X1,X2,X3,Y1,Y2,Y3],p)]
    sgn = (-1) ** sum(p)
    a,b,c,d = x2-x1, x3-x2, x2-x1+y2-y1, x3-x2+y3-y2
    c += 2; d += 2; sgn = -sgn
    tasks.append((a,b,c,d,sgn))

tasks.sort(key = itemgetter(2))

for a,b,c,d,sgn in tasks:
    # (1+A)^c(1+B)^d / (A-B)^2 における A^aB^b の係数
    # まずはa+b+2次式部分を抽出する：A側の次数で持つ
    D = a + b + 2
    # A^i B^j の寄与。
    L = max(0, D-d)
    R = min(c, D)
    if L > R:
        continue
    x = make_comb(c)[L:R+1]
    L,R = D-R,D-L
    y = make_comb(d)[L:R+1]
    x = x * y[::-1] % MOD
    # B=1と見立てる。(1-A)^2 で割って、A^(a-L)の係数
    np.cumsum(x,out=x)
    x %= MOD
    np.cumsum(x,out=x)
    x %= MOD
    L,R = D-R,D-L
    if 0 <= a-L < len(x):
        answer += sgn * x[a-L]

answer %= MOD
print(answer)

Measured memory_bytes: 200800
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1000000007;
const ld PI = acos(-1);  
const ld EPS = 0.0000000001;
#define REP(i, n) for(ll i=0; i<(ll)(n); i++)
#define REPD(i, n) for(ll i=n-1; 0<=i; i--)
#define FOR(i, a, b) for(ll i=a; i<(ll)(b); i++)
#define FORD(i, a, b) for(ll i=a; (ll)(b)<=i; i--)
#define ALL(x) x.begin(), x.end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

int main(){
    ll n, m;    cin >> n >> m;
    vector<ll> div;
    for(ll i=1; i*i<=m; i++){
        if(m%i==0){
            div.push_back(i);
            if(i!=m/i) div.push_back(m/i);
        }
    }
    sort(ALL(div),greater<ll>());
    for(auto x: div){
        if(m<x*n) continue;
        cout << x << endl;
        return 0;
    }
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <functional>
#include <utility>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  for(int i = 0;i < N;i++)cin >> A[i];

  int cnt[3] = {0,0,0};
  ll ans = 1;

  for(int i = 0;i < N;i++){
    ll c_cnt = 0;
    for(int j = 0;j < 3;j++){
      if(A[i] == cnt[j])c_cnt++;
    }

    ans *= c_cnt;
    ans %= MOD;

    for(int j = 0;j < 3;j++){
      if(A[i] == cnt[j]){
	cnt[j]++;
	break;
      }
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 640
s = input()
q = int(input())
from collections import deque
f_s = deque([])
b_s = deque([])
fwd = 1
for i in range(q):
    qs = list(input().split())
    if qs[0] == '1':
        fwd ^= 1
    elif qs[1] == '1':
        if fwd:
            f_s.appendleft(qs[2])
        else:
            b_s.append(qs[2])
    else:
        if fwd:
            b_s.append(qs[2])
        else:
            f_s.appendleft(qs[2])
print("".join(f_s)+s+"".join(b_s) if fwd else ("".join(f_s)+s+"".join(b_s))[::-1])

Measured memory_bytes: 12380
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define pb push_back
#define eb emplace_back
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
const ll INF = numeric_limits<ll>::max()/4;
const ll MOD = 1e9+7;
const int n_max = 1e5+10;

int main(){
    ll n,a,b; cin >> n >> a >> b;
    cout  << (abs(a-b) & 1 ? "Borys" : "Alice") << endl;
}

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

int main() {
  long long n, price = 1000; cin >> n;
  vector<long long> a(n); for(int i = 0; i < n; i++) cin >> a[i];
  for(int i = 0; i < n-1; i++) {
    long long stocks = 0;
    if(a[i] < a[i+1]) stocks = price / a[i];
    price += (a[i+1] - a[i]) * stocks;
  }
  cout << price << endl;
  return 0;
}


Measured memory_bytes: 3592
#include<stdio.h>

int main() {
    int n, k;
    scanf("%d %d",&n,&k);

    double p = 0;
    for(int a=1;a<=n;a++) {
        int t = a;
        double s = 1;
        while(t < k) {
            t *= 2;
            s *= 0.5;
        }

        p += s;
    }

    printf("%.12lf\n", p/n);
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
int N;
  cin>>N;
  vector<int>a(N);
  for(int i=0;i<N;i++)
    cin>>a.at(i);
  sort(a.begin(),a.end());
  int Min=a.at(0);
  int Max=a.at(N-1);
  map<int,int>M;
  for(int i=Min-3;i<=Max;i++)
    M[i]=0;
  for(int i=0;i<N;i++)
    M.at(a.at(i))++;
  int ans=0;
  int sum=0;
  for(int i=Min-3;i<=Max-3;i++){
  sum+=(M.at(i+3)-M.at(i));
    if(ans<=sum)
      ans=sum;
  }
  
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 5376
fun main() {
    val (n, m) = readLine()!!.split(' ').map { it.toInt() }
    val yd = Array(n + 1) { mutableListOf<Int>() }
    val py = (0 until m).map {
        val (p, y) = readLine()!!.split(' ').map { it.toInt() }
        yd[p].add(y)
        p to y
    }
    yd.forEach { it.sort() }

    val ans = py
            .joinToString("\n") { (p, y) ->
                p.toString().padStart(6, '0') +
                        (yd[p].binarySearch(y) + 1).toString().padStart(6, '0')
            }
    println(ans)
}


Measured memory_bytes: 85824
#include <iostream>
#include <stdio.h>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <limits.h>
#include <math.h>

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

using namespace std;
int good;
int mx;
bool correct;
int ans;
int main() {
    while(1) {
        correct = 0;
        ans = 0;
        cin >> good >> mx;
        if(good == 0) break;
        vector<int> p(good);
        for(int i= 0; i<good;i++) cin >> p[i];
        sort(p.begin(), p.end());
        for(int i = good-1; i >= 0;i--) {
            for(int j = 1;j <= i;j++) {
                if(p[i] + p[i-j] <= mx && ans < p[i] + p[i-j]) {
                    ans = p[i] + p[i-j];
                }
            } 
        }
        if(ans == 0) cout << "NONE" << endl;
        else cout << ans << endl;
    }
}


Measured memory_bytes: 3116
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,K;
  int L = 1;
  
  cin >> N >> K;
  
  for (int i = 0; i < N; i++) {
    if (L * 2 < L + K) {
      L *= 2;
    }
    else {
      L += K;
    }
  }
  
  cout << L << endl;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define DEBUG(x) cout << #x << " = " << x << endl
#define pb push_back
using namespace std;
typedef long long ll;


const int MAXN = 500005;
ll a[MAXN];
ll ans;
int main()
{
    //freopen("input.txt", "r", stdin);
    int n;
    cin >> n;
    for (int i = 0; i < 3*n; i++)
    {
        cin >> a[i];
    }
    sort(a, a + 3*n);
    for (int i = 0; i < n; i++)
    {
        ans += a[3*n - 2 - 2*i];
    }

    cout << ans;

    return 0;
}




Measured memory_bytes: 2560
class Problem
  attr_accessor *(?a..?z).to_a.map(&:to_sym)
  def initialize
    @d,@t,@s = gets.split.map(&:to_i)
  end

  def solve
    d <= t * s
  end

  def show(ans)
    puts ans ? "Yes" : "No"
  end
end

Problem.new.instance_eval do
  show(solve)
end

Measured memory_bytes: 14380
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define deb(x) cout<< #x << " " << x << "\n";
#define MAX 9223372036854775807
#define MIN -9223372036854775807
#define PI 3.141592653589
#define setbits(n) __builtin_popcountll(n)
const ll mod=1e9+7;


const int N=2e5+5;
ll f[N],invf[N];

int mul(int a, int b) {
    return (ll) a * b % mod;
}
int my_pow(int a, int b) {
    int r = 1;
    while(b) {
        if(b % 2) {
            r = mul(r, a);
        }
        a = mul(a, a);
        b /= 2;
    }
    return r;
}
int inv_fac(int a) {
    return my_pow(a, mod - 2);
}
 
int binomial(int a, int b) {
    if(a < 0 || b < 0 || b > a) {
        return 0;
    }
    return mul(f[a], mul(invf[b], invf[a-b]));
}
 
int fa(int a, int b) {
    int tmp = binomial(a + b, b);
    //~ debug() << imie(a) imie(b) imie(tmp);
    return tmp;
}

ll mpow(ll x, ll y){ 
    ll res = 1;
    x = x % mod;
    while (y > 0) { 
        if (y & 1) res = (res * x) % mod; 
        y = y >> 1;
        x = (x * x) % mod; 
    } 
    return res; 
} 
  
ll modInv(ll n){ 
    return mpow(n,mod-2); 
} 

void fact(){
    f[0]=1;
    invf[0]=1;
    for(ll i=1;i<N;i++){
        f[i]=(f[i-1]*i)%mod; 
        invf[i]=inv_fac(f[i]);
    }
}

ll paths(pair<ll,ll> p1, pair<ll,ll> p2){
    ll a=p1.first, b=p1.second, x=p2.first, y=p2.second;
    return ((f[x-a+y-b]*modInv(f[x-a]))%mod*modInv(f[y-b]))%mod;
}

ll paths1(pair<ll,ll> p1, pair<ll,ll> p2){
    ll a=p2.first - p1.first, b=p2.second - p1.second;
    return (f[a+b]*(modInv(f[a])*modInv(f[b]))%mod)%mod;
}

const int M=1e3+5;
ll n,m,k;

bool comp(pair<ll,ll> a, pair<ll,ll> b){
    return a.first+a.second<b.first+b.second;
}

int sub(int a, int b) {
    return (a - b + mod) % mod;
}


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

        f[0] = invf[0] = 1;
    for(int i = 1; i < N; ++i) {
        f[i] = mul(f[i-1], i);
        invf[i] = inv_fac(f[i]);
    }
    int h, w, n;
    scanf("%d%d%d", &h, &w, &n);
    vector<pair<int,int>> in(n);
    for(int i = 0; i < n; ++i) {
        scanf("%d%d", &in[i].first, &in[i].second);
    }
    sort(in.begin(), in.end(), [&](pair<int,int> a, pair<int,int> b) {
        return a.first + a.second < b.first + b.second;
    });
    // dp[i] - the number of paths to vertex in[i] such that it's the first
    // forbidden vertex
    
    in.emplace_back(h, w);
    
    vector<int> dp(n + 1);
    for(int i = 0; i <= n; ++i) {
        int tmp = fa(in[i].first - 1, in[i].second - 1);
        //debug() << imie(tmp);
        for(int j = 0; j < i; ++j) {
            if(in[j].first <= in[i].first && in[j].second <= in[i].second) {
                tmp = sub(tmp, mul(dp[j], fa(in[i].first - in[j].first, in[i].second-in[j].second)));
            }
        }
        dp[i] = tmp;
    }
    //debug() << imie(dp);
    printf("%d\n", dp[n]);


    cerr<<"\n\nTIME: "<<(double)(clock()-T)/CLOCKS_PER_SEC<<" sec\n";
    T = clock();
    return 0;
}


Measured memory_bytes: 7064
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;

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

int main() {
    int N;
    cin >> N;
    // B[i]:A[0]～A[i]  のgcd
    // C[i]:A[i]～A[N-1]のgcd
    vector<int> A(N), B(N), C(N);
    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
    }
    B[0] = A[0];
    C[N - 1] = A[N - 1];
    for (int i = 1; i < N; i++)
    {
        B[i] = gcd(B[i - 1], A[i]);
        C[N - i - 1] = gcd(C[N - i], A[N - i - 1]);
    }
    int M = 0; //求める最大値
    // 1つ選んで好きな数字に変える → 1つ選んでその数字以外のgcd
    // 選ぶ1つを探索
    for (int i = 0; i < N; i++)
    {
        if (i == 0) {
            // 左端
            M = max(M, C[1]);
        }
        else if (i == N - 1) {
            // 右端
            M = max(M, B[N - 2]);
        }
        else {
            M = max(M, gcd(B[i - 1], C[i + 1]));
        }
    }
    cout << M << endl;
    getchar(); getchar();
    return 0;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
int main ()
{
    int n,m;
    cin>>n>>m;
    int a=max(n,m),b=min(n,m);
    string res="";
    while(a--) res += to_string(b);
    cout<<res<<endl;
    return 0;
}

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

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back

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

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

const int inf=1e9;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};	

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

	cout<< x/500*1000+x%500/5*5  <<endl;


	return 0;
}



Measured memory_bytes: 256
//  cout << char(i+48) << endl;//なぜかaは47と得る時がある。+48で出力もaにできる。
//  cout << char(97) << endl;//アスキーコードでaを出力
// sort(b.begin(), b.end());//bという配列を小さい方からソート
// reverse(b.begin(), b.end());//bという配列をリターン
// 10桁でdouble出力するパターン１ 
// printf("%.10f\n", ma);
// 10桁でdouble出力するパターン２
//cout << fixed << setprecision(10);
//  cout << ma << endl;

/*01 02 03 12 13 23　と６回見ていくパターン 
for(int i=0;i<n-1;i++){
  for(int j=i+1;j<n;j++){
    }
  }
*///vector<vector<int>> data(3, vector<int>(4));//int型の2次元配列(3×4要素の)の宣言
//int64_t a;
//10のi乗pow(10, i);
/*string s; stringでの文字列を数字型に変える方法
  cin >> s;
  rep(i,s.size()-2) {
  int a= (s.at(i)-'0')*100 + (s.at(i+1)-'0')*10+ s.at(i+2) -'0';
    */
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  int n,l;
  cin >> n >> l;
  vector<string> s(n);
  rep(i,n) cin >> s.at(i);
  sort (s.begin(),s.end());
  rep(i,n) cout << s.at(i);
}

Measured memory_bytes: 256
import math

N = int(input())
p = list(map(int, input().split()))
q = list(map(int, input().split()))

# calc p order
a = 1
remain = list(range(1, N+1))
for i in range(N-1):
    ind = remain.index(p[i])
    remain.remove(p[i])
    a += math.factorial(len(remain)) * ind

# calc p order
b = 1
remain = list(range(1, N + 1))
for i in range(N - 1):
    ind = remain.index(q[i])
    remain.remove(q[i])
    b += math.factorial(len(remain)) * ind

print(abs(a-b))


Measured memory_bytes: 38384
A=[]
while(True):
	n,m=map(int,input().split())
	if n==0 and m==0:
		break
	#print(n,m)
	P=list(map(int,input().split()))
	#print(P)
	mark=1
	sign=1
	for i in range(n):
		for j in range(i,n):
			if i==j:
				pass
			else:
				#print(i,j)
				if m-(P[i]+P[j])>=0:
					if mark==1:
						max=P[i]+P[j]
						mark=0
						sign=0
					else:
						if P[i]+P[j]>max:
							max=P[i]+P[j]
				else:
					pass
	if sign==0:
		A.append(max)
	else:
		A.append(-1)
#print(A)
A.reverse()
for i in range(len(A)):
	tmp=A.pop()
	if tmp==-1:
		print("NONE")
	else:
		print(tmp)


Measured memory_bytes: 5716
n,m = map(int,input().split())

s = [0]*n

for i in range(m):
    keta, num = map(int,input().split())
    if keta == 1 and num == 0 and n != 1:
        print(-1)
        exit()
    if s[keta-1] == 0 or s[keta-1] == num:
        s[keta-1] = num
    else:
        print(-1)
        exit()

if s[0] != 0:
    print(*s, sep ="")
elif s[0] == 0 and n == 1:
    print(0)
elif s[0] == 0 and n != 1:
    s[0] = 1
    print(*s, sep ="")
else:
    print(-1)

Measured memory_bytes: 3064
N, M = map(int, input().split())
A = list(map(int, input().split()))

vote = sum(A)
for i in range(N):
  if(A[i] >= vote/(4*M)):
    A[i] = 1
  else:
    A[i] = 0

if(M <= sum(A)):
  print("Yes")
else:
  print("No")

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

using namespace std;

#define mp make_pair
#define fi first
#define se second
#define all(v) v.begin(),v.end()
#define allarr(a) a , a + n
#define ll long long
#define ull unsigned long long 
#define pb push_back
#define fastio ios_base::sync_with_stdio(false) ; cin.tie(NULL); cout.tie(NULL)
typedef pair<int, int> pi;
typedef pair<ll,ll> pll; 
typedef pair<int,pi> trp ;
typedef vector<pi> vpi;
typedef vector<pll> vpll ;
ll _abs (ll x ) { return (x>0?x:-x); }
map<int,int> m ; 
bool comp ( pair<string,int> a , pair<string,int> b ){
	return (a.fi < b.fi || (a.fi==b.fi && a.se > b.se ) ) ;
}
int main(){
	vector<pair<string,int> > a ; 
	int n ,x; 
	cin>>n ;
	string s; 
	for(int i= 0; i < n ; i++ ){
		cin>>s>>x; 
		m[x]=i ;
		a.pb(mp(s,x)) ; 
	}
	sort(all(a),comp); 
	for(int i = 0 ; i<n ; i++ ){
		cout << m[a[i].se]+1 <<endl; 
	}
}



Measured memory_bytes: 256
import copy
import sys

INF = 2**120

n = int(input())
d = [[] for j in range(n)]
for j in range(n):
    d[j] = [int(i) for i in input().split()]

ans = sum([sum(d[i]) for i in range(n)])

minus = [[0] * n for i in range(n)]

for k in range(n):
    for i in range(n):
        for j in range(n):
            if d[i][j] > d[i][k]+d[k][j]:
                print('-1')
                sys.exit()
            if d[i][j] == d[i][k]+d[k][j] and i != k and j != k:
                minus[i][j] = 1

for i in range(n):
    for j in range(n):
        if minus[i][j]:
            ans -= d[i][j]

print(ans//2)

Measured memory_bytes: 76640
#include <bits/stdc++.h>
#include <algorithm>
#include <map>
#include <cstdlib>
#include <cmath>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
const double pi=acos(-1);

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

int main(){
    int n,k;
    cin >> n >> k;
    vector<int> h(n);
    for(int i=0;i<n;i++) cin >> h[i];
    sort(h.begin(),h.end());
    int ans=1000000000;
    for(int i=0;i<n-k+1 ;i++){
        ans=min(ans,h[i+k-1]-h[i]);
    }
    cout << ans << endl;
}


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

using namespace std;

#define fi first
#define se second
#define pb push_back
#define sz(x) ((int)(x).size())
#define whole(x) (x).begin(), (x).end()

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

const int N = (int)2e5 + 2;
const int LG = 20;
const int mod = (int)1e9 + 7;
const int INF = (int)1e9 + 7;
const ll linf = 1e13;
const ld pi = acos(-1);
const int base = 10;
const ld EPS = 1e-9;

int n, m, dp[1005][1005];
bool used[1005][1005];
char a[1005][1005];

int add (int a, int b)
{
    int c = a + b;
    if (c >= mod) c -= mod;
    return c;
}

void dfs (int x, int y)
{
    used[x][y] =  true;
    if (x + 1 <= n && !used[x + 1][y] && a[x + 1][y] != '#') dfs(x + 1, y);
    if (y + 1 <= n && !used[x][y + 1] && a[x][y + 1] != '#') dfs(x, y + 1);
}

int main ()
{
    cin >> n >> m;
    for (int i = 1; i <= n; ++i)
    {
        for (int j = 1; j <= m; ++j)
        {
            cin >> a[i][j];
        }
    }
    dfs(1, 1);
    for (int i = 1; i <= n; ++i)
    {
        if (used[i][1]) dp[i][1] = 1;
    }
    for (int j = 1; j <= m; ++j)
    {
        if (used[1][j]) dp[1][j] = 1;
    }
    for (int i = 2; i <= n; ++i)
    {
        for (int j = 2; j <= m; ++j)
        {
            if (a[i][j] == '#') continue;
            dp[i][j] = add(dp[i - 1][j], dp[i][j - 1]);
        }
    }
    printf ("%d\n", dp[n][m]);
    return 0;
}


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

using E = System.Linq.Enumerable;

public class Program
{
    public static void Main()
    {
        var d = int.Parse(Console.ReadLine());
        var s = string.Join(" ", E.Concat(new [] { "Christmas" }, E.Repeat("Eve", 25 - d)));
        Console.WriteLine(s);
    }
}

Measured memory_bytes: 13268
#include <iostream>
#include <cmath>
using namespace std;
#define EPS (1e-10)

int n, hx, hy, dx ,dy;
int cx[21], cy[21];
bool done[21];
bool ans;

double D(double x1, double y1, double x2, double y2){
	return sqrt( (x1-x2)*(x1-x2) + (y1-y2)*(y1-y2) );
}

void solve(double t, int x, int y){
	if( ans ) return ;

	int cnt=0;
	for(int i=0 ; i < n ; i++ ){
		if( done[i] ) cnt++;
	}
	if( cnt == n ){
		ans = true;
		return;
	}

	for(int i=0 ; i < n ; i++ ){
		if( done[i] ) continue;

		double next_time = t + D( x , y , cx[i] , cy[i] );
		if ( D( dx , dy , cx[i] , cy[i] ) < next_time + EPS ){ 
			return; 
		}
	}
	for(int i=0 ; i < n ; i++ ){
		if( done[i] ) continue;

		double next_time = t + D( x , y , cx[i] , cy[i] );
		done[i] = true;
		solve( next_time , cx[i] , cy[i] );
		done[i] = false;
	}
}

int main(){
	while( cin >> n >> hx >> hy >> dx >> dy , (n || hx || hy || dx || dy) ){
		for(int i=0 ; i < n ; i++ ){
			cin >> cx[i] >> cy[i];
		}

		for(int i=0 ; i < 21 ; i++ ){
			done[i] = false;
		}
		ans = false;
		solve( 0.0 , hx , hy );
		if( ans ){
			cout << "YES" << endl;
		}else{
			cout << "NO" << endl;
		}
	}
}

Measured memory_bytes: 868
#include <stdio.h>
#include <string>
#include <iostream>
#include <iomanip>
#include <map>
#include <algorithm>
#include <vector>
#include <math.h>
#include <queue>
#define MOD (long long)1000000007
#define INF (long long)998244353
using namespace std;

int main(void){
    int m,d;
    int M,D;
    cin >> m >> d;
    cin >> M >> D;
    string ans="0";
    if(m!=M)ans="1";
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner
import scala.math._

object Main extends App {
  val sc = new Scanner(System.in)
  val N, W = sc.nextInt
  val wv = Array.fill(N, 2)(sc.nextInt)

  val dp = Array.fill(N+1, W+1)(0L)

  for (i <- 1 to N) {
    val Array(wi, vi) = wv(i-1)
    for (w <- 0 to W) {
      dp(i)(w) = if (w >= wi) max(dp(i-1)(w), dp(i-1)(w-wi)+vi) else dp(i-1)(w)
    }
  }
  println(dp.last.last)
}


Measured memory_bytes: 146204
implicit none
integer,allocatable:: a(:)
integer:: n,i,j,count,b

read(*,*) n
allocate(a(n))
read(*,*) a

count=0
do j=1,1000
b=0
do i=1,n
if(mod(a(i),2)==0)then
b=b+1
endif
end do

if(b==n)then
a=a/2
count=count+1
else
exit
endif

end do

write(*,*) count

end


Measured memory_bytes: 2860
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const ll mod = 1e9+7;

//vector<int> d(100010,mod);
vector<vector<int>> to(200100);

/*void dfs(int a,int c,int p = -1){
    for(auto r:to[a]){
        if(r == p) continue;
        if(d[r] > c+1) d[r] = c+1;

    }
}*/

int main(){
    int n,m;
    cin >> n >> m;
    for(int i = 0; i < m; i++){
        int a,b;
        cin >> a >> b;
        a--;b--;
        to[a].push_back(b);
        to[b].push_back(a);
    }
    queue<int> que;
    vector<int> seen(n,false);
    vector<int> ans(n);
    que.push(0);
    while(!que.empty()){
        int now = que.front();que.pop();
        for(auto p:to[now]){
            if(seen[p]) continue;
            seen[p] = true;
            ans[p] = now;
            que.push(p);
        }
    }
    cout << "Yes" << endl;
    for(int i = 1; i < n; i++){
        cout << ans[i]+1 << endl;
    }
    return 0;
}

Measured memory_bytes: 12916
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(v) sort((v).begin(),(v).end())
#define RSORT(v) sort((v).rbegin(),(v).rend())
const ll MOD = 1000000007;

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

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

ll mulMod(ll a, ll b)
{
    return (((a % MOD) * (b % MOD)) % MOD);
}



void solve(long long A, long long B){
    if(A+B >= 10){
        cout << "error" << endl;
    }else{
        cout << A + B << endl;
    }
}

int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    solve(A, B);
    return 0;
}


Measured memory_bytes: 256
N, M = [int(i) for i in input().split(" ")]
A = [int(i) for i in input().split(" ")]

A.sort(reverse=True)
sum_voted = sum(A)

for i in range(M):
  if A[i] < sum_voted / (4 * M):
    print("No")
    exit(0)

print("Yes")


Measured memory_bytes: 9164
# -*- coding: utf-8 -*-
n = int(input())
g = [[] for _ in range(n)]
for i in range(n - 1):
    u, v = map(int, input().split())
    g[u - 1].append((v - 1))
    g[v - 1].append((u - 1))

c_list = list(map(int, input().split()))
c_list.sort(reverse=True)


ans = [-1 for _ in range(n)]

#次にどの頂点に行くのかを表すリスト
q = list()
 
# g[0] の処理
ans[0] = c_list[0]
c_list.pop(0)
#始め0から始めたいから0
q.append(0)

#qが0になるまで動かしたい
while(len(q) != 0):
    v = q[0]
    q.pop(0)
    for u in g[v]:
        # print(v, u, w)
        if ans[u] != -1:
            continue
        # 問題特有のやつ
        ans[u] = c_list[0]
        c_list.pop(0)
        #uという頂点を次にみる
        q.append(u)
    # print(v, q)


print(sum(ans[1:]))
print(" ".join([str(a) for a in ans])) 

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

typedef long long lli;

const int MAXN = 500005;
int N; lli P, Q;
lli C[MAXN];

lli sum(lli n) {
  return n * (n + 1) / 2;
}

lli sum(lli a0, lli len) {
  return sum(len) + len * (a0 - 1);
}

int main() {
  while(cin >> N >> P >> Q) {
    for(int i = 0; i < N; ++i) {
      cin >> C[i];
      C[i] -= P * (N - i - 1);
    }
    sort(C, C+N, greater<lli>());
    lli now = sum(Q, N) * P;
    lli res = now;
    for(int i = 0; i < N; ++i) {
      now += C[i];
      now -= ( Q - i + N - (i + 1) ) * P;
      //cout << now << endl;
      res = max(res, now);
    }
    cout << res << endl;
  }
  return 0;
}

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

using namespace std;

using ll = long long;
using ld = long double;

using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;

typedef pair<ll, ll> P;

#define bit(n) (1LL << (n))

//#define int long long

#define all(v) v.begin(), v.end()
#define sortAl(v) sort(all(v))
#define sortAlr(v)          \
  sort(v.begin(), v.end()); \
  reverse(v.begin(), v.end())

#define rep(i, n) for (ll i = 0; i < n; i++)
#define REP(i, n) for (ll i = 1; i < n; i++)

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

template <class T>
inline void chmax(T &a, T b) {
  a = std::max(a, b);
}
template <class T>
inline void chmin(T &a, T b) {
  a = std::min(a, b);
}

#define mod (ll)(1e9 + 7)
#define INF LLONG_MAX

#define ll long long

// Greatest Common Divisor (最大公約数)
ll gcd(ll a, ll b) {
  // Eucledean algorithm
  while (a) {
    if (a < b) {
      std::swap(a, b);
    }
    a %= b;
  }
  return b;
}

// 約数リスト
vector<ll> get_divisors(const ll n) {
  vector<ll> divs;
  for (ll i = 1; i < (ll)sqrt((ld)n) + 1; i++) {
    if (n % i == 0) {
      divs.push_back(i);
      if (i != n / i) {
        divs.push_back(n / i);
      }
    }
  }

  // 必要に応じてソート
  // sort(divs.begin(), divs.end());

  return divs;
}

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

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

  vll arr = get_divisors(gcd(a, b));
  sort(all(arr));
  reverse(all(arr));

  cout << arr[k - 1] << endl;

  return 0;
}


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

using namespace std;
#define cinf(n,x) for(int i=0;i<(n);i++) cin >> x[i];
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)

int main (){
    int c[10];
    cinf(9,c);
    bool fumiya = true;
    if(c[3] - c[0] == c[4] - c[1] && c[3] - c[0] == c[5] - c[2]){

    }else fumiya = false;
    if(c[6] - c[3] == c[7] - c[4] && c[6] - c[3] == c[8] - c[5]){

    }else fumiya = false;
    if(c[1] - c[0] == c[4] - c[3] && c[1] - c[0] == c[7] - c[6]){

    }else fumiya = false;
    if(c[2] - c[1] == c[5] - c[4] && c[2] - c[1] == c[8] - c[7]){

    }else fumiya = false;

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



    return 0;
}

Measured memory_bytes: 256
import sys
import math
import collections
import decimal
import itertools
from collections import deque
from functools import reduce
import heapq
#n = int(input())
n, k = map(int, sys.stdin.readline().split())
#s = input()
p = list(map(int, sys.stdin.readline().split()))

p.sort()
ans = 0
for i in range(k):
    ans += p[i]

print(ans)
















Measured memory_bytes: 10028
#include <bits/stdc++.h>
using namespace std;using ll=long long;using uint=unsigned int;using pii=pair<int,int>;using pll=pair<ll,ll>;using ull = unsigned long long;using ld=long double;template<typename T>void _(const char*s,T h){cerr<<s<<" = "<<h<<"\n";}template<typename T,typename...Ts>void _(const char*s,T h,Ts...t){int b=0;while(((b+=*s=='(')-=*s==')')!=0||*s!=',')cerr<<*s++;cerr<<" = "<<h<<",";_(s+1,t...);}// break continue pop_back 998244353
#define int ll
#define pii pll
#define f first
#define s second
#define pb emplace_back
#define forn(i,n) for(int i=0;i<(n);++i)
#define sz(a)((int)(a).size())
#define sqr(x) ((x)*(x))
struct init{init(){cin.tie(0);iostream::sync_with_stdio(0);cout<<fixed<<setprecision(10);cerr<<fixed<<setprecision(5);}~init(){
#ifdef LOCAL
#define dbg(...) _(#__VA_ARGS__,__VA_ARGS__)
cerr<<"Time elapsed: "<<(double)clock()/CLOCKS_PER_SEC<<"s.\n";
#else
#define dbg(...) 
#endif
}}init;template<typename T,typename U>void upx(T&x,U y){if(x<y)x=y;}template<typename T,typename U>void upn(T&x,U y){if(x>y)x=y;}mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());const int D=4,dx[]={+1,0,-1,0},dy[]={0,+1,0,-1};

int32_t main(){

    int x;
    cin>>x;
    int g=__gcd(x,360ll);
    cout<<360/g<<'\n';

    return 0;
}


Measured memory_bytes: 3636
macro_rules! read_line_to_tuple {
    ( $( $t:ty ),* ) => {{
        let mut input = String::new();
        std::io::stdin().read_line(&mut input).unwrap();
        let mut iter = input.split_whitespace();
        ( $( iter.next().unwrap().parse::<$t>().unwrap() ),* )
    }};
}

const MOD: u32 = 998_244_353;

fn main() {
    let (n, k) = read_line_to_tuple!(usize, usize);
    let lr: Vec<(usize, usize)> = {
        (0..k)
            .map(|_| read_line_to_tuple!(usize, usize))
            .collect()
    };

    let mut dp = vec![0; n + 1];
    dp[1] = 1;
    dp[2] = MOD - 1;
    for i in 1..n {
        for j in 0..k {
            if i + lr[j].0 <= n {
                dp[i + lr[j].0] += dp[i];
                dp[i + lr[j].0] %= MOD;
            }
            if i + lr[j].1 + 1 <= n {
                dp[i + lr[j].1 + 1] += MOD - dp[i];
                dp[i + lr[j].1 + 1] %= MOD;
            }
        }
        dp[i + 1] += dp[i];
        dp[i + 1] %= MOD;
    }
    println!("{}", dp[n]);
}

Measured memory_bytes: 2844
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int area = a * b;
		int length = (a + b) * 2;
		System.out.println(area + " " + length);
	}
}

Measured memory_bytes: 25920
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;


int main(){
	int h, w;
    char tmp;
    int s[55][55];

    cin >> h >> w;

    for(int i=0;i<=w+1;i++){
        s[0][i] = 0;
        s[h+1][i] = 0;
    }
    for(int i=0;i<=h+1;i++){
        s[i][0] = 0;
        s[i][w+1] = 0;
    }

    for(int i=1;i<=h;i++){
        for(int j=1;j<=w;j++){
            cin >> tmp;
            if(tmp == '.') s[i][j] = 0;
            else if(tmp == '#') s[i][j] = 1;
        }   
    }

    for(int i=1;i<=h;i++){
        for(int j=1;j<=w;j++){
            if(s[i][j] == 1){
                if(s[i-1][j] + s[i+1][j] + s[i][j-1] + s[i][j+1] == 0){
                    cout << "No" << endl;
                    return 0;
                }
            }
        }   
    }

	cout << "Yes" << endl;
	
	return 0;
}


Measured memory_bytes: 256
s = input()

odd = ['R', 'U', 'D']
even = ['L', 'U', 'D']

for i in range(len(s)):
    if i % 2 == 0 and s[i] not in odd:
        print('No')
        exit()
    elif i % 2 == 1 and s[i] not in even:
        print('No')
        exit()

print('Yes')

Measured memory_bytes: 3064
#include <stdio.h>

int main()
{
	int a,b,c,x,y=0;	
	scanf("%d %d %d",&a,&b,&c);	
	for(x=a; x<=b; x++){
		if(c%x==0){
			y++;
		}
	}
	printf("%d\n",y);	
	return 0;
}

Measured memory_bytes: 596
#include <stdio.h>
#include <string.h>
#include <ctype.h>

int main(void) {

    int i = 0, count = 0;
    char word[10], text[1000];

    for (i = 0; i < 10; i++) word[i] = 0;
    for (i = 0; i < 1000; i++) text[i] = 0;

    scanf("%s", word);
    for (i = 0; i < 10; i++) word[i] = tolower(word[i]);
    while (1) {
        scanf("%s", text);
        if (strcmp(text, "END_OF_TEXT") == 0) break;
        for (i = 0; i < 1000; i++) text[i] = tolower(text[i]);
        if (strcmp(text, word) == 0) count++;
    }
    printf("%d\n", count);

    return 0;

}

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

int main(){
	long long n, d;
	cin >> n >> d;
	long long count = 0;
	while(n--){
		long long x, y;
		cin >> x >> y;
		if(sqrt((x * x) + (y * y)) <= d){
			count++;
		}
	}
	cout << count << endl;
}



Measured memory_bytes: 3576
import java.io.IOException
import java.io.InputStream
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val l = sc.nextIntArray(n)
    val max = l.max()!!
    val sum = l.sum()
    println(if (max < sum - max) "Yes" else "No")
}

class Scanner(private val `in`: InputStream) {
    private val buffer = ByteArray(1024)
    private var ptr = 0
    private var buflen = 0

    companion object {
        private fun isPrintableChar(b: Byte): Boolean = b in 33..126
        private fun isNumericChar(b: Byte): Boolean = b in 48..57
        private fun digit(b: Byte): Int = b - 48
    }

    fun hasNextByte(): Boolean {
        if (ptr < buflen) return true
        ptr = 0
        try {
            buflen = `in`.read(buffer)
        } catch (e: IOException) {
            e.printStackTrace()
        }
        return 0 < buflen
    }

    private fun readByte(): Byte = if (hasNextByte()) buffer[ptr++] else -1

    private fun skipUnprintable() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++
    }

    fun hasNext(): Boolean {
        skipUnprintable()
        return hasNextByte()
    }

    fun next(): String {
        if (!hasNext()) throw NoSuchElementException()
        return buildString {
            var b = readByte()
            while (isPrintableChar(b)) {
                appendCodePoint(b.toInt())
                b = readByte()
            }
        }
    }

    fun nextInt(): Int {
        if (!hasNext()) throw NoSuchElementException()
        var n = 0
        var b = readByte()
        val minus = b.toChar() == '-'
        if (minus) b = readByte()
        if (!isNumericChar(b)) throw NumberFormatException()
        do {
            n *= 10
            n += digit(b)
            b = readByte()
        } while (isNumericChar(b))
        return if (minus) -n else n
    }

    fun nextInts(n: Int): Array<Int> = Array(n) { nextInt() }

    fun nextIntArray(n: Int): IntArray = IntArray(n) { nextInt() }

    fun nextIntArrays(n: Int, m: Int): Array<IntArray> {
        val arrays = Array(m) { IntArray(n) }
        repeat(n) { i -> repeat(m) { j -> arrays[j][i] = nextInt() } }
        return arrays
    }

    fun nextLong(): Long {
        if (!hasNext()) throw NoSuchElementException()
        var n = 0L
        var b = readByte()
        val minus = b.toChar() == '-'
        if (minus) b = readByte()
        if (!isNumericChar(b)) throw NumberFormatException()
        do {
            n *= 10
            n += digit(b)
            b = readByte()
        } while (isNumericChar(b))
        return if (minus) -n else n
    }

    fun nextLongs(n: Int): Array<Long> = Array(n) { nextLong() }

    fun nextLongArray(n: Int): LongArray = LongArray(n) { nextLong() }

    fun nextLongArrays(n: Int, m: Int): Array<LongArray> {
        val arrays = Array(m) { LongArray(n) }
        repeat(n) { i -> repeat(m) { j -> arrays[j][i] = nextLong() } }
        return arrays
    }

}

Measured memory_bytes: 31828