akhauriyash/Code-Regression huggingface dataset:
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<cmath>
#include<cstdio>
#include<vector>
#include<cstring>
#include<iostream>
#include<algorithm>
#define rev(x) reverse(x,x+strlen(x))
#define mst(a,b) memset(a,b,sizeof(a))
using namespace std;
typedef long long ll;
const int N=1e6+10;
const double M=3.1415926;
ll n,ans=1,a[N],tmp;
int main(){
    cin>>n;
    for(int i=0;i<n;i++){
        scanf("%lld",&a[i]);
    }
    tmp=a[0];
    for(int i=1;i<n;i++){
        if(a[i]<tmp) ans++;
        tmp=min(tmp,a[i]);
    }
    cout<<ans<<endl;
    return 0;
}


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

#define SHINE_MAX 4000
#define ELITE 1000000
#define AHO "NA"

int shineN,eliteN;
int shineI[SHINE_MAX];	//??????????????????
long int shineU[SHINE_MAX];	//?£??????????

int dataN,num;
long int tanka,suryo;
int i,j;

int main(){
while(1){
	//??\???
	cin>>dataN;
	if(dataN==0){break;}
	shineN=0;
	for(j=0;j<dataN;j++){
	 cin>>num>>tanka>>suryo;num--;
	 //???????????????????????????????????¨??????????????????
	 for(i=0;i<shineN;i++){
	  if(shineI[i]==num){break;}
	 }
	 if(i==shineN){	//?????¨???????????£????????????
	  shineU[num]=0;
	  shineI[shineN]=num;
	  shineN++;
	 }
	 shineU[num]+=suryo*tanka;
	}
	//??????
	eliteN=0;
	for(j=0;j<shineN;j++){
	 i=shineI[j];
	 if(ELITE<=shineU[i]){
	  cout<<i+1<<endl;
	  eliteN++;
	 }
	}
	if(eliteN==0){cout<<AHO<<endl;}
}
return 0;
}

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

typedef long long ll;

#define rep(i, n) for(ll i = 0; i < (int)(n); i++)
const ll INF = 1e18;
const ll mod = 1e9+7;

int main() {
    ll n;
    cin>>n;
    vector<ll> a(n,0);
    map<ll,ll>mp;
    rep(i,n){
      cin>>a[i];
      a[i]--;
      mp[a[i]]++;
    }
    vector<ll> A(n,0);
    for(auto i=mp.begin();i!=mp.end();i++){
      ll m1=i->first;
      ll m2=i->second;
      if (m2>=2)A[m1]=m2*(m2-1)/2;
    }
    ll ans=0;
    rep(i,n)ans+=A[i];
    rep(i,n){
      ll anst=ans;
      ll now=a[i];
      ll c=A[now];

      anst-=c;
      ll c1=(mp[a[i]]-1)*(mp[a[i]]-2)/2;
      anst+=c1;
      cout<<anst<<endl;


    }


}


Measured memory_bytes: 12672
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<math.h>
#include<string>
#include <iomanip>
#include<deque>

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
const ll LINF = 1e18;
const int INF = 1e8;

using namespace std;


//マクロ定義
#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(int i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")				//デバッグ用


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

	int n;
	cin >> n;
	if (n == 1)
	{
		cout << "Hello World" << endl;
	}
	else
	{
		int a, b;
		cin >> a >> b;
		cout << a + b << endl;
	}

}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val (n,m) = readLine()!!.split(" ").map { it.toInt() }
    val uft = UnionFindTree(n)
    (1..m).forEach {
        val (x,y,z) = readLine()!!.split(" ").map { it.toInt() }
        uft.unite(x-1,y-1)
    }
    println(uft.size())
}

class UnionFindTree(N:Int){
    private val parent = IntArray(N){ it }
    private val rank = IntArray(N){ 0 }
    private val size = IntArray(N){ 1 }
    private var numTree = N

    fun size() = numTree
    fun find(x:Int):Int = if(parent[x]==x)x else { parent[x] = find(parent[x]);parent[x] }
    fun same(x:Int,y:Int) = find(x)==find(y)
    fun sizeOf(x:Int) = size[find(x)]
    fun unite(x:Int,y:Int){
        val rx = find(x)
        val ry = find(y)
        if (rx==ry) return else numTree--

        if (rank[rx]<rank[ry]){
            parent[rx] = ry
            size[ry] += size[rx]
        } else {
            parent[ry] = rx
            size[rx] += size[ry]
            if( rank[rx]==rank[ry] ) rank[rx]++
        }
    }
}

Measured memory_bytes: 65924
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(void){
  int n;
  cin >> n;
  vector<int> points(n);
  for(int i=0;i<n;++i){
    cin >> points[i];
  }
  sort(points.begin(), points.end(), [](int a, int b){return a<b;});
  int dist = 0;
  for(int i=1;i<n;++i){
    dist += points[i] - points[i-1];
  }
  cout << dist << endl;
}

Measured memory_bytes: 256
def main():
  n = int(input())
  data = list(map(int, input().split()))

  for d in data:
    if d % 2 == 0:
      if d % 3 == 0 or d % 5 == 0:
        pass
      else:
        print("DENIED")
        return      
  
  print("APPROVED")


if __name__ == "__main__":
  main()


Measured memory_bytes: 2940
import collections
n=int(input())

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

c = collections.Counter(prime_factorize(n))

def cnt(n,c):
    ans=0
    a=1
    for i in c.keys():
        b=1
        while c[i]-b>=0:
            ans+=1
            c[i]-=b
            b+=1
    return ans

print(cnt(n,c))


Measured memory_bytes: 9464
#include<bits/stdc++.h>
#define ll long long int
#define ld long double
#define pi pair<int,int>
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define sz(x) ((int)x.size())
#define ln(x) ((int)x.length())
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define endl '\n'
#define dbg(x) cout<<#x<<": "<<x<<endl
#define clr(x,v) memset(x, v, sizeof(x))
#define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
const double eps = 1e-9;
const double PI = acos(-1.0);
const ll mod = 1e9 + 7;
const int MAXN = 5e5 + 5;

int arr[MAXN];
int bit[MAXN];
int last_visit[MAXN];

struct Query
{
    int l, r, idx;
};

Query queries[MAXN];

bool cmp(Query x, Query y)
{
    return x.r < y.r;
}

void update(int idx, int val, int bit[], int n)
{
    for (; idx <= n; idx += idx & -idx)
        bit[idx] += val;
}

int query(int idx, int bit[], int n)
{
    int sum = 0;
    for (; idx > 0; idx -= idx & -idx)
        sum += bit[idx];
    return sum;
}

void cp()
{
    int n, q;
    cin >> n >> q;
    for(int i = 0; i < n; i++)
        cin >> arr[i];
    for(int i = 0; i < q; i++)
    {
        int l, r;
        cin >> l >> r;
        l--, r--;
        queries[i] = {l, r, i};
    }
    sort(queries, queries + q, cmp);
    clr(last_visit, -1);

    int ans[q];
    int cnt = 0;
    for (int i = 0; i < n; i++)
    {
        if (last_visit[arr[i]] != -1)
            update(last_visit[arr[i]] + 1, -1, bit, n);

        last_visit[arr[i]] = i;
        update(i + 1, 1, bit, n);

        while (cnt < q && queries[cnt].r == i)
        {
            ans[queries[cnt].idx] = query(queries[cnt].r + 1, bit, n) - query(queries[cnt].l, bit, n);
            cnt++;
        }
    }

    for (int i = 0; i < q; i++)
        cout << ans[i] << endl;
}

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

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

int main() {
    int N;
    cin >> N;
    string S;
    cin >> S;
    int ans = 0;
    rep(a, 10) rep(b, 10) rep(c, 10) {
        bool A = false, B = false, C = false;
        rep(i, N) {
            if (!A && S[i] - '0' == a)
                A = true;
            else if (A && !B && S[i] - '0' == b)
                B = true;
            else if (B && S[i] - '0' == c)
                C = true;
        }

        if (C) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
d=input()
if(d=="SAT"):
  print(1)
elif(d=="FRI"):
  print(2)
elif(d=="THU"):
  print(3)
elif(d=="WED"):
  print(4)
elif(d=="TUE"):
  print(5)
elif(d=="MON"):
  print(6)
else:
  print(7)

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

using std::string;
using std::cout;
using std::cin;
using std::vector;
using ull = unsigned long long;
using ll = long long;

int main(){
    ull n,m,x;
    cin >> n >> m >> x;
    vector<ull> c(n);
    vector<vector<ull>> a(n);
    
    vector<ull> understanding(m,0);

    for(ull i=0; i<n; i++){
        cin >> c[i];
        for(ull k=0; k<m; k++){
            ull a_;
            cin >> a_;
            a[i].push_back(a_);
        }
    }
    ull total_cost = 0ULL;
    ull ans = ULLONG_MAX;
    ull iteration = (1ULL<<n)-1ULL; // max of 2^12-1
    for(ull iter=1ULL; iter<=iteration; iter++){ // max of 2^12 patterns
        total_cost = 0ULL;
        for(int k=0; k<m; k++){
            understanding.at(k) = 0;
        }
        for(int i=0; i<n; i++){
            if(iter & (1<<i)){
                for(int k=0; k<m; k++){
                    understanding.at(k) += a.at(i).at(k);
                }
                total_cost += c.at(i);
            }
        }
        bool done = true;
        for(int k=0; k<m; k++){
            if(understanding.at(k)<x){
                done = false;
                break;
            }
        }
        if(done){
            ans = std::min(total_cost, ans);
        }
    }
    if(ans == ULLONG_MAX){
        cout << -1 << "\n";
    }else{
        cout << ans << "\n";
    }
    
    return 0;
}

Measured memory_bytes: 3636
#include<iostream>
#include<string>
using namespace std;
string s;
bool flag;
int main()
{
	cin>>s;
	for(register int i=0;i<s.length();i++)
	{
		if(s[i]=='C')
			flag=true;
		if(flag&&s[i]=='F')
		{
			cout<<"Yes";
			return 0;
		}
	}
	cout<<"No";
	return 0;
}

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

int n, m;
ll k = 1e9 + 7;

ll f(int n) {
	ll p = 1;
	rep(i, 2, n) p = p * i % k;
	return p;
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n >> m;
	if (abs(n - m) > 1) cout << 0;
	else {
		if (n < m) swap(n, m);
		if (n > m) cout << f(n) * f(m) % k;
		else cout << 2 * f(n) * f(n) % k;
	}
}

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

int main() {
	string s;cin >> s;
	string subs;
	int a=0,b=0,c=1;
	int count = 0, CL = 0;
	bool f = 0;
	if (s[0] == 'A')a = 1;

	subs=s.substr(2, s.length() - 3);
	for (int i = 0; i < subs.length();i++) {
		if (subs[i] == 'C') {
			count++;
			CL = i+2;
		}
	}
	if (count == 1)b = 1;

	for (int k = 1; k < s.length();k++) {
		if (k != CL) {
			if (s[k]<'a' || s[k]>'z')c *= 0;
		}
	}
	f = a * b*c;
	if (f)cout << "AC" << endl;
	else cout << "WA" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <cstdio>
#include <cstring>
using namespace std;
typedef long long int ll;
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}

int main()
{
    int a,b;
    cin>>a>>b;

    int c=a-2*b;
    if(c<0)
    	c=0;
    cout<<c;
    return 0;
}



Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
import java.math.*;

public class Main {
	public static void main(String[] args)throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb = new StringBuilder();

		String[] str = br.readLine().split("/");
		int y = Integer.parseInt(str[0]);
		int m = Integer.parseInt(str[1]);
		if(y>2019 || (y<=2019 && m>4)){
			System.out.println("TBD");
		}else{
			System.out.println("Heisei");
		}
	}
}

Measured memory_bytes: 22100
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 1; i <= (int)(n); ++i)
typedef long long ll;
map<int, int> mp;
void factorizeCntSum(int n) {
  int d, q;
  while (n >= 2 && n % 2 == 0) {
    n /= 2;
    mp[2]++;
  }
  d = 3;
  q = n / d;
  while (q >= d) {
    if (n % d == 0) {
      n = q;
      mp[d]++;
    } else {
      d += 2;
    }
    q = n / d;
  }
  if (n != 1) {
    mp[n]++;
  }
}

int main() {
  int n;
  cin >> n;
  rep(i,n)
    factorizeCntSum(i);
  ll cnt = 1;
  for (auto itr = mp.begin(); itr != mp.end(); ++itr) {
    cnt *= (itr->second + 1);
    cnt %= (ll)(1e9 + 7);
  }
  cout << cnt;
  return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.lang.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        if(n<10||n%2==1){
            System.out.println(0);
            return;
        }
        n /= 2;
        long result = 0;
        while(n>0){
            n /= 5;
            result += n;
        }
        System.out.println(result);
        sc.close();
    }
}

Measured memory_bytes: 20948
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<vector>
#include<utility>
#define REP(i, n) for(int i = 0; i < n; ++i)
using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    int a[100010];
    REP(i,N) cin >> a[i];
    a[N] = 0;
    sort(a, a+N+1, greater<int>());
    int ans = 0;
    int cur;
    int p = 1;
    cur = a[0];
    for (int i = 1; i < N + 1; ++i){
        if (cur == a[i]){
            p += 1;
        }
        else{
            if (p % 2 == 1){
                ans += 1;
            }
            cur = a[i];
            p = 1;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
# def makelist(n, m):
# 	return [[0 for i in range(m)] for j in range(n)]

# n = int(input())
# a, b = map(int, input().split())
# s = input()


N, T = map(int, input().split())
A = list(map(int, input().split()))

diff = [0]*N

mini = A[0]
for i in range(1, N):
	now = A[i]
	if now <= mini:
		mini = now
	else:
		diff[i] = now - mini

sa = max(diff)

ans = 0
mini = A[0]
l = 1
r = 0
for i in range(1, N):
	now = A[i]
	if mini == now:
		l += 1
	elif now < mini:
		if r > 0:
			ans += min(l, r)
			r = 0
		mini = now
		l = 1
	else: # now > mini
		if now - mini == sa:
			r += 1

if r > 0:
	ans += min(l, r)
print(ans)


Measured memory_bytes: 63600
N = gets.chomp.to_i
XL = []
N.times do |i|
  x, l = gets.chomp.split(" ").map(&:to_i)
  XL << {left: x - l, right: x + l}
end
XL.sort_by! {|v| v[:right]}

ans = 0
cur = -Float::INFINITY
XL.each do |v|
  if cur <= v[:left]
    ans += 1
    cur = v[:right]
  end
end
puts ans


Measured memory_bytes: 34552
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
#define ALL(a)  (a).begin(),(a).end()
const ll INF = 1e18+18;
const ll MAX = 200000;
const ll MOD = 1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;



int main(){
    ll K;
    string S;
    cin>>K>>S;
    ll Sz=S.size();
    if(Sz<=K){
        cout<<S<<endl;
        return 0;
    }
    rep(i, K){
        cout<<S.at(i);
    }
    cout<<"..."<<endl;
    return 0;

}

Measured memory_bytes: 3628
rows = int(input())
LstS = []
LstH = []
LstC = []
LstD=[]

for i in range(rows):
    x, y = input().split()
    if x == "S":
        LstS.append(int(y))
    elif x == "H":
        LstH.append(int(y))
    elif x == "C":
        LstC.append(int(y))
    elif x == "D":
        LstD.append(int(y))

LstS.sort
LstH.sort
LstD.sort
LstC.sort

for i in range(1,14,1):
    if LstS.count(i) == 0:
        print("S",end=" ")
        print(i)

for i in range(1, 14, 1):
    if LstH.count(i) == 0:
        print("H", end=" ")
        print(i)

for i in range(1, 14, 1):
    if LstC.count(i) == 0:
        print("C", end=" ")
        print(i)

for i in range(1, 14, 1):
    if LstD.count(i) == 0:
        print("D", end=" ")
        print(i)



Measured memory_bytes: 5620
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        for(int i = 1;;i++){
            int x = sc.nextInt();
            if(x==0){
                break;
            }
            else{
                System.out.printf("Case %d: %d\n",i,x);
            }
        }
    }
}


Measured memory_bytes: 62948
#include<bits/stdc++.h>
using namespace std;
string pat[4] = {"0xxxxxxx","110yyyyx10xxxxxx","1110yyyy10yxxxxx10xxxxxx","11110yyy10yyxxxx10xxxxxx10xxxxxx"};
int N;
map< pair< int , bool > , int > used;
vector< string > data;
int rec2( int idx, const string& str, const string& patan, bool y_flag){
  if(idx == str.size()){
    return y_flag;
  }
  int ret = 0;
  if(used.find( make_pair( idx, y_flag)) != used.end()) return used[make_pair( idx, y_flag)];
  if(isdigit(str[idx])){
    if(isdigit(patan[idx])){
      if(str[idx] != patan[idx]) return 0;
      else ret = rec2( idx + 1,  str, patan, y_flag);
    } else {
      ret = rec2( idx + 1, str, patan, y_flag|(str[idx]=='1'&&patan[idx]=='y'));
    }
  } else {
    if(isdigit(patan[idx])){
      ret = rec2( idx + 1, str, patan, y_flag);
    } else {
      ret = rec2( idx + 1, str, patan, y_flag|(patan[idx]=='y')) + rec2( idx + 1, str, patan, y_flag);
    }
  }
  return used[make_pair( idx, y_flag)] = ret % 1000000;
}
int rec( int idx, const string& str, const string& patan, bool y_flag){
  used.clear();
  return rec2( idx, str, patan, y_flag);
}
int main(){
  long long dp[1001] = {};
  while(cin >> N, N){
    for(int i = 0; i < N; i++){
      string s;
      cin >> s;
      data.push_back(s);
    }
    for(int i = 0; i < N; i++){
      if(i == 0){
        dp[i] = rec( 0, data[0], pat[0], true);
        dp[i] %= 1000000;
      } else if(i == 1){
        dp[i] = dp[0] * rec( 0, data[i], pat[0], true);
        dp[i] %= 1000000;
        dp[i] += rec( 0, data[0] + data[1], pat[1], false);
        dp[i] %= 1000000;
      } else if(i == 2){
        dp[i] = dp[1] * rec( 0, data[2], pat[0], true);
        dp[i] %= 1000000;
        dp[i] += dp[0] * rec( 0, data[1] + data[2], pat[1], false);
        dp[i] %= 1000000;
        dp[i] += rec( 0, data[0] + data[1] + data[2], pat[2], false);
        dp[i] %= 1000000;
      } else if(i == 3){
        dp[i] = dp[2] * rec( 0, data[3], pat[0], true);
        dp[i] %= 1000000;
        dp[i] += dp[1] * rec( 0, data[2] + data[3], pat[1], false);
        dp[i] %= 1000000;
        dp[i] += dp[0] * rec( 0, data[1] + data[2] + data[3], pat[2], false);
        dp[i] %= 1000000;
        dp[i] += rec( 0, data[0] + data[1] + data[2] + data[3], pat[3], false);
        dp[i] %= 1000000;
      } else {
        dp[i] = dp[i - 1] * rec( 0, data[i], pat[0], true);
        dp[i] %= 1000000;
        dp[i] += dp[i - 2] * rec( 0, data[i - 1] + data[i], pat[1], false);
        dp[i] %= 1000000;
        dp[i] += dp[i - 3] * rec( 0, data[i - 2] + data[i - 1] + data[i], pat[2], false);
        dp[i] %= 1000000;
        dp[i] += dp[i - 4] * rec( 0, data[i - 3] + data[i - 2] + data[i - 1] + data[i], pat[3], false);
        dp[i] %= 1000000;
      }
    }
    cout << dp[N - 1] << endl;

    data.clear();
  }
}

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

const int INF = 1 << 30;

int main() {
  int n;
	string s;
	cin >> n >> s;
	vector<int> l(n + 1), r(n + 1);
	for (int i = 0; i < n; i++) {
		if (s[i] == '#') l[i + 1] = l[i] + 1;
		else l[i + 1] = l[i];
	}
	for (int i = n - 1; i >= 0; i--) {
		if (s[i] == '.') r[i] = r[i + 1] + 1;
		else r[i] = r[i + 1];
	}
	int ans = INF;
	for (int i = 0; i <= n; i++) {
		ans = min(ans, l[i] + r[i]);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 5232
use proconio::input;
use proconio::marker::{Bytes, Chars};

// use std::cmp::*;
use std::collections::HashMap;

fn main() {
    input! {
        sa:Chars,
        sb:Chars,
        sc:Chars,
    }

    let mut a = 0;
    let mut b = 0;
    let mut c = 0;
    let mut n = 'a';
    loop {
        if n == 'a' {
            if sa.len() <= a {
                println!("A");
                return;
            }
            n = sa[a];
            a += 1;
        } else if n == 'b' {
            if sb.len() <= b {
                println!("B");
                return;
            }
            n = sb[b];
            b += 1;
        } else {
            if sc.len() <= c {
                println!("C");
                return;
            }
            n = sc[c];
            c += 1;
        }
    }
}


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

void max(int& a, int& b, int& c){
  if (a < b) {a^=b; b^=a; a^=b;}
  if (a < c) {a^=c; c^=a; a^=c;}
}
int main(){
  int a,b,c,k; cin >> a>> b >> c >> k;
  max(a, b, c) ;
  cout << a*pow(2, k)+b+c << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){

	int x,y;
	while(1){
		cin >>x >>y;
		if(x==y && y==0) break;
		if(x>y) cout <<y <<' ' << x ;
		else cout <<x <<' '<< y;
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <stack>
#include <cmath>
using namespace std;
using ll = long long;

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

    int N, M, lef, res = 1;
    cin >> N >> M;

    vector<pair<int, int> > V(M);
    for (int i = 0; i < M; i++) {
        cin >> V[i].second >> V[i].first;
    }
    sort(V.begin(), V.end());

    lef = V[0].first;
    for (int i = 1; i < M; i++) {
        if (V[i].second >= lef) {
            res++;
            lef = V[i].first;
        }
    }

    cout << res << endl;
    
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define pi 3.14159265359

int main(){
   int d,t,s;
   cin >> d>>t>>s;
   if(d>t*s){
       cout << "No" <<endl;
   }
   else{
       cout << "Yes" << endl;
   }
}

Measured memory_bytes: 3632
#define MOD_TYPE 1

#pragma region Macros
#include <bits/stdc++.h>
using namespace std;
/*
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
using Int = boost::multiprecision::cpp_int;
using lld = boost::multiprecision::cpp_dec_float_100;
*/
/*
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
*/
using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pld = pair<ld, ld>;
template <typename Q_type>
using smaller_queue = priority_queue<Q_type, vector<Q_type>, greater<Q_type>>;

constexpr ll MOD = (MOD_TYPE == 1 ? (ll)(1e9 + 7) : 998244353);
//constexpr ll MOD = 1;
constexpr int INF = (int)1e9;
constexpr ll LINF = (ll)4e18;
constexpr double PI = acos(-1.0);
constexpr double EPS = 1e-10;
constexpr int Dx[] = {0, 0, -1, 1, -1, 1, -1, 1, 0};
constexpr int Dy[] = {1, -1, 0, 0, -1, -1, 1, 1, 0};

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define REPI(i, m, n) for (int i = m; i < (int)(n); ++i)
#define repi(i, n) REPI(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << "\n"
#define Yes(n) cout << ((n) ? "Yes" : "No") << "\n"
#define possible(n) cout << ((n) ? "possible" : "impossible") << "\n"
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << "\n"
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << "\n"
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << "\n";

inline void init_main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(30) << setiosflags(ios::fixed);
}
template <typename T>
inline bool chmin(T &a, T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
inline bool chmax(T &a, T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
inline ll CEIL(ll a, ll b)
{
  return (a + b - 1) / b;
}
template <typename A, size_t N, typename T>
inline void Fill(A (&array)[N], const T &val)
{
  fill((T *)array, (T *)(array + N), val);
}
template <typename T, typename U>
constexpr ostream &operator<<(ostream &os, pair<T, U> &p) noexcept
{
  os << p.first << " " << p.second;
  return os;
}
#pragma endregion

void solve()
{
  ll a, v, b, w, t;
  cin >> a >> v >> b >> w >> t;
  ll d = abs(a - b);
  if (v <= w)
    YES(false);
  else
    YES(d <= t * (v - w));
}

int main()
{
  init_main();
  solve();
  return 0;
}


Measured memory_bytes: 3652
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		long N = scan.nextLong();
		scan.close();
		String s = Long.toString(N);
		long k = 0;
		for(int i = 0; i < s.length(); i++) {
			int t = Integer.parseInt(s.substring(i, i + 1));
			k += t;
		}
		if(N % k == 0) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}

	}
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100010;
int N;
int li[MAXN];
int main()
{
	cin >> N;
	for (int i = 1; i <= N; i++)
	{
		int x;
		cin >> x;
		li[x] = i;
	}
	for (int i = 1; i <= N; i++)
	{
		cout << li[i] << " ";
	}
	return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repp(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define rrep(i, n, m) for (int i = n; i >= m; i--)
#define ALL(a) (a).begin(), (a).end()
#define p(a, b) printf(a, b);
#define c(s) cout << (s) << endl;
#define yes cout << "Yes" << endl;
#define no cout << "No" << endl;
#define YES cout << "YES" << endl;
#define NO cout << "NO" << endl;
#define cyn(c) cout << (c ? "Yes" : "No") << endl;
#define cYN(c) cout << (c ? "YES" : "NO") << endl;
#define pyn(c) printf("%s\n", c ? "Yes" : "No");
#define pYN(c) printf("%s\n", c ? "YES" : "NO");
#define INF 1e18
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<LL, LL> P;
template <class T>
bool contain(const std::string &s, const T &v)
{
  return s.find(v) != std::string::npos;
}
ULL mod = 1e9 + 7;

map<ULL, ULL> prime_factor(ULL n)
{
  map<ULL, ULL> ret;
  for (ULL i = 2; i * i <= n; i++)
  {
    while (n % i == 0)
    {
      ret[i]++;
      n /= i;
    }
  }
  if (n != 1)
    ret[n] = 1;
  return ret;
}

int N,W;
int w[1005],v[1005];
int dp[1005][1005];
void knapsack_dp(){
  rrep(i,N-1,0){
    rep(j,W+1){
      if(j<w[i]){
        dp[i][j] = dp[i+1][j];
      }else{
        dp[i][j] = max(dp[i + 1][j], dp[i + 1][j - w[i]] + v[i]);
      }
    }
  }
}
// int cnt=0; char c;
// while (cin >> W){
//   if(W==0) break;
//   cin>>N;
//   rep(i,N)cin>>v[i]>>c>>w[i];
//   knapsack_dp();

//   int value,weight;
//   value = weight = 0;
//   rep(i,W+1){
//     if (value < dp[0][i]){
//       value = dp[0][i];
//       weight = i;
//     }
//   }

//   cout << "Case " << ++cnt << ":" << endl;
//   cout << value << endl;
//   cout << weight << endl;

//   memset(w,0,sizeof(w));
//   memset(v,0,sizeof(v));
//   memset(dp,0,sizeof(dp));
// }

int main(){
    int a,b,c; cin>>a>>b>>c;
    if(a==b&&b==c){
      yes;
    }else{
      no;
    }

}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>

using namespace std;

struct edge {
    int to;
    int cost;
};

struct status {
    int cost;
    int v;

    bool operator<(const status &another) const { return cost < another.cost; };

    bool operator>(const status &another) const { return cost > another.cost; };
};


int n;

vector<int> dijkstra(vector<vector<edge>> &graph, int s) {
    priority_queue<status, vector<status>, greater<>> que;
    vector<int> dis(n, 1145141919);
    dis[s] = 0;
    que.push({0, s});

    while (!que.empty()) {
        status now = que.top();
        que.pop();

        if (dis[now.v] < now.cost)continue;

        for (auto next:graph[now.v]) {
            if (dis[next.to] > dis[now.v] + next.cost) {
                dis[next.to] = dis[now.v] + next.cost;
                que.push({dis[next.to], next.to});
            }
        }
    }
    
    return dis;
}

int main() {
    while (true) {
        int m;
        cin >> m >> n;
        if (m == 0)break;

        vector<vector<edge>> graphc(n);
        vector<vector<edge>> grapht(n);
        for (int i = 0; i < m; i++) {
            int from, to, cost, time;
            cin >> from >> to >> cost >> time;
            from--;
            to--;
            graphc[from].push_back({to, cost});
            graphc[to].push_back({from, cost});
            grapht[from].push_back({to, time});
            grapht[to].push_back({from, time});
        }

        int k;
        cin >> k;
        for (int i = 0; i < k; i++) {
            int start, end, r;
            cin >> start >> end >> r;
            start--;
            end--;
            auto dis = dijkstra((r == 0 ? graphc : grapht), start);
            cout << dis[end] << endl;
        }
    }
    return 0;
}


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

int main()
{
	int H, W, K; //入力
	//int board[6][6]; //盤面の入力
	int board[36] = { 0 }, boardTrial[36] = { 0 };
	char input; //個別の記号の入力
	int blackCells = 0, blackCellsResult = 0, successfulResults = 0; //入力された黒の総数
	int trials = 1, maxTrials = 1, trialNum;

	cin >> H >> W >> K;

	for (int i = 1; i <= H; i++) {
		for (int j = 1; j <= W; j++) {
			cin >> input;
			if (input == '#') {
				board[(i - 1) * 6 + (j - 1)] = 1;
			}
		}
	}

	for (int i = 1;i <= H + W; i++) {
		maxTrials *= 2;
	}
	
	for (int i = 1; i <= maxTrials; i++) {
		//初期設定
		trialNum = i;
		for (int j = 1; j <= 36; j++) {
			boardTrial[j - 1] = board[j - 1];
		}
		blackCellsResult = 0;

		//行の赤変更
		for (int j = 1; j <= H; j++) {
			if (trialNum % 2 == 1) {
				for (int k = 1; k <= 6; k++) {
					boardTrial[(j - 1) * 6 + k - 1] = 0;
				}
			}
			trialNum /= 2;
		}

		//列の赤変更
		for (int j = 1; j <= W; j++) {
			if (trialNum % 2 == 1) {
				for (int k = 1; k <= 6; k++) {
					boardTrial[j - 1 + (k - 1) * 6] = 0;
				}
			}
			trialNum /= 2;
		}

		//点数確認
		for (int j = 1; j <= 36; j++) {
			if (boardTrial[j - 1] == 1) {
				blackCellsResult++;
			}
		}

		if (blackCellsResult == K) {
			successfulResults++;
		}

	}

	cout << successfulResults;

	return 0;

}

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

vector<int> to[2000005];
vector<int> ans;
void dfs(int v,int p=-1){
  for(int u : to[v]){
    if(u==p) continue;
    ans.at(u) += ans.at(v);
    dfs(u,v);
  }
}

int main(){
  int n,q;
  cin >> n >> q;
  for(int i=0;i<n-1;i++){
    int a,b;
    cin >> a >> b;
    --a; --b;
    to[a].push_back(b);
    to[b].push_back(a);
  }
  ans.resize(n);
  for(int i=0;i<q;i++){
    int p,x;
    cin >> p >> x;
    --p;
    ans.at(p)+=x;
  }
  dfs(0);
  for(int i=0;i<n;i++){
    cout << ans.at(i) << endl;
  }
  return 0;
}


Measured memory_bytes: 68736
#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>;
using Graph = vector<vector<int>>;

const int INF = 1001001001;

int dist[100005][3];

int main(){
    int n, m; 
    cin >> n >> m;
    Graph G(n);
    rep(i,m){
        int a, b; cin >> a >> b;
        --a, --b;
        G[a].pb(b);
    }
    int sv, tv; 
    cin >> sv >> tv;
    --sv, --tv;
    rep(i,n)rep(j,3) dist[i][j] = INF;
    queue<P> q;
    q.push(P(sv,0));
    dist[sv][0] = 0;
    while(!q.empty()){
        int v = q.front().first;
        int l = q.front().second;
        q.pop();
        for(int u : G[v]){
            int nl = (l+1)%3;
            if(dist[u][nl] != INF) continue;
            dist[u][nl] = dist[v][l] + 1;
            q.push(P(u,nl));
        }
    }
    int ans = dist[tv][0];
    if(ans == INF) ans = -1;
    else ans /= 3;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6912
#include <iostream>
#include <stdio.h>
using namespace std;

int f(int x,int y,int z){
	return x+y*y+z*z*z;
}
int main(void){
	int x,m,e;

	while(cin>>e,e){
		m=1000000;
		// x+yy+zzz=e????§£???.
		for(int y=0;y*y<=e;y++){
			for(int z=0;y*y+z*z*z<=e;z++){
				// if(y*y+z*z*z>e)goto lab;
				// printf("debug:%d\n",f(x,y,z));
				x=e-y*y-z*z*z;
				if(m>x+y+z)m=x+y+z;
			}
		}
lab:
		cout<<m<<endl;
	}
}

Measured memory_bytes: 2976
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()
ll MOD = 1000000007;
ll INF = 1e18;

int main() {
  //
  ll a, b, x;
  cin >> a >> b >> x;
  double ok = 0, ng = 90;
  while (ng - ok > 0.00000000001) {
    double mid = (ng + ok) / 2.0;
    double t = b * tan((90.0 - mid) * M_PI / 180.0);
    double v = 0;
    if (t <= a) {
      v = a * t * b / 2.0;
    } else {
      double b1 = (t - a) / tan((90.0 - mid) * M_PI / 180.0);
      v = (a * t * b - a * (t - a) * b1) / 2.0;
    }
    // cerr << mid << ":" << v << endl;
    if (v >= x) {
      ok = mid;
    } else {
      ng = mid;
    }
  }
  cout << setprecision(10) << fixed << ok << endl;
  return 0;
}


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

using namespace std;

#define REP(i, a, b) for (int i = a; i < b; i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()

typedef long long ll;
typedef unsigned long long ull;

int main() {
    int N;
    cin >> N;
    int d[N];
    rep(i, N) { cin >> d[i]; }
    map<int, int> dmap;
    rep(i, N) { dmap[d[i]]++; }
    cout << dmap.size() << endl;
    return 0;
}


Measured memory_bytes: 256
parseInt(x) = parse(Int,x)
parseMap(x::Array{SubString{String}, 1}) = map(parseInt, x)

function main()
  (N,K) = map(parseInt, split(readline()))
  H = map(parseInt, split(readline()))
  sort!(H)
  println(sum(H[1:(N-K)]))
end

main()

Measured memory_bytes: 125196
#include "bits/stdc++.h"

using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define ll long long
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
using pii = pair<int, int>;
// template<class T> ostream &operator<<(ostream &os,T &t){dump(t);return os;}
template <typename T, typename S>istream &operator>>(istream &is, pair<T, S> &p) { is >> p.first >> p.second; return is; }
//template <typename T, typename S>ostream &operator<<(ostream &os, pair<T, S> &p) {os << p.first << " " << p.second;return os;}

template <typename T> void printvv(const vector<vector<T>> &v) {
	cerr << endl;
	rep(i, 0, v.size()) rep(j, 0, v[i].size()) {
		if (typeid(v[i][j]).name() == typeid(INF).name() and v[i][j] == INF) {
			cerr << "INF";
		}
		else
			cerr << v[i][j];
		cerr << (j == v[i].size() - 1 ? '\n' : ' ');
	}
	cerr << endl;
}

#ifndef _DEBUG
#define printvv(...)
#endif
void YES(bool f) { cout << (f ? "YES" : "NO") << endl; }
void Yes(bool f) { cout << (f ? "Yes" : "No") << endl; }
template <class T, class U>bool chmin(T& a, U b) { if (a > b) { a = b; return true; }return false; }
template <class T, class U>bool chmax(T& a, U b) { if (a < b) { a = b; return true; }return false; }

signed main(signed argc, char *argv[]) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(12);

	int N; cin >> N;
	vector<int>mp(N + 1);
	for (int x = 1; x*x <= N; x++) {
		for (int y = 1; x*x + y * y + x * y <= N; y++) {
			for (int z = 1; x*x + y * y + z * z + x * y + y * z + z * x <= N; z++) {
				mp[x*x + y * y + z * z + x * y + y * z + z * x]++;
			}
		}
	}
	rep(i, 1, N + 1) {
		cout << mp[i] << endl;
	}
	return 0;
}


Measured memory_bytes: 3688
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n ,k, sum;
  cin >> n >> k ;
  for(int i = 0; i < n ; i++){
    int x ;
    cin >> x ;
    if( x < k -x ){
      sum += 2*x;
    }
    else{
      sum += 2*(k-x);
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;


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

	int n, i, j, k;
	string s;
	map<string, int> ct;

	cin >> n;
	while (n--) {
		cin >> s;
		ct[s]++;
	}

	cout << "AC x " << ct["AC"] << "\n";
	cout << "WA x " << ct["WA"] << "\n";
	cout << "TLE x " << ct["TLE"] << "\n";
	cout << "RE x " << ct["RE"] << "\n";


	return 0;
}


Measured memory_bytes: 3200
n,k=map(int,input().split())
p=list(map(int,input().split()))
e=[]
for pp in p:
    ex=(pp+1)/2
    e.append(ex)
ans=0
for i in range(n-k+1):
    if i==0:
        t=sum(e[:k])
        ans+=t
        continue
    t-=e[i-1]
    t+=e[i+k-1]
    ans=max(ans,t)

print(ans)

Measured memory_bytes: 25060
N, M = map(int, input().split())
A = [input() for _ in range(N)]
B = [input() for _ in range(M)]
ans = False

for i in range(N-M+1):
  for j in range(N-M+1):
    flg = True
    for k in range(M):
      if A[i+k][j:j+M] != B[k]:
        flg = False
    if flg:
      ans = True

if ans:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 9148
#include<iostream>
#include<cmath>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cassert>

#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define inf (1<<29)
#define MAX 5100
using namespace std;

int N,M;
//int g[MAX][MAX];

int main()
{
  scanf("%d %d",&N,&M);
  vector<int> g[N+5];
  rep(i,N+5)g[i].resize(i+5);
  rep(i,N+5)rep(j,i+1)g[i][j] = 0;
  rep(i,M)
    {
      int x,y,d;
      scanf("%d %d %d",&y,&x,&d);
      x--,y--;
      g[y][x]++,g[y+d+2][x+1]++,g[y+d+1][x+d+2]++;
      g[y][x+1]--,g[y+d+1][x]--,g[y+d+2][x+d+2]--;
    }

  rep(i,N+2)rep(j,i+2)if(j-1>=0)g[i][j] += g[i][j-1];
  rep(x,N+2)REP(y,x,N+2)if(y-1>=0)g[y][x] += g[y-1][x];
  rep(i,N+2)
    {
      int y = i,x = 0;
      while(y <= N+2 && x <= N+2)
	{
	  if(y-1>=0 && x-1>=0)g[y][x] += g[y-1][x-1];
	  y++,x++;
	}
    }

  int ans = 0;
  rep(y,N+2)rep(x,y+2)if(g[y][x]>0)ans++;
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 50400
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
const int maxn = 100005;
char s[maxn];

int main() {
	scanf("%s", s + 1);
	int n = strlen(s + 1);
	if (s[1] == s[n]) {
		if ((n - 2) & 1) puts("Second");
		else puts("First");
	} else {
		if ((n - 2) & 1) puts("First");
		else puts("Second");
	}
	return 0;
}

Measured memory_bytes: 384
from collections import deque

n = int(input())
d = deque()

for _ in range(n):
    s = input()
    if "deleteFirst" in s:
        d.popleft()
    elif "deleteLast" in s:
        d.pop()
    else:
        command, k = s.split()
        if command == "insert":
            d.appendleft(k)
        elif command == "delete":
            if k not in d: continue
            d.remove(k)
       
print(" ".join(d))


Measured memory_bytes: 69728
#include <iostream>
#include <map>
#include <algorithm>
#include <string>
#include <vector> 
#include <numeric>
#include <cmath>
#include <queue>
#include <iomanip>
#include <functional>


#define CHMAX(a,b) a = std::max(a,b)
#define CHMIN(a,b) a = std::min(a,b)
#define CHABS(a) a = std::abs(a) 
#define COUT(a) std::cout << a << std::endl
#define CERR(a) std::cerr << a << std::endl
#define FOR(n) for(lli i = 0; i < n; i++)

using namespace std;
using lli = long long int;
using pll = pair<lli, lli>;
using tlll = tuple<lli, lli, lli>;
using vll = vector<lli>;

lli mod197 = 1000000007LL;
lli INF = 10000000000000;

// ax + by = gcd(a,b) 最大公約数
template< typename T >
T extgcd(T a, T b, T& x, T& y) {
	T d = a;
	if (b != 0) {
		d = extgcd(b, a % b, y, x);
		y -= (a / b) * x;
	}
	else {
		x = 1;
		y = 0;
	}
	return d;
}

int main(void) {

	lli x, y;
	cin >> x >> y;
	cout << x + y / 2 << endl;



	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <string>

using namespace std;


int main()
{
    int n;
    cin >>n;
    vector<long long> a(n, 0);
    long long m = 1000;
    long long kabu;

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

    for (long long i = 0; i < n - 1; i++) {
        if (a[i] < a[i + 1]) {
            kabu = m / a[i];
            m = m % a[i];
            m = m + kabu * a[i + 1];
        }
    }

    cout << m;

    return 0;
}



Measured memory_bytes: 3640
import java.io.PrintWriter
import java.util.*

val pw = PrintWriter(System.out)
val sc = Scanner(System.`in`)

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val (a, b, c, k) = nextListOfInt()
    var ans = 0
    if(a - k >= 0) {
        ans = k
    }else if(b >= k-a){
        ans = a
    }else {
        ans = a - (k-a-b)
    }

    println(ans)

}

fun abc000b() {
}


fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextListOfString() = next().split(" ")
fun nextListOfInt() = nextListOfString().map { it.toInt() }
fun nextListOfLong() = nextListOfString().map { it.toLong() }
fun nextListOfDouble() = nextListOfString().map { it.toDouble() }



Measured memory_bytes: 38672
#include <iostream>
#include <cstdlib>

using namespace std;

int main(void) {
    int a,b,c,d;cin>>a>>b>>c>>d;
    if ((abs(a - b) <= d && abs(b - c) <= d) || abs(a - c) <= d) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 888
#include<bits/stdc++.h>
    #include<chrono>
     
    using namespace std;
    using namespace std::chrono;
     
    /// ----------------------------- (Debug) ------------------------------
    #define sim template < class c
    #define ris return * this
    #define dor > debug & operator <<
    #define eni(x) sim > typename enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
    sim > struct rge { c b, e; }; sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
    sim > auto dud(c* x) -> decltype(cerr << *x, 0); sim > char dud(...);
    struct debug {
    #ifndef ONLINE_JUDGE
    eni(!=) cerr << boolalpha << i; ris; }
    eni(==) ris << range(begin(i), end(i));}
    sim, class b dor(pair < b, c > d) {ris << "(" << d.first << ", " << d.second << ")";}
    sim dor(rge<c> d) {*this << "["; for (auto it = d.b; it != d.e; ++it) *this << ", " + 2 * (it == d.b) << *it; ris << "]";}
    #else
    sim dor(const c&) { ris; }
    #endif
    };
    vector<char*> tokenizer(const char* args) {
        char *token = new char[111]; strcpy(token, args); token = strtok(token, ", ");
        vector<char*> v({token});
        while(token = strtok(NULL,", ")) v.push_back(token);
        return reverse(v.begin(), v.end()), v;
    }
    void debugg(vector<char*> args) { cerr << "\b\b "; }
    template <typename Head, typename... Tail>
    void debugg(vector<char*> args, Head H, Tail... T) {
        debug() << " [" << args.back() << ": " << H << "] ";
        args.pop_back(); debugg(args, T...);
    }
    #define harg(...) #__VA_ARGS__
    #ifndef ONLINE_JUDGE
    #define dbg(...) { debugg(tokenizer(harg(__VA_ARGS__, \b\t-->Line)), __VA_ARGS__, __LINE__); cerr << endl;}
    #else
    #define dbg(...) { }
    #endif
    /// -----------------------------------------------------------------------
     
    typedef long long ll;
    typedef vector<int> vi;
    typedef pair<int,int> pi;
    typedef vector<pi> vpi; 
    #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)    
    #define F first
    #define S second
    #define PB push_back
    #define EB emplace_back
    #define MP make_pair
    #define print(x) cout << x << "\n";
    #define REP(i,a,b) for(i=a;i<=b;i++)
    #define RAP(i,a,b) for(i=a;i>=b;i--)
    #define spa <<" "<<
    #define all(x) (x).begin(), (x).end()
    int mod=1000000007;
    const int MX=0x3f3f3f3f;
     
    
    long long binpow(long long a, long long b, long long m) {
        a %= m;
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
    }
    int main(){
        IOS;
        int n,k,i,j;
        cin>>n>>k;
        ll ans=0,temp,extra;
        vector<ll> dp(k+1,0);
        RAP(i,k,1){
            (dp[i]=binpow(k/i,n,mod))%=mod;
            extra=0;
            for(j=2*i;j<=k;j+=i) (extra+=dp[j])%=mod;
            dp[i]=(dp[i]-extra+mod)%mod;
        }  
        REP(i,1,k) (ans+=(i*dp[i])%mod)%=mod;
        cout<<ans;
        return 0;
    } 

Measured memory_bytes: 4000
n = int(input())
a = [int(num) for num in input().split(" ")]
q = int(input())
m = [int(num) for num in input().split(" ")]

def build_combinations(n, a):
    result = []
    decide_next(n, a, 0, 0, result)
    return result

def decide_next(n, a, i, sum, result):
    if i == n:
        result.append(sum)
        return
    # Choosing a[i]
    decide_next(n, a, i+1, sum + a[i], result)
    # Not choosing a[i]
    decide_next(n, a, i+1, sum, result)

combinations = build_combinations(n, a)

for i in m:
    flag = "no"
    for j in combinations:
        if i == j:
            flag = "yes"
            break
    print(flag)


Measured memory_bytes: 43092