akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <numeric>

using namespace std;

#define int long long
typedef long double ld;
#define pii pair<int, int>
#define vi vector<int>
#define vii vector<vi>
#define viii vector<vii>
#define vpii vector<pii>
#define vb vector<bool>
#define vbb vector<vb>
#define vs vector<string>
#define pb push_back
#define ff first
#define ss second
#define all(a) a.begin(), a.end()
#define in(a, x) for (int i = x; i < (a).size(); ++i) cin >> (a)[i]
#define out(a) for (auto qwe : a) cout << qwe << " "

const int INF = 1e9;
const int INF64 = 1e18;
const int MOD = 1e9 + 7;
const int MOD9 = 1e9 + 9;
const int MOD3 = 998244353;
const int P = 37;

const int mxn = 200000;

vii mult(vii* a, vii* b) {
    int n = a->size();

    vii c(n, vi(n, 0));

    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            for (int k = 0; k < n; ++k) {
                c[i][j] += a->at(i)[k] * b->at(k)[j];
                c[i][j] %= MOD;
            }
        }
    }

    return c;
}

vii poww(vii a, int n) {
    if (n == 1) return a;

    if (n % 2 == 0) {
        vii c = poww(a, n / 2);
        return mult(&c, &c);
    } else {
        vii c = poww(a, n - 1);
        return mult(&a, &c);
    }
}

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

    int n, k;
    cin >> n >> k;

    vii a(n, vi(n));
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            cin >> a[i][j];
        }
    }

    vii x = poww(a, k);

    int answ = 0;

    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            answ += x[i][j];
            answ %= MOD;
        }
    }

    cout << answ;
}

Measured memory_bytes: 2816
#include <bits/stdc++.h>
using namespace std;
int main(void){
    long long mod = 1000000007;
    long long N,K;
    cin >> N >> K;
    long long count = 0;
    for (long long k = K; k <= N+1; k++){
        count += N * k - k*k + k + 1;
        count = count % mod;
    }
    printf("%lld\n",count);
    
}

Measured memory_bytes: 3764
#include <bits/stdc++.h>
using namespace std;
int main(){
  int A,B,C,X;
  int count = 0;
  cin >> A >> B >> C >> X;
  for (int i = 0; i <= A; ++i){
    for (int j = 0; j <= B; ++j){
      for (int k = 0; k <= C; ++k){
        if (X == 500 * i + 100 * j + 50 * k) count++;
      }
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<unistd.h>
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define ST first
#define ND second
#define ll long long
#define ld long double
using namespace std;
using namespace __gnu_pbds;
 
// replace ll with pair if multiset needed
typedef tree<int, null_type, greater<int >, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
ordered_set secik;
 
const ll INF = 1e9 + 9;
const ll MOD = 1e9 + 7;
const long long LINF = (ll)1e18 + 3;
 
// secik.insert({x, t++});
// secik.erase(secik.lower_bound({x,-1}));
// *secik.find_by_order(x)).first << "\n";
// secik.order_of_key(x)
 
//random_device device;
//mt19937 gener(device());
//uniform_int_distribution<int> gen(0,n-1);

const int SIZE = 2e5 + 5;

long long dp[300][SIZE];
long long pref[SIZE];

int main(){
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	
	int n,k; cin >> n >> k;
	vector<int> tab(n);
	for(int i = 0; i < n; i++){
		cin >> tab[i];
	}

	for(int i = 0; i <= tab[0]; i++){
		dp[0][i] = 1;
	}
	pref[0] = dp[0][0];
	for(int i = 1; i <= k; i++){
		pref[i] = pref[i-1] + dp[0][i];
	}
	//cout << pref[k] << endl;
	for(int i = 1; i < n; i++){
		for(int j = 0; j <= k; j++){
			long long subtract = 0;
			if(j - tab[i] - 1 >= 0) subtract = pref[j - tab[i] - 1];
			dp[i][j] = (pref[j] - subtract) % MOD;
		}
		pref[0] = dp[i][0];
		for(int j = 1; j <= k; j++){
			pref[j] = pref[j-1] + dp[i][j];
		}
	}

	cout << dp[n-1][k];
}

Measured memory_bytes: 157184
#include<bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
int read(){
	int w=0,f=1;
	char c=' ';
	while(c<'0'||c>'9')c=getchar(),f=c=='-'?-1:f;
	while(c>='0'&&c<='9')w=w*10+c-48,c=getchar();
	return w*f;
}
int n;
int a[N], b[N];
int ca[N], cb[N];
signed main(){
	n = read();
	for(int i = 1; i <= n; i++) a[i] = read(), ca[a[i]]++;
	for(int i = 1; i <= n; i++) b[i] = read(), cb[b[i]]++;
	for(int i = 1; i <= n; i++) if(ca[i] + cb[i] > n) return printf("No\n"), 0;
	reverse(b + 1, b + n + 1);
	vector<int> t;
	int cnt = 0, val = 0, len = 0;
	for(int i = 1; i <= n; i++)
	{
		if(b[i] == a[i])
		{
			cnt++;
			val = b[i];
			t.push_back(i);
		}
	}
	len = cnt;
	vector<int> s;
	for(int i = 1; i <= n; i++)
	{
	 if(a[i] == b[i]) continue;
	 if(cnt == 0) break;
	 if(a[i] != val && b[i] != val)
	 {
	 	s.push_back(i);
	 	cnt--;
	 }		
	}
	for(int i = 0; i < len; i++)
	{
		swap(b[s[i]], b[t[i]]);
	}
	printf("Yes\n");
	for(int i = 1; i <= n; i++) printf("%d ", b[i]);
	printf("\n");
	return 0;
}


Measured memory_bytes: 7292
#include<iostream>2
#include<vector>
#include<string>
#include<algorithm>
#include<queue>
#include<climits>
#include<set>
#include<cmath>
#define ll long long
using namespace std;

int main() {
	ll n, l;
	cin >> n >> l;
	vector<string>s(n);
	for (ll i = 0; i < n; i++) {
		cin >> s[i];
		//sort(s[i].begin(), s[i].end());
	}
	sort(s.begin(),s.end());
	for (ll i = 0; i < s.size(); i++) {
		cout << s[i];
	}
	cout << endl;
	

}

Measured memory_bytes: 256
//int a = stoi(c); 文字列をintへ
//小文字から大文字
//transform(a.begin(), a.end(), a.begin(), ::toupper);
//数値計算 個数以外はdouble
//map<キー,値> p は辞書。p[キー] = 値
//map 全探索
//auto begin = p.begin(), end = p.end();
//for (auto it = begin; it != end; it++) {}
//mapのキー：it->first mapのバリュー：it->second
//大文字判定 isupper(文字) 小文字判定 islower(文字)
//do{}while(next_permutation(ALL(配列)))
//小文字に対応する文字コード：S[i] - 'a'
//文字コード→小文字：(char)(数字+'a')
//グラフの距離:隣接行列で扱う
//bool型　初期値はTrue
//島渡りの問題：中間ノードに着目
//背反な事象にちゃんとわける
//チェックリストはマップを使う
//数が大きい時の比較はstring型で行う
//全て0になったか調べたい->0になるたびにcntする
//例外処理は最初にする
//x = p^m + q^n...の約数の個数:(n+1)*(m+1)....
//N!のどの素因数で何回割れるか
//⇔1~Nまでの数がそれぞれどの素因数で何回割り切れるかの和
//パズルの問題->一般化して全探索
//数が大きい時のせぐふぉはコードテストで試してみる
//stack<ll> s;
//s.push(要素);s.top();s.pop();
//queue<ll> q;
//q.push(要素);q.front();q.pop();
//同じ作業繰り返す系の問題：収束先を見つける
//関係性は隣接行列で記録
//過半数：N/2.0で判定
//ある量からある量を引く系の問題：端から定義してやる
#include <bits/stdc++.h>
#define rep(i,N) for(int i = 0; i < N;i++)
#define ALL(a) (a).begin(),(a).end()
#define ll long long int
using namespace std;

//円周率
const double PI = 3.14159265358979323846;
//割るやつ
const ll MOD = (pow(10, 9) + 7);

// K進数でのNの桁数
ll dig(ll N, ll K) {
	ll dig = 0;
	while (N) {
		dig++;
		N /= K;
	}
	return dig;
}
// a,bの最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}

//a,bの最小公倍数
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}

//階乗計算
ll f(ll n) {
	if (n == 0 || n == 1) return 1;
	else return (n * f(n - 1));
}

//Nのd桁目の数
ll dignum(ll N, ll d) {
	ll x = pow(10, d);
	N %= x;
	ll y = pow(10, d - 1);
	N /= y;
	return N;
}

//Nをdで何回割れるか
ll divcnt(ll N, ll d) {
	ll ans = 0;
	while (1) {
		if (N%d == 0) {
			ans++;
			N /= d;
		}
		else break;
	}

	return ans;
}

//素数判定
bool prime(ll num) {
	if (num < 2) return false;
	else if (num == 2) return true;
	else if (num % 2 == 0) return false;
	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2) {
		if (num % i == 0) return false;
	}
	return true;
}

//フィボナッチ数列
vector<ll> memo(pow(10, 6) + 1);
ll fibo(ll n) {
	if (n == 1) return 1;
	else if (n == 2) return 1;
	else if (memo[n] != 0) return memo[n];
	else return memo[n] = fibo(n - 1) + f(n - 2);
}

int main() {
	string S; cin >> S;

	if (S == "ABC") cout << "ARC" << endl;
	else cout << "ABC" << endl;
}

Measured memory_bytes: 11012
#include<bits/stdc++.h>
#define FF first.first
#define FS first.second
#define SF second.first
#define SS second.second
#define LL long long 
using namespace std;
typedef pair<LL,int>P1;
typedef pair<bool,LL>P2;
typedef pair<P1,P2>PP;
PP pp[100001];
int main(void){
	int n;
	LL t;
	int q;
	int vip[1001];
	int i,j;
	cin>>n>>t>>q;
	for(i=0;i<n;i++){
		cin>>pp[i].FF>>pp[i].FS;
		pp[i].SF=false;
		pp[i].SS=0;
	}
	for(i=0;i<q;i++){
		cin>>vip[i];
		vip[i]--;
	}
	for(i=0;i<n-1;i++){
		if(pp[i].FS<pp[i+1].FS){
			//cout<<pp[i].FF<<" "<<pp[i+1].FF<<endl;
			LL sa=(pp[i].FF+pp[i+1].FF)/2;
			//cout<<sa<<endl;
			if(sa<pp[i].FF+t){
				pp[i].SF=true;
				pp[i].SS=sa;
				pp[i+1].SF=true;
				pp[i+1].SS=sa;
			}
		}
	}
	for(i=0;i<q;i++){
		//cout<<"PPVIP="<<pp[vip[i]].FF<<endl;
		//cout<<"PPFSVIP="<<pp[vip[i]].FS<<endl;
		LL x=pp[vip[i]].FF;
		//cout<<pp[vip[i]].SS<<endl;
		if(!pp[vip[i]].SF){
			if(pp[vip[i]].FS==2){
				j=vip[i]-1;
				while(1){
					if(pp[j].SF){
			//			cout<<"X-T="<<x-t<<pp[j].SS<<endl;
						if(x-t<pp[j].SS){
							//pp[vip[i]].SS=x-t;
							pp[vip[i]].SS=pp[j].SS;
						}
						else{
							//pp[vip[i]].SS=pp[j].SS;
							pp[vip[i]].SS=x-t;
						}
						break;
					}
					if(j<0)	{
						pp[vip[i]].SS=x-t;
						break;
					}
					
					j--;
				}
			}
			else{
				j=vip[i];
				while(1){
					if(pp[j].SF){
				//		cout<<"X+T="<<x+t<<" "<<pp[j].SS<<endl;
						if(x+t>pp[j].SS){
							pp[vip[i]].SS=pp[j].SS;
						}
						else{
							pp[vip[i]].SS=x+t;
						}
						break;
					}
					if(j==n){
						pp[vip[i]].SS=x+t;
						break;
					}
					j++;
				}
			}
		}
	}
		
		/*for(j=0;j<n;j++){
			
			if(pp[j].SF){
				cout<<"j="<<j<<endl;
				cout<<"PPFSVIP="<<pp[vip[i]].FS<<endl;
				
					cout<<"X-T="<<x-t<<pp[j].SS<<endl;
					if(x-t<pp[j].SS&&(x-t>=0&&pp[j].SS>=0)||(x-t<0&&pp[j].SS<0)){
						pp[vip[i]].SS=pp[j].SS;
					}
					else{
						pp[vip[i]].SS=x-t;
					}
				}
				else{
					cout<<"X+T="<<x+t<<" "<<pp[j].SS<<endl;
					if(x+t>pp[j].SS&&(x+t>=0&&pp[j].SS>=0)||(x+t<0&&pp[j].SS<0)){
						pp[vip[i]].SS=pp[j].SS;
					}
					else{
						pp[vip[i]].SS=x+t;
					}
				}
			}
		}
	}*/
	
	for(i=0;i<q;i++){
		cout<<pp[vip[i]].SS<<endl;
	}
	return 0;
}
			
						
					
		


Measured memory_bytes: 6220
N=int(input())
D = [0] * N
DD = [0] * N
for i in range(N):
    D[i], DD[i] = map(int, input().split())
for k in range (N-2):
    if D[k]==DD[k] and D[k+1]==DD[k+1] and D[k+2]==DD[k+2]:
        print ("Yes")
        exit()
print("No")

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

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	string s, t;
	cin >> s >> t;
	int n = s.size(), m = t.size();
	int ans = m;

	for(int i = 0; i <= n-m; i++) {
		int get = 0;
		for(int j = 0; j < m; j++) {
			if(s[i+j] != t[j])
				get++;
		}
		ans = min(ans, get);
	}
	cout << ans << '\n';
}


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

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) cin >> A.at(i);
  
  vector<int> B(N),C(N),ans(N);
  
  for (int i = 0; i < N; i++) {
    if (i == 0) {
      B.at(i) = abs(A.at(i));
      C.at(N-1-i) = abs(A.at(N-1-i));
    } else {
      B.at(i) = B.at(i-1) + abs(A.at(i) - A.at(i-1));
      C.at(N-1-i) = C.at(N-i) + abs(A.at(N-1-i) - A.at(N-i));
    }
  }
  
  for (int i = 0; i < N; i++) {
    if (i == 0) {
      ans.at(i) = abs(A.at(i+1)) + C.at(i+1);
    } else if (i == N-1) {
      ans.at(i) = B.at(i-1) + abs(A.at(i-1));
    } else {
      ans.at(i) = B.at(i-1) + abs(A.at(i-1)-A.at(i+1)) + C.at(i+1);
    }
  }
  
  for (int i = 0; i < N; i++) cout << ans.at(i) << endl;
}

Measured memory_bytes: 2816
n=int(input())
a=list(map(int,input().split()))
a.sort(reverse=1)
p=0
ans=1
c=0
for x in a:
  q=x
  if p==q:
    ans*=p
    p,q=0,0
    c+=1
    if c==2:
      print(ans)
      exit()
  else:
    p=q
print(0)

Measured memory_bytes: 14224
import std.stdio, std.string, std.conv;
import std.range, std.algorithm;

void main() {
    int a,b;
    scan(a,b);

    writeln(a*b % 2 ? "Odd" : "Even");
}



void scan(T...)(ref T args) {
    string[] line = readln.split;
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}



void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

Measured memory_bytes: 256
import sys

input = sys.stdin.readline


def is_palindrome(s):
    n = len(s)
    for i in range(n // 2):
        if s[i] != s[n - i - 1]:
            return False
    return True


def main():
    s = input().strip()
    n = len(s)
    if is_palindrome(s) and is_palindrome(s[0:(n - 1) // 2]) and is_palindrome(s[((n + 3) // 2) - 1:n]):
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MM = 1000000000;
const int MOD = MM + 7;
const int MAX = 510000;
#define rep(i, n) for(ll i=0; i<n; i++)
#define Rep(i, j, n) for(ll i=j; i<n; i++)
#define all(vec) vec.begin(), vec.end()
template<class T> inline bool chmin(T& a, T b) {if(a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if(a < b) {a = b; return true;} return false;}
const ll INF = 1LL << 60;

int main() {
    int n; cin >> n;
    n %= 10;
    if(n == 3) cout << "bon" << endl;
    else if(n == 0 || n == 1 || n == 6 || n == 8) cout << "pon" << endl;
    else cout << "hon" << endl;
}


Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
#define ld long double
#define mod 1000000007
#define endl "\n"
#define pb push_back
#define mp make_pair

ll ans(ll x)
{
    if(x==1)
    {
        return 1;
    }
    
    return 1+2*ans(x/2);
}


int main()
{
    ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n;
    cin>>n;
    cout<<ans(n);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int n;
int main() {
    cin >> n;
    int best = 0;
    int ans = 0;
    for (int i = 0; i < n; i++) {
        int height;
        cin >> height;
        if (height >= best) {
            best = height;
            ++ans;
        }
    }
    cout << ans;
}

Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
#include <set>
using namespace std;

int main(){
   int n; cin>>n;
   vector<int> a(n-1);
   for(int i=0;i<n-1;i++) cin>>a[i];
   vector<int> ans(n);
   for(int i=0;i<n-1;i++) ans[a[i]-1]++;
   for(int i=0;i<n;i++) cout<<ans[i]<<endl;
   return 0;
}

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

using namespace std;

int main(){
    int M, T, P, R;
    while( true ){
        cin >> M >> T >> P >> R;
        
        if( M == 0 )
            break;
        
        vector<int> tans(T, 0);
        vector<int> ttime(T, 0);
        vector<int> pen(T * P, 0);
        
        int m, t, p, j;
        for(int i = 0; i < R; i++){
            
            cin >> m >> t >> p >> j;
            
            if(j == 0){
                tans[t-1] += 1;
                ttime[t-1] += m;
                ttime[t-1] += pen[(t-1)*P+p-1];
            }
            else{
                pen[(t-1)*P+p-1] += 20;
            }
        }
        
        vector<int> tscore(T, 0);
        vector<int> tss(T, 0);
        for(int i = 0; i < T; i++){
            tscore[i] = tans[i] * 50000 - ttime[i];
        }
        
        vector<int> trank(T);
        
        tss = tscore;
        sort( tss.begin(), tss.end() );
        tss.erase( unique( tss.begin(), tss.end() ), tss.end() );
        for(int i = 0; i < T; i++){
            trank[i] = find( tss.begin(), tss.end(), tscore[i] ) - tss.begin();
        }
        bool Fl = true;
        for(int i = T - 1; i >= 0; i--){
            bool flag = true;
            for(int j = T - 1; j >= 0; j--){
                if(trank[j] == i){
                    if(flag){
                        if(Fl){
                            cout << j + 1;
                            Fl = false;
                        }
                        else
                            cout << "," << j + 1;
                        flag = false;
                    }
                    else{
                        cout << "=" << j + 1;
                    }
                }
            }
        }
        cout <<endl;
        
    }
}

Measured memory_bytes: 3128
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>

#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;

int min3(int i, int j, int k)
{
    if(i<j){
        if(j<k){
            return i;
        }else{
            if(i<k){
                return i;
            }else{
                return k;
            }
        }
    }else if(j<k){
        return j;
    }else{
        return k;
    }
}

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


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

    //cout<<gcd(gcd(n,10),20)<<endl;

    ll sum=0;
    int last_min = 0;
    int ret_gcd=0;

    for (int i=1; i<= n; ++i){
        for (int j=1; j<= n; ++j){
            for (int k=1; k<= n; ++k){
                /*
                if(last_min < min3(i,j,k)){ //min更新
                    last_min = min3(i,j,k);
                    ret_gcd = gcd(gcd(i,j), k); //真gcdの計算
                }*/
                //sum += ret_gcd;
                sum += gcd(gcd(i,j), k);
            }
        }
    }
    cout<<sum<<endl;

} // end of main

//実行は、Opt + Ctl + N

Measured memory_bytes: 3632
#include <algorithm>
#include <bitset>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define MOD (1000000007l)
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)

using namespace std;

void solve() {
  ll N, K;
  cin >> N >> K;
  vector<ll> p(N);
  rep (i, N) cin >> p[i];

  vector<ll> acc(N+1, 0);
  rep (i, N) acc[i+1] = acc[i] + p[i];

  double ans = 0;

  for (ll i = 0; i + K < N+1; i++) {
    double tmp = acc[i+K] - acc[i];
    ans = max(ans, tmp);
  }

  ans += K;
  ans /= 2;

  cout << ans << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  cout << fixed;
  solve();
  return 0;
}


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

int main() {
  int a, b;
  int k = 0;
  cin >> a >> b;
  for (int i=0; i<2; i++){
    if (a >= b) {
      k += a;
      a = a-1;
    }
    else {
      k += b;
      b = b-1;
    }
  }
  
  cout << k << endl;
  
}

Measured memory_bytes: 256
use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;
use std::{vec, cmp, num};


struct Scanner<'a> {
    cin: StdinLock<'a>,
}

impl<'a> Scanner<'a> {
    fn new(cin: StdinLock<'a>) -> Scanner<'a> {
        Scanner {cin: cin}
    }

    fn read1<T: FromStr>(&mut self) -> Option<T> {
        let token = self.cin.by_ref().bytes().map(|c| c.unwrap() as char)
                    .skip_while(|c| c.is_whitespace())
                    .take_while(|c| !c.is_whitespace())
                    .collect::<String>();
        token.parse::<T>().ok()
    }

    fn read<T: FromStr>(&mut self) -> T {
        self.read1().unwrap()
    }
}

// create Vec<char> from String
#[allow(dead_code)]
fn to_chars(s: String) -> vec::Vec<char> {
    let mut cs = s.chars();
    let mut res = vec::Vec::new();
    while let Some(c) = cs.next() {
        res.push(c);
    }
    res
}

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);
    let a: i32 = sc.read();
    let b: i32 = sc.read();
    let c: i32 = sc.read();
    if b - a == c - b {
        println!("YES");
    } else {
        println!("NO");
    }
}

Measured memory_bytes: 4352
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef map<int, int> mii;
typedef map<char,int> mci;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<pair<int,int>> vii;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define in insert
#define sz(v) v.size()
#define mina(a,b) (a)=min((a),(b));
#define maxa(a,b) (a)=max((a),(b));
const ll INF = 1e18 + 5;

void solve(){
    int n,l; cin>>n>>l;
    vi v(n+1);
    int nearest=10000000;
    for(int i=1;i<=n;i++){
        v[i]=l+i-1;
        if(abs(nearest)>abs(v[i])) nearest=v[i];
    }
    int sum=0;
    bool con=true;
    for(int i = 1; i <= n; i++){
        if(v[i]==nearest && con){
            con=false;
            continue;
        }
        sum+=v[i];
    }
    cout<<sum;
}
int main(){
    int T=1;        //! COMMENT IF THERE IS NO TEST CASES
    //cin>>T;             
    for(int i = 0; i < T; i++) solve(); 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define endl "\n"
#define se second
#define ls( s) (s&(-s))
#define ll long long
#define inf 0x3f3f3f3f
#define fast    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const ll N = 300030;
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
const ll mod =    1e9+7;
ll a1[N],a2[N];
ll n;
ll arr[N];
int main()
{  fast
priority_queue<ll> p,q;
cin>>n;
for(int i=1;i<=3*n;i++)
cin>>arr[i];
ll suma=0,sumb=0;
for(int i=1;i<=n;i++)
{
	suma+=arr[i];
	p.push(-arr[i]);
}
a1[n]=suma;
for(ll i=3*n;i>2*n;i--)
{
	sumb+=arr[i];
	q.push(arr[i]);
}
a2[2*n]=sumb;
for(int i=n+1;i<=2*n;i++)
{
	suma+=arr[i];
	p.push(-arr[i]);
	suma+=p.top();
	p.pop();
	sumb+=arr[2*n-i+1+n];
	q.push(arr[3*n-i+1]);
	sumb-=q.top();
	q.pop();
	a1[i]=suma;
	a2[3*n-i]=sumb;
}
ll ans=a1[n]-a2[n];

for(int i=n+1;i<=2*n;i++)
ans=max(ans,a1[i]-a2[i]);
cout<<ans;
}


Measured memory_bytes: 8692
import sys

for line in sys.stdin:
    m, f, r = map(int, line.split())
    if m == f == r == -1:
        break
    if m == -1 or f == -1:
        print('F')
    elif (m + f) >= 80:
        print('A')
    elif (m + f) >= 65:
        print('B')
    elif (m + f) >= 50:
        print('C')
    elif (m + f) >= 30:
        if r >= 50:
            print('C')
        else:
            print('D')
    else:
        print('F')

Measured memory_bytes: 6728
import math


def gcd(a, b):
    a, b = max(a, b), min(a, b)
    if b == 0:
        return a
    return gcd(b, a % b)


def main():
    A, B = map(int, input().split())
    g = gcd(A, B)
    rt = int(math.sqrt(g))
    ans = set([1])
    for x in range(2, rt+1):
        if g % x == 0:
            ans.add(x)
            while g % x == 0:
                g //= x
    if g != 1:
        ans.add(g)
    print(len(ans))


if __name__ == "__main__":
    main()


Measured memory_bytes: 38512
// learned from semiexp (https://atcoder.jp/contests/arc058/submissions/816918)
// L = sum(s[i])
// O(K(log26 * L + N)) with bitset
#include<bits/stdc++.h>
#define maxn 2005
#define maxl 1000005
using namespace std;
string s[maxn];
bool dp[maxn][10005];
int st[maxn];
bitset<maxl> state;
int m;
bitset<maxl> seg[70];
char query() {
	int p = 1;
	while(p < m) {
		if((state & seg[p<<1]).none())
			p = p<<1|1;
		else
			p = p<<1;
	}
	return 'a' + p - m;
}
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n,k;
	cin >> n >> k;
	for(int i=1;i<=n;i++)
		cin >> s[i];
		
	dp[n+1][0] = true;
	for(int i=n;i>=1;i--) {
		for(int j=0;j<=k;j++)
			dp[i][j] = dp[i+1][j];
		for(int j=(int)s[i].size();j<=k;j++)
			dp[i][j] |= dp[i+1][j-(int)s[i].size()];
	}
	
	string tem = "";
	
	m = 32;
	for(int i=1;i<=n;i++) {
		st[i] = (int)tem.size();
		state[st[i]] = true;
		for(char c : s[i]) {
			seg[c - 'a' + m][(int)tem.size()] = true;
			tem += c;
		}
	}
	for(int i=m-1;i;i--)
		seg[i] = seg[i<<1] | seg[i<<1|1];
	
	string ans = "";
	for(int i=1;i<=k;i++) {
		for(int j=1;j<=n;j++)
			if(i + (int)s[j].size() - 1 > k || !dp[j+1][k - (i + (int)s[j].size() - 1)])
				state[st[j]] = false;
		
		char c = query();
		ans += c;
		
		state &= seg[c - 'a' + m];
		state <<= 1;

		for(int j=1;j<n;j++)
			if(state[st[j]])
				state[st[j+1]] = true;
	}
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 30852
// UNNECESSARY
// #include <chrono>//std::chrono::/system_clock/steady_clock/high_resolution_clock/duration
// #include <cstdio>//printf/scanf/fopen/fclose/fprintf/fscanf/snprintf/putc/puts/getc/gets
// #include <fstream>//ifstream/ofstream

// DATA STRUCTURES
#include <array>
#include <bitset>
#include <list>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <valarray>
#include <vector>

// MISCELLANEOUS
#include <algorithm>//min/max/sort(rand-access it)/merge
#include <cassert>
#include <climits>//INT_MAX/INT_MIN/ULLONG_MAX
#include <cmath>//fmin/fmax/fabs/sin(h)/cos(h)/tan(h)/exp/log/pow/sqrt/cbrt/ceil/floor/round/trunc
#include <cstdlib>//abs/atof/atoi/atol/atoll/strtod/strtof/..., srand/rand, calloc/malloc, exit, qsort
#include <iomanip>//setfill/setw/setprecision/fixed/scientific
#include <iostream>//cin/cout/wcin/wcout/left/right/internal/dec/hex/oct/fixed/scientific
#include <iterator>
#include <limits>//numeric_limits<type>::max/min/lowest/epsilon/infinity/quiet_NaN/signaling_NaN
#include <new>
#include <string>//stoi/stol/stoul/stoll/stoull/stof/stod/stold/to_string/getline
#include <utility>//pair

#ifndef REP
#define REP(i,n) for (int i = 0; i < n; ++i)
#endif

#ifndef REPST
#define REPST(i,n) for (size_t i = 0; i < n; ++i)
#endif

#ifndef READ
#define READ(x) std::cin >> x
#endif

typedef unsigned int ui;
typedef long long ll;
typedef unsigned long long ull;
typedef std::pair<int, int> pii;
typedef std::pair<ll, int> plli;
typedef std::pair<ull, int> puli;
typedef std::pair<double, int> pdi;
typedef std::pair<ll, ll> pllll;
typedef std::pair<ull, ull> pulul;
typedef std::pair<double, double> pdd;
typedef std::tuple<int, int, int> ti3;
typedef std::tuple<int, int, int, int> ti4;

const bool debug = true;

// --------------------------------------------------------------------------------------

using namespace std;

int main(void)
{
    ui n;
    ll k;
    cin >> n >> k;
    vector<pii> v;
    REP(i,n) {
        int a, b;
        cin >> a >> b;
        v.emplace_back(a, b);
    }
    sort(v.begin(), v.end());
    {
        int i = 0;
        while (k > 0) {
            k -= v[i].second;
            ++i;
        }
        cout << v[--i].first << '\n';
    }

    return 0;
}


Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;	
typedef long long ll;
typedef long double ld;
typedef complex<ld> pt;
#define X real()
#define Y imag()
void pin(pt& p){
	ld x,y; 
	cin>>x>>y; 
	p={x,y};
}
ostream& operator<<(ostream& os, pt p){
	return os<<p.X<<" "<<p.Y<<endl;
} 
ld dot(pt p,pt q){
	return (conj(p)*q).X;
}
pt solve(pt p,pt q,pt x){
	ld l = dot((q-p),(x-p))/abs(q-p);
	pt on = l*(q-p)/abs(q-p);
	pt prj = p+on;	
	return (prj+(prj-x));
}
int main (){
	cout<<fixed<<setprecision(12);
	pt p,q,x;
	pin(p);
	pin(q);
	int t; 
	cin>>t;
	while(t--){
		pin(x);
		cout<<solve(p,q,x); 
	}
	return 0;
}



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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)

#define DEBUG(x) cout<<#x<<": "<<x<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

#define CHMIN(a, b) a=min((a), (b))
#define CHMAX(a, b) a=max((a), (b))

const ll MOD=1000000007ll;
// const ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

string s;
int y, m, d;

bool solve(){
	if(y<2019){
		return true;
	}
	if(y>2019){
		return false;
	}
	if(m<=4){
		return true;
	}
	return false;
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	string s;
	cin>>s;
	y=stoi(s.substr(0, 4));
	m=stoi(s.substr(5, 2));
	d=stoi(s.substr(8, 2));
	bool ok=solve();
	cout<<(ok ? "Heisei" : "TBD")<<'\n';
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast")
#define ll long long
#define ull unsigned long long
#define LLMax LLONG_MAX
#define LLMin LLONG_MIN
#define Max INT_MAX
#define Min INT_MIN
#define FOR1(i,a,b) for(int i=(a);i<(b);i++)
#define FOR2(i,a,b) for(int i=(a);i<=(b);i++)
#define DWN(j,b,a) for(int j=(b);j>=(a);j--) 
#define SET0(a) memset(a,0,sizeof(a))
#define SETN1(a) memset(a,-1,sizeof(a))
#define IOS ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
//#define int long long
const int INF=0x3f3f3f3f;
const int NINF=-INF-1;
const double PI=acos(-1); 
const int mod=1e9+7;
const int maxn=5e5+50;
using namespace std;
int main() {
	//IOS;
	int n;
	cin>>n;
	printf("%.9lf",PI*2*n);
	return 0;
}

Measured memory_bytes: 3752
# -*- coding: utf-8 -*-
# モジュールのインポート
import itertools


def get_input() -> tuple:
    """
    標準入力を取得する.

    Returns:\n
        tuple: 標準入力
    """
    # 標準入力を取得
    N = int(input())
    P = tuple(map(int, input().split()))
    Q = tuple(map(int, input().split()))

    return N, P, Q


def main(N: int, P: tuple, Q: tuple) -> None:
    """
    メイン処理.

    Args:\n
        N (int): 数列の大きさ
        P (tuple): 順列
        Q (tuple): 順列
    """
    # 求解処理
    p = 0
    q = 0
    order = 1
    for t in itertools.permutations(range(1, N + 1), N):
        if t == P:
            p = order
        if t == Q:
            q = order
        order += 1

    ans = abs(p - q)

    # 結果出力
    print(ans)


if __name__ == "__main__":
    # 標準入力を取得
    N, P, Q = get_input()

    # メイン処理
    main(N, P, Q)


Measured memory_bytes: 9128
s=input().split('T')
x,y=map(int,input().split())
dx,dy={0},{0}
for i,a in enumerate(map(len,s[::2])):
    if i:dx=set(t+a for t in dx)|set(t-a for t in dx)
    else:dx={a}
for b in map(len,s[1::2]):dy=set(t+b for t in dy)|set(t-b for t in dy)
if x in dx and y in dy:print('Yes')
else:print('No')

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

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

vector<int> myVector(n);

for(int &x: myVector)
{
    cin>>x;
}

sort(myVector.begin(), myVector.end());

long long answer = 0;
for(int i=0; i< n-k ; i++)
{
    answer+=myVector.at(i);
    
}


cout<<answer<<endl;
return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);
      int X = sc.nextInt();
      int prime = X;
      int mid = prime/2;
      boolean flag = false;
      while (true){
        for(int i = 2; i <= mid; ++i){
        	if(prime % i == 0)
            {
              flag = true;
              break;
            }
        }
        if (!flag){
          break;
        }
        else
          flag = false;
          prime++;
      }
      System.out.println(prime);
    }
}

Measured memory_bytes: 23636
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define sz(x) (int)(x.size())

signed main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int a, b, c;
    cin >> a >> b >> c;
    if (a == b && b == c && a % 2 == 0) {
        cout << "-1\n";
        return 0;
    }
    int ans = 0;
    while (a % 2 == 0 && b % 2 == 0 && c % 2 == 0) {
        int t1 = (b + c) / 2;
        int t2 = (a + c) / 2;
        c = (a + b) / 2;
        b = t2;
        a = t1;
        ans++;
    }
    cout << ans << "\n";
}

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

int main(void){
   string S,T;
   cin>>S>>T;
   long long count=0;
   for(int i=0;i<S.size();i++){
      if(S[i]!=T[i]) count++;
   }
   cout<<count<<endl;
   return 0;
}


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

int main(){
  int n,i,odd=0,ord1=0,mlt4=0,a;
  cin >> n;
  for(i=0;i<n;i++){
    cin >> a;
    if(a%4==0){
      mlt4++;
    }else if(a%2==0){
      ord1++;
    }else{
      odd++;
    }
  }
  
  if(odd==0){
    cout << "Yes" << endl;
    return 0;
  }
  
  if(ord1==0){
    if(odd>mlt4+1){
      cout << "No" << endl;
    }else{
      cout << "Yes" << endl;
    }
    return 0;
  }
  
  if(mlt4==0){
    cout << "No" << endl;
    return 0;
  }
  
  if(mlt4>=odd){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}

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

using namespace std;

#define MOD 1000000007

int main()
{
    int n;
    cin >> n;
    int a[n];
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    long long suff = 0, ans = 0;
    for (int i = n-1; i >= 0; i--) {
        ans = ans + (a[i] * suff);
        suff += a[i];
        ans %= MOD;
        suff %= MOD;
    }
    cout << ans << '\n';
    return 0;
}


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

#define ll long long
#define endl "\n"

vector<ll> adj[100005];
ll vis[100005];
ll n, m;

void add(ll x, ll y) {
  adj[x].push_back(y);
  adj[y].push_back(x);
}

void solve() {
  ll a, b, c, d;
  cin >> a >> b >> c >> d;
  ll ans1 = max(a, b) * min(c, d);
  ll ans2 = min(a, b) * max(c, d);
  ll ans3 = max(a, b) * max(c, d);
  ll ans4 = min(a, b) * min(c, d);
  ll ans5 = max(max(ans1, ans2), max(ans3, ans4));
  cout << ans5 << endl;
}

int main() {
  ll t;
  // cin >> t;
  t = 1;
  while (t--)
    solve();
  return 0;
}

Measured memory_bytes: 5984
# coding:utf-8
import itertools
n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ans = 0
j = m

aa = [0] + list(itertools.accumulate(a))
bb = [0] + list(itertools.accumulate(b))
# print(aa)
# print(bb)


# しゃくとり法 / Aの山だけ読みつつ、そこにBからいくつ取り出すかで考える
for i, a_item in enumerate(aa):
    if a_item > k:
        break
    while a_item + bb[j] > k:
        j -= 1
    ans = max(i + j, ans)
print(ans)


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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    ll N;
    cin >> N;
    vector<ll> D(N);
    rep(i, N) cin >> D[i];
    sort(D.begin(), D.end());
    ll ans = D[N / 2] - D[N / 2 - 1];
    cout << ans << '\n';
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>

using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    int t[110000] = {};
    int x[110000] = {};
    int y[110000] = {};
    int n;
    cin >> n;
    for (int i = 1; i <= n; ++i) cin >> t[i] >> x[i] >> y[i];

    bool can = true;
    for (int i = 0; i < n; ++i) {
        int dt = t[i+1] - t[i];
        int dist = abs(x[i+1] - x[i]) + abs(y[i+1] - y[i]);
        if (dist > dt) can = false;
        if (dist % 2 != dt % 2) can = false;
    }
    cout << (can ? "Yes" : "No") << '\n';
}

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

const int INF = 1000000;

int main(){

    int n;
    while(1){
      cin >> n;
      if(n==0){
        break;
      }
      int table[10][10];

      bool realtowntable[10];

      for(int i=0;i<10;i++){
        realtowntable[i] = false;
      }

      for(int i=0;i<10;i++){
        for(int j=0;j<10;j++){
          if(i==j){
            table[i][j] = 0;
          }
          else{
            table[i][j] = INF;
          }
        }
      }
      int a,b,c;
      for(int i=0;i<n;i++){
        cin >> a >> b >> c;
        if(!realtowntable[a]){
          realtowntable[a] = true;
        }
        if(!realtowntable[b]){
          realtowntable[b] = true;
        }
        table[a][b] = table[b][a] = c;
      }

      for(int k=0;k<10;k++){
        for(int i=0;i<10;i++){
          for(int j=0;j<10;j++){
            if(table[i][j] > table[i][k] + table[k][j]){
              table[i][j] = table[i][k] + table[k][j];
            }
          }
        }
      }

      for(int k=0;k<10;k++){
        for(int i=0;i<10;i++){
          for(int j=0;j<10;j++){
            if(table[j][i] > table[j][k] + table[k][i]){
              table[j][i] = table[j][k] + table[k][i];
            }
          }
        }
      }

      int anstown = 0;
      long long int ans=0,tmp=0;
      ans = INF * 12;
      for(int i=0;i<10;i++){
        if(realtowntable[i]){
          tmp = 0;
          for(int j=0;j<10;j++){
            if(realtowntable[j]){
              tmp += table[i][j];
            }
          }
          if(ans > tmp){
            ans = tmp;
            anstown = i;
          }
        }
      }
      cout << anstown << ' ' << ans << endl;

    }


    return 0;
}

Measured memory_bytes: 3016
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
int dp[30];
int main()
{
    string s;
    cin >> s;
    rep(i, 4)
    {
        dp[s[i] - 'A']++;
    }
    rep(i, 30)
    {
        if (dp[i] != 0 && dp[i] != 2)
        {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}

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

bool isprime(int n) {
  	for (int i = 2; i <= sqrt(n); ++i) {
      	if (n % i == 0) {
          return false;
        }
    }
 	return true;
}

void solve(int n) {
    cout << n << ":" << flush;
  	if(isprime(n)) {
      	cout << " " << n << endl;
      return;
    }
 	while (n != 1) {
      	if (n % 2 == 0) {
          	n /= 2;
          	cout << " " << 2 << flush;
        } else {
          	for (int i = 3; i <= n; ++i) {
              if (n % i == 0) {
              		n /= i;
              		cout << " " << i << flush;
                break;
              }
            }
        }
    }
    cout << endl;
}

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


Measured memory_bytes: 3136
#include <iostream>

int main()
{
    int a,b;
    std::cin >> a >> b;
    if(a%2 == 0 || b%2 == 0)
    {
        std::cout << "Even" << std::endl;
    }
    else
    {
        std::cout << "Odd" << std::endl;
    }

    return 0;
}

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

main(){
	int m[6]={1,5,10,50,100,500};
	int sumv = 0;
	for(int i=0; i<6; ++i){
		int c; cin>>c;
		sumv += m[i]*c;
	}
	cout<<(sumv>=1000?1:0)<<endl;
}


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

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

using namespace std;


int main()
{
	int H,W;
	cin>>H>>W;
	
	int A[H+10][W+10];
	
	int c[11][11];
	REP(i,11){
		REP(j,11){
			c[i][j]=100000000;
		}
	}
	
	REP(i,10){
		REP(j,10){
			cin>>c[i][j];
		}
	}
	
	for(int i=1;i<H+1;++i){
		for(int j=1;j<W+1;++j){
			cin>>A[i][j];
		}
	}
	
	
	
	for(int k=0;k<10;++k){
		for(int j=0;j<10;++j){
			for(int i=0;i<10;++i){
				if(c[i][j]>(c[i][k]+c[k][j])){
					c[i][j]=c[i][k]+c[k][j];
				}
			}
		}
	}
	
	int Magic_cost=0;
	for(int i=1;i<H+1;++i){
		for(int j=1;j<W+1;++j){
			if(A[i][j]>-1){
				Magic_cost=c[A[i][j]][1]+Magic_cost;
			}
		}
	}
	cout<<Magic_cost<<endl;
	
	}

Measured memory_bytes: 384
A = int(input())
B = int(input())
C = int(input())
X = int(input())
cnt = 0
for a in range(A+1):
  for b in range(B+1):
    for c in range(C+1):
      if X == 500*a + 100*b + 50*c:
        cnt += 1
print(cnt)

Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cstdint>
#include <cassert>
#include <random>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T iabs(const T& x) { return max(x, -x); }
// #define abs gabs

int main() {
    i64 n, m, k;
    cin >> n >> m >> k;
    for (i64 i = 0; i <= n; ++i) {
        for (i64 j = 0; j <= m; ++j) {
            if (i * j + (n - i) * (m - j) == k) {
                cout << "Yes\n";
                return 0;
            }
        }
    }
    cout << "No\n";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long

using namespace std;

int main() {
    //freopen("a.in", "r", stdin);
    //freopen("a.out", "w", stdout);

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int n, x;
    cin >> n >> x;
    int sum = 0, ans = 1;
    for(int i = 1; i <= n; i ++) {
        int a;
        cin >> a;
        sum += a;
        if(sum <= x)
            ans ++;
    }
    cout << ans;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for (ll i = 0; i < (n); ++i)
const ll mod = 1000000007;
const ll INF = 9223372036854775807;
#define Sort(a) sort(a.begin(), a.end())
#define Bsort(a) sort(a.begin(), a.end(), greater<ll>())
#define Pi acos(-1)

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << setprecision(15) << fixed;
  ll a, b;
  cin >> a >> b;
  cout << (a-1)*(b-1) << '\n';
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
#define IO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)

int n;
double dp[3001][3001], headProb[3001];
bool visited[3001][3001];

double solve(int index, int numberOfTails)
{
    if(index > n && 2 * numberOfTails >= n)
        return 0;
    if(index > n)
        return 1.0;
    if(visited[index][numberOfTails])
        return dp[index][numberOfTails];
    visited[index][numberOfTails] = true;
    double ans = 0;
    ans += solve(index + 1, numberOfTails) * headProb[index];
    ans += solve(index + 1, numberOfTails + 1) * (1 - headProb[index]);
    return dp[index][numberOfTails] = ans;
}
int main()
{
    IO;
    cin >> n;
    for(int i = 1; i <= n; i++)
        cin >> headProb[i];
    memset(visited, false, sizeof visited);
    cout << fixed << setprecision(10) << solve(1,0);
    return 0;
}


Measured memory_bytes: 79616
#include <bits/stdc++.h>
using namespace std; typedef long double ld; typedef long long ll;
typedef unsigned long long ull;
#define endl "\n"
#define MP make_pair
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORR(x,arr) for(auto& x:arr)
#define VI vector<int>
#define PII pair<int, int>
#define FI first 
#define SE second
#define ALL(x) (x).begin(), (x).end()
const int INF=1<<30; const ll LINF=1LL<<60 ; const ll mod=1e9+7 ;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//-------------------
int n;
ll a[100000+5];
//ll dp[100000+5];
//bool check[100000+5];

int main(){
	scanf("%d", &n);
	FOR(i,1,n){ ll x; scanf("%lld", &x); a[i] = -x;}
	vector<ll> v(n,LINF);
	FOR(i,1,n){
		//cout << a[i];
		int idx = upper_bound(ALL(v), a[i]) - v.begin();
		v[idx] = a[i];
	}
	int ans = 0;
	FOR(i,0,n-1){
		ans += (v[i] != LINF? 1:0);
	}
	cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1792
import sys
def input(): return sys.stdin.readline().strip()
N, M, X = map(int, input().split())
li = [list(map(int, input().split())) for _ in range(N)]
ans = 10 ** 10
for i in range(2 ** N):
    p = [0] * M
    sum = 0
    for j in range(N):
        if ((i >> j) & 1):
            sum += li[j][0]
            for k in range(M):
                p[k] += li[j][k + 1]
        if all(x >= X for x in p):
            ans = min(sum, ans)

print(ans if ans != 10 ** 10 else -1)

Measured memory_bytes: 9248
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
    int y, m, d;
    scanf("%d/%d/%d", &y, &m, &d);
    if(m<=4) cout<<"Heisei"<<endl;
    else cout<<"TBD"<<endl;
    return 0;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define repreverse(i, start, end) for (long long i = start; i >= end; --i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define len(x) ((long long)(x).size())
#define lcm(a, b) ((a) / __gcd((a), (b)) * (b))
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vllvll = vector<vll>;
using pll = pair<ll, ll>;
template<class T>void print1d(T x,ll n=-1){if(n==-1)n=x.size();rep(i,0,n){cout<<x[i]<<' ';}cout<<'\n';}
template<class T>void print2d(T x,ll r=-1,ll c=-1){if(r==-1)r=x.size();if(c==-1)c=x[0].size();rep(i,0,r)print1d(x[i],c);}
template<class T, class U>bool haskey(T mp, U key) { return mp.find(key) != mp.end(); }
template<class T, class U>bool isin(T el, U container) { return find(all(container), el) != container.end(); }
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
template<class T>bool even(T n) { return ! (n & 1); }
template<class T>bool odd(T n) { return n & 1; }
template<class T>ld deg2rad(T deg) { return M_PI * deg / 180.0; }
template<class T>ld rad2deg(T rad) { return 180.0 * rad / M_PI; }
ll intpow(ll a,ll n){ll p=1;while(n){if(n&1)p*=a;a*=a;n>>=1;}return p;}
const long double pi = M_PI;
const long long big = 1LL << 50;
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;



int main()
{
        string S;
        cin >> S;
        ll N = len(S);
        map<char, ll> mp;
        rep(i, 0, N) {
                mp[S[i]]++;
        }
        if (N != 26) {
                for (char i = 'a'; i <= 'z'; ++i) {
                        if (mp[i] == 0) {
                                cout << S + i << endl;
                                return 0;
                        }
                }
        }
        if (S == "zyxwvutsrqponmlkjihgfedcba") {
                cout << -1 << endl;
                return 0;
        }

        string orig = S;
        next_permutation(all(S));

        string ans;
        rep(i, 0, N) {
                if (orig[i] == S[i]) ans += S[i];
                else {
                        ans += S[i];
                        break;
                }
        }
        cout << ans << endl;

        // map<char, ll> mp2;
        // rep(i, 0, N) {
        //         if ()
        // }
}

Measured memory_bytes: 3528
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <map>
#include <set>
#include <math.h>
#define rep(i,a,b) for(int i=(a); i<(b); ++i)
typedef long long ll;
using namespace std;

//const double PI=3.14159265358979323846;

int main() {
    int64_t a;
    double b;
    cin >> a >> b;
    int64_t c=b*100+0.5;
    int64_t ans = (a*c)/100;
    printf("%lld\n",ans);
}

Measured memory_bytes: 3256