akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(ll i=0;i< (n);i++)
#define rep1(i,n) for(ll i=1;i<= (n);i++)
using namespace std;
typedef long long ll;
const static ll MOD = (1e+9)+7;

ll modcross(ll a,ll k){
    if(k == 0)return 0;
    if(k % 2 == 1)return (a + modcross(a,k-1)) % MOD;
    ll t = modcross(a,k/2) % MOD;
    return (t * 2) % MOD; 
}

int main(){
    ll n,k;cin>>n>>k;
    vector<ll> A(n,0);rep(i,n)cin>>A[i];
    ll ans = 0;
    for(ll i = 0;i<n-1;i++){
        for(ll j = i+1;j<n;j++){
            if(A[i]>A[j])ans += ((k*(k-1))/2 % MOD ) + (k % MOD);
            if(A[i]<A[j])ans += (k*(k-1))/2 % MOD;
            ans %= MOD;
        }
    }
    cout<<ans%MOD<<endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())

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

c1 = collections.Counter(prime_factorize(N))
ans = 0
c = list(c1.values())
# print(c)

for i in c:
    k = 1
    while True:
        i =i - k
        if i >=0:
            ans += 1
            k += 1
        else:
            break
print(ans)

Measured memory_bytes: 9464
#include <iostream>
using namespace std;
 
int main() {
	
  	int N, T, c[120], t[120];
  	
  	cin >> N >> T;
  	
  	for(int i=0; i<N; i++){
  		cin >> c[i] >> t[i];
  	}
  	
  	int ans = 99999;
  	
  	for(int i=0; i<N; i++){
  		if(t[i] <= T){
  			if(c[i] < ans){
  				ans = c[i];
  			}
  		}
  	}
  	
  	if(ans < 99999){
  		cout << ans << endl;
  	}else{
  		cout << "TLE" << endl;
  	}

   	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
int t[99],h[99],i,s,N,T,L;main(){for(scanf("%d%d%d%d",&N,&T,&L,&L),i=0;i<N;i++)scanf("%d%d",t+i,h+i);for(i=s=0;;i=(i+1)%N)if(t[i]){t[i]--;if(++T>L)break;if(++s==9)s=0;}else if(h[i]){h[i]--;if(T<++s)break;t[i]=s;T-=s;s=0;}else break;printf("%d\n",i+1);}

Measured memory_bytes: 1028
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for(ll i = 0; i < (ll)(n); ++i)
#define FOR(i, a, b) for(ll i=(a); i < (ll)(b); ++i)
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;}

int main(){
	int n,k;
	cin >> n >> k;
	string s;
	cin >> s;
	
	int uh=0;
	REP(i,n-1){
		if(s[i]=='R' && s[i+1]=='L'){
			uh += 2;
		}
	}
	int rb = uh/2;
	int lb = uh/2;
	int euh=0;
	if(s[0]=='L'){
		euh++;
		lb++;
	}
	if(s[n-1]=='R'){
		euh++;
		rb++;
	}
	int ans = n-uh-euh;
	
	if(rb==lb){
		if(k >= rb){
			ans = n-1;
		}else{
			ans += k*2;
		}
	}else{
		if(k >= max(rb,lb)){
			ans = n-1;
		}else{
			ans += k*2;
		}
	}

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

Measured memory_bytes: 3716
#include <bits/stdc++.h>
#define mod 1e9+7
#define pb push_back
#define F first
#define S second

using namespace std;
typedef long long ll;
typedef long double ld;
int dx[4] = {-1, 0, +1, 0}, dy[4] = {0, -1, 0, +1};

deque <char> dq;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    string s;
    int q;
    cin >> s >> q;
    for (int i = 0; i < s.length(); i++)
        dq.pb(s[i]);
    int khara = 1;
    while (q--) {
        int a;
        cin >> a;
        if (a == 1) khara ^= 1;
        if (a == 2) {
            int x;
            cin >> x;
            char c;
            cin >> c;
            if (x == 1) {
                if (khara) dq.push_front(c);
                else dq.push_back(c);
            }
            if (x == 2) {
                if (khara) dq.push_back(c);
                else dq.push_front(c);
            }
        }
    }
    if (!khara)
        reverse(dq.begin(), dq.end());
    for (int i = 0; i < dq.size(); i++)
        cout << dq[i];
    cout << endl;
    return 0;
}


Measured memory_bytes: 976
a, b, k = list(map(int, input().split()))
la = []
lb = []
for i in range(1, a+1):
    if a % i == 0:
        la.append(i)
        lsas = sorted(set(la), key=la.index)
        for j in lsas:
            if b % j == 0:
                lb.append(j)

lsbs = sorted(set(lb), key=lb.index)
print(lsbs[len(lsbs)-k])


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

using namespace std;

int main(){
	int n, tc, hc;
	tc = hc = 0;
	string t, h;
	cin >> n;
	for (int i = 0; i < n; i++){
		cin >> t >> h;
		if (t == h) {
			tc++;
			hc++;
		}
		else if (t > h) tc += 3;
		else hc += 3;
	}
	cout << tc << " " << hc << endl;
}

Measured memory_bytes: 3208
//#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);
    string s;
    cin >> s;
    if((int)s.size()==2){
        cout << s << endl;
    }else{
        reverse(ALL(s));
        cout << s << endl;
    }

    return 0;
}

Measured memory_bytes: 3604
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import array
from bisect import *
from collections import *
import fractions
import heapq 
from itertools import *
import math
import re
import string

N, P = map(int, input().split())
As = list(map(int, input().split()))
odd = sum(1 for x in As if x % 2 == 1)
even = N - odd

def C(n, k):
    ans = 1
    for i in range(n - k + 1, n + 1):
        ans *= i
    for j in range(1, k + 1):
        ans //= j
    return ans

even_way = 0
for i in range(even + 1):
    even_way += C(even, i)

ans = 0
if P == 0:
    for j in range(0, odd + 1, 2):
        ans += C(odd, j)
else:
    for j in range(1, odd + 1, 2):
        ans += C(odd, j)
ans *= even_way
print(ans)

    


Measured memory_bytes: 5808
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const ll INF = 1e9;
const double pi=acos(-1);

int main(){
  string s,t;
  cin >> s >> t;
  
  vector<vector<int>>vec(26);
  rep(i,s.size()){
    vec[s[i]-'a'].push_back(i);
  }
  rep(i,s.size()){
    vec[s[i]-'a'].push_back(i+s.size());
  }
  
  ll ans=0;
  ll now=0;
  rep(i,t.size()){
    int c = t[i]-'a';
    if(vec[c].size()==0){
      cout << -1 << endl;
      return 0;
    }
    now = *lower_bound(vec[c].begin(),vec[c].end(),now)+1;
    if(now>=s.size()){
      ans+=s.size();
      now-=s.size();
    }
  }
  ans+=now;
  cout << ans << endl;
}


Measured memory_bytes: 1724
#include<algorithm>
#include<cstdio>
#include<utility>
using namespace std;
typedef pair<int, int> P;

const int INF = 1e8 + 1;
int n, m;
P p[1000];
int dp[1001][1 << 12];

int main() {
    scanf("%d %d", &n, &m);
    for (int i = 0; i < m; i++) {
        int a, b;
        scanf("%d %d", &a, &b);
        int s = 0;
        for (int j = 0; j < b; j++) {
            int c;
            scanf("%d", &c);
            s = s | (1 << (c - 1));
        }
        p[i] = P(a, s);
    }
    
    for (int i = 0; i <= m; i++) {
        for (int j = 1; j < (1 << n); j++) {
            dp[i][j] = INF;
        }
    }

    for (int i = 0; i < m; i++) {
        for (int j = 0; j < (1 << n); j++) {
            dp[i + 1][j] = min(dp[i + 1][j], dp[i][j]);
            int a = j | p[i].second;
            dp[i + 1][a] = min(dp[i + 1][a], dp[i][a]);
            dp[i + 1][a] = min(dp[i + 1][a], dp[i][j] + p[i].first);
        }
    }

    printf("%d\n", (dp[m][(1 << n) - 1] == INF) ? -1 : dp[m][(1 << n) - 1]);
    return 0;
}


Measured memory_bytes: 16128
#include<stdio.h>
 
int main(){
  long int i,n,a,b;
  scanf("%ld",&n);
  
  for(i=1; i*i<=n; i++){
     if(n%i==0){
       a=i;
       b=n/a;
    }
  }
  printf("%ld",a+b-2);
  return 0;
}

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

int main(){
  string s; int k; cin>>s>>k;

  int n=s.size();
  vector<string> subst;

  for(int l=1; l<=5; ++l){
    for(int i=0; i<n-l+1; ++i){
      subst.push_back(s.substr(i,l));
    }
  }

  sort(subst.begin(),subst.end());
  unique(subst.begin(),subst.end());
  cout<<subst[k-1]<<endl;
}


Measured memory_bytes: 1660
#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define rep_start(a,i,n) for(ll i=a;i<=n;i++)
#define rev(i,n) for(ll i=n-1;i>=0;i--)
#define rev1(i,n) for(ll i=n;i>0;i--)
#define sz(a) int((a).size())
#define all(c) c.begin(),c.end()
#define tr(c,i) for(typeof(c).begin() i+=c.begin; i!=c.end(); i++)
#define present(c,x) (c.find(x)!=c.end())
#define cpresent(c,x) (find(all(c),x)!=c.end())
#define pb push_back
#define F first
#define S second
#define INF INT_MAX
#define mod 1000000007
#define print1(a) cout<<a<<"\n";
#define print2(a,b) cout<<a<<" "<<b<<"\n";
#define print3(a,b,c) cout<<a<<" "<<b<<" "<<c<<"\n";
#define mt make_tuple
#define eb emplace_back

typedef long long int ll;
typedef vector<ll> vi;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef pair<ll,ll> ii;
typedef vector<ii> vii;
typedef tuple<int,int,int> State;

void solve(){
    ll k,a,b,tmp;cin>>k>>a>>b;
    if(a%k!=0) tmp=a/k*k+k;
    else tmp=a;
    if(tmp>=a && tmp<=b) cout<<"OK";
    else cout<<"NG";
}

signed main() {
    // your code goes here
    IOS
    ll t=1;
    //cin>>t;
    rep1(i,t){
        solve(); 
    }
    return 0;
}

Measured memory_bytes: 3660
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
#include <climits>
#include <fstream>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
//typedef pair<ll, ll> P;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define revrep(i, n) for(int i = (n)-1; i >= 0; i--)
#define pb push_back
#define f first
#define s second
#define chmin(x, y) x = min(x, y);
#define chmax(x, y) x = max(x, y);
#define sz(a) (int)(a).size()

//const ll INFL = LLONG_MAX;//10^18 = 2^60
const ll INFL = 1LL<<60;
//const int INF = INT_MAX;
const int INF = 1 << 30;//10^9
ll MOD = 1000000007;
//ll MOD = 998244353;
double EPS = 1e-11;

vector<ll> dy = {0, 1, 0, -1, 1, 1, -1, -1, 0};
vector<ll> dx = {1, 0, -1, 0, 1, -1, 1, -1, 0};

void pres(double A){printf("%.12lf\n", A);}
void BinarySay(ll x, ll y = 60){rep(i, y) cout << (x>>(y-1-i) & 1); cout << endl;}
ll cnt_bit(ll x){return __builtin_popcountll(x);}

ll pow_long(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2) res *= x;
    x *= x; k /= 2;
  }
  return res;
}

ll pow_mod(ll x, ll k){
  x %= MOD;
  ll res = 1;
  while(k > 0){
    if(k % 2){
      res *= x; res %= MOD;
    }
    x *= x; x %= MOD;
    k /= 2;
  }
  return res;
}

ll inverse(ll x){return pow_mod(x, MOD - 2);};

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

ll lcm(ll x, ll y){
  ll res = x / gcd(x, y);
  res *= y;
  return res;
};


//コンビネーション
const int MAXcomb = 2000010;
ll fac[MAXcomb], finv[MAXcomb], inv[MAXcomb];
//facはn!,finvは1/n!
//invは逆元
void COMinit(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < MAXcomb; i++){
        fac[i] = fac[i-1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
        finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
ll comb(int n, int k){
    if(n < k) return 0;
    if(n < 0 || k < 0) return 0;
    return fac[n] * finv[k] % MOD * finv[n-k] % MOD;
}

const int MAXkai = 200010;
ll kai_memo[MAXkai];
ll kai(ll N){
  if(kai_memo[N] != 0) return kai_memo[N];
  if(N <= 1) return 1;
  return kai_memo[N] = N * kai(N-1) % MOD;
}

ll disit(ll s, ll base = 10){
  ll res = 0;
  while(s){
    res++;
    s /= base;
  }
  return res;
}

//素因数分解O(√n)
vector<pair<ll, ll>> MakePrimeList(ll x) {
    vector<pair<ll, ll>> res;
    for(ll k=2; k*k<=x; k++) {
        if(x % k == 0) {
            ll cnt = 0;
            while(x % k == 0){
              x /= k;
              cnt++;
            }
            res.pb({k, cnt});
        }
    }
    if(x > 1) res.push_back({x, 1});
    return res;
}


void solve(){
  ll N, R;
  cin >> N >> R;
  if(N >= 10) cout << R << endl;
  else cout << R + 100 * (10 - N) << endl;
}

int main(){
  ios_base::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
  solve();
}


Measured memory_bytes: 256
import java.util.Scanner;

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

        if(N%1000==0){
            System.out.println(0);
        }
        else{
            System.out.println(1000-N%1000);
        }
    }
}

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

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

int h,v;

bool valid(int a,int b){
	return (a<h && a>=0 && b<v && b>=0);
}

int main(){
	cin>>h>>v;
	char c[21][21];
	int mx=0;
	for (int i=0;i<h;i++)
		for (int j=0;j<v;j++)
			 cin>>c[i][j];
	for (int i=0;i<h;i++)
		for (int j=0;j<v;j++){
			if (c[i][j]=='#') continue;
			for (int ii=0;ii<h;ii++)
				for (int jj=0;jj<v;jj++){
					if (c[ii][jj]=='#') continue;
					int d[21][21];
					for (int k=0;k<h;k++)
						for (int kk=0;kk<v;kk++)
							d[k][kk]=-1;
					queue<pair<int,int> > q;
					q.push(make_pair(i,j));
					d[i][j]=0;
					
					while (!q.empty()){
						int x=q.front().first;
						int y=q.front().second;
						q.pop();
						for (int k=0;k<4;k++){
							int nx=dx[k]+x;
							int ny=dy[k]+y;
							if (d[nx][ny]==-1 && c[nx][ny]=='.' && valid(nx,ny)){
								d[nx][ny]=d[x][y]+1;
								q.push(make_pair(nx,ny));
							}
						}
					}
					mx=max(d[ii][jj],mx);
				}
		}
	cout<<mx<<endl;
	return 0;
}

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

//#pragma GCC optimize("O3")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("avx,avx2,fma")

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef vector<pii> vpii;
typedef vector<pil> vpil;
typedef vector<pli> vpli;
typedef set<int> si;
typedef set<ll> sll;
typedef map<int, int> mii;
typedef map<ll, ll> mll;

const double pi = acos(-1.0);
const long long INF = 2e18;

#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz size()
#define in insert
#define endl "\n"

#define sqr(a) ((a) * (a))
#define jor(a) !(a&1)// jor means EVEN number
#define bjor(a) (a&1)// bjor means ODD number

#define all(a)  a.begin(), a.end()
#define mem(arr, b) memset(arr, b, sizeof(arr)) //memset only for -1 and 0
//fill(a, a+n, 5) //fill for any value

#define for0(i,b) for(int i=0;i<(b);i++)
#define for1(i,b) for(int i=1;i<=(b);i++)
#define forab(i,a,b) for(int i=(a);i<=(b);i++)
#define forba(i,b,a) for(int i=(b);i>=(a);i--)
#define rep(i,a,b,c) for(int i=(a);i!=(b);i+=(c))

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define fileRead freopen("input.txt", "r", stdin);
#define fileWrite freopen("output.txt", "w", stdout);

void print(int a[], int n){ // for testing or debugging
    for(int i=0;i<n;i++)cout<<a[i]<<" "; cout<<endl;
}

//-------------------------------------------------------------------\\

vll f(ll n){
    vll v;
    while(n){
        v.pb(n%26);
        if(n%26==0) n--;
        n/=26;
    }
    reverse(v.begin(),v.end());
    return v;
}

int main()
{
    ll n; cin>>n;
    vll v = f(n);
    
    char c[26]; 
    c[0]='z';
    char x = 'a';
    for1(i,25) c[i]=x, x++;
    
    string s="";
    for(auto t:v)
    {
        s+=c[t];
    }
    
    cout<<s;
}

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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod =(1e9)+7;
using P = pair<ll,ll>;

int main(){
    ll n,m;cin >>n>>m;
    map<ll,ll>mp;
    for (ll i = 1; i*i<=m; ++i) {
        if(m%i==0){
            mp[i]++;
            mp[m/i]++;
        }
    }
    ll ans=1;
    for(auto u:mp){
        if(m/u.first>=n){
            ans=max(ans,u.first);
        }
    }
    cout <<ans <<endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; (i) < (int)(n); ++ (i))
#define REP3(i, m, n) for (int i = (m); (i) < (int)(n); ++ (i))
#define REP_R(i, n) for (int i = (int)(n) - 1; (i) >= 0; -- (i))
#define REP3R(i, m, n) for (int i = (int)(n) - 1; (i) >= (int)(m); -- (i))
#define ALL(x) ::std::begin(x), ::std::end(x)
using namespace std;


vector<int> solve(int n, const vector<int64_t> & a, const vector<vector<int> > & g) {
    vector<int> ans(n);
    vector<int64_t> l;  // l[i] is the last element of the increasing subsequence whose length is i + 1
    function<void (int, int)> go = [&](int i, int parent) {
        int64_t x = a[i];
        int k = lower_bound(l.begin(), l.end(), x) - l.begin();
        bool pushed = k == (int)l.size();
        if (pushed) {
            l.push_back(x);
        } else {
            swap(l[k], x);
        }
        ans[i] = l.size();
        for (int j : g[i]) if (j != parent) {
            go(j, i);
        }
        if (pushed) {
            l.pop_back();
        } else {
            swap(l[k], x);
        }
    };
    go(0, -1);
    return ans;
}

// generated by online-judge-template-generator v4.1.0 (https://github.com/kmyk/online-judge-template-generator)
int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    constexpr char endl = '\n';
    int N;
    cin >> N;
    vector<int64_t> a(N);
    REP (i, N) {
        cin >> a[i];
    }
    vector<vector<int> > g(N);
    REP (i, N - 1) {
        int u, v; cin >> u >> v;
        -- u;
        -- v;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    auto ans = solve(N, a, g);
    REP (i, N) {
        cout << ans[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 36572
//daddy's back in town, back to rolling the damn hash yoooo babeeeeees//
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define dbg(x) cout << #x << '=' << x << '\n';
#define ll long long
#define x first
#define y second
#define pi pair <int, int>
#define vi vector <int>
#define L nod<<1
#define R ((nod<<1)|1)
const ll mod = 998244353;
#define int ll
int n, p2, p5, a=2, b=5;

int32_t main(){
	ios_base :: sync_with_stdio(0); cin.tie(); cout.tie();
	mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	cin>>n;
	if(n%2){
		int k=(n+1)/2;
		while(a<=2*k){
			p2+=(2*k)/a;
			p2-=k/a;
			a*=2;
		}
		p2-=k;
		while(b<=2*k){
			p5+=(2*k)/b;
			p5-=k/b;
			b*=5;
		}
	}
	else{
		int k=n/2;
		while(a<=k){
			p2+=k/a;
			a*=2;
		}
		p2+=k;
		while(b<=k){
			p5+=k/b;
			b*=5;
		}
	}
	//cout<<p2<<" "<<p5<<endl;
	cout<<min(p2, p5);
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<string>
#include<iostream>
#include<cctype>
#include<cstdio>
#include<vector>
#include<stack>
#include<queue>
#include <algorithm>
#include<math.h>
#include<set>
#include<map>
#include <sstream>
#include<iomanip>
#include <ctype.h>

//#include<bits/stdc++.h>


using namespace std;



int main() {

	long long  int a, b, c;
	cin >> a >> b >> c;
	long long int ans = 0,m=0;
	if (b > c) {
		cout << 0 << endl;
		return 0;
	}
	m = b*a - b;
	m += c;
	/*
	if (a == 1) {
		cout << max(c - b + 1,0) << endl;
	}
	*/cout << max(c*a-c+b - m+1,(long long int)0) << endl;

	return 0;

}




Measured memory_bytes: 256
#coding:utf-8
import heapq

A, B, M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

price = min(a) + min(b)

for i in range(M):
    x, y, c = map(int, input().split())
    total = a[x-1] + b[y-1] - c
    if price > total:
        price = total

print(price)

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

# define Rep(i,a,b) for(int i=a;i<=b;i++)
# define _Rep(i,a,b) for(int i=a;i>=b;i--)
# define RepG(i,u) for(int i=head[u];~i;i=e[i].next)

typedef long long ll;

const int N=1e5+5;

template<typename T> void read(T &x){
   x=0;int f=1;
   char c=getchar();
   for(;!isdigit(c);c=getchar())if(c=='-')f=-1;
   for(;isdigit(c);c=getchar())x=(x<<1)+(x<<3)+c-'0';
    x*=f;
}

int n,m;
int a[N],high[N];
int ans;

int main()
{
    read(n),read(m);
    Rep(i,1,n)read(a[i]);
    Rep(i,1,m){
        int x,y;
        read(x),read(y);
        high[x]=max(high[x],a[y]);
        high[y]=max(high[y],a[x]);
    }
    Rep(i,1,n)if(high[i]<a[i])ans++;
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 4544
import sys
sys.setrecursionlimit(10**6)
# input = sys.stdin.readline
ii = lambda: int(input())
mis = lambda: map(int,input().split())
lmis = lambda: list(mis())
INF = float('inf')

def main():
    r=ii()
    print(r**2)    



if __name__ == "__main__":
    main()

Measured memory_bytes: 3060
#include<cstdio>
#include<algorithm>
using namespace std;
const int maxn=205;
bool exist[maxn];
int main()
{
    int x,n;
    scanf("%d%d",&x,&n);
    for(int i=1;i<=n;i++)
    {
        int a;
        scanf("%d",&a);
        exist[a]=true;
    }
    for(int d=0;;d++)
    {
        if(!exist[x-d])
        {
            printf("%d\n",x-d);
            return 0;
        }
        if(!exist[x+d])
        {
            printf("%d\n",x+d);
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 1732
import math
from collections import defaultdict
pc = True
n = int(input())
a = list(map(int,input().split()))
g = math.gcd(a[0],a[1])
for i in range(2,n):
    g = math.gcd(g,a[i])
M = max(a)
class Sieve_of_Eratosthenes:
    def __init__(self, N):
        self.sieve = [-1] * (N+1)

        for i in range(2,N+1):
            if self.sieve[i] == -1:
                for j in range(1,1+N//i):
                    self.sieve[i*j] = i

    def isprime(self, num):
        if num <= 1:
            return False
        else:
            return self.sieve[num] == num

    def factorization(self, num):
        ret = set([])
        while num != 1:
            div = self.sieve[num]
            ret.add(div)
            num //= div
        return ret

sofe = Sieve_of_Eratosthenes(M)
ddic = defaultdict()
judge = set([])

for i in a:
    if not pc:
        break
    asf = sofe.factorization(i)
    
    if judge & asf != set():
        pc = False
    judge |= asf
if pc:
    print("pairwise coprime")
elif g == 1:
    print("setwise coprime")
else:
    print("not coprime")

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

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

    ll h = 2, l = 2;
    for (int i = k - 1; i >= 0; i--) {
        ll qh = h / a[i];
        ll ql = (l + a[i] - 1) / a[i];
        if (qh < ql) {
            cout << -1 << endl;
            return 0;
        }
        h = a[i] * (qh + 1) - 1;
        l = a[i] * ql;
    }
    cout << l << " " << h << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
int main() {
	int i, j, n, t, sw = 0, mini, a[100], flag = 1;
	scanf("%d", &n);
	flag = 1;
	for (i = 0; i < n; i++)scanf("%d", &a[i]);
	for (i = 0; flag; i++) {
		flag = 0;
		for (j = n - 1; j >= i + 1; j--) {
			if (a[j] < a[j - 1]) {
				t = a[j];
				a[j] = a[j - 1];
				a[j - 1] = t;
				sw++;
				flag = 1;
			}
		}
	}
	for (i = 0; i < n; i++) {
		printf("%d", a[i]);
		if (i != n - 1)printf(" ");
	}
	printf("\n%d\n", sw);
	return 0;
}

Measured memory_bytes: 604
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MAXN 100100
const ll inf = (ll)1e10;
const ll MOD = (ll)1e9+7;
ll dp[22][1 << 22];
bool chk ( int pos, int mask ) {
	return mask & (1 << pos);
}
int on ( int pos, int mask ) {
	return mask | (1<<pos);
}
int n, done;
int adj[21][21];
ll solve(ll pos , ll mask){
    if(dp[pos][mask] != -1) return dp[pos][mask];
    if (pos == n){
        if (mask == done - 1) {
            return 1;
        } else return 0;
    }
    dp[pos][mask] = 0;
    for(int j = 0 ; j < n; j++){
        if (adj[pos][j] && !(mask & (1<<j) ) ) dp[pos][mask] = (dp[pos][mask] + solve ( pos+1, mask|(1<<j) ) ) %MOD;
    }
    return dp[pos][mask];
}
int main()
{
	#ifdef __APPLE__
	//freopen("in.txt","r",stdin);
	//freopen("out.txt","w",stdout);
	#endif
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin >> n;
	for ( int i = 0; i < n; i++ ) {
		for ( int j = 0; j < n; j++ ) {
			cin >> adj[i][j];
		}
	}
	done = (1<<n);
	memset(dp,-1,sizeof(dp));
	cout << solve(0,0) << endl;
	return 0;
}


Measured memory_bytes: 721152
N = int(input())
A = [int(x) for x in input().split()]
A = sorted(A)

p = 1
limit = 10 ** 18
for a in A:
    if a == 0:
        print(0)
        exit()
    p *= a
    if p > limit:
        print(-1)
        exit()
print(p)


Measured memory_bytes: 21584
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define MAX 1000000000000000
#define all(v) v.begin(),v.end()
#define rep(i,a,b) for(i=(ll)a;i<(ll)b;i++)
#define revrep(i,a,b) for(i=(ll)a;i>=(ll)b;i--)
#define ii pair<ll,pair<ll,ll> >
#define MP make_pair
#define pb push_back
#define f first
#define se second
#define ll long long int
#define vi vector<ii>
ll modexp(ll a,ll b){ ll res = 1; while(b > 0){  if(b & 1) res = (res * a);  a = (a * a);  b/=2;  }  return res; }
#define rs resize
long long readLI(){  register char c;  for(c = getchar(); !(c>='0' && c<='9'); c = getchar());  register long long a=c-'0';
    for(c = getchar(); c>='0' && c<='9'; c = getchar())
        a = (a<<3)+(a<<1)+c-'0';
    return a;
}
const ll N = 1000009;
ll n,a,b;
int main()
{
    std::ios_base::sync_with_stdio(false); cin.tie(NULL);
    cin>>n>>a>>b;
    cout<<min(n * a,b);
    return 0;
}

Measured memory_bytes: 384
#include<cstdio>
using namespace std;
int main()
{
	int n,i,j,x;
	int a[1000];
	double s;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	for(i=0;i<n-1;i++){
		for(j=i+1;j<n;j++){
			if(a[i]>a[j]){
				x=a[i];
				a[i]=a[j];
				a[j]=x;
			}
		}
	}
	s=(double)(a[0]+a[1])/2;
	for(i=2;i<n;i++){
		s=(double)(s+a[i])/2;
	}
	printf("%lf\n",s);
	return 0;
}

Measured memory_bytes: 128
n, m = map(int, input().split())
listm=[0 for i in range(m)]
for i in range(n):
    l = list(map(int, input().split()))
    for a in l[1:]:
        listm[a-1] += 1
ans = 0
for listmitem in listm:
    if listmitem == n:
        ans += 1
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007, INF=(1LL<<60);
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    int h , w, k;
    cin >> h >> w >> k;
    string s[h];
    for(int i=0;i<h;i++) cin >> s[i];
    int ans = 0;
    int maki = 1 << h;
    int niko = 1 << w;
    for(int bit1 = 0; bit1 < maki ; bit1++){
      for(int bit2 = 0; bit2 < niko ; bit2 ++){
        int cnt = 0;
        for(int i=0;i<h;i++){
          for(int j=0;j<w;j++){
            if(s[i][j] == '#' && !(bit1 >> i & 1 || bit2 >> j & 1)) cnt++;
          }
        }
        if(cnt == k) ans++;
      }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define F first
#define S second
//-std=c++11
#define print(x) printf("%.12f",x);
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define rep(i, n) for(int i =0 ; i < n; ++i)
#define repr(i, n) for(int i=n-1;i>=0;i--)
#define Rep(i,a,b) for(int i=a;i<=b;i++)
#define Repr(i,a,b) for(int i=a;i>=b;i--)
#define pii pair < int, int >
#define iter ::iterator
#define forit(a) for(it=a.begin();it!=a.end();it++)
typedef vector<int> vi;
typedef  long long ll;
const int inf = int(1e9);
const int mod = inf + 7;
const int N = (int)2e5 + 5;
void solve(){
	int n;
	cin>>n;
	cout<<(n%2==0?n/2:n/2+1);
	
}


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

Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees#, log2, log
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
from decimal import Decimal
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()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
from decimal import *

N = INT()
a = LIST()

ave = sum(a)/N

b = [[abs(x-ave), i] for i, x in enumerate(a)]

b.sort(key = lambda x: (x[0], x[1]))

print(b[0][1])


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

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("YES")
#define p_no() p("NO")

const ll mod = 1e9 + 7;
const ll inf = 1e18;

const ll C = 1e9;

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

    // input
    ll S;
    cin >> S;

    ll x1 = C;
    ll x2 = 1;

    ll y1, y2;
    if(S%C==0){
        y1 = 0;
        y2 = S/C;        
    }else{
        y2 = (S+1e9-1)/1e9; // 切り上げ！
        y1 = x1 * y2 - S;
    }

    cout << "0 0 " << x1 << ' ' << y1 << ' ' << x2 << ' ' << y2 << endl;

    return 0;
}

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

// long long gcd(long long a, long long b) { return b != 0 ? gcd(b, a % b) : a;
// }

// int binary_search(int key) {
//     int ng = -1;
//     int ok = (int)a.size();
//     while(abs(ok - ng) > 1) {
//         int mid = (ok + ng) / 2;
//         if(isOK(mid, key))
//             ok = mid;
//         else
//             ng = mid;
//     }
//     return ok;
// }

// cout << fixed << setprecision(10);
// vector<vector<int>> vec(H, vector<int>(W))    // int H*W
// int MOD = 1000000007;

int main() {
    long long H, W;
    cin >> H >> W;
    long long ans;
    if(H==1 || W == 1) {
        ans = 1;
    }else{
        ans =(H*W+1)/2;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define SPEED ios_base::sync_with_stdio(false); cin.tie(NULL);
#define FOR(i, a, b) for (ll i = a; i < b; ++i)
#define RFOR(i, b, a) for (ll i = b; i >= a; --i)
#define ALL(x) x.begin(), x.end()
#define DEBUG(args...) { string _s = #args; replace(ALL(_s), ' ', '\0');\
replace(ALL(_s), ',', ' ');\
stringstream _ss(_s); istream_iterator<string> _it(_ss); _debug(_it, args);}
#define endl "\n"
#define F first
#define S second
#define pb(x) push_back(x)a
#define mp(x, y) make_pair(x, y)

using namespace std;
using namespace __gnu_pbds;

template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

void _debug(istream_iterator<string>) {}
template<typename T, typename... Args>
void _debug(istream_iterator<string> it, T first, Args... args) {
    cerr << ">> " << *it << " : " << first << endl; _debug(++it, args...);
}
template <typename T1, typename T2>
inline ostream& operator << (ostream& out, const pair<T1, T2>& p) {
    return out << "(" << p.F << ", " << p.S << ")";
}
template<typename T>
inline ostream& operator << (ostream& out, const vector<T>& v) {
    if (v.empty()) return out << "[]";
    else { out << '['; for (auto& e : v) { out << e << ", "; } return out << "\b\b]"; }
}
template<typename T>
inline ostream& operator << (ostream& out, const set<T>& s) {
    if (s.empty()) return out << "{}";
    else { out << '{'; for (auto& e : s) { out << e << ", "; } return out << "\b\b}"; }
}
template<typename T>
inline ostream& operator << (ostream& out, const unordered_set<T>& s) {
    return out << set<T>(ALL(s));
}
template<typename T1, typename T2>
inline ostream& operator << (ostream& out, const map<T1, T2>& m) {
    if (m.empty()) return out << "{}";
    out << '{'; for (auto& p : m) { out << p << ", "; } return out << "\b\b}";
}
template<typename T1, typename T2>
inline ostream& operator << (ostream& out, const unordered_map<T1, T2>& m) {
    return out << map<T1, T2>(ALL(m));
}
template<typename T>
inline ostream& operator << (ostream& out, const ordered_set<T>& s) {
    return out << set<T>(ALL(s));
}

typedef long long ll;
typedef long double ld;
typedef vector<long long> vll;
typedef pair<ll, ll> pll;
typedef vector<pair<ll, ll>> vpll;
typedef unordered_map<ll, ll> STll;
/************************************** MAIN PROGRAM ********************************************/

int main()
{
    //freopen("input.txt", "r", stdin);
    SPEED
    string s, t;
    cin >> s >> t;
    int ans = 0;
    for (int i = 0; i < s.size(); ++i) {
        ans += s[i] != t[i];
    }
    cout << ans;
}
/************************************** END OF PROGRAM ******************************************/
/** Stuff you should look for:
 * int overflow, array bounds, over-counting
 * special cases (n=1?), set/unordered_set TLE, multi-set/set error
 * do something instead of nothing and stay organized
 */


Measured memory_bytes: 3796
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <vector>

static const int IINF = 1 << 30;
static const long long LINF = 1LL << 60;
static const long long MOD = 1.0e+9 + 7;

template <typename T> std::vector<T> vectors(std::size_t n, T val) {
  return std::vector<T>(n, val);
}

template <typename T, typename... Args>
auto vectors(std::size_t n, Args... args) {
  return std::vector<decltype(vectors<T>(args...))>(n, vectors<T>(args...));
}

template <class T> inline bool chmin(T &a, const T &b) {
  return (a > b) ? a = b, true : false;
}

template <class T> inline bool chmax(T &a, const T &b) {
  return (a < b) ? a = b, true : false;
}

template <class T> inline void chadd(T &a, const T &b) {
  a += b, a %= MOD;
  // TODO minus case
}

template <class T>
std::ostream &operator<<(std::ostream &s, const std::vector<T> &v) {
  if (v.empty())
    return s;
  s << *v.begin();
  for (auto iter = v.begin() + 1; iter != v.end(); ++iter)
    if (std::is_fundamental<T>::value)
      s << " " << *iter;
    else
      s << std::endl << *iter;
  return s;
}

int main() {
  // Input
  int N, K;
  std::cin >> N >> K;
  std::vector<int> a(N - 1);
  std::vector<int> b(N - 1);
  for (int i = 0; i < N - 1; ++i) {
    int a_, b_;
    std::cin >> a_ >> b_;
    a[i] = a_ - 1;
    b[i] = b_ - 1;
  }

  using Graph = std::vector<std::vector<int>>;
  Graph G;

  G.resize(N);
  for (int i = 0; i < N - 1; ++i) {
    G[a[i]].push_back(b[i]);
    G[b[i]].push_back(a[i]);
  }

  // Main
  long long res = K;

  std::queue<int> que;
  std::vector<int> visited(N, -1);
  visited[0] = 0;
  que.push(0);
  while (not que.empty()) {
    int v = que.front();
    que.pop();
    int num;
    if (visited[v] == 0)
      num = K - 1;
    if (visited[v] >= 1)
      num = K - 2;
    for (auto c : G[v]) {
      if (visited[c] != -1)
        continue;
      res = (res * num) % MOD;
      --num;
      visited[c] = visited[v] + 1;
      que.push(c);
    }
  }

  // Output
  std::cout << res << std::endl;

  return 0;
}


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

using namespace std;

int numA_s[100001], numA_t[100001];

int calc_invariant(int *a, int l, int r)
{
  int A_num = a[r] - a[l - 1];
  int B_num = (r - l + 1) - A_num;
  return (A_num + B_num * 2) % 3;
}

int main()
{
  char s[100002], t[100002];
  int n, m;
  
  scanf("%s", &s[1]);
  scanf("%s", &t[1]);
  
  n = strlen(&s[1]);
  m = strlen(&t[1]);
  
  for (int i = 1; i <= n; i++) {
    numA_s[i] = (s[i] == 'A') + numA_s[i - 1];
  }
  
  for (int i = 1; i <= m; i++) {
    numA_t[i] = (t[i] == 'A') + numA_t[i - 1];
  }
  
  int q;
  scanf("%d", &q);
  
  for (int i = 0; i < q; i++) {
    int a, b, c, d;
    scanf("%d %d %d %d", &a, &b, &c, &d);
    if (calc_invariant(numA_s, a, b) == calc_invariant(numA_t, c, d)) {
      printf("YES\n");
    }
    else {
      printf("NO\n");
    }
  }
  
  return 0;
}

Measured memory_bytes: 1536
using System;

class Program
{
    static void Main()
    {
        for(; ; )
        {
            var line = Console.ReadLine().Split(' ');
            var a = int.Parse(line[0]);
            var op = char.Parse(line[1]);
            var b = int.Parse(line[2]);
            int ans = -99999;

            if (op == '?') break;
            switch (op)
            {
                case '+': ans = a + b; break;
                case '-': ans = a - b; break;
                case '*': ans = a * b; break;
                case '/': ans = a / b; break;
            }
            Console.WriteLine(ans);
        }
    }

}


Measured memory_bytes: 7836
#include <bits/stdc++.h>
#define rep(i,n) for(ll i = 0; i < (ll)(n); ++i)
#define MOD 1000000007

using namespace std;
using ll = long long;

int mp[1005][1005] = {};

int main() {
	int h, w;
	cin >> h >> w;
	int sx, sy, gx, gy;
	cin >> sy >> sx >> gy >> gx;
	rep(i,1002) rep(j, 1002) {
		if (i % (h + 1) == 0 || j % (w + 1) == 0) mp[i][j] = -1;
		else mp[i][j] = 1e9;
	}
	rep(i, h) {
		string s;
		cin >> s;
		rep(j, w) if (s[j] != '.') mp[i + 1][j + 1] = -1;
	}
	deque<pair<int, pair<int, int>>> q;
	mp[sy][sx] = 0;
	q.emplace_back(0, make_pair(sy, sx));
	while (q.size()) {
		int cost = q.front().first;
		int y = q.front().second.first;
		int x = q.front().second.second;
		q.pop_front();
		if (mp[y][x] < cost)continue;
		for (int i = y - 2; i <= y + 2; i++) {
			for (int j = x - 2; j <= x + 2; j++) {
				if(i < 1 || h < i || j < 1 || w < j) continue;
				if (i == y && j == x) continue;
				if (abs(i - y) + abs(j - x) == 1 && mp[i][j] > cost) {
					mp[i][j] = cost;
					q.emplace_front(cost, make_pair(i, j));
				}
				else if (mp[i][j] > cost + 1){
					mp[i][j] = cost + 1;
					q.emplace_back(cost + 1, make_pair(i, j));
				}
			}
		}
	}
	if (mp[gy][gx] == 1e9) mp[gy][gx] = -1;
	cout << mp[gy][gx] << endl;
	return 0;
}


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


int N;
vector<int> A;


void input() {
    cin >> N;
    A = vector<int>(N);
    rep(i, N) cin >> A[i];
}


int main() {
    input();
    set<int> s;
    rep(i, N) {
        if (s.count(A[i])) {
            cout << "NO" << endl;
            return 0;
        }
        s.insert(A[i]);
    }
    cout << "YES" << endl;
}


Measured memory_bytes: 10368
#include <bits/stdc++.h>
using namespace std;
 
int main() {
int N,M;
  cin >> N >> M;
  long long result = 0;
  vector<int> B(N); 
priority_queue<int> A;
  for(int a = 0;a < N;a++)cin >> B.at(a);
  for(int a = 0;a < N;a++)A.push(B.at(a));
   for(int a = 0;a < M;a++){
     A.push(A.top() / 2);
     A.pop();
   }
  
  for(int a = 0;a < N;a++){
    result += A.top();
    A.pop();
  }
  cout << result << endl;

}

Measured memory_bytes: 1276
N = int(input())
if N == 0:
  ans = 0
else:
  ans = ""
  while N != 1:
    if N % (-2) == 0:
      ans = "0" + ans
      N = N / (-2)
    else:
      ans = "1" + ans
      N = (N-1) / (-2)
  ans = "1" + ans
print(ans)

Measured memory_bytes: 3060
import java.util.Scanner;

class Main{

	static	int[] data;




	public static void main(String[] args) {





		Scanner sc = new Scanner(System.in);			//文字の入力
		int k = sc.nextInt();
		int s = sc.nextInt();
		
		int ans = 0;
		for(int a = 0;a <= k;a++){
			for(int b = 0;b <= k;b++){
				int c =  s - (b + a);
				if(c <= k && c >= 0){
					ans++;
				}
			}
		}

		System.out.println(ans);


	}



	static void num(int n){


		int num = n;
		for(int i = 1;i <= n;i++){
			if(n % i == 0){
				data[i]++;
				n /= i;
				i = 1;
			}
		}
		return;

	}
}


class Pair implements Comparable{
	Character from;
	int end;
	@Override
	public int compareTo(Object other) {
		Pair otherpair = (Pair)other;

		return end - otherpair.end;
	}
}




Measured memory_bytes: 22996
# coding: utf-8

n, m = map(int, input().split())
pyx = list()

for i in range(m):
    p = [i]
    p += map(int, input().split())
    pyx.append(p)

pyx.sort(key=lambda x:x[2])
pcount = [1 for i in range(n+1)]

for i in pyx:
#    print(i)
    i.append(pcount[i[1]])
    pcount[i[1]] += 1
#    print(i)

pyx.sort(key=lambda x:x[0])

for i in pyx:
    print("{:0=6}{:0=6}".format(i[1], i[3]))
    

Measured memory_bytes: 39196
while True:
    amount , A, B, C, x = map(int, input().split())
    if amount == A == B == C == x == 0: break

    lille_frame = list(map(int, input().split()))
    frame_count = 0
    stop_count = 0

    while True:
        if x == lille_frame[stop_count]:
            stop_count += 1

        if stop_count == len(lille_frame):
            print(frame_count)
            break
        else:
            frame_count += 1

        if frame_count > 10000:
            print(-1)
            break

        x = (A * x + B) % C

Measured memory_bytes: 6724
#include <iostream>
#include <string>

using namespace std;

int main(int argc, char **argv)
{
	string str;
	int count = 0, h[100] = { 0 };

	while(cin >> str) {
		if(str == "-") break;
		cin >> count;
		for(int i = 0; i < count; i++) cin >> h[i];
		for(int i = 0; i < count; i++) {
			for(int j = 0; j < h[i]; j++) str+= str[j];
			for(int j = 0; j < h[i]; j++) str.erase(str.begin());
		}
		cout << str << endl;
		for(int i = 0; i < count; i++) h[i] = 0;
	}
	return 0;
}

Measured memory_bytes: 3196
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define pii std::pair<int,int>
#define pli std::pair<ll,int>
#define pil std::pair<int,ll>
#define psi std::pair<string,int>
#define pll std::pair<ll,ll>
#define pci std::pair<char,int>
#define sll(x) scanf("%lld",&x)
#define prll(x) printf("%lld ",x)
#define pri(x) printf("%d ",x)
#define si(x) scanf("%d",&x)
#define pb push_back
#define vll std::vector<ll>
#define vpi std::vector<std::pair<int,int>>
#define vi std::vector<int>
#define vvi std::vector<std::vector<int>>
#define vvpil std::vector<std::vector<std::pair<int,ll>>>
#define vlpii std::vector<std::list<pii>>
#define vlpil std::vector<std::list<pil>>
#define li std::list<int>
#define lpil std::list<pil>
#define Endl printf("\n")
#define vli vector<list<int>>
#define vvll vector<vector<ll>>
#define mp make_pair
#define x first
#define y second
#define ull uint64_t
#define ma 100000000
#define imie(...) "[" << #__VA_ARGS__": " << (__VA_ARGS__) << "] "
const ll  INF=10000000000000;
const ll mod =  1e9 + 7;
const int MAX = 300005;
using namespace std;
void add(ll& a , ll b){
	a += b;
	if(a >= mod) a -= mod;
}
ll mul(ll a , ll b){
	return (a * b) % mod;
}
ll Pow(ll a , ll b){
	if(b == 0) return 1 ;
	ll c = Pow(a , b / 2) ;
	if(b % 2) return (a * ((c * c)% mod )) % mod ;
	return (c * c) % mod ;
}

//check modulo
int main(){
	IOS;
	cout.precision(50) ;
	int n ; cin >> n ;
	ll sum = 0 ;
	vi a(n);for(int i = 0 ;  i< n ; i++) cin >> a[i] ;
	vi b(n);for(int i = 0 ; i < n ; i++) {cin >> b[i] ;sum += b[i] ;}
	vi c(n - 1) ; for(int i = 0 ;  i< n - 1 ; i++) cin >> c[i] ;
	for(int i = 0 ; i < n - 1 ; i++){
		if(a[i + 1] == a[i] + 1){
			sum += c[a[i] - 1] ;
		}
	}
	cout << sum << endl; 
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <string> 
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <functional>
#include <cctype>
#include <list>
//#include <boost/multiprecision/cpp_int.hpp>

#define BIT(a) (1 << (a))

using namespace std;
//using namespace boost::multiprecision;

long long MOD = 1000000007;


long long mod_pow(long long x, long long n){
    long long res = 1;
    for(int i = 0;i < 60; i++){
        if(n >> i & 1) res = res * x % MOD;
        x = x * x % MOD;
    }
    return res;
}


int main(void){
    set<int> ans;
    int A, B, K;
    cin >> A >> B >> K;
    for (int i = A; i < A+K && i <= B; i++){
        ans.insert(i);
    }
    for (int i = B; i > B-K && i >= A; i--){
        ans.insert(i);
    }
    for (auto itr = ans.begin(); itr != ans.end(); itr++){
        cout << *itr << endl;
    }
    return 0;
}



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

using namespace std;

vector <  pair <int ,int >  > tab;
bool so ( pair <int,int> x , pair <int,int>  y){
    if(x.second > y.second){return false;}
    if(x.second < y.second){return true;}
    return x.first < y.first;
}
int main() {
    int n , m ;
    int rez(0);
    cin >> n >> m;
    int a , b;
    for(int i = 1 ; i <= m ; i++){
        cin >> a >> b;
        tab.push_back(make_pair(a ,b));
    }
    sort(tab.begin() , tab.end() , so);
    for(int i = 0 ; i < m ; i++){
        //cout << tab[i].first << " " << tab[i].second << endl;
    }
    for(int i = 0 ; i < m ; i++){
        int k = i + 1;
        rez++;
        while ( k < m && tab[k].first < tab[i].second ){
            k++;
        }
        i = k-1;
    }
    cout << rez;
    return 0;
}

Measured memory_bytes: 1400
#include <iostream>
#include <cstdlib>
#include <time.h>
#include <algorithm>
#include <map>
#include <queue>
#include <stack>
#include <vector>
#include <array>
#include <string>
#include <iomanip>
#include <cmath>
#define _USE_MATH_DEFINES
using namespace std;

typedef long long int ll;

int main(){
	cin.sync_with_stdio(false);
	cin.tie(0);
	char c;
	cin >> c;
	if(c == 'A')
		cout << "T";
	else if(c == 'T')
		cout << "A";
	else if(c== 'G')
		cout << "C";
	else
		cout << "G";
	return 0;
}

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

int main() {
  int N;
  cin>>N;
  vector<int>a(N);
  for(int i=0;i<N;i++){
    cin>>a.at(i);
  }
  sort(a.begin(),a.end());
  reverse(a.begin(),a.end());
  int A=0;
  int B=0;
  for(int i=0; i<N;i++){
    if(i%2==0){
      A=A+a.at(i);
    }
    else{
      B=B+a.at(i);
    }
  }
  cout<<A-B<< endl;

}


Measured memory_bytes: 256