akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define MAX(x,y) (x>y?x:y)
#define MIN(x,y) (x<y?x:y)
#define ABS(x) (x>0?x:-(x))

#define INF 1000000000

int array_min_max(int* p, int n,bool f)  //f: true→min false→max
{
	int tmp;

	if (f)
		tmp = INF;
	else
		tmp = 0;

	for (int i = 0; i < n; i++)
	{
		if (f)
		{
			if (p[i] < tmp)
				tmp = p[i];
		}
		else
		{
			if (p[i] > tmp)
				tmp = p[i];
		}
	}
	return tmp;
}

int main()
{
	int A, B;

	scanf("%d%d", &A, &B);

	if (A + 1 < B)
		printf("%d\n", B + (B - 1));
	else if (A > B + 1)
		printf("%d\n", A + (A - 1));
	else
		printf("%d\n", A + B);
}

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

int main() {
	int n,m,a,b;
	cin >> n >> m;
		a=1;
	b=n;
	if(n == 4){
		cout << 1 << " " << 4 << endl;
	}
	else{
	if(n%4 == 1){
		for(int i=0;i<m;i++){
			cout << a << " " << b << endl;
			a++;
			b--;
		}
	}
	else if(n%4 == 0){
		for(int i=0;i<m;i++){
			if(i==n/4-1){
				cout << a << " " << b << endl;
			a++;
			b-=2;
			continue;
			}
			cout << a << " " << b << endl;
			a++;
			b--;
		}
	}
	else if(n%4 == 3){
		for(int i=0;i<m;i++){
			cout << a << " " << b << endl;
			a++;
			b--;
		}
	}
	else if(n%4 == 2){
		for(int i=0;i<m;i++){
			if(i==n/4-1){
				cout << a << " " << b << endl;
			a++;
			b-=2;
			continue;
			}
			cout << a << " " << b << endl;
			a++;
			b--;
		}
	}
}
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define enter putchar('\n')
#define space putchar(' ')
#define eps 1e-8
#define mo 974711
#define MAXN 200005
//#define ivorysi
using namespace std;
typedef long long int64;
typedef double db;
template<class T>
void read(T &res) {
    res = 0;char c = getchar();T f = 1;
    while(c < '0' || c > '9') {
    if(c == '-') f = -1;
    c = getchar();
    }
    while(c >= '0' && c <= '9') {
    res = res * 10 + c - '0';
    c = getchar();
    }
    res *= f;
}
template<class T>
void out(T x) {
    if(x < 0) {x = -x;putchar('-');}
    if(x >= 10) {
    out(x / 10);
    }
    putchar('0' + x % 10);
}
int64 N,P;
int64 g = 1;
int main() {
#ifdef ivorysi
    freopen("f1.in","r",stdin);
#endif
    read(N);read(P);
    if(N == 1) {out(P);enter;return 0;}
    for(int64 i = 2 ; i <= P / i ; ++i) {
        if(P % i == 0) {
            int64 cnt = 0;
            while(P % i == 0) {P /= i;++cnt;}
            int64 k = cnt / N;
            while(k--) g *= i;
        }
    }
    out(g);enter;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <stdio.h>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <cstring>

using namespace std;

#define f first
#define s second
#define pb push_back
#define mp make_pair
#define ll long long
#define pii pair < int, int >
#define pll pair < long long, long long>
#define ull unsigned long long
#define vi vector < int >
#define vll vector < long long >
#define sz(a) (int)a.size()
#define forit(it, s) for(__typeof(s.begin()) it = s.begin(); it != s.end(); it++)
#define all(a) a.begin(), a.end()
#define sqr(x) ((x) * (x))
#define fname "searching"

const int inf = (int)1e9;
const ll INF = (ll)1e18;
const double eps = 1e-9;
const double pi = acos(-1.0);
const int mod = (int)1e9 + 7;

int n, k, a[55];
ll dp[55][55][5000];

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

    dp[0][0][0] = 1;
    for(int i = 0; i < n; ++i){
        for(int j = 0; j < n; ++j){
            for(int w = 0; w < 5000; ++w){
                dp[i + 1][j + 1][w + a[i]] += dp[i][j][w];
                dp[i + 1][j][w] += dp[i][j][w];
            }
        }
    }

    ll ans = 0;
    for(int i = 1; i <= n; ++i) ans += dp[n][i][k * i];

    return ans;
}

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

    cout << solve() << "\n";
    
    return 0;
}


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

#define MOD 1000000007
#define MAX_P 200005
Int fact[MAX_P],inv[MAX_P],finv[MAX_P];;
Int extgcd(Int a,Int b,Int& x,Int& y){
  Int d=a;
  if(b!=0){
    d=extgcd(b,a%b,y,x);
    y-=(a/b)*x;
  }else{
    x=1;y=0;
  }
  return d;
}
Int mod_inverse(Int a,Int mod){
  Int x,y;
  extgcd(a,mod,x,y);
  return (mod+x%mod)%mod;
}

Int mod_pow(Int x,Int n,Int mod){
  Int res=1;
  while(n){
    if(n&1) (res*=x)%=mod;
    (x*=x)%=mod;
    n>>=1;
  }
  return res;
}

Int mod_inverse2(Int a,Int mod){
  return mod_pow(a,mod-2,mod);
}

void init(Int mod){
  fact[0]=1;
  for(Int i=1;i<MAX_P;i++)
    fact[i]=(fact[i-1]*i)%mod;

  inv[1]=1;
  for(Int i=2;i<MAX_P;i++)
    inv[i]=inv[mod%i]*(mod-mod/i)%mod;
  
  finv[0]=1;
  for(Int i=1;i<MAX_P;i++)
    finv[i]=finv[i-1]*inv[i]%mod;
}

Int mod_fact(Int n,Int mod,Int& e){
  e=0;
  if(n==0) return 1;
  Int res=mod_fact(n/mod,mod,e);
  e+=n/mod;
  if(n/mod%2!=0)return res*(mod-fact[n%mod]) %mod;
  return res*fact[n%mod]%mod;
}

Int mod_comb(Int n,Int k,Int mod){
  if(n==k||k==0) return 1;
  Int e1,e2,e3;
  Int a1=mod_fact(n,mod,e1),a2=mod_fact(k,mod,e2),a3=mod_fact(n-k,mod,e3);
  if(e1>e2+e3) return 0;
  return a1*mod_inverse(a2*a3%mod,mod)%mod;
}

Int mod_comb2(Int n,Int k,Int mod){
  Int res=1;
  for(Int i=0;i<k;i++){
    res*=(n-i)%mod;
    res%=mod;
    res*=mod_inverse(i+1,mod);
    res%=mod;
  }
  return res;
}

//only for prime mod
Int mod_comb3(Int n,Int k,Int mod){
  if(k<0||k>n) return 0;
  return fact[n]*finv[k]%mod*finv[n-k]%mod;
}

Int montmort(Int n,Int mod){
  Int res=0,inv=1;
  for(Int k=2;k<=n;k++){
    (inv*=mod_inverse(k,mod))%=mod;
    if(k%2) (res+=mod-inv)%=mod;
    else (res+=inv)%=mod;
  }
  for(Int i=1;i<=n;i++)
    (res*=i)%=mod;
  return res;
}

// calculate P(t) from given points in [0,N]
Int LagrangePolynomial(vector<Int> &y,Int t,const Int mod){
  init(mod);
  Int n=y.size()-1;
  Int num=1;
  for(Int i=0;i<=n;i++)
    num=num*((t-i)%mod)%mod;
  Int res=0;
  for(Int i=0;i<=n;i++){
    Int tmp=(y[i]*num%mod)*mod_inverse((t-i)%mod,mod)%mod;
    tmp=tmp*finv[i]%mod;
    tmp=tmp*finv[n-i]%mod;
    if((n-i)&1) tmp=mod-tmp;
    res=(res+tmp)%mod;
  }
  return res;
}

//INSERT ABOVE HERE
Int dp[5050][5050];
signed main(){
  memset(dp,0,sizeof(dp));
  Int n;
  cin>>n;
  vector<Int> a(n),b(n);
  for(Int i=0;i<n;i++){
    cin>>a[i]>>b[i];
    dp[2500-a[i]][2500-b[i]]++;
  }
  
  for(Int i=1;i<5000;i++)
    for(Int j=1;j<5000;j++)
      dp[i][j]=(dp[i][j]+dp[i-1][j]+dp[i][j-1])%MOD;
  
  Int ans=0;
  for(Int i=0;i<n;i++)
    ans=(ans+dp[2500+a[i]][2500+b[i]])%MOD;

  init(MOD);
  for(Int i=0;i<n;i++) 
    ans=(ans+MOD-mod_comb3((a[i]+b[i])*2,a[i]*2,MOD))%MOD;

  ans=ans*mod_inverse(2,MOD)%MOD;
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 207360
# D - 2017-like Number
# https://atcoder.jp/contests/abc084/tasks/abc084_d

counts = []
counts.append(0)
counts.append(0)
counts.append(0)

prime = []

is_prime = []
is_prime.append(False)
is_prime.append(False)

def sieve(r):
    for i in range(2, r + 1):
        is_prime.append(True)

    for i in range(2, r + 1):
        if is_prime[i]:
            prime.append(i)

            j = 2 * i
            while j <= r:
                is_prime[j] = False
                j = j + i

def calc_like_number_count(r):
    for i in range(3, r + 1):
        if i % 2 == 1 and is_prime[i] and is_prime[(i + 1) // 2]:
            counts.append(1)
        else:
            counts.append(0)
    
    for i in range(3, r + 1):
        counts[i] = counts[i] + counts[i - 1]


def main():
    Q = int(input())
    querys = []
    max_r = 0
    for i in range(Q):
        l, r = map(int, input().split())
        querys.append((l, r))
        if max_r < r:
            max_r = r

    sieve(max_r)
    calc_like_number_count(max_r)

    for l, r in querys:
        print(counts[r] - counts[l - 1])
    
main()

Measured memory_bytes: 62808
import sys
input = sys.stdin.readline

from collections import deque

N,M=map(int,input().split())
AL=[[] for _ in range(N)]
for _ in range(M):
    A,B=map(int,input().split())
    AL[A-1].append(B-1)
    AL[B-1].append(A-1)
Q=deque([[0,-1]]) # [今いるindex,前のindex]
ANS=[-1 for _ in range(N)] # 答え
ANS[0]=1
TF=[0 for _ in range(N)]
while Q:
    i,c=Q.popleft()
    if TF[i]:
        continue
    TF[i]=1
    ANS[i]=c
    for j in AL[i]:
        if not TF[j]:
            Q.append([j,i])

print('Yes')
for i in range(1,N):
    print(ANS[i]+1)
    

Measured memory_bytes: 42492
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long A = sc.nextLong();
		long B = sc.nextLong();
		
		long h[] = new long[N];
		
		for(int i=0; i<N; i++){
			h[i]=sc.nextLong();
		}
		
		long fin;
		fin = Long.MAX_VALUE/B;
		long answer = binarytree(0,fin,A,B,N,h);
		System.out.println(answer);
	}
	
	public static long binarytree(long startrange, long endrange, long A,long B,int N,long h[]){
		if(startrange>endrange) return startrange;
		long mid = (startrange+endrange)/2;
		if(kansuu(mid,A,B,N,h)){
			return binarytree(startrange,mid-1,A,B,N,h);
		}
		else{
			return binarytree(mid+1,endrange,A,B,N,h);
		}
	}
	public static boolean kansuu(long T,long A,long B,int N,long h[]){
		double times=0;
		for(int i=0; i<N; i++){
			double U =(double)(h[i]-B*T);
			double K = U/(double)(A-B);
			double Y = Math.ceil(K);
			if(Y>0){
				times = times + Y;
			}
		}
		if(times<=T) return true;
		else return false;
	}
}

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

namespace ABC066A
{
	class Program
	{
		static void Main(string[] args)
		{
			int a, b, c,s;
			string[] word = Console.ReadLine().Split(' ');
			a = int.Parse(word[0]);
			b = int.Parse(word[1]);
			c = int.Parse(word[2]);

			if ((a > b) && (a > c))
			{
				s = b + c;
			}
			else if ((b > a) && (b > c))

			{
				s = a + c;
			}
			else
				s = a + b;



			Console.WriteLine(s);
			
		}
	}
}


Measured memory_bytes: 27304
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int mod = 1e9+7;

int main(){
    int n;
    cin >> n;
    list<int> li;
    for(int i = 0; i < n; i++){
        int a;
        cin >> a;
        if(i%2 == 1) li.push_back(a);
        else li.push_front(a);
    }
    if(n%2 == 0) li.reverse();
    for(auto p:li){
        cout << p << " ";
    }
    cout << endl;
}

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

using namespace std;

int main() {
    int num;
    string s;
    
    cin >> num >> s;
  
  	if (num % 2 != 0) {
      cout << "No" << endl;
      return 0;
    }

    string s1 = s.substr(0, num / 2);
    string s2 = s.substr(num / 2, num / 2);
    
    cout << (s1 == s2 ? "Yes" : "No") << endl;
    
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>

typedef long long ll;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define print(x) cout<<(x)<<endl
#define rep(i,n) for(int i = 0;i < ((int)(n));++i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SUM(vec) accumulate(all(vec),0LL)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define test(a) cout<<(#a)<<':'<<(a)<<endl

const int INF = 1e9+7;
const ll INFL = 9*1e18;

ll inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;}
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);}
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;}
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;}


bool isOk(ll key,ll value){
  return key < value;
}

int binary_search(vector<ll> a,ll key){
  ll ok = a.size();
  ll ng = -1;

  while(abs(ok - ng) > 1){
    ll mid = (ok + ng) / 2;
    if(isOk(key,a[mid]))ok = mid;
    else ng = mid;
  }
  return ok;
}


int main() {
  cin.tie(0); ios::sync_with_stdio(0);
  string s;cin>>s;
  int ans =0 ;
  rep(i,s.size()/2){
    if(s[i] != s[s.size()-i-1])ans++;
  }
  print(ans);
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
	// your code goes here
	   int n;
	   cin >> n;
	   int arr[n];
	   for (int i = 0; i < n;i++) {
	       cin >> arr[i];
	   }
	   sort (arr,arr + n);
	   long long int count = 0;
	   for (int i = 0; i < n - 2;i++) {
	       for (int j = i + 1; j < n - 1;j++) {
	           for (int k = j + 1; k < n;k++) {
	               if (arr[i] == arr[j] || arr[i] == arr[k] || arr[k] == arr[j])    continue;
	               if (arr[i] + arr[j] > arr[k])    count++;
	           }
	       }
	   }
	   cout << count << endl;
	
	return 0;
}


Measured memory_bytes: 3576
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
using namespace std;
typedef long long ll;

int N;
int h[100];

int f(int begin,int end,int m){
    //cout<<begin<<'~'<<end<<endl;
    if(end-begin<=1) return h[begin]-m;
    int minh=100100;
    for(int i=begin;i<end;i++) if(h[i]<minh) minh=h[i];
    int res=minh-m;
    int l=begin;
    for(int i=begin;i<end;i++){
        if(h[i]==minh){
            res+=f(l,i,minh);
            l=i+1;
        }else if(i==end-1){
            res+=f(l,end,minh);
        }
    }
    return res;
}

int main(){
    cin>>N;
    rep(i,N){
        cin>>h[i];
    }

    int ans=f(0,N,0);

    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a[40];
int main(){
	int n, m, ans = 0;
	cin >> n >> m;
	int s = n;
	while(s--){
		int k;
		cin >> k;
		for(int i = 0; i < k; i++){
			int x;
			cin >> x;
			a[x] ++;
			if(a[x] == n)
				ans ++;
		}
	}
	cout << ans;
	
	
	
}

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

const int64_t MOD = 1000000007;
typedef long long ll;
typedef unsigned long long ull;

#define FOR(i, start, end) for(uint64_t i=start; i<end; i++)
#define REP(i, n) FOR(i, 0, n)

// 最大公約数gcd
// 最小公倍数lcm=m*n/gcd
uint64_t gcd(uint64_t m, uint64_t n) {
  uint64_t temp;
  while (m % n != 0){
    temp = n;
    n = m % n;
    m = temp;
  }
  return n;
}

uint64_t lcm(uint64_t m, uint64_t n) {
  return (m*n)/gcd(m,n);
}

// vector<vector<uint64_t> > v(n+1, vector<uint64_t>(n+1, 0))
// v[n][k]に組み合わせ数が入る。
void comb(vector<vector <uint64_t> > &v){
  for(uint64_t i = 0;i <v.size(); i++){
    v[i][0]=1;
    v[i][i]=1;
  }
  for(uint64_t k = 1;k <v.size();k++){
    for(uint64_t j = 1;j<k;j++){
      v[k][j]=(v[k-1][j-1]+v[k-1][j]);
    }
  }
}

// 掛け算オーバーフロー判定
bool is_product_overflow(uint64_t a, uint64_t b) {

	uint64_t prod = a * b;
	
	return (prod / b != a);
}

//素因数分解
void primeFactorization(uint64_t a, list<uint64_t> &factors){ //素因数分解を出力するプログラム
  long i,sq;
  if(a%2==0){ //偶数の場合
    factors.push_back(2);
    primeFactorization(a/2,factors); //2で割った値で再帰
    return;
  }
  sq = sqrt(a);
  for(i=3;i<=sq;i+=2){ //3以上√a以下の奇数の場合
	if(a%i==0){
	  factors.push_back(i);
      primeFactorization(a/i,factors); //割れた値で再帰
      return;
	}
  }
  //偶数でも3以上√a以下の奇数の場合でも割り切れない場合
  if(a!=1){ //aが1でないなら、a自身は素数
    factors.push_back(a);
  }
}

// フェルマーの小定理
// mod. m での a の逆元 a^{-1} を計算する
// (a/b)%m = a*movinv(b,m)%m  
int64_t modinv(int64_t a, int64_t m) {
    int64_t b = m, u = 1, v = 0;
    while (b) {
        int64_t t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

// 円周率
// M_PI

// #include <iomanip> // setprecisionを使用するのに必要
// cout << std::fixed << std::setprecision(15) << y << endl;

// 昇順
// priority_queue<int, vector<int>, greater<int> > queue;

ll pCount(int x){
  if(x==0) return 1;
  return pCount(x-1)*2 + 1;
}

ll allCount(int x){
  if(x==0) return 1;
  return allCount(x-1)*2 + 3;
}


signed main() {
  ll n;
  cin >> n;
  
  vector<ll> vals;
  vals.push_back(357);
  vals.push_back(375);
  vals.push_back(537);
  vals.push_back(573);
  vals.push_back(735);
  vals.push_back(753);
  
  ll tens = 1000;
  while(tens<=10000000000){
    ll tmp;
    ll size = vals.size();
    for(int i=0;i<size;i++){
      ll v = vals[i];
      for(ll i=1;i<=tens;i*=10){
        tmp = (v/i)*(i*10) + 3*i + v%i; vals.push_back(tmp);
        tmp = (v/i)*(i*10) + 5*i + v%i; vals.push_back(tmp);
        tmp = (v/i)*(i*10) + 7*i + v%i; vals.push_back(tmp);
        if(v/i==0)break;
      }
    }
    tens *= 10;
    sort(vals.begin(),vals.end());
    vals.erase(unique(vals.begin(),vals.end()),vals.end());
    
    /*
    cout << vals.size() << endl;
    for(auto a:vals){
      cout << a << " ";
    }
    cout << endl;
    */
 }


  auto it = upper_bound(vals.begin(),vals.end(),n);
  cout << it-vals.begin() << endl;
  
  return 0;
}



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

char ary[100010];
int main(){
	cin>>ary;
	int N=strlen(ary);
	int cnt=0;
	for(int i=0;i<N;i++){
		if(ary[i]=='p') cnt++;
	}
	cout<<(N/2)-cnt<<endl;
	return 0;
}



Measured memory_bytes: 384
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int Y = sc.nextInt();
        int res10000 = -1;
        int res5000 = -1;
        int res1000 = -1;

        for (int a = 0; a <= N; a++ ) {
            for (int b = 0; b + a <= N; b++) {
                int c = N - a - b;
                int total = 10000 * a + 5000 * b + 1000 * c;
                if (total == Y) {
                    res10000 = a;
                    res5000 = b;
                    res1000 = c;
                }
            }
        }
        
        System.out.println(res10000 + " " + res5000 + " " + res1000);
    }
}

Measured memory_bytes: 23636
#include <bits/stdc++.h>
#define MODNum 1000000007
#define REP(type, i, a, b) for( type i = a; i < b; i++ )
typedef long long ll;

using namespace std;

int main (void) {
    ll N, M, ans;
    cin >> N >> M;
    vector<ll> P(M), Y(M);
    vector<vector<ll>> Yd(N);
    REP(ll,i,0,M){
        cin >> P.at(i) >> Y.at(i);
        Yd[P.at(i)-1].push_back(Y.at(i));
    }
    REP(ll,i,0,N) sort(Yd.at(i).begin(),Yd.at(i).end());
    REP(ll,i,0,M) printf("%012lld\n", ll(P.at(i)) * 1000000 + 
        ll(lower_bound(Yd[P.at(i)-1].begin(),Yd[P.at(i)-1].end(),Y.at(i)) - Yd[P.at(i)-1].begin() ) + 1 );
    return 0;
}


Measured memory_bytes: 8576
#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 DEBUG
#ifdef DEBUG
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
	template <typename Arg1>
	void __f(const char* name, Arg1&& arg1){
		cerr << name << " : " << arg1 << std::endl;
	}
	template <typename Arg1, typename... Args>
	void __f(const char* names, Arg1&& arg1, Args&&... args){
		const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
	}
#else
#define debug(...)
#endif
#define FOR(i,a,b) 	for(int i=a;i<b;++i)
#define RFOR(i,a,b) 	for(int i=a;i>=b;--i)
#define ln 		"\n"
#define mp make_pair
#define pb push_back
#define sz(a)	ll(a.size())
#define F first
#define S second
#define all(c)	c.begin(),c.end()
#define rall(c) c.rbegin(), c.rend()
#define trace(c,x) for(auto &x:c)
#define pii pair<ll,ll>
#define init(a, x) memset(a,x,sizeof(a))
typedef long long ll;
typedef long double ld;
typedef	priority_queue<pii,std::vector<pii>,greater<pii> > revpr;

typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> pbds;
// ordered_set X
//K-th smallest
//*X.find_by_order(k-1)
//NO OF ELEMENTS < A
//X.order_of_key(A)
const int L=1e6+7;
std::vector<int> v[L];
int visited[L], dp[L];
int dfs(int vertex)
{
	if(visited[vertex])return dp[vertex];
	visited[vertex] = 1;
	trace(v[vertex], x)
	{
		dp[vertex] = max(dp[vertex], 1 + dfs(x));
	}
	return dp[vertex];
}
void fff()
{
	int n, m, x, y;
	cin >> n >> m;
	FOR(i,0,m)
	{
		cin >> x >> y;
		v[x].pb(y);
	}
	int ans = 0;
	FOR(i,1,n+1)
	{
		ans = max(ans, dfs(i));
	}
	cout<<ans<<ln;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	//int t;cin >> t;while(t--)
	fff();
	return 0;
}

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

using namespace std;

struct node
{
    long long l,r;
} p[100005];

bool cmp(node &a,node &b)
{
    if(a.l==b.l)
        return a.r<b.r;
    return a.l<b.l;
}

int main()
{
    int N,i,X,L,ans=0,j;
    cin>>N;
    for(i=0; i<N; i++)
    {
        scanf("%d %d",&X,&L);
        p[i].l=X-L;
        p[i].r=X+L;
    }
    sort(p,p+N,cmp);
    j=0;
    for(i=1; i<N; i++)
    {
        if(p[j].r<=p[i].l)
            j=i;
        else
        {
            if(p[i].r<p[j].r)
                j=i;
            ans++;
        }
    }
    cout<<N-ans<<endl;
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const int MOD =1e9+7;
using ll=long long;
using Graph = vector<vector<int>>;

int main() {
    vector<ll> num(100001);
    int n;
    cin >> n;
    ll sum = 0;
    rep(i,n){
        int a;
        cin >> a;
        num[a]++;
        sum += a;
    }
    int q;
    cin >> q;
    vector<ll> ans;
    rep(i,q){
        int b, c;
        cin >> b >> c;
        sum -= num[b]*b;
        sum += num[b]*c;
        num[c] += num[b];
        num[b] = 0;
        
        ans.push_back(sum);
    }

    for(ll n:ans){
        cout << n << endl;
    }
}

Measured memory_bytes: 5112
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys
import math

tf = True
for s in sys.stdin:
  if tf:
    a = map(int,s.split())
    tf = False
    continue
  else:
    b = map(int,s.split())
    tf = True
  print sum([ 1 for i in range(4) if a[i]==b[i] ]),
  print sum([ 1 for i in range(4) for j in range(4) if i != j and a[i] == b[j] ])

Measured memory_bytes: 4344
import "dart:io";
 
void main(List<String> args) {
  int k = int.parse(stdin.readLineSync());
  List<List<int>> gcds = [];
  int sum = 0;

  for (int i1 = 1; i1 <= k; i1++) {
    for (int i2 = 1; i2 <= k; i2++) {
      for (int i3 = 1; i3 <= k; i3++) {
        sum += gcd([i1, i2, i3]);
      }
    }
  }

  print(sum);
}

int gcd (List<int> nums) {
  if (nums.contains(1)) {
    return 1;
  }

  int tmp = nums[0];

  for (int i = 1; i < nums.length; i++) {
    tmp = tmp.gcd(nums[i]);
  }

  return tmp;
}

Measured memory_bytes: 17172
#include <bits/stdc++.h>
using namespace std;
#define ALL(obj) obj.begin(),obj.end()
#define pb(obj) push_back(obj)
#define REP(i,N) for(int i=0;i<N;i++)
typedef long long ll;
const ll MOD=1000000007;
int main(){
	cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin>>N;
    vector<int>H(N);
    REP(i,N){
        cin>>H[i];
    }
    int count=0;
    int sub=0;
    REP(i,N-1){
        if(H[i+1]<=H[i]){
            count++;
        }
        else{
            sub=max(count,sub);
            count=0;
        }

    }
    sub=max(count,sub);
    cout<<sub<<endl;
}

Measured memory_bytes: 768
##Just for prctice
n=int(input())

A=[int(i) for i in input().split()]

A.sort()
A.reverse()
a=0
b=0
for i in range(n):
    if i%2==0:
        a+=A[i]
    else:
        b+=A[i]

print(a-b)

"""
2
3 1

2

3
2 7 4

5

4
20 18 2 18

18
"""




Measured memory_bytes: 3060
N, K = map(int, input().split(' '))
A = map(int, input().split(' '))
bucket = {}

for i in A:
    if i not in bucket.keys():
        bucket[i] = 1
    else:
        bucket[i] += 1

if len(bucket.keys()) <= K:
    print('0')
else:
    turn_over = 0
    turn_num = len(bucket.keys())
    for i in sorted(bucket.values()):
        turn_over += i
        turn_num -= 1
        if turn_num <= K:
            print(turn_over)
            break


Measured memory_bytes: 41216
#include <bits/stdc++.h>
using intl = long long;
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define repd(i, n) for(intl i = (intl)((n) - 1); i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define INF = 1e9;
#define debug(x) cout << #x << ":" << x << endl
using namespace std;
int main(){
    intl a;
    cin >> a;
    cout << (a+1)/2 << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)
#define FORR(I,A,B) for(ll I = ll((B)-1); I >= ll(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=ll(1e16)+ll(7);
const ll MOD=1000000007LL;
#define out(a) cout<<fixed<<setprecision((a))
//tie(a,b,c) = make_tuple(10,9,87);
#define pop(a) __builtin_popcount((a))
ll keta(ll a){ll r=0;while(a){a/=10;r++;}return r;}


ll calc(ll a,ll b,ll p){//a^(b) mod p   
  if(b==0)return 1;
  ll y = calc(a,b/2,p);y=(y*y)%p;
  if(b & 1) y = (y * a) % p;
  return y;
}

int main(){
  ll N,P,ans=0;
  cin >> N >> P;
  string S;
  cin >> S;


  if(P==5){
    FOR(i,0,N){
      if(S[i]=='5' || S[i]=='0'){
        ans += i+1;
      }
    }
    cout << ans << endl;
    return 0;
  }
  if(P==2){
    FOR(i,0,N){
      if((S[i]-'0')%2==0){
        ans += i+1;
      }
    }
    cout << ans << endl;
    return 0;
  }


  map<ll,ll> ma;
  ll x = 0;

  //ma[0] = 1;
  FOR(i,0,N){
    x *= 10;
    x += S[i]-'0';
    x %= P;
    ll k = x*calc(calc(10,i,P),P-2,P)%P;
    ans += ma[k];
    ma[k]++;
    if(x==0)ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 1028
//**PEACE BE UPON YOU**
// AZMAYEN FAYEK SABIL
// IUT CSE SWE-19

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

#include <cmath>
#include <string>
#include <algorithm>
using namespace std;


int main()

{
    float r;
    cin>>r;

    float ans;

    ans=(float) 2*3.14159*r;

    cout<<fixed<<setprecision(6)<<ans;


    return 0;
}


Measured memory_bytes: 3792
/*	
TELL YOUR CODE TO START BELIEVING IN GOD!!
THEY HATE US BECAUSE THEY AIN'T US
	ARIJIT SUR 
	@duke_knight
	@surcode
	IIT ISM 
 WORK SO HARD THAT YOUR IDOL BECOMES YOUR COMPETITOR 
 */
#include<bits/stdc++.h>
#define SIZE 100008
#define mod (ll)(1e9+7)
#define INF 0x3f3f3f3f
#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)
#define abs(a) (a>0?a:-a)
#define all(a) a.begin(),a.end()
#define pb push_back
#define pi pair<int,int>
#define sort(a) sort(all(a))
#define reverse(a) reverse(all(a))
#define input(a) {for(int i1=0;i1<a.size();i1++) cin>>a[i1];}
#define display(a) {for(int i1=0;i1<a.size();i1++) cout<<a[i1]<<" "; cout<<endl;}
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
typedef long long ll;
#define ff q.front().first
#define fs q.front().second
int dp[SIZE];
int dfs(int i, vector<int> adj[]){
    if(dp[i]==-1){
        for(int j=0;j<adj[i].size();j++) 
            dp[i] = max(dp[i],1+dfs(adj[i][j],adj));
    }
    return dp[i];
}
void solve(){
	int n,u,v,m;
    cin>>n>>m;  int maxdist = 0;
    vector<int> adj[n+1];
    while(m--){
        cin>>u>>v;
        adj[u].pb(v);
    }
    for(int i=1;i<=n;i++){
        maxdist = max(maxdist,dfs(i,adj));
    }
    printf("%d\n", 1+maxdist);
    return;
    bool visited[n+1] = {false};
    queue<pi> q;
    for(int i=1;i<=n;i++){
        if(!visited[i]){
            q.push({i,1});
            while(!q.empty()){
                visited[ff] = 1;
                maxdist = max(maxdist,fs);
                for(int i=0;i<adj[ff].size();i++)
                    q.push({adj[ff][i],fs+1});
                q.pop();
            }
        }
    }
    printf("%d\n", maxdist-1);
}
int main()
{
    IOS
    int t=1;
    //cin>>t;
    while(t--){
        memset(dp,-1,sizeof(dp));
    	solve();
    }
    return 0;
}

Measured memory_bytes: 12176
import sys
#input = sys.stdin.readline

from math import factorial

def main():
    s = input()
    sl = len(s)
    s_r = s[(sl//2)+1:]
    if s[:(sl//2)] != s_r[::-1]:
        print('No')
        exit()
    s1 = s[:((sl-1)//2)]
    s1l = len(s1)
    s1_f = s1[:(s1l//2)]
    if s1l %2 ==1:
        s1l += 1
    s1_r = s1[(s1l//2):]
    if s1_f != s1_r[::-1]:
        print('No')
        exit()

    s2 = s[((sl+3)//2)-1:]
    s1l = len(s1)
    s2_f = s2[:(s1l//2)]
    if s1l %2 ==1:
        s1l += 1
    s2_r = s2[(s1l//2):]
    if s2_f != s2_r[::-1]:
        print('No')
        exit()
    print('Yes')

if __name__ == '__main__':
    main()


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

int main(){
  string S;
  cin >> S;

  if(S == "Sunny"){
    cout << "Cloudy" << endl;
  } else if (S == "Cloudy"){
    cout << "Rainy" << endl;
  } else if (S == "Rainy"){
    cout << "Sunny" << endl;
  }
}

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

using namespace std;

int main()
{
	long long n;
	cin>>n;

	vector<long long>a(n+1,0);

	for(long long i=1;i<=n;i++)
	{
		for(int j=i;j<=n;j+=i)
			a[j]++;
	}

	long long total=0;

	for(long long i=1;i<=n;i++)
		total+=(a[i]*i);

	cout<<total;

	return 0;
}

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

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

  int n, k;
  cin >> n >> k;

  ll ans = 0;
  FOR(i, 1, n+1) {
    ans += (n+1)/i * max((ll)0, i-k) + max((ll)0, (n+1)%i-k);
  }
  if (k == 0) ans -= n;
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long ;
#define MOD (ll) (1e9+7)
ll mult(ll a,ll b)
{
	return ((a%MOD)*(b%MOD))%MOD;
}
ll add(ll a,ll b)
{
	a+=MOD;
	b+=MOD;
	return (a+b)%MOD;
}
ll pw(ll a,ll b)
{
	 ll res = 1;
	 while(b)
	 {
	 	 if(b%2==1)
	 	 {
	 	 	 res = mult(res,a);
	 	 }
	 	 b = b/2;
	 	 a = mult(a,a);
	 }
	 return res;
}
int main()
{
	ll n;
	cin>>n;
	ll re = pw(10,n);
	re = add(re,-2*pw(9,n));
	re = add(re,pw(8,n));
	cout<<re<<"\n";
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = int64_t;
using P = pair<ll, ll>;
template <class T>
using V = vector<T>;

int main() {
  int n;
  cin >> n;
  V<ll> a(n);
  rep(i, n) cin >> a[i];

  sort(a.begin(), a.end());

  ll r = a.back();
  double m = r / 2.0;
  ll l = a[0];
  rep(i, n) {
    if (abs(m - a[i]) < abs(m - l)) {
      l = a[i];
    }
  }
  cout << r << " " << l << endl;
}


Measured memory_bytes: 4040
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (int)(k); i < (int)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1e9 + 7;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<class T>
istream& operator >> (istream& is, vector<T>& v)
{
	for (auto &i : v) is >> i;
	return is;
}
template<class T>
ostream& operator<<(ostream& os, vector<T>& v)
{
	const string delimiter = "\n";
	REP(i, v.size())
	{
		os << v[i];
		if (i != v.size() - 1) os << delimiter;
	}
	return os;
}
/*--------------------template--------------------*/


const int N = 1111111;
bool prime[N + 1];
vector<int> primes;

void hurui()
{
	memset(prime, true, sizeof(prime));
	prime[0] = prime[1] = false;
	for (int i = 2; i*i < N; i++)
	{
		if (!prime[i]) continue;
		for (int j = i; i*j < N; j++)
		{
			prime[i*j] = false;
		}
	}
	REP(i, N + 1)
	{
		if (prime[i])
		{
			primes.push_back(i);
		}
	}
}

ll pow(ll x, ll n, ll mod)
{
	ll res = 1;
	while (n > 0)
	{
		if (n & 1) res = res * x % mod;
		x = x*x%mod;
		n >>= 1;
	}
	return res;
}

int n;
vi q;
ll dp[111111];

ll solve(int p)
{
	if (dp[p] >= 0) return dp[p];
	if (p == n) return 0;
	if (p == n - 1)
	{
		if (prime[q[p]])	return 1;
		else return 0;
	}
	ll res = 0;
	if (prime[q[p + 1]] && q[p + 1] > q[p])
	{
		res += solve(p + 1);
	}
	if (p + 2 < n && prime[q[p + 2]] && q[p + 2] > q[p])
	{
		res += solve(p + 2);
	}
	if (p + 2 == n)
	{
		res += 1;
	}
	return dp[p] = res % MOD;
}

int main()
{
	cin.sync_with_stdio(false); cout << fixed << setprecision(10);
	MS(dp, -1);
	hurui();
	cin >> n;
	q.resize(n);
	cin >> q;
	if(prime[q[0]]) cout << solve(0) << endl;
	else cout << 0 << endl;
	return 0;
}


Measured memory_bytes: 9292
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp setprecision
#define pb(x) push_back(x)
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ld, ld> pdd;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = 1e8;
const ll INF = 1e16;
const string alpha = "abcdefghijklmnopqrstuvwxyz";

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

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <queue>
#include <map>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
int n, k;
ll ans;

ll trip(ll a) { return 1ll * a * a * a; }

int main() {
	cin >> n >> k;
	ll ans1 = n / k;
	ll ans2 = 0;
	if(!(k & 1)) ans2 = n / (k / 2) - n / k;
	ans = trip(ans1) + trip(ans2);
	cout << ans << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;

namespace AtCoder.C
{
    public class Program
    {
        public static void Main() { var r = GetResult(); Debug.WriteLine(r); Console.Write(r); }

        private static object GetResult()
        {
            var N = ReadLong();
            var A = ReadLongs();
            var dic = new Dictionary<long, long>();
            foreach (var item in A)
            {
                if (!dic.ContainsKey(item))
                {
                    dic.Add(item, 0);
                }
                dic[item]++;
            }

            var pair = new List<long>();
            foreach (var item in dic)
            {
                for (int i = 0; i < item.Value / 2; i++)
                {
                    pair.Add(item.Key);
                }
            }

            if (pair.Count < 2) return 0;
            pair = pair.OrderByDescending(x => x).ToList();
            return pair[0] * pair[1];
        }

        #region Console.Read

        public static string ReadText() { return Console.ReadLine(); }
        public static List<string> ReadTexts() { return Console.ReadLine().Split(' ').ToList(); }
        public static long ReadLong() { return long.Parse(Console.ReadLine()); }
        public static (long, long) Read2Longs() { var ls = ReadLongs(); return (ls[0], ls[1]); }
        public static (long, long, long) Read3Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2]); }
        public static (long, long, long, long) Read4Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3]); }
        public static (long, long, long, long, long) Read5Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3], ls[4]); }
        public static List<long> ReadLongs() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList(); }

        #endregion
    }
}


Measured memory_bytes: 43552
import math;
N,x = map(int, raw_input().split());
a = map(int, raw_input().split());
cnt = 0;
for i in range(N):
    if(a[i] > x):
        cnt += a[i] - x;
        a[i] = x;
    if(i > 0 and a[i] + a[i-1] > x):
        cnt += a[i] + a[i-1] - x;
        a[i] = x - a[i-1];
print(cnt);

Measured memory_bytes: 11340
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

int dx[] = {-1,-1,-1, 0, 0, 0, 1, 1, 1};
int dy[] = {-1, 0, 1,-1, 0, 1,-1, 0, 1};
int main(void){
  SPEEDUP
  cout << setprecision(15);
  ll H,W,N;cin >> H >> W >> N;
  map<PII,int> mp;
  rep(i,N){
    int x,y;cin >> y >> x;
    --x;--y;
    rep(j,9){
      int nx = x+dx[j],ny = y+dy[j];
      if(mp.count(PII(nx,ny)))++mp[PII(nx,ny)];
      else mp[PII(nx,ny)] = 1;
    }
  }
  vector<ll> v(10,0);
  ll sum = 0;
  for(const pair<PII,int> &p : mp){
    //cout << p.first.first SP p.first.second SP p.second << endl;
    if(p.first.first>=1 && p.first.first < W-1
        && p.first.second >=1 && p.first.second < H-1){
      ++v[p.second];
      ++sum;
    }
  }
  v[0] = (H-2)*(W-2) - sum;
  rep(i,10) cout << v[i] << endl;
  return 0;
}


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

using namespace std;


int main()
{
    int N[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int K;
	cin >> K;

    cout << N[K-1] << endl;  

}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<vector>
#include<iostream>
using namespace std;
int n;
int h,a[100010];
int main()
{
	cin>>h>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		h-=a[i];
	}
	if(h<=0)
	{
		printf("Yes\n");
	}
	else
	{
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
using namespace std;
long long comb[51][51];
long long combination(int n, int r){
  if(!r)comb[n][r] = 1;
  if(r==1)comb[n][r] = n;
  if(n==r)comb[n][r] = 1;
  if(comb[n][r]){return comb[n][r];}
  comb[n][r]=combination(n-1,r-1)+combination(n-1,r);
  return comb[n][r];
}
int main(){
  int n,A,B;cin>>n>>A>>B;
  vector<long long> a(n);
  for(int i = 0; n > i; i++)cin>>a[i];
  sort(a.begin(),a.end(),greater<long long>());
  double ans = 0.0;
  for(int i = 0; A > i; i++)ans += (double)a[i]/A;
  cout << fixed << setprecision(10) << ans << endl;
  int i = A-1;
  for(; 0 <= i && a[i]==a[A]; i--);i++;
  int j = A;
  for(; n > j && a[j]==a[A]; j++);j--;
  if(A==n){
    cout << 1 << endl;
    return 0;
  }
  if(a[0] == a[A]){
    long long kos = 0LL;
    for(int z = A-i; min(B,j-i+1) >= z;z++){
      //z = (0,A-i) ~ ()
      //cout << z << endl;
      
      kos += combination(j-i+1,z);
    }
    cout << kos << endl;
  }else{
    cout << combination(j-i+1,A-i) << endl;
  }

}

Measured memory_bytes: 256
/*
ID: sstfmsc1
TASK: milk2
LANG: C++
*/
#include <bits/stdc++.h>
 
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define forin(i, n) for ( int i = 0; i < (int)n; ++i )
#define MAXN 5
#define MAXS 10000
#define INF 1000000
typedef long long ll;
const char nl = '\n';
ll MOD = (ll)(1e9 + 7);
int modk( int k, int x ) { return ( ( x % k ) + k ) % k; }

void solve()
{
    int n; cin >> n;

	vector<int> a(n);

	forin(i, n) cin >> a[i];

	int ans = 0;

	forin(i, n - 2)
	{
		for ( int j = i+1; j < ( n - 1 ); ++j )
		{
			for ( int k = j+1; k < n; ++k )
			{
				int suma = a[i] + a[j] + a[k];
				int maxi = max(a[i], max(a[j], a[k]));
				if ( a[i] != a[j] && a[i] != a[k] && a[j] != a[k]
					&& ( suma - maxi ) > maxi )
				{
					//cout << i+1 << ' ' << j+1 << ' ' << k+1 << nl;
					++ans;
				}
			}
		}
	}

	cout << ans << nl;
    return;
}
 
int main()
{
    //freopen("input.in", "r", stdin);
    //freopen("milk2.out", "w", stdout);
    //IOS
	//int q;
    //while( q-- )
    solve();
        
    return 0;
}

Measured memory_bytes: 3600
#include <iostream>
#include <cstdio>
#include <vector>
#include <stack>
#include <set>
#include <map>
#include <math.h>
#include <queue>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define Sort(Array) sort(Array.begin(), Array.end())
#define rev(a) reverse(a.begin(), a.end())
#define out(ans) cout << ans << endl;
const int MOD = 1000000007;
const int INF = INT_MAX;





int main() {

    int n;
    cin >> n;
    string s;
    cin >> s;

    int ans = n;
    int left = 0;
    int right = 0;
    rep(i,n) {
        if (s[i] == 'E') ++right;
    }
    for (int leader = 0; leader < n; ++leader) {
        if (1 <= leader && s[leader-1] == 'W') ++left;
        if (s[leader] == 'E') --right;
        ans = min(ans, left + right);
    }


    cout << ans << endl;



    return 0;
}




//              g++ -std=c++1z






Measured memory_bytes: 832
n = int(input())
a = list(map(int,input().split()))

index = 1
cnt = 0
for i in range(len(a)):
  if a[i] != index:
    cnt +=1
  else:
    index +=1
    
if min(a)!=1:
  print("-1")
else:
  print(cnt)

Measured memory_bytes: 26140
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <limits>

#define ll long long

using namespace std;

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

	int n; cin >> n;
	vector<ll>v(n);
	vector<ll>sum1(n);
	vector<ll>sum2(n);

	for (int i = 0; i < n; i++) {
		cin >> v[i];
		v[i] -= i + 1;
	}

	sort(v.begin(), v.end());

	for (int i = 0; i < n; i++) {
		sum1[i] += v[i];
		if (i > 0) sum1[i] += sum1[i - 1];
	}

	for (int i = n - 1 ; i >= 0 ; i--) {
		sum2[i] += v[i];
		if (i < n - 1) sum2[i] += sum2[i + 1];
	}

	ll ans = numeric_limits<ll>::max();

	for (int i = 0; i < n - 1; i++) {
		ll l = (i + 1), r = n - (i + 1);
		ll val = v[i] * l - sum1[i] + sum2[i + 1] - v[i] * r;
		ans = min(ans, val);
	}

	ll val = v[n - 1] * n - sum1[n - 1];
	ans = min(ans, val);

	cout << ans;

}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i < (n+1); ++i)
using namespace std;
using ll = long long;
const ll INF = +10010010000;

typedef pair<ll,ll> P;
const ll MO = 1000000007;

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

int gcd(vector<int> a){
    int ans = a[0];
    rrep(i,a.size()-1){
        ans = gcd(ans,a[i]);
    }
    return ans;
}

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n)cin >> a[i];
    cout << gcd(a) << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <climits>

using namespace std;

struct edge { int cap, to, rev; };

int dfs(vector<vector<edge>> &A, vector<bool> &U, int s, int t, int f)
{
        if (s == t)
                return f;
        U[s] = true;
        for (auto &e: A[s]) {
                if (!e.cap || U[e.to])
                        continue;
                int d = dfs(A, U, e.to, t, min(e.cap, f));
                if (d > 0) {
                        e.cap -= d;
                        A[e.to][e.rev].cap += d;
                        return d;
                }
        }
        return 0;
}

int main(int argc, char **argv)
{
        int V, E;
        cin >> V >> E;
        vector<vector<edge>> A(V);
        for (int i = 0; i < E; i++) {
                int u, v, c;
                cin >> u >> v >> c;
                A[u].push_back({c, v, (int)A[v].size()});
                A[v].push_back({0, u, (int)A[u].size()-1});
        }
        int sum = 0;
        while (true) {
                vector<bool> U(V);
                int d = dfs(A, U, 0, V-1, INT_MAX);
                if (!d)
                        break;
                sum += d;
        }
        cout << sum << endl;
        return 0;
}

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

namespace Atcoder
{
    public class Program
    {
        static void Main(string[] args)
        {
            var r1 = ReadSplit();
            var N = r1[0].ToInt32();
            var M = r1[1].ToInt32();
            var w = new List<int>();
            var r2 = ReadSplit();
            for (int i = 0; i < M; i++)
            {
                w.Add(r2[i].ToInt32());
            }
            var sum = w.Sum();
            if (N < sum)
            {
                WriteRead("-1");
                return;
            }
            WriteRead(N - sum);
        }

        public static string Read()
        {
            return Console.ReadLine();
        }

        public static string[] ReadSplit()
        {
            return Console.ReadLine().Split(' ');
        }

        public static void WriteRead(object str)
        {
            Console.WriteLine(str);
            Read();
        }

        public static void Write(object str)
        {
            Console.WriteLine(str);
        }
    }
}


public static class Extentions
{
    public static int ToInt32(this object obj)
    {
        return int.Parse(obj.ToString());
    }

    public static long ToInt64(this object obj)
    {
        return long.Parse(obj.ToString());
    }

    public static decimal ToDecimal(this object obj)
    {
        return decimal.Parse(obj.ToString());
    }

    public static double ToDouble(this object obj)
    {
        return double.Parse(obj.ToString());
    }

    public static T2 GetValueZero<T1, T2>(this Dictionary<T1, T2> d, T1 key) where T2 : struct
    {
        T2 value;
        if (d.TryGetValue(key, out value))


        {
            return value;
        }
        return new T2();
    }
}



Measured memory_bytes: 20208
import sys
import collections
N = int(input())
Ans = 0

if N <= 1:
  print(Ans)
  sys.exit()

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

c = collections.Counter(prime_factorize(N))
A = list(c.values())
p = len(A)
#print(A)
#print(p)

Ans = Ans + p
now = 0

for r in range(p):
  now = int(A[r]) - 1
  loop = 2

  for q in range(1000):
    now = now - loop
    if now >= 0:
      Ans = Ans + 1
      loop = loop + 1
    else:
      break

print(Ans)

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

signed main(){
    int n;
    cin >> n;
    vector<int> v(n);
    for (int i = 0; i < n; i++)
    {
        cin >> v[i];
    }
    int count = 0;
    for (int i = 1; i < n - 1; i++)
    {
        if (v[i-1] < v[i] && v[i] < v[i+1])
            count++;
        else if (v[i+1] < v[i] && v[i] < v[i-1])
            count++;
    }
    cout << count << "\n";
}

Measured memory_bytes: 256