akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 

using namespace std;
using namespace __gnu_pbds; 

#define ff              first
#define ss              second
#define ll              int64_t
#define ld              long double
#define nl              cout<<"\n"
#define all(v)          v.begin(),v.end()
#define mset(a,v)       memset((a),(v),sizeof(a))
#define forn(i,a,b)     for(int64_t i=int64_t(a);i<int64_t(b);++i)
#define forb(i,a,b)     for(int64_t i=int64_t(a);i>=int64_t(b);--i)
#define fastio()        ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ordered_set     tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> 

#define mod         1000000007
#define mod2        998244353 
#define inf         1000000000000007
#define pi          3.14159265358979323846

template<class L,class R> ostream& operator<<(ostream& out,pair<L,R> &p)        {return out<<"("<<p.ff<<", "<<p.ss<<")";}
template<class T> ostream& operator<<(ostream& out,vector<T> &v)                {out<<"[";for(auto it=v.begin();it!=v.end();++it){if(it!=v.begin())out<<", ";out<<*it;}return out<<"]";}
template<class T> ostream& operator<<(ostream& out,deque<T> &v)                 {out<<"[";for(auto it=v.begin();it!=v.end();++it){if(it!=v.begin())out<<", ";out<<*it;}return out<<"]";}
template<class T> ostream& operator<<(ostream& out,set<T> &s)                   {out<<"{";for(auto it=s.begin();it!=s.end();++it){if(it!=s.begin())out<<", ";out<<*it;}return out<<"}";}
template<class L,class R> ostream& operator<<(ostream& out,map<L,R> &m)         {out<<"{";for(auto it=m.begin();it!=m.end();++it){if(it!=m.begin())out<<", ";out<<*it;}return out<<"}";}

void dbg_out() {cerr<<"]\n";}
template<typename Head,typename... Tail> 
void dbg_out(Head H,Tail... T) {cerr<<H;if(sizeof...(Tail))cerr<<", ";dbg_out(T...);}
#ifdef LOCAL
	#define dbg(...) cerr<<"["<<#__VA_ARGS__<<"] = [",dbg_out(__VA_ARGS__)
#else
	#define dbg(...)
#endif

ll count_digits(ll n)     {ll dig=floor(log10(n)+1);return dig;}
ll mpow(ll x,ll y,ll p)   {ll r=1;x=x%p;while(y>0){if(y&1)r=(r*x)%p;y=y>>1;x=(x*x)%p;}return r;}
ll mod_inv(ll a,ll m)     {ll m0=m,y=0,x=1;if(m==1)return 0;while(a>1){ll q=a/m,t=m;m=a%m,a=t;t=y;y=x-q*y;x=t;}if(x<0)x+=m0;return x;}
/* const ll MAXN=1000007;ll spf[MAXN+5];vector<ll> prime; */
/* void sieve(ll n)        {forn(i,2,MAXN+1)spf[i]=i;for(ll i=2;i*i<=n;i++)if(spf[i]==i)for(ll j=i*i;j<=n;j+=i)if(spf[j]==j)spf[j]=i;forn(i,2,MAXN+1)if(spf[i]==i)prime.push_back(i);} */

//-------------------------------L_I_Erq34-------------------------------

int main()
{
	fastio();
	ll z,n,m,t,k,i,j,l,d,h,r;
	cin>>n;
	if(n==1)
	{
		cout<<"0\n";
		return 0;
	}
	ll ans=((mpow(10,n,mod)-2*mpow(9,n,mod)+mpow(8,n,mod))%mod+mod)%mod;
	cout<<ans<<"\n";
	cerr<<"\nTime elapsed: "<<1000*clock()/CLOCKS_PER_SEC<<"ms\n";
	return 0;
}


Measured memory_bytes: 3668
#include <bits/stdc++.h>
#define PI 3.1415926535897932
#define _GLIBCXX_DEBUG
using namespace std;
int main() {
  
  int H,W;
  cin>>H>>W;
  
  vector<string> vec(H);
  for(int i=0;i<H;i++){
    cin>>vec[i];
  }
  
  for(int i=0;i<H;i++){
    cout<<vec[i]<<endl;
    cout<<vec[i]<<endl;
  }
}


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

function main()
	n,wl = readline() |> split |> parseMap
	a = [Int[0] for i in 1:4]
	w,v = readline() |> split |> parseMap
	gw = w
	b = [Int[] for i in 1:4]
	push!(b[1],v)
	for i in 2:n
		w,v = readline() |> split |> parseMap
		push!(b[w-gw+1],v)
	end
	for i in 1:4
		b[i] = sort(b[i],rev=true)
	end
	for i in 1:4
		for j in 1:length(b[i])
			push!(a[i],a[i][length(a[i])]+b[i][j])
		end
	end
	ans = 0
	for i in 1:length(a[1])
		for j in 1:length(a[2])
			for k in 1:length(a[3])
				for l in 1:length(a[4])
					if (i-1)*gw+(j-1)*(gw+1)+(k-1)*(gw+2)+(l-1)*(gw+3)<=wl
						ans = max(ans,a[1][i]+a[2][j]+a[3][k]+a[4][l])
					end
				end
			end
		end
	end
	println(ans)
end

main()

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

const int MOD = 1000000007;
const int INF = 999999999;

int main(){
    string S;
    int K;
    cin >> S >> K;
    rep(i, K){
        if(S[i] != '1'){
            cout << S[i] << endl;
            return 0;
        }
    }
    cout << 1 << endl;
return 0;}
/**
 * g++ code.cpp
 * ./a.out
 * shift + ctrl + i
**/ 

Measured memory_bytes: 256
n,m,k=map(int,input().split())
ans=0
mod=998244353
f=[1]
for i in range(n):f+=[f[-1]*(i+1)%mod]
def comb(a,b):return f[a]*pow(f[b],mod-2,mod)*pow(f[a-b],mod-2,mod)%mod
for kk in range(k+1):
  anss=m*pow(m-1,n-1-kk,mod)%mod
  anss=anss*comb(n-1,kk)%mod
  ans=(ans+anss)%mod
print(ans)

Measured memory_bytes: 82376
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>
#include <cmath>
#include <functional>
#include <queue>
#define REP(i,n) for(ll i=0;i<n;i++)
#define FOR(i,n1,n2) for(ll i=n1;i<n2;i++)
#define put(a) cout<<a<<endl;
using namespace std;
typedef long long ll;
const ll INF = 9223372036854775807-1;
const int inf = 2147483647-1;

int a,b,c,x,y;
int main() {
    cin >> a >> b >> c >> x >> y;
    int pa,pb,pc;
    int m = max(x,y);
    int res = inf;
    for(int i=0;i<=m*2;i+=2){
        int sum=0;
        sum += i*c;
        sum += max((x-i/2),0)*a;
        sum += max((y-i/2),0)*b;
        res = min(sum,res);
    }
    put(res);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rint register int
using namespace std;
bool hw(string s)
{
	for(int i=0;i+i<s.size();i++)
		if(s[i]!=s[s.size()-1-i])
			return 0;
	return 1;
}
string s;
int main()
{
	cin>>s;
	int n=s.size();
	if(hw(s) && hw(s.substr(0,(n-1)/2)) && hw(s.substr((n+1)/2,n)))
		puts("Yes");
	else
		puts("No");
	return 0;
} 

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

#define ll long long
#define ull unsigned long long

using namespace std;

int main() {
	ull X, Y, A, B, C;
	cin >> X >> Y >> A >> B >> C;

	vector <ull> p(A, 0);
	vector <ull> q(B, 0);
	vector <ull> r(C, 0);

	for (int ii = 0; ii < A; ++ii){
		cin >> p[ii];
	}
	for (int ii = 0; ii < B; ++ii){
		cin >> q[ii];
	}
	for (int ii = 0; ii < C; ++ii){
		cin >> r[ii];
	}

	//大きい順にソート
	sort(p.rbegin(), p.rend());
	sort(q.rbegin(), q.rend());
	sort(r.rbegin(), r.rend());

	//p, qを大きい方からX, Y個ずつ選ぶ
	vector <ull> pp(X, 0);
	for (int ii = 0; ii < X; ++ii){
		pp[ii] = p[ii];
	}
	vector <ull> qq(Y, 0);
	for (int ii = 0; ii < Y; ++ii){
		qq[ii] = q[ii];
	}

	//小さい順にソート
	sort(pp.begin(), pp.end());
	sort(qq.begin(), qq.end());

	//pp, qqをrで置き換える
	bool doFlag = true;
	int idxp = 0;
	int idxq = 0;
	int idxr = 0;

	// bool pMax = false;
	// bool qMax = false;
	while (doFlag && (idxr < C)) {
		//ppとqqどちらを実行するか決める
		bool doP = true;
		if (idxp == X){
			doP = false;
		} else if (idxq == Y) {
			doP = true;
		} else if (pp[idxp] > qq[idxq]) {
			doP = false;			
		}

		if ( doP ){
			//rの方が大きいなら入れ替え
			if (pp[idxp] < r[idxr]){
				pp[idxp] = r[idxr];
				idxp++;
				idxr++;
			} else {
				doFlag = false;
			}
		} 
		//qqが小さいとき
		else {
			//rの方が大きいなら入れ替え
			if (qq[idxq] < r[idxr]){
				qq[idxq] = r[idxr];
				idxq++;
				idxr++;
			} else {
				doFlag = false;
			}
		}

		if ( (idxp == X) && (idxq == Y) ){
			doFlag = false;
		}
	}

	ull sum = 0;
	for (int ii = 0; ii < pp.size(); ++ii){
		sum += pp[ii];
	}
	for (int ii = 0; ii < qq.size(); ++ii){
		sum += qq[ii];
	}

	cout << sum << endl;

	return 0;
}


Measured memory_bytes: 3968
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (in i = 0; i < (in)(n); i++)
#define REP(i,a,b) for(in i=(in)(a);i<(in)(b);i++)
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
const double PI=3.14159265358979323846;
const in MOD = 1000000007;
const in INF=1e18+7;
const in inf=1e9+7;
using P=pair<in,in>;
vector<in> dx={0,1,-1,0};
vector<in> dy={1,0,0,-1};

using T=tuple<in,in,in,in>;

struct edge{in to; in cost;};
vector<vector<edge>> graph(0);
vector<in> d(0);
const in MAX_dist=INF;

void init(in n){
    graph.resize(n);
    d.resize(n,MAX_dist);
}

void dijkstra(in s){
    if(d.size()==0){cout<<"You Should init"<<endl;return;}
    priority_queue<P, vector<P>, greater<P>> que;
    d[s]=0;
    que.emplace(0,s);
    while(!que.empty()){
        P p=que.top();
        que.pop();
        in v=p.second;
        if(d[v]<p.first) continue;
        rep(i,graph[v].size()){
            edge e=graph[v][i];
            if(d[e.to]>d[v]+e.cost){
            d[e.to]=d[v]+e.cost;
            que.emplace(d[e.to],e.to);
            }
        }
    }
}

int main(){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cout << fixed << setprecision(10);
    in n,m,s;
    cin>>n>>m>>s;
    vector<T> a(m);
    in x,y,z,w;
    rep(i,m){
        cin>>x>>y>>z>>w;
        x --,y --;
        a[i]=T(x,y,z,w);
    }
    vector<P> b(n);
    rep(i,n){
        cin>>x>>y;
        b[i]=P(x,y);
    }
    in ed=50ll*m+1;
    init(n*ed);
    rep(i,n){
        rep(j,ed-1){
            if(j+b[i].first<ed){
                graph[i*ed+j].push_back({i*ed+j+b[i].first,b[i].second});
            }
            else{
                graph[i*ed+j].push_back({(i+1)*ed-1,b[i].second});
            }
        }
    }
    rep(i,m){
        tie(x,y,z,w)=a[i];
        rep(j,ed){
            if(j<z) continue;
            graph[x*ed+j].push_back({y*ed+j-z,w});
            graph[y*ed+j].push_back({x*ed+j-z,w});
        }
    }
    s=min(s,ed-1);
    dijkstra(s);
    REP(i,1,n){
        in ans=INF;
        rep(j,ed){
            ans=min(ans,d[i*ed+j]);
        }
        cout<<ans<<'\n';
    }
}/*
./problem.exe
*/

Measured memory_bytes: 44596
#include <bits/stdc++.h>
using namespace std;
#define INF -100000000000000000000000
int main()
{
    long long a[4];
    cin >> a[0] >> a[1] >> a[2] >> a[3];
    long long ans = INF;
    for (int i = 0; i < 2; i++)
    {
        for (int j = 2; j < 4; j++)
        {
            ans = max(ans, a[i] * a[j]);
        }
    }
    cout << ans << endl;
}


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

int main() {
    ll n, m, qw = 1e9 + 7;
    cin >> n >> m;
    string s;
    ll dp[n + 1][m + 1];
    bool field[n + 1][m + 1];
    For(i, n) {
        For(j, m) {
            field[i][j] = true;
            dp[i][j] = 0;
        }
    }
    For(i, n) {
        cin >> s;
        For(j, m) {
            if(s[j - 1] == '#') field[i][j] = false;
        }
    }
    dp[1][1] = 1;
    For(i, n) {
        For(j, m) {
            if(i > 1) {
                if(field[i - 1][j]) dp[i][j] += dp[i - 1][j];
            }
            if(j > 1) {
                if(field[i][j - 1]) dp[i][j] += dp[i][j - 1];
            }
            dp[i][j] %= qw;
        }
    }
    cout << dp[n][m] % qw;
    return 0;
}

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

int a[110];

int main(){
	int n, m, x, l=0, r=0;
	cin >> n >> m >> x;
	for(int i=0; i<m; i++){
		cin >> a[i];
		if(a[i]<x) l++;
		else if(a[i]>x) r++;
	}
	cout << min(l, r) << endl;
}

Measured memory_bytes: 768
#include<iostream>
#include<cstring>
#include<string>
#include<algorithm>
#include<queue>

using namespace std;
typedef long long ll;
const int maxn = 2e5+10;

int main(){
    int n,T;
    cin>>n>>T;
    int ans = maxn;
    for(int i = 1;i<=n;i++){
        int a,b;
        cin>>a>>b;
        if(b<=T) ans = min(ans,a);
    }
    if(ans == maxn){
        cout<<"TLE"<<endl;
    }
    else{
        cout<<ans<<endl;
    }
    return 0;
}



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

int main(){
    int n;
    cin >> n;
    int sum = 0;
    int i = n;
    while(i>0){
        sum += (i%10);
        i /= 10;
    }
    if(!(n%sum)) printf("Yes\n");
    else printf("No\n");
    return 0;
}


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

//#pragma GCC optimize ("Ofast")
//#pragma GCC target ("avx,avx2")

#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define mp make_pair
#define pb push_back
#define X first
#define Y second
#define dbg(x) cerr<<#x<<" : "<<x<<endl

typedef long long int ll;
typedef long double ld;
typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector<pii> vii;
const ll INF = 1e18+1;
const ll MOD = 1000000007L;
clock_t time_p=clock();
void timer(){time_p=clock()-time_p;cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";}

template <typename Arg1> ostream& operator << (ostream& out, const vector<Arg1> &a) {out<<"[ ";for(const auto &x:a)out<<x<<" ";return out<<"]";}


int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,k;
    cin>>n>>k;
    vi h(n);
    ll ans = 0;
    rep(i,n){
        cin>>h[i];
        if(h[i] >= k){
            ans++;
        }
    }
    cout<<ans<<endl;

    timer();
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define LL long long
const int N = 2e5 + 10;
int n, c[N], cnt[N], siz[N];
	inline LL cal(int n) {
		// C(n,2) + n
		return 1LL*n*(n+1)/2;
	}
LL ans[N];
vector<int>G[N];
	void dfs(int v, int fa) {
		int tmp = cnt[c[v]];
		siz[v] = 1;
		for(int u:G[v]) {
			if(u==fa) continue;
			cnt[c[v]] = 0;
			dfs(u, v);
			siz[v] += siz[u];
			ans[c[v]]+=cal(siz[u]-cnt[c[v]]);
		}
		cnt[c[v]] = tmp + siz[v];
	}
	
	#define ADD(a, b) 	\
		do {			\
			G[a].push_back(b);	\
			G[b].push_back(a);	\
		}while(0);		
		
	inline void add(int a, int b) {
		G[a].push_back(b);
		G[b].push_back(a);
	}
	
int main() {
	//scanf("%d", &n);
	std::ios::sync_with_stdio(false);
	cin>>n;
	for (int i = 1; i <= n; i++)
		//scanf("%d", &c[i]);
		cin>>c[i];
	for (int i = 1; i < n; i++) {
		int u, v;
		//scanf("%d%d", &u, &v);
		cin>>u>>v;
		G[u].push_back(v);
		G[v].push_back(u);
		//ADD(u, v); ADD(v, u);
	}
	dfs(1, 0);
	for (int i = 1; i <= n; i++) {
		cout<< cal(n) - ans[i] - cal(n - cnt[i])<<endl;
	}
	return 0;
}


Measured memory_bytes: 37080
N=int(input())
p=list(map(int,input().split()))
q=['x' for _ in range(N)]
ans=0
for i in range(N):
    if p[i]!=i+1:
        q[i]='o'
for i in range(N):
    if q[i]=='x':
        if i<N-1:
            p[i], p[i+1]=p[i+1], p[i]
            q[i+1]='o'
        else:
            p[i], p[i-1]=p[i-1], p[i]
            q[i-1]='o'
        q[i]='o'
        ans+=1

print(ans)


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

int main(){
  int a,b,c;
  cin >> a >> b >> c;
  swap(a,b);
  swap(a,c);
  cout << a << ' ' << b << ' ' << c << endl; 
}

Measured memory_bytes: 256
n, m = map(int, input().split())

a = []
b = []
for i in range(n):
    x, y = map(int, input().split())
    a.append(x)
    b.append(y)

c = []
d = []
for i in range(m):
    x, y = map(int, input().split())
    c.append(x)
    d.append(y)

for j in range(n):
    l = []
    for i in range(m):
        l.append(abs(a[j] - c[i]) + abs(b[j] - d[i]))
    print(l.index(min(l)) + 1)

Measured memory_bytes: 9096
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  int x,cnt=0;
  cin>>s;
  
  for(int i=0; i<s.size(); ++i){
    if(s[i] == 'o'){
      ++cnt;
    }
  }
  
  x = 15 - s.size();
  if(cnt + x >= 8){
    cout<<"YES\n";
  }else cout<<"NO\n";
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(300000)

MOD = 1000000007  # type: int

def solve(n: int, m: int, x: "List[int]", y: "List[int]"):
    def make_count(n):
        nc = [0] * n
        nc[0] = nc[n - 1] = n
        for i in range(1, (n - 1) // 2 + 1):
            nc[i] = nc[n - i - 1] = (nc[i - 1] + (n - 2 * i)) % MOD
        return nc

    nc = make_count(n - 1)
    mc = make_count(m - 1)
    xs = 0
    for i in range(n - 1):
        xs += (x[i + 1] - x[i]) * nc[i]
        xs %= MOD

    ret = 0
    for j in range(m - 1):
        ret += (y[j + 1] - y[j]) * xs * mc[j]
        ret %= MOD
    print(ret)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    n = int(next(tokens))  # type: int
    m = int(next(tokens))  # type: int
    x = [ int(next(tokens)) for _ in range(n) ]  # type: "List[int]"
    y = [ int(next(tokens)) for _ in range(m) ]  # type: "List[int]"
    solve(n, m, x, y)

if __name__ == '__main__':
    main()


Measured memory_bytes: 26924
#include <bits/stdc++.h>
using namespace std;
#define ll long long int 
#define pb push_back
#define mod 1000000007
#define mk make_pair
int main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,k;
    cin>>n>>k;
    vector<vector<int> > v;
    v.resize(n+1);
    for(int i=0;i<=n;i++)
    v[i].resize(k+1);
    int a[n+1]={0};
    for(int i=1;i<=n;i++)
   { cin>>a[i];}
   sort(a+1,a+n+1);
   
   
   
    for(int i=0;i<=k;i++)
    v[0][k]=2;
    for(int i=0;i<=n;i++)
    v[i][0]=2;
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=k;j++)
        {
            if(i==1)
            {
                int t=j/a[i];
                t%=2;
                if(t==0)
                v[i][j]=2;
                else
                v[i][j]=1;
            }
            else
            {
                int f=1;
                for(int k=1;k<=i;k++)
               {    
                  if(j-a[k]>0)
                  {
                    if(v[i][j-a[k]]==2)
                    {v[i][j]=1;f=0;break;}
                   
                  }
                  else if(j-a[k]==0)
                  {
                    v[i][j]=1;f=0;break;
                  }
                 else
                 {
                   
                 }
               }
               if(f==1)
               v[i][j]=2;
            }
        
           // cout<<v[i][j]<<" ";
        }
       // cout<<endl;
    }
    if(v[n][k]==1)
    cout<<"First";
    else
    cout<<"Second";   
    return 0;
}

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

int main() {
    string s;
    cin>>s;
    set<char> st;
    rep(i,s.size()) st.insert(s[i]);
    if (st.size()==s.size()) cout<<"yes"<<endl;
    else cout<<"no"<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define eb emplace_back
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}


int const INF = 1001001001;


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

int n;
cin >> n;
vi w(n);
vi sum(n);

rep(i,n){
    cin >> w[i];
    if(i == 0) sum[i] = w[i];
    else sum[i] = sum[i-1] + w[i];
}

int m = INF;
rep(i,n-1){
    m = min(m,abs(sum[i] - (sum[n-1]-sum[i])));
}

cout << m << endl;



return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define str to_string
#define endl "\n"
#define PI 3.141592653589
using namespace std;
using lint = long long;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

//AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC
int main(){
    bool c=false,f=false;
    string s;cin>>s;
    for(char tmp:s){
        if(c==false){
            if(tmp=='C')c=true;
        }
        else{
            if(tmp=='F')f=true;
        }
    }
    if(f==false)cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
}


Measured memory_bytes: 3628
#include<cstdio>
const int MaxN=100010;
int N,A[MaxN];
struct edge{int to;edge*next;}E[MaxN*2],*ne=E,*fir[MaxN];
void link(int u,int v){*ne=(edge){v,fir[u]};fir[u]=ne++;}
bool dfs(int i,int fa){
	int c=0;
	long long sum=0,mx=0;
	for(edge*e=fir[i];e;e=e->next)if(e->to!=fa){
		if(!dfs(e->to,i))return 0;
		sum+=A[e->to];
		A[e->to]>mx?mx=A[e->to]:1;
		c++;
	}
	if(!c)return 1;
	if(c==1&&i==1)return sum==A[i];
	long long d=sum-A[i];
	mx=sum/2<sum-mx?sum/2:sum-mx;
	if(d>mx||d<0||d>A[i])return 0;
	A[i]-=d;
	return!A[i]||i!=1;
}
int main(){
	scanf("%d",&N);
	for(int i=1;i<=N;i++)scanf("%d",A+i);
	for(int i=1,u,v;i<N;i++)scanf("%d%d",&u,&v),link(u,v),link(v,u);
	puts(dfs(1,0)?"YES":"NO");
}

Measured memory_bytes: 11136
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional>
using namespace std;
#define int long long
#define double long double
#define FAST ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define mod 1000000007
using namespace __gnu_pbds;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag,tree_order_statistics_node_update> new_data_set;
bool isprime(int n)
	{
    	if(n==1) return true;
    	for(int i = 2;i*i<=n;i++){
    		if(n%i==0) return false;
		}
		return true;
	}
int lcm(int a,int b){
	return (a*b)/__gcd(a,b);
}
int gcd(int a, int b) 
{ 
    if (b == 0) 
        return a; 
    return gcd(b, a % b);  
      
} 
unsigned int factorial(unsigned int n) 
{ 
    if (n == 0) 
    return 1; 
    return n * factorial(n - 1); 
} 
const int inf=1e17+7;
//const int N=2e5+5;
//int dp[100001];
//vector<int> graph[100005];
bool ispal(string s){
	int l=s.length()-1,f=0,flag=0;
	while(f<=l){
		if(s[f]==s[l]){
			f++;
			l--;
		}
		else{
			flag++;
			break;
		}
	}
	if(flag!=0)return false;
	else return true;
}
//bool visited[100005]={false};
//int sieve[1000001];
signed main(){
	FAST
	int n;
	cin>>n;
	double sum=0;
	double arr[n];
	for(int i=0;i<n;i++)cin>>arr[i];
	double dp[n][n+1];
	cout<<fixed<<setprecision(10);
	//dp[0][1]=arr[0];
	for(int i=0;i<=n;i++)dp[0][i]=0;
	dp[0][1]=arr[0];
	dp[0][0]=1-arr[0];
	for(int i=1;i<n;i++){
		dp[i][0]=dp[i-1][0]*(1-arr[i]);
	}
	for(int i=1;i<n;i++){
		for(int j=1;j<=n;j++){
			dp[i][j]=dp[i-1][j-1]*(arr[i]) + dp[i-1][j]*(1-arr[i]);
			if(i==n-1 && j>(n/2)){
				sum+=dp[i][j];
			}
			//cout<<dp[i][j]<<" ";
		}
		//cout<<endl;
	}
	/*for(int i=0;i<n;i++){
		for(int j=0;j<=n;j++)cout<<dp[i][j]<<" ";
		cout<<endl;
	}*/
	if(n!=1)cout<<sum;
	else cout<<arr[0];
}

Measured memory_bytes: 140928
use std::io;
use std::str::FromStr;

fn main(){
    let stdin = io::stdin();
    let mut buf = String::new();

    let _ = stdin.read_line(&mut buf);
    let vec : Vec<i64> = buf.split_whitespace().map(|x| i64::from_str(x).unwrap()).collect();
    let (a, b) = (vec[0], vec[1]);

    println!("{} {}", a*b, 2*(a+b));
}



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

int main(){
  int N,K;
  std::cin >> N >> K;
  int ndiff = 0;
  bool lmid = false;
  bool initl = false;
  std::vector<char> c_arr(N+2);
  for(int i = 0; i < N; i++){
    char c;
    std::cin >> c;
    if(c == 'L'){
      if(i == 0) initl = true;
      if(lmid) c = 'R';
      else if(K > 0){
        lmid = true;
        c = 'R';
        K--;
      }
    }else{
      lmid = false;
    }
    c_arr[i+1] = c;
  }
  c_arr[0] = 'R'; c_arr[N+1] = 'L';
  for(int i = 1; i < N+1; i++){
    if(c_arr[i] == 'L' && c_arr[i] != c_arr[i-1]){
      if(initl) initl = false;
      else ndiff++;
    }
    else if(c_arr[i] == 'R' && c_arr[i] != c_arr[i+1]) ndiff++;
  }
  std::cout << N-ndiff << std::endl;
}


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

using namespace std;

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

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

    vector<int> ms(N);
    int counter = 0;
    rep(i, N){
        cin >> ms.at(i);
        X -= ms.at(i);
        counter++;
    }

    sort(ms.begin(), ms.end());
    rep(i, N){
        while(X > 0){
            int consume = ms.at(i);
            if(X >= consume){
                X -= consume;
                counter++;
            } else {
                break;
            }
        }
    }
    cout << counter << endl;
}

Measured memory_bytes: 256
def main():
    N, M = map(int, input().split())
    P = [[] for _ in range(N)]
    PY = []
    for _ in range(M):
        p, y = map(int, input().split())
        PY.append((p - 1, y))
        P[p - 1].append(y)
    PD = [{} for _ in range(N)]
    for i in range(N):
        for j, c in enumerate(sorted(P[i]), 1):
            PD[i][c] = j
    for p, y in PY:
        print('%06d%06d' % (p + 1, PD[p][y]))

main()


Measured memory_bytes: 67788
package main

import (
	"fmt"
	"math"
)

func main() {
	var x float64
	fmt.Scan(&x)
  	const itr = 1.01
	
	cnt := 0
  	money := 100.0
	for money < x {
      money = math.Trunc(money * 1.01)
      //fmt.Println(money)
		cnt++
	}
	fmt.Println(cnt)
}

Measured memory_bytes: 1756
#include <iostream>

using namespace std;

int main(){
	int x, y, z;
	cin >> x >> y >> z;
	int i;
	for(i = 0; i < 1000000; i++){
		int a, b;
		a = i * y;
		b = (i + 1) * z;
		if(a + b > x){
			cout << i - 1 << endl;
			return 0;
		}
	}
}

Measured memory_bytes: 256
fun main(arr:Array<String>) {
    var abc = readLine()!!.split(" ").map { it.toLong() }.sorted()
    val dic = mutableSetOf(abc.joinToString("#"))
    var ans = 0
    while (abc.all { it % 2 == 0L }) {
        ans++
        abc = listOf(abc[1]/2 + abc[2]/2, abc[0]/2 + abc[2]/2, abc[0]/2 + abc[1]/2)
        val key = abc.joinToString("#")
        if(dic.contains(key)) {
            println(-1)
            return
        }
        dic.add(key)
    }
    println(ans)
}


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

#define fi first
#define se second
#define be begin
#define en end
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define ALL(a) (a).be() , (a).en()

using LL = long long;

template<typename T> using V = vector< T >;
using Vi = V<int>;
using Vll = V<LL>;
using Vs = V<string>;

const LL INFLL = 999999999999999LL;

template<typename A, size_t N, typename T>
void FILL(A (&array)[N], const T &val){fill((T*)array,(T*)(array+N),val);}

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

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

LL dp[100005];
int main(){
    int n;
    cin>>n;

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

    FILL(dp,INFLL);
    dp[0]=0;

    for(int i=1; i<n; i++){
        chmin(dp[i],dp[i-1]+abs(h[i-1]-h[i]));
        if(i-2>=0){
            chmin(dp[i],dp[i-2]+abs(h[i-2]-h[i]));
        }
    }

    cout<<dp[n-1]<<endl;

    return 0;
}

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

int main()
{
    vector<int> A(0);
    int q, query, x, p, ap;
    cin >> q;
    for (int i = 0; i < q; ++i)
    {
        cin >> query;
        switch (query)
        {
        case 0:
            cin >> x;
            A.push_back(x);
            break;
        case 1:
            cin >> p;
            ap = A.at(p);
            cout << ap << endl;
            break;
        case 2:
            A.pop_back();
            break;
        }
    }
}


Measured memory_bytes: 3872
N,X=map(int, input().split()) 
L=list(map(int, input().split())) 
D = 0
for i in range(N):
  D = D + L[i]
  if D > X:
    print(i+1)
    break
  if D == X:
    print(i+2)
    break
  if D < X and i == N-1:
    print(i+2)
    break
  



Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define FOR(i, n) for(int i = 0; i < (n); ++i)
#define REP(i, a, b) for(int i = (a); i < (b); ++i)
#define TRAV(i, a) for(auto & i : (a))
#define SZ(x) ((int)(x).size())
#define PR std::pair
#define MP std::make_pair
#define X first
#define Y second
typedef long long ll;
typedef std::pair<int, int> PII;
typedef std::vector<int> VI;

void reduce(VI &A){
	for(int i = 0; i < SZ(A)-1; ++i){
		A[i] = std::abs(A[i]-A[i+1]);
	}
	A.pop_back();
}

int parity(int n, int k){
	for(int i = 0; i < 21; ++i){
		if((n & (1<<i)) == 0 && (k & (1<<i)) != 0) return 0;
	}
	return 1;
}

int main(){
	std::ios_base::sync_with_stdio(false);
	std::cin.tie(0);
	int n;
	std::cin >> n;
	VI A(n);
	std::string s;
	std::cin >> s;
	FOR(i, n) A[i] = s[i]-'0';
	FOR(i, 1) if(SZ(A) > 1) reduce(A);
	n = SZ(A);
	if(n == 1){
		std::cout << A[0] << "\n";
		return 0;
	}
	int cnt = 0;
	FOR(i, n) if(A[i] == 1) cnt++;
	if(cnt){
		int ans = 0;
		FOR(i, n){
			if(A[i] == 2) A[i] = 0;
			ans = ans^(A[i]*parity(n-1, i));
		}
		std::cout << (ans ? 1 : 0);
	}else{
		int ans = 0;
		FOR(i, n){
			if(A[i] == 2) A[i] = 1;
			ans = ans^(A[i]*parity(n-1, i));
		}
		std::cout << (ans ? 2 : 0);
	}


	return 0;
}

Measured memory_bytes: 5788
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<ctime>
#include<map>
#include<bitset>
#include<set>
#include<assert.h>
#include<chrono>
#include<random>
#define LL long long
#define mp(x,y) make_pair(x,y)
#define pll pair<long long,long long>
#define pii pair<int,int>
#define SZ(x) ((int)x.size())
using namespace std;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
inline LL read()
{
	LL f=1,x=0;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
int stack[20];
template<typename T>inline void write(T x)
{
	if(x<0){putchar('-');x=-x;}
    if(!x){putchar('0');return;}
    int top=0;
    while(x)stack[++top]=x%10,x/=10;
    while(top)putchar(stack[top--]+'0');
}
template<typename T>inline void pr1(T x){write(x);putchar(' ');}
template<typename T>inline void pr2(T x){write(x);putchar('\n');}
template<typename T>inline void chkmin(T &x,T y){x=x<y?x:y;}
template<typename T>inline void chkmax(T &x,T y){x=x>y?x:y;}
const int MAXN=100005;
const int mod=1e9+7;
void ad(int &x,int y){x+=y;if(x>=mod)x-=mod;}
void dl(int &x,int y){x-=y;if(x<0)x+=mod;}
int X[MAXN],Y[MAXN],n,m;
int main()
{
	n=read();m=read();
	for(int i=1;i<=n;i++)X[i]=read();
	for(int i=1;i<=m;i++)Y[i]=read();
	int s1=0,s2=0;
	for(int i=1;i<=n;i++)
	{
		ad(s1,1LL*(i-1)*(X[i]+mod)%mod);
		dl(s1,1LL*(n-i)*(X[i]+mod)%mod);
	}
	for(int i=1;i<=m;i++)
	{
		ad(s2,1LL*(i-1)*(Y[i]+mod)%mod);
		dl(s2,1LL*(m-i)*(Y[i]+mod)%mod);
	}pr2(1LL*s1*s2%mod);
	return 0;
}



Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		int x = scanner.nextInt();
		scanner.close();
		int y = (int) (x / 1.08);

		if (y * 1.08 == x) {
			System.out.println(y);
		} else if ((int) ((y + 1) * 1.08) == x) {
			System.out.println(y + 1);
		} else {
			System.out.println(":(");
		}
	}

}

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

using namespace std;
typedef long long ll;

#define MOD (long long)(1e9+7)
#define INF (1LL<<60)
#define rep(i,n) for(ll i = 0; i < (n); i++)
#define rep1(i,n) for(ll i = 1; i <= (n); i++)

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


// 最大公約数
ll gcd(ll a, ll b)
{
  if(b == 0) return a;
  return gcd(b, a % b);
}

// mod m におけるa の逆元
ll modinv(ll a, ll m) {
  ll b = m, u = 1, v = 0;
  while (b) {
    ll t = a / b;
    a -= t * b; swap(a, b);
    u -= t * v; swap(u, v);
  }
  u %= m;
  if (u < 0) u += m;
  return u;
}

// 素因数分解
vector<pair<ll, ll>> prim;
void pf(ll n)
{
  ll s = sqrt(n);
  ll r = 0;
  for(ll i = 2; i <= s; i++) {
    if((n % i) == 0) {
      r = 0;
      do {
	r++;
	n = n / i;
      } while((n % i) == 0);
      prim.push_back({i, r});
    }
  }
  if(n > s) {
    prim.push_back({n, 1});
  }
}

void solve()
{
  ll N, K, X, Y; cin >> N >> K >> X >> Y;
  ll ans = 0;

  if(N <= K) {
    ans = N * X;
  } else {
    ans = K * X + (N - K) * Y;
  }

  
  cout << ans << endl;
}


int main(void)
{
  // ll t; cin >> t; rep(i, t)
  solve();
}


Measured memory_bytes: 3552
open System

[<AutoOpen>]
module Cin =
    let read f = stdin.ReadLine() |> f
    let reada f = stdin.ReadLine().Split() |> Array.map f

[<EntryPoint>]
let main _ =
    let n = read int
    let ass = Array.zeroCreate n
    for i in 0..n-1 do ass.[i] <- read int

    ass
    |> Array.distinct
    |> Array.length
    |> printfn "%d"
    0


Measured memory_bytes: 14940
from heapq import heappush, heappop
from itertools import permutations, accumulate, combinations
from math import pi, ceil, floor
import numpy as np
from collections import defaultdict, deque,Counter
from operator import itemgetter
from bisect import bisect_left, bisect_right, insort_left, insort_right
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(10 ** 6)
# MOD = 10 ** 9 + 7
# INF = float("inf")


def main():
    a, b, n = map(int, input().split())
    if b - 1 <= n:
        x = b - 1
        f = floor(a * x / b) - a * floor(x / b)
    else:
        x = n
        f = floor(a * n / b) - a * floor(n / b)
    print(f)


if __name__ == '__main__':
    main()

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

int main() {
  int h, w, x; cin >> h >> w >> x;
  char a[h][w];
  for(int i = 0; i < h; i++) {
    for(int j = 0; j < w; j++) {
      cin >> a[i][j];
    }
  }
  int ans = 0;
  for(int i = 0; i < (1 << h); i++) {
    for(int j = 0; j < (1 << w); j++) {
      int track = 0;
      for(int k = 0; k < h; k++) {
        for(int l = 0; l < w; l++) {
          if((i & (1 << k)) != 0) continue;
          if((j & (1 << l)) != 0) continue;
          if(a[k][l] == '#') track ++;
        }
      }

      if(track == x) ans++;
    }
  }

  cout << ans << endl;
  return 0;

}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll check(vector<ll>&pref, vector<ll>& a){
	ll n=a.size()-1;
	for(int i=n-1;i>=1;i--){
		if(pref[i]*2<a[i+1])
			return i;
	}
	return 0;
}
int main(){
	ll n; cin>>n;
	vector<ll>a(n+1,0);
	for(ll i=1;i<=n;i++)
		cin>>a[i];
	sort(a.begin(),a.end());
	vector<ll>pref=a;
	for(ll i=1;i<=n;i++)
		pref[i]=pref[i]+pref[i-1];
	ll x=check(pref,a);
	cout<<n-x<<endl;
	return 0;
}

Measured memory_bytes: 1792
use std::cmp;

fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };
    let a: i64 = sc.read();
    let b: i64 = sc.read();
    println!("{}", cmp::max(a - 2 * b, 0));
}

pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n')
            .take_while(|&b| b != b' ' && b != b'\n')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
vector<vector<int>> graph(100001);
vector<int> h(100001);
int main()
{
    int n,m;
    cin>>n>>m;
    for(int i=1;i<=n;i++)
    {
        int a;
        cin>>a;
        h[i]=a;
    }
    for (int  i = 0; i < m; i++)
    {
        int a,b;
        cin>>a>>b;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }
    int c=0;
    for(int i=1;i<=n;i++)
    {
        bool good=true;
        for(int child: graph[i])
        {
            if(h[i]<=h[child])
            {
                good=false;
                break;
            }  
        }
        if(good)
            c++;
    }
    cout<<c<<endl;
}

Measured memory_bytes: 8744
#include <iostream>
#include <bits/stdc++.h>
#include<string>
using namespace std;
 
int main() {
    int n;
    cin>>n;
    long long int a[n];
    for(int i=0;i<n;i++)
    cin>>a[i];
    sort(a,a+n);
    int x=0;
    for(int i=0;i<n;i++)
    {
        for(int j=i+1;j<n;j++)
        {
            if(a[j]!=a[i])
            {
            for(int k=j+1;k<n;k++)
            {
                if(a[k]!=a[j])
                {
                if(a[i]+a[j]>a[k])
                x++;
                }
            }
            }
        }
    }
    cout<<x;
    return 0;
}

Measured memory_bytes: 3632
def resolve():
    def decode(x):
        return ord(x) - 97

    def encode(x):
        return chr(x + 97)

    S = list(map(decode, input()))
    K = int(input())

    for i in range(len(S) - 1):
        if S[i] == 0:
            continue
        if 26 - S[i] <= K:
            K -= 26 - S[i]
            S[i] = 0

    S[-1] = (S[-1] + K) % 26
    ans = map(encode, S)
    print("".join(ans))


if __name__ == "__main__":
    resolve()

Measured memory_bytes: 10576
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;


namespace ConsoleApp6
{
	class Program
	{
		static void Main(string[] args)
		{
			while (true)
			{
				string hw = Console.ReadLine();
				string[] sq = hw.Split(' ');

				int H = int.Parse(sq[0]);
				int W = int.Parse(sq[1]);

				if(H == 0 && W == 0)
					{
						break;
					}

				for (int i = 0; i < H; i++)
				{
					for (int j = 0; j < W; j++)
					{
						if(j % 2 == 0 && i % 2 == 0 || j % 2 ==1 && i % 2 ==1 )
						{
							Console.Write("#");
						}
						else
						{
							Console.Write(".");
						}
					}
					Console.WriteLine();
				}
				Console.WriteLine();
			}
		}
	}
}



Measured memory_bytes: 15940
#include<stdio.h>

int main(){
   int n,i,cnt = 0;
   scanf("%d",&n);
   int x[n];
   for(i = 0; i < n; i++){
      scanf("%d",&x[i]);
   }
   for(i = 0; i < n; i++){
      cnt++;
      if(x[i]%2==0){
         if(x[i]%3!=0 && x[i]%5!=0){
            printf("DENIED");
            break;
         }
      }
      if(cnt==n){
         printf("APPROVED");
      }
   }
   return 0;
}


Measured memory_bytes: 128
import sys
import numpy as np
import math
from collections import deque 
from functools import reduce

# input = sys.stdin.readline

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

h = list(map(int, input().split()))

h_np = np.array(h)
max_np = np.zeros(n)

for i in range(m):
    a, b = map(int, input().split())
    max_np[a-1] = max(max_np[a-1], h[b-1])
    max_np[b-1] = max(max_np[b-1], h[a-1])
num_np = np.where(h_np > max_np, 1, 0)    
print(sum(num_np))

Measured memory_bytes: 38608
#include<bits/stdc++.h>
typedef long long ll;

ll a,b;

ll work(ll a,ll b)
{
    if(a==b)return 1;
    
    ll t=1ll<<(63-__builtin_clzll(b));

    if(t>a&&t<=b)
    {
	ll ret=2*(t-a);
	b-=1ll<<(63-__builtin_clzll(b));
	if(!b)return ret+std::min(a,1ll);
	return ret+std::min(a,1ll<<(64-__builtin_clzll(b)));
    }
    else return t=1ll<<(63-__builtin_clzll(b)),work(a-t,b-t);
}

int main()
{
    scanf("%lld%lld",&a,&b);
    printf("%lld\n",work(a,b));
    
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define len(v) ll(v.size())
#define fi first
#define se second

template <class T>
void cout_vec(const vector<T> &vec){
  for(auto itr:vec) cout<<itr<<' ';
  cout<<endl;
}

typedef pair<ll,ll> P;
const ll mod=1e9+7;
const ll inf=1e15;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n,m;
  cin>>n>>m;
  map<int,int> cnt;
  rep(i,m){
    int a,b;
    cin>>a>>b;
    cnt[a]++;
    cnt[b]++;
  }
  for(auto itr:cnt){
    if(itr.se%2!=0){
      cout<<"NO"<<endl;
      return 0;
    }
  } 
  cout<<"YES"<<endl;
}

Measured memory_bytes: 4352
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <deque>
#include <list>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>

using namespace std;

int n;
bool prime[1000000];

int main() {

	for (int i = 2; i <= 1000000; i++) prime[i] = true;

	for (int i = 2; i <= 1000000; i++) {
		if (!prime[i]) continue;
		for (int j = 2; i * j <= 1000000; j++) {
			prime[i * j] = false;
		}
	}

	n = -1;
	cin >> n;

	while (n != -1) {
		int cnt = 0;
		for (int i = 2; i <= n; i++) {
			if (prime[i]) cnt++;
		}
		cout << cnt << endl;

		n = -1;
		cin >> n;
	}

	return 0;
}

/*@@@@@@@@@@@@@@@@@@@@@@@@@*/
/*@                       @*/
/*@ debug output erased ? @*/
/*@                       @*/
/*@@@@@@@@@@@@@@@@@@@@@@@@@*/

Measured memory_bytes: 2136
#include<bits/stdc++.h>
#define taskname "test1"
#define int long long
using namespace std;

main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);   cout.tie(nullptr);
    if (ifstream("test.inp"))
    {
        freopen("test.inp", "r", stdin);
        #ifdef CHECKING
            freopen(taskname".out", "w", stdout);
        #else
            freopen("test.out", "w", stdout);
        #endif //CHECKING
    }
    else if (ifstream(taskname".inp"))
    {
        freopen(taskname".inp", "r", stdin);
        freopen(taskname".out", "w", stdout);
    }

    int k;  cin >> k;
    int a = k / 2, b = k - a;
    cout << a * b;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) FOR(i,0,n)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define PB push_back
#define LB lower_bound
#define UB upper_bound
#define PQ priority_queue
#define UM unordered_map
#define ALL(a) (a).begin(),(a).end()
typedef vector<ll> vi;
typedef vector<vector<ll>> vvi;
const ll INF = (1ll << 60);
typedef pair<ll,ll> pii;
typedef vector<vector<ll>> Graph;
typedef vector<pii> vpii;

int main() {
  ll N,K; cin>>N>>K;
  vi A(N); REP(i,N) cin>>A[i];
  ll gcd=A[0];
  REP(i,N) gcd=__gcd(gcd,A[i]);
  REP(i,N) {
    if(K<=A[i]&&(A[i]-K)%gcd==0) {
      cout<<"POSSIBLE"<<endl;
      return 0;
    }
  }
  cout<<"IMPOSSIBLE"<<endl;
  return 0;
}


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

int main(){

   Long n;
   cin >> n;

   vector<Long> arr(n);
   for(Long i=0 ; i<n ; ++i) cin >> arr[i];
   
   map<Long,Long> mp;
   for(Long i=0 ; i<n ; ++i) mp[arr[i]]++;

   Long tot = 0;
   std::map<Long,Long>::iterator it = mp.begin();
   while(it!= mp.end()) tot += it->second * (it->second - 1) / 2, it++ ;

   for(Long i=0 ; i<n ; ++i) {
      it = mp.find(arr[i]);
      cout << tot - it->second + 1 <<'\n';
   }

   return 0;
}

Measured memory_bytes: 11008
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
 
int main() {
  int N;
  int i;
  int A[200];
  int calc_cnt;
  cin >> N;
  for(i=0;i < N; i++){
    cin >> A[i];
  }
  while(1){
    int odd_flg = 0;
    for(i=0;i < N; i++){
      if(A[i] & 0x1){
        //odd number
        odd_flg = 1;
        break;
      }else{
        //even number
         A[i] = A[i] >> 1;
      }
    }
    if(odd_flg == 0){
      calc_cnt++;
    }else{
      break;
    }
  }
  cout << calc_cnt << endl;
}

Measured memory_bytes: 256
from collections import deque

N, M = map(int, input().split())
ARR = []

for i in range(M):
    ARR.append(list(map(int, input().split())))


def prepare(n, m, arr):
    nodes = [[] for i in range(n)]
    nodeStatus = [False for i in range(n)]
    for i in range(m):
        startNode = arr[i][0] - 1
        endNode = arr[i][1] - 1

        nodes[startNode].append(endNode)
        nodes[endNode].append(startNode)

    return nodes, nodeStatus


def calculate(n, nodes, nodeStatus):
    nodeMarks = [-1 for i in range(n)]

    q = deque()

    q.append((0, -1))

    while len(q) > 0:
        currentNode, parentNode = q.popleft()

        if nodeStatus[currentNode] == True:
            continue

        nodeStatus[currentNode] = True
        nodeMarks[currentNode] = parentNode
        childNodes = nodes[currentNode]

        for childNode in childNodes:
            if nodeStatus[childNode] == True:
                continue
            q.append((childNode, currentNode))

    minusNumber = nodeMarks.count(-1)
    if minusNumber > 1:
        print("No")
        return

    print("Yes")
    for i in range(1, n):
        print(nodeMarks[i] + 1)


nodes, nodeStatus = prepare(N, M, ARR)

calculate(N, nodes, nodeStatus)


Measured memory_bytes: 74132
#include <algorithm>
#include <iostream>
using namespace std;
int main() {
    int a, b, m; cin >> a >> b >> m;
    int A[a], B[b];
    for (int i = 0; i < a; i++) cin >> A[i];
    for (int i = 0; i < b; i++) cin >> B[i];
    int ans = *min_element(A, A+a) + *min_element(B, B+b);
    for (int i = 0; i < m; i++) {
        int x, y, c; cin >> x >> y >> c;
        ans = min(ans, A[x-1] + B[y-1] - c);
    }
    cout << ans << endl;
}


Measured memory_bytes: 1024
#include<stdio.h>
#include<string.h>
int main(void)
{
    int i,j,l;
    char a[21];
    char b[21];

    scanf("%s",a);
    j=strlen(a);
    for(i=0; i<=j+1; i++){
        if(j==i)
        b[i]=a[i];
        else
        b[j-i-1]=a[i];
    }

    printf("%s\n",b);

    return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <cstdio>
#include <complex>
#include <numeric>
#include <string.h>
#include <random>
#define rep(i,n) for (int i = 0; i < (int)n; i++)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<pi, pi> pp;
typedef pair<ll, ll> pl;
double PI = 3.141592653589793238462643383279;
const double EPS = 1e-9;
const ll MOD = 998244353;
const int inf = 1 << 30;
const ll linf = 1LL << 60;

constexpr ll V = 1000000;

ll mod_pow (ll x, ll y) {
    ll ret = 1;
    while (y) {
        if (y&1) ret = ret * x % MOD;
        x = x * x % MOD;
        y /= 2;
    }
    return ret;
}

ll N;
ll A[200000];
ll C[V+1];
ll w[V+1];
ll inv[V+1];

void init() {
    for (ll i = 1; i <= V; i++) inv[i] = mod_pow(i, MOD-2);
    for (ll i = 1; i <= V; i++) {
        w[i] = (inv[i] + w[i] + MOD) % MOD;
        for (ll j = i*2; j <= V; j += i) {
            w[j] = (w[j] - w[i] + MOD) % MOD;
        }
    }
}

int main() {
    init();
    cin >> N;
    rep(i,N) cin >> A[i];
    rep(i,N) C[A[i]]++;
    ll ans = 0;
    for (ll i = 1; i <= V; i++) {
        ll add = 0;
        ll sum1 = 0, sum2 = 0;
        for (ll j = i; j <= V; j += i) {
            sum1 = (sum1 + C[j]*j) % MOD;
            sum2 = (sum2 + C[j]*j*j) % MOD;
        }
        add = (sum1*sum1-sum2+MOD)%MOD;
        add = add * inv[2] % MOD;

        ans = (ans + add*w[i]) % MOD;
    }
    cout << ans << endl;
}

Measured memory_bytes: 25216
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	n := getInt()
	k := getInt()
	s := []rune(getString())

	r := 0
	ans := 0
	count := 0
	if s[0] == '0' {
		count++
	}

	for l := 0; l < n; l++ {
		for (r < n) && (count <= k) {
			if (r+1 < n) && (s[r] == '1') && (s[r+1] == '0') {
				count++
			}
			r++
		}

		ans = max(ans, r-l)

		if (l+1 < n) && (s[l] == '0') && (s[l+1] == '1') {
			count--
		}
	}

	fmt.Println(ans)
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

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

var sc = bufio.NewScanner(os.Stdin)

func init() {
	tmp := 200001
	sc.Buffer(make([]byte, tmp), tmp)
	sc.Split(bufio.ScanWords)
}

func getInt() int {
	i, err := strconv.Atoi(getString())
	if err != nil {
		panic(err)
	}
	return i
}

func getString() string {
	sc.Scan()
	s := sc.Text()
	return s
}


Measured memory_bytes: 1280
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#include <set>
#include <map>
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(0), cout << fixed << setprecision(20);
#define rep(i,n) for (int i=0; i<n;++i)
#define ALL(a)  (a).begin(),(a).end()
#define PI 3.14159265358979
typedef long long ll;
using namespace std;
const ll MOD = 1e9+7LL;
const int INF = 2e9;
int X, t;

int main() {
  INCANT;
  cin >> X >> t;
  cout << max(X-t, 0) << "\n";
  return 0;
}

Measured memory_bytes: 256