akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)

int main() {
    bool ans=true;
    string s;
    cin >> s;
    int c[26] = {};
    int n = 26;
    rep(i, s.size()) {
        c[s[i] - 97]++;
    }
    // dif(a,0)=97
    rep(i, n) {
        if (c[i] % 2 == 1) {
            ans = false;
        }
    }
    if (ans==true) {
        cout << "Yes" << endl;
    }
    else cout << "No" << endl;
}


Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int rmx = 100000;
    vint cnt(rmx+1,0);
    for(int i=3;i<=rmx;i+=2){
        bool f = true;
        int x = i;
        int y = x;
        for(int j=2;j*j<=y;++j){
            while(x%j==0){
                x/=j;
            }
        }
        if(x<y){
            f = false;
        }
        x = (i+1)/2;
        y = x;
        for(int j=2;j*j<=y;++j){
            while(x%j==0){
                x/=j;
            }
        }
        if(x<y){
            f = false;
        }
        if(f){
            cnt[i] = cnt[i-2]+1;
        }else{
            cnt[i] = cnt[i-2];
        }
    }
    int q;
    cin >> q;
    REP(i,q){
        int l,r;
        cin >> l >> r;
        cout << cnt[r] - cnt[max(1,l-2)] << "\n";
    }

    return 0;
}

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

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

int MOD=1e9+7;
ll INF=1e18;

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

int main(){
    ll d, n; cin>>d>>n;
    ll num=1;
    while(d--) num*=100;
    if(n!=100) cout << n*num << endl;
    else cout << n*num+num << endl;
}

Measured memory_bytes: 256
# coding:utf-8
from collections import deque
d = deque()
for i in range(int(input())):
    str = input().split()
    if str[0] == "insert":
        d.appendleft(str[1])
    elif str[0] == "delete":
        if str[1] in d:
            d.remove(str[1])
    elif str[0] == "deleteFirst":
        d.popleft()
    elif str[0] == "deleteLast":
        d.pop()
print(*d)



Measured memory_bytes: 69736
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF=1001001001;
vector<pair<int64_t,int64_t>>prime_factorize(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p; 
}
int main() {
  int R,G,B,N;
  cin>>R>>G>>B>>N;
  int64_t cnt=0;
  for(int r=0;r<=N;r++){
    for(int g=0;g<=N-r;g++){
      int t=N-R*r-G*g;
      if(t>=0&&t%B==0){cnt++;}
    }
  }
  cout<<cnt<<endl;
  return 0;
}

Measured memory_bytes: 3596
//BUGSBUNNY
//IIT ROORKEE

#include<bits/stdc++.h>
using namespace std; 
#define int long long
#define ll long long
#define double long double
#define ld long double
#define endl '\n'
#define vi vector<int>
#define vvi vector<vi>
#define vs vector<string>
#define vl vector<long long>
#define vpii vector<pii>
#define vpipii vector<pipii>
#define vb vector<bool>
#define pb push_back
#define pob pop_back
#define gcd __gcd
#define mp make_pair
#define pii pair<int,int>
#define pipii pair<int,pii>
#define piipi pair<pii,int>
#define pld pair<long double,long double>
#define mod 1000000007 
// #define mod 998244353
#define rep(i,n) for (ll i = 0; i < n; i++)
#define repp(i,a,b) for(ll i = a ; i<b ; i++)
#define reppr(i,a,b) for(ll i = a-1 ; i>=b ; i--)
#define repr(i,n) for (ll i = n - 1; i >= 0; i--)
#define ff first
#define ss second
#define pc putchar_unlocked
#define gc getchar_unlocked
#define inf 9223372036854775807
#define infn -9223372036854775807
#define pi 3.14159265358979323846
#define eps 0.0000000001
#define sp << " " << 
#define setprec(x) cout << fixed << setprecision(x);
#define reve(a) reverse(all(a));
#define SORT(a) sort(all(a));
#define all(n) n.begin(),n.end()

//Modular Exponentiation
    int powmod(int x,int y) 
    { 
        if (y == 0) return 1; 
        int p = powmod(x, y/2) % mod; 
        p = (p * p) % mod;   
        return (y%2 == 0)? p : (x * p) % mod; 
    }

//modInverse
    int modInverse(int a) 
    { 
       return powmod(a,mod-2); 
    }

//Binomial Coefficients
    // int fact[200010], factinv[200010];
    // int nCr(int n , int r)
    // {
    //     return ((fact[n] * modInverse(fact[n-r]) % mod * modInverse(fact[r]))%mod) ;
    // }

void solve();

signed main()
{
    //-------------------------------------------------------------------------------
        
        ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
        clock_t clk = clock();

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

        // fact[0] = 1 , factinv[0] = 1;
        // repp(i,1,200010)
        // {
        //     fact[i] = (fact[i-1] * i)%mod;
        //     factinv[i] = (factinv[i-1] * modInverse(i))%mod;
        // }
        
    //-------------------------------------------------------------------------------
        int t = 1;
        // cin >> t;
        while(t--)
            solve();
        clk = clock() - clk;
        cerr << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << endl;
    //-------------------------------------------------------------------------------
}

void solve()
{
    string s;
    cin >> s;
    if(s.length()==6 && s[2]==s[3] && s[4]==s[5])
        cout << "Yes";
    else
        cout << "No";  
}

Measured memory_bytes: 256
#include<cstdio>
#include<vector>
#include<utility>
#include<algorithm>
using namespace std;
int main(){
    int n;
    long long int k,a[100000],c;
    vector<long long int> bi;
    vector<pair<long long int ,long> > k1;
    long b[100000],ans=0;
    scanf("%d %lld",&n,&k);
    k1.push_back(make_pair(k,0));
    while(k){
        bi.push_back(k%2);
        k/=2;
    }
    for(int i=bi.size()-1;i>=1;i--){
        if(bi[i]==1){
            c=0;
            for(int j=bi.size()-1;j>=0;j--){
                c*=2;
                if(j<i||(j!=i&&bi[j])){
                    c+=1;
                }
            }
            k1.push_back(make_pair(c,0));
        }
    }
    for(int i=0;i<n;i++){
        scanf("%lld %ld",&a[i],&b[i]);
        for(int j=0;j<k1.size();j++){
            c=a[i]|k1[j].first;
            if(c==k1[j].first){
                k1[j].second+=b[i];
            }
        }
    }
    for(int i=0;i<k1.size();i++){
        ans=max(ans,k1[i].second);
    }
    printf("%ld\n",ans);
}

Measured memory_bytes: 1792
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <string>
#include <utility>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  int x, y;

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


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

int main(){
    int R, G, B, N;
    cin >> R >> G >> B >> N;
    int ans = 0;
    
    for(int r = 0; r * R <= N; r++){
        for(int g = 0; g * G <= N; g++){
            if((N - (r * R) - (g * G)) >= 0){
                if((N - (r * R) - (g * G)) % B == 0){
                    ans++;
                }
            }
        }
    }
    
    cout << ans << endl;

    return 0;
}


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

typedef long lint;
typedef long long llint;
typedef pair<int, int> pint;
typedef pair<long long, long long> pllint;
typedef tuple<long long, long long, long long> tllint;

// static const int MAX = 1e6;
// static const int NIL = -1;
// static const llint INF = 1<<21;
// static const llint MOD = 1e9 + 7;

bool compPair(const pint& arg1, const pint& arg2) { return arg1.first > arg2.first; }
bool compTuple(const tllint& arg1, const tllint& arg2) { return get<2>(arg1) > get<2>(arg2); }
template<class T> void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> void chmin(T& a, T b) { if (a > b) { a = b; } }

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

    vector<pint> ab(n+1);
    for(int in=1;in<=n;++in) {
        cin >> ab[in].first >> ab[in].second;
    }
    sort(ab.begin(), ab.end());

    vector<vector<int>> dp(3501, vector<int>(3501, 0));
    for(int in=0;in<n;++in) {
        for(int it=0;it<=t;++it) {
            dp[in+1][it] = dp[in][it];
            if(it-ab[in+1].first>=0) {
                dp[in+1][it] = max(dp[in][it], dp[in][it-ab[in+1].first]+ab[in+1].second);
            }
        }
    }

    int ans = 0;
    for(int in=1;in<=n;++in) {
        chmax(ans, dp[in-1][t-1]+ab[in].second);
    }

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


Measured memory_bytes: 51316
#include <bits/stdc++.h>
using namespace std;
const int maxn=1000005;
struct datas { int L,R,dec; } cow[maxn];
int n;
char S[maxn];
bool cmp(datas A,datas B)
{
	if (A.dec>=0 && B.dec<0) return true;
	if (A.dec<0 && B.dec>=0) return false;
	if (A.dec>=0 && B.dec>=0) return A.L<B.L;
	return A.R>B.R;
}
int main()
{
	scanf("%d",&n);
	for (int i=1,len;i<=n;i++)
	{
		scanf("%s",S);
		len=strlen(S);
		for (int j=0;j<len;j++)
			if (S[j]=='(') cow[i].R++; else
			if (cow[i].R) cow[i].R--; else cow[i].L++;
		cow[i].dec=cow[i].R-cow[i].L;
	}
	sort(cow+1,cow+1+n,cmp);
	//for (int i=1;i<=n;i++) cerr<<">>>>>>"<<cow[i].L<<" "<<cow[i].R<<" "<<cow[i].dec<<endl;
	int now=0;
	for (int i=1;i<=n;i++)
	{
		if (now<cow[i].L)
		{
			puts("No");
			return 0;
		}
		now=now-cow[i].L+cow[i].R;
	}
	if (!now) puts("Yes"); else puts("No");
	return 0;
}


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

int main(){
  int A, B, C;
  cin >> A >> B >> C;
  int mx = max({A, B, C});
  int ans = A + B + C + 9 * mx;
  cout << ans << endl;
}

Measured memory_bytes: 3620
N = int(input())
a = list()
for elem in input().split(' '):
    a.append(int(elem))

max = 0
count = 0
i_old = 0
for i in a:
    if i_old == 0:
        pass
    elif i<=i_old:
        count += 1
    else:
        count = 0
    if count > max:
        max = count
    i_old = i
print(max)
        



Measured memory_bytes: 14252
import sys
import math
from collections import defaultdict
from bisect import bisect_left, bisect_right

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def LI(): return list(map(int, input().split()))
def LIR(row,col):
    if row <= 0:
        return [[] for _ in range(col)]
    elif col == 1:
        return [I() for _ in range(row)]
    else:
        read_all = [LI() for _ in range(row)]
        return map(list, zip(*read_all))

#################

# Aは単調減少列の右端から選べる
# Bは ceil(N/A) ~ N-A+1 を取れる

N,A,B = LI()

if math.ceil(N/A) <= B <= N-A+1:
    numl = [1]*A  # 各単調減少列の要素数
    numl[0] = B
    left = N-A-B+1
    for i in range(1,A):
        val = min(left,B-1)
        numl[i] += val
        left -= val
    ans = []
    now = 1
    for i in range(A):
        ans.extend(list(reversed(range(now,now+numl[i]))))
        now += numl[i]
    print(*ans)
else:
    print(-1)

Measured memory_bytes: 72688
#define _CRT_SECURE_NO_WARNINGS

#include<iostream>
#include<string>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<map>
#include<tuple>
#include<algorithm>
#include<numeric>
#include<math.h>

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

using namespace std;

using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;

const int mod = 1e9 + 7;
const long double pi = 3.141592653589793238462643383279502884197;
const long double eps = 1e-7;

int t[200010];
int ch[200010][30];

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

	REP(i, 200010) {
		t[i] = 0;
		REP(j, 30) ch[i][j] = 0;
	}

	REP(i, N) {
		int si, ti, ci;
		cin >> si >> ti >> ci;
		ci -= 1;

		if (ch[2 * si][ci] == -1 && ch[2 * ti - 1][ci] == 1) {
			ch[2 * si][ci] = 0;
			ch[2 * ti - 1][ci] = 0;
		}
		else if (ch[2 * si][ci] == -1) {
			ch[2 * si][ci] = 0;
			ch[2 * ti][ci] = -1;
		}
		else if (ch[2 * ti - 1][ci] == 1) {
			ch[2 * si - 1][ci] = 1;
			ch[2 * ti - 1][ci] = 0;
		}
		else {
			ch[2 * si - 1][ci] = 1;
			ch[2 * ti][ci] = -1;
		}
	}


	REP(i, 200001){
		REP(j, C) {
			if (ch[i][j] == 1) {
				t[i]++;
			}
			else if (ch[i][j] == -1) {
				t[i]--;
			}
		}
	}

	int ans = 0;
	REPS(i, 1, 200001) {
		t[i] += t[i - 1];
		ans = max(ans, t[i]);
	}
	cout << ans;
	system("pause");
	return 0;
}

Measured memory_bytes: 24696
import java.util.Scanner;

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

		int n = sc.nextInt();
		int m = sc.nextInt();
		int M = 1000000007;
		long[] a = new long[n + 1];
		for (int i = 0; i < m; i++) {
			a[sc.nextInt()] = -1;
		}

		a[0] = 1;
		a[1] = a[1] == -1 ? -1 : 1;
		for (int i = 2; i <= n; i++) {
			if (a[i] == -1) continue;
			long steps = 0;
			if (a[i - 1] != -1) steps = (steps + a[i - 1]) % M;
			if (a[i - 2] != -1) steps = (steps + a[i - 2]) % M;
			a[i] = steps;
		}

		System.out.println(a[n]);
	}
}


Measured memory_bytes: 48608
#include<bits/stdc++.h>
	using namespace std;
	#define int long long int
	#define pb push_back
	const int mod=1e9+7;
	#define all(x) x.begin(),x.end()
	#define endl '\n'
	#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
	vector<int>parent;
	vector<int>sz;
	int find(int a){
		if(a==parent[a])return a;
		return parent[a]=find(parent[a]);
	}
	void add(int a,int b){
		a=find(a);
		b=find(b);
		if(a==b)return;
		parent[b]=a;
		sz[a]+=sz[b];
	}
	int32_t main(){
		IOS;
		int n,m;
		cin>>n>>m;
		parent.resize(n+1);
		for(int i=1;i<=n;i++){
			parent[i]=i;
		}
		sz.assign(n+1,1);
		set<pair<int,int>>s;
		for(int i=0;i<m;i++){
			int a,b;
			cin>>a>>b;
			if(s.find({b,a})==s.end())
			s.insert({a,b});
		}
		for(auto u:s)add(u.first,u.second);
		int count=*max_element(sz.begin()+1,sz.end());
	
		cout<<count<<endl;
		return 0;
	}


Measured memory_bytes: 18704
use std::io::{self, BufRead};

fn main() {
    let stdin = io::stdin();
    let mut lines = stdin.lock().lines();
    let n = lines.next().unwrap().unwrap().parse::<i32>().unwrap();

    for i in 1..10 {
        for j in 1..10 {
            if i * j == n {
                println!("Yes");
                return;
            }
        }
    }
    println!("No");
}


Measured memory_bytes: 4352
program sample
    implicit none
    integer(8) ::a, b,c,i,j,m,n,k,a1,b1,c1
    
    character(len=10)::s
    character(len=1)::t
    read(*,*) s
    a=len_trim(s)
    b=0
    c=0
    do i=1,a
        t=s(i:i)
        if (t=='A' .or. t=='C' .or. t=='G' .or. t=='T') then
            b=b+1
        else
            if (b>c)then
                c=b
            end if
            b=0
        end if

    end do
    if (b>c)then
        c=b
    end if
    write(*,*)c
    stop
end program sample
  



Measured memory_bytes: 256
using namespace std;
#include<bits/stdc++.h>
#define ll long long int
#define bigint int64_t
#define vll vector<ll>
#define vpll vector<pll>
#define pb push_back
#define MOD 1000000007
#define sz(x) (ll)(x).size()
#define op2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define op3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define op4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define op5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define en cout<<"\n"
#define LCM(a,b) (a*(b/__gcd(a,b)))
#define all(v) v.begin(),v.end()
#define maxqueue    priority_queue<int>
#define F_OR1(e) F_OR(i, 0, e, 1)
#define F_OR2(i, e) F_OR(i, 0, e, 1)
#define F_OR3(i, b, e) F_OR(i, b, e, 1)
#define minqueue    priority_queue<int,vector<int>,greater<int> >
#define lb(v,val)  (lower_bound(v.begin(),v.end(),val)-v.begin())
#define ub(v,val)  (upper_bound(v.begin(),v.end(),val)-v.begin())
#define INF (ll)(1e18)
#define ini(a,b) memset(a,b,sizeof(a))
#define vvll vector<vector<ll>>
#define ar array
#define pll ar<ll,2>
#define prec(n) fixed<<setprecision(n)
#define F_OR(i, a, b, s) for (int i = (a); ((s) > 0 ? i < (b) : i > (b)); i += (s))
#define F_OR4(i, b, e, s) F_OR(i, b, e, s)
#define GET5(a, b, c, d, e, ...) e
#define F_ORC(...) GET5(__VA_ARGS__, F_OR4, F_OR3, F_OR2, F_OR1)
#define forn(...) F_ORC(__VA_ARGS__)(__VA_ARGS__)
#define op1(x)                cerr<<#x<<": "<<x<<endl
#define op6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define GET5(a, b, c, d, e, ...) e
#define D_EBC(...) GET5(__VA_ARGS__, op4, op3, op2, op1)
#define op(...) D_EBC(__VA_ARGS__)(__VA_ARGS__)
#define each(x, a) for (auto& x: a)
#define ff first
#define ss second


template <typename T>
void read(T &x) {
    cin >> x;
}
template <typename T , typename T0>
void read(T &x, T0 &y) {
    cin >> x >> y;
}

template <typename T , typename T0 , typename T1>
void read(T &x, T0 &y, T1 &z) {
    cin >> x >> y >> z;
}

template <typename T , typename T0 , typename T1 , typename T2>
void read(T &x, T0 &y, T1 &z, T2 &w) {
    cin >> x >> y >> z >> w;
}

template <typename T>
void read(vector< T > &oneD, ll n) {
    for (ll i = 0; i < n; i++) {
        read(oneD[i]);
    }

}

template <typename T>
void read(T oneD[] , ll n) {
    for (ll i = 0; i < n; i++) {
        read(oneD[i]);
    }
}
void answer(){
    ll x,a=100,ans=0;
    read(x);
    while(a<x){
        a+=(a)/100;
        ans++;
    }
    cout<<ans;
}
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll t=1;
    // read(t);
    while(t--){
        answer();
    }
}

Measured memory_bytes: 3640
a,b = map(int, input().split())
c = 0
d = 0
e = [1,3,5,7,8,10,12]
f = [4,6,9,11]
g = [2]
for i in e:
  if i==a:
    c = "x"
  if i==b:
    d = "x"
for j in f:
  if j==a:
    c = "y"
  if j==b:
    d = "y"
if c==d or a==b:
  print("Yes")
else:
  print("No")
  

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

using namespace std;

int main()
{

    int n,i,c=0,a,f=0;
    cin>>n;

   if(n==2)
    cout<<1<<endl;
   else
   {
      for(i=1;i<=n;i++)
    {
        c+=((n-1)/i);

    }

    cout<<c<<endl;
   }



    return 0;
}


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

bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}

int main(void){

    int N;
    cin >> N;

    while(1){
        
        if(IsPrime(N)){
            cout << N << endl;
            break;
        }
        N++;
    }
}


Measured memory_bytes: 3624
#!/usr/bin/env python3
import sys


def solve(X: int, Y: int):
    print(X+Y//2)


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    X = int(next(tokens))  # type: int
    Y = int(next(tokens))  # type: int
    solve(X, Y)

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
import heapq
from collections import deque
from enum import Enum
import sys
import math
from _heapq import heappush, heappop
import copy
from test.support import _MemoryWatchdog

BIG_NUM = 2000000000
HUGE_NUM = 99999999999999999
#MOD = 1000000007
MOD = 10000
EPS = 0.000000001
sys.setrecursionlimit(100000)


tomato = 0
cream = 1
basil = 2
tomato_2 = 3
cream_2 = 4
basil_2 = 5

N,K = map(int,input().split())
dp = [[0]*6 for _ in range(N)]
decided = [-1]*N

#決まってる日
for _ in range(K):
    A,B = map(int,input().split())
    decided[A-1] = B-1

#初日
if decided[0] == -1:
    for i in range(3):
        dp[0][i] = 1
else:
    dp[0][decided[0]] = 1

for i in range(1,N):

    if decided[i] == -1:   #メニューが決まってない
        for pre in range(6):
            for tommorow in range(6):
                if pre%3 != tommorow%3: #別の種類
                    if tommorow >= 3: #2日連続ではない
                        continue
                    dp[i][tommorow] += dp[i-1][pre]
                    dp[i][tommorow] %= MOD
                else: #同じ種類
                    if pre < 3 and tommorow >= 3:
                        dp[i][tommorow] += dp[i-1][pre]
                        dp[i][tommorow] %= MOD
    else: #メニューが決まっている
        for pre in range(6):
            if pre%3 != decided[i]%3: #別種
                dp[i][decided[i]] += dp[i-1][pre]
                dp[i][decided[i]] %= MOD
            else: #同種
                if pre >= 3:
                    continue
                dp[i][decided[i]+3] += dp[i-1][pre]
                dp[i][decided[i]+3] %= MOD


ans = 0
for i in range(6):
    ans += dp[N-1][i]
    ans %= MOD

print("%d"%(ans))


Measured memory_bytes: 13844
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
#define ROF(i,a,b) for(ll i=a;i>=b;i--)
#define per(i,a) ROF(i,a,0)
#define pb push_back
using namespace std;
using ll=long long;
using ld=long double;
using ch=char;
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vP;
typedef vector<ch> vc;
typedef vector<vc> vvc;
const ll MOD=1000000007;
const ll MOD2=998244353;
const ld PI=acos(-1);
const ll INF=1e18;
struct edge{ll to,cost;};
struct edge2{ll from,to,cost;};

template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    string S;
    cin >> S;
    ll res0=INF,res1=0;
    rep(i,S.size()){
        if(S[i]=='A'){
            chmin(res0,i);
        }
        else if(S[i]=='Z'){
            chmax(res1,i);
        }
    }
    cout << res1-res0+1 << endl;
}

Measured memory_bytes: 3712
#include <stdio.h>
int main(){
    int H[100],W[100],i,k,ix,o;
    i=0;
    while(1){
        scanf("%d %d",&H[i],&W[i]);
        if(H[i]==0&&W[i]==0){
            ix=i;
            break;
        }
        i++;
    }
    for(i=0;i<ix;i++){
        for(o=0;o<H[i];o++){
            for(k=0;k<W[i];k++){
                if(o%2!=0){
                    if(k%2!=0){
                        printf("#");
                    }else{
                        printf(".");
                    }
                }else{
                    if(k%2!=0){
                        printf(".");
                    }else{
                        printf("#");
                    }
                }
            }
            printf("\n");
        }
        printf("\n");
    }
    return 0;
}

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

//--------------some #defines-------------------------
#define boost ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define get1(x) int x; cin>>x
#define get2(x,y) int x,y; cin>>x>>y
#define min2(x,y) (x<y?x:y)
#define max2(x,y) (x>y?x:y)

#define loop(i,a,b) for(int i=(a);i<(b);i++)
#define rev(i,a,b) for(int (i)=(a);(i)>=(b);(i)--)
#define all(x) (x).begin(), (x).end()
#define sz(x) (x).size()
#define endl '\n'

#define vi vector<int>

#define matrix(x,n,m) vector<vector<int> > x(n,vi (m))
#define pb push_back
#define pii pair<int,int>
#define mkp make_pair
#define ff first
#define ss second
#define vpii vector<pair<int,int> >
#define ll long long


//#define gcd(x,y) __gcd(x,y)
//#define lcm(x,y) (x)*(y)/__gcd(x,y)

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

int main()
{
    boost;
    get1(t);
    if (t%1000!=0)
    {
        cout<<(t/1000+1)*1000-t;
    }
    else
        cout<<0;

    return 0;
}



Measured memory_bytes: 3668
using System;
using System.Linq;

namespace B___Balance
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var Wi = Console.ReadLine().Split().Select(int.Parse).ToArray();

            int sum = Wi.Sum(), min = int.MaxValue;
            for (int i = 1; i <= N; i++)
                min = Math.Min(min, Math.Abs(sum - 2 * Wi.Take(i).Sum()));

            Console.WriteLine(min);
        }
    }
}


Measured memory_bytes: 13396
N = int(input())
V = [int(i) for i in input().split()]
C = [int(i) for i in input().split()]

ans = 0
dif = [0] * N

for i in range(N):
    dif[i] = V[i] - C[i]
    if dif[i] > 0:
        ans += dif[i]

print(ans)

Measured memory_bytes: 3064
#include <iostream>

using namespace std;

int main(){
  int a , b;
  cin >> a >> b;
  if (a < b) {
    cout << "a < b" << endl;
  }
  else if (a > b) {
    cout << "a > b" << endl;
  }
  else {
    cout << "a == b" << endl;
  }
  return 0;
}


Measured memory_bytes: 3088
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,k;
    cin >> n >> k;
    vector<int> v(n);
    for(int i = 0;i < n;++i)
        cin >> v.at(i);
    sort(v.begin(),v.end());
    int sum = 0;
    int count = 0;
    for(int i = 0;i < n;++i)
    {
        if(sum + v[i] >= k)
        {
            if(sum + v[i] == k)
            {
                count++;
            }
            break;
        }
        if(i == n - 1)
        {
            break;
        }
        sum += v[i];
        count++;
    }
    cout << count <<endl;
}


Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<vector>
#include<string>
#define rep(i, start, end) for (int i = (int)start; i < (int)end; ++i)
#define rrep(i, start, end) for (int i = (int)start - 1; i >= (int)end; --i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return 0;}
template<typename T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return 0;}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, K;
    cin >> N >> K;
    vector<int> P(N);
    rep(i, 0, N) {
        cin >> P[i];
    }
    sort(all(P));
    int ans = 0;
    rep(i, 0, K) {
        ans += P[i];
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
  int n; cin >> n;
  int x,y,ans;
  cin >> x;
  ans = x;
  rep(i,n-2){
    cin >> y;
    ans += min(x,y);
    x = y;
  }
  cout << ans +x << endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
//#define int long long
#include <math.h>
#include <time.h>
using namespace std;
const int MOD = 1000000007;
#define dump(x)                             \
    if (dbg) {                              \
        cout << #x << " = " << (x) << endl; \
    }
bool dbg = true;
int n;//全体の人数
vector<int>ai(16);//証言の数のvector
vector<vector<int> >honest(16,vector<int>(16));//正直不親切vector
int cnt = 0;
int ans = 0;
int xi, yi;
void solve(){
    for(int bit = 0; bit < (1 << n); bit++){
        bool flag = true;
        for(int j = 0; j < n; j++){
            if(bit & (1 << j)){//j桁目が立っているとき→正直もののjさんの発言に矛盾がないかを確認
            for(int k = 0; k < n; k++){
                if(bit & (1 << k)){//k桁目が立っている時→kさんは正直
                    if(honest.at(j).at(k) == 1){//kさんは不親切ではだめ
                        flag = false;
                    }
                }
                else{
                    if(honest.at(j).at(k) == 2){//kさんは正直ではダメ
                        flag = false;
                    }
                }
            }
            }
        }
        if(flag){
            ans = max(ans, (int)bitset<16>(bit).count());
        }
    }
    cout << ans << endl;
}

int main(){
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> ai.at(i);
        for(int j = 0; j < ai.at(i); j++){
            cin >> xi >> yi;
            xi--;
            yi++;
            honest.at(i).at(xi) = yi;//0(未入力)との区別のために正直もの: 2、不親切:1で格納
        }
    }//入力完了
    solve();
    return 0;
}



Measured memory_bytes: 256
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <list>

using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(d) string(1,d)
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007

int main() {
  ll n;
  cin>>n;
  vector<ll> v;
  rep(i,0,n){
  	ll a;
  	cin>>a;
  	a--;
  	v.pb(a);
  }
  ll c = 0;
  ll d[100005];
  clr(d,0);
  rep(i,0,v.sz){
  	if(d[i]==0&&d[v[i]]==0&&i==v[v[i]]){
  		c++;
  		d[i]++;
  		d[v[i]]++;
  	}
  }
  cout << c << endl;
  return 0;
}


Measured memory_bytes: 1908
#include <iostream>
#include <vector>
#include <queue>
#include <set>
using namespace std;

int main()
{
  int x, y, z, k;
  cin >> x >> y >> z >> k;

  vector<int64_t> A(x), B(y), C(z);
  for (auto&& e : A) cin >> e;
  for (auto&& e : B) cin >> e;
  for (auto&& e : C) cin >> e;
  sort(begin(A), end(A), greater<>());
  sort(begin(B), end(B), greater<>());
  sort(begin(C), end(C), greater<>());

  priority_queue<tuple<int64_t, int, int, int>> pq;
  pq.push({A[0] + B[0] + C[0], 0, 0, 0});
  set<tuple<int, int, int>> s;
  s.insert({0, 0, 0});
  vector<int64_t> ans;

  while (ans.size() < k) {
    auto v = pq.top(); pq.pop();
    ans.push_back(get<0>(v));
    auto a = get<1>(v);
    auto b = get<2>(v);
    auto c = get<3>(v);
    if (a + 1 < x && s.count(make_tuple(a + 1, b, c)) == 0) {
      s.insert(make_tuple(a + 1, b, c));
      pq.push(make_tuple(A[a + 1] + B[b] + C[c], a + 1, b, c));
    }
    if (b + 1 < y && s.count(make_tuple(a, b + 1, c)) == 0) {
      s.insert(make_tuple(a, b + 1, c));
      pq.push(make_tuple(A[a] + B[b + 1] + C[c], a, b + 1, c));
    }
    if (c + 1 < z && s.count(make_tuple(a, b, c + 1)) == 0) {
      s.insert(make_tuple(a, b, c + 1));
      pq.push(make_tuple(A[a] + B[b] + C[c + 1], a, b, c + 1));
    }
  }
  for (int i = 0; i < k; i++) {
    cout << ans[i] << endl;
  }
}


Measured memory_bytes: 896
N = int(input())
S = [0]*N
dict = {}
cnt = 0
for i in range(N):
    S[i] = sorted(input())
    if tuple(S[i]) in dict:
        dict[tuple(S[i])] += 1
        cnt += dict[tuple(S[i])]    
    dict.setdefault(tuple(S[i]),0)
print(cnt)

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

int main() {
    long long x;
    cin >> x;
    //x *= 100;

    long long money = 100;
    int year = 1;
    while(1) {
        money += money / 100;
        if (money >= x) break;

        year++;
    }

    cout << year << endl;
}

Measured memory_bytes: 3620
fun main(args: Array<String>) {
    val (n, k) = readLine()!!.split(' ').let {
        it[0].toInt() to it[1].toLong()
    }
    val a = readLine()!!.split(' ').map { it.toInt() }.sorted().toIntArray()
    val f = readLine()!!.split(' ').map { it.toInt() }.sortedDescending().toIntArray()

    var l = 0L
    var r = 1e12.toLong()
    while (l < r) {
        val m = l + (r - l) / 2

        var x = 0L
        for (i in 0 until n) {
            x += Math.max(a[i] - (m / f[i]), 0)
        }

        if (x <= k) {
            r = m
        } else {
            l = m + 1
        }
    }

    println(l)
}


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

using namespace std;

int main() {
    int n, a[111];
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        scanf("%d", a + i);
    }
    int ans = 1e9;
    for (int i = -100; i <= 100; i++) {
        int sum = 0;
        for (int j = 0; j < n; j++){
            sum += (a[j] - i) * (a[j] - i);
        }
        ans = min(ans, sum);
    }
    cout << ans << endl;
    return 0;
}


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

AB = sorted(AB, key = lambda ab:ab[0])

cost = 0
count = 0
for a, b in AB:
	if b < M - count:
		cost += a * b
		count += b
	else:
		t = M - count
		cost += a * t
		count += t
		break
print(cost)


Measured memory_bytes: 18904
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <cmath>
#include <cctype>
#include <sstream>
#include <algorithm>
using namespace std;
#define all(c) (c).begin(), (c).end()
#define rep(i,n) for (int i=0; i<(int)(n); i++)
#define iter(c) __typeof((c).begin())
#define tr(it,c) for (iter(c) it=(c).begin(); it!=(c).end(); it++)
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define pr(a) cout << (a) << endl
typedef long long ll;
typedef pair<int,int> P;
const int MAX=1000000000;
int dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};

int main() {
  int t;
  cin >> t;
  bool ck=false;
  while(t--) {
    if(ck) cout << endl;
    ck=true;
    int n;
    cin >> n;
    string s[n][n];
    bool d[n][n];
    rep(i,n) {
      rep(j,n) {
	if(i==0 || j==0 || j==n-1) s[i][j]='#';
	else s[i][j]=' ';
	if(i==n-1 && j==n-1 && n!=1) s[i][j]=' ';
	d[i][j]=false;
	if(i==1 && j>=1 || j==1 && i>=1 || j==n-2 && i>=1 && i<n-1) d[i][j]=true;
      }
    }
    if(n<=2) {
      rep(i,n) {
	rep(j,n) cout << s[i][j];
	cout << endl;
      }
      continue;
    }
    int nx=n-1,ny=n-1,k=3,kk=0;
    while(1) {
      s[nx][ny]='#';
      if(d[nx+dx[k]][ny+dy[k]]) {
	k=(k+1)%4;
	kk=(kk+1)%4;
	if(d[nx+dx[k]][ny+dy[k]]) break;
      }
      d[nx+dx[kk]][ny+dy[kk]]=true;
      nx+=dx[k];
      ny+=dy[k];
    }
    rep(i,n) {
      rep(j,n) cout << s[i][j];
      cout << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 1748
#include<iostream>
#include<string>
#include<algorithm>
#include<bits/stdc++.h>
#include<vector>
 
using namespace std;
 
int main(){
  int D,N;
  cin >> D >> N;
  if(N==100)
  N=N+1;
  if(D==0)
  cout << N << endl;
  if(D==1)
  cout << N*100 << endl;
  if(D==2)
  cout << N*10000 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <cmath>

using namespace std;

int main() {
    size_t n;
    cin >> n;
    vector<size_t> d(n, 0);
    for (auto& e : d) {
        cin >> e;
    }
    size_t c = 0;
    for (size_t i = 0; i < d.size(); ++i) {
        auto x = d[i];
        for (size_t j = i + 1; j < d.size(); ++j) {
            auto y = d[j];
            c += x * y;
        }
    }
    cout << c << endl;
    return 0;
}


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

int main() {
  long long n,a,b;
  cin>>n>>a>>b;
  if(a>b){
    cout<<"0"<<endl;
    return 0;
  }
  if(n==1&&a!=b){
    cout<<"0"<<endl;
    return 0;
  }
  cout<<(n-2)*(b-a)+1<<endl;
}

Measured memory_bytes: 256
#include <algorithm>     //sort,二分探索,など
#include <bitset>        //固定長bit集合
#include <cmath>         //pow,logなど
#include <complex>       //複素数
#include <deque>         //両端アクセスのキュー
#include <functional>    //sortのgreater
#include <iomanip>       //setprecision(浮動小数点の出力の誤差)
#include <iostream>      //入出力
#include <iterator>      //集合演算(積集合,和集合,差集合など)
#include <map>           //map(辞書)
#include <numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include <queue>         //キュー
#include <set>           //集合
#include <stack>         //スタック
#include <string>        //文字列
#include <unordered_map> //イテレータあるけど順序保持しないmap
#include <unordered_set> //イテレータあるけど順序保持しないset
#include <utility>       //pair
#include <vector>        //可変長配列

using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= (ll)(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= (ll)(b); i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(), (x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())      //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))   //最大値を求める
#define MIN(x) *min_element(ALL(x))   //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 10000007      //10^9+7:合同式の法
#define MAXR 100000       //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first      //pairの一つ目の要素
#define S second     //pairの二つ目の要素

#define ifr(i,n) for(int i=(n)-1;i>=0;--i)

signed main()
{
    int N;
    cin >> N;
    vector<int> A(N);
    unordered_map<int, int> B(N);
    REP(i, N){
        cin >> A[i];
    }

    //int a, b;
    ll ans = 0;

    REP(i,N){
        ans+=B[A[i]-i];
        B[-i-A[i]]++;
    }

    cout << ans << endl;
    
}

Measured memory_bytes: 18700
#include <bits/stdc++.h>
#define ALL(a) (a).begin(),(a).end()
#define N_MAX 1000
#define ll long long int
using namespace std;

int main() {
	string S; cin >> S;
	string T, R;
	for (int i = 0; i < S.size(); i++) {
		if (i % 2 == 0) {
			T += '0';
			R += '1';
		}
		else {
			T += '1';
			R += '0';
		}
	}
	
	int t = 0, r = 0;
	for (int i = 0; i < S.size(); i++) {
		if (S[i] != T[i])t++;
		if (S[i] != R[i])r++;
	}

	cout << min(t, r) << endl;
}


Measured memory_bytes: 768
#include <iostream>
#include <string>
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <algorithm>
#include <ctime>
#include <vector>
#include <set>
#include <queue>
using namespace std;
typedef long long ll;

#define PI 3.14159265358979323846264338327950L

int res;

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

    int N;
    cin >> N;
    vector<int> h(N);
    for(int i = 0; i < N; i++ )
    {
        cin >> h[i];
    }
    res = 0;
    vector<pair<int, int>> water(1);
    water[0].first = -1;
    water[0].second = -1;
    bool flag = true;
    while (flag){
        for (int i = 0; i < N; i++){
            if(water[0].first==-1&&h[i]!=0){
                water[0].first = i;
            }else if(h[i]==0&&water[0].second==-1&&water[0].first!=-1){
                water[0].second = i-1;
            }
        }
        if(water[0].first!=-1&&water[0].second==-1){
            water[0].second = N-1;
        }
        flag = false;
        for (int i = 0; i < N; i++)
        {
            if(h[i]!=0){
                flag = true;
            }
        }

        if(water[0].first==-1&&water[0].second==-1){
            flag = false;
        }else{
            
            res++;
            for (int i = water[0].first; i < water[0].second + 1; i++)
            {
                h[i]--;
            }
            water[0].first = water[0].second = -1;
        }
    }
        cout << res << endl;
    return 0;
}

Measured memory_bytes: 3620
//(・ω・)
#include <stdio.h>
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, atoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <iomanip> //setprecision
#include <limits>
#include <sstream> //istringstream
#include <stdlib.h>
#include <list>
#include <iterator>//std::advance()
using namespace std;

int main(){
   priority_queue<long long, vector<long long>, less<long long>> q;
   long long n,m;
   cin >> n >> m;
   for(long long i=0; i<n; i++){
       long long a;
       cin >> a;
       q.push(a);
   }
   for(long long i=0; i<m; i++){
       long long maxq=q.top();
       maxq/=2;
       q.pop();
       q.push(maxq);
   }
   long long ans=0;
   for(long long i=0; i<n; i++){
       ans+=q.top();
       q.pop();
   }
   cout << ans << endl;
}

Measured memory_bytes: 1400
# include <bits/stdc++.h>
# define pb push_back
# define ll long long
# define fi first
# define se second
# define all(vc) vc.begin(),vc.end()
# define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
# define DEBUG

using namespace std;

const int N = 1e5 + 7;
const int mod = 1e9 + 7;

int n, a[N], b[N], c[N];
vector < pair < int, int > > vc;

int main()
{
    speed;
    /// Author: Dilshod--Imomov
    #ifdef DEBUGd
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif // DEBUG
    cin >> n;
    for ( int i = 0; i < n; i++ ) {
        cin >> a[i];
        b[i] = i + 1;
    }
    for ( int i = 0; i < n; i++ ) {
        if ( a[i] != i + 1 ) {
            vc.pb({a[i], i + 1});
        }
    }
    if ( vc.size() > 2 ) {
        cout << "NO";
    }
    else {
        if ( vc.size() == 0 || (vc[0].fi == vc[1].se && vc[0].se == vc[1].fi) ) {
            cout << "YES";
        }
        else cout << "NO";
    }
}



Measured memory_bytes: 256
import java.util.Scanner;

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

		Scanner sc = new Scanner(System.in);
		int k = sc.nextInt();
		int x = sc.nextInt();

		int count = 0;

		for (int i = x - k + 1; i < x + k; i++) {
			System.out.print(i);
			if (x != x + k - 1) {
				System.out.print(" ");
			}
		}
		sc.close();

	}
}

Measured memory_bytes: 21716
#include<stdio.h>
int gcd(int a,int b);
int main(void){
  int a,b,c,k,i,ans,ab;
  
  scanf("%d",&k);
  ans = 0;
  
  for(a=1;a<=k;a++){
    for(b=1;b<=k;b++){
      for(c=1;c<=k;c++){
        ab = gcd(a,b);
        ans += gcd(ab,c);
      }
    }
  }
  
  printf("%d\n",ans);
  
  return 0;
}
 
int gcd(int a,int b){
  if(b==0){
    return a;
  }
  int i;
  i = gcd(b,a%b);
  return i;
}

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

using namespace std;

int main(){
	while(true){
		int n, q;
		cin >> n >> q;
		if(n == 0 && q == 0){ break; }
		vector<int> c(101, 0);
		c[0] = q - 1;
		while(n--){
			int m;
			cin >> m;
			while(m--){
				int d;
				cin >> d;
				++c[d];
			}
		}
		int maxval = c[0];
		for(int i = 1; i < c.size(); ++i){
			maxval = max(maxval, c[i]);
		}
		for(int i = 0; i < c.size(); ++i){
			if(c[i] == maxval){
				cout << i << endl;
				break;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 1196
#include<stdio.h>

int main()
{
	int n,d,m=0,i=1;
	
	scanf("%d",&n);
	
	while(n!=0){
		d=n%10;
		if(d==1){
			m=m+9*i;
		}
		else{
			m=m+1*i;
		}
		n=n/10;
		i=i*10;
	}
	printf("%d\n",m);
	
	return 0;
}

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

using namespace std;

int main(){
  int n,l;
  cin>>n>>l;
  vector<string> seq(n);
  for(int i=0; i<n; i++) cin>>seq[i];
  sort(seq.begin(), seq.end());
  for(int i=0; i<n; i++) cout<<seq[i];
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<cstdio>
#include<stdlib.h>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<string.h>
#include<cmath>
#include<vector>

#include<stack>
#include<queue>
#include<time.h>
#include<set>
#include<map>
#include <iomanip>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i>b;i--)
#define vint vector<int> 
#define vvint vector<vint>
#define ct(a) cout<<a<<endl
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
#define MAX 100000


ll a, b;


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


	cin >> a >> b;

	if (a == 1 || b == 1) {
		cout << 1 << endl;
	}
	else {
		if (a*b % 2 == 0) {
			cout << a * b / 2 << endl;
		}
		else cout << a * b / 2 + 1 << endl;
	}
	return 0;
}


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

int main() {
    long long a, v, b, w, t;
    cin >> a >> v >> b >> w >> t;

    bool can = false;

    if (a < b) {

        for (int i = 1; i <= t; i++) {
            a += v;
            b += w;
            if (a >= b) {
                can = true;
                break;
            }
        }
    } else {

         for (int i = 1; i <= t; i++) {
            a -= v;
            b -= w;
            if (a <= b) {
                can = true;
                break;
            }
        }
       
    }


    if (can) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 3620
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
//typedef pair<int,int> P;
//priority_queue<int> pque;
//priority_queue<int, vector<int>, greater<int>> pque;
ll INFL = 1000000000000000010;//10^18 = 2^60
int INF = 1000000000;//10^9
ll MOD  = 1000000007;
ll kai(int n){
    if(n == 0 || n == 1)return 1;
    else if(n >= 2){
        return kai(n-1) * n;
    }else{
        return 0;
    }
}


int main(void){
    string s;
    cin >> s;
    for(int i = 0; i < 19; i++){
        if(i != 5 && i != 13){
            cout << s.at(i);
        }else{
            cout << " ";
        }
    }
    cout << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    void main() {
    	Scanner sc = new Scanner(System.in);
    	int n = sc.nextInt();
    	int[] a = new int[n];
    	
    	for(int i = 0; i < a.length; i++) {
    		a[i] = sc.nextInt();
    		}
    	for(int i = 0; i < a.length; i++) {
    		if(i != 0) {
    			System.out.print(" " + a[n - i - 1]);
    		}
    		else{
    			System.out.print(a[n - i - 1]);
    		}
    	}
    	System.out.println();
    }

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


Measured memory_bytes: 26220
import collections
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

N=int(input())
c = collections.Counter(prime_factorize(N))

X=[]
for a in c.values():
    X.append(a)
def count(a):
    if 1<=a<=2:
        return 1
    elif 3<=a<=5:
        return 2
    elif 6<=a<=9:
        return 3
    elif 10<=a<=14:
        return 4
    elif 15<=a<=20:
        return 5
    elif 21<=a<=27:
        return 6
    elif 28<=a<=35:
        return 7
    elif 36<=a<=40:
        return 8

ans=0
for i in range(len(X)):
    ans+=count(X[i])
print(ans)


Measured memory_bytes: 9492