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

// long long int型の整数の桁数を返す。入力は19桁まで
long long int digit(long long int num) {
    long long int nine = 0;
    long long int cnt = 0;
    while (1) {
        nine = nine*10 + 9;
        cnt++;
        if (cnt == 20) return -1;
        if (num - nine < 0) return cnt;
    }
}

int main(void) {
    long long int n, ans=0, keta;
    scanf("%lld", &n);
    if (n%2==1) {
        ans=0;
    } else {
        keta = digit(n);
        long long int i, lower, upper;
        /*for (i = 1; i < 10; i++) {
            lower = (long long int)pow(10, keta-1)*i;
            upper = (long long int)pow(10, keta-1)*(i+1);
            if (lower <= n < upper) {
                break;
            }
        }*/
        long long int ten=1, five=2;
        /*while (1) {
            ten*=10;
            if (n < ten) {
                break;
            }
            ans += (n - n%ten)/ten;
        }*/
        while (1) {
            five*=5;
            if (n < five) {
                break;
            }
            ans += (n - n%five)/five;
        }
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    string a,b;
    cin>>a>>b;
    int i,j;
    cin>>i>>j;
    string f;
    cin>>f;
    if(f==a)
    {
        cout<<(i-1)<<" "<<j<<endl;
    }
    else
    {
        cout<<(i)<<" "<<(j-1)<<endl;
    }
}

Measured memory_bytes: 256
import sys
n = int(input())
lst = [list(map(int, input().split())) for i in range(n)]
lst.sort(key=lambda x:x[1])

time = 0
for i in range(n):
  time += lst[i][0]
  if time > lst[i][1]:
    print("No")
    sys.exit()
print("Yes")

Measured memory_bytes: 53728
N, K = map(int, input().split())
A = sorted([int(a) for a in input().split()], key = lambda x: -abs(x))
# print("A =", A)
P = 10 ** 9 + 7
m = 0
ans = 1
lp = 0
lm = 0
np = 0
nm = 0
for a in A[:K]:
    if a > 0:
        lp = a
        ans = ans * a % P
    elif a < 0:
        lm = a
        m ^= 1
        ans = ans * a % P
    else:
        print(0)
        exit()

if m == 0:
    print(ans)
    exit()

for a in A[K:]:
    if a > 0:
        np = a
        break
for a in A[K:]:
    if a < 0:
        nm = a
        break

if lp and nm and lm and np:
    if lp * np > lm * nm:
        print(ans * pow(lm, P-2, P) * np % P)
    else:
        print(ans * pow(lp, P-2, P) * nm % P)
elif lp and nm:
    print(ans * pow(lp, P-2, P) * nm % P)
elif lm and np:
    print(ans * pow(lm, P-2, P) * np % P)
elif A[-1] == 0:
    print(0)
else:
    A = A[::-1][:K]
    ans = 1
    for a in A:
        ans = ans * a % P
    print(ans)

Measured memory_bytes: 31872
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <tuple>
#include <stack>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define print(s) cout << s << endl
using namespace std;
const int INF = 1e9;
typedef long long lint;
const lint LINF = 1e18;
const lint MOD = 1e9 + 7;
// const lint MOD = 998244353;
int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}
char upper(char c){
	return c-0x20;
}
char lower(char c){
	return c+0x20;
}

int gcd(int x, int y) {
  if (y == 0) return x;
  return gcd(y, x%y);
}
 
int main() {
  int n;
  cin>>n;
  vector<int> a(n);
  rep(i,n) cin>>a[i];
  vector<int> l(n), r(n);
  rep(i,n-1) l[i+1] = gcd(l[i], a[i]);
  for (int i = n-1; i >= 1; --i) r[i-1] = gcd(r[i], a[i]);
  int ans = 1;
  rep(i,n) ans = max(ans, gcd(l[i],r[i]));
  cout<<ans<<endl;
  return 0;
}


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

#define fastio 			ios::sync_with_stdio(0);	cin.tie(0); cout.tie(0);  cout<<fixed;  cout<<setprecision(12);
#define randomINT 		mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define	newl 			cout<<"\n"
#define DISP(as)		for(auto it : as) cout<<it<<" ";newl;
#define all(x)         	(x).begin(),(x).end()
#define mset(x,val)    	memset(x,val,sizeof(x))
#define newl           	cout<<"\n"
#define pb             	push_back
#define mp             	make_pair
#define f 				first
#define s 				second
#define dline          cerr<<"///REACHED///\n";
#define deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';

typedef long long 				ll;
typedef long double 			ld;
typedef vector<ll> 				vll;
typedef pair<ll , ll> 			pll;
typedef pair<ld, ld> 			pld;
typedef unordered_map<ll, ll> 	um;
typedef vector<pll> 			vpll;

const ll 	MAX5 	= 	1e+5 + 7;
const ll 	MAX7 	= 	1e+7 + 7;
const ll 	MAXN 	= 	4 * MAX5;
const ll   	INF   	=  	0x7f7f7f7f7f7f7f7f;
const int  	INFi 	=  	0x7f7f7f7f;
const ll 	MOD		=  	1e+9 + 7;
const int N = 1e4;

ll vis[N]; vll adj[N];

// <------------- Declare Variables Here ------------> //

ll t = 1;
ll n, m, s, cnt = 1, u, v, k;

// <------------- Implement Functions Here ----------> //

ll dp[3000][3000];

ll add(ll a,ll b,ll c) {
	return ((a + b)%MOD + c)%MOD;
}

// <------------- Start of main() -------------------> //

void MAIN() {
	cin >> n >> m;
	vll a(n),b(m);
	for(ll i=0;i<n;i++) cin>>a[i];
	for(ll i=0;i<m;i++) cin>>b[i];
	//sort(all(a));
	//sort(all(b));

	for(ll i=1;i<=n;i++) {
		for(ll j=1;j<=m;j++) {
			if(a[i-1] == b[j-1]) {
				dp[i][j] = add(dp[i-1][j] , dp[i][j-1] , 1);
			}
			else {
				dp[i][j] = add(dp[i-1][j] , dp[i][j-1] , -dp[i-1][j-1] + MOD);
			}
		}
	}

	/*for(ll i=0;i<=n;i++) {
		for(ll j=0;j<=m;j++) {
			cout<<dp[i][j]<<" ";
		}
		newl;
	}
	newl;*/

	cout<<(dp[n][m] + 1)%MOD;
}

int main() {
	fastio; randomINT;
	//cin >> t;
	while (t--) {
		MAIN();
	}
	return 0;
}


Measured memory_bytes: 43072
#include "bits/stdc++.h"
using namespace std;
 
////////////// Prewritten code follows. Look down for solution. ////////////////

#define fs first
#define sc second
#define pb push_back
#define mp(a, b) make_pair(a, b)
#define len(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long long ll;
typedef pair<ll, ll> pll;

template<typename T>
const T INF = (is_same<T, int>::value ? 1e9 : 1e18);
template<typename T>
inline T mod(T n, T mod){ T res = n%mod; if(res < 0) res += mod; return res; }

/// command for char arrays with spaces -> scanf(" %[^\n]", text);
 
////////////////////////// Solution starts below. //////////////////////////////

int main(){
	fastio;
	int n, m;
	cin >> n >> m;
	if(n == m) cout << "Yes\n";
	else cout << "No\n";
	return 0;
}

Measured memory_bytes: 256
nk = input().split()
n = int(nk[0])
k = int(nk[1])

cnt = 0
for b in range(n):
    if b+1 > k:
        cnt += (n // (b+1)) * (b+1 - k)
    if n % (b+1) >= max(k,1):
        if k > 0:
            cnt += n % (b+1) - k + 1
        else:
            cnt += n % (b+1)

        

print(cnt)

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <map>
#include <numeric>
#include <random>

using namespace std;

const int MOD = 1000000007;
typedef long long ll;

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N,T,t,tmp;
  vector<int> c;
  cin>>N>>T;
  for(int i=0;i<N;i++){
    cin>>tmp>>t;
    if(t<=T)c.push_back(tmp);
  }
  if(c.size()>0){
    sort(c.begin(),c.end());
    cout<<c[0]<<endl;
  }else{
    cout<<"TLE"<<endl;
  }
}


Measured memory_bytes: 256
D = list(reversed(sorted([int(input()) for _ in range(5)])))
max_rest = 0
max_rest_idx = 0
time = 0
for i in range(5):
    if D[i]%10 == 0:
        continue
    if max_rest <= (10 - D[i]%10):
        max_rest = (10 - D[i]%10)
        max_rest_idx = i
for i in range(5):
    if i == max_rest_idx:
        continue
    if D[i]%10 == 0:
        time += D[i]
    else:
        time += (D[i] + (10 - D[i]%10))
time = time + D[max_rest_idx]
print(time)

Measured memory_bytes: 3064
/*                        ______
 _______   /\     |``\   |        |  /
    |     /  \    |__/   |____    |/
    |    / _ _\   |  \   |        |\
    |   /      \  |   \  |______  |  \

            Dept. of CSE
        Comilla  University

*/
#include<bits/stdc++.h>
#define pi 2*acos(0.0)
#define ll long long
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define Node struct node
#define spc " "
#define  E  2.71828182845904523536
#define pb push_back
#define pp pop_back
#define valid(nx,ny) nx>=0 && nx<n && ny>=0 && ny<m
#define ee endl
#define pii pair<int,int>
#define infinity 10000000000000000
#define mod 1000000007
int fx[]={0,0,+1,-1};
int fy[]={+1,-1,0,0};

using namespace std;
///check n=1;
///check corner case;
const int maX=1e5+1;
vector<ll>Graph[maX],cost[maX];
ll visit[maX];
ll x[10];
ll y[10];

int main()
{
   ll n,i,j,cc=0,x;
   cin>>n>>x;
   ll ara[n+1];
   ara[0]=0;
    for(i=0;i<n;i++){
        cin>>j;
        ara[i+1]=ara[i]+j;
    }
    for(i=0;i<=n;i++){
        if(ara[i]<=x)cc++;
        else break;
    }
    cout<<cc<<endl;
return 0;
}


Measured memory_bytes: 4992
"XXOR"
N, K = map(int, input().split())
A = list(map(int, input().split()))
# 2進数で41桁の理想的な数字を求める
K += 1
binary_K = format(K, '041b')
ideal_x = ""
for i in reversed(range(41)):
    bit = 1 << i
    count = 0
    # 大きい桁から、bitが立っている数をカウントする
    for a in A:
        if a & bit:
            count += 1
    if count > N - count:  # 1の方が多いなら
        ideal_x += "0"
    else:
        ideal_x += "1"
# print(binary_K)
# print(ideal_x)
# binary_Kより小さい範囲で理想的なxを探す
ans = 0
for i in range(41):
    if binary_K[i] == "0":
        continue
    x = binary_K[:i] + "0" + ideal_x[i+1:]
    x = int(x, 2)
    fx = 0
    for a in A:
        fx += a ^ x
    ans = max(ans, fx)
print(ans)


Measured memory_bytes: 14620
#include<iostream>
#include<string>
#include<algorithm>

using namespace std;

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

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define ed cout<<"\n";
#define SPEED ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ll longlongint
using namespace std;
int main(){
     SPEED;
     int n;
     cin>>n;
     int t[110000],x[110000],y[110000];
     t[0]=x[0]=y[0]=0;
     rep(i,n){cin>>t[i+1]>>x[i+1]>>y[i+1];}
     bool can=true;
     rep(i,n){
         int dt=t[i+1]-t[i];
         int dist=abs(x[i+1]-x[i])+abs(y[i+1]-y[i]);
         if(dt<dist)can=false;
         if(dist%2!=dt%2)can=false;
     }
     if(can) cout<<"Yes";
     else cout<<"No";
     ed;
     return 0;
}


Measured memory_bytes: 1408
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MAXLEN 100000
void run();

int main(int argc, char const *argv[]) {
  run();
  return 0;
}

void run(){
  int n;
  int T;
  scanf("%d%d", &n, &T);
  long price[n];
  for(int i = 0; i < n; i++){
    scanf("%ld", &price[i]);
  }
  //search pointを設定
  int sp[n];
  sp[0] = 0;
  int tmin = price[0];
  for(int i = 1; i < n; i++){
    if(price[i] < tmin){
      sp[i] = i;
      tmin = price[i];
    }else{
      sp[i] = sp[i-1];
    }
  }
  int count = 0;
  int benefit = 0;
  long hp = 0;
  for(int i = n - 1; i > 0; i--){
    if(price[i] > hp){
      hp = price[i];
      long b = price[i] - price[sp[i-1]];
      if(b == benefit){
        count++;
      }else if(b > benefit){
        count = 1;
        benefit = b;
      }
    }
  }
  printf("%d\n", count);
}


Measured memory_bytes: 1280
#include <iostream>
#include <vector>
#include <cassert>

using namespace std;
typedef long long ll;

const ll MOD = 1e9 + 7;
vector<ll> fact;

void init_fact(int n) {
    fact = vector<ll>(n);
    fact[0] = 1;
    for (int i = 1; i < n; i++) fact[i] = fact[i - 1] * i % MOD;
}

ll calc_pow(ll x, ll pow) {
    if (pow == 0) return 1;
    ll a = calc_pow(x, pow / 2);
    a = a * a % MOD;
    if (pow % 2 == 1) a *= x;
    return a % MOD;
}

ll calc_div(ll a, ll b) {
    return a * calc_pow(b, MOD - 2) % MOD;
}

ll calc_comb(ll n, ll r) {
    if (n < r)return 0;
    return calc_div(fact[n], fact[r] * fact[n - r] % MOD);
}

int main() {
    init_fact(250000);

    int n, a, b, c;
    cin >> n >> a >> b >> c;

    ll diva = calc_div(a, a + b), divb = calc_div(b, a + b), divc = calc_div(100, a + b);

    ll ret = 0;
    for (int i = 0; i < n; i++) {
        ll x = calc_pow(diva, n);
        x *= calc_pow(divb, i), x %= MOD;
        ll y = calc_pow(divb, n);
        y *= calc_pow(diva, i), y %= MOD;

        ll now = x + y;
        now *= calc_comb(n + i - 1, n - 1), now %= MOD;
        now *= divc, now %= MOD;
        ret += now * (n + i) % MOD, ret %= MOD;
    }

    cout << ret << endl;
    return 0;
}

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


int main() {
	int r, d, x;
	cin >> r >> d >> x;
	for (int i = 0; i < 10; i++) {
		int y;
		y = r * x - d;
		x = y;
		cout << x << endl;
	}
	return 0;
}

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

using ll = long long;

using namespace std;

int main(){

    ll r,d,x;
	
	cin >> r >> d >> x;
	
	for (ll i=0; i<10; i++){
		x = r*x - d;
		cout << x << endl;
	}

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
                     
                    int main(void)
                    {
                       int a,b,c;
                       int x,y,z;
                       int min;
                       
                       scanf("%d", &a);
                       scanf("%d", &b);
                       scanf("%d", &c);
                       
                       x = a + b;
                       y = b + c;
                       z = c + a;
                       
                       min = x;
                       if(x>y){
                       min = y;
                        if(y>z){
                        min=z;
                        }
                       }
                       else if(x>z){
                       min = z;
                       }
                       
                       printf("%d\n", min);
                     
                       return 0;
                    }
         

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define f first
#define s second
#define pb push_back
typedef long long ll;
typedef long double ld;
using namespace std;



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

  int a, b, t;
  cin >> a >> b >> t;
  cout << (t / a) * b << endl;

  return 0;
}











Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c;
  while(cin>>a>>b>>c){
    int sum=0;
    a=a%b*10;
    while(c--){
      sum+=a/b;
      a=a%b*10;
    }
    cout<<sum<<endl;
  }
}

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

int main(int argc, char *argv[]) { ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);

  int a,b,c,d,e,k;cin>>a>>b>>c>>d>>e>>k;
  if(e-a>k)puts(":(");
  else puts("Yay!");
  
  return 0;
}


Measured memory_bytes: 3628
n, m, x = map(int,input().split())
a = []
for i in range(n):
    a.append(list(map(int,input().split())))

price = {}
for i in range(2 ** n):
    rikai = []
    total = 0
    for j in range(n):  # このループが一番のポイント
        if ((i >> j) & 1):  # 順に右にシフトさせ最下位bitのチェックを行う
            rikai.append(a[j][1:])  # フラグが立っていたら bag に果物を詰める
            total += a[j][0]  # 買い物累計額にも加算
    price[total] = rikai


# for k,v in price.items():
#     flatv = sum(v, [])
#     for i in range(m):
#         temp += flatv[] #m*iのやつ

def python_list_add(in1, in2):
   return list(map(sum, zip(in1, in2)))

flag = False
minp = (10 ** 5) * 12
for k,v in price.items():
    r = [0]*m
    for i in range(len(v)):
        r = python_list_add(r, v[i])
    if min(r) >= x:
        minp = min(minp, k)
        flag = True

if flag:
    print(minp)
else:
    print("-1")


Measured memory_bytes: 13688
a = gets.to_i
b = gets.to_i
c = gets.to_i
x = gets.to_i
 
count = 0
 
 
#500円玉の枚数分、支払い方がある
(a + 1).times do |i|
  #100円玉の枚数分さらに分けられる
  (b + 1).times do |j|
    #50円玉の枚数分さらに分けられる
    (c + 1).times do |k|
      count += 1 if x == 500*i + 100*j + 50*k
    end
  end
end
puts count


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

int zeta(int a,int b){
  if(a>=b) return a-b;
  else return b-a;
}

int main(){
  int x,n;
  cin>>x>>n;
  if(n==0){
    cout<<x<<endl;
  }else{
    vector<int>p(n);
    for(int i=0;i<n;i++){
      cin>>p[i];
    }
    int ans1=0;
  for(int i=0;i<1000;i++){
    int count1=0;
    for(int j=0;j<n;j++){
      if(x-i!=p[j]){
        count1++;
      }
      
    }
    if(count1==n){
      ans1=i;
      break;
    }
  }
  int ans2=0;
for(int h=0;h<1000;h++){
  int count2=0;
  for(int j=0;j<n;j++){
    if(x+h!=p[j]){
      count2++;
    }
    
  }
  if(count2==n){
    ans2=h;
    break;
  }
}
if(ans1<=ans2){
  cout<<x-ans1<<endl;
}else{
  cout<<x+ans2<<endl;
}
  
  }
  
  
  return 0;
}








Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)

int main() {
  int n;
  cin >> n;
  vector<int> h(n);
  REP(i, n)
    cin >> h.at(i);
  
  int cur = 0;
  int step = 0;
  REP(i, n - 1) {
    if (h.at(i + 1) <= h.at(i)) {
      ++cur;
    }
    else
      cur = 0;
    step = max(step, cur);
  }
  
  cout << step << endl;
  
  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
#define MOD 1000000007
#define MAX 510000
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

using namespace std;
typedef long long ll;
typedef pair<int, int> P;

//cout << fixed << setprecision(10);//
//最小公倍数//
ll gcd(ll x, ll y) {
	if (x == 0) return y;
	return gcd(y%x, x);
}
ll lcm(ll x, ll y) { return x * y / gcd(x, y); }

//逆元mod(mを法とするaの逆元)//
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

//Cmonp//
ll fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
ll COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

//nが大

ll com(ll n,ll m){
	if(n<=0 || m<=0 || n==m){
		return 1;
	}
	if(n<m){
		return 0;
	}
	ll k=1;
	for(ll i=1;i<=m;i++){
       k*=(n-i+1); 
	   k%=MOD;
	   k*=modinv(i,MOD);
	   k%=MOD;
	}

	return k;
}


////////////////////////////////////////////////////////////////////




int main() {
ll n,m,k;
cin>>n>>m>>k;



ll ml=com(n*m-2,k-2);

ll ans=0;
for(int i=1;i<=n-1;i++){
	ans+=i*m*m*(n-i);
	ans%=MOD;
}

for(int i=1;i<=m-1;i++){
	ans+=i*n*n*(m-i);
	ans%=MOD;
}

ans*=ml;
ans%=MOD;
cout<<ans<<endl;

return 0;

}


Measured memory_bytes: 256
#pragma GCC optimize(3,"Ofast","inline")
#include<bits/stdc++.h>

#define int long long
#define pb push_back
#define pf push_front
#define st first
#define nd second
#define sz(x) ((int)x.size())
#define ins insert
#define fastio ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define lowbit(x) ((x)&(-x))
#define pi acos(-1.0)
using namespace std;

const int maxn=2e5+10;
const int maxe=1e6+10;
const int mod=1e9+7;
const int inf=0x3f3f3f3f;

inline int read(){
    int x=0; bool flag=1; char ch=getchar();
    while(ch<'0'||ch>'9') {if(ch=='-') flag=0; ch=getchar();}
    while(ch>='0'&&ch<='9') {x=(x<<1)+(x<<3)+ch-'0'; ch=getchar();}
    if(flag) return x;
    return ~(x-1);
}
inline void write(int x){
    if(x<0) {x=~(x-1); putchar('-');}
    if(x>9) write(x/10);
    putchar(x%10+'0');
}
int father[maxn];
int Find(int x)
{
    if(x!=father[x])return father[x]=Find(father[x]);
    return x;
}
void Combine(int a,int b)
{
    int fa=Find(a);
    int fb=Find(b);
    if(fa!=fb)
    {
        father[fa]=fb;
    }
}
main(){
    fastio;
    int n=read(),m=read();
    for(int i=1;i<=n;++i)father[i]=i;
    for(int i=1;i<=m;++i){
        int x=read(),y=read();
        Combine(x,y);
    }
    map<int,int>num;
    int ans=0;
    for(int i=1;i<=n;++i){
        num[Find(i)]++;
        ans=max(ans,num[Find(i)]);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 17608
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <queue>
#include <iomanip>
#define ll long long int
#define mod 1000000007
#define pii pair<int, int>
#define fr(n) for (int i = 0; i < n; i++)
#define fr1(n) for (int i = 1; i <= n; i++)
using namespace std;

int main() {
    ios::sync_with_stdio(false);
    int n;
    ll a[102] = {};
    cin >> n;
    fr(n) cin >> a[i];
    fr1(n - 1) {
        ll g = __gcd(a[i], a[0]);
        a[0] *= a[i] / g;
    }
    cout << a[0];
}


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

int main()
{
    int n, m, x, y, p=0, i, k, j;
    cin>>n>>m;
    vector<int>v[m+1];
    for(i=0; i<n; i++){
        cin>>x>>y;
        if(x<=m){
            v[x].push_back(y);
        }
    }
    priority_queue<int>pq;

    for(i=1; i<=m; i++){
        for(j=0; j<v[i].size(); j++){
            k=v[i][j];
            pq.push(k);
        }
        if(!pq.empty()){
            p=p + pq.top();
            pq.pop();
        }
    }
    cout<<p<<endl;
    return 0;

}


Measured memory_bytes: 5504
#include <iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main(void){
    
    long long n,k;
    
    cin>>n>>k;
    vector<int>h(n);
    for(int i=0;i<n;i++){
        cin>>h[i];
    }
    sort(h.begin(),h.end(),greater<int>());
    
    for(int i=0;i<n;i++){
        if(k==0)break;
        h[i]=0;
        k--;
    }
    long long ans=0;
    for(int i=0;i<n;i++){
        ans+=h[i];
    }
    cout<<ans<<endl;
    return 0;
}


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

char str[100100];

int ty[4][100100];

main()
{
    int n;
    scanf("%d",&n);
    scanf("%s",str);
    ty[0][0]=ty[0][1]=ty[1][0]=ty[2][1]=0; // sheep
    ty[1][1]=ty[2][0]=ty[3][0]=ty[3][1]=1; // wolf
    for(int i=1;i<n;i++)
    {
        if(str[i]=='o')
        {
            for(int j=0;j<4;j++)
            {
                if(ty[j][i]==0)ty[j][i+1]=ty[j][i-1];
                else ty[j][i+1]=(ty[j][i-1]+1)%2;
            }
        }
        else
        {
            for(int j=0;j<4;j++)
            {
                if(ty[j][i]==1)ty[j][i+1]=ty[j][i-1];
                else ty[j][i+1]=(ty[j][i-1]+1)%2;
            }
        }
    }
    for(int i=0;i<4;i++)
    {
        if(str[0]=='o')
        {
            if(ty[i][0]==0&&ty[i][n-1]==ty[i][1]&&ty[i][0]==ty[i][n])
            {
                //printf("%d %d\n",ty[i][n-1],ty[i][1]);
                for(int j=0;j<n;j++)printf("%s",ty[i][j]==0?"S":"W");
                return 0;
            }
            if(ty[i][0]==1&&ty[i][n-1]!=ty[i][1]&&ty[i][0]==ty[i][n])
            {
                for(int j=0;j<n;j++)printf("%s",ty[i][j]==0?"S":"W");
                return 0;
            }
        }
        else
        {
            if(ty[i][0]==1&&ty[i][n-1]==ty[i][1]&&ty[i][0]==ty[i][n])
            {
                for(int j=0;j<n;j++)printf("%s",ty[i][j]==0?"S":"W");
                return 0;
            }
            if(ty[i][0]==0&&ty[i][n-1]!=ty[i][1]&&ty[i][0]==ty[i][n])
            {
                for(int j=0;j<n;j++)printf("%s",ty[i][j]==0?"S":"W");
                return 0;
            }
        }
    }
    printf("-1");
}


Measured memory_bytes: 2048
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define rep1(i, n) for (ll i = 1; i <= (ll)n; i++)
#define PI 3.14159265358979323846
#define vll vector<long long>
#define vvll vector<vector<long long>>
#define pll pair<long long, long long>
using namespace std;
using ll = long long;
using ld = long double;

// グローバル変数（入力）
ll d;

void input() { 
  cin >> d;
}

void solve() {
  rep(i,d){
    cout << 1 << endl;
  }
}

int main() {
  input();
  solve();
  return 0;
}


Measured memory_bytes: 3636
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <unordered_map>
#include <vector>

using namespace std;

typedef long long lint;

struct edge_t {
  int other, value;
};

const int maxn = 1e5;

vector<edge_t> adj[maxn];
int many[16];
int dp[1<<16], subsetxor[1<<16];

int solve1(int v, int p) {
  int acc = 0;
  for (const edge_t &ed : adj[v])
    if (ed.other != p) {
      const int u = ed.other;
      int res = solve1(u, v);
      ++many[res ^ ed.value];
      acc ^= ed.value;
    }
  return acc;
}

int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n - 1; ++i) {
    int a, b, value;
    scanf("%d %d %d", &a, &b, &value);
    adj[a].push_back({b, value});
    adj[b].push_back({a, value});
  }
  solve1(0, -1);

  int result = 0;

  many[0] = 0;
  for (int i = 1; i < 16; ++i) {
    result += many[i] / 2;
    many[i] %= 2;
  }

  subsetxor[0] = 0;
  for (int s = 1; s < (1<<16); ++s) {
    int b = __builtin_ctz(s);
    subsetxor[s] = b ^ subsetxor[s ^ (1<<b)];
  }

  for (int s = 0; s < (1<<16); ++s) {
    dp[s] = __builtin_popcount(s);
    for (int submask = s; submask > 0; submask = ((submask - 1) & s))
      if (subsetxor[submask] == 0)
        dp[s] = min(dp[s], dp[s ^ submask] + (__builtin_popcount(submask) - 1));
  }

  int mask = 0;
  for (int i = 0; i < 16; ++i)
    if (many[i] == 1)
      mask |= 1<<i;

  result += dp[mask];
  printf("%d\n", result);

  return 0;
}


Measured memory_bytes: 10752
#include <algorithm>
#include<iostream>
#include<vector>
#include<deque>
#include<queue>
#include<list>
#include<stack>
#include<map>
#include<set>
#include<string>
#include <sstream>
#include<bitset>

#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<limits.h>

using namespace std;
const int INF = 0x7fffffff;

int gcd(int x,int y){
  int mi,ma;
  ma = max(x,y);
  mi = min(x,y);
  if(ma % mi == 0){
    return mi;
  }
  else{
    return gcd(mi,ma % mi);
  }
}

int main(){
  long ii,jj,kk;
  int a,b;
  cin >> a >> b;

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



Measured memory_bytes: 3108
#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>
#include <bitset>
#include<stack>
#include<functional>
#include<unordered_set>
#include<unordered_map>
#include<atcoder/all>

using ll=long long;
#define rep(i,s,e) for(ll i=s;i<e;i++)
#define repeq(i,s,e) for(ll i=s;i<=e;i++)

using namespace std;
int main()
{
	int T;
	cin >> T;
	rep(i,0,T) {
		long long N, M, A, B;
		cin >> N >> M >> A >> B;
		cout << atcoder::floor_sum(N, M, A, B) << endl;
	}
	return 0;
}



Measured memory_bytes: 3604
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <vector>

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


typedef ::std::int_fast64_t i64;
typedef ::std::uint_fast64_t u64;
typedef ::std::int_fast32_t i32;
typedef ::std::uint_fast32_t u32;

namespace tools {
  template <typename T>
  void read(::std::istream& is, ::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    vector.reserve(size);
    ::std::copy_n(::std::istream_iterator<T>(is), size, ::std::back_inserter(vector));
  }
  template <typename T>
  void read(::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    ::tools::read(::std::cin, vector, size);
  }

  template <typename T, ::std::size_t N>
  void read(::std::istream& is, ::std::array<T, N>& array) {
    ::std::copy_n(std::istream_iterator<T>(is), N, array.begin());
  }
  template <typename T, ::std::size_t N>
  void read(::std::array<T, N>& array) {
    ::tools::read(::std::cin, array);
  }
}

#endif

// main.cpp

int main() {
  i64 N;
  std::string s;
  std::cin >> N >> s;

  std::cout << (std::count(s.begin(), s.end(), 'R') > std::count(s.begin(), s.end(), 'B') ? "Yes" : "No") << std::endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
int main()
{
	int A,B,C,D,x,y;
	while(scanf("%d%d%d%d",&A,&B,&C,&D)!=EOF)
	{
		x=A+B;y=C+D;
		if(x==y)
		{
			printf("Balanced\n");
		}
		else{
			if(x>y)
			{
				printf("Left\n");
			}
			else{
				printf("Right\n");
			}
		}
	}
	return 0;
 } 

Measured memory_bytes: 128
// luogu-judger-enable-o2
#include<bits/stdc++.h>
using namespace std;
const long long T=1e9+7;
map<long long ,unsigned long long >dp;
long long f(long long x)
{
    if(dp[x]!=0) return dp[x];
    return dp[x]=((f(x/2)+f((x-1)/2)+f((x-2)/2)))%T;
}
int main ()
{
	dp[0]=1;
    dp[1]=2;
	long long n;
    scanf("%lld",&n);
    printf("%lld",f(n));
    return 0;
}

Measured memory_bytes: 256
import numpy as np
import sys
import math
MAX_INT = int(10e12)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

N = I()
a = [I() for i in range(N)]

num = max(a)
cnt = a.count(num)
if cnt == 1:
  b = sorted(a)
  bb = b[-2]
  for i in a:
    if i == num:
      print(bb)
    else:
      print(num)
else:
  for i in range(N):
    print(num)

Measured memory_bytes: 23196
#include<stdio.h>
int x[125000],min=150000;
int main(void)
{
	int n,m,i,j,k,l,wcnt,bcnt,rcnt,cnt=0;
	char a[50][51];
	scanf("%d %d",&n,&m);
	for(i=0;i<n;i++){
		x[i]=0;
	}
	for(i=0;i<n;i++){
		scanf("%s",a[i]);
	}
	for(i=0;i<n-2;i++){
		for(j=i+1;j<n-1;j++){
			for(k=0;k<=i;k++){
				wcnt=0;
				for(l=0;l<m;l++){
					if(a[k][l]=='W')wcnt++;
				}
				x[cnt]+=m-wcnt;
			}
			for(k=i+1;k<=j;k++){
				bcnt=0;
				for(l=0;l<m;l++){
					if(a[k][l]=='B')bcnt++;
				}
				x[cnt]+=m-bcnt;
			}
			for(k=j+1;k<n;k++){
				rcnt=0;
				for(l=0;l<m;l++){
					if(a[k][l]=='R')rcnt++;
				}
				x[cnt]+=m-rcnt;
			}
			cnt++;
		}
	}
	for(i=0;i<cnt;i++){
		if(min>x[i]){
			min=x[i];
		}
	}
	printf("%d\n",min);
	return 0;
}

Measured memory_bytes: 604
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)

ll mod = 1e09;

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

  ll n;
  cin >> n;

  ll cnt = 0;
  vector<ll> y;
  FOR(i, 1, n + 1){
    y.clear();
    for(int j = 1; j * j <= i; j++){
      if(j * j == i) y.pb(j);
      else if(i % j == 0){
        y.pb(j);
        y.pb(i / j);
      }
    }
    if((i % 2 == 1) && y.size() == 8) cnt++;
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstdlib>
#include <algorithm>
#include <time.h>
#include <cstdio>
#include <queue>
using namespace std;


int memo[1000100];

int main(){
	int n,q;
	cin >> n >> q;
	priority_queue< pair<int,int> , vector< pair<int,int> > , greater< pair<int,int> > > Q;
	pair<int,int> ans(1e9,1e9);
	for(int i = 0 ; i < q ; i++){
		int a,b;
		scanf("%d%d",&a,&b);
		memo[a] += b;
		Q.push(make_pair(-memo[a],a));
		while(-Q.top().first != memo[Q.top().second] ) Q.pop();
		printf("%d %d\n",Q.top().second,-Q.top().first);
	}
}

Measured memory_bytes: 6020
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    int n, m;
    int[][] ss;
    int[] ks;
    int[] ps;
    void run() {
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt(); m = sc.nextInt();

        ss = new int[m][];
        ks = new int[m];
        ps = new int[m];
        for (int i = 0; i < m; i++) {
            ks[i] = sc.nextInt();
            ss[i] = new int[ks[i]];
            for (int j = 0; j < ks[i]; j++) {
                ss[i][j] = sc.nextInt() - 1;
            }
        }

        for (int i = 0; i < m; i++) {
            ps[i] = sc.nextInt();
        }

        int cnt = 0;
        for (int S = 0; S < (1 << n); S++) {
            if (check(S)) cnt++;
        }
        System.out.println(cnt);
    }

    boolean check(int S) {
        for (int i = 0; i < m; i++) {
            int cnt = 0;
            for (int j = 0; j < ks[i]; j++) {
                cnt += (S & (1 << ss[i][j])) > 0 ? 1 : 0;
            }
            if (cnt % 2 != ps[i]) return false;
        }
        return true;
    }

    void debug(Object...os) {
        System.err.println(Arrays.deepToString(os));
    }

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


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

int main(){
  int a,b;
  cin >> a >> b;
  if(a%3 == 0){
    puts("Possible");
  }
  else if(b%3 == 0){
    puts("Possible");
  }
  else if((a+b)%3 == 0){
    puts("Possible");
  }
  else{
    puts("Impossible");
  }
  return 0;
}


Measured memory_bytes: 256
N, M = map(int, input().split())
S = [list(map(int, input().split())) for i in range(N)]
S.sort()
ans = 0
k = M
for i in range(N):
  if k == 0:
    break
  elif S[i][1] <= k:
    k -= S[i][1]
    ans += S[i][0] * S[i][1]
  else:
    ans += S[i][0] * k
    k = 0
print(ans)

Measured memory_bytes: 27460
import java.util.*;

public class Main {
	static ArrayList[] graph;
	public static void main(String[] args) {
		Scanner s=new Scanner(System.in);
		int size=Integer.parseInt(s.next());
		int edges=Integer.parseInt(s.next());
		graph=new ArrayList[size];
		for(int i=0;i<size;i++)
			graph[i]=new ArrayList<Integer>();
		int[] incoming=new int[size];
		for(int i=0;i<edges;i++)
		{
			int source=s.nextInt();
			int dest=s.nextInt();
			graph[source-1].add(dest-1);
			incoming[dest-1]++;
			
		}
		Queue<Integer> Q=new LinkedList<>();
		for(int i=0;i<incoming.length;i++)
			if(incoming[i]==0)
				Q.add(i);
		int len=0;
		while(!Q.isEmpty())
		{
			int length=Q.size();
			for(int i=0;i<length;i++)
			{
				int v = Q.poll();
				for (Integer e : (ArrayList<Integer>) graph[v]) {
					incoming[e]--;
					if (incoming[e] == 0)
						Q.add(e);
				}
			}
			len++;
		}
		System.out.println(len-1);
		s.close();
	}
}


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

double dp[305][305][305];
int n;

double dfs(int a, int b, int c) {
  if(a+b+c==0) return 0.0;
  if(dp[a][b][c]>-0.5) return dp[a][b][c];
  double ks = (double) n/(a+b+c);
  double res = 0;
  if(a) {
    res += (dfs(a-1, b, c)+ks)*a/(a+b+c);
  }
  if(b) {
    res += (dfs(a+1, b-1, c)+ks)*b/(a+b+c);
  }
  if(c) {
    res += (dfs(a, b+1, c-1)+ks)*c/(a+b+c);
  }
  return dp[a][b][c]=res;
}

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  
  vector<int> a(4);
  cin >> n;
  for(int i=0; i<n; i++) {
    int x;
    cin >> x;
    a[x]++;
  }
  for(int i=0; i<=n; i++)
    for(int j=0; j<=n; j++)
      for(int k=0; k<=n; k++)
        dp[i][j][k] = -1;

  printf("%.12f\n", dfs(a[1], a[2], a[3]));

  
  return 0;
}

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

#define lli long long int
#define ld long double
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define pf push_front
#define ff first
#define ss second
#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)

////////////////////////////////////////////////////////    By: Umang Srivastava

/*
lli extgcd(lli a, lli b, lli *x , lli *y)
{
	if(a==0)
	{
		*x=0;
		*y=1;
		return b;
	}
	lli x1 , y1;
	lli gcd = extgcd(b%a , a , &x1 , &y1);
	*x=y-(b/a)*x1;
	*y=x1;
	return gcd;
}

lli modinv(lli a, lli m)
{
	lli x,y;
	lli g = extgcd(a,m,&x,&y);
	if(g!=1)
		return -1;
	return (x%m+m)%m;
}

lli moddiv(lli a, lli b, lli m)
{
	a=a%m;
	lli inv = modinv(b,m);
	if(inv!=-1)
		return ((a*inv + m)%m);
	else
		return -1;
}
*/
lli binpow(lli a, lli b, lli m)
{
	lli res=1;
	a=a%m;
	while(b>0)
	{
		if(b & 1)
		{
			res = (res * a)%m;
		}
		b=b>>1;
		a=(a*a)%m;
	}
	return res;
}
/*
lli gcd(lli a, lli b)
{
    // if(b<a)
    // {
    //     lli t=a;
    //     a=b;
    //     b=t;
    // }
    if(a==0)
        return b;
    return gcd(b%a,a);
}
*/
/////////////////////////////////////////////////////////

int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    lli n,ans;
    cin>>n;
    ans=((binpow(10,n,mod)%mod + binpow(8,n,mod)%mod)%mod - ((binpow(9,n,mod))%mod + (binpow(9,n,mod))%mod)%mod + mod)%mod;
    cout<<ans<<endl;

}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);++(i))
#define all(x) (x).begin(),(x).end()
#define dump(x) cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define yes(n) cout << ((n) ? "yes" : "no") << endl

using namespace std;
using ll = long long;


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

  bool ok = false;
  for (int i = 1; i <= x; ++i) {
    int j = x - i;
    if ((i * 2 + j * 4 == y) || (i * 4 + j * 2 == y)) {
      ok = true;
      break;
    }
  }
  Yes(ok);
}


Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    long a[n+1];
    for(int i=1;i<=n;i++)cin >> a[i];
    long ans = 0;
    map<long,long>numU;
    map<long,long>numD;
    set<long>numbers;
    for(int i=1;i<=n;i++){
        numU[a[i]+i]++;
        numD[i-a[i]]++;
        numbers.insert(a[i]+i);
        numbers.insert(i-a[i]);
    }
    for(int j:numbers){
        ans += numU[j] * numD[j];
    }
    cout << ans << endl;

    
}

Measured memory_bytes: 67620
a,b,c = map(int,input().split())
if a == b and b == c and a%2 == 0:
    print(-1)
    exit()
else:
    t = True
    ans = 0
    while t:
        if a%2+b%2+c%2 > 0:
            print(ans)
            break
        else:
            ans += 1
            A = (b+c)//2
            B = (c+a)//2
            C = (a+b)//2
            a = A
            b = B
            c = C

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
const int MAXN=105;
int a[MAXN];
int main()
{
	int n, tot=0;
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
		tot+=a[i];
	}
	int x=round(1.0*tot/n);
//	printf("x:%d\n",x);
	int ans=0;
	for(int i=1;i<=n;i++){
		ans+=(a[i]-x)*(a[i]-x);
	}
	printf("%d\n",ans);
	return 0;
}

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

int main () {
  int K,N;
  cin >> K >> N;
  vector<int> A(N);
  for (int i=0; i<N; i++) {
    cin >> A[i];
  }
  int max_d = 0;
  
  for (int i=0; i<N-1; i++){
    max_d = max(max_d, abs(A[i+1]-A[i]));
  }
  
  max_d = max(max_d, K-A[N-1]+A[0]);
  
  cout << K - max_d << endl;
  
  
}

Measured memory_bytes: 3992
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;

signed main() {
  int K; 
  cin >> K;

  priority_queue<int, vector<int>, greater<int>> q;
  q.push(1);
  q.push(2);
  q.push(3);
  q.push(4);
  q.push(5);
  q.push(6);
  q.push(7);
  q.push(8);
  q.push(9);

  int cnt = 1;
  while(!q.empty()){
    auto p = q.top(); q.pop();
    if(cnt == K){
      cout << p << endl;
      return 0;
    }

    char c1 = p%10-1;
    char c2 = p%10+1;
    if(p%10 != 0) q.push(p*10+c1);
    if(p%10 != 9) q.push(p*10+c2);
    q.push(p*10+p%10);
    cnt++;
  }

  

  return 0;
}

Measured memory_bytes: 2420
function main(arg) {
	arg = arg.trim().split(' ');
	var b = parseInt(arg[1], 10),
        a = parseInt(arg[0], 10),
    	x = 1, out = 0;
  	for (var i = 0; x < b; i++){
    	x += a-1;
      	out += 1; 
    }
  console.log(out)
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

#define ll 				long long
#define eb 				emplace_back
const long long 		MOD = 1e9 + 7;
#define rep(i,n) 		for (int (i) = 0; (i) < (n); (i)++) 
#define REP(i,k,n)  	for (int (i) = (k); (i) <= (n); (i)++) 
#define REPR(i,k,n) 	for (int (i) = (k); (i) >= (n); (i)--)
#define watch(x) 		cout << (#x) << " = " << (x) << endl
#define t(x)			int x; cin >> x; while(x--)

int main()
{
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
	ios_base::sync_with_stdio(false); cin.tie(nullptr);
	
	/*---- continue Coding ;----*/

	int n;
	cin >> n;
	if(n >= 30){
		cout << "Yes" << "\n";
	}else{
		cout << "No" << "\n";
	}
	
	/*---- break ;----*/

	cerr<<"Execution time: "<<(float)clock()/CLOCKS_PER_SEC<<" secs"<<endl; 
	return 0;
}

Measured memory_bytes: 3788
#include<bits/stdc++.h>
#include<ext/pb_ds/priority_queue.hpp>
#define For(i,a,b) for(i=(a);i<=(b);++i)
#define Forward(i,a,b) for(i=(a);i>=(b);--i)
#define Rep(i,a,b) for(register int i=(a);i<=(b);++i)
#define Repe(i,a,b) for(register int i=(a);i>=(b);--i)
#define Chkmin(a,b) a=a<b?a:b
#define Chkmax(a,b) a=a>b?a:b
using namespace std;
using namespace __gnu_pbds;
template<typename T>inline void read(T &x)
{
    T s=0,f=1;char k=getchar();
    while(!isdigit(k)&&(k^'-'))k=getchar();
    if(!isdigit(k)){f=-1;k=getchar();}
    while(isdigit(k)){s=s*10+(k^48);k=getchar();}
    x=s*f;
}

const int MAXN=1e5+7;

static int n,m;

static struct edge
{
	int v,w,nxt;
}p[MAXN<<1];

static int head[MAXN],e;

inline void add(int u,int v,int w)
{p[++e]=(edge){v,w,head[u]};head[u]=e;}

static int a[MAXN],b[MAXN],x=-1;

inline void dfs(int u,int fr)
{
	if(b[u]<-1e9||b[u]>1e9)puts("0"),exit(0);
	for(register int v=head[u];v;v=p[v].nxt)if(p[v].v^fr)
	{
		if(!a[p[v].v])
		{
			a[p[v].v]=-a[u];b[p[v].v]=p[v].w-b[u];
			dfs(p[v].v,u);
		}
		else
		{
			if(a[p[v].v]==-a[u])
			{
				if(b[p[v].v]==p[v].w-b[u])continue;
				else puts("0"),exit(0);
			}
			else
			{
				if(a[u]*(p[v].w-b[u]-b[p[v].v])<=0||(p[v].w-b[u]-b[p[v].v])&1)puts("0"),exit(0);
				if(x<0)x=(p[v].w-b[u]-b[p[v].v])/2*a[u];
				else if(x!=(p[v].w-b[u]-b[p[v].v])/2*a[u])puts("0"),exit(0);
			}
		}
	}
}

static int l,r;

inline void solve()
{
	read(n);read(m);
	static int u,v,w;
	Rep(i,1,m)read(u),read(v),read(w),add(u,v,w),add(v,u,w);
	a[1]=1;
	dfs(1,0);
	l=1;r=1e9;
	if(x<0)
	{
		Rep(i,1,n)
		{
			if(a[i]>0)Chkmax(l,1-b[i]);
			else Chkmin(r,b[i]-1);
		}
		if(l>r)return (void)puts("0");
		return (void)printf("%d\n",r-l+1);
	}
	Rep(i,1,n)if(a[i]*x+b[i]<=0)return (void)puts("0");
	puts("1");
}

int main()
{
    solve();
    return 0;
}


Measured memory_bytes: 6400
#include"bits/stdc++.h"
#include<unordered_set>
#include<unordered_map>
#include<random>
using namespace std;
typedef long long ll;
const ll MOD = 1'000'000'007LL; /*998'244'353LL;*/
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(n); (i)++)
int dx[4]={ 1,0,-1,0 };
int dy[4]={ 0,1,0,-1 };

int H, W, N;

signed main(){
	cin >> H >> W >> N;
	cout << min((N+H-1)/H, (N+W-1)/W) << endl;
}

Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
//#include "boost/multiprecision/cpp_int.hpp"
//typedef boost::multiprecision::cpp_int LL;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2

ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
typedef pair<dd,dd> d_d;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fi first
#define se second
#define endl "\n"
#define SORT(v) sort(v.begin(),v.end())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
#define POSL(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define POSU(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
//template<class T>void max(T a,T b){if(a<b)return b;else return a;}
//template<class T>void min(T a,T b){if(a>b)return b;else return a;}
//template<class T>bool Max(T&a, T b){if(a < b){a = b;return 1;}return 0;}
//template<class T>bool Min(T&a, T b){if(a > b){a = b;return 1;}return 0;}

//////////////////////////



int main(){fastio
    ll n,l;cin>>n>>l;
    vector<string>v(n);
    rep(i,0,n-1)cin>>v[i];
    SORT(v);
    for(auto x:v)cout<<x;
    cout<<endl;
    
    return 0;
}


Measured memory_bytes: 256
from collections import Counter
N = int(input())
xy = [list(map(int, input().split())) for _ in range(N)]
 
counter = Counter(((b1[0] - b2[0], b1[1] - b2[1])for b1 in xy for b2 in xy if b1 != b2))
print(N - (list(counter.most_common())+[(0,0)])[0][1])


Measured memory_bytes: 3956