akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;

//

#define RESIDUE(u,v) (capacity[u][v] - flow[u][v])
#define RCOST(u,v) (cost[u][v] + h[u] - h[v])
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define LL long long

int n;
LL x_init,x[100000];

LL gcd(LL a,LL b){
  if(a<b)
    return gcd(b,a);
  if(b!=0)
    return gcd(b,a%b);
  return a;
}

int main(){
  cin>>n>>x_init;
  REP(i,n)
    cin>>x[i];

  LL ret=abs(x[n-1]-x_init);
  REP(i,n-1){
    ret = gcd(ret,abs(x[i]-x_init));
  }
  cout<<ret<<endl;
  return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>
#include<iostream>
#include<string.h>
using namespace std;
int main()
{
	int a[10][150], n;
	cin>>n;
	int i, k;
	for (i = 1; i <= 2; i++)
		for (k = 1; k <= n; k++)
			cin >> a[i][k];

	int d[150];
	memset(d, 0, sizeof(d));
	for (i = 1; i <= n; i++)
	{
		for (k = 1; k <= i; k++)
			d[i] = d[i] + a[1][k];

		for (k = i; k <= n; k++)
			d[i] = d[i] + a[2][k];
	}
	int max = d[1];
	for (i = 1; i <= n; i++)
		if (d[i] > max)
			max = d[i];
	cout << max;
//	getchar();	getchar();
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 200005;
ll a[maxn];
bool b[maxn];
int main()
{
    ll a, b, c, k;
    cin >> a >> b >> c >> k;
    ll ans = min(a, k) - max(0ll, k - a - b);
    cout << ans << endl;
    return 0;
}

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

int main()
{
#ifdef LOCAL
    // 以降 cin の入力元が 'xxx.txt' になる
    std::ifstream in("a.txt");
    std::cin.rdbuf(in.rdbuf());
#endif

    int a;
    string s;

    cin >> a;
    cin >> s;

    if (a >= 3200)
    {
        cout << s;
    }
    else
    {
        cout << "red";
    }

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();

		if(a>=13) {
			System.out.print(b);
		}else if(6<=a&&a<=12) {
			System.out.print(b/2);
		}else {
			System.out.print(0);
		}
		sc.close();

	}

}


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

int main()
{
    int n;
    string s, t, ans;
    cin >> n >> s >> t;

    for (int i = 0; i < n; i++)
    {
        ans += s[i];
        ans += t[i];
    }

    cout << ans << endl;
}

Measured memory_bytes: 3620
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<iomanip>
#include<list>
#include<deque>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define END {}
#endif
typedef long long ll;
#define int ll
#define uset unordered_set
#define umap unordered_map
typedef std::pair<int,int> P;
struct edge{int to,cost;};
const int INF=100000000000000000;
const int INF2=9223372036854775807;
const int MOD=1000000007;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define min(X,Y) (((int)(X)<(int)(Y))?(X):(Y))
#define max(X,Y) (((int)(X)>(int)(Y))?(X):(Y))
#define MAX(X,Y) (*max_element(X,Y))
#define MIN(X,Y) (*min_element(X,Y))
#define NP(X,Y) next_permutation(X,Y)
#define setp(X,Y) cout<<fixed<<setprecision(X)<<Y<<endl
int ceil2(int a,int b){if(a%b==0){return a/b;}else{return a/b+1;}}
int pow2(int a,int b){int r=1;for(int i=1;i<=b;i++){r*=a;}return r;}
int Log2(int a){int t=0;while(1){if(a==0||a==1){break;}a/=2;t++;}return t;}

int N;
int K;
int A[200010],F[200010];


signed main(){
	cin>>N>>K;
	int sum=0;
	REP(i,N){
		cin>>A[i];
		sum+=A[i];
	}
	REP(i,N){
		cin>>F[i];
	}
	sort(A,A+N);
	sort(F,F+N,greater<>());
	int ok=-1,ng=1000000000000;
	while(abs(ok-ng)>1){
		int mid=(ok+ng)/2;
		int num=0;
		REP(i,N){
			int c=mid/F[i];
			c=A[i]-c;
			c=max(0,c);
			num+=c;
		}
		if(num>K){
			ok=mid;
		}
		else{
			ng=mid;
		}
	}
	cout<<ng<<endl;
	return 0;
}


Measured memory_bytes: 3328
#include <iostream>
#include <list>
#include <random>

#define llong long long
#define rep(i,l,n) for(int (i)=(l);(i)<(n);(i++))

using namespace std;

int main(){
	int N; cin >> N;
	if( N%1000==0 ) cout << "0";
	else cout << 1000-N%1000;
	return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define st first
#define nd second

using namespace std;

void debug_out() { cerr << endl; }
template<class T> ostream& prnt(ostream& out, T v) { out << v.size() << '\n'; for(auto e : v) out << e << ' '; return out;}
template<class T> ostream& operator<<(ostream& out, vector <T> v) { return prnt(out, v); }
template<class T> ostream& operator<<(ostream& out, set <T> v) { return prnt(out, v); }
template<class T1, class T2> ostream& operator<<(ostream& out, map <T1, T2> v) { return prnt(out, v); }
template<class T1, class T2> ostream& operator<<(ostream& out, pair<T1, T2> p) { return out << '(' << p.st << ' ' << p.nd << ')'; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) { cerr << " " << H; debug_out(T...);}

#define dbg(...) cerr << #__VA_ARGS__ << " ->", debug_out(__VA_ARGS__)
#define dbg_v(x, n) do{cerr<<#x"[]: ";for(int _=0;_<n;++_)cerr<<x[_]<<" ";cerr<<'\n';}while(0)
#define dbg_ok cerr<<"OK!\n"

const int N = 200100;
int n, a[N];

bool check(int nr) {
	
	map <int, int> m;
	
	for(int i = 1; i <= n; i++) {
		if(a[i] > a[i - 1]) continue;

		while(!m.empty() && m.rbegin()->st > a[i])
			m.erase(prev(m.end()));

		int x = a[i];
		m[x]++;
		if(nr == 1) return 0;
		while(m[x] == nr) {
			m.erase(m.find(x));
			x--;
			m[x]++;
			if(x <= 0) return 0;
		}
		if(x <= 0) return 0;
	}
	return 1;
}

int main() {
	ios_base::sync_with_stdio(false);

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

	int l = 1, r = n;
	while(l != r) {
		int mid = (l + r) / 2;
		if(check(mid)) r = mid;
		else l = mid + 1;
	}
	cout << l << '\n';
}	

	

Measured memory_bytes: 1024
a = int(input())
b = int(input())
c = int(input())
x = int(input())

ans = 0
for i in range(a + 1):
    for j in range(b + 1):
        for k in range(c + 1):
            if 500 * i + 100 * j + 50 * k == x:
                ans += 1

print(ans)


Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
using namespace std;

typedef double db;

db dist(db x1,db y1,db z1,db x2,db y2,db z2){
    return sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)+(z1-z2)*(z1-z2));
}

const db INF=(db)(1<<30);
db G[100][100];
db mindist[100];
bool used[100];
db x[100],y[100],z[100],r[100];

int main(){
    int n, i, j;
    while(cin>>n,n){
        for(i=0;i<n;i++) cin>>x[i]>>y[i]>>z[i]>>r[i];
        for(i=0;i<n;i++){
            for(j=0;j<n;j++){
                db d=dist(x[i],y[i],z[i],x[j],y[j],z[j]);
                G[i][j]=d-r[i]-r[j]>=0?d-r[i]-r[j]:0.0;
            }
        }
        db ans=0.0;
        for(i=0;i<n;i++){
            mindist[i]=G[0][i];
            used[i]=false;
        }
        used[0]=true;
        for(i=0;i<n;i++){
            int id=-1;
            db m=INF;
            for(j=0;j<n;j++){
                if(used[j]) continue;
                if(mindist[j]<m){
                    m=mindist[j];id=j;
                }
            }
            if(id==-1)break;
            used[id]=true;
            ans+=m;
            for(j=0;j<n;j++)
                mindist[j]=min(mindist[j],G[id][j]);
        }
        printf("%.3lf\n",ans);
    }
    return 0;
}

Measured memory_bytes: 1324
#include<bits/stdc++.h>
#define show(x) cout<<#x" = "<<x<<endl;
#define show2(x,y) cout<<#x" = "<<x<<" "<<#y<<" = "<<y<<endl;
#define all(x) x.begin(),x.end()
#define INF 0x3f3f3f3f
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> iipair;
typedef pair<unsigned,unsigned> uupair;
typedef vector<int> vec;
typedef vector<unsigned> uvec;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    string s;
    cin>>s;
    for(unsigned i=0;i<s.length();++i) cout<<"x";
}

Measured memory_bytes: 256
#include<iostream>
#include<fstream>
#include<vector>
#include<initializer_list>
#include<string>
#include<stdio.h>
using namespace std;
  int main(){
int A,B;
scanf("%d%d",&A,&B);

if (A==1 && B==2)
{printf("3\n");}
else if (A==1 && B==3)
{printf("2\n");}
else if (A==2 && B ==1)
{printf ("3\n");}
else if (A==2 && B ==3)
{printf ("1\n");}
else if (A==3 && B ==2)
{printf ("1\n");}
else if (A==3 && B ==1)
{printf ("2\n");}}


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

struct vec {
  long long x, y;

  vec(long long _x, long long _y): x(_x), y(_y) {
  }

  __int128 dot(const vec &o) {
    return (__int128)x * (__int128)o.x + (__int128)y * (__int128)o.y;
  }

  __int128 cross(const vec &o) {
    return (__int128)x * (__int128)o.y - (__int128)y * (__int128)o.x;
  }

  bool operator < (const vec &o) {
    return (*this).cross(o) < (__int128)0;
  }
};

const int mod = 1000000007;
const int maxN = 1000000;
int f[maxN + 1];

int mul(int a, int b) {
  return (int)((((long long)a * (long long)b) % (long long)mod + mod) % mod);
}

int add(int a, int b) {
  return (int)((((long long)a + (long long)b) % (long long)mod + mod) % mod);
}

int get(int a, int b) {
  return add(add(f[a], f[b]), mod - 1);
}

int main() {
  f[0] = 1;
  for (int i = 0; i < maxN; ++i) {
    f[i + 1] = add(f[i], f[i]);
  }
  int n;
  std::cin >> n;
  std::vector <vec> a;
  int s = 0;
  for (int i = 0; i < n; ++i) {
    long long x, y;
    std::cin >> x >> y;
    if (x == 0 && y == 0) {
      s += 1;
      continue;
    }
    if (x < 0 || (x == 0 && y < 0)) {
      x = -x;
      y = -y;
    }
    a.push_back(vec(x, y));
  }
  n = (int)a.size();
  int ans = 1;
  std::sort(a.begin(), a.end());
  std::vector <bool> u(n, false);
  int cur = 0, next = 0;
  while (cur < n) {
    if (u[cur]) {
      ++cur;
      continue;
    }
    //std::cerr << "---" << std::endl;
    int i = cur;
    while (i < n && a[cur].cross(a[i]) == (__int128)0) {
      assert(!u[i]);
      u[i] = true;
      //std::cerr << " main: " << a[i].x << " " << a[i].y << std::endl;
      ++i;
    }
    int s1 = (i - cur);

    if (next < i) {
      next = i;
    }
    while (next < n && a[cur].dot(a[next]) > (__int128)0) {
      ++next;
    }
    int j = next;
    while (j < n && a[cur].dot(a[j]) == (__int128)0) {
      assert(!u[j]);
      u[j] = true;
      //std::cerr << "  sec: " << a[j].x << " " << a[j].y << std::endl;
      ++j;
    }
    int s2 = j - next;

    ans = mul(ans, get(s1, s2));
  }
  ans = add(ans, mod - 1);
  ans = add(ans, s);
  std::cout << ans << std::endl;
  return 0;
}


Measured memory_bytes: 11304
#include <iostream>
#include <algorithm>
#include <array>
#include <functional>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string>
#include <vector>

#define INF 1000000000
#define MOD 1000000007
#define ll long long
#define rep(i,a,b) for(int i = (a); i < (b); i++)
#define bitget(a,b) (((a) >> (b)) & 1)
#define vint vector<int>
#define vvint vector<vector<int>>
#define vsort(x) sort(x.begin(),x.end())

using int64 = uint64_t;

using namespace std;

int main() {
	int a[4];
	rep(i, 0, 4)
		cin >> a[i];
	int sum = 0;
	rep(i, 0, 4)
		sum += a[i];
	cout << sum / 60 << endl;
	cout << sum % 60 << endl;
	return 0;
}

Measured memory_bytes: 3100
#include<bits/stdc++.h>
using namespace std;
long long n,m;
int main(){
	ios::sync_with_stdio(false);
    cin>>n>>m;
    if(n==1||m==1) cout<<1;
    else if(m%2==0) cout<<n*m/2;
    else cout<<n*(m+1)/2-n/2;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
Bri = [list(map(int, input().split())) for _ in range(M)]

class UnionFind():
    # 作りたい要素数nで初期化
    # 使用するインスタンス変数の初期化
    def __init__(self, n):
        self.n = n
        # root[x]<0ならそのノードが根かつその値が木の要素数
        # rootノードでその木の要素数を記録する
        self.root = [-1]*(n+1)
        # 木をくっつける時にアンバランスにならないように調整する
        self.rnk = [0]*(n+1)

    # ノードxのrootノードを見つける
    def Find_Root(self, x):
        if(self.root[x] < 0):
            return x
        else:
            # ここで代入しておくことで、後の繰り返しを避ける
            self.root[x] = self.Find_Root(self.root[x])
            return self.root[x]
    # 木の併合、入力は併合したい各ノード
    def Unite(self, x, y):
        # 入力ノードのrootノードを見つける
        x = self.Find_Root(x)
        y = self.Find_Root(y)
        # すでに同じ木に属していた場合
        if(x == y):
            return 
        # 違う木に属していた場合rnkを見てくっつける方を決める
        elif(self.rnk[x] > self.rnk[y]):
            self.root[x] += self.root[y]
            self.root[y] = x

        else:
            self.root[y] += self.root[x]
            self.root[x] = y
            # rnkが同じ（深さに差がない場合）は1増やす
            if(self.rnk[x] == self.rnk[y]):
                self.rnk[y] += 1
    # xとyが同じグループに属するか判断
    def isSameGroup(self, x, y):
        return self.Find_Root(x) == self.Find_Root(y)

    # ノードxが属する木のサイズを返す
    def Count(self, x):
        return -self.root[self.Find_Root(x)]


Isla = UnionFind(N+1)

a = N*(N-1)//2
ans = [a]
for _ in range(M):
    x1, x2 = Bri.pop()
    if not Isla.isSameGroup(x1, x2):
        a = max(a-Isla.Count(x1)*Isla.Count(x2), 0)
    ans.append(a)
    Isla.Unite(x1, x2)
ans = ans[-2::-1]
for an in ans:
    print(an)


Measured memory_bytes: 31120
#include<bits/stdc++.h>
using namespace std;
#define fine cout<<"fine"<<endl;
#define ll long long int
#define pb push_back
#define FASTIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define F first
#define S second
#define all(v) v.begin(),v.end()
const ll inf=(ll)2e18;
const int mod=1e9+7;

void solve()
{
    ll n,m,v1,p;
    cin>>n>>m>>v1>>p;
    ll a[n];
    for(int i=0;i<n;i++)
    cin>>a[i];
    sort(a,a+n);
    vector<ll> v;
    v.pb(-1);
    for(int i=0;i<n-p+1;i++)
    v.pb(a[i]);
    ll s=0;
    int in=max((int)(v1-(p-1)-1),0);
    ll ans=p-1;
    int i;
    for(i=v.size()-1;i>in;i--){
        if(v[i]+m>=a[n-p])
        ans++;
    s+=v[i];}
    for(i=in;i>0;i--)
    {
        if(v[i]+m<a[n-p])
        break;
        ll va=(v.size()-1-i)*m+((v.size()-1-i)*v[i]-s);
        if(va>=0)
        {
            ll in1=v1-(i+p-1);
            if(in1!=0&&va/in1>=m)
            ans++;
        }
        s+=v[i];
    }
    cout<<ans<<endl;
}
int main()
{
    FASTIO;
    solve();
}


Measured memory_bytes: 2168
#include<cstdio>
#include<queue>
#include<utility>
#include<cstring>
#include<stack>
#include<algorithm>
#include<cmath>
#include<iostream>
#include<map>
#define MAX_N 100001
#define INF_INT 2147483647
#define INF_LL 9223372036854775807
#define REP(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
void init(int n);
int find(int n);
void unite(int x,int y);
bool same(int x, int y);
ll bpow(ll,ll,ll);
typedef vector<int> vec;
typedef vector<vec> mat;
mat mul(mat &A,mat &B);
mat pow(mat A,ll n);
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};


bool cmp_P(const P &a,const P &b){
  return a.second < b.second;
}
int main()
{
  int N;
  cin >> N;
  cout << (N/2)*((N+1)/2) << endl;
  return 0;
}

int par[MAX_N];
int ranks[MAX_N];

//n要素で初期化
void init(int n){
  REP(i,n){
    par[i] = i;
    ranks[i] = 0;
  }

}

//木の根を求める
int find(int x){
  if(par[x] == x){
    return x;
  }else{
    return par[x] = find(par[x]);
  }
}

void unite(int x,int y){
  x = find(x);
  y = find(y);
  if(x == y) return ;
  if(ranks[x] < ranks[y]){
    par[x] = y;
  }else{
    par[y] = x;
    if(ranks[x] == ranks[y]) ranks[x]++;
  }
}

bool same(int x, int y){
  return find(x) == find(y);
}

ll bpow(ll a, ll n,ll mod){
  int i = 0;
  ll res=1;
  while(n){
    if(n & 1)
      res = (res*a) % mod;
    a = (a*a) % mod;
    n >>= 1;
  }
  return res;
}
const int MOD = 1000000007;
mat mul(mat &A, mat &B){
  mat C(A.size(),vec(B[0].size()));
    REP(i,A.size())REP(k,B.size())REP(j,B[0].size()){
    C[i][j] = (C[i][j] + A[i][k] * B[k][j]) % MOD;
  }
  return C;
}

mat pow(mat A,ll n)
{
  mat B(A.size(),vec(A.size()));
  REP(i,A.size()){
    B[i][i] = 1;
  }
  while(n > 0){
    if ( n & 1) B = mul(B,A);
    A = mul(A,A);
    n >>= 1;
  }
  return B;
}


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

int main() {
  int K;
  cin >> K;
  auto start = system_clock::now();
  for (int cnt = 1, now = 0; static_cast<double>(duration_cast<milliseconds>(system_clock::now() - start).count()) < 1990; cnt++) {
    now = (now * 10 + 7) % K;
    if (now == 0) return cout << cnt << "\n", 0;
  }
  cout << -1 << "\n";
}

Measured memory_bytes: 3600
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace arc076_a
{
    class Program
    {
        static long mod = 1000000000 + 7; 
        static long Factorial(long n)
        {
            long ans = 1;
            for (long i = n; i > 0; i--)
            {
                ans *= i;
                while (ans > mod)
                {
                    ans = ans % mod;
                }
            }
            return ans;
        }
        static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split();
            long N = long.Parse(str[0]);
            long M = long.Parse(str[1]);
            if (!(N - M <= 1 && N - M >= -1))
            {
                Console.WriteLine(0);
            }
            else if (N == M)
            {
                Console.WriteLine((2 * (Factorial(N) % mod) * (Factorial(M) % mod)) % mod);
            }
            else
            {
                Console.WriteLine(((Factorial(N) % mod) * (Factorial(M) % mod)) % mod);
            }
        }
    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,(n)-1,0)
#define all(v) v.begin(), v.end()
#define endk '\n'
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ld eps = 1e-10;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b){if(a>b) a=b;}
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b){if(a<b) a=b;}

#define MAX_N 2000005
ll inv[MAX_N], fac[MAX_N], finv[MAX_N];
void make() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for(int i=2; i<MAX_N; i++) {
    inv[i] = mod - inv[mod%i] * (mod/i) % mod;
    fac[i] = fac[i-1] * (ll)i % mod;
    finv[i] = finv[i-1] * inv[i] % mod;
  }
}
ll perm(ll n, ll r) {
  if(n < 0)       return 0;
  else if(n < r)  return 0;
  else            return (fac[n] * finv[n-r]) % mod;
}
ll comb(ll n, ll r) {
  ll ans = 1;
  ans = perm(n, r);
  ans = (ans * finv[r]) % mod;
  return ans;
}
ll modpow(ll a, ll N) {
  ll ans = 1;
  ll tmp = a;
  while(N > 0) {
    if(N % 2 == 1) (ans *= tmp) %= mod;
    (tmp *= tmp) %= mod;
    N /= 2;
  }
  return ans;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  make();
  int n, k; cin >> n >> k;
  vector<ll> cnt(k+1);
  for(int i=k; i>=1; i--) {
    cnt[i] = modpow(k/i, n);
    for(int j=2; j*i<=k; j++) {
      (cnt[i] -= cnt[j*i]) %= mod;
      (cnt[i] += mod) %= mod;
    }
  }
  ll ans = 0;
  for(int i=1; i<=k; i++) (ans += cnt[i] * i) %= mod;
  cout << ans << endk;
  return 0;
}


Measured memory_bytes: 50968
a = [
    ['11', '11'],
    ['1', '1', '1', '1'],
    ['1111'],
    ['01', '11', '10'],
    ['110', '011'],
    ['10', '11', '01'],
    ['011', '110']
]


def f(b):
    for j in range(len(a)):
        for x in range(9 - len(a[j][0])):
            for y in range(9 - len(a[j])):
                c = True
                for i in range(len(a[j])):
                    if b[y + i][x:x + len(a[j][0])] != a[j][i]:
                        c = False
                if c:
                    return j

try:
    while True:
        b = [raw_input() for i in range(8)]
        print chr(ord('A') + f(b))
        raw_input()
except:
    pass

Measured memory_bytes: 4252
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed
#define pb push_back
#define eb emplace_back
using namespace std;
typedef long long ll;
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}
template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;
using pi=pair<int,int>;
using vi=vc<int>;
void yes(){ cout << "Yes" << endl; }
void no(){ cout << "No" << endl; }
int SIZE(string s){ return (int)s.size(); }

int main(){
    cout << fixed << setprecision(20);
    string s,t; cin >> s >> t;
    sort(s.begin(), s.end());
    sort(t.rbegin(), t.rend());
    if(s < t) yes();
    else no();
    return 0;
}


Measured memory_bytes: 256
from bisect import bisect_left

def main():
    ConstNum,PersonNum=map(int,input().split())

    S=[]
    T=[]
    X=[]
    for i in range(ConstNum):
        s,t,x=map(int,input().split())
        S.append(s)
        T.append(t)
        X.append(x)

    DepartureTime=[]
    for i in range(PersonNum):
        d=int(input())
        DepartureTime.append(d)

    XST=zip(X,S,T)
    XST=sorted(XST)

    res=[-1]*PersonNum
    stop=[-1]*PersonNum

    for x,s,t in XST:
        left_value=s-x
        right_value=t-x

        left_index=bisect_left(DepartureTime,left_value)
        right_index=bisect_left(DepartureTime,right_value)

        while left_index<right_index:
            if stop[left_index]==-1:
                res[left_index]=x
                stop[left_index]=right_index
                left_index+=1
            else:
                left_index=stop[left_index]

    for i in range(PersonNum):
        print(res[i])

if __name__=="__main__":
    main()

Measured memory_bytes: 58672
#define CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#include<algorithm>
#define fastIO std::ios_base::sync_with_stdio(false);std::cin.tie(0);std::cout.tie(0)
#define in(x) freopen(x,"r",stdin);
#define out(x) freopen(x,"w",stdout);
#define debug(x) cerr<<"("<<*x<<")"<<endl;
using namespace std;

#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define pb push_back
#define mp make_pair
#define maxn 2000005
#define N 1e5+1

typedef unsigned long long ll;
int dp[(int)1e6];
int n, m;
map<int, int>x;
ll  MOD = 1000000007;
int main() {
	fast
		memset(dp, 0, sizeof dp);
	int n, m;
	cin >> n >> m;
	for (int i = 0; i < m; i++)
	{
		int temp;
		cin >> temp;
		x[temp]++;
	}
	dp[0] = 1;
	dp[1] = 1;
	if (x[1] > 0)dp[1] = 0;
	if (x[0] > 0)dp[0] = 0;
	for (int i = 2; i <= n; i++)
	{
		if (x[i] > 0)dp[i] = 0;
		else dp[i] = (dp[i - 1] + dp[i - 2]) % MOD;
	}
	cout << dp[n] << endl;;
	cin >> dp[0];
		return 0;
	}

Measured memory_bytes: 8832
a,b,c,d,e,f = map(int,input().split())
con=0
ans_sugar=0
ans_beaker=0

for x in range(0,31):
  for y in range(0,31):
    if x==y==0:
      continue
    water=100*(a*x + b*y)
    for z in range(0,f-water+1):
      for w in range(0,f-water+1):
        if z==w==0:
          continue
        sugar=c*z + d*w
        beaker=sugar+water
        tmp_con=(sugar*100)/beaker
        if beaker>f:break
        if sugar<=(a*x + b*y)*e and tmp_con>con:
          ans_beaker=beaker
          ans_sugar=sugar
          con=tmp_con
       
if ans_beaker==0:
  while ans_beaker<f:
    ans_beaker+=100*a
    if ans_beaker>f:
      ans_beaker-=100*a
      break
print(ans_beaker,ans_sugar)     
    
    
    

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int a[3];
	for (int i=0; i<3; i++)
		cin >> a[i];
	sort(a, a+3);
	bool poor = false;
	if(a[0]==a[1] && a[1]!=a[2])
		poor = true;
	else if(a[0]!=a[1] && a[1]==a[2])
		poor = true;
	if(poor) cout << "Yes\n";
	else cout << "No\n";
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner scan=new Scanner(System.in);
		String str1=scan.next(),str2=scan.next();
		str1+=str1;
		if (str1.contains(str2))
        {
            System.out.println("Yes");
        }
		else {
			System.out.println("No");
		}
		}
}

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

int main()
{
	int a, b, c, d; cin >> a >> b >> c >> d;
	
	string ans = "No";

	if (abs(a - c) <= d) ans = "Yes";

	if(abs(a-b)<=d && abs(b-c)<=d) ans = "Yes";
		
	cout << ans << endl;
	
	return 0;
}

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

int main()
{
  int n;
  cin>>n;
  int a[n];
  for(int i=0; i<n; i++) cin>>a[i];
  int max=a[0];
  bool check=true;
  for(int i=0; i<n; i++)
  {
    if(a[i]>max) max = a[i];
    if(a[i]<max-1) check=false;
  }
  if(check) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}

Measured memory_bytes: 640
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " \n"[i==n-1];};
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll N;
	cin >> N;
	ll q[20], x[20];
	rep(i,0,N) cin >> q[i] >> x[i];
	ll v1 = 1, v2 = 0;
	rep(i,0,N){
		if(q[i] == 1){
			v1 *= x[i];
			v2 *= x[i];
		}else if(q[i] == 2){
			v2 += x[i];
		}else{
			v2 -= x[i];
		}
	}
	cout << -v2 << " " << v1 << endl;

}


Measured memory_bytes: 3212
#include <bits/stdc++.h>
using namespace std;
 
#define int long long int
#define vi vector<int>
#define vvi vector<vi>
#define read(a)  for(int i = 0; i < n; i++) cin >> a[i];
#define print(a)  for(int i = 0; i < n; i++) cout << a[i] << " ";
#define pb push_back
#define pql priority_queue<int>
#define pqs priority_queue<int, vi, greater<int>>
#define pqlv priority_queue<vi>
#define pqsv priority_queue<vi, vvi, greater<vi>>
// #define endl '\n'
#define N 10000002
#define MOD 1000000007
signed main() {
    int t = 1;
    // cin >> t;
    while(t--) {
        int x, y;
        cin >> x >> y;
        bool ans = false;
        for(int i = 0; i <= x; i++) {
            int a = i, b = x - i;
            if(a * 2 + b * 4 == y) {
                ans = true;
            }
        }
        (ans) ? cout << "Yes" : cout << "No";
    }
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define ld  double
#define ll long long 
#define pp push
#define pb push_back
#define pf push_front
#define mp make_pair
#define inf 1e9
#define f first
#define s second
#define pll pair<ll,ll>
#define vll vector<ll>
#define vi vector<int>
#define mod 1000000007
using namespace std; 
void lcs( char *X, char *Y, int m, int n ) 
{ 
   int L[m+1][n+1]; 
  
   /* Following steps build L[m+1][n+1] in bottom up fashion. Note 
      that L[i][j] contains length of LCS of X[0..i-1] and Y[0..j-1] */
   for (int i=0; i<=m; i++) 
   { 
     for (int j=0; j<=n; j++) 
     { 
       if (i == 0 || j == 0) 
         L[i][j] = 0; 
       else if (X[i-1] == Y[j-1]) 
         L[i][j] = L[i-1][j-1] + 1; 
       else
         L[i][j] = max(L[i-1][j], L[i][j-1]); 
     } 
   } 
  
   // Following code is used to print LCS 
   int index = L[m][n]; 
  
   // Create a character array to store the lcs string 
   char lcs[index+1]; 
   lcs[index] = '\0'; // Set the terminating character 
  
   // Start from the right-most-bottom-most corner and 
   // one by one store characters in lcs[] 
   int i = m, j = n; 
   while (i > 0 && j > 0) 
   { 
      // If current character in X[] and Y are same, then 
      // current character is part of LCS 
      if (X[i-1] == Y[j-1]) 
      { 
          lcs[index-1] = X[i-1]; // Put current character in result 
          i--; j--; index--;     // reduce values of i, j and index 
      } 
  
      // If not same, then find the larger of two and 
      // go in the direction of larger value 
      else if (L[i-1][j] > L[i][j-1]) 
         i--; 
      else
         j--; 
   } 
  
   // Print the lcs 
   cout<<lcs;
}
int main()
{
   char as[10000],ss[10000];
   cin>>as>>ss;
   ll n=strlen(as);
   ll m=strlen(ss);
   lcs(as,ss,n,m);
}

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

#define int long long
int n, m, a[100005];

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

signed main() {
    scanf("%lld%lld", &n, &m);
    int tmp = 1;
    for (int i = 1; i <= n; ++i) {
        int tt; scanf("%lld", &tt);
        a[i] = tt; tt /= 2;
        tmp = lcm(tmp, tt);
        if (tmp > m) { puts("0"); return 0; }
    }
    //if (tmp % 2 == 0) { puts("0"); return 0; }
    int ans = m / tmp - m / (tmp * 2);
    for (int i = 1; i <= n; ++i)
        if (tmp % a[i] == 0) { puts("0"); return 0; }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 1024
k, a, b = map(int, input().split())
if k < a or a >= b - 1:
    print(k + 1)
elif k % 2 == a % 2:
    print((b - a) * ((k - a + 1) // 2) + a + 1)
else:
    print((b - a) * ((k - a + 1) // 2) + a)

Measured memory_bytes: 3060
# -*- coding: utf-8 -*-
# C

import sys
from collections import defaultdict, deque
from heapq import heappush, heappop
import math
import bisect
input = sys.stdin.readline

# 再起回数上限変更
# sys.setrecursionlimit(1000000)

mod = 10**9 + 7
n = int(input())

ans = pow(10,n,mod)
ans -= pow(9,n,mod)
ans -= pow(9,n,mod)
ans += pow(8,n,mod)

print(ans % mod)


Measured memory_bytes: 65428
import fileinput


def algorithm(a, b):
    return a + b if b % a == 0 else b - a


def pass_inputs(input_lines):
    a, b = input_lines[0]
    return algorithm(a, b)


def convert_int(s):
    try:
        r = int(s)
    except ValueError:
        r = s
    return r


def run():
    out = pass_inputs([[convert_int(v) for v in l.strip().split(" ")] for l in fileinput.input()])
    print(out)


if __name__ == "__main__":
    run()


Measured memory_bytes: 3188
#include <iostream>
#include <utility>
using namespace std;
typedef long long ll;
pair<ll,ll> dp[100010],t[200010] = {};
ll a[100010],m = 0;
void built(){
	for(int i = m-1;i>0;i--){
		t[i] = max(t[i<<1],t[i<<1|1]);
	}
}

void update(ll p,pair<ll,ll> a){
	for(t[p+=m] = a;p>1;p >>= 1){
		t[p>>1] = max(t[p],t[p^1]);
	}
}

pair<ll,ll> query(int l, int r){
	pair<ll,ll> mx = {0,0};
	for(l += m, r += m; l<r; l >>= 1,r >>= 1){
		if(l&1) mx = max(mx,t[l++]);
		if(r&1) mx = max(mx,t[--r]);
	}
	return mx;
}
int main(){
	int i,n;
	cin >> n;
	for(i=0;i<n;i++){
		cin >> a[i];
		m = max(m,a[i]);
	}
	m++;
	for(i=0;i<n;i++){
		pair<ll,ll> p = query(0,a[i]);
		dp[a[i]] = {p.first + 1,p.second + a[i]};
		update(a[i],dp[a[i]]);
	}
	cout << query(0,m).second << endl;
}


Measured memory_bytes: 8544
import java.util.*;
import java.io.*;

class Main{
    public static void main(String[] args){
        int count;
        int[] array = new int[100];
        int key;

        try{
            Scanner scan = new Scanner(System.in);
            String str = scan.next();

            count = Integer.parseInt(str);

            for(int i = 0; i < count; i++){
                str = scan.next();
                array[i] = Integer.parseInt(str);
                if(i == count - 1){
                    System.out.println(array[i]);
                }else{
                    System.out.print(array[i] + " ");
                }
            }

            //Insertion Sort Part
            for(int i = 1; i < count; i++){
                key = array[i];
                int j = i -1;
                while(j >= 0 && array[j] > key){
                    array[j+1] = array[j];
                    j--;
                }
                array[j+1] = key;

                //if(key != array[i]){
                for(int k = 0; k < count; k++){
                    if(k == count - 1){
                        System.out.println(array[k]);
                    }else{
                        System.out.print(array[k] + " ");
                    }
                }
                //}

            }

        }catch(Exception e){
            System.out.println("ERROR");
        }

    }
}



Measured memory_bytes: 34208
#include<stdio.h>
int main()
{
    int N, i, count, j;
    scanf("%d", &N);
    int a[N+1];
    for(i=0; i<N; i++)
    {
        scanf("%d", &a[i]);
    }
    count=0;

    for(i=0; i<N; i++)
    {
        for(j=1; ; j++)
        {
            if(a[i]%2==0)
            {
                a[i]=a[i]/2;
                count++;
            }
            else
                break;
        }
    }
    printf("%d\n", count);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <bitset>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
template < class T > inline bool chmax(T& a, T b) {if (a < b) { a=b; return true; } return false; }
template < class T > inline bool chmin(T& a, T b) {if (a > b) { a=b; return true; } return false; }
#define DEBUG_VLL(vec) REP(sz, vec.size()) std::cerr<<vec[sz]<<(sz==vec.size()-1?'\n':' ');

const long long MOD = 1000000007;
const long long HIGHINF = (long long)1e18;
const int INF = (int)1e9;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    cout << n << ':';
    for (int i = 2; i * i <= n; i++) {
        while (n % i == 0) {
            cout << " " << i;
            n /= i;
        }
    }

    if (n != 1) cout << " " << n;
    cout << '\n';
    return 0;
}



Measured memory_bytes: 3212
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

int main() {
	ll a;
	double b;
	cin >> a >> b;
	ll B = b * 100 + 0.5;
	//ll ans = a * b+0.000001;
   //ll B = b;
	cout << a * B/100 << endl;
	return 0;
}


Measured memory_bytes: 3700
import scala.annotation.tailrec
import scala.math._

object Main extends App {

  val YES = "YES"
  val Yes = "Yes"
  val NO = "NO"
  val No = "No"

  val input: Array[Array[Int]] = Array.ofDim(6, 6000000)
  ///////////////////////////////////////////

  val sc = new java.util.Scanner(System.in)
  val a, b, k = sc.nextInt
//  val b = sc.nextInt
//  val discs = List.fill(m)(sc.nextInt)
//  val b = List.fill(m)(sc.nextInt)

  val mini = (a until a + k).filter(_ <= b)
  val maxi = (b - k + 1 to b).filter(a <= _)

  (mini ++ maxi).distinct.sorted.foreach(println(_))

  ///////////////////////////////////////////

  def bigIterator(start: BigInt, end: BigInt, step: BigInt = 1) =
    Iterator.iterate(start)(_ + step).takeWhile(_ <= end)

  def lcm(a :Int, b :Int): Int =
    a / gcd(a, b) * b

  def lcm(a :Long, b :Long): Long =
    a / gcd(a, b) * b

  def gcd(a: Int, b: Int): Int =
    if (b == 0) a else gcd(b, a % b)

  def gcd(a: Long, b: Long): Long =
    if (b == 0) a else gcd(b, a % b)

  def setOrUpdated[A, B](a: Map[A, B], key: A, value: B, f: (B, B) => B) =
    a.get(key) match {
      case Some(v) => a.updated(key, f(value, v))
      case _ => a + (key -> value)
    }

  // https://stackoverflow.com/questions/10199171/matcherror-when-match-receives-an-indexedseq-but-not-a-linearseq/10199441#10199441
  object +: {
    def unapply[T](s: Seq[T]) =
      s.headOption.map(head => (head, s.tail))
  }

  @tailrec
  def foldLeftWithNext[A, B](seq: Seq[A])(z: B)(op: (B, A, A) => B)(tailOp: (B, A) => B): B = {
    seq match {
      case Nil => z
      case a +: Nil => tailOp(z, a)
      case a +: next +: tail => foldLeftWithNext(next +: tail)(op(z, a, next))(op)(tailOp)
    }
  }
}

Measured memory_bytes: 169268
#include<iostream>
#include<cmath>
#include<algorithm>
#include <cassert>
#include<string>
using namespace std;
int main(){
	int a = 0, b = 0, c=0, d[100000], e[100000],f=0,g=0,h=0, count = 0;
	char ac,uc[100000];
	string manji,gage;
	cin >> manji;
	cout << manji.front()<< manji.size() - 2 << manji.back();
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define FIND(s, e) ((s).find(e) != (s).end())
#define EB emplace_back

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;
bool check(int n) {
    return 1 <= n && n <= INF;
}
signed main(void) {
    int N; cin >> N;
    VI p(N);
    for_each(ALL(p), [](int &e){scanf("%d", &e);});
    VI a(N), b(N);
    VI sum(N);
    REP(i, N) {
        sum[p[i] - 1] = INF - N + i - 1;
    }
    int cnt = 0;
    REP(i, N) {
        a[i] = i + 1 + cnt;
        b[i] = sum[i] - a[i];
        if (i == 0) continue;
        if (a[i] <= a[i - 1]) {
            int buf = a[i - 1] - a[i] + 1;
            a[i] += buf;
            b[i] -= buf;
            cnt += buf;
        }
        if (b[i] >= b[i - 1]) {
            int buf = b[i] - b[i - 1] + 1;
            a[i] += buf;
            b[i] -= buf;
            cnt += buf;
        }
        assert(check(a[i]) && check(b[i]));
    }
    for_each(ALL(a), [](int e){printf("%d ", e);});
    printf("\n");
    for_each(ALL(b), [](int e){printf("%d ", e);});
    printf("\n");
}


Measured memory_bytes: 896
from itertools import product

N = int(input())

S = [int(x) for x in str(N)]
n = len(S)

# dp[pos][smaller?][started?][3?][5?][7?]
dp = [[[[[[0] * 2 for _ in range(2)] for _ in range(2)]
        for _ in range(2)] for _ in range(2)] for _ in range(n + 1)]
dp[0][0][0][0][0][0] = 1

for i, j, k, c3, c5, c7 in product(range(n), [0, 1], [0, 1], [0, 1], [0, 1],
                                   [0, 1]):
    num = [0, 3, 5, 7]
    if not j:
        num = [x for x in num if x <= S[i]]
    if k:
        num = [x for x in num if x != 0]
    for x in num:
        f0 = k or x != 0
        f3 = c3 or x == 3
        f5 = c5 or x == 5
        f7 = c7 or x == 7
        dp[i + 1][j or x < S[i]][f0][f3][f5][f7] += dp[i][j][k][c3][c5][c7]

ans = sum([dp[n][j][1][1][1][1] for j in [0, 1]])
print(ans)


Measured memory_bytes: 3064
function Main(input) {
	var inputArr = input.split("\n");
	var arr = inputArr[0].split(" ");
 	var n = parseInt(arr[0]);
  	var d = parseInt(arr[1]);
 
  　var ans = Math.floor(n / (d*2 + 1));
　　var sur = n % (d*2 + 1);
  	if (sur > 0) {
      ans++;
    }

	console.log(ans) ;
}
 
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

int main(){
  int n;
  cin >> n;
  vector<long long> a(n);
  int count = 0;
  for(int i = 0; i < n; i++) cin >> a[i];
  for(int i = 0; i < n; i++){
    if(a[i] % 2 != 0) count++;
  }
  cout << (count % 2 == 0 ? "YES" : "NO") << endl;
}

Measured memory_bytes: 3992
package main

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

func main() {
	n := readInt()
	q := readInt()

	results := make([]int, n+1)
	parents := make([]int, n+1)

	for i := 0; i < n-1; i++ {
		a := readInt()
		b := readInt()
		parents[b] = a
	}

	for i := 0; i < q; i++ {
		p := readInt()
		x := readInt()
		results[p] += x
	}

	for i := 1; i <= n; i++ {
		results[i] += results[parents[i]]
	}

	for i := 1; i <= n; i++ {
		fmt.Print(results[i])

		if i != n {
			fmt.Print(" ")
		}
	}
	fmt.Println()
}

const (
	ioBufferSize = 1 * 1024 * 1024 // 1 MB
)

var stdinScanner = func() *bufio.Scanner {
	result := bufio.NewScanner(os.Stdin)
	result.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	result.Split(bufio.ScanWords)
	return result
}()

func readString() string {
	stdinScanner.Scan()
	return stdinScanner.Text()
}

func readInt() int {
	result, _ := strconv.Atoi(readString())
	return result
}


Measured memory_bytes: 11904
def solve():
    n,l = map(int,input().split())
    if l > 0:
        print(int(n*(l-1)+n*(n+1)/2-l))
    elif l <= 0 and l +n-1 >=0:
        print(int(n*(l-1)+n*(n+1)/2))
    else:
        print(int(n*(l-1)+n*(n+1)/2-l-n+1))
    return 0

solve()

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

int main(int argc, char const* argv[]) {
    std::string Sa, Sb, Sc;
    char        turn = 'a';
    std::cin >> Sa >> Sb >> Sc;

    while (1) {
        if (turn == 'a') {
            if (Sa == "") {
                std::cout << "A" << '\n';
                break;
            }
            turn = Sa.at(0);
            Sa.erase(Sa.begin());
        } else if (turn == 'b') {
            if (Sb == "") {
                std::cout << "B" << '\n';
                break;
            }
            turn = Sb.at(0);
            Sb.erase(Sb.begin());
        } else {
            if (Sc == "") {
                std::cout << "C" << '\n';
                break;
            }
            turn = Sc.at(0);
            Sc.erase(Sc.begin());
        }
    }
    return 0;
}


Measured memory_bytes: 256
while True:
    N, M = map(int, input().split())

    if N == 0 and M == 0:
        break

    h = [int(input().replace("\r", "")) for _ in range(N)]
    w = [int(input().replace("\r", "")) for _ in range(M)]

    table = {}

    for i in range(N):
        tmp = 0
        for j in range(i, N):
            tmp += h[j]
            table[tmp] = table.get(tmp, 0) + 1

    ans = 0

    for i in range(M):
        tmp = 0
        for j in range(i, M):
            tmp += w[j]
            ans += table.get(tmp, 0)

    print(ans)




Measured memory_bytes: 34928
import Control.Applicative

main :: IO ()
main = do
  { [a, b] <- readLineInputs
  ; print $ solve a b
  }

{- |
>>> solve 4 10
3
>>> solve 8 9
2
>>> solve 8 8
1
-}
solve :: Int -> Int -> Int
solve a b = iter a b 1 0
  where
    iter a b c d = if b <= c then d
      else iter a b (pred c + a) (succ d)

readLineInputs :: Read a => IO [a]
readLineInputs = map read . words <$> getLine



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

#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, m, n) for(int i = (int)(m); i < (int)(n); ++i)

const int MOD = 1e+9 + 7;

template <typename T>
T pow_mod( T n, T p )  // n^p % m
{
    if( p == 0 ) return 1;
    if( p%2 == 1 ) return pow_mod(n, p-1) * n % MOD;
    else{
        T tmp = pow_mod(n, p/2) % MOD;
        return tmp*tmp % MOD;
    }
}

template <typename T>
T nCk_mod( T n, T k )
{
    if( n < 0 or k < 0 || n < k ) return 0;
    T numerator = 1, denominator = 1;
    for( int i = 1; i <= min(k, n-k); ++i ){
        numerator = numerator*(n-i+1) % MOD;
        denominator = denominator*i %MOD;
    }
    return numerator * pow_mod<T>(denominator, MOD-2) % MOD;
}

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

    REP(i, K){
        cout << (nCk_mod<long long>(N-K+1, i+1) * nCk_mod<long long>(K-1, i)) % MOD << endl;
    }
    
    return 0;
}

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

using namespace std;

#define FOR(i, j, k) for(int i = j; i < k; ++i)
#define rep(i, j) FOR(i, 0, j)
#define FORr(i, j, k) for(int i = j; i >= k; --i)
#define repr(i, j) FOR(i, j, 0)
#define INF (1 << 30)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> Pi;

const int MOD = 1e9 + 7;
const int dy[]={0, 0, 1, -1};
const int dx[]={1, -1, 0, 0};

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

int main() {
	int X, A, B;
	scanf("%d %d %d", &X, &A, &B);
	int tmp = A - B;
	if(tmp < 0) {
		if(abs(tmp) <= X) printf("safe\n");
		else printf("dangerous\n");
	}
	else printf("delicious\n");
	return 0;
}

Measured memory_bytes: 256
x,y,z=map(int,input().split())
if x+z-1<y-z+1:
	for i in range(x,x+z):
		print(i)
	for j in range(y-z+1,y+1):
		print(j)
else:
	for k in range(x,y+1):
		print(k)

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

using namespace std;

int main() {
  int N;
  cin >> N;
  vector<int> A;
  for(int i = 1; i <= 9; i++) A.push_back(111 * i);
  cout << *lower_bound(A.begin(), A.end(), N) << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main() {
  int N;

  cin >> N;

  int ans = 1000000000;
  for (int i = 1; i <= N / 2; i++) {
    int a = i;
    int b = N - i;
    int asum = 0, bsum = 0;

    while (a > 0) {
      asum += a % 10;
      a = a / 10;
    }
    while (b > 0) {
      bsum += b % 10;
      b = b / 10;
    }
    ans = min(ans, asum + bsum);
  }

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


Measured memory_bytes: 256