akhauriyash/Code-Regression huggingface dataset:
//shara's here
#include<bits/stdc++.h>
using namespace std;
int main(){
	int x,y,z;
	cin>>x>>y>>z;
	if(x+y==z)cout<<"Yes";
	else if(x+z==y){cout<<"Yes";}
	else if(y+z==x){cout<<"Yes";}
	else cout<<"No";


	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define fore(i,a) for(auto &i:a)
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
//---------------------------------------------------------------------------------------------------
struct UnionFind {vector<int> par, cnt;
    UnionFind(int NV) { par.clear(); cnt.resize(NV, 1); rep(i, 0, NV) par.push_back(i); }
    void reset() { rep(i, 0, cnt.size()) cnt[i] = 1; rep(i, 0, par.size()) par[i] = i; }
    int operator[](int x) { return par[x] == x ? x : par[x] = operator[](par[x]); }
    void operator()(int x, int y) {x = operator[](x); y = operator[](y);
        if (x != y) par[x] = y, cnt[y] += cnt[x];}};
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/
 
 


#define NO "NO"
#define YES "YES"
int N, H;
vector<int> E[500];
int in[505], ou[505];
int used[505], ok[505];
//---------------------------------------------------------------------------------------------------
string solve() {
    cin >> N >> H;
    UnionFind uf(505);
    rep(i, 0, N) {
        int a, b, c, d; cin >> a >> b >> c >> d;

        int L;
        if (0 < c) L = -c;
        else L = a;

        int R;
        if (0 < d) R = d;
        else R = -b;

        L += 250, R += 250;

        E[L].push_back(R);

        ou[L]++;
        in[R]++;

        used[L] = used[R] = 1;
        uf(L, R);

        //printf("[%d -> %d]\n", L - 250, R - 250);
    }

    rep(i, 0, 505) {
        int x = i - 250;

        if (0 < x) {
            if (ou[i] < in[i]) return NO;
            else if (ou[i] > in[i]) uf(500, i);
        }

        if (x < 0) {
            if (in[i] < ou[i]) return NO;
            else if (in[i] > ou[i]) uf(500, i);
        }
    }

    rep(i, 0, 505) if (used[i]) {
        if (uf[i] != uf[500]) return NO;
    }

    return YES;
}
//---------------------------------------------------------------------------------------------------
void _main() {
    cout << solve() << endl;
}

Measured memory_bytes: 1024
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower

#define lint long long

using namespace std;

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

  set<lint> n_set;
  for(int i=0;i<n;i++){
    int a;
    cin >> a;
    n_set.insert(a);
  }
  if(n==n_set.size()){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
  
  return 0;
}


Measured memory_bytes: 9600
#include<iostream>
#include<algorithm>
#define SEISEKI 10000000

using namespace std;

int main() {
	while (1) {
		int n;
		int ans=SEISEKI;

		cin >> n;
		int a[1001];
		if (n == 0)break;
		for (int i = 0; i < n; i++) {
			cin >> a[i];
		}

		sort(a, a+n);	//昇順

		for (int i = 0; i<n; i++) {
			for (int j = i + 1; j < n; j++) {
				ans = min(ans, abs(a[i] - a[j]));
			}
		}
		cout << ans<<endl;
	}
	return 0;
}


Measured memory_bytes: 3072
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		String S = sc.next();

		for (int i = 0; i < S.length(); i++) {
			System.out.print("x");
		}
		System.out.println("");

		sc.close();
	}

}


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

using namespace std;

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;
const ll MAX = 100005;

ll A[100005];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    REP(i, N) {
        cin >> A[i];
    }
    ll ans = 0;
    vector<pll> v0(MAX), v1(MAX);
    REP(i, MAX) {
        v0[i].second = i;
        v1[i].second = i;
    }
    for (ll i = 0; i < N; i += 2) {
        v0[A[i]].first++;
    }
    for (ll i = 1; i < N; i += 2) {
        v1[A[i]].first++;
    }
    ll a = (N + 1) / 2, b = N / 2;
    sort(v0.begin(), v0.end(), [](pll a, pll b) { return a.first > b.first; });
    sort(v1.begin(), v1.end(), [](pll a, pll b) { return a.first > b.first; });
    if (v0[0].second == v1[0].second)
        ans = std::min(a - v0[0].first + b - v1[1].first,
                       a - v0[1].first + b - v1[0].first);
    else
        ans = a - v0[0].first + b - v1[0].first;

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

Measured memory_bytes: 4224
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <math.h>

int main(void) {
    int H, W;
    int K;
    int C[6][6];
    int pt = 0;

    scanf("%d %d %d", &H, &W, &K);

    for(int i = 0; i < H; i++) {
        char t[7];
        scanf("%s", t);
        for(int j = 0; j < W; j++) {
            if(t[j] == '.') {
                C[i][j] = 0;
            }
            else {
                C[i][j] = 1;
            }
        }
    }

    for(int i = 0; i < pow(2, H); i++) {
        for(int j = 0; j < pow(2, W); j++) {

            int cnt = 0;
            for(int x = 0; x < H; x++) {
                for(int y = 0; y < W; y++) {
                    if((C[x][y] == 1) && (((i >> x) & 0x01) == 0x00) && (((j >> y) & 0x01) == 0x00)) {
                        cnt++;
                    }
                }
            }

            if(cnt == K) {
                pt++;
            }
        }
    }

    printf("%d\n", pt);
    
    return 0;
}


Measured memory_bytes: 2540
#include<iostream>
#include<string>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define AC "CORRECT"
#define INF 1e6
using namespace std;
typedef pair<int,int> P;

int main(){
	int t,p,r,tid,qid,time;
	string check;
	while(cin>>t>>p>>r,t||p||r){
		P point[t+1];
		int wc[t+1][p+1];
		int num[t+1];
		rep(i,t+1){
			point[i]=P(0,0);
			rep(j,p+1)wc[i][j]=0;
			num[i]=i;
		}
		point[0]=P(0,INF);
		rep(i,p+1)wc[0][i]=INF;
		rep(i,r){
			cin>>tid>>qid>>time>>check;
			if(check==AC){
				point[tid].first++;
				point[tid].second+=(time+wc[tid][qid]*1200);
			}else wc[tid][qid]++;
		}
		for(int i=t;i>=0;i--){
			loop(j,0,i){
				bool hoge=false;
				if(point[j].first>point[j+1].first){
					hoge=true;
				}else if(point[j].first==point[j+1].first){
					if(point[j].second<point[j+1].second){
						hoge=true;
					}else if(point[j].second==point[j+1].second){
						if(num[j]<num[j+1]){
							hoge=true;
						}
					}
				}
				if(hoge){
					int tmp=num[j];
					num[j]=num[j+1];
					num[j+1]=tmp;
					P alt=point[j];
					point[j]=point[j+1];
					point[j+1]=alt;
				}
			}
		}
		for(int i=t;i>=1;i--)cout<<num[i]<<" "<<point[i].first<<" "<<point[i].second<<endl;
	}
	return 0;
}

Measured memory_bytes: 3172
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
using namespace std;
using ll = long long;
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; }
const ll INF = 1e18;
const ll MOD = 1e9 + 7;

int main(){
    int n, x;
    cin >> n >> x;
    vector<ll> v(n);
    rep(i, n) cin >> v[i];

    ll ans = 0;
    for(int i=1; i<n; i++){
        if(v[i-1] + v[i] > x){
            ll diff = (v[i-1] + v[i]) - x;
            ans += diff;
            v[i] -= min(v[i], diff);
            diff -= min(v[i], diff);
            v[i-1] -= min(v[i-1], diff);
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 1024
def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]

N = int(input())

yakusu_list = make_divisors(N)
if len(yakusu_list)%2 == 1:
    ans = (yakusu_list[len(yakusu_list)//2]-1)*2
else:
    ans = yakusu_list[len(yakusu_list)//2-1] - 1 + yakusu_list[len(yakusu_list)//2] - 1

print(ans)

Measured memory_bytes: 9236
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <cstdio>
#include <string>
#include <vector>
#include <random>
#include <chrono>
#include <utility>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <sstream>
#include <assert.h>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <unordered_map>
using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(bool x) {cerr << (x ? "true" : "false");}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}

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...);}
#ifdef HOME
#warning CHECK int:ll::INT_MAX:LLONG_MAX
#define maxn 20
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define maxn 2000006
#define gcd __gcd
#define debug(x...)
#endif

#define ff first
#define endl '\n'
#define ss second
#define inf 0x3f3f3f3f

#define MOD 1000000007
#define PI 3.14159265358979323846264338327950L
#define f(i,x,n) for(int i=x;i<=n;i++)
#define fr(i,x,n) for(int i=x;i>=n;i--)
struct _ { ios_base::Init i; _() { ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL); } } _;

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


int main() {

	long long x; cin >> x;

	long long A = 0, B = 0;

	for (A = -1000; A <= 1000; A++) {
		for (B = -1000; B <= A; B++) if ((pow(A, 5) - pow(B, 5)) == x) {
				cout << A << " " << B;
				exit(0);
			}
	}

	return 0;
}

Measured memory_bytes: 4036
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

vector<LL> tb;

void divisor(int64_t n) {
	
	for (int64_t i = 1; i * i <= n; i++) {
		if (n % i == 0) {
			tb[i]++;
			if (i * i != n) tb[n / i]++;
		}
	}
	
}

void prime_factor(int64_t n) {
	
	for (int64_t i = 2; i * i <= n; i++) {
		while (n % i == 0) {
			tb[i]++;
			n /= i;
		}
	}

	//素数は1回も割られないのでそのままでてくる
	if (n != 1) tb[n]++;
	tb[1]++;
	return;
}


int main() {

	int n; cin >> n;
	tb.resize(n+1);


	vector<int> a(n);

	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	set<int> ans;
	for (int i = n-1; i >=0; i--) {
		int val = a[i];
		int r = tb[i + 1] % 2;

		if (r != val) {
			ans.insert(i + 1);
			divisor(i + 1);
		}
	}

	cout << ans.size() << endl;
	for (auto i : ans) {
		cout << i << " ";
	}

	cout << endl;
	

	return 0;
}
/*
5
1 1 1 1 1
*/

Measured memory_bytes: 9216
import java.io.*;
import java.util.*;
import java.math.*;


public class Main {
	Scanner sc = new Scanner(System.in);

	void run() {
		boolean m[][] = new boolean[8][8];
		m[7][1] = true;
		m[7][2] = true;
		m[7][3] = true;
//		m[7][4] = true;
		m[6][1] = true;
		
		int p[][] = new int[8][8];
		p[1][2] = 300;
		p[1][3] = 500;
		p[1][4] = 600;
		p[1][5] = 700;
		p[1][6] = 1350;
		p[1][7] = 1650;
		p[2][3] = 350;
		p[2][4] = 450;
		p[2][5] = 600;
		p[2][6] = 1150;
		p[2][7] = 1500;
		p[3][4] = 250;
		p[3][5] = 400;
		p[3][6] = 1000;
		p[3][7] = 1350;
		p[4][5] = 250;
		p[4][6] = 850;
		p[4][7] = 1300;
		p[5][6] = 600;
		p[5][7] = 1150;
		p[6][7] = 500;
		
		for(;;){
			int n = sc.nextInt();
		      
			if(n == 0){
				break;
			}
			
			int t1 = sc.nextInt()*60+sc.nextInt();
			
			int mz = sc.nextInt();
			int t2 = sc.nextInt()*60 + sc.nextInt();
			
			boolean h = false;
			if(t1 >= 17*60 + 30 && t1 <= 19*60 + 30){
				h = true;
			}
			if(t2 >= 17*60 + 30 && t2 <= 19*60 + 30){
				h = true;
			}
			int a = Math.max(n, mz);
			int b = Math.min(n , mz);
			
			if(m[a][b]){
				h = false;
			}
			
			int pr = p[b][a];
			
			if(h){
				if(pr % 100 == 0){
					System.out.println(pr/2);
				}else{
					System.out.println((pr-50)/2+50);
				
				}
			}else{
				System.out.println(pr);
			}
			
		}

	}

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

}

Measured memory_bytes: 12000
#include <functional>
#include <algorithm>
#include <iostream>
#include <numeric>
#include <iomanip>
#include <utility>
#include <cstdlib>
#include <sstream>
#include <bitset>
#include <vector>
#include <cstdio>
#include <ctime>
#include <queue>
#include <deque>
#include <cmath>
#include <stack>
#include <list>
#include <map>
#include <set>

using namespace std;

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

#define dump(x)  cerr << #x << " = " << (x) << endl
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back


int main() {
    int b,r,g,c,s,t;
    while(cin>>b>>r>>g>>c>>s>>t){
        if(b==0 && r==0 && g==0 && c==0 &&s==0 && t==0)break;
        int sum=100;

        sum-=3*( t-(s + b*5 + r*3) );
        sum-=2*( b*5 + r*3 );
        
        sum+=b*15 + r*15 + g*7 + c*2;
        sum+=b*5*15 + r*3*15;
        
        cout<<sum<<endl;
    }
    return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define vi vector<int>
#define pb push_back
#define F first
#define S second
#define pi pair<int,int>
#define all(v) v.begin(),v.end()
const int MOD = 1e9+7;
template <typename A>istream& operator>>(istream& input,vector<A>& x) {for(auto& i:x)input>>i;return input;}
template<typename A>ostream& operator<<(ostream& output,vector<A>& x) {for(auto& i:x)output<<i<<' ';return output;}
signed main()
{
    ios::sync_with_stdio(0); cin.tie(0);cout.tie(0);
    int T=1;
   // cin>>T;
    while(T--)
    {
        int a,b;
        cin>>a>>b;
        int ans =ceil(1.0*(b-a)/(a-1));
        cout<<ans+1<<"\n";
    }

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(int)(a); i!=(int)(b); i++)
#define RFOR(i, a, b) for(int i=(int)(a); i!=(int)(b); i--)
#define REP(i, n) FOR(i, 0, n)
using namespace std;
using ll = long long;

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

  sort(x, x+3);

  cout << (x[2]*10) + x[1] + x[0] << endl;

  return 0;
}


Measured memory_bytes: 256
import sys
import math
import collections
import itertools
import array
import inspect

# Set max recursion limit
sys.setrecursionlimit(10000)

# Debug output
def chkprint(*args):
    names = {id(v):k for k,v in inspect.currentframe().f_back.f_locals.items()}
    print(', '.join(names.get(id(arg),'???')+' = '+repr(arg) for arg in args))

# Binary converter
def to_bin(x):
    return bin(x)[2:]

# --------------------------------------------

dp = None

def main():
    num_max, length, d = [int(_) for _ in input().split()]

    # 数列の全パターン数
    all_pattern = num_max * length

    # ペアの全パターン数
    pair_pattern = num_max ** 2

    # 差の絶対値がdとなるペアの個数
    if d == 0:
        d_pattern = (num_max - d)
    else:
        d_pattern = (num_max - d) * 2

    # ペアの差の絶対値がdとなる確率
    prob = d_pattern / pair_pattern

    ans = prob * (length - 1)

    print(ans)

main()


Measured memory_bytes: 5012
#include <stdio.h>
int main(void) {
 
	// ?????????????????\???
	int num1,num2,num3;
	scanf("%d" "%d" "%d",&num1,&num2,&num3);
 
	// ?????¶??????????????????
	if (num1 < num2 && num2 < num3) {
 
		printf("Yes\n");
 
	} else {
 
		printf("No\n");
 
	}
	return 0;
}

Measured memory_bytes: 1808
#include <bits/stdc++.h>
using namespace std;
const int N=105;
int n,a[N];
int main(){
	cin >> n;
	for (int i=1;i<=n;i++)
		cin >> a[i];
	int tot=0;
	for (int i=1;i<=n;i++)
		tot+=a[i];
	int t=1;
	for (int i=1;i<=n;i++)
		if (abs(a[i]*n-tot)<abs(a[t]*n-tot))
			t=i;
	cout << t-1;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int n,m,a[1000];
int main(void){
    while(1){
    cin>>n>>m;
    if(n==0&&m==0)return 0;
    for(int i=0;i<n;i++)cin>>a[i];
    int ans=0;
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            if(i!=j){
                int L=a[i]+a[j];
                if(L<=m)ans=max(ans,L);
            }
        }
    }
    if(ans==0)cout<<"NONE"<<endl;
    else cout<<ans<<endl;
    }
}



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

int main(){
	int n;
	cin>>n;
	int a[n];
	rep(i,n) cin>>a[i];
  int b[n];	
  memcpy(b,a,sizeof(a));
	sort(a,a+n);
	int mx=a[n-1];
	int nx=a[n-2];
	rep(i,n){
		if(b[i]!=mx) cout << mx << endl;
		else cout << nx << endl;
	}

}

Measured memory_bytes: 3200
#include <iostream>
#include <cmath>
#include <climits>
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <string>
#include <stack>
#include <algorithm>
#include <map>
#include <numeric>
#include <set>
using namespace std;

#define ll long long
#define ld long double
// v:vector  type:型  order:greater or less
#define _sort(v,type,order) do { sort(v.begin(),v.end(),order<type>()); } while(0)
// vector 要素の総和算出
// v:vector  default_value:初期値
#define _sum(v,default_value) accumulate(v.begin(),v.end(),default_value )
// vector 最大値( return ite )
#define _max_element(v) max_element(v.begin(),v.end())
// vector 最大値が格納されている要素値
#define _max_element_number(v) distance(v.begin(),max_element(v.begin(),v.end()))

//set<uint32_t> member;	// 重複するデータを保持する事はできない member.insert(2) member.insert(2) ⇒ member.count(2)は1
//multiset<uint32_t> v;	// 重複するデータも保持する事はできる   member.insert(2) member.insert(2) ⇒ member.count(2)は2

// 丸め
#define _round(v) round(v)
// 2乗 / 3乗
#define _square(v) pow(v,2)
#define _cube(v)   pow(v,3)
// 大小判定
#define _max(x,y) max(x,y)
#define _min(x,y) min(x,y)
// string ⇒ int
#define _stringtoi(s) stoi(s)
// double 平方根
#define _sqrt(x) sqrt(x)
// double 引数 x 以上で最小の整数値 ex) 3.30303 ⇒ 4
#define _ceil(x) ceil(x)
// 指定された要素以上の値が現れる最初の位置のイテレータを取得する
#define _lower_bound(v,min) lower_bound(v.begin(), v.end(), min)
// 指定された要素より大きい値が現れる最初の位置のイテレータを取得する
#define _upper_bound(v,min) upper_bound(v.begin(), v.end(), min)

// 順列 n個の数が与えられる
// 0,1,2,...,n-1
// 全ての並べ方を1行ごとに出力する
// ex 0 1 2 / 0 2 1 / 1 0 2 / 1 2 0 / 2 0 1 / 2 1 0
#define _next_permutation(v) do {   \
	for (auto num : v) {            \
		printf("%d ", num);         \
	}                               \
	printf("\n");                   \
} while (next_permutation(v.begin(), v.end()))

// 絶対値
static int32_t _abs(const int32_t x) { return  (x > 0 ? x : -x); }
// 最大公約数
static int gcd(int a, int b)
{
	if (a < b) {
		a ^= b;
		b ^= a;
		a ^= b;
	}
	return b ? gcd(b, a % b) : a;
}
// 最小公倍数
static int lcm(int a, int b) { return a * b / gcd(a, b); }
// 多次元 std::vector 生成
template<class T>
vector<T> make_vec(size_t a) { return vector<T>(a); }
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts) { return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...)); }
// ex) auto dp = make_vec<uint64_t>(SIZE + 1, 2, 2);

// 168 B
// https://atcoder.jp/contests/abc168/tasks/abc168_b

int main()
{
	string s;
	uint32_t k;

	cin >> k >> s;

	if (s.size() <= k) {
		printf("%s\n", s.c_str());
		return 0;
	}

	string result = s.substr(0, k);
	result += "...";
	printf("%s\n", result.c_str());

	return 0;
}


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

int main() {
int h,w;
cin>>h>>w;
char a[h][w];
  for(int i=0 ; i<h ; i++){
    for(int j=0 ; j<w ; j++) cin>>a[i][j];
  }
  
  for(int i=0 ; i<w+2 ; i++) cout<<"#";
  cout<<endl;
  
  for(int i=0 ; i<h ; i++){
    cout<<"#";
   for(int j=0 ; j<w ; j++) cout<<a[i][j];
    cout<<"#"<<endl;
  }
  
  for(int i=0 ; i<w+2 ; i++) cout<<"#";
  cout<<endl;
  }

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n, e[300010], w[300010], pe=0, pw=0;

int main(void){
    string s;
    cin >> n >> s;
    for(int i=0;i<n;++i){
        if(s[i]=='W') ++pw;
        w[i] = pw;
    }
    for(int i=n-1;i>=0;--i){
        if(s[i]=='E') ++pe;
        e[i] = pe;
    }
    int min = 300010;
    for(int i=0;i<n;++i){
        if(min > (w[i]+e[i]-1)) min = w[i]+e[i]-1;
    }
    cout << min << endl;
}


Measured memory_bytes: 3076
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)
#define all(x) x.begin(),x.end()

int main() {
  int y,m,d;
  string s;
  cin >> s;
  {
    stringstream ss;
    ss << s.substr(5,2);
    ss >> m;
  }
  {
    stringstream ss;
    ss << s.substr(8,2);
    ss >> d;
  }
  if(m < 4) {
    cout << "Heisei" << endl;
  }
  else if(m > 4) {
    cout << "TBD" << endl;
  }
  else if(d <= 30) {
    cout << "Heisei" << endl;
  }
  else {
    cout << "TBD" << endl;
  }

}


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 = new int[3];
     a[0] = sc.nextInt();
     a[1] = sc.nextInt();
     a[2] = sc.nextInt();
     java.util.Arrays.sort(a);
     System.out.println(a[0]+" "+a[1]+" "+a[2]);
    }
}


Measured memory_bytes: 26192
#include <iostream>
#include <vector>
#include <queue>
#include <cmath>
#include <algorithm>
#include <string>

using namespace std;

int main()
{
    long long int x, n;
    cin >> x;
    for (long long int a = -118; a <= 119; a++)
    {
        for (long long int b = -119; b <= 118; b++)
        {
            if (a * a * a * a * a - b * b * b * b * b == x)
            {
                cout << a << " " << b << endl;
                return 0;
            }
        }
    }
    return 0;
}

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

using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); i++) 
#define REP(i, n) for (int i = 0; i < (n); i++)

typedef pair<int,string> minus2;
typedef long long ll;
int main(int argc, char const *argv[])
{
    int N; cin >> N;
    vector<ll> limit;
    ll res = 0;
    int ans[34] = {0};
    ll beki = 1;
    limit.push_back(0);
    limit.push_back(1);
    for (int i = 0;limit.back()>-1e10;i++){
        beki *= -2;
        ll tmp = limit[i] + beki;
        limit.push_back(tmp);
    }
    if (N==0){
        cout << "0" << endl;
        return 0;
    }
    
    while(N!=0){
        if (N == 1) {
            ans[1] = 1;
            break;
        }
        REP (i, limit.size()){
            if (N > 0) {
                if (N <= limit[i]){
                    N -= limit[i] - limit[i - 2];
                    ans[i] = 1;
                    break;
                }
            }
            else if (N < 0) {
                if (N >= limit[i]){
                    N -= limit[i] - limit[i - 2];
                    ans[i] = 1;
                    break;
                }
            }
        }
    }
    int idx;
    string o;
    for (idx = 33; idx > 0; idx--) {
        if (ans[idx] == 1) break;
    }
    for (int i = idx; i>0; i--) {
        char c = (ans[i] == 0) ? '0':'1';
        o.push_back(c);
    }
    cout << o << endl;
    return 0;
}


Measured memory_bytes: 256
s = input()
S = len(s)

#i文字目まで見たときj文字目まで確定しているときの組み合わせ
dp = [[0 for i in range(4)]for j in range(S+1)]
mod = 10**9+7

dp[0][0] = 1

for j in range(4):
    for i in range(S):
        dp[i+1][j] = dp[i][j]%mod
        if s[i] == "?":
            dp[i+1][j] = dp[i][j]*3%mod
            if j > 0:
                dp[i+1][j] += dp[i][j-1]%mod
        else:
            if "ABC".index(s[i])+1 == j:
                dp[i+1][j] += dp[i][j-1]%mod

print(dp[S][3]%mod)

Measured memory_bytes: 27584
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from functools import lru_cache
import bisect
import re
import queue


class Scanner():
    @staticmethod
    def int():
        return int(sys.stdin.readline().rstrip())

    @staticmethod
    def string():
        return sys.stdin.readline().rstrip()

    @staticmethod
    def map_int():
        return [int(x) for x in Scanner.string().split()]

    @staticmethod
    def string_list(n):
        return [input() for i in range(n)]

    @staticmethod
    def int_list_list(n):
        return [Scanner.map_int() for i in range(n)]

    @staticmethod
    def int_cols_list(n):
        return [int(input()) for i in range(n)]


class Math():
    @staticmethod
    def gcd(a, b):
        if b == 0:
            return a
        return Math.gcd(b, a % b)

    @staticmethod
    def lcm(a, b):
        return (a * b) // Math.gcd(a, b)

    @staticmethod
    def roundUp(a, b):
        return -(-a // b)

    @staticmethod
    def toUpperMultiple(a, x):
        return Math.roundUp(a, x) * x

    @staticmethod
    def toLowerMultiple(a, x):
        return (a // x) * x

    @staticmethod
    def nearPow2(n):
        if n <= 0:
            return 0
        if n & (n - 1) == 0:
            return n
        ret = 1
        while(n > 0):
            ret <<= 1
            n >>= 1
        return ret

    @staticmethod
    def sign(n):
        if n == 0:
            return 0
        if n < 0:
            return -1
        return 1

    @staticmethod
    def isPrime(n):
        if n < 2:
            return False
        if n == 2:
            return True
        if n % 2 == 0:
            return False
        d = int(n ** 0.5) + 1
        for i in range(3, d + 1, 2):
            if n % i == 0:
                return False
        return True


class PriorityQueue:
    def __init__(self, l=[]):
        self.__q = l
        heapq.heapify(self.__q)
        return

    def push(self, n):
        heapq.heappush(self.__q, n)
        return

    def pop(self):
        return heapq.heappop(self.__q)


sys.setrecursionlimit(1000000)
MOD = int(1e09) + 7
INF = int(1e30)


def main():
    # sys.stdin = open("Sample.txt")
    N, K = Scanner.map_int()
    S = defaultdict(int)
    for i in range(N):
        a, b = Scanner.map_int()
        S[a] += b
    n = 0
    for i in range(100001):
        n += S[i]
        if n >= K:
            print(i)
            return
    return


if __name__ == "__main__":
    main()


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

int main()
{
	int N;

	scanf("%d", &N);

	int H[N];
	int flag = 0;

	for(int i = 0;i < N;i++) {
		scanf("%d", &H[i]);
	}

	for(int i = N - 1;i > 0;i--) {
		if(H[i] >= H[i - 1]) {
		} else if(H[i - 1] - H[i] == 1) {
			H[i - 1] -= 1;
		} else {
			flag = 1;
			break;
		}
	}
	
	if(flag == 0) {
		printf("Yes\n");
	} else {
		printf("No\n");		
	}

}

Measured memory_bytes: 512
// https://atcoder.jp/contests/abc173/tasks/abc173_a
#include<bits/stdc++.h>
using namespace std;

int main(int argc, char* argv[]) {
	int n;
	cin >> n;
	if (n%1000) {
		cout << 1000-(n%1000) << endl;
	} else {
		cout << 0 << endl;
	}
	
	return 0;
}


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

using namespace std;
using ll = long long;

ll build(int k, vector<ll> &seg){
    if(seg[k] != -1)return seg[k];
    return seg[k] =  build(2*k,seg) + build(2*k+1, seg);
}

void update(int n, int k, vector<ll>&seg, int x){
    k += n; 
    while(k>=1){
        seg[k]+=x;
        k/=2;
    }
}

ll sum(int n, int l, int r, vector<ll>&seg){
    l+=n;
    r+=n;

    r--;
    ll s = 0;
    while(l<=r){
        if(l&1){s += seg[l];l++;}
        if((r&1)==0){s += seg[r];r--;}

        l/=2;
        r/=2;
    }

    return s;
}




void solve(int q, int n, vector<ll>a){
    vector<ll> tree(2*n,-1);
    
    int idx = n;
    for(ll ai:a){
        tree[idx] = ai;
        idx++;
    }

    build(1,tree);

    int opt, arg1, arg2;
    while(q--){
        cin>>opt>>arg1>>arg2;

        if(opt == 0){
            update(n, arg1, tree, arg2);
            continue;
        }

        if(opt == 1){
            cout<<sum(n, arg1, arg2, tree)<<endl;
            continue;
        }
    }

}

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

    vector<ll>a(n);

    for(ll &ai:a)
        cin>>ai;

    solve(q,n,a);
    return 0;
}

Measured memory_bytes: 19976
n = int(input())
xy = [list(map(int, input().split())) for _ in range(n)]

f0 = [x - y for x, y in xy]
f1 = [x + y for x, y in xy]

f0.sort()
f1.sort()

ans = max((f0[-1] - f0[0]), (f1[-1] - f1[0]))
print(ans)


Measured memory_bytes: 61952
import java.util.*;

public class Main {

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

        String str = sc.next();

        Map<Character, Integer> map = new HashMap<>();
        for (char i = 'a'; i <= 'z'; i++) {
            map.put(i, 0);
        }

        for (char c : str.toCharArray()) {
            map.put(c, map.get(c) + 1);
        }

        Optional<Character> ans = map.entrySet().stream()
                .filter(a -> a.getValue() == 0)
                .map(a -> a.getKey())
                .findFirst();

        if (ans.isPresent()) {
            System.out.println(ans.get());
        } else {
            System.out.println("None");
        }
    }
}


Measured memory_bytes: 29768
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<vector>
#include<map>
using namespace std;
int main() {
    char a,b;
    cin >> a >> b;
    if(a == b) cout << 'H' << endl;
    else cout << 'D' << endl;
    return 0;
}

Measured memory_bytes: 3500
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
  ll n;
  cin>>n;
  ll a[n];
  for(ll i=0;i<n;i++)
    cin>>a[i];
  ll sum=0;
  for(ll i=1;i<n;i++)
  {
       sum+=max(a[i-1]-a[i],(ll)0);
       a[i]=max(a[i],a[i-1]);
  }
  cout<<sum;
}

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

using namespace std;

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

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

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

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

    int n;
    ll m, v, p, a[112345];

    cin >> n >> m >> v >> p;
    REP(i, n)
    cin >> a[i];

    sort(a, a + n);

    int l = -1;
    int r = n - p;

    while (r - l > 1)
    {
        int mid = (r + l) / 2;

        ll aa[112345];

        REP(i, n)
        aa[i] = a[i];

        int fc = 0;

        int i = max(0LL, mid - v + 1);
        while (i <= mid)
            aa[i] += m, fc++, i++;

        i = n - (p - 1);
        while (i < n)
        {
            if (fc < v)
                aa[i] += m, fc++;
            i++;
        }

        ll re = max(0LL, v - fc) * m;

        bool ng = false;

        for (int i = mid + 1; i < n - (p - 1); i++)
        {
            re -= max(0LL, min(m, aa[mid] - aa[i]));
            if (aa[mid] < aa[i])
                ng = true;
        }

        if (ng || (re > 0))
        {
            l = mid;
        }
        else
        {
            r = mid;
        }
    }

    cout << n - r << endl;

    return 0;
}


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

int main(){
int n;
cin>>n;
vector<pair<int, int> > pairs(n);
REP(i,n){
  cin>>pairs[i].first;
  pairs[i].second=i+1;
}
sort(pairs.begin(),pairs.end());
for (int i = 0; i <n; i++)
{
  /* code */
  cout<<pairs[i].second<<" ";
}

}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
template<class t> inline t read(t &x){
	char c=getchar();bool f=0;x=0;
	while(!isdigit(c)) f|=c=='-',c=getchar();
	while(isdigit(c)) x=(x<<1)+(x<<3)+(c^48),c=getchar();
	if(f) x=-x;return x;
}
template<class t> inline void write(t x){
	if(x<0) putchar('-'),write(-x);
	else{if(x>9) write(x/10);putchar('0'+x%10);}
}

#define int long long

const int N=2e5+5;
const int mod=1e9+7;
int n,a[N],ans;

int fpow(int x,int y){
	int res=1;
	for(;y;y>>=1,x=x*x%mod) if(y&1) res=res*x%mod;
	return res;
}

signed main(){
	read(n);
	for(int i=1;i<=n;i++) read(a[i]);
	sort(a+1,a+1+n,greater<int>());
	for(int i=1;i<=n;i++) ans=(ans+a[i]*(i+1)%mod)%mod;
	write(ans*fpow(4,n-1)%mod);
}


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


using namespace std;


int main() {
	int M1, M2, D1, D2;
	cin >> M1 >> D1;
	cin >> M2 >> D2;

	if (M1 == M2) cout << 0 << endl;

	else cout << 1 << endl;

	return 0;
}

	






Measured memory_bytes: 256
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
def gcd(*numbers): reduce(math.gcd, numbers)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7
count = 0
ans = 0

N = i()
a = l()

for i in range(N):
    ans^=a[i]

print("Yes" if ans == 0 else "No")


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

int main()
{
    int a,b;
    while(~scanf("%d %d",&a,&b))
    {
        if(a==2||b==2)
            printf("No\n");
        else if(a==4&&b==6||a==4&&b==9||a==4&&b==11||a==6&&b==9||a==6&&b==11||a==9&&b==11)
            printf("Yes\n");
        else if(a==1&&b==3||a==1&&b==5||a==1&&b==7||a==1&&b==8||a==1&&b==10||a==1&&b==12||a==3&&b==5||a==3&&b==7||a==3&&b==8||a==3&&b==10||a==3&&b==12||a==5&&b==7||a==5&&b==8||a==5&&b==10||a==5&&b==12||a==7&&b==8||a==7&&b==10||a==7&&b==12||a==8&&b==10||a==8&&b==12||a==10&&b==12)
            printf("Yes\n");
        else
            printf("No\n");
    }
    return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
using namespace std;

int main() {
	string str1, str2;
	int i,n,taro=0,hanako=0,j=0,a,b,c;
	cin >> n;
	for (i = 0; i < n; i++) {
		cin >> str1;
		cin >> str2;
		b = str1.length();
		c = str2.length();
		a = min(b, c);
		for (j = 0; j < a; j++) {
			if (int(str1[j]) > int(str2[j])) {
				taro += 3;
				break;
			}
			else if (int(str1[j]) < int(str2[j])) {
				hanako += 3;
				break;
			}
			if (j == (a - 1)) {
				if (str1 == str2) {
					taro += 1;
					hanako += 1;
				}
				else if (str1.length() > str2.length()) {
					taro += 3;
				}
				else if (str1.length() < str2.length()) {
					hanako += 3;
				}
			}
		}
	}
		
	cout << taro << " " << hanako<<endl;
}



Measured memory_bytes: 3152
#include<bits/stdc++.h>
using namespace std;
#define int long long

int n;
struct edge{ int to,cost; };
const int N = 4e5+10;
vector< edge > G[N];

void dikstra(int s){
  typedef pair<int, int> P;
  const int INF = 1 << 30;

  priority_queue<P,vector<P>,greater<P>> que;
  vector<int> d(N,INF); //sからの最短距離
  d[s] = 0;
  que.push({0,s}); //{最短距離,頂点}

  while( !que.empty() ){
    P p = que.top(); que.pop();
    int v = p.second;
    if(d[v] < p.first) continue;
    for(auto e : G[v]){
      if(d[e.to] > d[v] + e.cost){
        d[e.to] = d[v] + e.cost;
        que.push( {d[e.to],e.to} );
      }
    }
  }

  for(int i = 0; i < n; i++){
    cout << d[i] << endl;
  }
}

signed main(){

  cin >> n;
  vector<pair<int,int>> v;
  for(int i = 0; i < n; i++){
    int a; cin >> a;
    v.push_back({a,i});
  }
  sort(v.begin(),v.end());
  for(int i = 0; i < n-1; i++){
    int cost = v[i+1].first - v[i].first;
    G[v[i].second].push_back({v[i+1].second,cost});
    G[v[i+1].second].push_back({v[i].second,cost});
  }

  v.clear();
  for(int i = 0; i < n; i++){
    int b; cin >> b;
    v.push_back({b,i+n});
  }
  sort(v.begin(),v.end());
  for(int i = 0; i < n-1; i++){
    int cost = v[i+1].first - v[i].first;
    G[v[i].second].push_back({v[i+1].second,cost});
    G[v[i+1].second].push_back({v[i].second,cost});
  }

  for(int i = 0; i < n; i++){
    G[i].push_back({i+n,0});
    G[i+n].push_back({i,0});
  }
  dikstra(0);

  return 0;
}



Measured memory_bytes: 38108
#include<iostream>

using namespace std;

bool find(long int A[], int n, int start, int end){
  if(end <= start)
    return false;
  else{
    int mid = (start + end) / 2;
    if(A[mid] == n)
      return true;
    else if(A[mid] > n)
      return find(A, n, start, mid);
    else
      return find(A, n, mid + 1, end);
  }
}

int main(){
  int n, m, q, count = 0;
  cin >> n;
  long int A[n];
  for(int i = 0; i < n; i++)
    cin >> A[i];
  cin >> q;
  while(q--){
    cin >> m;
    if(find(A, m, 0, n))
      count++;
  }
  cout << count << endl;
}

Measured memory_bytes: 1940
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;

int main(){
    int x, y; cin >> x >> y;
    for(int a = 0; a <= x; a++){
        int b = x - a;
        if(b < 0) continue;
        if(a * 2 + 4 * b == y){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 3632
#include "bits/stdc++.h"
using namespace std;

typedef long long ll;
typedef pair<int, int> P;

const int INF = 1000000007;

int main(void){
	int n;
	cin>>n;

	int value = 0;
	bool can = false;
	for(int i=0;i<=n;i++){
		for(int j=0;j<=n;j++){
			value = 4*i + 7*j;
			if(value == n) can = true;
		}
	}

	if(can) printf("Yes\n");
	else printf("No\n");

	return 0;
}

Measured memory_bytes: 256
# coding=utf-8

import sys
stdin = sys.stdin
def na(): return map(int, stdin.readline().split())
def ns(): return stdin.readline().strip()

def main():
    ct = 0
    k,s = na()
    for i in range(0, k+1):
        for j in range(0, k+1):
            if 0 <= s-(i+j) <= k:
                ct += 1
    print(ct)
    pass


if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <string>
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

using namespace std;
using ll = long long;


int main() {
    int n, k;
    cin >> n >> k;
    vector<int> dp(n+1);
    vector<int> h(n+1);

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

    dp[1] = 0;
    for (int i = 2; i <= n; ++i) {
        dp[i]= abs(h[i-1] - h[i]) + dp[i-1];
        for (int l = 1; l <= min(k, i-1); ++l) {
            dp[i] = min(dp[i], abs(h[i-l] - h[i]) + dp[i-l]);
        }
    }

    cout << dp[n] << endl;

    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<queue>
#include<set>
using namespace std;
typedef long long ll;

int main(){
    int n, m, l;
    cin >> n >> m >> l;
    ll mat[n][n];
    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            mat[i][j] = 1ll<<60;
        }
    }
    while(m-- > 0){
        int a, b, c;
        cin >> a >> b >> c;
        a--, b--;
        mat[a][b] = mat[b][a] = c;
    }
    for(int k = 0; k < n; k++){
        for(int i = 0; i < n; i++){
            for(int j = 0; j < n; j++){
                if(mat[i][k] == 1ll<<60 || mat[k][j] == 1ll<<60)  continue;
                mat[i][j] = min(mat[i][j], mat[i][k]+mat[k][j]);
            }
        }
    }
    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            if(mat[i][j] <= l)    mat[i][j] = 1;
            else                  mat[i][j] = 1ll<<60;
        }
    }
    for(int k = 0; k < n; k++){
        for(int i = 0; i < n; i++){
            for(int j = 0; j < n; j++){
                mat[i][j] = min(mat[i][j], mat[i][k]+mat[k][j]);
            }
        }
    }
    int q;
    cin >> q;
    while(q-- > 0){
        int s, t;
        cin >> s >> t;
        s--, t--;
        cout << (mat[s][t] == 1ll<<60 ? -1 : mat[s][t]-1) << endl;
    }
    return 0;
}


Measured memory_bytes: 1280
#include<iostream>
#include<utility>
#include<queue>
#include<vector>
#include<string>

using namespace std;
char A[801][801];
int reach[801][801];
struct P
{
	int i;
	int j;
	int n;
	P(int i, int j, int n) {
		this->i = i;
		this->j = j;
		this->n = n;
	}
};
int main() {

	int h, w, k;
	cin >> h >> w >> k;
	string s;
	int si, sj;
	for (int i = 0; i < h; i++) {
		cin >> s;
		for (int j = 0; j < w; j++) {
			A[i][j] = s[j];
			if (s[j] == 'S') {
				si = i;
				sj = j;
			}
		}
	}
	
	queue<P> que;
	que.push(P(si, sj,0)); 
	reach[si][sj] = 1;
	int di[4] = { 0,0,1,-1 };
	int dj[4] = { 1,-1 ,0,0};

	while (!que.empty()) {
		P p = que.front(); que.pop();
		int i = p.i;
		int j = p.j;
		int n = p.n;
		int nn = n + 1;
		if (i == 0 || j == 0 || i == h - 1 || j == w - 1 ) {
			cout << 1 << endl;
			return 0;
		}
		if (nn > k)continue;
		for (int k = 0; k < 4; k++) {
			int ni = i + di[k];
			int nj = j + dj[k];
			if (ni >= 0 && ni < h&&nj >= 0 && nj < w&&reach[ni][nj] != 1 && A[ni][nj] == '.') {
				reach[ni][nj] = 1;
				que.push(P(ni, nj,nn));
			}
		}
	}
	int ans = w + k;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (reach[i][j] == 1) {
				ans = min(ans, i );
				ans = min(ans, j );

				ans = min(ans, h-i-1);
				ans = min(ans, w-j-1);
			}
		}
	}
	//for (int i = 0; i < h; i++) {
	//	for (int j = 0; j < w; j++) {
	//		cout << reach[i][j];
	//	}
	//	cout << endl;
	//}
	cout <<(k-1+ ans) / k +1<< endl;

}

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

long long arr[200200], sum[200200];
long long n, ans = 0x7ffffffffffffffLL;

int main() {
	scanf("%lld", &n);
	for (int i = 1; i <= n; i++) {
		scanf("%lld", &arr[i]);
		sum[i] = sum[i - 1] + arr[i];
	}
	for (int i = 2; i <= n; i++) {
		ans = min(ans, abs((sum[i - 1] << 1) - sum[n]));
	}
	printf("%lld", ans);
} 

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

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);

    int n;
    cin >> n;


    vector<int> comb(n + 1,0);
    vector<int> a(n);
    map<int,int> mp;
    rep(i,n) {
        cin >> a[i];
        mp[a[i]]++;
    }

    for(auto i : mp){
        int itr = i.first;
        int x = i.second;

        int C = x * (x - 1) / 2;
        comb[itr] =  C;
    }

    int sum = 0;
    for(int i = 0; i < n + 1; i++){
        sum += comb[i];
    }

    for(int i = 0; i < n; i++){
        int ans = sum;
        int x = mp[a[i]];
        ans -= (x * (x - 1) / 2);
        ans += ((x - 1) * (x - 2) / 2);
        cout << ans << endl;
    }
}

Measured memory_bytes: 12672
/**
 * File    : A.cpp
 * Author  : Kazune Takahashi
 * Created : 2018-11-2 12:23:14
 * Powered by Visual Studio Code
 */

#include <iostream>
#include <iomanip>   // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple>
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set>
#include <functional>
#include <random> // auto rd = bind(uniform_int_distribution<int>(0, 9), mt19937(19920725));
#include <chrono> // std::chrono::system_clock::time_point start_time, end_time;
// start = std::chrono::system_clock::now();
// double elapsed = std::chrono::duration_cast<std::chrono::milliseconds>(end_time-start_time).count();
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;

#define DEBUG 0 // change 0 -> 1 if we need debug.

typedef long long ll;

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

// const int C = 1e6+10;
// const ll M = 1000000007;

int main()
{
  string S;
  cin >> S;
  int ans = 0;
  for (auto i = 0; i < (int)S.size(); i++)
  {
    if (S[i] == '+')
    {
      ans++;
    }
    else
    {
      ans--;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
from itertools import product

d, g = map(int, input().split())
g //= 100
p, c = [], []
for _ in range(d):
    i, j = map(int, input().split())
    p.append(i)
    c.append(j // 100)

# full search about complete bonuses
ans = sum(p)
for tf in product([True, False], repeat=d):
    score = 0
    cnt = 0

    for ind in range(d):
        if tf[ind]:
            cnt += p[ind]
            score += (ind + 1) * p[ind] + c[ind]
    
    for ind in range(d-1, -1, -1):
        if score >= g:
            break

        if tf[ind]:
            continue
        
        if (ind + 1) * p[ind] + score <= g:
            cnt += p[ind]
            score += (ind + 1) * p[ind]
        else:
            cnt += (g - score - 1) // (ind + 1) + 1
            score = g
    
    if score >= g and ans > cnt:
        ans = cnt

print(ans)


Measured memory_bytes: 9144