akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
int main () {
	char x;
	int ans = 0;
	while ((x = getchar ()) != EOF) {
		if ((x <= '9') && ('0' <= x))ans += (x - '0');
	}
	if (ans % 9 == 0) {
		printf ("Yes\n");
	} 
	else printf ("No\n");
	return 0;
} 

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

#define ll long long int
#define ull unsigned long long int
#define po2(z) 1<<(ll)z
#define fr(i,x,n) for(ll i=(ll)(x);i<(ll)(n);++i)
#define rf(i,x,n) for(ll i=(ll)(x);i>=(ll)(n);--i)
#define modinv(x) powah(x,mod-2)
#define ncr(n,r) (((fact[n]*modinv(fact[n-r]))%mod*modinv(fact[r]))%mod)
#define factorial fact.pb(1);sidha(i,1,MAX)fact.pb((fact[i-1]*i)%mod)
#define TC ll test;cin>>test;while(test--)
#define tej ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define mod (ll)1000000007
#define MAX 100005

ll static t[102][MAX];


int main(){
memset(t,-1,sizeof(t));
ll n,W;
cin>>n>>W;

ll wt[n],val[n];

fr(i,0,n)cin>>wt[i]>>val[i];


fr(i,0,n+1){
fr(j,0,W+1){
	if(i==0||j==0){
		t[i][j]=0;
	}
}
}

fr(i,1,n+1){
fr(j,1,W+1){
if(wt[i-1]<=j){
	 t[i][j]=max(val[i-1]+t[i-1][j-wt[i-1]],t[i-1][j]);
	}
	else{
	 t[i][j]= t[i-1][j];
	}
}
}

cout<<t[n][W];

}


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

using namespace std;

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

  int n, h;
  cin >> n;
  int res = 0, tmp = 0;
  int prev = 0;
  while (n--) {
    cin >> h;
    tmp = (h <= prev ? tmp+1 : 0);
    res = max(res, tmp);
    prev = h;
  }
  cout << res << endl;

  return 0;
}



Measured memory_bytes: 256
N,K=map(int,input().split())
L=[0 for i in range(10**5+1)]
for i in range(N):
    a,b=map(int,input().split())
    L[a]+=b
    

for i in range(10**5+1):
    K-=L[i]
    if K<=0:
        print(i)
        exit()
    

Measured memory_bytes: 45040
import bisect
import cmath
import heapq
import itertools
import math
import operator
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter, mul, add, xor

import numpy as np

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

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


N, M = list(map(int, sys.stdin.buffer.readline().split()))
X = list(map(int, sys.stdin.buffer.readline().split()))

X.sort()
diffs = np.abs(np.diff(X))
diffs.sort()
if N >= M:
    print(0)
else:
    ans = diffs.cumsum()[M - N - 1]
    print(ans)



Measured memory_bytes: 22244
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <numeric>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <time.h>

using namespace std;
typedef long long ll;
#define pl pair<ll,ll>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define foreach(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); itr++)
#define dbg(x) cout << #x"="<< (x) << endl
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back(a) 
#define in(x) cin >> x;
#define all(x) (x).begin(), (x).end()
#define INF 2147483600
#define fi first
#define se second

int main(){
	ll n;//10^5
	cin>>n;
	vector<ll> a(n),b(n);
	rep(i,n)cin>>a[i]>>b[i];
	
	//1ループで行きたい.
	ll ans=0;
	for(ll i=n-1;i>=0;i--){
		ans+=ceil((double)(a[i]+ans)/b[i])*b[i]-(a[i]+ans);
	}
	cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1792
#include<stdio.h>
int main()
{
    int n, temp;
    scanf("%d", &n);
    int m=n;
    if(n%1000==0) printf("0\n");
    else{
    if(n>1000)
    {
        n/=1000;
        temp=n;
    }
    printf("%d\n", 1000*(temp+1)-m);
    }
}

Measured memory_bytes: 1732
#include <bits/stdc++.h>
using namespace std;
int main(){
  int i,counter=0;
  std::string a,b;

    cin>>a;
    cin>>b;

    for(i=0;i<3;i++){
      if(a.at(i)==b.at(i)){
        counter++;
      }
    }

    cout<<counter<<endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    int A,B;
    cin >> A >> B;

    cout << (B - A) * (B - A + 1) / 2 - B << endl;
}

Measured memory_bytes: 256
A = int(input())
B = int(input())
C = int(input())
X = int(input())
cnt = 0
for i in range(A+1):
    for j in range(B+1):
        for k in range(C+1):
            if i*500+j*100+k*50 == X:
                cnt += 1
print(cnt)

Measured memory_bytes: 40048
#include<bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define MOD	1000000007
#define int	long long
#define pii pair<int,int> 
#define vi vector<int>
using namespace std;

int32_t main(){
	int n;
	cin >> n;
	
	if(n % 2){
		cout << 0 << endl;
	}
	else{
		int ans = 0;
		
		for(int i = 10; i <= n; i *= 5){
			ans += n / i;
		}
		cout << ans << endl;
	}

	return 0;
}



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

int main() {
  int64_t n,k;
  cin>>n>>k;
 int64_t count=1;
  for(int i=0;i<n;i++){
    if(i==0){
      count*=k;
    }
    else{
    count*=k-1;
    }
  }
  cout<<count;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <bits/stdc++.h>
using namespace std;
typedef long long int lli;
#define WHITE 1
#define BLACK 0
int dfs(int s, int p, vector<vector<int> > &G, int color, vector<vector<lli> > &M ){
	int v;
	lli product = 1, part_ans;
	if(M[s][color]!=-1) return M[s][color];
	for (int i = 0; i < G[s].size(); ++i)
	{
		v = G[s][i];
		if(v==p) continue;
		if(color==BLACK){
			part_ans = dfs(v, s, G, WHITE, M)%1000000007;
		}else{
			part_ans = (dfs(v, s, G, WHITE, M)%1000000007+dfs(v, s, G, BLACK, M)%1000000007)%1000000007;
		}
		product*=part_ans;
		product %= 1000000007;
	}
	return M[s][color]=(product%1000000007);
}
int main(int argc, char const *argv[])
{
    int N, x, y;
    cin>>N;
    vector<vector<int> > G(N+1);
    vector<vector<lli> > M(N+1, vector<lli> (2, -1));
	for (int i = 0; i < N-1; ++i)
	{
		cin>>x>>y;
		G[x].push_back(y);
		G[y].push_back(x);
	}
	lli ans1 = dfs(1, -1, G, BLACK, M);
	lli ans2 = dfs(1, -1, G, WHITE, M);
	// cout<<ans1 <<" "<<ans2<<" =>";
	cout<<(ans1+ans2)%1000000007;
    return 0;
}

Measured memory_bytes: 19584
#include<bits/stdc++.h>
using namespace std;
template<typename T>
inline void read(T &x)
{
	x=0;
	int f=1;
	char ch=getchar();
	while(ch<'0'||ch>'9')
	{
		if(ch=='-') f=-1;
		ch=getchar();
}
	while(ch>='0'&&ch<='9') x=x*10+(ch^48),ch=getchar();
	x*=f;
	return;
}	
template<typename T>
void write(T x)
{
	if(x<0) putchar('-'),x=-x;
	if(x>=10) write(x/10);
	putchar(x%10+'0');
	return;
}
const int MAXN=20;
const long long inf=1e18+7;
int n;
struct node{
    int x,y;
    long long p;
}a[MAXN];
long long ans[MAXN];
int dis[MAXN];
void dfs(int step,int cnt,long long tot)
{
    if(step==n+1)
    {
        ans[cnt]=min(ans[cnt],tot);
        return;
    }
    dfs(step+1,cnt,tot);
    int tmp[MAXN];
    long long ttmp=0;
    for(int i=1;i<=n;++i) tmp[i]=dis[i];
    for(int i=1;i<=n;++i) dis[i]=min(dis[i],abs(a[i].y-a[step].y)),ttmp+=a[i].p*dis[i];
    dfs(step+1,cnt+1,ttmp);
    ttmp=0;
    for(int i=1;i<=n;++i) dis[i]=tmp[i];
    for(int i=1;i<=n;++i) dis[i]=min(dis[i],abs(a[i].x-a[step].x)),ttmp+=a[i].p*dis[i];
    dfs(step+1,cnt+1,ttmp);
    for(int i=1;i<=n;++i) dis[i]=tmp[i];
}
int main()
{
    read(n);
    for(int i=1;i<=n;++i) read(a[i].x),read(a[i].y),read(a[i].p);
    long long tmp=0;
    for(int i=0;i<=n;++i) ans[i]=inf,dis[i]=min(abs(a[i].x),abs(a[i].y)),tmp+=a[i].p*dis[i];
    dfs(1,0,tmp);
    for(int i=0;i<=n;++i) write(ans[i]),putchar('\n');
	return 0;
}


Measured memory_bytes: 3620
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;


int main() {
	int N;
	int A, B, C, D;
	pair<int,int>score[101] = {};
	cin >> N;
	for (int i = 0; i < 101; i++) score[i].second = i;
		for (int i = 0; i < (N*(N - 1) / 2); i++) {
		cin >> A >> B >> C >> D;
		if (C > D) {
			score[A].first+=3;
		}
		else if (C < D) {
			score[B].first+=3;
		}
		else {
			score[A].first++;
			score[B].first++;
		}
	}

	sort(score, score + 101);
	reverse(score, score + 101);

	int ans[101] = {};
	int tmp = 0;
	int s = 1;
	int num = 0;
	for (int i = 0; i < N; i++) {
		if (tmp != score[i].first) {
			num+=s;
			s = 1;
		}
		else {
			s++;
		}
		ans[score[i].second] = num;
		tmp = score[i].first;
	}

	for (int i = 1; i <= N; i++) {
		cout << ans[i] << endl;
	}
	
	return 0;
	
}

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

class Program
{
    static void Main()
    {
        var N = int.Parse(Console.ReadLine());

        var AB = new int[N][];
        for (int i = 0; i < N; i++)
        {
            AB[i] = Console.ReadLine().Split().Select(int.Parse).ToArray();
        }
        Array.Sort(AB, (x, y) => x[1] - y[1]);

        var flag = true;
        var time = 0;
        for (int i = 0; i < N; i++)
        {
            if ((time += AB[i][0]) > AB[i][1])
            {
                flag = false;
                break;
            }
        }
        Console.WriteLine(flag ? "Yes" : "No");
    }
}


Measured memory_bytes: 28440
def get_ints():
    return list(map(int, input().split()))

a, b, c, k = get_ints()
xs = [a, b, c]
vs = [1, 0, -1]
ans = 0
for i in range(3):
    take = min(xs[i], k)
    ans += vs[i] * take
    k -= take

print(ans)



Measured memory_bytes: 61724
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <vector>
#include <queue>
#include <iostream>
#include <set>
#include <map>
#include <string>

using namespace std;

#define mod 1e9+7
#define ll long long int
#define epsilon 1e-7

int min(int x, int y){
    if(x<y)return x;
    return y;
}

struct edge
{
    int to, cost;
};
typedef pair<int, int> P;
vector<edge> g[100000];
ll d[100000];
int x[100000];
int y[100000];

int main(void){
    int n;
    scanf("%d", &n);
    for(int i = 0;i < n-1;i++){
        int a, b, c;
        scanf("%d %d %d", &a, &b, &c);
        edge e1, e2;
        e1.to = b-1;
        e1.cost = c;
        e2.to = a-1;
        e2.cost = c;
        g[a-1].push_back(e1);
        g[b-1].push_back(e2);
    }
    int q, k;
    scanf("%d %d", &q, &k);
    k--;
    for(int i = 0;i < q;i++){
        scanf("%d %d", &x[i], &y[i]);
    }
    priority_queue<P, vector<P>, greater<P>> que;
    for(int i = 0;i < n;i++){
        d[i] = 1e14;
    }
    d[k] = 0;
    que.push(P(0, k));
    while(!que.empty()){
        P p = que.top();
        que.pop();
        int v = p.second;
        if(d[v] < p.first)continue;
        for(int i = 0;i < g[v].size();i++){
            edge e = g[v][i];
            if(d[e.to] > d[v] + e.cost){
                d[e.to] = d[v] + e.cost;
                que.push(P(d[e.to], e.to));
            }
        }
    }
    for(int i = 0;i < q;i++){
        printf("%lld\n", d[x[i]-1] + d[y[i]-1]);
    }
    return 0;
}

Measured memory_bytes: 10100
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using Map = map<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
ll INF=1LL<<60;
ll MOD=1000000007;



int main(){
  string S;
  cin >> S;
  ll N=S.size();
  ll ans1=0;
  ll ans2=0;
  for(ll i=0;i<N;i++){
    if(i%2==1&&S[i]!='0')ans1++;
    if(i%2==0&&S[i]!='1')ans1++;
  ;}
  for(ll i=0;i<N;i++){
    if(i%2==0&&S[i]!='0')ans2++;
    if(i%2==1&&S[i]!='1')ans2++;
  ;}
  cout<<min(ans1,ans2)<<endl;
    return 0;
}


Measured memory_bytes: 512
#include "bits/stdc++.h"
using namespace std;

int main()
{
	int64_t x;
	cin >> x;

	int64_t a = 0;
	int64_t b = 0;
	bool flag = false;

	for (int64_t i = -200; i <= 200; i++) {
		for (int64_t j = -200; j <= 200; j++) {
			if (pow(i, 5) - pow(j, 5) == x) {
				a = i;
				b = j;
				flag = true;
				break;
			}
		}
		if (flag == true) {
			break;
		}
	}

	cout << a << " " << b << endl;
}


Measured memory_bytes: 4028
import java.util.Scanner;

public class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    String S = sc.next();
    int len = S.length();
    char[] s = S.toCharArray();
    int ans = 0;
    for(int i = 0;i < len - 2;i++){
      if(s[i] == 'A' && s[i+1] == 'B' && s[i+2] == 'C') ans++;
    }
    System.out.println(ans);
  }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define ll long long
#define maxn 105
using namespace std;
struct Node{
  int id, c;
  string str;
}a[maxn];
int n,m;

bool cmp(Node a,Node b){
  if(a.str == b.str){
    return a.c > b.c;
  }
  return a.str < b.str;
}

int main()
{
  scanf("%d", &n);
  for(int i=0;i<n;i++){
    cin>>a[i].str>>a[i].c;
    a[i].id = i + 1;
  }
  sort(a, a + n, cmp);
  for(int i=0;i<n;i++){
    cout<<a[i].id<<endl;
  }
  return 0;
}


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

using namespace std;

int main(){
  int N, K, ans=1;

  cin >> N >> K;

  for(int i = 0; i < N; i++){
    if(ans < K) ans *= 2;
    else ans += K;
  }

  cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
typedef long double ld;
int main(){
	ld v;
	while(scanf("%Lf",&v)!=EOF){
		ld t=v/9.8;
		ld h=4.9*t*t;
		int n=ceil(h/5.0)+1.0;
		printf("%d\n",n);
	}
	return 0;
}

Measured memory_bytes: 1060
#include<bits/stdc++.h>
#pragma GCC optimize(2)
using namespace std;

int main(){
	string a,b,e;
	int c,d;
	
	cin>>a>>b>>c>>d>>e;
	
	if(a==e) cout<<c-1<<' '<<d;
	else cout<<c<<' '<<d-1;
	
	return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//useful 
#define rep(i,n) for(int i = 0; i < (n); i++)
int long long gcd(int long long a, int long long b){
    return b?gcd(b,a%b):a;
} //最大公約数
int long long lcm(int long long a, int long long b){
    return a/gcd(a,b)*b;
} //最小公倍数
int long long GetDigit(int long long num){
    int long long digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
} //桁数
int long long GetDigitN(int long long num, int long long N){
    int long long digit=0;
    while(num!=0){
        num /= N;
        digit++;
    }
    return digit;
} //十進数でnumの際のN進数における桁数
int long long divisorcount(int long long n){
	int long long ans = 1;
	vector<int> x(n + 1);
	int long long num = n; // 素因数分解する変数num 
	for (int long long i = 2; i <= n; i++) {
		while (num%i == 0) { // 素数で割り切れなくなるまで割っていく
			x.at(i)++; //割った個数を配列に足す
			num /= i;
		}
	}
	for (int i = 2; i <= n; i++){
		ans *= x.at(i) + 1; //それぞれを+1して掛けていく
	}
    return ans;
} //約数カウント

int main(){
    double N, X, T;
    cin >> N >> X >> T;
    cout << std::fixed << setprecision(0) << ceil(N / X) * T << endl;
    return 0;
}

Measured memory_bytes: 3704
S = input()
k = int(input())
d = {}
cnt = 0
for i, s in enumerate(S):
  if s == "1":
    cnt += 1
    if i+1 == k:
      print(s)
      exit()
  else:
    print(s)
    exit()
if cnt == len(S):
  print("1")

Measured memory_bytes: 3060
#include<iostream>
#include<cstdio>
#include<queue>
#include<vector>
#include<algorithm>

#define INF 1010000000
#define rep(i,n) for(int i=0;i<n;i++)
#define reps(i,n) for(int i=1;i<=n;i++)
#define sint(i) scanf("%d",&i);
#define sintt(i,j) scanf("%d%d",&i,&j);
#define sinttt(i,j,k) scanf("%d%d%d",&i,&j,&k);

using namespace std;

class S{
	public:
	int p;
	int v;
	int n;
	
	S(int p,int v,int n):p(p),v(v),n(n){}
	
	bool operator<(const S&a)const{
		return v>a.v;
		return v==a.v ? v>a.v : n <a.n;
	}
};

int main(){
	while(1){
		int c,n,m,s,g;
		scanf("%d%d%d%d%d",&c,&n,&m,&s,&g);
		if(c==0&&n==0&&m==0&&s==0&&g==0)break;
		
		int root[101][101];
		rep(i,101)rep(j,101)root[i][j]=INF;
		
		rep(i,101)root[i][i]=0;
		
		rep(i,m){
			int a,b,d;
			sinttt(a,b,d);
			root[a][b]=d;
			root[b][a]=d;
		}
		
		priority_queue<S> qui;
		qui.push(S(s,0,0));
		int ans=0;
		
		int visit[101][11];
		rep(i,101)rep(j,11)visit[i][j]=0;
		
		while(1){
			if(qui.empty()==1){
				ans=-1;
				break;
			}
			
			S u=qui.top();qui.pop();
			if(visit[u.p][u.n]==1){continue;}
			
			//printf("%d %d %d\n",u.p,u.v,u.n);
			if(u.p==g){
				ans=u.v;
				break;
			}
			
			visit[u.p][u.n]=1;
			
			reps(i,n){
				if(root[u.p][i]!=INF){
						qui.push(S(i,u.v+root[u.p][i],u.n));
						
					if(visit[i][u.n+1]==0 && u.n+1 <= c){
						qui.push(S(i,u.v+root[u.p][i]/2,u.n+1));
					}
				}
			}
		}
		printf("%d\n",ans);
	}
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define Int int32_t
#define all(c) c.begin(), c.end()
#define FAST ios_base::sync_with_stdio(false) , cin.tie(NULL);
#define pii pair< int , int >
#define pb push_back
#define F first
#define S second
#define endl "\n"
#define bitcnt(n) __builtin_popcountll(n)
#define setpre(n) cout << fixed << setprecision(n)
#define tr(c) for(auto x : c )cout << x << " ";
#define ol(c , s , e ) for(int pos=s; pos<e ; pos++) cout << c[pos] << " ";
#define PI acos(-1l)
const int M = 1000000007;
const int N=3e5+5;
const int INF = 2e18+5;
//#define rohit
#ifdef rohit
template<typename... T >
void bug(T... __VA_ARGS__) {
    ((cerr << __VA_ARGS__ << " ") , ...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", bug(__VA_ARGS__) , cerr << endl;
#endif

void solve(){
    int x , y;
    cin >> x >> y;
    for(int  i=0 ; i<=x ; i++){
        if(x*(2*i + 4*(x - i) == y )){
            cout << "Yes";
            return;
        }
    }
    cout << "No";
}


signed main(){
    FAST;
    //TODO: check test cases.
    int tc=1;
//    cin >> tc;
    for(int t = 1 ; t <= tc ; t++){
        solve();
    }
}
/* Extra Cares
 * 1)In graphs or dp problems sometimes long long creates MLE.
 * 2)Check whether int to long long typecasting is commented or not?
 * 3)Check overflows.
*/

Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
int n,ans,a[100010];
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	sort(a+1,a+n+1);
	for(int i=2;i<=n;i++) ans+=(a[i]==a[i-1]);
	if(ans%2==1) ans++;
	cout<<n-ans<<"\n";
	return 0;
}

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

using namespace std;

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

using _loop_int = int;
#define REP(i,n) for(_loop_int i=0; i<(_loop_int)(n); i++)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a); i<(_loop_int)(b); i++)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1; i>=(_loop_int)(a); i--)

#define CHMIN(a,b) (a)=min((a),(b))
#define CHMAX(a,b) (a)=max((a),(b))
#define ALL(v) (v).begin(),(v).end()

#define DEBUG(x) cerr<<#x<<": "<<(x)<<endl
#define DEBUG_VEC(v) cerr<<#v<<": ";REP(__i,(v).size())cerr<<((v)[__i])<<", ";cerr<<endl

const ll MOD = 998244353ll;

ll modinv(ll a){
    ll b=MOD-2, r=1;
    while(b){
        if(b&1)r=r*a%MOD;
        a=a*a%MOD;
        b>>=1;
    }
    return r;
}

int n;
int a[252521];

const int MAX = 1252830;
// const int MAX = 12;
ll cnt[MAX];

ll dp[MAX];

int main(){
    scanf("%d",&n);
    REP(i,n)scanf("%d",a+i);
    REP(i,n)cnt[a[i]]++;

    ll ans = 0;
    FOR(i,1,MAX){
        ll total = 0;
        int it = i;
        while(it < MAX){
            total += 1ll * it * cnt[it] % MOD;
            total %= MOD;
            it += i;
        }
        it = i;
        while(it < MAX){
            total += MOD - 1ll * it * cnt[it] % MOD;
            total %= MOD;
            dp[i] += total * (1ll * it * cnt[it] % MOD) % MOD;
            dp[i] %= MOD;
            dp[i] += 1ll * cnt[it] * (cnt[it]-1) / 2 % MOD * it % MOD * it % MOD;
            dp[i] %= MOD;
            it += i;
        }
    }
    FORR(i,1,MAX){
        int it = i+i;
        while(it < MAX){
            dp[i] += MOD - dp[it];
            dp[i] %= MOD;
            it += i;
        }
        // DEBUG(dp[i]);
        ans += dp[i] * modinv(i) % MOD;
        ans %= MOD;
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 20736
# -*- coding: utf-8 -*-

from operator import itemgetter

n = int(input())
#tmp = input().split()
#hoge = list(map(lambda a: int(a), tmp))

data=[[0 for i in range(2)] for j in range(n)]
#print(data)
for i in range(0,n):
	tmp = input().split()
	hoge = list(map(lambda a: int(a), tmp))
	data[i][0]=hoge[0]
	data[i][1]=hoge[1]
#print(data)
data.sort()

#if(data[n-1][0]>data[n-1][1]):
res = data[n-1][0] + data[n-1][1]

print(res)


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

using namespace std;

typedef long long int ll;
typedef long long int lli;
typedef unsigned long long int ull;
typedef long double ld;
typedef string str;

typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<ld> vd;
typedef vector<str> vs;
typedef vector<ll> vll;
typedef vector<pair<ll, ll>> vpll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<char>> vvc;
typedef vector<vector<str>> vvs;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rrep(i, n) for (ll i = 1; i <= (n); ++i)
#define fin(ans) cout << (ans) << endl;
//３つ以上の値をセットに(3より多いときはカッコ内を増やす)\
sort -> p -> q -> r
#define mt(p, q, r) make_tuple(p, q, r)
#define all(a) a.begin(), a.end()

template <typename T>
void V(T &n)
{
  for (ll i = 0; i < n.size(); i++)
  {
    cin >> n[i];
  }
}

template <typename T, typename U>
void V2(T &n, U &m)
{
  for (ll i = 0; i < n.size(); i++)
  {
    cin >> n[i] >> m[i];
  }
}

template <typename T>
void Sort(T &n, ll a = 0, ll b = 0)
{
  if (b == 0)
  {
    return (sort(n.begin() + a, n.end()));
  }
  else
  {
    return (sort(n.begin() + a, n.begin() + b));
  }
}

template <typename T>
void Down(T &n, ll a = 0, ll b = 0)
{
  if (b == 0)
  {
    return (sort(n.begin() + a, n.end(), greater<ll>()));
  }
  else
  {
    return (sort(n.begin() + a, n.begin() + b, greater<ll>()));
  }
}

void Main()
{
  vll a(5); V(a); ll k; cin >> k;
  Sort(a);
  if(a[4] - a[0] <= k) fin("Yay!")
  else fin(":(")
}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(20); //高精度少数表示
  Main();
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <numeric>
#include <queue>
#include <numeric>
#include <iomanip>
#include <sstream>
#include <cmath>
#include <map>
#include <functional>
#include <limits>
#include <set>
#include <stack>
#include <cctype>
#define rep(i,a,b) for((i)=a;i<(int)(b);i++)

#define AAA (1000000007) 


using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pairII;


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

ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}
ll powD(ll a, ll b) {
	ll ans = 1;
	a %= AAA;
	for (int i = 0; i < b; i++)
	{
		ans *= a;
		ans %= AAA;
	}
	return ans;
}


int main() {
	int i, j, k;
	int N, M, K;

	string S;

	cin >> N;
	ll Sum;
	Sum = 1;
	ll A[100000];
	rep(i, 0, N) {
		cin >> A[i];
		if (A[i] == 0)
			Sum = 0;
	}
	if (Sum == 0) {
		cout << 0;
		return 0;
	}
	rep(i, 0, N) {
		if (A[i] == 0) {
			Sum = 0;
			break;
		}
		if (log10(Sum) + log10(A[i]) > 18) {
			Sum = -1;
			break;
		}
		Sum *= A[i];
		if (Sum > 1000000000000000000) {
			Sum = -1;
			break;
		}
	}
	cout << Sum;
}


Measured memory_bytes: 4704
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int h = sc.nextInt();
		int w = sc.nextInt();
		
		String[] s = new String[h + 2];
		char[] c = new char[w + 2];
		for (int i = 0; i < c.length; i++) {
			c[i] = '.';
		}
		
		for (int i = 0; i < h + 2; i++) {
			if (i == 0 || i == h + 1) {
				s[i] = String.valueOf(c); 
				continue;
			}
			s[i] = "." + sc.next() + ".";
		}
		
		for (int i = 1; i <= h; i++) {
			for (int j = 1; j <= w; j++) {
				
				if (s[i].charAt(j) == '#') {
					System.out.print("#");
					continue;
				}
				
				int cnt = 0;
				if (s[i - 1].charAt(j - 1) == '#') {
					cnt++;
				}
				if (s[i - 1].charAt(j) == '#') {
					cnt++;
				}
				if (s[i - 1].charAt(j + 1) == '#') {
					cnt++;
				}
				if (s[i].charAt(j - 1) == '#') {
					cnt++;
				}
				if (s[i].charAt(j + 1) == '#') {
					cnt++;
				}
				if (s[i + 1].charAt(j - 1) == '#') {
					cnt++;
				}
				if (s[i + 1].charAt(j) == '#') {
					cnt++;
				}
				if (s[i + 1].charAt(j + 1) == '#') {
					cnt++;
				}
				System.out.print(cnt);
			}
			System.out.println();
		}
	}
}

Measured memory_bytes: 21716
////////////////////////////////////////////////////
                    //                                                //
                    //  For her who keeps the fire kindling in me...  //
                    //                                                //
                    ////////////////////////////////////////////////////

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
// import java.util.Scanner;
// import java.util.Arrays;
// import java.util.ArrayList;
// import java.util.Collections; 
// import java.util.StringTokenizer;
import java.util.*;
import java.lang.Math;
import java.awt.Point;

import java.awt.geom.*;

public class Main {

    public static void main(String args[]) {
        try {
            FastReader s = new FastReader();
            BufferedWriter w = new BufferedWriter(new OutputStreamWriter(System.out));
            int i, j;
            long m, n, sum, t, max, k, h, x, y, min, correct_ans, vert, num, size, local_ans, global_ans;
            long a, b;


            // n = s.nextInt();
            // m = s.nextInt();
            
            n = s.nextLong();
            k = s.nextLong();

            long arr[] = new long[(int)n];



            for(i=0; i<(int)n; i++)
                arr[i] = s.nextLong();

        
            Arrays.sort(arr);

            sum = 0l;
            for(i=0; i<(int)(n-k); i++)
                sum+=  arr[i];

                w.write(sum+"\n");

            w.close();


        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

// ========================================### FAST IO ###=========================================//
class FastReader {
    BufferedReader br;
    StringTokenizer st;

    public FastReader() {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    String next() {
        while (st == null || !st.hasMoreElements()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

    int nextInt() {
        return Integer.parseInt(next());
    }

    long nextLong() {
        return Long.parseLong(next());
    }

    Double nextDouble() {
        return Double.parseDouble(next());
    }

    String nextLine() {
        String str = "";
        try {
            str = br.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return str;
    }
}
// ====================================================================================================//

Measured memory_bytes: 54996
#include<bits/stdc++.h>
using namespace std;
long long n,a[200010],sum[200010],x[200010],l,r,ans;
int main(){
	long long i,j;
	cin>>n;
	sum[0]=0;
	x[0]=0;
	for(i=1;i<=n;i++)cin>>a[i];
	for(i=1;i<=n;i++)sum[i]=sum[i-1]+a[i];
	x[1]=a[1];
	for(i=2;i<=n;i++)x[i]=x[i-1]^a[i];
	l=1;
	for(r=1;r<=n;r++){
		while(sum[r]-sum[l-1]!=(x[r]^x[l-1]))l++;
		ans+=r-l+1;
	}
	cout<<ans<<'\n';
	return 0;
}

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



Measured memory_bytes: 2088
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

using namespace std;

// repetition
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

// container util
#define all(x) (x).begin(), (x).end()

// debug
#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x)                                         \
  cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
       << " " << __FILE__ << endl;

// typedef
typedef long long lint;
typedef unsigned long long ull;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

// constant
const int MOD = (int)1e9 + 7;
const int INF = (int)1e18;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

// conversion
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

//
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() {
  ios::sync_with_stdio(false);
  cin.tie(0);

  int k, x;
  cin >> k >> x;
  if (x <= k * 500) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int table[3][3];
void solve(){
  for(int i=1 ; i<3 ; i++){
    if(!((table[i][0]-table[i-1][0] == table[i][1]-table[i-1][1]) && (table[i][1]-table[i-1][1] == table[i][2]-table[i-1][2]))){
      cout << "No" << endl;
      return;
    }
  }
  cout << "Yes" << endl;
}

int main(){
  for(int i=0 ; i<3 ; i++){
    for(int j=0 ; j<3 ; j++){
       cin >> table[i][j];
    }
  }
  solve();
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
 
int main(){
    int X, A, B;
    cin >> X >> A >> B;
    if ( (X-A)*(X-A) > (X-B)*(X-B) )
	{
        cout << "B" ;
    }
    else
	{
        cout << "A" ;
    }
}

Measured memory_bytes: 3088
// #include "knapsack_2.h"
#include <algorithm>
#include <iostream>
#include <limits>
#include <numeric>
#include <vector>

struct Item {
    int weight;
    int value;

    Item(int w, int v)
        : weight{w}
        , value{v}
    {
    }
};

long long max_value(const std::vector<Item>& items, long long capacity)
{
    const int sum_values{std::accumulate(
        items.cbegin(), items.cend(), 0, [](auto acc, const auto& item) {
            return acc + item.value;
        })};

    std::vector<long long> dp(sum_values + 1, 1e18 + 5);
    dp.front() = 0;

    for (const auto& item : items) {
        for (int value = sum_values; value >= item.value; --value) {
            dp[value] =
                std::min(dp[value], item.weight + dp[value - item.value]);
        }
    }

    auto it = std::find_if(dp.crbegin(), dp.crend(), [capacity](auto val) {
        return val <= capacity;
    });

    return dp.size() - 1 - std::distance(dp.crbegin(), it);
}

int main(int argc, char* argv[])
{
    int n, capacity;
    std::cin >> n >> capacity;
    std::vector<Item> items;
    items.reserve(n);
    for (int i = 0; i < n; ++i) {
        int weight, value;
        std::cin >> weight >> value;
        items.emplace_back(weight, value);
    }
    std::cout << max_value(items, capacity) << std::endl;
    return 0;
}


Measured memory_bytes: 1024
/*************************************************************************
	> File Name: 1.cpp
	> Author: Knowledge_llz
	> Mail: 925538513@qq.com 
	> Blog: https://blog.csdn.net/Pig_cfbsl 
	> Created Time: 2020/7/5 20:21:41
 ************************************************************************/

#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<algorithm>
#define For(i,a,b) for(register int i=(a);i<=(b);++i)
#define LL long long
using namespace std;
int read(){
	char x=getchar(); int u=0,fg=0;
	while(!isdigit(x)){ if(x=='-') fg=1; x=getchar(); }
	while(isdigit(x)){ u=(u<<3)+(u<<1)+(x^48); x=getchar(); }
	return fg?-u:u;
}
const int maxx=4e5+10;
const int mod=1e9+7;
LL a[maxx],b[maxx],c[maxx],numa=0,numb=0,ans=1;
bool zero;
bool cmp(LL x,LL y){ return x>y; } 
int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.in", "r", stdin);
	freopen("output.out", "w", stdout);
#endif
	int n=read(),k=read();
	LL u;
	For(i,1,n){
		u=read();
		ans=ans*u%mod;
		if(u>0) a[++numa]=u;
		else if(u<0) b[++numb]=-u;
		else zero=1;
	}
	if(numa+numb<k){
		printf("0\n");
		return 0;
	}
	if(k==n){
		printf("%lld\n",(ans+mod)%mod);
		return 0;
	}
	ans=1;
	sort(a+1,a+numa+1,cmp);
	sort(b+1,b+numb+1,cmp);
	int cnt=0;
	if((k&1)==0){
		for(int i=1;i+1<=numa;i+=2)
			c[++cnt]=a[i]*a[i+1];
		for(int i=1;i+1<=numb;i+=2)
			c[++cnt]=b[i]*b[i+1];
		sort(c+1,c+cnt+1,cmp);
		int i,j;
		for(i=k,j=1;i>0 && j<=cnt;i-=2,++j)
			ans=(ans*(c[j]%mod))%mod;
//		cout<<i<<j<<endl;
		if(i>0) ans=ans*a[numa]%mod*(-b[numb])%mod;
	}
	else{
		if(!numa){
			if(numb>=k){ 
				for(int i=numb;i>=numb-k+1;i--)
					ans=ans*b[i]%mod;
				ans=-ans;
			}
			else ans=0;
		}
		else{
		ans=a[1];
		for(int i=2;i+1<=numa;i+=2)
			c[++cnt]=a[i]*a[i+1];
		for(int i=1;i+1<=numb;i+=2)
			c[++cnt]=b[i]*b[i+1];sort(c+1,c+cnt+1,cmp);
		--k;
	int i,j;
		for(i=k,j=1;i>0 && j<=cnt;i-=2,++j)
			ans=(ans*(c[j]%mod))%mod;
//		cout<<i<<j<<endl;
		if(i>0) ans=ans*a[numa]%mod*(-b[numb])%mod;
		}
	}
//	cout<<ans<<endl;
	if(ans<0 && zero) ans=0;
	printf("%lld\n",(ans+mod)%mod);
	return 0;
}


Measured memory_bytes: 6060
package main

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

type ByValue []float64

func (s ByValue) Len() int           { return len(s) }
func (s ByValue) Swap(i, j int)      { s[i], s[j] = s[j], s[i] }
func (s ByValue) Less(i, j int) bool { return s[i] < s[j] }

func input() string {
	var s string
	fmt.Scan(&s)
	return s
}

func inputLn() string {
	var s string
	fmt.Scanln(&s)
	return s
}

func inputByScanner(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}

func convListStrToInt(strList []string) []int {
	intList := make([]int, len(strList))
	for k, v := range strList {
		intV, _ := strconv.Atoi(v)
		intList[k] = intV
	}
	return intList
}

func convListStrToFloat(strList []string) []float64 {
	intList := make([]float64, len(strList))
	for k, v := range strList {
		intV, _ := strconv.Atoi(v)
		intList[k] = float64(intV)
	}
	return intList
}

func main() {
	n, _ := strconv.Atoi(inputLn())
	hList := make([]int, n)
	for i := 0; i < n; i++ {
		num, _ := strconv.Atoi(input())
		hList[i] = num
	}

	res := "Yes"
	max := hList[0]
	for i := 1; i < n; i++ {
		if hList[i] < max {
			res = "No"
		}
		if max < hList[i] {
			max = hList[i] - 1
		}
	}
	fmt.Println(res)
}


Measured memory_bytes: 5504
#include <bits/stdc++.h>
using namespace std;
#define boost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define fi first
#define se second
#define debug(x) cerr << " - " << #x << ": " << x << endl;
#define debugs(x, y) cerr << " - " << #x << ": " << x << " " << #y << ": " << y << endl;
#define debugii(x) cerr << " - " << #x << ": " << x.fi<<","<<x.se << endl;
#define sep() cerr << "--------------------" << endl;
#define all(x) (x).begin(),(x).end()
#define sz(x) (ll)x.size()
#define ll long long
#define ii pair<int,int>
#define v vector<int>
#define vii vector<ii>
#define vv vector<vector<int> >
#define mp make_pair
#define INF 1000000000
#define pb push_back
#define EPS 1e-9
const int MOD = 1000000007; // 998244353
int tab[100002][3],n,dp[100002][3];
int solve(int idx,int last){
    if(idx==n)return 0;
    if(last!=-1&&dp[idx][last]!=-1)
        return dp[idx][last];
    int ans=0;
    for (int i = 0; i < 3; ++i)
        if(last!=i)
            ans=max(ans,tab[idx][i]+solve(idx+1,i));
    if(last!=-1)dp[idx][last]=ans;
    return ans;
}
int main(){
    boost;
    memset(dp,-1,sizeof dp);
    cin>>n;
    for (int i = 0; i < n; ++i)
        for (int j = 0; j < 3; ++j)
            cin>>tab[i][j];
    cout<<solve(0,-1);
    return 0;
}
//long long
//array bounds
//special cases
//binary search

Measured memory_bytes: 10368
// be name khoda
#include<bits/stdc++.h>

using namespace std;

#define F first
#define S second
#define int long long
#define mpr make_pair 
#define pii pair<int,int>
typedef long long ll;
#pragma GCC optimize("Ofast")

const int maxn = 2010;
const int mod = 998244353;
const int inf = 1e18+10;

int n, x;
int a[maxn];
vector<int> stk;
int mn[maxn][maxn];

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

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

    int ans = inf;
    for(int t = 1; t <= n; t++)
    {
        int cost = x*(t-1);
        for(int l = 0; l < n; l++)
        {
            int r = (l+t-1) % n;
            if(l == r)
            {
                mn[l][r] = a[l];
                cost += mn[l][r];
                continue;
            }
            mn[l][r] = min(a[l], mn[(l+1)%n][r]);
            cost += mn[l][r];
        }
        ans = min(ans,cost);
    }
    cout<< ans;
}

 


 

Measured memory_bytes: 31744
n, m = map(int, raw_input().split())
a = []
for i in range(n):
    ls2 = map(int, raw_input().split())
    a.append(ls2)
b = []
for i in range(m):
    b.append(input())
c = []
for i in range(n):
    #c.append([])
    #c_pre = []
    c_i = 0
    for j in range(m):
        #c_pre.append(a[i][j]*b[j])
        c_i += a[i][j]*b[j]
    c.append(c_i)
for i in xrange(n):
    print c[i]

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

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            var X = int.Parse(Console.ReadLine());
            var A = int.Parse(Console.ReadLine());
            var B = int.Parse(Console.ReadLine());

            Console.WriteLine((X - A) % B);
        }
    }
}

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

using namespace std;
using ll = long long;
const int MOD = 1000000007;

int main() {
    int H, W;
    cin >> H >> W;

    vector<vector<bool> > hw(H + 1,vector<bool>(W + 1,1));
    vector<vector<int> > dp(H + 1,vector<int>(W + 1,0));
    dp.at(1).at(1) = 1;

    char temp;
    for(int h = 1; h < H + 1; h++) {
        for(int w = 1; w < W + 1; w++) {
            cin >> temp;
            if(temp == '.') {
                hw.at(h).at(w) = 0;
            }
        }
    }

    int ans = 0;
    int h, w;
    for(int i = 1; i < H + W + 1; i++) {
        for(int j = 0; j < H + W; j++) {
            h = j;
            w = i - j;
            if(h > 0 && w > 0 && h <= H && w <= W) {
                if(!(hw.at(h - 1).at(w))) {
                    dp.at(h).at(w) += dp.at(h - 1).at(w);
                }
                dp.at(h).at(w) %= MOD;
                if(!(hw.at(h).at(w - 1))) {
                    dp.at(h).at(w) += dp.at(h).at(w - 1);
                }
                dp.at(h).at(w) %= MOD;
                //cout << h << ',' << w << endl;
            }
        }
    }

    cout << dp.at(H).at(W) << endl;


    return 0;
}

Measured memory_bytes: 7728
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()
#define LL long long

using namespace std;

int main(){

    int N,M;cin>>N>>M;
    int cnt[N];fill_n(cnt,N,0);
    REP(i,M){
        int a,b;cin>>a>>b;
        cnt[--a]++;cnt[--b]++;
    }
    REP(i,N)if(cnt[i]%2){
            cout<<"NO"<<endl;
            return 0;
        }
    cout<<"YES"<<endl;

    return 0;
}

Measured memory_bytes: 640
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline
H, W, B, A = map(int, input().split())
grid = [[0]*W for _ in range(H)]

for row in range(H):
    for col in range(W):
        if (row < A and col < B) or (row >= A and col >= B):
            grid[row][col] = 1
for l in grid:
    print("".join(map(str, l)))


Measured memory_bytes: 11892
n = int(input())
L = list(map(int, input().split()))
L.sort()
ans = 0
for i in range(n - 2):
    a = L[i]
    k = i
    for j in range(i + 1, n - 1):
        b = L[j]
        while k < n and L[k] < a + b:
            k += 1
        ans += k - (j + 1)
print(ans)


Measured memory_bytes: 3188
#include <iostream> // cin, cout, cerr
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota
#include <cstdio> // printf, scanf
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <iomanip> // cout<<setprecision(n)
#include <functional> // function<void(int)>

#ifdef DEBUG
#include "debug.hpp"
#else
#define debug(...)
#endif

#define rep(i,n) for(int i = 0; i < (n); i++)
#define ENDL '\n'
#define print(i) std::cout << (i) << '\n'

#define int long long // at least int64 > 9*10^18
#define all(v) (v).begin(), (v).end()
/* libraries */

signed main() {
	std::string s;
	std::cin >> s;
	int n = s.size();
	rep(i,n-1) {
		if(s[i]==s[i+1]) {
			std::cout << i+1 << ' ' << i+2 << ENDL;
			return 0;
		}
	}
	rep(i,n-2) {
		if(s[i]==s[i+2]) {
			std::cout << i+1 << ' ' << i+3 << ENDL;
			return 0;
		}
	}
	std::cout << -1 << ' ' << -1 << ENDL;
	return 0;
}


Measured memory_bytes: 512
import sys
## io ##
def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
def MIIZ(): return list(map(lambda x: x-1, MII()))
#======================================================#
def main():
    n = II()
    aa = MII()
    t = 1
    if 0 in aa:
        print(0)
        return None
    for a in aa:
        t *= a
        if t > 10**18:
            print(-1)
            return None
    print(t)

if __name__ == '__main__':
    main()

Measured memory_bytes: 22152
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,a,c=0;
  cin>>n;
  map<int,int> m;
  for(int i=0;i<n;i++){
    cin>>a;
    m[a]++;
  }
  for(auto au:m){
    if(au.first>au.second) c+=au.second;
    else c+=au.second-au.first;
  }
  cout<<c;
}

Measured memory_bytes: 4736
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){return o<<"("<<p.fs<<","<<p.sc<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}
typedef pair<int,int> P;
int N,M;
int I;
const int MI=500000;
int inf=1e9;
vector<P> G[MI];
map<P,int> p2id;
int getid(int v,int c){
	if(p2id.count(P(v,c))) return p2id[P(v,c)];
	p2id[P(v,c)]=I;
	return I++;
}
int d[MI];
void add_edge(int a,int b,int c){
	G[a].pb(P(b,c));
	G[b].pb(P(a,c));
}
int main(){
	scanf("%d%d",&N,&M);
	I=N;
	rep(i,M){
		int p,q,c;
		scanf("%d%d%d",&p,&q,&c);
		p--,q--;
		int a=getid(p,c);
		int b=getid(q,c);
		add_edge(a,b,0);
		add_edge(a,p,1);
		add_edge(b,q,1);
	}
	priority_queue<P,vector<P>,greater<P> > que;
	rep(i,I) d[i]=inf;
	d[0]=0;
	que.push(P(0,0));
	while(!que.empty()){
		P p=que.top();que.pop();
		int v=p.sc,c=p.fs;
		if(d[v]!=c) continue;
		for(P e:G[v]){
			int u=e.fs,cost=e.sc;
			if(d[u]>d[v]+cost){
				d[u]=d[v]+cost;
				que.push(P(d[u],u));
			}
		}
	}
	if(d[N-1]==inf) puts("-1");
	else cout<<d[N-1]/2<<endl;
}


Measured memory_bytes: 58108
from collections import deque

#create digraph
#nodes will be (steps % 3) * N + node
N, M = map(int, input().split())
adj = [[] for _ in range(3*N)]
for _ in range(M):
    u, v = map(int, input().split())
    u -= 1
    v -= 1

    adj[      u].append(  N + v)
    adj[  N + u].append(2*N + v)
    adj[2*N + u].append(      v)

S, T = map(int, input().split())
S -= 1
T -= 1

#bfs
q = deque([S])
depth = [10 ** 9] * (3*N)
depth[S] = 0
while q:
    node = q.popleft()
    if node == T:
        break
    for next_node in adj[node]:
        if depth[next_node] > depth[node] + 1:
            depth[next_node] = depth[node] + 1
            q.append(next_node)

if depth[T] == 10 ** 9:
    print(-1)
else:
    print(depth[T] // 3)

Measured memory_bytes: 112212
<?php
    fscanf(STDIN,"%d%d%d%d",$W,$H,$x,$y);
    
    //xyが長方形の中心にある場合
    if($W == 2*$x && $H == 2*$y){
        echo ($W*$H/2)." 1";
    }else{
        echo ($W*$H/2)." 0";
    }
    
    
    
?>

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

int main()
{
	int n;
	cin>>n;
	n=n%10;
	if(n==2 or n==4 or n==5 or n==7 or n==9)
	{
		cout<<" hon"<<endl;
	}
	else if(n==0 or n==1 or n==6 or n==8)
	{
		cout<<" pon"<<endl;
	}
	else
	{
		cout<<" bon"<<endl;
	}
	return 0;
}

Measured memory_bytes: 3552
#include <iostream>
#include <cstdio>

using namespace std;

long long int pat(long long int a){
	if(a <= 1000){
		return a + 1;
	}else if(a <= 2000){
		return 2001 - a;
	}else{
		return 0;
	}
}

int main(){
	
	long long int n, ans;
	
	while(true){
		cin >> n;
		if(cin.eof()){
			break;
		}
		ans = 0;
		for(long long int i = 0; i <= n; i++){
			ans += pat(i) * pat(n - i);
		}
		printf("%lld\n", ans);
	}
	
	return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
int main() {
  int n;
  string s;
  cin >> n >> s;
  int r = 0, w = 0;
  rep(i,n){
    if(s[i]=='R') r++;
    else w++;
  }
  int ans = 0;
  rep(i,r){
    if(s[i]=='W') {
      ans++;
    }    
  }
  cout << ans << endl;
}

Measured memory_bytes: 3720
#include<bits/stdc++.h>
using namespace std;
int fa[100010];
bool f[100010];
int getf(int x)
{
	if(fa[x]==x)
		return x;
	return fa[x]=getf(fa[x]);
}
int main()
{
	int n,m,i,u,v,w,tot=0;
	cin>>n>>m;
	for(i=1;i<=n;i++)
		fa[i]=i;
	for(i=0;i<m;i++)
	{
		cin>>u>>v>>w;
		fa[getf(u)]=getf(v);
	}
	for(i=1;i<=n;i++)
	{
		int x=getf(i);
		if(!f[x])
			tot++;
		f[x]=true;
	}
	cout<<tot;
	return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long int
#define mod 1000000007
#define string_mod 2549536629329_base_255
#define pb push_back
#define F first
#define S second
#define ff first
#define endl "\n"
#define ss second
#define all(v) v.begin(), v.end()
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
int power(int x, unsigned int y, int p)
{
  int res = 1;
  x = x % p;
  while (y > 0)
  {

    if (y & 1)
      res = (res * x) % p;

    y = y >> 1;
    x = (x * x) % p;
  }
  return res;
}

int lcm(int a, int b)
{
  return (a * b) / __gcd(a, b);
}  
int32_t main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int tc;
  tc = 1;
  while (tc--)
  {
    int n, k;
    cin >> n;
    int a[n];
    for (int i = 0; i < n;i++){
      cin >> a[i];
    }
    int mn = a[0];
    int ans = 1;
    for (int i = 1; i < n;i++){
      if(a[i]<mn){
        ans++;
        mn = a[i];
      }
    }
    cout << ans << endl;
  }

  return 0;
}

Measured memory_bytes: 1792