akhauriyash/Code-Regression huggingface dataset:
/**
DufauX-XuafuD
**/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define reset(x) memset(x,-1,sizeof(x))
#define CheckBit(a,b) (a&(1ll<<b))
#define SetBit(a,b) a=(a|(1ll<<b))
#define UnSetBit(a,b) a=(a&(~(1ll<<b)))
#define maxx 10000006
#define PI 2*acos(0.0)
const long long INF = 2000000000000000000LL;	// 2e18
const int inf = 0x3f3f3f3f;	// 1061109567
const long double EPS = 1e-9;
//bitset<maxx/2>vis;
//bitset<maxx>pr;
//int mobi[maxx+10];
//vector<ll>prime;
//void sieve(){
//    ll x=maxx/2, y=sqrt(maxx)/2;
//    for(ll i=1;i<=y;i++){
//        if(vis[i]==0){
//            for(ll j=(i*(i+1)*2);j<x;j+=(2*i)+1)
//                vis[j]=1;
//        }
//    }
//    prime.push_back(2);
//    for(ll i=3;i<maxx;i+=2)
//        if(vis[i/2]==0)
//        prime.push_back(i);
//}
//void generate_mobius()
//{
//    for(int i=0;i<maxx;i++)mobi[i]=1;
//    for(int i=2;i<maxx;i++){
//        if(!pr[i]){
//            mobi[i]*=-1;
//            for(int j=i+i;j<maxx;j+=i){
//                pr[j]=1;
//                mobi[j]*=(j%(i*i)?-1:0);
//            }
//        }
//    }
//}
//bool isprime(ll a)
//{
//    if(a==1)return false;
//    if(a==2)return true;
//    if(a%2==0)return false;
//    for(ll i=0;i<prime.size() && prime[i]*prime[i]<=a;i++)
//        if(a%prime[i]==0)return false;
//    return true;
//}
/*Used path compression technique*/
/*-------------------------------------*/
//ll finds(ll a)
//{
//    vector<ll>vec;
//    while(parent[a]>0){
//        vec.pb(a);
//        a=parent[a];
//    }
//    for(int i=0;i<vec.size();i++)parent[vec[i]]=a;
//    return a;
//}
//void unions(ll a,ll b)
//{
//    parent[a]+=parent[b];
//    parent[b]=a;
//}
/*------------------------------*/
/* Calculate ( a*b ) %c */
inline ll mulmod(ll a, ll b, ll c) {
    ll ret = 0 , cur = a % c ;
    while(b) { if(b%2) ret=(ret+cur)%c; cur=(cur<<1)%c; b=b>>1; }
    return ret%c;
}
//Calculate (b^p)%m || modular inverse: b^-1 = bigmod(b, m-2, m)
inline ll bigmod(ll b, ll p, ll m){
    ll ret = 1, cur = b % m;
    while(p) { if(p&1) ret=(ret*cur)%m; cur=(cur*cur)%m; p=p>>1; }
    return ret;
}
inline ll modulo(ll a,ll b,ll c) { //Same as big mod, use for numbers over 1e10
    ll ret = 1 , cur = a%c ;
    while(b) { if(b%2) ret=mulmod(ret,cur,c); cur=mulmod(cur,cur,c); b=b>>1; }
    return ret%c ;
}
inline ll power(ll b, ll p){
    ll ret = 1, cur = b;
    while(p) { if(p&1) ret=(ret*cur); cur=(cur*cur); p=p>>1; }
    return ret;
}
ll lcm(ll a,ll b)
{
    return (a/__gcd(a,b))*b;
}
ll gcd(ll a,ll b)
{
    return __gcd(a,b);
}
void Dufaux()
{
    ll n;
    cin>>n;
    ll mul=1;
    while(mul*2<=n){
        mul*=2;
    }
    cout<<mul<<endl;
}
int main()
{
    FastIO;
	///sieve();
	///generate_mobius();
	int test=1;
	while(test--){
        Dufaux();
	}
	return 0;
}





Measured memory_bytes: 3636
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

int main(void){
    int N, Y, result[] = {0, 0, 0}, value = 0;

    scanf("%d%d", &N, &Y);

    result[1] = N;

    while (true){
        value = result[0] * 10000 + result[1] * 5000 + result[2] * 1000;
        if(value == Y){
            break;
        }
        else if(value < Y){
            result[0] ++;
            result[1] --;
        }
        else{
            result[2] ++;
            result[1] --;
        }
    }


    if(result[0] < 0 || result[1] < 0 || result[2] < 0){
        cout << "-1 -1 -1" << endl;
        return 0;
    }

    cout << result[0] << " " << result[1] << " " << result[2] << endl;
    return 0;
}

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

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()

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


const int MAX_N = 1 << 18;

// [1, n]
// BIT is initialized by zeros
// !!initialize the size ""n""!!
int bit[MAX_N + 1], n, q;

// get sum in [1, i]
// sum{[i, j]} = sum{[1, j]} - sum{[1, i-1]}
int sum(int i) {
    int s = 0;
    while (i > 0) {
        s += bit[i];
        i -= i & -i;
    }
    return s;
}

// add x to bit[i]
void add(int i, int x) {
    while (i <= n) {
        bit[i] += x;
        i += i & -i;
    }
}

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

    cin >> n;
    vector<int> a(n);
    vector<P> b(n);
    rep(i, n) {
        cin >> a[i];
        b[i] = P(a[i], i);
    }

    sort(all(b));
    rep(i, n) {
        a[b[i].second] = i + 1; // compress a[] to 1, 2, ...
    }

    reverse(all(a));
    ll ans = 0;
    rep(i, n) {
        ans += sum(a[i] - 1);
        add(a[i], 1);
    }

    cout << ans << endl;
}

Measured memory_bytes: 6040
#include <algorithm>
#include <climits>
#include <cmath>
#include <csignal>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <queue>
#include <string>
#include <vector>

using ll = long long;
using namespace std;

int main() {
    int n = 0;
    cin >> n;
    vector<double> v(n);
    for (int i=0; i<n; i++) {
        cin >> v.at(i);
    }
    sort(v.begin(), v.end());
    double ans = v.at(0);
    for (int i=1; i<n; i++) {
        ans = (ans + v.at(i)) / 2;
    }
    cout << fixed;
    cout << setprecision(10) << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<pint> vpint;
#define mp make_pair
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)

int cnt;
vector<int> v;//?´???°??§???????´???°??§???????????°?????\????????????


//???????????????
void print(int num){
	printf("%d:", num);
	for (int i = 0; i < v.size(); ++i){
		printf(" %d", v[i]);
	}
	printf("\n");
	return;
}


//???????´???°????´???°????????????????¢??????????
void check(int yakusu){
	for (int i = 6; i < yakusu; i += 7){
		if (yakusu % i == 0) return;
	}
	for (int i = 8; i < yakusu; i += 7){
		if (yakusu % i == 0) return;
	}

	v.push_back(yakusu);//?´???°??§?????£????????§??\??????
	return;
}

void slove(int num){
	//?´???°??§??????????????¢????????????????´???°??§????????????check()??¢??°??§?´???°????????????????????????
	for (int i = 6; i<= num; i += 7){
		if (num % i == 0) check(i);
		if (num % (i + 2) == 0) check(i + 2);
	}
	return;
}

int main(void){
	int n;
	rep(i, 10000000){
		scanf("%d", &n);
		if(n == 1) break;
		slove(n);
		print(n);
		v.clear();//v?????°?????????????????°?????\??£??????????????§???????????§?????????????????¨???????????????
	}	

	return 0;
}

Measured memory_bytes: 3248
n,k=map(int,input().split())
l=list(map(int,input().split()))
a=[0]*42
for i in range(n):
    p=l[i]
    j=0
    while p>0:
        a[j]+=p%2
        p=p//2
        j+=1
ans=0
for i in range(41,-1,-1):
    if a[i]<n-a[i]:
        if k>=2**i:
            k-=2**i
            ans+=(2**i)*(n-a[i])
        else:
            ans+=(2**i)*a[i]
    else:
        ans+=(2**i)*a[i]
print(ans)


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

long long n,ans,m;
inline long long cal(long long x,long long y)
{	
	if(x>y)
	swap(x,y);
	if(y%x==0)
	return (2*(y/x)-1)*x;
	return 2*(y/x)*x+cal(y%x,x);
}
int main()
{
	scanf("%lld%lld",&n,&m);
	printf("%lld\n",n+cal(n-m,m));
	return 0;
}

Measured memory_bytes: 764
import os
import sys

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7

S = list(sys.stdin.readline().rstrip())
T = list(sys.stdin.readline().rstrip())
Q = int(sys.stdin.readline())
A, B, C, D = list(zip(*[map(int, sys.stdin.readline().split()) for _ in range(Q)]))
A = np.array(A, dtype=int)
B = np.array(B, dtype=int)
C = np.array(C, dtype=int)
D = np.array(D, dtype=int)

S = np.array(['.'] + S)
T = np.array(['.'] + T)

SA = (S == 'A').cumsum()
SB = (S == 'B').cumsum()
TA = (T == 'A').cumsum()
TB = (T == 'B').cumsum()

sa = SA[B] - SA[A - 1]
sb = SB[B] - SB[A - 1]
ta = TA[D] - TA[C - 1]
tb = TB[D] - TB[C - 1]
ans = np.full(Q, 'NO', dtype='U3')
ans[(sa - sb) % 3 == (ta - tb) % 3] = 'YES'
print(*ans, sep='\n')


Measured memory_bytes: 87872
#include <bits/stdc++.h>
typedef long long ll;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
	
using namespace std;
const int MAX_N=3e5,INF=1e8;
int N,A,B;
vector<int> ans;
int main(){
	bool f=false;
	cin>>N>>A>>B;
	if (A>B){
		f=true;
		swap(A,B);
	}
	if ((ll)N<=(ll)A*B && A+B<=N+1){
		int b=0;
		REP(i,N){
			if (N-i+b==B){
				FOR(j,i,N){
					ans.push_back(-INF-j);
				}
				break;
			}else{
				if (i%A==0){
					b++;
				}
				ans.push_back(-A*b+i%A);
			}
		}
		{
			vector<int> x(ans);
			sort(x.begin(),x.end());
			REP(i,N){
				ans[i]=lower_bound(x.begin(),x.end(),ans[i])-x.begin()+1;
			}
		}
		if (f){
			reverse(ans.begin(),ans.end());
		}
		REP(i,N){
			if (i)cout<<" ";
			cout<<ans[i];
		}
		cout<<endl;
	}else{
		cout<<-1<<endl;
	}
	return 0;
}

Measured memory_bytes: 3548
X = int(input())
A = list(map(int, input().split()))


count = 0
for i in range(len(A)):
    for j in range(i+1,len(A)):
        for k in range(j+1,len(A)):
            #print(i,j,k)
            tmp = sorted([A[i],A[j],A[k]])
            if (tmp[2]<tmp[0]+tmp[1])and (tmp[0]<tmp[1]<tmp[2]) :
                count+=1


print(count)

Measured memory_bytes: 8916
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+10;
int n,nn,mm,tot;
struct Ipoint{
	int x,y,e,id;
	Ipoint(int a=0,int b=0,int c=0,int d=0){
		x=a,y=b,e=c,id=d;
	}
}point[N<<1];
int gete(int x,int y){ //返回点所在的边，注意顶点的情况 
	int ans;
	if(!x&&y<mm) ans=1;
	else if(y==mm&&x<nn) ans=2;
	else if(x==nn&&y) ans=3;
	else ans=4;
	return ans;
}
int cmp(Ipoint a,Ipoint b){
	int ea=a.e,eb=b.e;
	if(ea!=eb) return ea<eb;
	if(ea==1) return a.y<b.y;
	if(ea==2) return a.x<b.x;
	if(ea==3) return a.y>b.y;
	if(ea==4) return a.x>b.x;
}
bool pd(int x,int y){
	if(!x||!y||x==nn||y==mm) return 1;
	return 0;
}
int sta[N<<1],top;
int main(){
	int t1,t2,t3,t4;
	scanf("%d%d%d",&nn,&mm,&n);
	for(int i=1;i<=n;i++){
		scanf("%d%d%d%d",&t1,&t2,&t3,&t4);
		if(pd(t1,t2)&&pd(t3,t4)) point[++tot]=Ipoint(t1,t2,gete(t1,t2),i),point[++tot]=Ipoint(t3,t4,gete(t3,t4),i);
	}
	sort(point+1,point+tot+1,cmp);
	for(int i=1;i<=tot;i++){
		sta[top++]=point[i].id;
		if(sta[top-1]==sta[top-2]&&top>1) top-=2;
	}
	if(top) printf("NO\n");
	else printf("YES\n");
	return 0;
}

Measured memory_bytes: 3712
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,c;
    cin>>n>>c;
    int wt[n];
    int val[n];
    for (int i=0;i<n;i++)
    {
        cin>>wt[i];
        cin>>val[i];
    }
    long long dp[n][c+1];
    for (int i=0;i<n;i++)
    {
        for (int j=0;j<=c;j++)
        {
            if (j==0) dp[i][j] = 0;
            else if (i==0) {
                dp[i][j] = j<wt[0]?0:val[0];
            }
            else {
                dp[i][j] = j<wt[i] ? dp[i-1][j] : max(dp[i-1][j] , val[i]+dp[i-1][j-wt[i]]);
            }
        }
    }
    cout<<dp[n-1][c];
}

Measured memory_bytes: 78336
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int main() {
	string a, b;
	cin >> a >> b;
	int s = stoi(a + b);
	for (int i = 0; i <= 1000; i++) {
		if (s == i * i) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
	int y;
	cin >> y;
}

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

using namespace std;

int main() {
  int N, s{};
  cin >> N;
  vector<int> A(N + 2);
  for (int i = 1; i <= N; ++i) {
    cin >> A[i];
    s += abs(A[i] - A[i - 1]);
  }
  s += abs(A[N]);
  for (int i = 1; i <= N; ++i) {
    cout << s + abs(A[i + 1] - A[i - 1]) - abs(A[i + 1] - A[i]) -
                abs(A[i] - A[i - 1])
         << endl;
  }
}


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

int main(){
  int n;
  while(cin >> n, n){
    int ans = 1;
    for(int i = 2;i*i < n; i++){
      if(n%i == 0){
	ans += i;
	if(n/i != i)ans += n/i;
      }
    }
    if(n != 1 && ans == n){
      cout << "perfect number" << endl;
    }else if(ans > n){
      cout << "abundant number" << endl;
    }else{
      cout << "deficient number" << endl;
    }
  }
  return 0;
}

    

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

#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define RFOR(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define LL long long
#define INF INT_MAX/3

const double EPS = 1e-14;
const double PI  = acos(-1.0);


int main(){
  LL n, p;
  cin >> n >> p;

  int v[1000010];
  REP (i, 1000010) v[i] = 0;

  if (n == 1) {
    cout << p << endl;
    exit(0);
  }

  int i = 2;
  while(p > 1 && i < 1000010) {
    if (p % i == 0) {
      p /= i;
      v[i]++;
      continue;
    }
    i++;
  }
  LL ans = 1;

  REP (i, 1000010) {
    if (v[i] >= n)
      ans *= pow(i ,(v[i] / n));
  }

  cout << ans << endl;
}


Measured memory_bytes: 4096
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
from bisect import bisect

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

S = input()
print(700+100*S.count("o"))


Measured memory_bytes: 5148
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n); for(int i = 0;i < (int)(n);i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
int main(){
    int a,b,c,d;
    cin >> a >> b >> c >>d;
    int x = c-a;
    int y = d-b;
    rep(i,x)cout << "R";
    rep(i,y)cout << "U";
    rep(i,x)cout << "L";
    rep(i,y)cout << "D";
    cout << "D";
    rep(i,x+1)cout << "R";
    rep(i,y+1)cout << "U";
    cout << "L";
    cout << "U";
    rep(i,x+1)cout << "L";
    rep(i,y+1)cout << "D";
    cout << "R";
    cout << endl;
    return 0;
}

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

// clang-format off
template <typename T> T gcd(T a, T b) { return b == 0 ? a : gcd(b, a % b); }
template <typename T> T lcm(T a, T b) { return a * b / gcd(a, b); }
template <typename T> T clamp(T val, T min, T max) { return val < min ? min : (max < val ? max : val); }
char capitalize(char c) { return static_cast<char>(std::toupper(static_cast<unsigned char>(c))); }
// template <typename T> size_t max_index(T begin, T end) { return distance(begin, max_element(begin, end)); }
// template <typename T> size_t min_index(T begin, T end) { return distance(begin, min_element(begin, end)); }
// clang-format on

#define int long long
#define YES "YES"
#define NO  "NO"
#define MOD 1000000000+7
#define forit(v) for(auto it = v.begin(); it != v.end(); ++it)

using namespace std;

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

  int num = 0;
  // num = numeric_limits<int>::max();
  // num = numeric_limits<int>::min();
  // bool flag = false;
  // flag = true;

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

  while(true) {
    bool flag = true;
    for (auto it = a.begin(); it != a.end(); ++it) {
      if (*it % 2 == 0) *it /= 2;
      else flag = false;
      if (!flag) break;
    }
    if (!flag) break;
    ++num;
  }
  
  cout << num << endl;
  // cout << (flag ? YES : NO) << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using PII = pair<int, int>;
#define FI(i, a, b) for (int i = (a); i <= (b); ++i)
#define FD(i, b, a) for (int i = (b); i >= (a); --i)
#define DEBUG(x) cerr << #x << ": " << (x) << endl;

int main() {
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<string> a(n);
  FI(i, 0, n - 1) cin >> a[i], sort(a[i].begin(), a[i].end());
  LL ans = 0;
  unordered_map<string, int> mp;
  for (int i = 0; i < n; i++) {
    ans += mp[a[i]]++;
  }
  cout << ans << endl;
}


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

int main() {
    ll N; cin >> N;
    ll ans= 0LL;
    ll mod = 1000000007LL;

    ll a=1;
    for (ll i = 0; i < N;i++) {
        a *= 10;
        a %= mod;
    }
    ans += a; ans %= mod;

    ll b=1;
    for (ll i = 0; i < N;i++) {
        b *= 9;
        b %= mod;
    }
    ans -= 2 * b; ans %= mod;

    ll c=1;
    for (ll i = 0; i < N;i++) {
        c *= 8;
        c %= mod;
    }
    ans += c; ans %= mod;

    ans = (ans + mod) % mod ;

    cout << ans << endl;
}

Measured memory_bytes: 3596
import java.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Main {
// Mainに書き換え！

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        // 整数の入力
        int len = Integer.parseInt(sc.next());
        String str = sc.next();

        Pattern dupPattern = Pattern.compile("([ \\w]+)\\1", Pattern.CASE_INSENSITIVE);
        Matcher matcher = dupPattern.matcher(str);

        while (matcher.find()) {
            str = str.replaceAll("([ \\w]+)\\1", "$1");
        }
        //System.out.println(str);

        if ((len != str.length())&&(len % str.length()) == 0) {
            System.out.println("Yes");

        }else{
            System.out.println("No");

        }

    }
}

Measured memory_bytes: 21844
import java.util.Scanner;

public class Main{
	private static Scanner scan;
	public static void main(String[] args) {
		scan = new Scanner(System.in);
		String a[] = new String[1000];
		int n = 0;
		while(scan.hasNext()){
			a[n] = scan.next();
			n++;
		}
		
		String m = 	"";
		int max = 0;
		String w = null;
		for(int i = 0;i < n;i++){
			int c = 0;
			if(m.length() < a[i].length()){
				m = a[i];
			}
			for(int j = 0;j < n;j++){
				if(a[i].equals(a[j])){
					c++;
				}
			}
			if(max < c){
				max = c;
				w = a[i];	
			}	
		}
		System.out.println(w + " " + m);
	}

}

Measured memory_bytes: 12000
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;

namespace MyProject
{
    class Program
    {
        static void Main(string[] args)
        {
#if Local
            var sw = new Stopwatch();
            sw.Start();
            Console.SetIn(new StreamReader("input.in"));
#endif

            var solver = new Solver();
            solver.Solve();
#if Local
            Console.WriteLine($"{sw.ElapsedMilliseconds}ms");
#endif
        }
    }

    class Solver
    {
        public void Solve()
        {
            var item = Console.ReadLine().Split().Select(elem => long.Parse(elem)).ToArray();
            var A = item[0];
            var B = item[1];
            var K = item[2];

            if (A < K)
            {
                K -= A;
                A = 0;
                if (B < K)
                {
                    B = 0;
                }
                else
                {
                    B -= K;
                }
            }
            else
            {
                A -= K;
            }

            Console.WriteLine($"{A} {B}");
        }
    }
}


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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}

const int MAX_N = 112345;
int A[MAX_N];
int B[MAX_N];

int main2() {
  int N = nextInt();
  REP(i, N+1) A[i] = nextInt();
  REP(i, N) B[i] = nextInt();

  ll ans = 0;
  for (int i = 0; i < N; i++) {
    int d = min(A[i], B[i]);
    ans += d;
    A[i] -= d;
    B[i] -= d;
    int e = min(B[i], A[i+1]);
    ans += e;
    A[i+1] -= e;
    B[i] -= e;

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

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}


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

using namespace std;

int main()
{
    int N;
    long long K;
    cin >> N >> K;
    vector<int> a(N);
    vector<int> f(N);
    for (int i = 0; i < N; i++)
        cin >> a[i];
    for (int i = 0; i < N; i++)
        cin >> f[i];

    sort(a.begin(), a.end());
    sort(f.rbegin(), f.rend()); //降順
    long long l = -1, r = 1e12; // 左と右
    long long p;                //ピボット
    while (l + 1 < r)
    {
        p = (l + r) / 2;
        bool ok = [&] {
            long long s = 0;
            for (int i = 0; i < N; i++)
            {
                s += max(0ll, a[i] - p / f[i]);
            }
            return s <= K;
        }();
        if (ok)
            r = p;
        else
            l = p;
    }
    cout << r << endl;
}

Measured memory_bytes: 1792
from collections import deque
import copy

H,W=map(int,input().split())
MAP=[list(input()) for y in range(H)]

def Maze(_x, _y):
  MAP2=copy.deepcopy(MAP)
  q=deque([[_x,_y]])
  MAP2[_y][_x]=0
  while q:
    xy=q.popleft()
    for d in [(0,-1),(-1,0),(0,1),(1,0)]:
      x2,y2=xy[0]+d[0],xy[1]+d[1]
      if x2<0 or y2<0 or x2>=W or y2>=H:
        continue
      if MAP2[y2][x2]=='.':
        q.append([x2,y2])
        MAP2[y2][x2]=MAP2[xy[1]][xy[0]]+1
  
  maxM=0
  for y in range(H):
    for x in range(W):
      if type(MAP2[y][x])==int:
        maxM=max(maxM, MAP2[y][x])
  return maxM
  

ans=0
for y in range(H):
  for x in range(W):
    if MAP[y][x]=='.':
      ans=max(ans, Maze(x,y))
print(ans)

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

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
#define hash dhsjakhd
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef long double ld;

ll n,m,T,k,q;

ll even[200001] = {0};
ll odd[200001] = {0};
ll A[200001] = {0};

ll ev(ll i){
    if(i == 0)return 2;
    return i%2;
}

ll od(ll i){
    return (i+1)%2;
}

ll val(ll i, ll state){
    if(state == 0 || state == 4)return A[i];
    if(state == 2)return odd[i];
    return even[i];
}

ll DP[200001][5] = {0};
bool DPC[200001][5] = {0};

ll dp(ll i, ll state){
    if(i == n)return 0;
    if(DPC[i][state])return DP[i][state];
    ll ans = val(i,state) + dp(i+1,state);
    if(state < 4)ans = min(ans, dp(i,state+1));
    DPC[i][state] = 1;
    DP[i][state] = ans;
    return ans;
}


int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    //freopen("input.txt","r",stdin);
    //freopen("autput.txt","w",stdout);
    ll a,b,c;

    cin >> n;
    for(int c1 = 0; c1 < n; c1++){
        cin >> A[c1];
        even[c1] = ev(A[c1]);
        odd[c1] = od(A[c1]);
    }

    ll ans = dp(0,0);
    cout << ans << "\n";

    return 0;
}


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

int main() {
  ll sum = 0,m = 1e9;
  int nc = 0,n;
  bool zf = false;
  cin >> n;
  vector<ll>a(n);
  rep(i,n){
    cin >> a[i];
    sum += abs(a[i]);
    m = min(abs(a[i]),m);
    if(a[i] < 0) nc++;
    if(a[i] == 0) zf = true;
  }
  if(zf || nc%2 == 0) cout << sum << endl;
  else cout << sum-2*m << endl;
}

Measured memory_bytes: 1152
import numpy as np
from fractions import gcd
def lcm(a,b):
  return a*b//gcd(a,b)
N,M=map(int,input().split())
a=[i//2 for i in map(int,input().split())]
b=np.array(a)
cnt=0
while all(b%2==0):
  b//=2
if any(b%2==0):
  print(0)
  exit()
ans=1
for i in a:
  ans=lcm(ans,i)
print((M//ans-1)//2+1)

Measured memory_bytes: 25016
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<(int)(n);i++)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
template<typename T> ostream& operator<<(ostream& os,const set<T>& st){ os<<"{"; for(T v:st) os<<v<<","; os <<"}"; return os; }
template<typename T,typename U> inline void chmax(T &x,U y){ if(y>x) x = y; }
template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

int main(){
    double t,x; cin >> t >> x;

    cout << Double(t/x) << endl;
}


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

ll powll(ll a,ll n){
  if(n==0)
  {
    return 1;
  }
  return powll(a,n-1)*a;
}

ll dic[5000][5000],k[5000];
int main() {
   ll i,j;
   ll n,x,y;
   cin >>n>>x>>y;
   for(i=1; i<=n; i++)
   {
     k[i]=0;
   }

   for(i=1; i<=n; i++)
   {
     for ( j = 1; j <= n; j++)
     {
       dic[i][j]=abs(j-i);
       k[abs(j-i)]+=1;
     }
   }

   k[dic[x][y]]-=2;
   k[1]+=2;
   dic[x][y]=1;
   dic[x][y]=1;
   for(i=1; i<=n-1; i++)
   {
     for(j=i+1; j<=n; j++)
     {
       ll xyr=dic[i][x]+dic[x][y]+dic[y][j];
       ll yxr=dic[i][y]+dic[y][x]+dic[x][j];
       ll minnum=min(xyr,yxr);
       if(dic[i][j]>minnum)
       {
         k[dic[i][j]]-=2;
         k[minnum]+=2;
         dic[i][j]=minnum;
         dic[j][i]=minnum;
        //  cout <<minnum<<' '<<i<<' '<<j<<endl;
       }
     }
   }

   for(i=1; i<=n-1; i++)
   {
     cout<< k[i]/2 <<endl;
   }
   
}

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

#include <cstdio>

using namespace std;

const int MAX_W = 103, MAX_H = 103;

int W, H;
char G[MAX_H][MAX_W];
int res;
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};

void dfs(int x,int y){
    char c = G[x][y];
    G[x][y] = '!'; //一定要把dfs过的点标成不能再访问,否则会回来

    for(int i = 0;i < 4;i++){
        int nx = x + dx[i], ny = y + dy[i];
        if(0<=nx && nx<H && 0<=ny && ny<W && G[nx][ny] == c)
            dfs(nx, ny);

    }
}

void solve(){
    res = 0;
    for(int i = 0;i < H;i++){
        for(int j = 0;j < W;j++){
            if(G[i][j] != '!'){
                dfs(i, j);
                res++;
            }
        }
    }
    printf("%d\n", res);
    return;
}

int main(){
    while(~scanf("%d %d",&H, &W)){
        if(W == 0&& H == 0) break;
        for(int i = 0;i < H;i++){
            scanf("%s", G[i]);
        }
        solve();
    }
    return 0;
}


Measured memory_bytes: 3144
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		while(true){
			int n = sc.nextInt();
			if(n==0) break;
			
			double[][] xy = new double[n][2];
			for(int i=0;i<n;i++){
				String[] s = sc.next().split(",");
				xy[i][0] = Double.valueOf(s[0]);
				xy[i][1] = Double.valueOf(s[1]);
			}
			
			Arrays.sort(xy, new Comparator<double[]>(){
				public int compare(double[] o1, double[] o2) {
					if(o1[0]==o2[0]){
						if(o1[1]-o2[1]>0) return 1;
						else return -1;
					}else{
						if(o1[0]-o2[0]>0) return 1;
						else return -1;
					}
				}
			});
			
			int z = 0;
			int zz = 0;
			int cnt = 0;
			
			double a = Double.MAX_VALUE;
			double b, c;
			boolean flag;
			while(true){
				flag = false;
				b = -Double.MAX_VALUE;
				for(int i=z+1;i<n;i++){
					if(xy[z][0]==xy[i][0]) c = Double.MAX_VALUE;
					else c = (xy[z][1]-xy[i][1])/(xy[z][0]-xy[i][0]);
					
					if(b<c && c<=a){
						b = c;
						zz = i;
						flag = true;
					}
				}
				a = b;
				z = zz;
				cnt++;
				if(flag==false) break;
			}
			
			a = Double.MAX_VALUE;
			while(true){
				flag = false;
				b = -Double.MAX_VALUE;
				for(int i=z-1;i>=0;i--){
					if(xy[z][0]==xy[i][0]) c = Double.MAX_VALUE;
					else c = (xy[z][1]-xy[i][1])/(xy[z][0]-xy[i][0]);
					
					if(b<c && c<=a){
						b = c;
						zz = i;
						flag = true;
					}
				}
				a = b;
				z = zz;
				cnt++;
				if(flag == false) break;
			}
			
			System.out.println(n-cnt+2);
		}	
	}	
}

Measured memory_bytes: 17276
import java.util.*;
import java.math.*;
public class Main{
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int m=sc.nextInt();
		ArrayList<State>[] map=new ArrayList[n];
		map[0]=new ArrayList<>();
		for(int i=n-1; i>=1; i--){
			map[i]=new ArrayList<>();
			map[i].add(new State(i-1,0));
		}
		for(int i=0; i<m; i++){
			int l=sc.nextInt()-1;
			int r=sc.nextInt()-1;
			long c=sc.nextLong();
			map[l].add(new State(r,c));
		}
		PriorityQueue<State> q=new PriorityQueue<>();
		long[] dist=new long[n];
		Arrays.fill(dist,-1);
		q.add(new State(0,0));
		while(!q.isEmpty() && dist[n-1]==-1){
			State s=q.poll();
			if(dist[s.l]!=-1){
				continue;
			}
			dist[s.l]=s.c;
			for(State ss:map[s.l]){
				if(dist[ss.l]==-1){
					q.add(new State(ss.l,ss.c+s.c));
				}
			}
		}
		System.out.println(dist[n-1]);
	}
	static class State implements Comparable<State>{
		int l;
		long c;
		State(int l,long c){
			this.l=l;
			this.c=c;
		}
		@Override
		public int compareTo(State o){
			return Long.compare(this.c,o.c);
		}
	}
}


Measured memory_bytes: 111292
#include<iostream>
#define MAX_K 2 * 100001
using namespace std;
typedef long long ll;

ll mod_count[MAX_K];

int main() {
    int N, K;
    ll all_count = 0;
    cin >> N >> K;
    for (int i = 0; i <= N; i++) mod_count[i] = 0;
    for (int i = 1; i <= N; i++) {
        mod_count[i % K]++;
    }
    for (int i = 1; i < K; i++) {
        if (i == (K - i)) all_count += mod_count[i] * mod_count[i] * mod_count[i];
    }
    all_count += mod_count[0] * mod_count[0] * mod_count[0];
    cout << all_count << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll N;
int a[200000];

int main(void){
    // Your code here!
    cin >> N;
    if(N%2==1) {
        cout << 0 << endl;
        return 0;
    }
    
    ll start = 10;
    ll cnt = 0;
    while(true){
        if(start > N) break;
        cnt += N/start;
        start *= 5;
    }
    
    cout << cnt << endl;
}


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

int main() {
long long int a,b,c;
cin>>a>>b>>c;
a%=12;
for(long long int i=0;i<a;i++){
if(i%2==0){
b=b-c;
}
else{
c=b+c;
}
}
cout<<b<<" "<<c<<endl;
}



Measured memory_bytes: 3108
/*
Author : Xinyuan
*/
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define REP(i, n) for(int i = 0; i < n; i++)
#define INF 1000000007
#define mod 1005
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef long long int  ll;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
int nxt() {int x;scanf("%d", &x);return x;}


int main(){
    int n, m;
    cin >> n >> m;
    VVI adjList(n);
    for (int i = 0; i < m; i+=1){
        int a = nxt(), b = nxt();
        a--;b--;
        adjList[a].push_back(b);
        adjList[b].push_back(a);
    }
    VI dist(n, INF), parent(n, -1);
    dist[0] = 0;
    queue<PII> q; q.push({0, 0});
    while(!q.empty()){
        int d = q.front().first, u = q.front().second;
        q.pop();
        if(d > dist[u]) continue;
        d = dist[u];
        for(int v : adjList[u]){
            if(dist[u] + 1 < dist[v]){
                dist[v] = dist[u] + 1;
                parent[v] = u;
                q.push({dist[v], v});
            }
        }
    }
    bool possible = true;
    for (int i = 0; i < n; i+=1){
        if(dist[i] == INF) possible = false;
    }
    if(possible){
        printf("Yes\n");
        for (int i = 1; i < n; i+=1){
            printf("%d\n", parent[i] + 1);
        }
    }
    else printf("No\n");
    return 0;
}



Measured memory_bytes: 10960
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0590

"""
import sys
from sys import stdin
input = stdin.readline


def main(args):
    # https://www.ioi-jp.org/joi/2005/2006-m2-prob_and_sol/2006-m2-t4-review.html
    invalid_room = 0

    R = int(input())
    for _ in range(R):
        area = int(input())
        valid = False
        x = 1
        while 2 * (x**2 + x) <= area:
            if (area - x) % (2*x + 1) == 0:
                valid = True
                break
            x += 1
        if valid is False:
            invalid_room += 1

    print(invalid_room)


if __name__ == '__main__':
    main(sys.argv[1:])

Measured memory_bytes: 7776
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<bitset>
#include<deque>
#include<functional>
#include<iterator>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<utility>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define a first
#define b second
#define sz(x) (ll)((x).size())
#define pb push_back
#define mp make_pair
#define bg begin()
#define ed end()
#define all(x) (x).bg,(x).ed
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep1(i,n) for(ll i=1;i<=(n);i++)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(ll i=(n);i>=1;i--)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
const ll MOD=1000000007;
const ll INF=1000000000000000;
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;}
ll maxx(ll x,ll y,ll z){return max(max(x,y),z);}
ll minn(ll x,ll y,ll z){return min(min(x,y),z);}
ll gcd(ll x,ll y){if(x%y==0) return y;else return gcd(y,x%y);}
ll lcm(ll x,ll y){return x*(y/gcd(x,y));}
ll digsz(ll x){if(x==0) return 1;else{ll ans=0;while(x){x/=10;ans++;}return ans;}}
ll digsum(ll x){ll sum=0;while(x){sum+=x%10;x/=10;}return sum;}
vector<ll> pw2(62,1);vector<ll> pw10(19,1);

int main(){
    {rep1(i,61) pw2[i]=2*pw2[i-1];}
    {rep1(i,18) pw10[i]=10*pw10[i-1];}
    
    ll N,K; cin>>N>>K;
    vector<ll> X(N+1);
    rep1(i,N) cin>>X[i];
    
    ll ans=INF;
    rep1(i,N-K+1){
        chmin(ans,abs(X[i]-X[i+K-1])+min(abs(X[i]),abs(X[i+K-1])));
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 4052
#![allow(non_snake_case)]

use std::io::{stdin, Read};
use std::str::FromStr;
fn read_option<T: FromStr>() -> Option<T> {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok()
}
fn read<T: FromStr>() -> T {
    let opt = read_option();
    opt.expect("failed to parse token")
}

fn main() {
    let H: usize = read();
    let N: usize = read();
    use std::collections::HashMap;
    let mut magics: HashMap<usize, usize> = HashMap::new();
    for _ in 0..N {
        let a: usize = read();
        match magics.get(&a) {
            Some(&org) => magics.insert(a, std::cmp::min(org, read())),
            None => magics.insert(a, read()),
        };
    }
    let mut dp = vec![10_usize.pow(10); H + 10];
    dp[0] = 0;
    for i in 0..H {
        let now = dp[i];
        for (attack, power) in &magics {
            let nextIndex = if i + attack > H { H } else { i + attack };
            dp[nextIndex] = std::cmp::min(dp[nextIndex], now + power);
        }
    }
    println!("{}", dp[H]);
}


Measured memory_bytes: 2276
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	double a=0,b=0;
	for(int i=1;i<=n;i++)
		if(i%2==1)
			a++;
		else\
			b++;
		printf("%.8lf\n",a/(a+b));
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a[200001];
int main()
{
	int n,j=0;
	long long sum=0,xorsum=0,s=0;
	cin>>n;
	for(int i=1;i<=n;i++) cin>>a[i];
	for(int i=1;i<=n;i++)
	{   
	    while(j+1<=n&&(xorsum^a[j+1])==sum+a[j+1])
	    {
		    sum=sum+a[j+1];
		    xorsum=xorsum^a[j+1];
		    j++;
	    }
	    s=s+j-i+1;
		sum=sum-a[i];	
		xorsum=xorsum^a[i];	
	}
	cout<<s;
}

Measured memory_bytes: 1152
I, O, T, J, L, S, Z = map(int,input().split())
ans = (I // 2) * 2 + (J // 2) * 2 + (L // 2) * 2 + O
if I > 0 and J > 0 and L > 0:
    ans = max(ans, ((I - 1) // 2) * 2 + ((J - 1) // 2) * 2 + ((L - 1) // 2) * 2 + O + 3)
print(ans)

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

using namespace std;

int main(){
  int N;
  cin >> N;
  
  vector<char> S;
  char s;
  for(int i = 0;i < N;i++){
	cin >> s;
    S.push_back(s);
  }
  sort(S.begin(),S.end());
  S.erase(unique(S.begin(),S.end()),S.end());
  
  string value[] = {"One","Two","Three","Four"};
  cout << value[S.size() - 1] << endl;
}

Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
#include <sstream>
#include <iomanip>
#include <set>
#include <stack>
#include <cassert>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vvb> vvvb;
typedef vector<vvvb> vvvvb;
typedef vector<string> vs;
typedef vector<vs> vvs;
typedef vector<vvs> vvvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<vvd> vvvd;
typedef pair<ll, ll> PL;
typedef vector<PL> vpl;
typedef vector<vector<PL>> vvpl;
const int INF = 1001001001;
const ll LINF = 1e17;
const double pi = 3.1415926535897932;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define RFOR(i, a, b) for(ll i = (a); i > b; i--)
#define rep(i, n) for(ll i = 0; i < n; i++)
#define rrep(i, n) for(ll i = n-1; i > -1; i--)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)
#define ff first
#define ss second
#define pb push_back
#define epb emplace_back
#define ALL(X) (X).begin(),(X).end()

template <typename T>
T gcd(T a, T b) {
    return (a == 0) ? b : gcd(b%a, a);
}
template <typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

bool p_comp_fs(const PL p1, const PL p2){ return p1.first < p2.first;};
bool p_comp_fg(const PL p1, const PL p2){ return p1.first > p2.first;};
bool p_comp_ss(const PL p1, const PL p2){ return p1.second < p2.second;};
bool p_comp_sg(const PL p1, const PL p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec){
    sort(ALL(vec));
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}

inline ll popcnt(ll x){return __builtin_popcountll((unsigned long long)x);};
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
//friend bool operator<(const stc& lhs, const stc& rhs){
//    return std::tie(lhs.l, lhs.r) < std::tie(rhs.l, rhs.r);
//}



int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    ll N, K, Q; cin >> N >> K >> Q;
    vl cnt(N, 0);
    rep(i, Q){
        ll a; cin >> a; a--; cnt[a]++;
    }
    
    vl rem(N, K);
    rep(i, N){
        ll sub = Q-cnt[i];
        rem[i] -= sub;
    }
    
    rep(i, N){
        cout << (rem[i] > 0 ? "Yes" : "No") << endstr;
    }
    return 0;
}


Measured memory_bytes: 2176
import java.util.*;

public class Main {
    public static void main(String[] args){
    	Scanner scan = new Scanner(System.in);
    	int n = scan.nextInt();
    	String s = scan.next();
    	int ans = 0;
    	for (int i=1;i < n;i++) {
    		int cnt = 0;
    		String x = s.substring(0, i);
    		String y = s.substring(i, n);
    		
    		Set<Character> xSet = new HashSet<>();
    		for (char c : x.toCharArray()) xSet.add(c);
    		Set<Character> ySet = new HashSet<>();
    		for (char c : y.toCharArray()) ySet.add(c);
    		for (char c : ySet) if (xSet.contains(c)) cnt++;
    		if (cnt > ans) ans = cnt;
    	}
    	System.out.println(ans);
    }
}

Measured memory_bytes: 22996
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(a) (a).begin(), (a).end()
#define sort(a) sort(all(a))
using P = pair<int, int>;
using ll = long long;
using ld = long double;
typedef vector<int> vi;
int dx[4] = { 0, 1, 0,-1 };
int dy[4] = { 1, 0,-1, 0 };
const ll MOD = 1000000007;

signed main() {
  char s;
  cin >> s;
  if(isupper(s)) {
    cout << "A" << endl;
  } else {
    cout << "a" << endl;
  }
  return 0;
}

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

#define fast ios::sync_with_stdio(false);cin.tie(0); cout.tie(0);
#define sz(s) (int)s.size()
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i,n) for(int i=0;i<(int)n;i++)
#define for1(i,n) for(int i=1;i<=(int)n;i++)
#define ford(i, b, a) for (int i = (int)(b); i >= a; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<ll> vl;
const ll N = (ll)1e5+77;
const ll inf = (ll) 1e16+7;
const ll mod = (ll) 1e8;
const ld pi = acos(-1);

ll n, m, k;
pll layer[55];

pll memo(ll l) {
    if(l==0) return {1,1};
    if (layer[l].first != -1) return layer[l];
    pll tmp, ret = {1, 0};
    tmp = memo(l - 1);
    ret.first += tmp.first;
    ret.second += tmp.second;
    ret.first += 1;
    ret.second += 1;
    tmp = memo(l - 1);
    ret.first += tmp.first;
    ret.second += tmp.second;
    ret.first += 1;
    return layer[l] = ret;
}

ll solve(ll l, ll x) {
    if(l == 0) return 1;
    if (x <= 1) return 0;
    ll ret = 0;
    if (x <= layer[l - 1].first + 1) {
        ret += solve(l - 1, x - 1);
    } else if (x == layer[l - 1].first + 2) {
        ret += layer[l - 1].second + 1;
    } else if (x <= 2 * layer[l - 1].first + 2) {
        ret += layer[l - 1].second + 1 + solve(l - 1, x - layer[l - 1].first - 2);
    } else if (x == 2 * layer[l - 1].first + 3) {
        ret += 2 * layer[l - 1].second + 1;
    }
    return ret;
}

int main() {
    fast;
    cin >> n >> k;
    forn(i, 54) layer[i] = {-1, -1};
    layer[0] = {1, 1};
    memo(n);
    forn(i, 54) {
//        cout<<layer[i].first<<" "<<layer[i].second<<endl;
    }
    cout << solve(n, k) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
int main(){
    ll n,q;
    cin >> n >> q;
    ll res = 0;
    res = (n - 2) * (n - 2);
    ll yokomin = n - 1;
    ll tatemin = n - 1;
    vector<ll> tatefi(n,-1);//影響ある縦
    vector<ll> yokofi(n,-1);
    for(int i = 0;i < q;i++){
        ll t,x;
        cin >> t >> x;
        x--;
        if(t == 1){//縦に挟む
          for(int j = x;j < n;j++){
              if(tatefi[j] != -1)break;
              tatefi[j] = yokomin;
          }
          res -= tatefi[x] - 1;
          tatemin = min(tatemin,x);
        }
        else{//横に挟む
          for(int j = x;j < n;j++){
              if(yokofi[j] != -1)break;
              yokofi[j] = tatemin;
          }
          res -= yokofi[x] - 1;
          yokomin = min(yokomin,x);
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 6420
//list index out of rangeエラー表示用
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep1(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)




int main(){
    int n;
    cin >> n;
    vector<long long> a(n);
    rep1(i, n){
        cin >> a[i];
    }
    long long ans = 0;
    long long waru = pow(10, 9) + 7;
    long long tem = 0;
    rep1(i, n){
        tem += a[i];
        tem = tem % waru;
    }
    rep1(i, n){
        tem -= a[i];
        if(tem < 0){
            tem += waru;
        }
        ans += tem * a[i];
        ans = ans % waru;
    }

    cout << ans;
    
}


Measured memory_bytes: 4848
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <functional>

using namespace std;
typedef long long llong;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<llong, llong> pll;
typedef pair<ld, ld> pdd;

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n, A;
    llong dp[5001] = {};
    llong tp[5001] = {};
    dp[2500] = 1;
    cin >> n >> A;
    for (int i = 0; i < n; ++i) {
        int x;
        cin >> x;
        x -= A;
        for (int j = 0; j <= 5000; ++j) {
            if (dp[j]) {
                tp[j] += dp[j];
                tp[j + x] += dp[j];
            }
        }
        for (int j = 0; j <= 5000; ++j) {
            dp[j] = tp[j];
            tp[j] = 0;
        }
    }
    printf("%lld\n", dp[2500] - 1);
    return 0;
}

Measured memory_bytes: 384
A=int(input())
B=int(input())
C=int(input())
D=int(input())
E=int(input())
a=(10-(A%10))%10
b=(10-(B%10))%10
c=(10-(C%10))%10
d=(10-(D%10))%10
e=(10-(E%10))%10
M=max(a,b,c,d,e)
print(A+a+B+b+C+c+D+d+E+e-M)

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

int main() {
	int a, b;
	char op;

	cin >> a >> op >> b;
	while (op != '?') {
		if (op == '+')
			cout << a + b << endl;
		else if (op == '-')
			cout << a - b << endl;
		else if (op == '*')
			cout << a * b << endl;
		else if (op == '/')
			cout << a / b << endl;

		cin >> a >> op >> b;
	}

	return 0;
}

Measured memory_bytes: 3068
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(int i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(int i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define uniq(x) (x).erase(unique((x).begin(), (x).end()), (x).end())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n, x;
    cin >> n >> x;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    int cnt = 0, happy = 0;
    sort(all(a));
    
    rep(i, n) {
        if ((cnt + a[i]) > x) {
            break;
        }
        
        cnt += a[i];
        happy++;
    }
    
    if ((happy == n) && (cnt < x)) {
        happy--;
    }
    
    cout << happy << endl;
    return 0;
}

Measured memory_bytes: 256