akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <tuple>
#include <assert.h>
#include <deque>
#include <bitset>
#include <iomanip>
#include <limits>
#include <chrono>
#include <random>
#include <array>
#include <unordered_map>
#include <functional>
#include <complex>

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

constexpr long long MAX = 5100000;
constexpr long long INF = 1LL << 60;
constexpr int inf = 1 << 28;
//constexpr long long mod = 1000000007LL;
//constexpr long long mod = 998244353LL;

using namespace std;
typedef unsigned long long ull;
typedef long long ll;


int main()
{
	/*
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	*/
	int kkt = 89;
	while (kkt) {
		int n; scanf("%d", &n); if (n == 0) break;
		vector<vector<int>> t(n, vector<int>(n + 1)); for (int i = 0; i < n; i++) for (int j = 0; j <= n; j++) scanf("%d", &t[i][j]);
		vector<int> dp(1 << n, inf);
		dp[0] = 0;
		for (int S = 0; S < (1 << n); S++) {

			for (int i = 0; i < n; i++) {
				int mn = inf;
				if (!(S >> i & 1)) {
					for (int j = 0; j < n; j++) if (S >> j & 1) chmin(mn, t[i][j + 1]);
					chmin(mn, t[i][0]);
					int nextS = (S | (1 << i));
					chmin(dp[nextS], dp[S] + mn);
				}
			}
		}
		cout << dp[(1 << n) - 1] << "\n";
	}
	return 0;

}


Measured memory_bytes: 3460
// Date: 2020-02-27

#include <bits/stdc++.h>
#include <stdio.h>
using namespace std;

typedef long long LL;
typedef long double LD;
typedef vector<int> VI;
typedef pair<LL, LL> pll;
typedef pair<int, int> pii;
#define FIO ios::sync_with_stdio(false);cin.tie(0)
#define rep(i, a, b) for(int i = int(a); i <= int(b); ++i)
#define per(i, b, a) for(int i = int(b); i >= int(a); --i)
#define mem(x, y) memset(x, y, sizeof(x))
#define all(x) (x).begin(),(x).end()
#define mk make_pair
#define pb push_back
#define fi first
#define se second
const LL INF = 1e18;
const LL mod = 1e9 + 7;
const int inf = 0x3f3f3f3f;
const int N = 1e5 + 10;
template <typename T> void chkmax(T &x, T y) { x = max(x, y); }
template <typename T> void chkmin(T &x, T y) { x = min(x, y); }
LL qpow(LL x, LL y, LL MOD) {LL a=1; while(y){ if(y&1) a=a*x%MOD; x=x*x%MOD; y>>=1; } return a;}

int n, k, q;
int a[N], b[N], c[N], tot, ans;

void add(int l, int r) {
    int len = r-l+1;
    rep(i, 1, len) b[i] = a[i+l-1];
    sort(b+1, b+1+len);
    rep(i, 1, len-k+1) c[++tot] = b[i];
}

void solve(int x) {
    tot = 0;
    int pre = 1;
    rep(i, 1, n+1) if(a[i] < x) {
        if(pre <= i-1) add(pre, i-1);
        pre = i+1;
    }
    sort(c+1, c+1+tot);
    if(tot < q) return;
    chkmin(ans, c[q]-c[1]);
}

int main() {
    scanf("%d%d%d", &n, &k, &q);
    rep(i, 1, n) scanf("%d", &a[i]);
    a[n+1] = 0;
    ans = inf;
    rep(i, 1, n) solve(a[i]);
    printf("%d\n", ans);

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <functional>
#include <queue>
#include <stack>
#include <cmath>
#define INF 10000000000000000
#define MOD 1000000007
using namespace std;




int main(){
    int ans=0;
    int a, b;
    cin >> a >> b;
    
    ans+=a-1;
    if(b>=a){ans++;}
    cout<<ans<<endl;
    
    return 0;
}



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

namespace atcorder2
{
    class Program
    {
        public static long Read()
        {
            return long.Parse(Console.ReadLine());
        }

        public static long[] Reads()
        {

            return Console.ReadLine().Split().Select(long.Parse).ToArray();
        }






        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);


            var nmx = Reads();
            var n = nmx[0];
            var m = nmx[1];
            var x = nmx[2];
            var a = Reads();
            Array.Sort(a);
            long sum = 0;
            for (int i = 0; a[i] < x; i++)
            {
                sum++;
            }
            Console.WriteLine(Math.Min(sum, m - sum));
              
            
           
           
            



            Console.Out.Flush();
        }
    }
}




Measured memory_bytes: 13396
#include <iostream>
#include <stdio.h>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <vector>
#include <list>

using namespace std;


int main() {
	int a, b;
	bool tf = false;
	cin >> a >> b;
	int i;
	for (i = 1; i < 1010; i++) {
		int aa = i * 0.08;
		int bb = i * 0.1;
		if (aa == a && bb == b) {
			tf = true;
			break;
		}
	}
	if (tf) {
		cout << i << endl;
	}
	else {
		cout << -1 << endl;
	}
	return 0;
}

Measured memory_bytes: 256
/* template.cpp {{{ */
#include <bits/stdc++.h>
using namespace std;
#define get_macro(a, b, c, d, name, ...) name
#define rep(...) get_macro(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
#define rrep(...) get_macro(__VA_ARGS__, rrep4, rrep3, rrep2, rrep1)(__VA_ARGS__)
#define rep1(n) rep2(i_, n)
#define rep2(i, n) rep3(i, 0, n)
#define rep3(i, a, b) rep4(i, a, b, 1)
#define rep4(i, a, b, s) for (ll i = (a); i < (ll)(b); i += (ll)(s))
#define rrep1(n) rrep2(i_, n)
#define rrep2(i, n) rrep3(i, 0, n)
#define rrep3(i, a, b) rrep4(i, a, b, 1)
#define rrep4(i, a, b, s) for (ll i = (ll)(b) - 1; i >= (ll)(a); i -= (ll)(s))
#define each(x, c) for (auto &&x : c)
#define fs first
#define sc second
#define all(c) begin(c), end(c)
using ui = unsigned;
using ll = long long;
using ul = unsigned long long;
using ld = long double;
const int inf = 1e9 + 10;
const ll inf_ll = 1e18 + 10;
const ll mod = 1e9 + 7;
const ll mod9 = 1e9 + 9;
const int dx[]{-1, 0, 1, 0, -1, 1, 1, -1};
const int dy[]{0, -1, 0, 1, -1, -1, 1, 1};
template<class T, class U> void chmin(T &x, const U &y){ x = min<T>(x, y); }
template<class T, class U> void chmax(T &x, const U &y){ x = max<T>(x, y); }
struct prepare_ { prepare_(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(12); } } prepare__;
/* }}} */

const int N = 1 << 13;
pair<int, int> seg[N * 2 - 1];
void update(int k, int x){
  int i = k + N - 1;
  seg[i] = {x, k};
  while (i){
    i = (i - 1) / 2;
    seg[i] = max(seg[i * 2 + 1], seg[i * 2 + 2]);
  }
}
pair<int, int> query(int l, int r, int k = 0, int a = 0, int b = N){
  if (r <= a || b <= l) return {-inf, -inf};
  if (l <= a && b <= r) return seg[k];
  int m = (a + b) / 2;
  auto vl = query(l, r, k * 2 + 1, a, m);
  auto vr = query(l, r, k * 2 + 2, m, b);
  return max(vl, vr);
}

int n, m;
ll a[5000];
int b[5000][200];
ll g[5010][5010];

int main(){
  cin >> n >> m;
  rep(i, 1, n) cin >> a[i], a[i] += a[i - 1];
  rep(i, n) rep(j, m) cin >> b[i][j];

  rep(i, m){
    rep(j, n) update(j, b[j][i]);
    queue<pair<int, int>> qu;
    qu.emplace(0, n);
    while (qu.size()){
      int l, r;
      tie(l, r) = qu.front(), qu.pop();
      if (r - l <= 0) continue;
      int p, q;
      tie(p, q) = query(l, r);
      if (r - l == 1){
        g[l + 1][l + 1] += p;
        g[l][l + 1] -= p;
        g[l + 1][l + 2] -= p;
        g[l][l + 2] += p;
      }
      else {
        g[q + 1][q + 1] += p;
        g[l][q + 1] -= p;
        g[q + 1][r + 1] -= p;
        g[l][r + 1] += p;
        qu.emplace(l, q);
        qu.emplace(q + 1, r);
      }
    }
  }

  rrep(i, 1, n + 1) rep(j, 1, n + 1){
    g[i][j] += g[i + 1][j];
    g[i][j] += g[i][j - 1];
    g[i][j] -= g[i + 1][j - 1];
  }

  ll res = 0;
  rep(i, n) rep(j, i, n) chmax(res, g[i + 1][j + 1] - a[j] + a[i]);
  cout << res << endl;
}


Measured memory_bytes: 200064
#include <bits/stdc++.h>
using namespace std;
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
#define fast ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL) 
#define ll long long 
#define int long long 
#define vll vector<long long>
#define pii pair<long long ,long long > 
#define vvi vector< vector<long long > > 
#define vpii vector<pair<int,int>> 
#define pll  pair<long long ,long long > 
#define pb  push_back
#define ff  first 
#define sec second  
#define SORT(a) sort(a.begin(),a.end())
#define SORTR(a) sort(a.rbegin(),a.rend()) 
#define m_p make_pair
#define all(x) (x.begin(),x.end()) 
#define sz(v) ((int)(v.size()))
#define endl '\n'
typedef vector< long long > vi ;
const int MOD=1e9 +7 ;
int sizet=1e4+10; 
 
int recur( int h){ 

    if(h==1) return 1; 
    else return recur(h>>1)*2+1; 

}


int32_t main(){
  fast; 
  #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
  #endif 
    
  int T=1; //cin>>T; 
  while(T--){

     int h,n; cin>>h>>n; 
     vpii v(n); 
     for(int i=0;i<n;i++){ int x,y; cin>>x>>y; v[i]={x,y};} 

    vector< int> dp(sizet,INT_MAX);
    dp[h]=0; 
    for(int i=h;i>=0;i--){
        if(dp[i]!=INT_MAX){
            for(int j=0;j<n;j++){
                pii p=v[j]; 
                if(i-p.ff>=0) dp[i-p.ff]=min(dp[i-p.ff],dp[i]+p.sec); 
                else dp[0]=min(dp[0],dp[i]+p.sec);
            }
        }
    }  
    //debug(dp); 
    cout<<dp[0]<<endl; 




  }
    


  return 0; 
} 


Measured memory_bytes: 3700
def func(x, y):
    res, n = 0, len(x)
    for p, q in [[1, 1], [1, -1], [-1, 1], [-1, -1]]:
        smallest = p * x[0] + q * y[0] + 0
        for i in range(n):
            cur = p * x[i] + q * y[i]
            res = max(res, cur - smallest)
            smallest = min(smallest, cur)
    return res

n = int(input())
x,y = [],[]
for i in range(n):
    a,b = list(map(int,input().split()))
    x.append(a)
    y.append(b)
print(func(x,y))

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

#define fa(x,v) for(auto x:v)
#define f(i,a,b) for(ll i=(ll)a;i<=(ll)b;i++)
#define rf(i,a,b) for(ll i=(ll)a;i>=(ll)b;i--)
#define spc " "
#define endl '\n'
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define len(s) (ll)int(s.length())
#define sz(v) (ll)int(v.size())
#define MOD 1000000007

void Fast_IO() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    #ifndef ONLINE_JUDGE
    freopen("input.in","r",stdin);
    freopen("output.out","w",stdout);
    freopen("debug.out","w",stderr);
    #endif
} 

// Code Here

ll calc(vector < pair < ll, pair <ll,ll> > > v)
{
	ll ret = 0;
	priority_queue < ll, vector <ll>, greater <ll> > pq;
	ll cc = 0;
	fa(x,v) {
		ll ki = x.ff, li = x.ss.ff, ri = x.ss.ss;
		if(ki >= cc + 1) {
			ret += li;
			pq.push(li - ri);
			cc++;
		}
		else {
			if(pq.empty()) {
				ret += ri;
				continue;
			}
			ll u = pq.top();
			ll annoy = li - ri;
			if(u < annoy) {
				pq.pop();
				ret -= u;
				ret += li;
				pq.push(annoy);
			}	
			else {
				ret += ri;
			}
		}
	}
	return ret;
}

int main()
{
    Fast_IO();
    int n_testcases; cin>>n_testcases;
    for(int n_testcase = 1; n_testcase <= n_testcases; n_testcase++)
    {
    	ll n; cin >> n;
    	ll ans = 0;
    	vector < pair < ll,pair<ll,ll> > > v1, v2;
    	f(_,1,n) {
    		ll ki, li, ri; cin >> ki >> li >> ri;
    		if(li == ri) ans += li;
    		else if(li < ri) v2.pb(mp(n-ki,mp(ri,li)));
    		else v1.pb(mp(ki,mp(li,ri)));
    	}
    	sort(v1.begin(), v1.end());
    	sort(v2.begin(), v2.end());
    	ans += calc(v1) + calc(v2);
    	cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 14224
#include <iostream>
#include <math.h>
#include <stdio.h>

using namespace std;

int main() {
  int X;
  cin >> X;
  if (X == 2) {
    printf("2\n");
    return 0;
  }
  if (X % 2 == 0) {
    ++X;
  }
  for (int i = X;; i += 2) {
    double s = sqrt(i);
    bool flg = true;
    for (int j = 3; j <= s; j += 2) {
      if (i % j == 0) {
        flg = false;
        break;
      }
    }
    if (flg) {
      printf("%d\n", i);
      return 0;
    }
  }
}

Measured memory_bytes: 3220
#include<bits/stdc++.h>
using namespace std;
int main(){
int i,n,m;
cin>>n>>m;
int a[n];
int s=0;
for(i=0;i<n;i++){
    cin>>a[i];
    s+=a[i];
}
float x=((1/(float)(4*m))*s);
int ans=0;
//cout<<x<<endl;
for(i=0;i<n;i++){
    if(a[i]>=x) ans++;
}
//cout<<ans<<endl;
if(ans>=m) cout<<"Yes"<<endl;
else cout<<"No"<<endl;
return 0;
}
  

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long lint;

#define PI acos(-1)
#define INF64 1LL << 60
#define INF32 1 << 29
#define all(a) (a).begin(), (a).end()
#define INV ((long long int)1000000007)

using namespace std;

void execute()
{
	int K, S;
	cin >> K >> S;

	lint ans = 0;
	for (int i = K; 0 <= i; i--)
	{
		for (int j = K; 0 <= j; j--)
		{
			if (0 <= S - i - j && S - i - j <= K)
			{
				ans++;
			}
		}
	}
	cout << ans << endl;
	return;
}

int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	execute();

	int stop;
	cin >> stop;

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int w[1001];
int v[1001];
int c;
int arr[10001][10001];
int max1(int a, int b)
{

    return (a > b) ? a : b;
}
void print(int n1, int n2)
{
    for(int i = 1; i <= n1; i++)
    {
        for(int j = 1; j <= n2; j++)
        {

            cout << arr[i][j] << " ";
        }
        cout << endl;
    }
}
int main()
{

    int n;
    cin >> n;
    cin >> c;
    for(int i = 1; i <= n; i++)
    {
        cin >> v[i];
        cin >> w[i];
    }
    /*for(int i = 0; i < n; i++)
    {
        cin >> v[i];
    }*/
  //  cin >> c;
    for(int i = 0; i <= c; i++)
    {
            arr[0][i] = 0;
    }
    for(int i = 0; i <= n; i++)
    {
            arr[i][0] = 0;
    }
    for(int i = 1; i <= n; i++)
    {
        for(int j = 1; j <= c; j++ )
        {
            if(j >= w[i]) {
                arr[i][j] = max1(v[i]+arr[i-1][j-w[i]],arr[i-1][j]);
            }
            else
            {
                arr[i][j] = arr[i-1][j];
            }
        }
    }
  //  print(n,c);
    cout << arr[n][c] << endl;
    return 0;
}

Measured memory_bytes: 5260
n = int(input())
B = list(map(int, input().split()))
A = [0 for _ in range(n)]
A[0] = B[0]
A[n-1] = B[n-2]
for i in range(n-2):
  A[i+1] = min(B[i], B[i+1])
print(sum(A[j]for j in range(n)))

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

int main() {
  int K;
  string S;
  cin >> K >> S;
  if (S.size() <= K) cout << S;
  else {
    for (int i = 0; i < K; i++) {
      cout << S.at(i);
    }
    cout << "...";
  }
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  loop(i,0,n)
#define all(c) c.begin(),c.end()
#define rall(c) c.rbegin(),c.rend()
#define vi vector<int>
#define vl vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>

int main(){
    int s;
    cin>>s;
    int a,b;
    a=s/100;
    b=s-(s/100)*100;
    if(a>12){
      if(b<=12 && b>0)cout<<"YYMM"<<endl;
      else if(b>12 || b==0)cout<<"NA"<<endl;
    }
    else if(a<=12 && a>0){
      if(b<=12 && b>0)cout<<"AMBIGUOUS"<<endl;
      else if(b>12 || b==0)cout<<"MMYY"<<endl;
    }
    else if(a==0){
      if(b<=12 && b>0)cout<<"YYMM"<<endl;
      else if(b>12 || b==0)cout<<"NA"<<endl;
    }
    
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
#define rep(i,n) for(int i = 0;i < n;i++)
int main(){
    int n,k,ans;
    int A[n];
    cin >> n >> k;
    rep(i,n){
        cin >> A[i];
    }
    if(n == k){
        ans = 1;
    }else{
        ans = (n - 2)/(k - 1) + 1;
    }
    cout << ans <<endl;
}

Measured memory_bytes: 2560
#include <iostream>
using namespace std;
int main(void){
    long long L,R,i,j,a,m;
    cin>>L>>R;
    if(R-L>2018){
        cout<<0<<endl;
        return 0;
    }
    a=10000;
    for(i=L;i<R;i++){
        for(j=i+1;j<R+1;j++){
            m=((i%2019)*(j%2019))%2019;
            a=min(a,m);
        }
    }
    cout<<a<<endl;
}


Measured memory_bytes: 256
import java.util.*;

    public class Main{
        public static void main(String[]args){
            int A,B,C;
            Scanner scan = new Scanner(System.in);
            A = scan.nextInt();
            B = scan.nextInt();
            C = scan.nextInt();

            if(A==B){
                System.out.println(C);
            }
            else if(A==C){
                System.out.println(B);
            }
            else if(B==C){
                System.out.println(A);
            }


        }
    }



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

#define int long long
using ll = long long;
using ull = unsigned long long;
#define repi(n) for (long long i = 0; i < (n); ++i)
#define repj(n) for (long long j = 0; j < (n); ++j)
#define repk(n) for (long long k = 0; k < (n); ++k)
#define rep(i, a, b) for (auto i = (a); i < (b); ++i)
#define itr(itr) for (auto&& v : (itr))
#define updatemax(t, v) (t = std::max(t, (v)))
#define updatemin(t, v) (t = std::min(t, (v)))

ll l[100];
signed main() {
  int n;
  cin >> n;
  repi(n) cin >> l[i];
  sort(l, l + n);
  ll re = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = i + 1; j < n; ++j) {
      for (int k = j + 1; k < n; ++k) {
        if (l[i] == l[j] || l[j] == l[k]) continue;
        if (l[k] < l[i] + l[j]) ++re;
      }
    }
  }
  cout << re << endl;
}


Measured memory_bytes: 3652
#include <stdio.h>

int main(void) {
	int ans[100] = {0};
	int i, n;
	
	while(scanf("%d",&n),n > -1 ) {
		if(n == 0) printf("0");
		for(i = 0; n ; i++ ) {
			ans[i] = n % 4 ;
			n /= 4 ;
		}
		for(i--; i >= 0; i-- ) {
			printf("%d",ans[i]);
		}
		puts("");
	}
	return 0;
}

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

#define DEBT_FIRST 100000

int main(void)
{
  int n;
  int debt = DEBT_FIRST;
  int buf;
  int i;

  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    debt += (debt / 20);
    buf = (int)((debt * pow(10, -3)) + 0.999);
    debt = (buf * pow(10, 3));
  }
  printf("%d\n", debt);

  return 0;
}

Measured memory_bytes: 592
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    n=int(input())
    from collections import Counter
    S=[Counter(input()) for _ in range(n)]
    ans=''
    for s in "abcdefghijklmnopqrstuvwxyz":
        ans+=s*min(c[s] for c in S)
    print(ans)
resolve()

Measured memory_bytes: 39152
// Template from https://techracho.bpsinc.jp/jhonda/2019_08_05/78537

// input macro for competive-programming from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };

    ($iter:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, bytes) => {
        read_value!($iter, String).into_bytes()
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    use std::io::Read;
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();

    println!("{}", solve(&s));
}

macro_rules! test {
    ($($input:expr => $output:expr),* $(,)*) => {
        #[test]
        fn solve_test() {
            $(
                assert_eq!(solve($input), $output);
            )*
        }
    };
}

test! {
r#"1 3"# => r#"Yes"#,
r#"2 4"# => r#"No"#,
}

fn solve(src: &str) -> String {
    input! {
        source = src,
        x: isize,
        y: isize,
    }

    let f:[isize; 7] = [1, 3, 5, 7, 8, 10, 12];
    let s:[isize; 4] = [4, 6, 9, 11];

    if x == y && x == 2 {
        "Yes"
    } else if f.into_iter().filter(|&&i| x == i).count() == 1 && f.into_iter().filter(|&&i| y == i).count() == 1 {
        "Yes"
    } else if s.into_iter().filter(|&&i| x == i).count() == 1 && s.into_iter().filter(|&&i| y == i).count() == 1 {
        "Yes"
    } else {
        "No"
    }.to_string()
}

Measured memory_bytes: 4352
import java.util.*;

public class Main {

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

	long C[][];
	public void init(int n) {
		C = new long[n+1][n+1];
		C[0][0]=1;
		for(int i=1; i<=n; i++) {
			C[i][0]=1;
			for(int j=1; j<=n; j++) {
				C[i][j] = C[i-1][j-1]+C[i-1][j];
			}
		}
	}

	private long com(int n, int k) {
		if(n<k) return 0;
		return C[n][k];
	}

	public void run() {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		int a=sc.nextInt();
		int b=sc.nextInt();
		ArrayList<Long> v= new ArrayList<Long>();
		for(int i=0; i<n; i++) {
			v.add(sc.nextLong());
		}
		init(n);
		Collections.sort(v,Collections.reverseOrder());
		int acnt=0;
		int apos=0;
		for(int i=0; i<n; i++) {
			if(v.get(i).equals(v.get(a))) {
				acnt++;
				if(i<a) {
					apos++;
				}
			}
		}
		double total = 0.0;
		for(int i=0; i<a; i++) {
			total += v.get(i);
		}
		double ave = total/(double)a;
		System.out.println(ave);

		long ans = 0;
		if(apos==a) {
			for(int i=a; i<=b; i++) {
				ans += com(acnt, i);
			}
		}else {
			ans = com(acnt, apos);
		}
		System.out.println(ans);
		sc.close();
	}

}


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

int main(void){
  int i=0;
  int x[100];

  char s[100];

  while( scanf("%s", s) != EOF ){

    if ( s[0] == '+' ){
      i=i-2;
      x[i]=x[i]+x[i+1];
    } else if ( s[0] == '-' ){
      i=i-2;
      x[i]=x[i]-x[i+1];
    } else if ( s[0] == '*' ){
      i=i-2;
      x[i]=x[i]*x[i+1];

    } else {
      x[i] = atoi(s);

    }
    i++;
  }
  printf("%d\n",x[i-1]);

  return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <utility>
#include <functional>
using namespace std;
using LL = long long;
using P = pair<int, int>;
const LL MOD = 1e9+7;

int main(void) {
    LL h, w, a, b; cin >> h >> w >> a >> b;

    function<LL(LL, LL)> pow = [&pow](LL s, LL t) -> LL {
        if(t == 0) return 1LL;
        if(t == 1) return s;
        if(t % 2 == 0) return pow( (s*s)%MOD, t/2 );
        if(t % 2 == 1) return (s * pow(s, t-1))%MOD;
        return 0LL;
    };
    
    auto inv = [&pow](LL b) -> LL {
        return pow(b, MOD-2);
    };
    
    // 階乗テーブル作成
    vector<LL> fact(h+w);
    fact[0] = fact[1] = 1;
    for(int i=2; i<h+w; ++i) {
        fact[i] = (fact[i-1] * i) % MOD;
    }
    
    // 階乗の逆数テーブル作成
    vector<LL> invfact(h+w);
    for(int i=0; i<h+w; ++i) {
        invfact[i] = inv(fact[i]);
    }
    
    auto comb = [&](LL x, LL y) -> LL {
        if(x == 0 || y == 0) return 1;
        return (((fact[x+y] * invfact[x]) % MOD) * invfact[y]) % MOD;
    };
    
    LL ans = 0;
    for(LL p=h-a, q=b+1; p>=1 && q<=w; --p, ++q) {
        LL tmp = (comb(p-1, q-1) * comb(h-p, w-q)) % MOD;
        //cout << "comb(" << p-1+q-1 << "," << min(p-1, q-1) << ") * comb(" << h-p+w-q << "," <<  min(h-p, w-q) << ")" << endl;
        ans += tmp;
        ans %= MOD;
    };
    cout << ans << endl;
    
    return 0;
}

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

static const double PI = 3.14159265358979;

int main()
{
    int A, B, H, M;
    cin >> A >> B >> H >> M;

    double tA = 2 * PI * (H * 60 + M) / (12 * 60);
    double tB = 2 * PI * M / 60;

    double c = sqrt(A * A + B * B - 2 * A * B * cos(tB - tA));
    cout << fixed << setprecision(10);
    cout << c << endl;
}

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


int main()
{
  int w,a,b;
  cin>>w>>a>>b;
  if(a+w<b)
    cout<<b-(a+w)<<"\n";
  else if(a+w==b)
    cout<<"0\n";
  else if(b+w<a)
    cout<<a-(b+w)<<"\n";
  else
    cout<<"0\n";      



  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
	int n,m,i,j,k,l,flag=0,exist=0;
	scanf("%d %d",&n,&m);
	char a[n][n],b[m][m];
	for(i=0;i<n;i++)scanf("%s",a[i]);
	for(i=0;i<m;i++)scanf("%s",b[i]);
	for(i=0;i<n;i++){//行
		for(j=0;j<n;j++){//列
			if(i+m-1>=n || j+m-1>=n) continue;
			flag=1;
			for(k=0;k<m;k++){
				for(l=0;l<m;l++){
					if(b[k][l]!=a[i+k][j+l])flag=0;
				}
			}
			if(flag==1)exist=1;
		}
	}
	
	
	
	if(exist==1)	printf("Yes");
	else	printf("No");
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <math.h>
 
using namespace std;
 
int main()
{
  char X,Y;
  cin >> X >> Y;
  
  if(X < Y) cout << '<' << endl;
  else if(X > Y ) cout << '>' << endl;
  else cout << '=' << endl;
}

Measured memory_bytes: 256
N = input()
if(len(N)==1):#9
    print(N)
elif(len(N)==2):#99
    print(9)
elif(len(N)==3):#999
    print(int(N)-90)
elif(len(N)==4):#9999
    print(999-90)
elif(len(N)==5):#99999
    print(int(N)-9090)
else:
    print(90909)


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

int main(){
  int i,j,cnt=0;
  int n;
  cin>>n;
  string s,t;
  cin>>s>>t;
  for(i=0;i<n;i++){
    if(s.substr(i)==t.substr(0,n-i)){
      cout<<(s.substr(0,i)+t).size();
      return 0;
    }
  }
  cout<<2*n<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define int long long
#define double long double
#define mod 1000000007
#define F first
#define S second
#define P pair<long long,long long>
#define all(a) a.begin(),a.end()
#define INF 1000000000000000000
using namespace std;

signed main(){
    int n; cin>>n;
    vector<P> r(n),b(n);
    rep(i,n) cin>>r.at(i).F>>r.at(i).S;
    rep(i,n) cin>>b.at(i).F>>b.at(i).S;
    sort(all(b));
    int ans=0;
    rep(i,n){
        int x=b.at(i).F,y=b.at(i).S;
        int tmp1=-1,tmp2=-1;
        rep(j,r.size()){
            if(r.at(j).F<x and r.at(j).S<y){
                if(r.at(j).S>tmp1){
                    tmp1=r.at(j).S;
                    tmp2=j;
                }
            }
        }
        if(tmp2>=0){
            ans++;
            r.erase(r.begin()+tmp2);
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
class Main{
	public static void main(String[] args){
    	Scanner sr = new Scanner(System.in);
      	int K = sr.nextInt();
        String S = sr.next();
      if(K >= S.length())
        System.out.println(S);
      else
        System.out.println(S.substring(0,K) + "...");
      
    }
} 

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

const int N = 301;

int n, nb[4];
double exp[N][N][N];

double DFS(int i, int j, int k) {
  if(i < 0 || j < 0 || k < 0)
    return 0.0;
  if(exp[i][j][k] > -1.0)
    return exp[i][j][k];
  double t = i + j + k,
    	 lan = n / t,
         prob[] = {i/t, j/t, k/t};
  exp[i][j][k] = prob[0] * DFS(i-1, j, k) +
                 prob[1] * DFS(i+1, j-1, k) +
                 prob[2] * DFS(i, j+1, k-1);
  exp[i][j][k] += lan;
  return exp[i][j][k];
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  
  cin >> n;
  for(int i = 0; i < n; i++) {
    int a;
    cin >> a;
    nb[a]++;
  }
  for(int i = 0; i <= n; i++)
    for(int j = 0; j <= n; j++)
      for(int k = 0; k <= n; k++)
        exp[i][j][k] = -1000.0;
  exp[0][0][0] = 0.0;
  
  DFS(nb[1], nb[2], nb[3]);
  cout << setprecision(16) << exp[nb[1]][nb[2]][nb[3]];
}

Measured memory_bytes: 213376
# D - Even Relation

# 木なのでノードAB間の辺を辿ればそれがAB間の最短経路となる
# 全ての｢辺｣についてループする

from collections import deque

N = int(input())

edge = [[] for _ in range(N)]

for _ in range(N-1):
    u, v, w = map(int, input().split())
    edge[u-1].append([v-1, w])
    edge[v-1].append([u-1, w])

color = [0] + [-1]*(N-1)
d = deque([0])

while d:
    current_point = d.pop()
    for current_edge in edge[current_point]:
        if color[current_edge[0]] == -1:
            color[current_edge[0]] = (color[current_point] + current_edge[1]) % 2
            d.append(current_edge[0])

for idx in range(N):
    print(color[idx])

Measured memory_bytes: 82336
//                                               KEEP GRINDING
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 

using namespace std;
using namespace __gnu_pbds; 

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>   new_data_set;

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); 

#define int long long
#define ld long double
#define MOD 1000000007
#define mod 998244353
#define precise(i) fixed << setprecision(10) << i
#define f(i,a,b) for(int i=a;i<b;++i)

#define endl '\n'
#define debug cout<<endl;cout<<"\n========================================\n"<<endl;
#define err1(a) cout<<#a<<" "<<a<<endl;
#define err2(a,b) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<endl;
#define err3(a,b,c) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<endl;
#define err4(a,b,c,d) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<" "<<#d<<" "<<d<<endl;

#define all(a) a.begin(),a.end()
#define show(a) for(auto xyz:a)cout<<xyz<<" ";cout<<endl;
#define mx(a) *max_element(a)
#define mn(a) *min_element(a) 
#define LB lower_bound  //THIS GIVES THE ITR TO THE ELEMENT IN RANGE [SI,EI) THAT IS >= OUR VALUE 
#define UB upper_bound  //THIS GIVES THE ITR TO THE ELEMENT IN RANGE [SI,EI) THAT IS > OUR VALUE 

#define fr first
#define sc second

#define MAXN 200050
#define INF 9223372036854775807
signed main(){
    fastio
	int a,b;
	cin>>a>>b;
	cout<<(a*b);
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
const int maxn=3e5+10;
vector<int> p[maxn];
bool a[maxn];
int c[maxn],n;
vector<int> ans;

int main(){
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        scanf("%1d",&a[i]);
    }
    for(int i=1;i<=n;i++){
        for(int j=i+i;j<=n;j+=i){
            p[j].push_back(i);
        }
    }
    for(int i=n;i>=1;i--){
        if(c[i]!=a[i]){
            ans.push_back(i);
            for(auto j:p[i]){
                c[j]++;
                c[j]%=2;
            }
        }
    }
    printf("%d\n",(int)ans.size());
    for(auto i:ans){
        printf("%d ",i);
    }
}
/*
    Good Luck
        -Lucina
*/


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

using namespace std;

#define all(c) (c).begin(), (c).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

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

int main() {
    string S;
    cin >> S;
    int s = S.size();
    int t = 0;
    rep(i, S.size()) {
	if (S[i] == 'A') s = min(s, i);
	if (S[i] == 'Z') t = max(t, i);
    }
    cout << t - s + 1 << endl;
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include<string>
#include<cstdio>
using namespace std;
int main(void){
    int n,sum,x=0,y=0,z=0,flag=0;
    cin>>n>>sum;
    for(;x<=n;x++){
        if(flag==1)break;
        for(y=0;y<=n+1;y++){
            z=n-x-y;
            if(z<0)break;
            if((10000*x+5000*y+1000*z)==sum){flag=1;break;}
        }
    }
    if(flag==0)x=y=z=-1;
    else x--;
    printf("%d %d %d",x,y,z);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long h,w;
long long ans = LLONG_MAX,totalarea;

int main()
{
	int i,j;
	long long area1,area2,area3,maxarea,minarea,remain;
	
	scanf("%lld %lld",&h,&w);
	
	totalarea = h*w;
	for(i=1;i<h;i++)
	{
		area1 = i*w;
		remain = h-i;
		
		area2 = (remain/2) * w;
		area3 = totalarea - area1 - area2;
		if(area1 >= area2 && area1 >= area3)
		{
			maxarea = area1;
		}
		else if(area2 >= area1 && area2 >= area3)
		{
			maxarea = area2;
		}
		else if(area3 >= area2 && area3 >= area1)
		{
			maxarea = area3;
		}
		
		if(area1 <= area2 && area1 <= area3)
		{
			minarea = area1;
		}
		else if(area2 <= area1 && area2 <= area3)
		{
			minarea = area2;
		}
		else if(area3 <= area2 && area3 <= area1)
		{
			minarea = area3;
		}
		if(abs(maxarea - minarea) < ans)
		{
			ans = abs(maxarea - minarea);
		//	printf("area1 = %d		area2 = %d		area3 = %d\n",area1,area2,area3);
		}
		
		area2 = (w/2) * remain;
		area3 = totalarea - area1 - area2;
		if(area1 >= area2 && area1 >= area3)
		{
			maxarea = area1;
		}
		else if(area2 >= area1 && area2 >= area3)
		{
			maxarea = area2;
		}
		else if(area3 >= area2 && area3 >= area1)
		{
			maxarea = area3;
		}
		
		if(area1 <= area2 && area1 <= area3)
		{
			minarea = area1;
		}
		else if(area2 <= area1 && area2 <= area3)
		{
			minarea = area2;
		}
		else if(area3 <= area2 && area3 <= area1)
		{
			minarea = area3;
		}
		if(abs(maxarea - minarea) < ans)
		{
			ans = abs(maxarea - minarea);
		//	printf("area1 = %d		area2 = %d		area3 = %d\n",area1,area2,area3);
		}
	}
	for(i=1;i<w;i++)
	{
		area1 = i*h;
		remain = w-i;
		
		area2 = (remain/2) * h;
		area3 = totalarea - area1 - area2;
		if(area1 >= area2 && area1 >= area3)
		{
			maxarea = area1;
		}
		else if(area2 >= area1 && area2 >= area3)
		{
			maxarea = area2;
		}
		else if(area3 >= area2 && area3 >= area1)
		{
			maxarea = area3;
		}
		
		if(area1 <= area2 && area1 <= area3)
		{
			minarea = area1;
		}
		else if(area2 <= area1 && area2 <= area3)
		{
			minarea = area2;
		}
		else if(area3 <= area2 && area3 <= area1)
		{
			minarea = area3;
		}
		if(abs(maxarea - minarea) < ans)
		{
			ans = abs(maxarea - minarea);
		//	printf("area1 = %d		area2 = %d		area3 = %d\n",area1,area2,area3);
		}
		
		area2 = (h/2) * remain;
		area3 = totalarea - area1 - area2;
		if(area1 >= area2 && area1 >= area3)
		{
			maxarea = area1;
		}
		else if(area2 >= area1 && area2 >= area3)
		{
			maxarea = area2;
		}
		else if(area3 >= area2 && area3 >= area1)
		{
			maxarea = area3;
		}
		
		if(area1 <= area2 && area1 <= area3)
		{
			minarea = area1;
		}
		else if(area2 <= area1 && area2 <= area3)
		{
			minarea = area2;
		}
		else if(area3 <= area2 && area3 <= area1)
		{
			minarea = area3;
		}
		if(abs(maxarea - minarea) < ans)
		{
			ans = abs(maxarea - minarea);
		//	printf("area1 = %d		area2 = %d		area3 = %d\n",area1,area2,area3);
		}
	}
	
	printf("%lld\n",ans);
}

Measured memory_bytes: 3792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

char a[52][52];
int main() {
	ll h,w;
	cin>>h>>w;
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			cin>>a[i][j];
		}
	}
	ll dx[4]={1,0,-1,0};
	ll dy[4]={0,1,0,-1};
	bool ans=true;
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			char now=a[i][j];
			if(now=='#'){
			for(int k=0;k<4;k++){
				ll nextx=i+dx[k];
				ll nexty=j+dy[k];
				if(nextx<0||nextx>=h||nexty<0||nexty>=w){
					continue;
				}
				if(a[nextx][nexty]=='#'){
					break;
				}
				if(k==3){
					ans=false;
				}
			}
			}
		}
	}
	cout << (ans?"Yes":"No");
	// your code goes here
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    double tot,x,tk=0,bit=0;
    while(n--)
    {
        string str;
        cin>>x>>str;
        if(str=="JPY")
            tk+=x;
        else
            bit+=x;
    }
    tot=tk+(bit*380000.0);
    cout<<tot<<endl;
    return 0;
}


Measured memory_bytes: 256
import heapq
import sys

input = sys.stdin.readline

def dijkstra_heap(s,edge,n):
    #始点sから各頂点への最短距離
    d = [10**20] * n
    used = [True] * n #True:未確定
    d[s] = 0
    used[s] = False
    edgelist = []
    for a,b in edge[s]:
        heapq.heappush(edgelist,a*(10**6)+b)
    while len(edgelist):
        minedge = heapq.heappop(edgelist)
        #まだ使われてない頂点の中から最小の距離のものを探す
        if not used[minedge%(10**6)]:
            continue
        v = minedge%(10**6)
        d[v] = minedge//(10**6)
        used[v] = False
        for e in edge[v]:
            if used[e[1]]:
                heapq.heappush(edgelist,(e[0]+d[v])*(10**6)+e[1])
    return d

def main():
    N = int(input())
    edge = [[] for i in range(N)]
    for _ in range(N-1):
        a, b, c = map(int, input().split())
        a -= 1
        b -= 1
        edge[a].append([c,b])
        edge[b].append([c,a])
    Q, K = map(int, input().split())
    K -= 1
    d = dijkstra_heap(K,edge,N)
    for _ in range(Q):
        x, y = map(int, input().split())
        x -= 1
        y -= 1  
        print(d[x]+d[y])



if __name__ == "__main__":
    main()



Measured memory_bytes: 112352
import java.util.*;
public class Main {
	public static void main(String[] args){
      	//データ取り込み
		Scanner sc = new Scanner(System.in);
		int a[] = new int[3];
		for(int i=0;i<3;i++){
        	a[i]= sc.nextInt();
        }
      	Arrays.sort(a);
      	System.out.println(a[2]*10+a[1]+a[0]);
      
      
    }
}

Measured memory_bytes: 21844
#!/usr/bin/env python3
import sys
from collections import Counter
MOD = 1000000007  # type: int


def solve(N: int, A: "List[int]"):
    counter = Counter(A)

    if N%2==0:
        for value in counter.values():
            if value%2!=0:
                print(0)
                return 
        
        print(2**(N//2)%MOD)
    else:
        for key,value in counter.items():
            if (value%2!=0 and int(key)!=0) or (value%2==0 and int(key)==0):
                print(0)
                return 
        
        print(2**((N-1)//2)%MOD)

    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A)

if __name__ == '__main__':
    main()


Measured memory_bytes: 19428
import sys

def debug(x, table):
    for name, val in table.items():
        if x is val:
            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)
            return None

def solve():
    N = int(input())
    A = [int(i) for i in input().split()]
    yes = 'YES'
    no = 'NO'

    num_od = 0

    for a in A:
        if a % 2 == 1:
            num_od += 1

    if num_od % 2 == 1:
        print(no)
    else:
        print(yes)

if __name__ == '__main__':
    solve()

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

using namespace std;

using ll = long long;

const long long MOD_NUMBER = 1000000007;
const int MAX = 2147483647;
const double PI = 3.14159265358979323846;

int main() {
  ll n, k, sum = 0;
  cin >> n >> k;
  vector<ll> p(n);
  for (int i = 0; i < n; i++) {
    cin >> p[i];
  }
  sort(p.begin(), p.end());
  for (int i = 0; i < k; i++) {
    sum += p[i];
  }
  cout << sum << endl;
}

Measured memory_bytes: 3636
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
 
using ll = long long;
 
void max_self(ll& a, ll b) {
    a = max(a, b);
}
void min_self(ll& a, ll b) {
    a = min(a, b);
}
 
const ll INF = 1e18L + 5;
 
int main() {
    int n, W;
    scanf("%d%d", &n, &W);
    vector<int> weight(n), value(n);
    for(int i = 0; i < n; ++i) {
        scanf("%d%d", &weight[i], &value[i]);
    }
    int sum_value = 0;
    for(int x : value) {
        sum_value += x;
    }
    vector<ll> dp(sum_value + 1, INF); // 0 ... W
    dp[0] = 0;
    // dp[i] - the minimum total weight of items with total value exactly i
    for(int item = 0; item < n; ++item) {
        for(int value_already = sum_value - value[item]; value_already >= 0; --value_already) {
        //~ for(int weight_already = 0; weight_already <= W - weight; ++weight_already) {
            min_self(dp[value_already+value[item]], dp[value_already] + weight[item]);
        }
    }
    ll answer = 0;
    for(int i = 0; i <= sum_value; ++i) {
        if(dp[i] <= W) {
            answer = max(answer, (ll) i);
        }
        //~ min_self(answer, dp[i]);
    }
    printf("%lld\n", answer);
}

Measured memory_bytes: 1024
#include<stdio.h>
#include<string.h>
int main(void)
{
    int n;
    int i,j,k;
    int flg,flg2;
    int cnt,len;
    char a[11],b[21];
    cnt=0;
 
    scanf("%s",a);
    len=strlen(a);
    scanf("%d",&n);
 
    for(k=0;k<n;k++){
        scanf("%s",b);
             
        for(i=0;i<10;i++){
            b[i+10]=b[i];
        }
        b[20]='\0';
        flg2=0;
        for(i=0;i<20;i++){
            flg=1;
            for(j=0;j<len;j++){          
                if(i+j>20){
                    flg=0;
                    break;
                }
                if(a[j]!=b[i+j]){
                    flg=0;
                }
            }
            if(flg==1){
                flg2=1;
            }
        }
        if(flg2==1){
            cnt++;
        }
    }
    printf("%d\n",cnt);
    return 0;
}

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

#define y1 aklsdja
#define ii pair < int , int >
#define iii pair < int , ii >
#define iv pair < ii , ii >

#define fi first
#define se second
#define pb push_back
#define t top()
#define fr front()

#define FOR(i , x , n) for(int i = x ; i <= n ; ++i)
#define REP(i , x) for(int i = 0 ; i < x ; ++i)
#define FORD(i , x , n) for(int i = x ; i >= n ; --i)

#define oo 1e17
#define ll long long
#define int long long
#define pow poww

const int N = 1e2 + 5;
const int VAL = 1e5 + 5;
int n , W;
int w[N] , v[N];
int dp[VAL];

main()
{
    //freopen("test7.inp","r",stdin);
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> n >> W;
    FOR(i , 1 , n)
        cin >> w[i] >> v[i];
    FOR(i , 1 , W)
        dp[i] = -oo;
    FOR(i , 1 , n)
        FORD(j , W , 0)
            if(j >= w[i])
                dp[j] = max(dp[j] , dp[j - w[i]] + v[i]);
    int res = 0;
    FOR(i , 0 , W)
        res = max(res , dp[i]);
    cout << res;
}


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

int main(){
    int A,B; cin >> A >> B;
    cout << ((A - 2 * B > 0)? A - 2 * B : 0) << endl;
    return 0;
}

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

using namespace std;

int R[110], C[110], H[110];
int r, c, h;

int g(int p) {
  return H[p] + abs(r-R[p]) + abs(c-C[p]);
}

bool f(int p) {
  return H[p] == max(0, h - abs(r-R[p]) - abs(c-C[p]));
}

void solve() {
  int n, x;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> C[i] >> R[i] >> H[i];
    if (H[i]) x = i;
  }
  for (r = 0; r < 101; r++) {
    for (c = 0; c < 101; c++) {
      h = g(x);
      bool t = true;
      for (int i = 0; i < n; i++) {
        t &= f(i);
      }
      if (t) return;
    }
  }
}

int main() {
  solve();
  cout << c << " " << r << " " << h << endl;
}


Measured memory_bytes: 256
n, q = map(int, input().split())
s = input()
counts = [0] * n
for i in range(1, n):
    if s[i - 1] == 'A' and s[i] == 'C':
        counts[i] = counts[i - 1] + 1
    else:
        counts[i] = counts[i - 1]

ret = [0] * q
for i in range(q):
    l, r = map(int, input().split())
    ret[i] = counts[r - 1] - counts[l - 1]

print(*ret, sep='\n')


Measured memory_bytes: 51928
using System;
using System.Linq;
using System.Collections.Generic;
class ProgramE
    {
        static void Main(string[] args)
        {
            
            string[] input = Console.ReadLine().Split();
            int n = int.Parse(input[0]);
            int m = int.Parse(input[1]);
            long L = long.Parse(input[2]);

            int[,] road = new int[n,n];
            int[,] gas = new int[n,n];
            int Inf = 1000000000 + 1;
            for(int i = 0; i < n; i++)
                for(int j = 0; j < n; j++)
                {
                    if(i == j)
                        road[i , j] = 0;
                    else
                        road[i , j] = Inf;
                    
                }

            for(int i = 0; i < m; i++)
            {
                string[] input_road = Console.ReadLine().Split();
                int a = int.Parse(input_road[0]);
                int b = int.Parse(input_road[1]);
                int c = int.Parse(input_road[2]);
                road[a - 1, b - 1] = c;
                road[b - 1, a - 1] = c;
            }

            for(int s = 0; s < n;s++)
                    for(int t = 0; t < n;t++)
                        for(int u = 0; u < n;u++)
                            road[t, u] = Math.Min(road[t, u], road[t, s] + road[s, u]); 

            for(int i = 0; i < n; i++)
                for(int j = 0; j < n; j++)
                {
                    if(road[i,  j]  <= L)
                        gas[i , j] = 1;
                    else
                        gas[i , j] = Inf;
                    
                }

            for(int s = 0; s < n;s++)
                    for(int t = 0; t < n;t++)
                        for(int u = 0; u < n;u++)
                            gas[t, u] = Math.Min(gas[t, u], gas[t, s] + gas[s, u]); 

            string input_Q = Console.ReadLine();
            int Q = int.Parse(input_Q);
            

            for(int i = 0; i < Q;i++)
            {
                string[] input_st = Console.ReadLine().Split();
                int s = int.Parse(input_st[0]);
                int t = int.Parse(input_st[1]);

                if(gas[s - 1, t - 1] >= Inf)
                    Console.WriteLine("-1");
                else
                    Console.WriteLine(gas[s - 1, t - 1] - 1);
                

            }

            
                
        }
    }

Measured memory_bytes: 17528
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
int mini=10000000;
int N; cin >> N;
vector<int> a(N);
for(int i=0;i<N;i++)cin>>a[i];
vector<int> s(N+1, 0);
for(int i=0;i<N;i++)s[i+1]=s[i]+a[i];
rep(i,N) if( abs( (s[i]-s[0]) - (s[N]-s[i]) )<mini )mini=abs( (s[i]-s[0]) - (s[N]-s[i]));
cout <<mini<< endl;
}

Measured memory_bytes: 256