akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using P = pair<ll,ll>;
using Um = unordered_map<char,ll>;
#define fl cout<<flush;
#define endl '\n'
template <typename T> inline void prt(T v){cout<<v<<'\n';}
template <typename T> inline bool chmax(T &a, const T &b){if (a<b){a=b;return 1;}return 0;}
template <typename T> inline bool chmin(T &a, const T &b){if (a>b){a=b;return 1;}return 0;}
const ll INF=1LL<<60;
const ll MOD=1e9+7;
const ll MOD2=998244353;
const ld pi=3.14159265358979323846;
const ld eps=1e-10;


#define debug(v) cout<<#v<<": ",prt(v);
template <typename A,typename B>
inline void prt(pair<A,B> p){cout<<"("<<p.first<<", "<<p.second<<")\n";}
template <typename A,typename B,typename C>
inline void prt(tuple<A,B,C> p){cout<<"("<<get<0>(p)<<", "<<get<1>(p)<<", "<<get<2>(p)<<")\n";}
inline void prt(bool p){if(p)cout<<"True"<<'\n';else cout<<"False"<<'\n';}
template <typename T> 
inline void prt(vector<T> v){cout<<'{';for(ll i=0;i<v.size();i++){cout<<v[i];if(i<v.size()-1)cout<<", ";}cout<<'}'<<'\n';}
template <typename T> 
inline void prt(deque<T> v){cout<<'{';for(ll i=0;i<v.size();i++){cout<<v[i];if(i<v.size()-1)cout<<", ";}cout<<'}'<<'\n';}
template <typename A,typename B>
inline void prt(map<A,B> v){cout<<'{';ll c=0;for(auto &p: v){cout<<p.first<<":"<<p.second;c++;if(c!=v.size())cout<<", ";}cout<<'}'<<'\n';}
template <typename A,typename B>
inline void prt(unordered_map<A,B> v){cout<<'{';ll c=0;for(auto &p: v){cout<<p.first<<":"<<p.second;c++;if(c!=v.size())cout<<", ";}cout<<'}'<<'\n';}
template <typename T> 
inline void prt(set<T> v){cout<<'{';for(auto i=v.begin();i!=v.end();i++){cout<<*i;if(i!=--v.end())cout<<", ";}cout<<'}'<<'\n';}
template <typename T> 
inline void prt(multiset<T> v){cout<<'{';for(auto i=v.begin();i!=v.end();i++){cout<<*i;if(i!=--v.end())cout<<", ";}cout<<'}'<<'\n';}


signed main(void){
    cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    vector<ll> S(1LL<<N,0);
    for(ll i=0;i<(1LL<<N);++i)cin>>S[i];
    sort(S.rbegin(), S.rend());
    multiset<ll> selected;
    multiset<ll> notyet;
    selected.insert(S[0]);
    for(ll i=1;i<(1LL<<N);++i){
        notyet.insert(S[i]);
    }
    for(ll i=0;i<N;++i){
        multiset<ll> select;
        auto itr=selected.end();
        for(ll j=0;j<(1LL<<i);++j){
            --itr;
            auto x=notyet.lower_bound(*itr);
            if(x==notyet.begin()){
                prt("No");
                return 0;
            }
            --x;
            select.insert(*x);
            notyet.erase(x);
        }
        for(auto p: select){
            selected.insert(p);
        }
    }
    prt("Yes");

    return 0;
}



Measured memory_bytes: 23748
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.*;


public class Main {
    int[] time;
    private void solve() {
        time = new int[3];
        for(int i = 0;i < 3;i++) {
            time[i] = nextInt();
        }

        int ans = Integer.MAX_VALUE;
        for(int i = 0;i < 3;i++) {
            ans = Math.min(ans, time[i] + time[(i + 1) % 3]);
        }

        out.println(ans);
    }

    public static void main(String[] args) {
        out.flush();
        new Main().solve();
        out.close();
    }

    /* Input */
    private static final InputStream in = System.in;
    private static final PrintWriter out = new PrintWriter(System.out);
    private final byte[] buffer = new byte[4096];
    private int p = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (p < buflen)
            return true;
        p = 0;
        try {
            buflen = in.read(buffer);
        } catch (IOException e) {
            e.printStackTrace();
        }
        if (buflen <= 0)
            return false;
        return true;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrint(buffer[p])) {
            p++;
        }
        return hasNextByte();
    }

    private boolean isPrint(int ch) {
        if (ch >= '!' && ch <= '~')
            return true;
        return false;
    }

    private int nextByte() {
        if (!hasNextByte())
            return -1;
        return buffer[p++];
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = -1;
        while (isPrint((b = nextByte()))) {
            sb.appendCodePoint(b);
        }
        return sb.toString();
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}


Measured memory_bytes: 21204
n = int(input())
tal = [[int(i) for i in input().split()] for i in range(n)]
t,a = 1,1 
for i in range(n):
    m = max(t//tal[i][0],a//tal[i][1])
    if t>tal[i][0]*m or a>tal[i][1]*m:
        m += 1
    t = m*tal[i][0]
    a = m*tal[i][1]
print(a+t)


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

long long a[200005], s[200005];

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	int n;
	cin>>n;
	
	for(int i=1;i<=n;i++){
		cin>>a[i];
		
		s[i] = s[i-1] + a[i];
	}

	long long ans=INFINITY, aux;
	
	for(int i=1;i<n;i++){
		aux=abs(s[i]-s[n]+s[i]);
		ans=min(ans, aux);
	}
	
	cout<<ans;
}


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

#define ll int64_t
using namespace std;
#include <cstdlib> 
#include <math.h>
#include<cstdio>
#include<cstring>
#define FOR(I, A, B) for (ll I = (A); I <= (B); I++)
#define fo(i,n) for(ll i=0;i<n;i++)
#define sz(a) ll((a).size())
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define dbg(x) cout << #x << " = " << x << endl
#define dbg2(x,y) cout << #x << " = " << x << ", " << #y << " = " << y << endl
#define dbg3(x,y,z) cout << #x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << endl
#define dbg4(x,y,z,q) cout << #x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << ", " << #q << " = " << q << endl
#define scan(char_array) scanf("%[^\n]s",&char_array)
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);


int main(){
    IOS
    string s;
    cin>>s;
    ll x,y;
    cin>>x>>y;
    map<ll,ll> xx;
    map<ll,ll> yy;
    xx[0]=1;
    ll cnt=0;
    ll to_inc=0;
    for(auto pp:s){
        if(pp=='T') {
            if(cnt%2==0){
                set<ll> gett;
                for(auto kk:xx){
                    if(kk.second>0) {
                        gett.insert(kk.first+to_inc);
                        if(cnt>0) gett.insert(kk.first-to_inc);}
                }
                xx.clear();
                for(auto pp:gett){
                    xx[pp]++;
                }
                
            }
            cnt++;
            to_inc=0;
        }
        else if(cnt%2==0) to_inc++;
       // dbg2(pp,to_inc);
        //for(auto kk:xx){
          //      //dbg(kk.first);
        // }
        
    }
    if(to_inc&&cnt%2==0){
        set<ll> gett;
                for(auto kk:xx){
                    if(kk.second>0) {
                        gett.insert(kk.first+to_inc);
                        if(cnt>0) gett.insert(kk.first-to_inc);}
                }
                xx.clear();
                for(auto pp:gett){
                    xx[pp]++;
                }
    }
    yy[0]=1;
    to_inc=0;
    cnt=0;
    for(auto pp:s){
        if(pp=='T') {
            if(cnt%1==0){
                set<ll> gett;
                for(auto kk:yy){
                    if(kk.second>0) {gett.insert(kk.first+to_inc); gett.insert(kk.first-to_inc);}
                }
                yy.clear();
                for(auto pp:gett){
                    yy[pp]++;
                }
                
            }
            cnt++;
            to_inc=0;
        }
        else if(cnt%2==1) to_inc++;
        
    }


     if(to_inc&&cnt%2==1){
        set<ll> gett;
                for(auto kk:yy){
                    if(kk.second>0) {
                        gett.insert(kk.first+to_inc);
                        if(cnt>0) gett.insert(kk.first-to_inc);}
                }
                yy.clear();
                for(auto pp:gett){
                    yy[pp]++;
                }
    }
   

    if(xx[x]>0&&yy[y]>0) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

}

Measured memory_bytes: 896
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<tuple>
#include<bitset>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-15
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
ll Merge(std::vector<ll>& a, ll i, ll chunk_size, std::vector<ll>& tmp) {
     std::vector<ll>::iterator a1 = a.begin() + i;
     ll l1 = chunk_size;
     std::vector<ll>::iterator a2 = a1 + l1;
     ll l2 = (a.size() > i + chunk_size * 2) ? chunk_size : a.size() - i - chunk_size;

     tmp.clear();
     ll res = 0;

     for (ll i1 = 0, i2 = 0; i1 != l1 || i2 != l2; ) {
          if (i1 == l1) {
               tmp.push_back(a2[i2++]);
          } else if (i2 == l2) {
               tmp.push_back(a1[i1++]);
          } else if (a1[i1] <= a2[i2]) {
               tmp.push_back(a1[i1++]);
          } else if (a2[i2] <= a1[i1]) {
               tmp.push_back(a2[i2++]);
               res += l1 - i1;
          } else {
               std::cerr << "Oops" << std::endl;
          }
     }

     for (ll di = 0; di < tmp.size(); ++di)
          a[i + di] = tmp[di];

     return res;
}

ll CountCross(std::vector<ll>& a) {
     ll res = 0;
     std::vector<ll> tmp(a.size());

     for (ll chunk_size = 1; chunk_size < a.size(); chunk_size *= 2)
          for (ll i = 0; i + chunk_size < a.size(); i += chunk_size * 2)
               res += Merge(a, i, chunk_size, tmp);

     return res;
}
int main(){
	ll N,K,a[200001];
	vll asum;
	asum.push_back(0);
	scan(N);scan(K);
	rep(i,N){
		scan(a[i]);
		a[i]-=K;
		asum.push_back(asum.back()+a[i]);
	}
	ll tento=CountCross(asum);
	ll ans=N*(N+1)/2-tento;
	prin(ans);
	return 0;
}


Measured memory_bytes: 5104
W, H, N = map(int, input().split())
a = [list(map(int, input().split())) for i in range(N)]

xa = [0]
xb = [W]
ya = [0]
yb = [H]


for i in range(N):
    if a[i][2] == 1:
        xa.append(a[i][0])
    elif a[i][2] == 2:
        xb.append(a[i][0])
    elif a[i][2] == 3:
        ya.append(a[i][1])
    elif a[i][2] == 4:
        yb.append(a[i][1])

x1 = max(xa)
x2 = min(xb)
y1 = max(ya)
y2 = min(yb)
if x1 < x2 and y1 < y2:
    print((x2 - x1) * (y2 - y1))
else:
    print("0")
    

Measured memory_bytes: 3064
def check(a):
  for i in range(int(len(a)/2)):
    if a[i]!=a[-(i+1)]:
       return False
  return True
 
S=input()
if check(S):
  a=S[0:int(len(S)/2)]
  b=S[int(len(S)/2)+1:len(S)]
  if check(a) and check(b):
    print('Yes')
  else:
    print('No')
else:
    print('No')

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

cnt = 0
nums = ''

def dfs(nums):
    global cnt
    
    if len(nums) >= 10:
        return
        
    k = list(nums)
    k = set(nums)

    if len(nums) >= 1:
        if int(nums) <= N and len(k) >= 3:
            cnt += 1
    
    dfs(nums + '3')
    dfs(nums + '5')
    dfs(nums + '7')

    return

dfs(nums)

print(cnt)

Measured memory_bytes: 3064
# -*- coding: utf-8 -*-
import sys
from collections import deque, defaultdict
from math import sqrt, factorial
# def input(): return sys.stdin.readline()[:-1] # warning not \n
# def input(): return sys.stdin.buffer.readline().strip() # warning bytes
# def input(): return sys.stdin.buffer.readline().decode('utf-8')


def solve():
    n, m = [int(x) for x in input().split()]
    ac = set()
    pen = defaultdict(int)
    pp = 0
    for _ in range(m):
        p, S = [x for x in input().split()]
        if p not in ac and S == 'AC':
            ac.add(p)
            pp += pen[p]
        else:
            if not p in ac:
                pen[p] += 1

    print(len(ac), pp)

t = 1
# t = int(input())
for case in range(1,t+1):
    ans = solve()


"""


"""


Measured memory_bytes: 26428
#include <cstdio>
void reader(int *x) {
	char k = getchar_unlocked(); *x = k - '0';
	while (1) {
		k = getchar_unlocked();
		if (k < '0' || k > '9') break;
		*x = ((*x) << 1) + ((*x) << 3) + k - '0';
	}
}
void reader(long long *x) {
	char k = getchar_unlocked(); *x = k - '0';
	while (1) {
		k = getchar_unlocked();
		if (k < '0' || k > '9') break;
		*x = ((*x) << 1) + ((*x) << 3) + k - '0';
	}
}
int n, b[100009]; long long a[100009];
int main() {
	reader(&n);
	for (int i = 0; i < n; i++) {
		reader(&a[i]);
		reader(&b[i]);
	}
	long long ret = 0;
	for (int i = n - 1; i >= 0; i--) {
		long long d = (a[i] + ret) % b[i];
		if (d) ret += b[i] - d;
	}
	printf("%lld\n", ret);
	return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD=1e9+7;

long long mgcd(int a,int b){
  if(a>b) return mgcd(b,a);
  if(a==0) return b;
  return mgcd(b,a%b);
}

int main() {
  int n;
  cin>>n;
  long long suma=0;
  rep(i,n){
    int a;
    cin>>a;
    suma+=a;
  }
  cout<<suma-n<<endl;
}

Measured memory_bytes: 256
# ABC106D - AtCoder Express 2
from itertools import accumulate as acc


def main():
    # 2D cumulative sum
    N, M, Q, *X = map(int, open(0).read().split())
    LR, PQ = X[: 2 * M], X[2 * M :]
    rails = [[0] * (N + 1) for _ in range(N + 1)]
    for l, r in zip(*[iter(LR)] * 2):
        rails[l][r] += 1
    rails = tuple(tuple(acc(a)) for a in rails)
    rails = tuple(tuple(acc(a[::-1]))[::-1] for a in zip(*rails))
    ans = []
    for p, q in zip(*[iter(PQ)] * 2):
        ans.append(rails[q][p])
    print("\n".join(map(str, ans)))


if __name__ == "__main__":
    main()

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

inline int read()
{
	int ret=0; char c=getchar();
	while(c<48||c>57)c=getchar();
	while(c>=48 && c<=57)ret=ret*10+c-48,c=getchar();
	return ret;
}
#define N 200010
int vi2[N],u,v,m,n,ans,p[N],vi[N],a[N],c[N][2],tot;
set<int>s;

void dfs(int p, int pr)//dian bian
{
	s.insert(p); vi[p]=1;
	for(int o=a[p]; o; o=c[o][1]){
		if(vi[c[o][0]])continue;//goto ///11 98 //???qianhou  //rao  int a //=5
		dfs(c[o][0],p);//fan  buyiyang
	}
}

void dfs2(int u, int pr)
{
	 vi2[u]=1;
	if(s.find(p[u])!=s.end())++ans;
	for(int o=a[u]; o; o=c[o][1]){
		if(vi2[c[o][0]])continue;
//		if(c[o][0]==pr)continue;
		dfs2(c[o][0],u);
	}
}

int main()
{
	n=read(); m=read();
	for(int i=1; i<=n; ++i){
		p[i]=read();	}
	for(int i=1; i<=m; ++i) {
		u=read(); v=read();
		c[++tot][0]=v; c[tot][1]=a[u]; a[u]=tot;
		c[++tot][0]=u; c[tot][1]=a[v]; a[v]=tot;
	}
	for(int i=1; i<=n; ++i)if(!vi[i]){
		s.clear();
		dfs(i,0);
		dfs2(i,0);
	}
	cout<<ans;
}

Measured memory_bytes: 11136
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  int cost[n];
	int height[n];
    for(int i=0;i<n;i++)
      cin>>height[i];
   if(n>=1)
     cost[0]=0;
   if(n>=2)
     cost[1]=abs(height[0]-height[1]);
  for(int i=2;i<n;i++)
    cost[i]=min(cost[i-1]+abs(height[i-1]-height[i]),cost[i-2]+abs(height[i-2]-height[i]));
  cout<<cost[n-1];	
      
}


Measured memory_bytes: 1024
h,n = map(int,input().split())
aa = [0]*n
bb = [0]*n
for i in range(n):
    a,b = map(int,input().split())
    aa[i] = a
    bb[i] = b
m = max(aa)

dp = [float("inf") for _ in range(h+m)]
dp[0] = 0
for i in range(1,h+m):
    for j in range(n):
        if i-aa[j] >= 0:
            dp[i] = min(dp[i-aa[j]]+bb[j],dp[i])

print(min(dp[h:]))


Measured memory_bytes: 46684
def f(n):
    alphabets = "abcdefghijklmnopqrstuvwxyz"

    s = ""
    while n > 0:
        n, mod = divmod(n, 26)
        if mod == 0:
            s += 'z'
            n -= 1
        else:
            s += alphabets[mod - 1]
    
    return s[::-1]

print(f(int(input())))

Measured memory_bytes: 9116
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;


int main() {        
    int n, k;
    cin >> n >> k;
    vector<int> v(n, 0);
    for (int i = 0; i < n; i++) {
        cin >> v[i];
    }
    if (k > *max_element(v.begin(), v.end())) {
        cout << "IMPOSSIBLE" << endl;
        return 0;
    }
    int g = v[0];
    int flag = 0;
    for (int i = 1; i < n; i++) {
        g = gcd(g, v[i]);
        if (v[i] == k) flag = 1;
    }
    if (abs(v[0] - k) % g == 0) flag = 1;
    if (flag) {
        cout << "POSSIBLE" << endl;
    } else {
        cout << "IMPOSSIBLE" << endl;
    }
}


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

int main(){
  int k,a,b;
  cin>>k>>a>>b;
  
  for(a;a<=b;a++){
    if(a%k==0){
      cout<<"OK"<<endl;
      return 0;
    }
  }
  cout<<"NG"<<endl;
}
    

Measured memory_bytes: 3624
import java.util.*;

public class Main {
    public static void main(String[] args) {
        //天気を格納するリスト
        ArrayList<String> weather = new ArrayList<String>();
        //天気をリストに格納
        weather.add("Sunny");
        weather.add("Cloudy");
        weather.add("Rainy");
        //今日の天気
        String nowWeaher;
        //標準入力を読み込むためのScanner
        Scanner sc = new Scanner(System.in);
        
        //今日の天気を標準入力から読み込む
        nowWeaher = sc.next();
        //リストから該当する天気のインデックスを探す
        int tomorrow_weather = weather.indexOf(nowWeaher) + 1;
        //もしリストの総数を超えていたら最初に戻る
        if(tomorrow_weather >= weather.size()){
            tomorrow_weather = 0;
        }
        //明日の天気を表示
        System.out.println(weather.get(tomorrow_weather));
        
    }
}


Measured memory_bytes: 21204
#include <iostream>
#include <string>

using namespace std;

int main(void) {
	string s;
	cin >> s;
	if (s[0] == s[s.size() - 1]) {
		if (s.size() & 1)
			printf("Second\n");
		else
			printf("First\n");
	}
	else{
		if (s.size() & 1)
			printf("First\n");
		else
			printf("Second\n");
	}
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <cstdio>
#define rep(i,n) for(int i = 0; i < n; ++i)
#define rep1(i,n) for(int i = 1; i <= n; ++i)
#define rep2(i,s,t) for(int i = s; i <= t; ++i)
#define rev(i,n) for(int i = n-1; i >= 0; --i)
#define rev1(i,n) for(int i = n; i > 0; --i)
#define rev2(i,s,t) for(int i = s; i >= t; --i)
#define F first
#define S second
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if(a < b){ a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if(a > b){ a = b; return 1; } return 0; }
using ll = long long;
using pi = pair<int,int>;
using vi = vector<int>;
using vii = vector<vi>;
struct UFT{
  vector<int> par;//親
  vector<int> rank;//木の深さ
  vector<int> size;//木の大きさ
  int n;
  
  UFT(int _n)
  {
    n = _n;
    par.resize(n);
    rank.assign(n,0);
    size.assign(n,0);
    rep(i,n){
      par[i] = i;
    }
  }
  
  //xの根を返す
  int find(int x)
  {
    if(par[x] == x) return x;
    else return par[x] = find(par[x]);
  }

  //x,yを併合
  void unite(int x,int y)
  {
    x = find(x);
    y = find(y);
    if(x == y) return;

    if(rank[x] < rank[y]){
      par[x] = y;
      size[y] += size[x];
    }
    else{
      par[y] = x;
      size[x] += size[y];
      if(rank[x] == rank[y]) rank[x]++;
    }
  }

  //x,yが同じグループにいるかどうかを返す
  bool same(int x,int y)
  {
    return find(x) == find(y);
  }

  //xの属する木のサイズを探す
  int usize(int x)
  {
    return size[find(x)];
  }
};

int main()
{
  int n,q; scanf("%d %d", &n, &q);
  UFT uf(n);
  while(q-- > 0) {
    int t,u,v; scanf("%d %d %d", &t, &u, &v);
    if(t == 0) uf.unite(u, v);
    else printf("%d\n", (uf.same(u, v) ? 1 : 0));
  }
  return 0;
}


Measured memory_bytes: 5260
use proconio::{input};

fn main(){
    const arr: [i32; 29] = [
        0,
        343474715,
        0,
        0,
        0,
        0,
        499999999,
        0,
        0,
        0,
        495113154,
        675365680,
        0,
        0,
        0,
        0,
        0,
        0,
        2,
        19,
        173224800,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        833484826,
    ];
    input!{
        a: usize,
        b: usize,
        c: usize,
    }
    
    let m = (a + b + c) % 29;
    println!("{}", arr[m]);
}

Measured memory_bytes: 3168
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(ll i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll x, k, d;
  cin >> x >> k >> d;
  x = abs(x);
  ll ans;
  if(x / d > k) {
    ans = x - k * d;
  } else {
    k -= x / d;
    if(k % 2) {
      ans = d - x % d;
    } else {
      ans = x % d;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
typedef long long ll; 
#define arrlen(arr) (sizeof(arr)/sizeof(arr[0]))
#define Sort(arr) sort(arr, arr+arrlen(arr))
#define For(i,s,n) for(ll i=s;i<n;i++)

//降順クイックソート
void QsortR(ll B[],ll C[],ll left,ll right){
	int i=left,j=right,p=C[(left+right)/2];
	
	while(1){
		while(C[i]>p) i++;
		while(p>C[j]) j--;
		if(i>=j) break;
		swap(C[i],C[j]);
		swap(B[i],B[j]);
		i++;
		j--;
	}

	if(left<i-1) QsortR(B,C,left,i-1);
	if(j+1<right) QsortR(B,C,j+1,right);
}

int main(){
	ll N,M;
	cin >> N >> M;
	ll A[2*N],B[M],C[M],D[N];
	For(i,0,N){
		cin >> A[i];
		D[i]=0;
	}
	For(i,0,M){
		cin >> B[i] >> C[i];
	}
	
	QsortR(B,C,0,M-1);
	//For(i,0,M) cout << B[i] << " " << C[i] << endl;
	
	ll num=0;
	For(i,0,M){
		for(int j=num;j<min(num+B[i],N);j++){
			D[j]=C[i];
		}
		num+=B[i];
		if(num>=N) break;
	}
	
	For(i,N,2*N) A[i]=D[i-N];
	Sort(A);
	
	//cout << "B and C" << endl;
	//For(i,0,M) cout << B[i] << " " << C[i] << endl;
	//cout << "A" << endl;
	//For(i,0,2*N) cout << A[i] << endl;
	
	ll ans=0;
	For(i,N,2*N) ans+=A[i];
	cout << ans;
}

Measured memory_bytes: 4096
#include <bits/stdc++.h>
#define ri register
#define int long long
#define E (n+1)
using namespace std; const int N=1000010, Mod=1e9+7;
inline int read()
{
    int s=0, w=1; ri char ch=getchar();
    while(ch<'0'||ch>'9') { if(ch=='-') w=-1; ch=getchar(); }
    while(ch>='0'&&ch<='9') s=(s<<3)+(s<<1)+(ch^48), ch=getchar();
    return s*w;
}
signed main()
{
    int a,b,c;
    a=read(), b=read(), c=read();
    (b*c>=a)?puts("Yes"):puts("No");
    return 0;
}

Measured memory_bytes: 3636
S = input()
mozi = dict()
for i in range(4):
	mozi[S[i]] = 0

for i in range(4):
    mozi[S[i]] += 1

num = 0
for i in mozi:
  num += 1
  if mozi[i] != 2:
    print("No")
    exit()
 
if num == 2:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 38384
import heapq
n, m = map(int, input().split())
a = list(map(lambda x: int(x)*(-1), input().split()))
heapq.heapify(a)
for i in range(m):
  b = heapq.heappop(a)
  heapq.heappush(a,((-1*b)//2)*-1)
print(-sum(a))

Measured memory_bytes: 20368
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <list>
#include <string>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <iomanip> // setprecisionを使用するのに必要 cout << fixed << setprecision(15) << p でpを小数点以下15桁表示
using namespace std;
#define REPD(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) REPD(i, 0, n)
typedef long long ll;
#define fin(ans) cout << (ans) << '\n'
/*

*/
int main()
{
    int N;
    double average_d;
    int average_i=0;
    cin >> N;
    int num[N];
    REP(i, N){
        cin >> num[i];
        average_i += num[i];
    }
    average_d = (double)average_i / N;
    average_i /= N;

    //四捨五入する
    if(average_d*10-average_i*10 > 5){
        average_i++;
    }
    int ans = 0;
    REP(i,N){
        ans += (num[i] - average_i) * (num[i] - average_i);
    }
    fin(ans);
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<set>
#include<map>
#include<queue>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);++i)
#define rrep(i,n) for(int (i)=(n)-1;(i)>=0;--i)
#define rep1(i,n) for(int (i)=1;(i)<=(n);++i)
#define rrep1(i,n) for(int (i)=(n);(i)>=1;--i)
#define pb push_back
#define fr first
#define sc second
typedef int ll;
typedef pair<int,int> P;
typedef pair<int,int> LP;
typedef double db;
using namespace std;
vector<LP> vs[100000],vs2[100000];
ll N,M,Q;
ll A[100000],B[100000];
bool f[100000];
ll d[100000];
ll ans[100000];
ll cnt[100000];
queue<ll> q;

void bfs(ll v){
  q.push(v);
  while(!q.empty()){
    v = q.front();
    q.pop();
    rep(i,vs[v].size()){
      if(cnt[vs[v][i].fr]==1){
        f[vs[v][i].sc]=0;
        q.push(vs[v][i].fr);
      }
      else cnt[vs[v][i].fr]--;
    }
  }
}

int main(){
  cin>>N>>M;
  Q=N+M-1;
  rep(i,N+M-1){
    cin>>A[i]>>B[i];
    A[i]--;
    B[i]--;
    vs[A[i]].pb(LP(B[i],i));
    cnt[B[i]]++;
    f[i]=1;
  }
  ll c=0;
  rep(i,N){
    if(cnt[i]==0) c=i;
  }
  bfs(c);

  ans[c]=0;
  rep(i,Q){
    if(!f[i]){
      ans[B[i]]=A[i]+1;
    }
  }
  rep(i,N) cout<<ans[i]<<endl;
}


Measured memory_bytes: 10240
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func main() {
	sc.Split(bufio.ScanWords)
	x, y := getInt(), getInt()

	ax := abs(x)
	ay := abs(y)
	if x == y {
		out(0)
		return
	}
	if ax == ay {
		out(1)
		return
	}

	if x >= 0 && y >= 0 && x > y {
		if y == 0 {
			out(x - y + 1)
		} else {
			out(x - y + 2)
		}
		return
	}
	if x >= 0 && y >= 0 && x < y {
		out(y - x)
		return
	}

	if x < 0 && y >= 0 && ax > ay {
		if y == 0 {
			out(ax - ay)
		} else {
			out(ax - ay + 1)
		}
		return
	}
	if x < 0 && y >= 0 && ax < ay {
		out(ay - ax + 1)
		return
	}

	if x >= 0 && y < 0 && ax > ay {
		out(ax - ay + 1)
		return
	}
	if x >= 0 && y < 0 && ax < ay {
		out(ay - ax + 1)
		return
	}

	if x < 0 && y < 0 && ax > ay {
		out(ax - ay)
		return
	}
	if x < 0 && y < 0 && ax < ay {
		out(ay - ax + 2)
		return
	}
}


Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	int a[3];
	cin >> a[0] >> a[1] >> a[2];
	sort(a, a + 3);
	if ((a[2] - a[1] + a[2] - a[0]) % 2 == 0)
		cout << (a[2] - a[1] + a[2] - a[0]) / 2;
	else
		cout << (a[2] - a[1] + a[2] - a[0] + 3) / 2;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

/*选择排序法（0起点）*/
int selectionSort(int A[],int N){
	int i,j,t,sw=0,minj;
	for(i=0;i<N-1;i++){
		minj=i;
		for(j=i;j<N;j++){
			if(A[j]<A[minj]) minj=j;
		}
		t=A[i];A[i]=A[minj];A[minj]=t;
		if(i!=minj)sw++;
	}
	return sw;
}
int main(){
	int A[100],N,i,sw;
	
	scanf("%d",&N);
	for(i=0;i<N;i++) scanf("%d",&A[i]);
	
	sw=selectionSort(A,N);
	
	for(i=0;i<N;i++){
		if(i>0) printf(" ");
		printf("%d",A[i]);
	}
	printf("\n");
	printf("%d\n",sw);
	
	return 0;
} 


Measured memory_bytes: 2756
#include<stdio.h>

int main() {
    int x, y;//変数の宣言
    
    //入力
    //printf("たて　よこ　→ ");
    scanf("%d %d", &x, &y);
    
    //出力
    printf("%d %d\n", x*y, 2*x + 2*y);
    //printf("周りの長さ: %d\n", 2*x + 2*y);
    
    return 0;
}


Measured memory_bytes: 2032
#include <bits/stdc++.h>
using namespace std;
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; }

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ for(auto it : P) { s << "<" << it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ for(auto it : P) { s << "<" << it.first << "->" << it.second << "> "; } return s << endl; }


int main() {
    int N, X, Y;
    cin >> N >> X >> Y;
    --X, --Y;
    vector<int> res(N, 0);
    vector<vector<int>> dp(N, vector<int>(N));
    for (int i = 0; i < N; ++i) for (int j = 0; j < N; ++j) dp[i][j] = abs(i-j);
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < N; ++j) {
            chmin(dp[i][j], dp[i][X] + dp[Y][j] + 1);
            chmin(dp[i][j], dp[i][Y] + dp[X][j] + 1);
        }
    }
    for (int i = 0; i < N; ++i) for (int j = i+1; j < N; ++j) res[dp[i][j]]++;
    for (int d = 1; d < N; ++d) cout << res[d] << endl;
}

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

int main()
{
	int N;
	char S[30001] = {};
	scanf("%d", &N);
	scanf("%s", S);
	
	int i, j, pin, count = 0, digit[3];
	for (pin = 0; pin < 1000; pin++) {
		digit[2] = pin % 10;
		digit[1] = (pin / 10) % 10;
		digit[0] = pin / 100;
		
		for (i = 0, j = 0; i < N && j < 3; i++) {
			if (S[i] == '0' + digit[j]) j++;
		}
		if (j == 3) count++;
	}
	
	printf("%d\n", count);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstring>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <utility>
#include <functional>
#include <deque>
#include <cctype>
#include <stack>
#include <bitset>

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

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;
}

const ll mod = 1000000007;
const ll INF = 1 << 30;
const ll INF2 = 9000000000000000000LL;
bool fl = false;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
string abc = "abcdefghijklmnopqrstuvwxyz";
struct edge { ll to, cost; };
struct edge1 { ll from, to, cost; };
double pai = 3.141592653589793;

int main() {
	ll n, m, V, W, b[4][100] = { 0 }, ans = 0;
	vector<int>a[4];
	cin >> n >> m >> V >> W;
	a[0].push_back(W);
	for (int i = 1;i < n;i++) {
		int v, w;
		cin >> v >> w;
		a[v - V].push_back(w);
	}
	for (int i = 0;i < 4;i++) {
		sort(a[i].rbegin(), a[i].rend());
	}
	b[0][0] = 0;
	b[1][0] = 0;
	b[2][0] = 0;
	b[3][0] = 0;
	for (int i = 0;i < 4;i++) {
		for (int j = 1;j <= a[i].size();j++) {
			b[i][j] = b[i][j - 1] + a[i][j - 1];
		}
	}
	for (int i = 0;i <= a[0].size();i++)
		for (int j = 0;j <= a[1].size();j++)
			for (int k = 0;k <= a[2].size();k++)
				for (int l = 0;l <= a[3].size();l++) 
					if (V*i + (V + 1)*j + (V + 2)*k + (V + 3)*l <= m) {
						ans = max(ans, b[0][i] + b[1][j] + b[2][k] + b[3][l]);
					}
	cout << ans << endl;
}

Measured memory_bytes: 256
import * as fs from 'fs'
import {debug} from '../../../util'

const input = fs.readFileSync('/dev/stdin', 'utf8').trim().split('\n')
const output = (x: any) => console.log(x)
// debug(input)
const [N, M, X] = input[0].split(' ').map(i => Number(i))
const data = []
for (const i of [...Array(N)].map((v, i) => ++i)) {
    const tmp = input[i].split(' ').map(i => Number(i))
    data.push(tmp)
}

const isXOrMore = (A: number[], X: number): boolean => {
    return A.every(v => v >= X)
}

let minPrice = Number.MAX_SAFE_INTEGER

for (let bit = 0; bit < (1 << N); ++bit) {
    let price = 0
    const A = Array(M).fill(0)

    for (const i of [...Array(N).keys()]) {
        if (bit & (1 << i)) {
            // debug(data[i])
            price += data[i][0]
            for (const key of [...Array(M)].map((v, i) => ++i)) {
                A[key - 1] += data[i][key]
            }
        }
    }

    if (isXOrMore(A, X)) {
        minPrice = Math.min(minPrice, price)
    }
}

minPrice === Number.MAX_SAFE_INTEGER ? output(-1) : output(minPrice)

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

const int MOD=1000000007;

int main()
{
  int h,w;
  int dp[1005][1005]={};
  char gr[1005][1005];

  cin>>h>>w;
  for(int i=1;i<=h;i++){
    for(int j=1;j<=w;j++) cin>>gr[i][j];
  }

  dp[0][1]=1;
  for(int i=1;i<=h;i++){
    for(int j=1;j<=w;j++){
      if(gr[i][j]!='#'){
	dp[i][j]=dp[i][j-1]%MOD+dp[i-1][j]%MOD;
      }
    }
  }

  cout<<dp[h][w]%MOD<<endl;
  return 0;
}


Measured memory_bytes: 5120
#include <iostream>
#include <string>

using namespace std;

int main() {
	long N , a[100010];

	cin >> N;

	for (long i = 0; i < 100010; i++) {
		a[i] = 0;
	}

	for (long i = 0; i < N; i++) {
		long t;
		cin >> t;
		a[i] = t;
	}

	long count = 0;


	for (long i = 0; i < N; i++) {
		long g = max(0L, ((a[i] -1) / 2 ));
		count += g;
		a[i] -= g * 2;
	}

	for (long i = 0; i < N - 1; i++) {
		if (a[i] == 2) {
			a[i] = 0;
			count ++;		
		}

		long g = min(a[i],a[i+1]);
		count += g;
		a[i] -= g;
		a[i+1] -=g;
	}

	for (long i = 0; i < N; i++) {
		long g = a[i] / 2;
		count += g;
		a[i] -= g * 2;
	}

	cout << count << endl;
	return 0;
}


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

using namespace  std;
 int main(){
     string s,t;
     int flag = 1;
     cin >> s;
     cin >> t;
     for(int i=0;i<s.size();i++){
         if(s[i] != t[i]) flag = 0;
     }
     if(flag) cout << "Yes" << endl;
     else cout << "No" << endl;


return 0;
 }

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

using namespace std;

#define ll long long
#define ull unsigned long long
#define db double
#define ldb long double 

#define fi first
#define se second
#define MP make_pair
#define pii pair <int, int>
#define pil pair <int, ll> 
#define pli pair <ll, int>
#define pll pair <ll, ll>  

#define All(x) x.begin(), x.end()
#define pb push_back
#define pf push_front

#define ms0(x) memset(x, 0, sizeof(x))
#define ms1(x) memset(x, -1, sizeof(x))

#define oye cerr << "Yes!" << endl; 
#define O(x) cerr << #x << ": " << x << endl;  

template <typename T> void printarr(T a[], int b, int e) {
  if(b > e) return ; 
  for(int i = b; i < e; i++) cout << a[i] << " "; 
  cout << a[e] << endl; 
} 

template <typename T> int chkmax(T &x, const T &y) {
  return x < y ? x = y, 1 : 0; 
}

template <typename T> int chkmin(T &x, const T &y) {
  return x > y ? x = y, 1 : 0; 
}

const int N = 1001000; 
const int mod = 998244353; 

int addp(int x, int y) {
  return (x += y) >= mod ? x - mod : x; 
}

char s[N]; 
int n; 
int ans = 1;
int cnt[3];  

int main() {
  scanf("%d", &n); n *= 3;  
  scanf("%s", s + 1);
  for(int i = 1; i <= n; i++) {
    int x[3], y[3]; 
    x[0] = cnt[0]; x[1] = cnt[1], x[2] = cnt[2]; 
    sort(x, x + 3); 
    int op = 0; 
    if(s[i] == 'R') op = 0; 
    if(s[i] == 'G') op = 1; 
    if(s[i] == 'B') op = 2; 
    cnt[op]++; 
    y[0] = cnt[0]; y[1] = cnt[1], y[2] = cnt[2]; 
    sort(y, y + 3); 
    if(y[2] != x[2]) {
      ; // ans = 1ll * ans * x[2] % mod; 
    }
    else if(y[0] != x[0]) {
      ans = 1ll * ans * (x[1] - x[0]) % mod; 
    }
    else {
      ans = 1ll * ans * (x[2] - x[1]) % mod; 
    }
  }
  for(int i = 1; i <= n / 3; i++) ans = 1ll * ans * i % mod; 
  printf("%d\n", ans); 
  return 0; 
}

Measured memory_bytes: 512
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        x: usize,
    }
    // x<=n<2xの素数テーブル。indexはxを引いてから。
    let mut table = vec![true; 2 * x];
    for i in 2..x {
        for j in (i..2 * x).step_by(i) {
            table[j] = false;
        }
    }
    println!("{}", (x..2 * x).find(|i| table[*i]).unwrap());
}


Measured memory_bytes: 2240
{-# LANGUAGE FlexibleInstances    #-}
{-# LANGUAGE TypeSynonymInstances #-}

import           Control.Applicative
import           Control.DeepSeq
import           Control.Monad
import           Control.Monad.ST
import qualified Data.Array                  as A
import qualified Data.Array.IArray           as IA
import qualified Data.Array.IO               as AI
import qualified Data.Array.MArray           as MA
import qualified Data.Array.ST               as STA
import qualified Data.Array.Unboxed          as AU
import           Data.Bits
import qualified Data.ByteString.Char8       as BS
import           Data.Char
import qualified Data.Graph                  as G
import           Data.Int
import qualified Data.IntMap                 as IM
import qualified Data.IntSet                 as IS
import           Data.List
import qualified Data.Map.Strict             as M
import           Data.Maybe
import           Data.Ord
import qualified Data.Sequence               as SQ
import qualified Data.Set                    as S
import           Data.Time
import qualified Data.Tree                   as T
import qualified Data.Vector                 as V
import qualified Data.Vector.Mutable         as VM
import qualified Data.Vector.Unboxed         as VU
import qualified Data.Vector.Unboxed.Mutable as VUM

readInt :: IO [Int]
readInt = map (fst . fromJust . BS.readInt) . BS.words <$> BS.getLine

readInts :: Int -> IO [[Int]]
readInts n = replicateM n readInt

readInteger :: IO [Integer]
readInteger = map (fst . fromJust . BS.readInteger) . BS.words <$> BS.getLine

readIntegers :: Int -> IO [[Integer]]
readIntegers n = replicateM n readInteger

readString :: IO [String]
readString = map BS.unpack . BS.words <$> BS.getLine

readStrings :: Int -> IO [[String]]
readStrings n = replicateM n <$> readString

toPair :: [a] -> (a, a)
toPair [x, y] = (x, y)

count :: Eq a => a -> [a] -> Int
count a as = length $ filter (== a) as

put :: Show a => a -> IO ()
put = putStr . show

putLn :: Show a => a -> IO ()
putLn = print

putList :: Show a => [a] -> IO ()
putList [n] = put n
putList (n:ns) = do
  put n
  putStr " "
  putList ns

putStrList :: [String] -> IO ()
putStrList [n] = putStr n
putStrList (n:ns) = do
  putStr n
  putStr " "
  putStrList ns

main = do
  [a, b, c, d] <- readInt
  putStrLn $ f (a + b) (c + d)

f a b
  | a < b = "Right"
  | a == b = "Balanced"
  | otherwise = "Left"


Measured memory_bytes: 380
using System;

public class Hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var x = int.Parse(line[0]);
        var y = int.Parse(line[1]);
        var ans = getPoint(x);
        ans += getPoint(y);
        Console.WriteLine(ans == 600000 ? 1000000 : ans);
    }
    static int getPoint(int a)
    {
        if (a == 1) return 300000;
        if (a == 2) return 200000;
        if (a == 3) return 100000;
        return 0;
    }
}


Measured memory_bytes: 11092
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-6;
const double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}

int main(){
	int a;scanf("%d",&a);
	int o1=0;
	int o2=0;
	int o4=0;
	for(int i=0;i<a;i++){
		int p;scanf("%d",&p);
		if(p%4==0)o4++;
		else if(p%2==0)o2++;
		else o1++;
	}
	bool ok=false;
	if(o2==0){
		if(o1<=o4+1)ok=true;
	}else{
		if(o1<=o4)ok=true;
	}
	if(ok)printf("Yes\n");else printf("No\n");
}


Measured memory_bytes: 128
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <sstream>
#include <cassert>
#include <list>
using namespace std;
static const double EPS = 1e-8;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PI;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define SZ(a) (int(a.size()))
#define F first
#define S second
const double pi=acos(-1);
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};

int n,m,cap;
vector<PI> G[4000];
bool lpg[4000];
bool vis[4000][4000];

map<string,int> stoi;
int getnum(string s){
  if(stoi.count(s))return stoi[s];
  int sz=SZ(stoi);
  return stoi[s]=sz;
}

void solve(){
  stoi.clear();
  memset(lpg,0,sizeof(lpg));
  memset(vis,0,sizeof(vis));  
  string src,dest;
  cin>>src>>dest;
  int st=getnum(src),go=getnum(dest);
  
  rep(i,n+1)G[i].clear();
  rep(i,n){
    string p,q;
    int c;
    cin>>p>>q>>c;
    int u=getnum(p);
    int v=getnum(q);
    G[u].pb(mp(v,c));
    G[v].pb(mp(u,c));
  }
  rep(i,m){
    string s;
    cin>>s;
    int t=getnum(s);
    if(t>4000)exit(0);
    lpg[t]=1;
  }

  priority_queue<pair<int,PI> >q;
  q.push(mp(0,mp(cap*10,st)));
  while(!q.empty()){
    int cc=-q.top().F;
    int ca=q.top().S.F;
    int cv=q.top().S.S;

    q.pop();
    if(lpg[cv])ca=cap*10;
    if(vis[cv][ca])continue;
    vis[cv][ca]=true;
    if(cv==go){
      cout<<cc<<endl;
      return;
    }

    rep(i,SZ(G[cv])){
      int to=G[cv][i].F;
      int co=G[cv][i].S;
      if(co>ca)continue;
      int nca=ca-co;
      if(to>4000 || nca>4000)break;
      if(vis[to][nca])continue;
      q.push(mp(-cc-co,mp(nca,to)));
    }
  }
  cout<<-1<<endl;
}

main(){
  while(cin>>n>>m>>cap,n)
    solve();
}

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<P> VP;
typedef vector<vector<ll>> VV;
typedef vector<vector<int>> VVi;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
const ll INF=1e18+18;
const ll MAX=100005;
const ll MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbgmap(mp) cerr << #mp << ":"<<endl; for (auto i = mp.begin(); i != mp.end(); ++i) { cerr << i->first <<":"<<i->second << endl;}
#define dbgarr(n,m,arr) rep(i,n){rep(j,m){cerr<<arr[i][j]<<" ";}cerr<<endl;}
#define dbgdp(n,arr) rep(i,n){cerr<<arr[i]<<" ";}cerr<<endl;
#define dbgmint(n,arr) rep(i,n){cerr<<arr[i].x<<" ";}cerr<<endl;
#define out(a) cout<<a<<endl
#define out2(a,b) cout<<a<<" "<<b<<endl
#define vout(v) rep(i,v.size()){cout<<v[i]<<" ";}cout<<endl
#define Uniq(v) v.erase(unique(v.begin(), v.end()), v.end())
#define fi first
#define se second

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

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

template<typename T>istream& operator>>(istream&i,vector<T>&v)
{rep(j,v.size())i>>v[j];return i;}

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<"	";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<std::setprecision(10);

    ll sx,sy,tx,ty;
    cin>>sx>>sy>>tx>>ty;
    ll diffx = tx-sx;
    ll diffy = ty-sy;
    string ans;
    vector<pair<char,ll>> vp;
    vp.emplace_back(mp('R',diffx));
    vp.emplace_back(mp('U',diffy));
    vp.emplace_back(mp('L',diffx));
    vp.emplace_back(mp('D',diffy));
    vp.emplace_back(mp('D',1));
    vp.emplace_back(mp('R',diffx+1));
    vp.emplace_back(mp('U',diffy+1));
    vp.emplace_back(mp('L',1));
    vp.emplace_back(mp('U',1));
    vp.emplace_back(mp('L',diffx+1));
    vp.emplace_back(mp('D',diffy+1));
    vp.emplace_back(mp('R',1));
    Each(p,vp){
        rep(i,p.second){
            ans += p.first;
        }
    }
    cout<<ans<<endl;
    return  0;
}


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

int main(void) {
	long long int N; cin >> N;
	string dat = "zabcdefghijklmnopqrstuvwxy";
	string s;
	while(N > 0) {
		s += dat[N % 26];
		if(N % 26 == 0) 
			N = (N / 26) - 1;
		else
			N /= 26;
	}
	reverse(s.begin(), s.end());
	
	cout << s << '\n';
}


Measured memory_bytes: 3624
import java.util.Arrays;
import java.util.Scanner;


public class Main{

	static Scanner sc = new Scanner(System.in);
	
	static int input[] = new int[5];
	
	public static void main(String[] args) {
		
		while(read()){
			solve();
		}
	}
	
	public static boolean read(){
		if(!sc.hasNext()) return false;
		
		for(int i = 0; i < 5; i++){
			input[i] = sc.nextInt();
		}
		
		return true;
	}
	
	public static void solve(){
		
		Arrays.sort(input);
		
		System.out.println(input[4] + " " + input[3] + " " + input[2] + " " + input[1] + " " + input[0]);
	}

}

Measured memory_bytes: 12000
# include <bits/stdc++.h>
# define rep(i,a,b) for(int i=a;i<=b;++i)
using namespace std;
const int maxn = 100010;
int read(){
	char c=getchar(); int x=0;
	for(;c<'0'||c>'9';c=getchar());
	for(;c>='0'&&c<='9';c=getchar())x=x*10+c-'0';
	return x;
}
int a[maxn];
int n;
int main(){
	n=read();
	rep(i,0,n-1)a[i]=read();
	sort(a+0,a+n);
	reverse(a+0,a+n);
	int p=0,y=0;
	for(;p+1<n&&a[p+1]>p+1;++p);
	for(;y<n&&a[y]>p;++y);
	if ((a[p]-p)&1 && (y-p)&1) puts("Second");
	else puts("First");
	return 0;
}

Measured memory_bytes: 640