akhauriyash/Code-Regression huggingface dataset:
//Author: Fuadul Hasan(fuadul202@gmail.com)
#include<bits/stdc++.h>
using namespace std;

#define ll long long
const int N   = 2e5 + 5;

int main(){
	
	
	int a,b,c,k;
	cin>>a>>b>>c>>k;

	int cnt = 0;
	if(a>=b){
		while(a>=b){
			b *= 2;
			cnt++;
		}
	}

	if(b>=c){
		while(b>=c){
			c *= 2;
			cnt++;
		}
	}

	//cout<<cnt<<endl;
	if(cnt>k){
		cout<<"No"<<endl;
	}else{
		cout<<"Yes"<<endl;
	}

	

	return 0;
}

Measured memory_bytes: 3616
import os
import sys
from collections import defaultdict, Counter, deque
from itertools import product, permutations,combinations, accumulate
from operator import itemgetter
from bisect import bisect_left,bisect
from heapq import heappop,heappush,heapify
from math import ceil, floor, sqrt
from copy import deepcopy

def main():
    
    n,m,k = map(int, input().split())
    n_list = list(map(int, input().split()))
    m_list = list(map(int, input().split()))

    a_list = [0]
    b_list = [0]

    ans = 0
    num = 0

    for i in range(n):
        a_list.append(a_list[i] + n_list[i])

    for i in range(m):
        b_list.append(b_list[i] + m_list[i])


    
    for i in range(n+1):
        if k < a_list[i]:
            break
        while(b_list[m] > k - a_list[i]):
            m -= 1
        ans = max(ans, i+m)
    print(ans)
            

if __name__ == "__main__":
    main()


Measured memory_bytes: 132844
#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define pi 3.141592653589793
const int N = 200001;
using namespace std;


string f(string a, string b) {
    int dp[8][10];
    memset(dp, 0, sizeof dp);
    for (int i = a.size() - 1; i >= 0; i--) {
        if (b[i] == '?') {

            for (int j = a[i] - '0' + 1; j < 10; j++) {
                dp[i][j] = 1;
            }
        }
    }
}



int main() {
//    cout << fixed << setprecision(10);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);


    int s, w;
    cin >> s >> w;
    cout << (w >= s ? "unsafe" : "safe");


}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define int long long
#define mod (int)(1e9+7)
#define inf (int)(3e18)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P std::pair<int,int>
#define PiP std::pair<int,std::pair<int,int>>
#define all(v) v.begin(),v.end()
#define mkp std::make_pair
#define prique(T) std::priority_queue<T,vector<T>,greater<T>>
using namespace std;
template<class T> inline void chmax(T& a, T b) { a = std::max(a, b); }
template<class T> inline void chmin(T& a, T b) { a = std::min(a, b); }

bool prime(int x) {
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0)return false;
	}
	return x != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}
int get_rand(int MIN, int MAX) {
	std::random_device rnd;
	std::mt19937 mt32(rnd());
	std::uniform_int_distribution<int>engine(MIN, MAX);
	return engine(mt32);
}
/*--------Library Zone!--------*/



signed main() {
	int n,m;
	cin>>n>>m;
	cout<<lcm(n,m)<<endl;
}


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

typedef long long LL;
const int N = 405, M = N * N, mod = 998244353;

int n, a[N], b[N], p[N], factor[N], ifactor[N];
std::vector<int> dp[N];

void reduce(int &x) { x += x >> 31 & mod; }
int pow(int x, int y, int ans = 1) {
	for (; y; y >>= 1, x = (LL) x * x % mod)
		if (y & 1) ans = (LL) ans * x % mod;
	return ans;
}
void init(int n) {
	factor[0] = 1;
	for (int i = 1; i <= n; ++i)
		factor[i] = (LL) factor[i - 1] * i % mod;
	ifactor[n] = pow(factor[n], mod - 2);
	for (int i = n; i; --i)
		ifactor[i - 1] = (LL) ifactor[i] * i % mod;
}
void convolute(std::vector<int> &dp, int p, int b) {
	static int a[N]; std::vector<int> ret(dp.size() + b - 1);
	for (int i = 0, q = mod - 1; i < b; ++i, q = (LL) q * p % mod)
		a[i] = (LL) q * ifactor[i] % mod;
	for (int i = 0; i < dp.size(); ++i)
		for (int j = 0; j < b; ++j)
			ret[i + j] = (ret[i + j] + (LL) dp[i] * a[j]) % mod;
	dp = ret;
}
void plus(std::vector<int> &dp, const std::vector<int> &rhs) {
	if (rhs.size() > dp.size()) dp.resize(rhs.size());
	for (int i = 0; i < rhs.size(); ++i) reduce(dp[i] += rhs[i] - mod);
}

int main() {
	std::ios::sync_with_stdio(0), std::cin.tie(0);
	std::cin >> n, dp[0].emplace_back(mod - 1), init(400);
	int sum = 0, cur = 0;
	for (int i = 0; i < n; ++i)
		std::cin >> a[i] >> b[i], sum += a[i];
	int isum = pow(sum, mod - 2);
	for (int i = 0; i < n; ++i)
		p[i] = (LL) a[i] * isum % mod;
	for (int i = 0; i < n; ++i) {
		cur += a[i];
		for (int j = cur; ~j; --j) {
			convolute(dp[j], p[i], b[i]);
			if (j >= a[i]) plus(dp[j], dp[j - a[i]]);
		}
	}
	int ans = 0;
	for (int i = 0, t = 0; i < sum; ++i, reduce(t += isum - mod))
		for (int j = 0; j < dp[i].size(); ++j)
			ans = (ans + (LL) dp[i][j] * pow(mod + 1 - t, mod - j - 2, factor[j])) % mod;
	std::cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Math;

class MainClass
{
    static void Main()
    {
        var nxy = ReadLine().Split().Select(int.Parse).ToArray();
        var N = nxy[0];
        var X = nxy[1]-1;
        var Y = nxy[2]-1;

        var G = new Graph<int>(N);
        for (int i = 0; i < N-1; i++)
        {
            G.Add(i, i + 1);
            G.Add(i + 1, i);
        }
        G.Add(X, Y);
        G.Add(Y, X);

        long[] ans = new long[N - 1];
        for (int i = 0; i < N; i++)
        {
            var used = new bool[N];
            used[i] = true;
            var que = new Queue<(int,int)>();
            que.Enqueue((i,0));
            while (que.Count > 0)
            {
                var v = que.Dequeue();
                foreach (var j in G[v.Item1])
                {
                    if (used[j]) continue;
                    used[j] = true;
                    que.Enqueue((j, v.Item2 + 1));
                    ans[v.Item2]++;
                }
            }
        }
        foreach (var i in ans)
        {
            WriteLine(i/2);
        }
    }
}
class Graph<T>//普通のグラフ
{
    protected List<T>[] G;
    public Graph(int size)
    {
        G = new List<T>[size];
        for (int i = 0; i < size; i++)
        {
            G[i] = new List<T>();
        }
    }

    public List<T> this[int i] => G[i];
    public void Add(int from, T to) => G[from].Add(to);
    public List<T>[] ToListArray() => G;
    public int Length => G.Length;
}

Measured memory_bytes: 32400
import collections

N = int(input())
S = [input() for i in range(N)]
M = int(input())
T = [input() for i in range(M)]

maxi = 0

for i in range(len(S)):
    if S.count(S[i]) - T.count(S[i]) > maxi:
        maxi = S.count(S[i]) - T.count(S[i])

print(maxi)

Measured memory_bytes: 9428
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#define vi vector<int>
#define pii pair<int,int>
#define mii map<int,int>
#define mod 1000000007
int32_t main()
{
    int a,b,max,step,lcm=0;
  cin>>a>>b;
  if(a > b)
      max = step = a;
   else
      max = step = b;

   while(1) {
      if(max%a == 0 && max%b == 0) {
         lcm = max;
         break;    
      }

      max += step;
   }
  cout<<lcm<<endl;
    return 0;
    
}

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

#define rep(i,n)  for(int i=0;i<n;++i)
#define per(i,n)  for(int i=n-1;i>=0;--i)
#define sc1(a)  scanf("%d",&a)
#define sc2(a,b)  scanf("%d %d",&a,&b)
#define sc3(a,b,c)  scanf("%d %d %d",&a,&b,&c)
#define sl1(a)  scanf("%lld",&a)
#define sl2(a,b)  scanf("%lld %lld",&a,&b)
#define sl3(a,b,c)  scanf("%lld %lld %lld",&a,&b,&c)
#define PI 3.1415926535897932

long long dp[105][2][5];
int main(){
    int k,x;
    char n[105];
    scanf("%s",n);
    sc1(k);
    dp[0][0][0]=1;
    x=strlen(n);
    for (int i=1;i<=x;i++) {
        for (int j=0;j<4;j++) {
            if (dp[i-1][0][j]>0) {
                if (n[i-1]-'0'>0) dp[i][0][j+1]=1;
                else dp[i][0][j]=1;
                for (int m=0;m<n[i-1]-'0';m++) {
                    if (m==0) dp[i][1][j]+=1;
                    else dp[i][1][j+1]+=1;
                }
            }
            if (dp[i-1][1][j]>0) {
                dp[i][1][j+1]+=dp[i-1][1][j]*9;
                dp[i][1][j]  +=dp[i-1][1][j];
            }
        }
    }
    printf("%lld\n",dp[x][0][k]+dp[x][1][k]);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>

using namespace std;

int main(){

	int n, x;

	cin >> n;

	for (int i = 1; i <= n; i++){
		x = i;
		if (x % 3 == 0){
			cout << " " << i;
		}
		else{
			while (x > 0){
				if (x % 10 == 3){
					cout << " " << i;
					break;
				}
				x /= 10;
			}
		}
	}
	cout << endl;

	return 0;
}

Measured memory_bytes: 1160
def cmb(n, r, mod):
    if (r < 0 or r > n):
        return 0
    r = min(r, n - r)
    return g1[n] * g2[r] * g2[n - r] % mod


mod = 998244353
N = 2 * 10**5  # 出力の制限
g1 = [1, 1]  # 元テーブル
g2 = [1, 1]  # 逆元テーブル
inverse = [0, 1]  # 逆元テーブル計算用テーブル

for i in range(2, N + 1):
    g1.append((g1[-1] * i) % mod)
    inverse.append((-inverse[mod % i] * (mod // i)) % mod)
    g2.append((g2[-1] * inverse[-1]) % mod)


N, M, K = map(int, input().split())

m_pow = [0] * N
m_pow[0] = 1

for i in range(1, N):
    m_pow[i] = m_pow[i - 1] * (M - 1) % mod

ans = 0

for i in range(K+1):
    ans = (ans + cmb(N - 1, i, mod) * M * m_pow[N - 1 - i]) % mod

print(ans)


Measured memory_bytes: 114344
n = int(input())
minC = n
for i in range(n+1):
    cnt = 0
    t = i
    while t > 0:
        cnt += t%6
        t //= 6
    t = n-i
    
    while t > 0:
        cnt += t%9
        t //= 9
        
    if minC > cnt:
        minC = cnt
print(minC)

Measured memory_bytes: 3060
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define REP(i, n, N) for(ll i=(n);i<(N);i++)
#define RREP(i, n, N) for(ll i=(N-1);i>=(n);i--)
#define CK(n, a, b) ((a)<=(n)&&(n)<(b))
#define ALL(v) (v).begin(), (v).end()
#define MCP(a, b) memcpy(b,a,sizeof(b))
#define p(s) cout<<(s)<<endl
#define p2(a, b) cout<<(a)<<" "<<(b)<<endl
typedef long long ll;
using namespace std;
const ll mod = 1e9 + 7;
const ll inf = 1e18;

int N, T;
ll c[1010], t[1010];

int main() {
    cin>>N>>T;
    REP(i,0,N){
        cin>>c[i]>>t[i];
    }

    ll ans = inf;
    REP(i,0,N){
        if(t[i] <= T){
            ans = min(ans, c[i]);
        }
    }

    if(ans == inf){
        cout<<"TLE"<<endl;
    }else{
        cout<<ans<<endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define pb push_back
#define mp make_pair
#define all(x) x.begin(), x.end()
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
typedef vector<int>         vi;
const int mod = 1000000007;






int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,m,ans=0;
    cin>>n>>m;
    vector<bool> v(n+1,false);

    for(int i=0;i<m;i++){
        int a,b;
        cin>>a>>b;
        if(a==1){
            if(v[b]==true){
                ans=1;
            }
            v[b]=true;

        }
        if(b==n){
            if(v[a]==true){
                ans=1;
            }
            v[a]=true;

        }

    }
    if(ans==1){
        cout<<"POSSIBLE"<<endl;
    }
    else{
    cout<<"IMPOSSIBLE"<<endl;
    }












    }















































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

#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define FOR(i, k, n) for (int i = (k); i < (int)(n); ++i)
using ll = long long int;

using namespace std;

int main() {
  ll A, B, Q;
  cin >> A >> B >> Q;
  vector<ll> s(A + 2), t(B + 2), x(Q);
  s[0] = -1e12;
  s[A + 1] = 1e12;
  t[0] = -1e12;
  t[B + 1] = 1e12;
  REP(i, A) cin >> s[i + 1];
  REP(i, B) cin >> t[i + 1];
  REP(i, Q) cin >> x[i];
  sort(s.begin(), s.end());
  sort(t.begin(), t.end());
  REP(i, Q) {
    int l = 0, r = A + 2;
    while (r - l > 1) {
      int mid = (l + r) / 2;
      if (s[mid] <= x[i])
        l = mid;
      else
        r = mid;
    }
    int l2 = 0, r2 = B + 2;
    while (r2 - l2 > 1) {
      int mid = (l2 + r2) / 2;
      if (t[mid] <= x[i])
        l2 = mid;
      else
        r2 = mid;
    }
    cout << min({max(x[i] - t[l2], x[i] - s[l]),
                 (x[i] - s[l]) + (t[l2 + 1] - s[l]),
                 (x[i] - t[l2]) + (s[l + 1] - t[l2]),
                 (s[l + 1] - x[i]) + (s[l + 1] - t[l2]),
                 (t[l2 + 1] - x[i]) + (t[l2 + 1] - s[l]),
                 max(s[l + 1] - x[i], t[l2 + 1] - x[i])})
         << endl;
  }
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
 
struct UnionFind{
  vector<long long> par;
 
  UnionFind(int n){
    par.assign(n,-1);
  }
 
  void unite(long long x, long long y){
    x=root(x);y=root(y);
    if(x==y) return;
 
    if(par[x]>par[y]){
      swap(x,y);
    }
    par[x]+=par[y];
    par[y]=x;
  }
 
  long long root(long long x){
    if(par[x]<0){
      return x;
    }else{
      return par[x]=root(par[x]);
    }
  }
 
  bool same(long long x, long long y){
    return root(x)==root(y);
  }
};

int main(){
  long long n,m;
  cin >> n >> m;
  UnionFind uf(n);
  long long a[m],b[m];
  map<long long, long long> mp;
  vector<long long> ans;
  for(int i=0;i<m;i++){
    cin >> a[i] >> b[i];
    a[i]--;b[i]--;
  }
  for(int i=0;i<n;i++){
    mp[i]++;
  }
  reverse(a,a+m);
  reverse(b,b+m);
  ans.push_back(n*(n-1)/2);
  for(int i=0;i<m-1;i++){
    long long last=ans.back();
    if(!uf.same(a[i],b[i])){
      ans.push_back(last-mp[uf.root(a[i])]*mp[uf.root(b[i])]);
      long long tmp=mp[uf.root(a[i])],cmp=mp[uf.root(b[i])];
      mp[uf.root(a[i])]=0;
      mp[uf.root(b[i])]=0;
      uf.unite(a[i], b[i]);
      mp[uf.root(a[i])]=tmp+cmp;
    }else{
      ans.push_back(last);
    }
  }
  reverse(ans.begin(), ans.end());
  for(int i=0;i<m;i++){
    cout << ans[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 10872
#include<bits/stdc++.h>
#define rep(i, n) for(int (i)=0 ;i <(n); ++(i))
#define REP(i,m,n) for(int (i) = (m); (i) <= (n); ++(i))
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)? "YES":"NO")
typedef long long ll;
using namespace std;

int main() {
  string s;
  cin >> s;
  cout << "2018" + s.substr(4) << endl;;

  return 0;
}

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

using namespace std;
typedef long long LL;

int main(){
  int N;
  cin >> N;
  vector<int> p(N);
  rep(i,N) cin >> p[i];
  int ans=0;
  rep(i,N-1) if(p[i]==i+1){
    swap(p[i],p[i+1]);
    ans++;
  }
  if(p[N-1]==N) ans++;
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define pi 3.14159
using namespace std;

int main()
 {
 	int i,j,n,c=0;
 	string s,t;
 	cin>>s;
 	cin>>t;
 	n=s.length();
 	for(i=0;i<n;i++)
 		{
 			if(s[i]!=t[i])
 				c++;
		 }
		 cout<<c<<endl;
	return 0;
}
 	
 					

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

using namespace std;

int main()
{
    #ifdef LOCAL_EXEC
    #else
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #endif // LOCAL_EXEC
//    cout << "Hello world!" << endl;
    long long int l,r,d,i,result=0,n,j,k;
    cin>>n;
    long long int A[n+1]={0};
    for(i=1;i<=100;i++){
        for(j=1;j<=100;j++){
            for(k=1;k<=100;k++){
                if(i*i+j*j+k*k+i*j+j*k+k*i<=n)
                    A[i*i+j*j+k*k+i*j+j*k+k*i]+=1;
            }
        }
    }
    for(i=1;i<=n;i++){
        cout<<A[i]<<endl;
    }
    return 0;
}


Measured memory_bytes: 3604
#!/usr/bin/env python

from collections import deque
import itertools as it
import sys

sys.setrecursionlimit(1000000)

N = input()

m = {}

for loop in range(N):
    s, p1, p2 = raw_input().split()
    m[s] = (int(p1), int(p2))

N = input()
lst = raw_input().replace('/', '//').split()
sta = []

for s in lst:
    hoge = [0 for i in range(256)]
    if s in m:
        p = m[s]
        for i in range(p[0], p[1] + 1):
            hoge[i] = 1
        sta.append(hoge)
    elif s in ['+', '-', '*', '//']:
        n2 = sta.pop()
        n1 = sta.pop()
        #print s,n1, n2
        for i in range(256):
            for j in range(256):
                if n1[i] and n2[j]:
                    try:
                        index = eval(str(i) + s + str(j))
                        hoge[index % 256] = 1
                    except:
                        print "error"
                        exit()
        #print hoge
        sta.append(hoge)
    else:
        hoge[int(s)] = 1
        sta.append(hoge)

print "correct"
    



Measured memory_bytes: 5032
#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
#define N 25

int inp(){
	int Ans;char C;bool O=false;
	while((C=getchar())<'0'||C>'9')if(C=='-')O=true;Ans=C-48;
	while((C=getchar())>='0'&&C<='9')Ans=(Ans<<3)+(Ans<<1)+C-48;
	return O==true?-Ans:Ans;
}

int n,p[N],q[N],a,b,tim;
int ans[N];
bool vis[N];

void check(){
	tim++;
	bool Flag=0;
	for(int i=1;i<=n;i++)
		if(ans[i]!=p[i]){Flag=1;break;}
	if(Flag==0)a=tim;
	Flag=0;
	for(int i=1;i<=n;i++)
		if(ans[i]!=q[i]){Flag=1;break;}
	if(Flag==0)b=tim;
}

void dfs(int k){
	if(k==n+1){
		check();
		return;
	}
	for(int i=1;i<=n;i++)
		if(!vis[i]){
			vis[i]=1;
			ans[k]=i;
			dfs(k+1);
			vis[i]=0;
		}
}

int main(){
	n=inp();
	for(int i=1;i<=n;i++)p[i]=inp();
	for(int i=1;i<=n;i++)q[i]=inp();
	dfs(1);
	cout<<(a>b?a-b:b-a);
}

Measured memory_bytes: 256
mod = 10 ** 9 + 7
n = int(input())
a = list(map(int, input().split()))
l = [0 for i in range(len(str(bin(max(a)))) - 2)]
a = [bin(i)[2:] for i in a]

for i in a:
    for j, k in enumerate(i[::-1]):
        if k == "1":
            l[j] += 1
ans = 0
for i, j in enumerate(l):
    ans = (ans + (j * (n - j)) * (2 ** i)) % mod
print(ans)

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define eee(a) (cerr << (#a) << ": " << (a) << endl);


using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
using mint = map<int, int>;

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

const char sp = ' ';
const char cmm = ',';
const int MOD = 1e9+7;
const int INF = 1e9;
const ll LINF = 1e18;

ll mod(ll a, ll b){return (a%b+b)%b;}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void Judge(bool b){b?Yes():No();}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void JUDGE(bool b){b?YES():NO();}
ll powMod(ll b, ll e, ll m){ll r=1;while(e>0){if(e&1)r=(r%m)*(b%m)%m;b=(b%m)*(b%m)%m;e>>=1;}return r;}
double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));}

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename T>
void ppp(T n){cout << n << endl;}
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
    int len = v.size();
    s << '[';
    for (int i = 0; i < len; ++i) {
        s << v[i]; if (i < len-1) s << ", ";
    }
    s << ']';
    return s;
}

struct aaa{
    aaa(){
        cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(15);
    };
}fastio;

int amx, a1, bmx, b1;
int main(){

    int n;
    cin >> n;

    vector<int> cnta(100001, 0), cntb(100001, 0);

    rep(i, n) {
        int v;
        cin >> v;
        if(i%2==0) {
            cnta[v]++;
            if(cnta[v] > amx){
                amx = cnta[v];
                a1 = v;
            }
        }
        else {
            cntb[v]++;
            if(cntb[v] > bmx){
                bmx = cntb[v];
                b1 = v;
            }
        }
    }
    sort(cnta.rbegin(), cnta.rend());
    sort(cntb.rbegin(), cntb.rend());

    if(a1 != b1) ppp(n-amx-bmx);
    else ppp(n-max(amx+cntb[1], bmx+cnta[1]));



    return 0;
}


Measured memory_bytes: 1024
int main(void){
	char line[11],line1[30];
	int i=0,sum=0;

	scanf("%s",line);
	while(line[i]){
		if(isupper(line[i]))
			line[i]=tolower(line[i]);
		i++;
	}

	for(;i=0,scanf("%s",line1),strcmp(line1,"END_OF_TEXT");){
		while(line1[i]){
			if(isupper(line1[i]))
				line1[i]=tolower(line1[i]);
			i++;
		}

		if(!strcmp(line1,line))
			sum++;
	}

	printf("%d\n",sum);

	return 0;
}

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

using namespace std;

int main() {
	cin.sync_with_stdio(false);

	int A, B, C, D;
	cin >> A >> B >> C >> D;
	if (A*B <= C*D) {
		cout << C*D << endl;
	}
	else {
		cout << A*B << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
using namespace std;
int main(void)
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int c, a;
	cin >> c >> a;
	if ((c*a )%2 == 0)
	{
		cout << "Even" << endl;
	}
	else {
		cout << "Odd" << endl;
	}
}


Measured memory_bytes: 256
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;

int main(){
	long long n, x;
	scanf("%lld%lld", &n, &x);
	vector<vector<long long>> a(n, vector<long long>(n));
	for(int i = 0; i < n; i++){
		scanf("%lld", &a[0][i]);
	}
	for(int i = 1; i < n; i++){
		for(int j = 0; j < n; j++){
			a[i][j] = min(a[i - 1][(n + j - 1) % n], a[0][j]);
		}
	}
	long long ans = (long long)1e18, sum;
	for(int i = 0; i < n; i++){
		sum = 0;
		for(int j = 0; j < n; j++){
			sum += a[i][j];
		}
		ans = min(ans, sum + x * i);
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 31616
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		solve();
	}

	private static void solve() {
		Scanner scn = new Scanner(System.in);
		PrintWriter pr = new PrintWriter(System.out);
		while(true){
			int W = scn.nextInt();
			int H = scn.nextInt();
			int count=0;
			if(W==0&&H==0) break;
			char[][] map = new char[H+2][W+2];
			for(int x=0;x<H+2;x++){
				for(int y=0;y<W+2;y++){
					map[x][y]='#';
				}
			}
			int startx=1;
			int starty=1;
			for(int x=1;x<H+1;x++){
				String tmp=scn.next();
				for(int y=1;y<W+1;y++){
					map[x][y]=tmp.charAt(y-1);
					if(map[x][y]=='@'){
						startx=x;
						starty=y;
					}
					if(map[x][y]=='.'){
						count++;
					}
				}
			}
			mapcount(map,startx,starty);
			for(int x=1;x<H+1;x++){
				for(int y=1;y<W+1;y++){
					if(map[x][y]=='.'){
						count--;
					}
				}
			}
			pr.println(count+1);
		}
		pr.flush();
		scn.close();
	}

	private static void mapcount(char[][] map, int startx, int starty) {
		if(map[startx][starty+1]=='.'){
			map[startx][starty+1]='#';
			mapcount(map,startx,starty+1);
		}
		if(map[startx+1][starty]=='.'){
			map[startx+1][starty]='#';
			mapcount(map,startx+1,starty);
		}
		if(map[startx][starty-1]=='.'){
			map[startx][starty-1]='#';
			mapcount(map,startx,starty-1);
		}
		if(map[startx-1][starty]=='.'){
			map[startx-1][starty]='#';
			mapcount(map,startx-1,starty);
		}
		
	}

}

Measured memory_bytes: 38592
#include <bits/stdc++.h>
#define rep(i, a, b) for(register int i = a; i <= b; i++)
#define per(i, a, b) for(register int i = a; i >= b; i--)
using namespace std;

typedef unsigned long long ull;
typedef pair <int, int> pii;
typedef long long ll;

template <typename _T>
inline void read(_T &f) {
    f = 0; _T fu = 1; char c = getchar();
    while(c < '0' || c > '9') { if(c == '-') fu = -1; c = getchar(); }
    while(c >= '0' && c <= '9') { f = (f << 3) + (f << 1) + (c & 15); c = getchar(); }
    f *= fu;
}

template <typename T>
void print(T x) {
    if(x < 0) putchar('-'), x = -x;
    if(x < 10) putchar(x + 48);
    else print(x / 10), putchar(x % 10 + 48);
}

template <typename T>
void print(T x, char t) {
    print(x); putchar(t);
}

const int N = 105;

char c[N];
int n, ans;

int main() {
    scanf("%s", c + 1); n = strlen(c + 1);
    for(register int i = 1; i <= n / 2; i++) ans += (c[i] != c[n - i + 1]);
    print(ans, '\n');
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>

bool issep( char ch )
{
	return ch == ' ' || ch == '.' || ch == ',';
}

std::string s;

std::vector<std::string> split()
{
	std::vector<std::string> ret;
	std::string::size_type i = 0, j = 0;

	while( i < s.size() && j < s.size() )
	{
		while( i < s.size() && issep( s[i++] ) );
		--i;

		j = i;

		while( j < s.size() && !issep( s[++j] ) );

		if( i < j )
		{
			std::string t = s.substr( i, j - i );

			if( 3 <= t.size() && t.size() <= 6 )
				ret.push_back( t );

			i = j + 1;
		}
	}

	return ret;
}

int main()
{
	std::getline( std::cin, s );

	std::vector<std::string> v = split();
	for( int i = 0; i != v.size(); ++i )
		( i ? std::cout << " " : std::cout ) << v[i];

	std::cout << std::endl;

	return 0;
}

Measured memory_bytes: 1172
[N, M] = list(map(int, input().split()))
[s, c] = [[],[]]
for _ in range(M):
  input_line = list(map(int, input().split()))
  s.append(input_line[0])
  c.append(input_line[1])
  
ans = -1

if N == 1:
  for i in range(10):
    count = 0
    for j in range(M):
      if str(i)[s[j]-1] == str(c[j]):
        count += 1
    if count == M:
      ans = i
      break
  
elif N == 2:
  for i in range(10, 100):
    count = 0
    for j in range(M):
      if str(i)[s[j]-1] == str(c[j]):
        count += 1
    if count == M:
      ans = i
      break
  
else:
  for i in range(100, 1000):
    count = 0
    for j in range(M):
      if str(i)[s[j]-1] == str(c[j]):
        count += 1
    if count == M:
      ans = i
      break
      
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define pi acos(-1)
#define el << endl
using namespace std;
typedef long long ll;
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    ll x,n,a,b,i,j,k;
    cin>>x;
    ll cnt=0;
    i =100;
    while(i<x)
    {
        i += i/100;
        cnt++;
    }
    cout<< cnt << endl;
    return 0;
}


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

#if MYDEBUG
#include "lib/cp_debug.hpp"
#else
#define DBG(...) ;
#endif
#if __cplusplus <= 201402L
template <typename T>
T gcd(T a, T b) { return ((a % b == 0) ? b : gcd(b, a % b)); }
template <typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }
#endif
using LL = long long;
constexpr LL LINF = 334ll << 53;
constexpr int INF = 15 << 26;
constexpr LL MOD = 1E9 + 7;

namespace Problem {
using namespace std;

class Solver {
 public:
  int n;
  vector<unsigned long long> a;
  Solver(unsigned long long n) : n(n), a(n){};

  void solve() {
    unsigned long long xor_all = 0;
    for (int i = 0; i < n; ++i) {
      cin >> a[i];
      xor_all ^= a[i];
    }
    DBG(xor_all)
    sweepout(a, xor_all);
    sort(a.begin(), a.end(), [&](unsigned long long x, unsigned long long y) -> bool { return (x & (~xor_all)) > (y & (~xor_all)); });
    DBG(a)
    unsigned long long red = 0;
    for (int i = 0; i < n; ++i) {
      unsigned long long r1 = red ^ a[i];
      unsigned long long r2 = red;
      unsigned long long xor1 = r1 + (xor_all ^ r1);
      unsigned long long xor2 = r2 + (xor_all ^ r2);
      if (xor1 > xor2) {
        red = r1;
      } else {
        red = r2;
      }
      DBG(red)
    }
    cout << red + (xor_all ^ red) << endl;
  }
  // 行列のrankを掃き出し法で求める
  int sweepout(vector<unsigned long long>& t, LL mask) {
    DBG(t)
    int row = t.size(), n = 60, rank = 0;
    for (int i = n - 1; i >= 0; --i) {
      if (mask & (1ll << i)) continue;
      int p = rank;
      while (((t[p] >> i) & 1) == 0) {
        p++;
        if (p == row) break;
      }
      if (p == row) continue;
      swap(t[rank], t[p]);
      for (int j = 0; j < row; ++j) {
        if (j != rank && ((t[j] >> i) & 1)) t[j] ^= t[rank];
      }
      DBG(t)
      rank++;
      if (rank == min(n, row)) break;
    }
    return rank;
  }
};
}  // namespace Problem

int main() {
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(false);
  // std::cout << std::fixed << std::setprecision(12);
  long long n = 0;
  std::cin >> n;

  Problem::Solver sol(n);
  sol.solve();
  return 0;
}


Measured memory_bytes: 1024
N = int(input())
a = list(map(int,input().split()))
frag = 0
count = 0
i = 0
j = 1
while i<N:
  if a[i] == j:
    frag = 1
    i = i+1
    j = j+1
  else:
    i = i+1
    count = count+1
if frag == 0:
  print(-1)
else:
  print(count)

Measured memory_bytes: 24744
#include <bits/stdc++.h>
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long int
using namespace std;
 
int main() {
    fast();
    /*ll t;
    cin>>t;
    while(t--)
    {
       
    }*/
    string s;
    cin>>s;
    int flag=1;
    for(ll i=0;i<s.length();i++)
    {
        if((i+1)%2==1)
        {
            if(s[i]=='L')
            flag=0;
        }
        else
        {
            if(s[i]=='R')
            flag=0;
        }
    }
    if(flag)
    cout<<"Yes";
    else
    cout<<"No";
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <cmath>
#include <string>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int,int> pint;
typedef pair<ll,ll> pll;
#define range(i,a,b) for(int i=a;i<b;++i)
#define rep(i,n) range(i,0,n)
const ll INF=1e10;
#define PI 3.141592
#define pb push_back

void show(vector<vll> a){
    range(i,1,a.size()){
        range(j,1,a[i].size()){
            cout << a[i][j] << " ";
        }
        cout << endl;
    }
}

int main(){
    int n,m; cin >> n >> m;
    char ch;
    vint a(m),b(m),c(m),d(m);
    vector<vll> K(n+1,vll(n+1,INF));
    rep(i,m){
        int a,b; cin >> a >> ch >> b >> ch;
        cin >> K[a][b] >> ch >> K[b][a];
    }
    int s,g,v,p; cin >> s >> ch >> g >> ch >>  v >> ch >> p;

    range(k,1,n+1) range(i,1,n+1) range(j,1,n+1){
        if(K[i][j]>K[i][k]+K[k][j]){
            K[i][j]=K[i][k]+K[k][j];
        }
    }
    cout << v-p-K[s][g]-K[g][s] << endl;
}


Measured memory_bytes: 3040
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll gcm(ll a,ll b ) {
  ll c;
  while (b != 0) {
    c = a % b;
    a = b;
    b = c;
  }
  return a;
}

ll lcm(ll a,ll b ) {
  return a * (b / gcm(a, b));
}

int main(){
  int n;
  cin>>n;
  ll a[n];
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  for(int i=1;i<n;i++){
    a[i]=lcm(a[i-1],a[i]);
  }
  cout<<a[n-1];
}
  

Measured memory_bytes: 256
N, M, C = map(int, input().split())
B = list(map(int, input().split()))
cnt = 0
for i in range(N):
    summ = C
    A = list(map(int, input().split()))
    for j in range(M):
        summ += B[j]*A[j]
    if(summ > 0): cnt+= 1
print(cnt)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <iostream>
#include <numeric>
using namespace std;
int main(){
    ios::sync_with_stdio(false), cin.tie(0);
    int a,b;
    cin>>a>>b;
    if((a+b)%2==0){
        cout<<(a+b)/2<<endl;
    }else{
        cout<<"IMPOSSIBLE"<<endl;
    }
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define fi first
#define se second
long long mo = 1000000007;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
typedef pair<ll,Pll> PlP;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}
ld PI=3.14159265358979323846;

int main(){
    ll X,Y,Z,K;
    cin >> X >> Y >> Z >> K;
    vector<ll> A(X), B(Y), C(Z);
    vector<ll> v;
    rep(i,X){
        cin >> A[i];
        //v.emplace_back(A[i],0);
    }
    sort(A.rbegin(), A.rend());
    rep(i,Y){
        cin >> B[i];
        //v.emplace_back(B[i],1);
    }
    sort(B.rbegin(), B.rend());
    rep(i,Z){
        cin >> C[i];
        //v.emplace_back(C[i],2);
    }
    sort(C.rbegin(), C.rend());
    priority_queue<pair<Pll,Pll>> que;
    map<PlP,ll> mp;
    ll a = 0;
    ll b = 0;
    ll c = 0;
    mp[PlP(a,Pll(b,c))]++;
    que.push(make_pair(Pll(A[a]+B[b]+C[c], a), Pll(b,c)));
    rep(qqq, K){
        a = que.top().first.second;
        b = que.top().second.first;
        c = que.top().second.second;
        v.push_back(que.top().fi.fi);
        que.pop();
        if(a < X-1 && mp[PlP(a+1,Pll(b,c))] == 0){
            mp[PlP(a+1,Pll(b,c))]++;
            que.push(make_pair(Pll(A[a+1]+B[b]+C[c], a+1), Pll(b,c)));
        }
        if(b < Y-1 && mp[PlP(a,Pll(b+1,c))] == 0){
            mp[PlP(a,Pll(b+1,c))]++;
            que.push(make_pair(Pll(A[a]+B[b+1]+C[c], a), Pll(b+1,c)));
        }
        if(c < Z-1 && mp[PlP(a,Pll(b,c+1))] == 0){
            mp[PlP(a,Pll(b,c+1))]++;
            que.push(make_pair(Pll(A[a]+B[b]+C[c+1], a), Pll(b,c+1)));
        }
    }
    rep(i,K){
        cout << v[i] << endl;
    }
    //sort(v.rbegin(), v.rend());
    /*
    ll a = 0;
    ll b = 0;
    ll c = 0;
    v.push_back(A[a]+B[b]+C[c]);
    rep(t,K-1){
        ll AA = 0;
        ll BB = 0;
        ll CC = 0;
        if(a < X - 1){
            AA = A[a+1]+B[b]+C[c];
        }else{
            AA = 
        }
        if(b < Y - 1)BB = A[a]+B[b+1]+C[c];
        if(c < Z - 1)CC = A[a]+B[b]+C[c+1];
        if(AA >= BB && AA >= CC){
            v.push_back(AA);
            a++;
        }else if(BB >= AA && BB >= CC){
            v.push_back(BB);
            b++;
        }else{
            v.push_back(CC);
            c++;
        }
    }
    rep(i,K){
        cout << v[i] << endl;
    }
    /*multiset<ll> ms;
    rep(i,X){
        rep(j,Y){
            ms.insert(A[i]*B[j]);
        }
    }*/
}

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

using namespace std;

#define int long long

const int INF = 1e18 + 118;

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n, k, s;
    cin >> n >> k >> s;
    if (s == 1000000000)
    {
        for (int i = 0; i < k; ++i)
        {
            cout << s << " ";
        }
        for (int i = k; i < n; ++i)
        {
            cout << 1 << " ";
        }
        cout << endl;
        return 0;
    }
    for (int i = 0; i < k; ++i)
    {
        cout << s << " ";
    }
    for (int i = k; i < n; ++i)
    {
        cout << s + 1 << " ";
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 1280
#include <iostream>
#include <vector>
int main() {
  int N;
  std::cin >> N;
  std::vector<int> v(N);
  for(auto &&ele : v) std::cin >> ele;
  int ans = 0;
  for(size_t i = 0; i < N; i++) for(size_t j = i + 1; j < N; j++) ans += v[i] * v[j];
  std::cout << ans << std::endl;
  return 0;
}

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

const int MOD = 1e9 + 7;

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

    int H, W, K; cin >> H >> W >> K;
    int dp[H + 1][W]; fill(dp[0], dp[H + 1], 0); dp[0][0] = 1;

    for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W; ++j) {
            for (int k = 0; k < 1 << (W - 1); ++k) {
                bool isolated = true;
                for (int l = 0; l < W - 2; ++l) {
                    if (((k >> l) & 1) && ((k >> (l + 1)) & 1)) {
                        isolated = false;
                    }
                }
                if (isolated) {
                    if (j >= 1 && ((k >> (j - 1)) & 1)) {
                        dp[i + 1][j - 1] += dp[i][j];
                        dp[i + 1][j - 1] %= MOD;
                    }
                    else if (j <= W - 2 && ((k >> j) & 1)) {
                        dp[i + 1][j + 1] += dp[i][j];
                        dp[i + 1][j + 1] %= MOD;
                    }
                    else {
                        dp[i + 1][j] += dp[i][j];
                        dp[i + 1][j] %= MOD;
                    }
                }
            }
        }
    }

    cout << dp[H][K - 1] << endl;

    return 0;
}

Measured memory_bytes: 256
import std;

alias sread = () => readln.chomp();
alias lread = () => readln.chomp.to!long();
alias aryread(T = long) = () => readln.split.to!(T[]);
//aryread!string();
//auto PS = new Tuple!(long,string)[](M);
//x[]=1;でlong[]全要素1に初期化
void main()
{
    auto n = lread();
    auto s = sread();
    auto t = sread();
    // writeln(s);
    // writeln(t);
    long ans = -1;
    foreach (i; 0 .. n + 1)
    {
        if (func(s, t, i))
        {
            // writeln(s[($ - i) .. $], t[0 .. i]);
            ans = max(ans, i);

        }
    }
    // writeln(ans);
    writeln((s.length + t.length) - ans);

}

bool func(string s, string t, long x)
{
    if (s[($ - x) .. $] == t[0 .. x])
    {
        return true;
    }
    else
    {
        return false;
    }
}

void arywrite(T)(T a)
{
    a.map!text.join(' ').writeln;
}


Measured memory_bytes: 3664
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int l = s.length();
		int p_l = l-7;
		String set_s = "";
		
		if (l==7) {
			if (s.equals("keyence")) {
				System.out.println("YES");
				return;
			}
			
		} else {
			for (int j=0; j<=7; j++) {
				set_s = s.substring(0,j) + s.substring(j+p_l,l);
              
				if (set_s.equals("keyence")) {
					System.out.println("YES");
					return;
				}
			}
		}

		System.out.println("NO");
		return;
		
	}
}

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

#define ll long long
#define pb push_back
#define mp make_pair
#define boost ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0)
#define f first
#define se second
#define lb lower_bound
#define ub upper_bound
#define pii pair<double, double>
#define all(x) x.begin(), x.end()

const int N = 1e5 + 144, mod = 1e9 + 7, inf = 1e9 + 7;
int n, m;
vector <int> g[N];
bool was[N];
int ans[N];

ll bp(ll x, ll y){
    if(y == 0)
        return 1;
    if(y & 1)
        return (x * bp(x, y - 1)) % mod;
    ll z = bp(x, y / 2);
    return (z * z) % mod;
}

void dfs(int x){
    was[x] = true;
    for(auto to: g[x]){
        if(!was[to])
            dfs(to);
        ans[x] = max(ans[to] + 1, ans[x]);
    }
}

int main(){
    boost;
    cin >> n >> m;
    for(int i = 1; i <= m; i++){
        int x, y;
        cin >> x >> y;
        g[x].pb(y);
    }
    for(int i = 1; i <= n; i++){
        if(!was[i])
            dfs(i);
    }
    int mx = 0;
    for(int i = 1; i <= n; i++){
        mx = max(ans[i], mx);
    }
    cout << mx;
    return 0;
}


Measured memory_bytes: 8320
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int main() {
    int a, b;
    string s;
    cin >> a >> b >> s;
    REP(i,a+b+1){
        if (i == a){
            if (s[i] != '-'){
                cout << "No" << endl;
                return 0;
            }
        }else{
            if (s[i] < '0' || s[i] > '9'){
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;

    return 0;
}





Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); ++i)
using namespace std;
int main() {
  int n;
  cin >> n;
  double sum=0;
  vector<int>a(n);
  vector<double>reciprocal(n);
  rep(i,n) {
    cin >> a[i];
    reciprocal[i]=1.0/a[i];
    sum+=reciprocal[i];
  }
  cout << fixed << setprecision(15) << 1.0/sum << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>

int main()
{
	std::string S;
	int N = 0;

	std::cin >> N >> S;
	for (int i = 0; i < S.size(); i++)
	{
		if (S[i] + N > 'Z') S[i] = 'A' - ('Z' - S[i] + 1);
		S[i] += N;
	}

	std::cout << S << std::endl;
  
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long LL;
#define SORT(c) sort((c).begin(),(c).end())

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

using namespace std;
int main(void)
{
  int m,n;
  cin >> m >> n;
  vector<string> fi(m);
  REP(i,m) cin >> fi[i];
  int answer=0;
  REP(i,m) REP(j,n) if(fi[i][j]=='.') --answer;
  vector<pair<int,int> > pos[256];
  REP(i,m) REP(j,n) if(fi[i][j]!='.'){
    pos[fi[i][j]].push_back(make_pair(i,j));
  }
  bool flag=true;
  while(flag){
    flag=false;
    FOR(i,'A','Z'+1){
      if(pos[i].size()<2) continue;
      int x0,x1,y0,y1;
      x0=pos[i][0].first;
      y0=pos[i][0].second;
      x1=pos[i][1].first;
      y1=pos[i][1].second;
      if(x0==x1){
	if(abs(y0-y1)>1){
	  bool er=true;
	  if(y0>y1) swap(y0,y1);
	  FOR(j,y0+1,y1) if(fi[x0][j]!='.') er=false;
	  if(er){
	    fi[x0][y0]='.';
	    fi[x1][y1]='.';
	    flag=true;
	    pos[i].clear();
	  }
	}
      }else if(y0==y1){
	if(abs(x0-x1)>1){
	  bool er=true;
	  if(x0>x1) swap(x0,x1);
	  FOR(j,x0+1,x1) if(fi[j][y0]!='.') er=false;
	  if(er){
	    fi[x0][y0]='.';
	    fi[x1][y1]='.';
	    flag=true;
	    pos[i].clear();
	  }
	}
      }else if((x0-x1)*(y0-y1)>0){
	bool er0=true,er1=true;
	if(x0>x1){
	  swap(x0,x1);
	  swap(y0,y1);
	}
	FOR(j,x0+1,x1+1) if(fi[j][y0]!='.') er0=false;
	FOR(j,y0+1,y1) if(fi[x1][j]!='.') er0=false;
	FOR(j,y0+1,y1+1) if(fi[x0][j]!='.') er1=false;
	FOR(j,x0+1,x1) if(fi[j][y1]!='.') er1=false;
	if(er0||er1){
	  fi[x0][y0]='.';
	  fi[x1][y1]='.';
	  flag=true;
	  pos[i].clear();
	}
      }else if((x0-x1)*(y0-y1)<0){
	bool er0=true,er1=true;
	if(x0>x1){
	  swap(x0,x1);
	  swap(y0,y1);
	}
	FOR(j,x0+1,x1+1) if(fi[j][y0]!='.') er0=false;
	FOR(j,y1+1,y0) if(fi[x1][j]!='.') er0=false;
	FOR(j,y1,y0) if(fi[x0][j]!='.') er1=false;
	FOR(j,x0+1,x1) if(fi[j][y1]!='.') er1=false;
	if(er0||er1){
	  fi[x0][y0]='.';
	  fi[x1][y1]='.';
	  flag=true;
	  pos[i].clear();
	}
      }
    }
  }
  REP(i,m) REP(j,n) if(fi[i][j]=='.') ++answer;
  cout << answer << endl;

  return 0;
}

Measured memory_bytes: 3288
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int A = scanner.nextInt(); // 500
        int B = scanner.nextInt(); // 100
        int C = scanner.nextInt(); // 50
        int X = scanner.nextInt();
        int count = 0;
        for (int i1 = 0; i1 <= C; i1++) {
            for (int i2 = 0; i2 <= B; i2++) {
                for (int i3 = 0; i3 <= A; i3++) {
                    if (50 * i1 + 100 * i2 + 500 * i3 == X) {
                        count++;
                    }
                }
            }
        }
        System.out.println(count);
    }
}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
#define f(i,a,b) for(register int i=a;i<=b;++i)
#define ff(i,a,b) for(register int i=a;i>=b;--i)
#define debug(x) cerr << #x << " : " << x << " " << endl
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<string, string> pss;
const ll mod = 998244353;
const ll mod1 = 2e18 + 7;
const double tiaohe = 0.57721566490153286060651209;
const int inf = 0x3f3f3f3f;
ll oula(ll x) { ll res = x;f(i, 2, x / i) { if (x % i == 0) { res = res / i * (i - 1);while (x % i == 0) x /= i; } }if (x > 1) res = res / x * (x - 1);return res; }
ll quickmod(ll a, ll n, ll m) { ll s = 1;while (n) { if (n & 1) { s = s * a % m; }a = (a*a) % m;n = n / 2; }return s; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
void ex_gcd(ll a, ll b, ll &x, ll &y, ll &d) { if (!b) { d = a, x = 1, y = 0; } else { ex_gcd(b, a % b, y, x, d);y -= x * (a / b); } }
ll inv(ll t, ll p) { ll d, x, y;ex_gcd(t, p, x, y, d);return d == 1 ? (x % p + p) % p : -1; }
//double a = log(n) +tiaohe + 1.0 / (2 * n);
double eqa = (1 + sqrt(5.0)) / 2.0;
const int N = 6e5 + 5;
int t;

int main()
{
	//freopen("in.txt", "r", stdin);
	int n, k,x;
	while (cin >> n >> k)
	{
		f(i, 1, k)cin >> x, n -= x;
		if (n <= 0)puts("Yes");
		else puts("No");
	}
	return 0;
}

Measured memory_bytes: 3600
#include <iostream>
using namespace std;
int k(long n) {
	if (n < 10)return 1;
	else if (n < 100) return 2;
	else if (n < 1000) return 3;
	else if (n < 10000) return 4;
	else if (n < 100000) return 5;
	else if (n < 1000000) return 6;
	else if (n < 10000000) return 7;
	else if (n < 100000000) return 8;
	else if (n < 1000000000) return 9;
	else if (n < 10000000000) return 10;
}
int main() {
	long n;
	cin >> n;
	long ans = 1000000000;
	for (int i = 1; i <= 100000; i++) {
		if (n%i == 0) {
			long pre;
			long b;
			b = n / i;
			if (b > i) pre = k(b);
			else pre = k(i);
			if (ans > pre) ans = pre;
		}
	}
	cout<<ans<<endl;
	return 0;
}

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

int my_gcd(int n, int m){
    if(n < m) swap(n, m);
    if(m == 0) return n;
    else return my_gcd(m, n%m);
}

signed main(){
    // cout << fixed << setprecision(10) << flush;

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

    int l = t[0];
    for(int i=1; i<n; i++){
        int g = my_gcd(l, t[i]);
        l = l / g * t[i];
    }
    cout << l << endl;

    return 0;
}

Measured memory_bytes: 3568
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
using namespace std;

void solve() {
    string s; cin >> s;
    int f = 1;
    if(s.size()%2 != 0) f = 0;
    else{
        for(int i = 0; i < s.size(); i += 2){
            if(s[i] != 'h' || s[i+1] != 'i') f = 0;
        }
    }
    if(f) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

    solve();
    return 0;
}
 


Measured memory_bytes: 256