akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

int solve(vector<vector<int>>& m, vector<vector<int>>& memo, int row , int col, int n){
    
    if(row==n)return 0;
    if(col!=-1 && memo[row][col]!=-1)return memo[row][col];

    int a=0,b=0,c=0;

    if(col!=0)
    a= m[row][0]+solve(m,memo,row+1,0,n);

    if(col!=1)
    b= m[row][1]+solve(m,memo,row+1,1,n);

    if(col!=2)
    c= m[row][2]+solve(m,memo,row+1,2,n);

    if(col!=-1)
    return memo[row][col]=max(a,max(b,c));
    
    else return max(a,max(b,c));

}

int main(){

    int n;
    cin>>n;

    vector<vector<int>> m(n, vector<int>(3));

    for(int i=0;i<n;i++){
            int a,b,c;
            cin>>a>>b>>c;

            m[i][0]=a;
            m[i][1]=b;
            m[i][2]=c;
    }

   vector<vector<int>> memo(n, vector<int>(3));

   for(int i=0;i<n;i++)
   {
       memo[i][0]=-1;
       memo[i][1]=-1;
       memo[i][2]=-1;
   }

   int row=0,col=-1;

  cout<<solve(m,memo,row,col,n)<<endl;
  

    return 0;
}

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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) (x).begin(),(x).end()
#define endl "\n"

using ll = long long;
using P = pair<int,int>;
using mp =  map<string,int>;

const int MOD = 1e9 + 7;

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

    int h, w, n;
    cin >> h >> w >> n;

    int ans = (n + max(h, w) - 1) / max(h, w) + 0.5;
    cout << ans << endl;


    return 0;
}



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

using namespace std;

const int MAX_N = 123456;
int n, activity_hapns[3][MAX_N], happiness[3][MAX_N];

void highest_hapns(int a) {
    happiness[0][a] = max(happiness[1][a - 1] + activity_hapns[0][a], happiness[2][a - 1] + activity_hapns[0][a]);
    happiness[1][a] = max(happiness[0][a - 1] + activity_hapns[1][a], happiness[2][a - 1] + activity_hapns[1][a]);
    happiness[2][a] = max(happiness[0][a - 1] + activity_hapns[2][a], happiness[1][a - 1] + activity_hapns[2][a]);
}

int main() {

    cin >> n;
    for (int i = 0; i < n; i++)
        for (int j = 0; j < 3; j++)
            cin >> activity_hapns[j][i];

    happiness[0][0] = activity_hapns[0][0];
    happiness[1][0] = activity_hapns[1][0];
    happiness[2][0] = activity_hapns[2][0];
    for (int i = 1; i < n; i++) {
        highest_hapns(i);
    }

    cout << max(happiness[0][n - 1], max(happiness[1][n - 1], happiness[2][n - 1])) << endl;
    return 0;
}

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

using ll = long long;

const int INF = 1001001001;
const ll INF_LL = 1001001001001001001LL;

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

  int dif = -1;
  rep(i,n){
    for(int j = i+1;j<n;j++){
      dif = max(dif,abs(a[i]-a[j]));
    }
  }

  cout << dif << endl;
  
  return 0;
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define pb push_back
#define pi pair<int, int>
#define l first
#define r second
#define all(x) x.begin(), x.end()
#define fori(a, b, step) for (int i = a; i < b; i += step)
#define forj(a, b, step) for (int j = a; j < b; j += step)
#define int long long

const int maxn = 5e5 + 1, CC = 10001;

using namespace std;

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int a, b, c;
    cin >> a >> b >> c;
    int ans = 0;
    if (a + b >= c - 1)
        cout << b + c;
    else
        cout << 2 * b + a + 1;
    return 0;
}


Measured memory_bytes: 3656
n=int(input())
S=list(map(int,input().split()))
q=int(input())
T=list(map(int,input().split()))

def bs(ken,lst):
    left=0
    right=len(lst)
    while (left<right):
        middle=(left+right)//2
        if lst[middle]==ken:
            return 1
        elif lst[middle]<ken:
            left=middle+1
        elif lst[middle]>ken:
            right=middle
    else: return 0

cnt=0
for i in T:
    cnt+=bs(i,S)
print(cnt)


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

inline int gcd(int a,int b){
  return (a%b==0)? b:gcd(b,a%b);
}

int main()
{
  int N;
  cin>>N;
  vector<int> x(N+1);
  for(int i=0;i<=N;i++){
    cin>>x[i];
  }
  sort(x.begin(),x.end());
  vector<int> diff;
  for(int i=0;i<N;i++){
    diff.push_back(x[i+1]-x[i]);
  }
  int ans=diff[0];
  for(int i=1;i<N;i++){
    ans=gcd(ans,diff[i]);
  }
  cout<<ans;
  
}
  

Measured memory_bytes: 1276
import java.util.*; 
public class Main {

  public static void main(String[] args) {
  
  Scanner sc=new Scanner(System.in);
  int a[]=new int[3];
  a[0]=sc.nextInt();
  int b=a[0]/2;



  System.out.println(b*(a[0]-b));
  }
  
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;
typedef long long ll;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,m;cin >> n >> m;
	vector<vector<ll>> a(3,vector<ll>(n));
	rep(j,n) rep(i,3) cin >> a[i][j];
	ll ans=-1000000000000000000;
	for(int i=0;i<(1<<3);++i){
		vector<ll> sum(n);
		rep(j,n){
			rep(k,3){
				if(i&(1<<k)) sum[j]+=a[k][j];
				else sum[j]-=a[k][j];
			}
		}
		sort(sum.begin(),sum.end());
		reverse(sum.begin(),sum.end());
		ll SUM=0;
		rep(j,m) SUM+=sum[j];
		ans=max(SUM,ans);
	}
	cout << ans << endl;
}

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


using namespace std;


#define ll long long
#define mk make_pair
#define pb push_back
#define ff first
#define sc second
#define all(x) x.begin(), x.end()
#define sz(x) (x).size()

ll gcd(ll a, ll b);

ll sum(int n);

void go(){
   string s;cin>>s;
   set<char> cnt;
   for(char ch : s) cnt.insert(ch);
   string ans = cnt.size()==2?"Yes":"No";
   cout << ans;
}
int main(){
   
   ios_base::sync_with_stdio(0);
   cin.tie(0);
   cout.tie(0);

   go();

   return 0;
}

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

ll sum(int n){                
   if(n == 0){
      return n;
   }else{
      return sum(n/10) + n%10;
   }
}


Measured memory_bytes: 256
use proconio::input;

fn main() {
    input! {
        n: usize,
        numbers: [usize; n],
    }

    let m = 1000000007;
    let mut cum = vec![0; n-1];
    let mut ans = 0;

    cum[n-2] = numbers[n-1]; 
    for i in 1..n-1 {
        cum[n-2-i] = (cum[n-1-i] + numbers[n-1-i]) % m; 
    }

    for i in 0..n-1 {
        ans = (ans + ((numbers[i] * cum[i]) % m)) % m; 
        //println!("ans {}", ans);
    }

    println!("{}", ans);
}


Measured memory_bytes: 7216
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();
// freopen("input.txt", "r", stdin);

int main() {
    int k, a, b;
    cin >> k >> a >> b;
    if (a%k == 0 || (b/k-a/k) > 0)
        cout << "OK" << endl;
    else
        cout << "NG" << endl;
    return 0;
}


Measured memory_bytes: 3668
n,y = gets.split(' ').map(&:to_i)
y = y/1000
ans = '-1 -1 -1'

for c in 0..y
	if ((10 * n - y - 9 * c) % 5) == 0
		b = (10 * n - y - 9 * c) / 5
		a = n - b - c
		if c <= n && b >= 0 && a >= 0
			ans = a.to_s + ' ' + b.to_s + ' ' + c.to_s
			break
		end
	end
end
puts ans


Measured memory_bytes: 3836
x,y,z,k = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))

AB = []
for xi in range(x):
  for yi in range(y):
    AB.append(A[xi]+B[yi])

AB = sorted(AB,reverse=True)
C = sorted(C,reverse=True)

i=0
j=0

ABC = []
for ab in AB[:k]:
  for c in C[:k]:
    ABC.append(ab+c)

ABC = sorted(ABC,reverse=True)
for abc in ABC[:k]:
  print(abc)

Measured memory_bytes: 145352
#include<bits/stdc++.h>
using namespace std;
struct I{
    I(){
	ios::sync_with_stdio(false);cin.tie(0);
	cout<<fixed;
	cout<<setprecision(10);
    }
}init;

typedef long long LL;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
#define rep(i,n) for(auto i=(n)*0;i<n;i++)
#define range(i,n) for(auto &i:n)


int main(){
    for(int n,d;cin>>n>>d,n+d;){
	VV c(n);
	V m(n);
	rep(i,n){
	    cin>>m[i];
	    c[i].resize(m[i]+1);
	    c[i][0]=0;
	    rep(j,m[i]){
		cin>>c[i][j+1];
		c[i][j+1]+=c[i][j];
	    }
	    reverse(c[i].begin(),c[i].end());
	}
	int lb=0,id=0;
	for(bool update=true;update;){
	    update=false;
	    rep(i,n)if(i!=id)while(m[i]>0&&c[i][m[i]-1]<=lb+d)m[i]--,update=true;

	    lb=1145141919;
	    rep(i,n)if(i!=id)lb=min(lb,c[i][m[i]]);
	    while(m[id]>0&&c[id][m[id]-1]<=lb+d)m[id]--,update=true;
	    lb=min(lb,c[id][m[id]]);
	    rep(i,n)if(c[i][m[i]]==lb)id=i;
	}
	int check=0;
	rep(i,n)check+=m[i];
	if(check>0)cout<<"No"<<endl;
	else cout<<"Yes"<<endl;
    }
    return 0;
}

Measured memory_bytes: 3216
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;

string S;
int N;

int nxt[200020][26];
int dp[200020];

int main(){
  cin>>S;
  N=S.size();

  for(int i=0;i<=N;i++) for(int j=0;j<26;j++) nxt[i][j]=N;

  for(int i=N-1;i>=0;i--){
      for(int k=0;k<26;k++){
          nxt[i][k]=nxt[i+1][k];
      }
      nxt[i][S[i]-'a']=i;
  }

  for(int i=0;i<=N;i++) dp[i]=N;
  dp[N]=0;
  for(int i=N-1;i>=0;i--){
      for(int k=0;k<26;k++){
          dp[i]=min(dp[i],dp[nxt[i+1][k]]+1);
      }
  }

  string ans="";
  int now=0;
  while(now<N){
      int mi=N;
      for(int k=0;k<26;k++) mi=min(mi,dp[nxt[now][k]]);

      for(int k=0;k<26;k++){
          if(dp[nxt[now][k]]==mi){
              ans+=string(1,char('a'+k));
              now=nxt[now][k]+1;
              break;
          }
      }
  }
  cout<<ans<<endl;



  return 0;
}


Measured memory_bytes: 21764
#include <bits/stdc++.h>
using namespace std;
#define pii pair <int, int>
#define ll long long
#define pdd pair <double, double>
#define pll pair <ll, ll>
#define pb push_back
#define vi vector <int>
#define vvi vector <vi>
#define PI 3.14159
int main(){
    ios::sync_with_stdio(0);cin.tie(nullptr);
    int dias, tarefas, temporario;
    cin>>dias>>tarefas;
    for(int i=0; i<tarefas;i++){
        cin>>temporario;
        dias -= temporario;
    }
    if(dias <= -1){
        cout<<-1<<endl;
    }else{
        cout<<dias<<endl;
    }
}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
//#define ll long long
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 (a>b) { a=b; return 1; } return 0; }
#define rep(i, n) REP(i, 0, n)
#define rep_rev(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define all(x) (x).begin(),(x).end()
ll t1,t2,t3;
const ll mod = 1000000007;
const int INF = 1e9;
const ll INFLONG = 1e18;

int main(){
  string s,t;
  cin >> s;
  cin >> t;
  ll sum = 0;
  ull len = s.size();
  rep(i,len){
    if(s[i] != t[i]){
      sum++;
    }
  }
  cout << sum << endl;
}

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

int main(){
    int d[5], m[5];
    for(int i = 0; i < 5; i++){
        cin >> d[i];
        m[i] = d[i] % 10;
        if(m[i] == 0){
            m[i] = 10;
        }
    }

    int mn = m[0];
    for(int i = 1; i < 5; i++){
        mn = min(mn, m[i]);
    }

    int ans = 0;
    for(int i=0; i<5; i++){
        ans += ceil(d[i] / 10.0) * 10;
    }

    ans -= 10;
    
    if(mn < 10){
        ans += mn;
    }else{
        ans += 10;
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
	string a, b;
	cin >> a >> b;
	b += b;
	for (int i = 0; i < a.size(); i++) {
		bool flag = true;
		for (int j = 0; j < a.size(); j++) {
			if (a[j] != b[j + i])flag = false;
		}
		if (flag) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
A1,A2,A3 = map(int,input().split())

#A1 cost=0
A11 = abs(A2-A1) + abs(A3-A2)
A12 = abs(A3-A1) + abs(A2-A3)

#A2 cost=0
A21 = abs(A1-A2) + abs(A3-A1)
A22 = abs(A3-A2) + abs(A1-A3)

#A3 cost=0
A31 = abs(A1-A3) + abs(A2-A1)
A32 = abs(A2-A3) + abs(A1-A2)

print(min(A11,A12,A21,A22,A31,A32))

Measured memory_bytes: 3064
#include <iostream>
using namespace std;
int A[1000][1000]={{}};
int b[1000]={};
int main(void){
  int n, m, i, j;
  int sum;


  cin >> n >> m;

  for(i=0; i<n; i++){
      for(j=0;j<m;j++){
          cin >> A[i][j];
      }
  }

  for(i=0; i<m; i++){
      cin >>b[i];
  }


  for(i=0; i<n; i++){
      sum = 0;
      for(j=0; j<m; j++){
          sum += A[i][j] * b[j];
      }
      cout << sum << endl;
  }
}


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

int main() {
    unsigned int K;
	cin >> K;
	queue<long long> q;
	for(int i=1;i<=9;i++)q.push(i);
	long long ans;
	for(int i=1;i<=K;i++){
		ans=q.front();
		q.pop();
		if(ans%10)q.push(10*ans+(ans%10)-1);
		q.push(10*ans+(ans%10));
		if(ans%10!=9)q.push(10*ans+(ans%10)+1);
	}


    cout << ans << endl;
    // cout << lunlun(to_string(K),vec) <<endl;
    return 0;
}


Measured memory_bytes: 1792
mod = 10**9+7
N = int(input())


def mod_factorials(n, m):
    mod_factorials = [1] * (n + 1)
    for i in range(1, n+1):
        mod_factorials[i] = mod_factorials[i-1]*i
        mod_factorials[i] %= m
    return mod_factorials

# 1!,2!,3!,...,n! �εո� (mod m)
def mod_inv_factorials(n, m):
    mod_invs = [1] * (n + 1)
    invs = [1] * (n + 1)
    for i in range(2, n + 1):
        invs[i] = m - invs[m % i] * (m//i) % m

    for i in range(1, n+1):
        mod_invs[i] = invs[i]*mod_invs[i-1]
        mod_invs[i] %= m
    return mod_invs

if N == 1:
    print(0)
else:
    ans = 0
    pow8 = [1]*(N+1)
    pow2 = [1]*(N+1)
    mod_facts = mod_factorials(N,mod)
    mod_invs = mod_inv_factorials(N,mod)
    for i in range(1,N+1):
        pow8[i] = pow8[i-1]*8
        pow8[i] %= mod
        pow2[i] = pow2[i-1]*2
        pow2[i] %= mod

    for k in range(2,N+1):
        ans += mod_facts[N]*mod_invs[k]*mod_invs[N-k]*(pow2[k]-2)*pow8[N-k]
        ans %= mod
    ans %= mod 


    print(ans)




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

int main() {
    string a, b;
    cin >> a >> b;

    string A, B;
    for (int i = 0; i < stoi(b); i++) A += a;
    for (int i = 0; i < stoi(a); i++) B += b;

    cout << min(A, B) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<map>
#include<cstdio>
#include<vector>
#include<cstdlib>

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

using namespace std;

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

struct Point{
	int x,y;
	bool operator<(const Point &p)const{ return make_pair(x,y)<make_pair(p.x,p.y); }
};

typedef pair<Point,Point> Futon;

int n,mark[40000];
vector<int> adj[40000];

bool issame(int u,int v){ return abs(u-v)==n; }

bool dfs(int u){
	rep(i,adj[u].size()){
		int v=adj[u][i];
		if(mark[v]==-1){
			if(issame(u,v)) mark[v]=1-mark[u];
			else            mark[v]=mark[u];
			if(!dfs(v)) return false;
		}
		else{
			if(!issame(u,v) && mark[u]!=mark[v]
			||  issame(u,v) && mark[u]==mark[v]) return false;
		}
	}

	return true;
}

int main(){
	for(;scanf("%d",&n),n;){
		Point futon[40000];
		map<Point,int> f;
		rep(j,n){
			int x,y;
			char dir; scanf("%d%d %c",&x,&y,&dir);

			futon[j]=(Point){x,y};
			if(dir=='x') futon[n+j]=(Point){x+1,y};
			if(dir=='y') futon[n+j]=(Point){x,y+1};

			f[futon[ j ]]=j;
			f[futon[n+j]]=n+j;
		}

		rep(u,2*n){
			adj[u].clear();
			rep(k,4){
				int x=futon[u].x+dx[k];
				int y=futon[u].y+dy[k];
				Point p={x,y};
				if(f.count(p)) adj[u].push_back(f[p]);
			}
		}

		bool ok=true;
		rep(u,2*n) mark[u]=-1;
		rep(u,2*n) if(mark[u]==-1) {
			mark[u]=0;
			if(!dfs(u)){ ok=false; break; }
		}

		puts(ok?"Yes":"No");
	}

	return 0;
}

Measured memory_bytes: 0
/**In the name of Allah, the Most Merciful, the Most Merciful.**/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define INF 9223372036854775806
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define PI 2*acos(0.0)
#define EPS 1e-9
ll max(ll a,ll b) {if(a>b) return a; else return b;}
ll min(ll a,ll b) {if(a<b) return a; else return b;}

int main()
{
    ll a[20]={0},b[20]={0};
    ll sum=0,last=1,p=1;
    for(int i=1;i<=11;i++){
        p=p*26;
        sum+=p;
        a[i]=last; b[i]=sum;
        last=sum+1;
    }

    ll n;
    cin>>n;

    int len=0;
    for(int i=1;i<=11;i++){
        if(a[i]<=n && b[i]>=n){
            len=i;
            break;
        }
    }

    string ans="";
    for(int i=1;i<=len;i++){
        n-=1;
        int r=n%26;
        ans+=(r+97);
        n/=26;
    }
    reverse(ans.begin(),ans.end());
    cout<<ans<<endl;

    return 0;
}




Measured memory_bytes: 3624
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A = Integer.parseInt(sc.next());
        int B = Integer.parseInt(sc.next());
        sc.close();

        int sum = 1;
        int cnt = 0;
        while (sum < B) {
            sum += A-1;
            cnt++;
        }
        System.out.println(cnt);
    }
}

Measured memory_bytes: 23124
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
#define Priq priority_queue<int,vi,greater<int>>
#define pb push_back
#define mp make_pair
#define INF (1ll<<62)-1
#define MAX 1000000000
signed main(){
    int N; cin>>N;
    vi A(N),B(N);
    rep(i,0,N) cin>>A[i];
    rep(i,0,N) cin>>B[i];
    priority_queue<pii> Q;
    rep(i,0,N) Q.push(mp(B[i],i));
    int ans=0;
    while(Q.size()>0){
        int X=Q.top().first,Y=Q.top().second; Q.pop();
        int P=(Y-1+N)%N,R=(Y+1)%N;
        int S=B[P]+B[R];
        if(X<A[Y]){
            cout<<-1<<endl;
            return 0;
        }
        int Z=(X-A[Y]);
        int C=X-Z/S*S;
        if(C==A[Y]){
            B[Y]=A[Y];
            ans+=Z/S;
        }
        else if(B[Y]==C){
            cout<<-1<<endl;
            return 0;
        }
        else{
            B[Y]=C;
            ans+=Z/S;
            Q.push(mp(C,Y));
        }
    }
    cout<<ans<<endl;
}


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

  
int main() {
	int N,K;
  cin >> N >> K;
  vector<int> h(N);
  for(int i=0;i<N;i++){
	cin >> h[i];
  }
  int ans =0;
  for(int i=0;i<N;i++){
   if(K <= h[i]) ans++ ;
  }
  cout << ans <<endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

const int N = 200000;
set<int> A[N],B[N];
int ca[N]={}, cb[N]={};

int main(){
    int n,m;
    string s;
    cin >>n >>m >>s;

    rep(i,m){
        int a,b;
        cin >>a >>b;
        --a;
        --b;

        if(s[a] == 'A') A[b].insert(a);
        else B[b].insert(a);

        if(s[b] == 'A') A[a].insert(b);
        else B[a].insert(b);
    }

    vector<bool> alive(n,true);
    queue<int> que;
    rep(i,n){
        ca[i] = A[i].size();
        cb[i] = B[i].size();

        if(ca[i]==0 || cb[i]==0){
            alive[i] = false;
            que.push(i);
        }
    }
    while(!que.empty()){
        int v = que.front();
        que.pop();
        // dbg(v);

        for(int nx:A[v]){
            if(s[v]=='A'){
                --ca[nx];
                if(alive[nx] && ca[nx]==0){
                    alive[nx] = false;
                    que.push(nx);
                }
            }
            else{
                --cb[nx];
                if(alive[nx] && cb[nx]==0){
                    alive[nx] = false;
                    que.push(nx);
                }
            }
        }
        for(int nx:B[v]){
            if(s[v]=='A'){
                --ca[nx];
                if(alive[nx] && ca[nx]==0){
                    alive[nx] = false;
                    que.push(nx);
                }
            }
            else{
                --cb[nx];
                if(alive[nx] && cb[nx]==0){
                    alive[nx] = false;
                    que.push(nx);
                }
            }
        }
    }

    // rep(i,n){
    //     dbg(ca[i]);dbg(cb[i]);
    // }

    string ans = "No";
    rep(i,n)if(alive[i]) ans = "Yes";
    cout << ans << endl;
    return 0;
}


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

int main() {
  int a, b;
  cin >> a >> b;
  
  if(a <= b){
    for(int i = 0; i < b; i++){
      cout << a;
    }
  }else{
    for(int i = 0; i < a; i++){
      cout << b;
    }
  }
  cout << endl;
}

Measured memory_bytes: 3604
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <math.h>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <functional>
#include <assert.h>
#define int long
#define ll long long
#define rep(i, n) for(int i = 0; i < n; i++)
const int INF = 1e9;
using namespace std;

signed main() {
    int A,B; cin >> A >> B;
    if(A<10 && B<10) cout << A*B << endl;
    else cout << -1 << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define INF (1e9)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
const long double PI = acos(-1.0L);
const long long MOD = 1000000007LL;
// const long long MOD = 998244353LL;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
template<class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true;} return false; }
template<class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true;} return false; }
//////////////////////////////////////////////////////////////////////////////////////////////////////////

bool check[200000];

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    ll N,K; cin >> N >> K;
    vector<int> A(N);
    rep(i,N) {
        cin >> A[i];
        A[i]--;
    }

    vector<vector<int>> G(200000);
    rep(i,N) G[A[i]].emplace_back(i);
    rep(i,N) G[A[i]].emplace_back(N+i);

    vector<vector<ll>> D(100, vector<ll>(N));
    int cnt;
    rep(i,N) {
        D[0][i] = (*upper_bound(all(G[A[i]]),i) + 1) - i;
    }
    for (int i = 1; i < 100; i++) {
        cnt = i;
        for (ll j = 0; j < N; j++) {
            D[i][j] = D[i-1][j] + D[i-1][(D[i-1][j]+j)%N];
        }
        cout << endl;
        if (D[i][0] >= N*K) break;
    }
    ll num = 0;
    ll L = N*K;
    while (cnt >= 0) {
        if (D[cnt][num] <= L) {
            L -= D[cnt][num];
            num = (num + D[cnt][num])%N;
        } else cnt--;
    }
    vector<int> ans;
    rep(_,L) {
        if (check[A[num]]) {
            while (check[A[num]]) {
                check[*ans.rbegin()] = false;
                ans.pop_back();
            }
        } else {
            check[A[num]] = true;
            ans.emplace_back(A[num]);
        }
        num++;
    }

    for (auto i : ans) cout << i+1 << " ";
    cout << endl;
}

Measured memory_bytes: 171620
#include<stdio.h>
#define MAX 100000

int partition(int A[],int n,int p,int r){
  int x,i,j,t;
  x=A[r];
  i=p-1;
  for(j=p;j<r;j++){
    if(A[j]<=x){
      i++;
      t=A[i];
      A[i]=A[j];
      A[j]=t;
    }
  }
  t=A[i+1];
  A[i+1]=A[r];
  A[r] = t;
  return i+1;
}

main(){
  int A[MAX],n,i,q;
  scanf("%d",&n);
  for (i=0;i<n;i++)scanf("%d", &A[i]);
  q=partition(A,n,0,n-1);

  for(i=0;i<n;i++){
    if(i)printf(" ");
    if(i==q)printf("[");
    printf("%d", A[i]);
    if(i==q)printf("]");
  }
  printf("\n");

  return 0;
}



Measured memory_bytes: 2164
def solve():
    a, b = list(map(int, input().split()))
    
    if a == 0 and b == 0:
        print(0)
        return
    
    if a == 0:
        ans = b * (b - 1) // 2
        print(ans)
        return

    if b == 0:
        ans = a * (a - 1) // 2
        print(ans)
        return
    
    ans = a * (a - 1) // 2
    ans += b * (b - 1) // 2
    print(ans)
    return

if __name__ == "__main__":
    solve()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define LL long long int
using namespace std;
int const MAXN = 1e6+5;
int main (){
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    int a, b,c;
    cin >> a >> b >> c;
    if (a + b + c >= 22)
        cout << "bust";
    else cout << "win";

}


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

int main() {
    int a[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int k;
    cin >> k;
    cout << a[k-1] << endl;
    return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var n, x, t int
	fmt.Scan(&n, &x, &t)
	if n%x == 0 {
		fmt.Println((n / x) * t)
	} else {
		fmt.Println((n/x + 1) * t)
	}
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

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

func abs(n int) int {
	if n < 0 {
		return -n
	}
	return n
}


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

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	int a, b, c;
	cin >> a >> b >> c;
	if (a == b && b == c) {
		if (a % 2 == 0) {
			cout << -1 << '\n';
			return 0;
		} else {
			cout << 0 << '\n';
			return 0;
		}
	}
	int cnt = 0;
	while (a % 2 == 0 && b % 2 == 0 && c % 2 == 0) {
		int tempA = a, tempB = b, tempC = c;
		tempA = (a + b) / 2;
		tempB = (b + c) / 2;
		tempC = (c + a) / 2;
		a = tempA;
		b = tempB;
		c = tempC;
		cnt++;
	}
	cout << cnt << '\n';

	return 0;
}


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

int main(){
    /*#ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        //freopen("test.txt","r",stdin);
        //freopen("output.txt","w",stdout);
    #endif*/
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout<<fixed;
 
    int n;cin>>n;
    vector<int> v(n);
    for(int i=0;i<n;i++){
        cin>>v[i];
      	
        if(i == 0){v[i]--;continue;}
        if(v[i] > v[i - 1])v[i]--;
        if(v[i] < v[i - 1]){
            cout<<"No";
            return 0;
        }
    }
    cout<<"Yes";

    /*#ifndef ONLINE_JUDGE
        cout << "\nTime Elapsed : " << 1.0 * clock() << " ms\n";
    #endif*/
    return 0;
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s= sc.next();
		String t = sc.next();
		int min = Integer.MAX_VALUE;
		for (int i=0;i<=s.length()-t.length();i++) {
			int temp =0;
			for (int j=0;j<t.length();j++) {
				if (s.charAt(i+j)!=t.charAt(j)) {
					temp++;
				}
			}
			if (temp<min) {
				min = temp;
			}
		}
		System.out.println(min);
	}
}

Measured memory_bytes: 35620
import java.util.*;
import static java.lang.System.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		ArrayList<Rebyu> sortedList = new ArrayList<>();
		ArrayList<Rebyu> list = new ArrayList<>();
		for (int i = 0; i < n; i++) {
			String name = sc.next();
			int score = sc.nextInt();
			Rebyu r1 = new Rebyu(score, name);
			Rebyu r2 = new Rebyu(score, name);
			sortedList.add(r1);
			list.add(r2);	
		}
		Collections.sort(sortedList);
		for(int i = 0; i < n; i++) {
			Rebyu r1 = sortedList.get(i);
			for(int j = 0; j < n; j++) {
				Rebyu r2 = list.get(j);
				if ( r1.name.equals(r2.name) && r1.score == r2.score) {
					out.println(j + 1);
					break;
				}
			}
		}
		
	}
	static class Rebyu implements Comparable<Rebyu>{
		int score;
		String name;
		Rebyu(int score, String name){
			this.score = score;
			this.name = name;
		}
		@Override
		public int compareTo(Rebyu o) {
			int res = this.name.compareTo(o.name);
			if (res != 0)
				return res;
			
			return  - (Integer.compare(this.score, o.score));
			
		}
	}
}

Measured memory_bytes: 23124
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<math.h>
using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define in(x) cin >> x
#define out(str) cout << str << endl

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; }



int main(){
    rep(i,9){
        rep(j,9){
            cout<<i+1<<"x"<<j+1<<"="<<(i+1)*(j+1)<<endl;
        }
    }
}



Measured memory_bytes: 3096
using System;
internal class Program
{
    private static void Main(string[] args)
    {
        string text = Console.ReadLine();
        string value = string.Empty;
        switch (text)
        {
            case "Sunny":
                value = "Cloudy";
                break;
            case "Cloudy":
                value = "Rainy";
                break;
            case "Rainy":
                value = "Sunny";
                break;
        }
        Console.WriteLine(value);
    }
}

Measured memory_bytes: 13140
a, b= map(int, input(). split())
while a != 0 and b!= 0:
  for i in range(a):
    for j in range(b):
        if (i + j) % 2 == 0:
            print("#", end="")
        else:
            print(".", end="")
    print("")
  print("")
  a, b= map(int, input(). split())



Measured memory_bytes: 7012
package main

import (
	"fmt"
)

func main() {
	var a int
	var s string
	fmt.Scan(&a)
	fmt.Scan(&s)

	var half = a / 2

	if s[:half] == s[half:] {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}

}

Measured memory_bytes: 512
n = int(input())
a = [int(i) for i in input().split()]
if n == 0 and a[0] == 1:
    print(1)
    exit()
b = []
i = 0
for j in reversed(a):
    i += j
    b.append(i)
b.reverse()
ans = 1
if a[0] != 0:
    print(-1)
    exit()
i = 1
for j, k in zip(a[1:], b[1:]):
    if j > i*2:
        print(-1)
        exit()
    i = min(k, i * 2) - j
    ans += i + j
    if i < 0:
        print(-1)
        exit()
print(ans)


Measured memory_bytes: 20164
n,a,b=map(int,input().split())
m=10**9+7
def c(x,r=1):
 for i in range(x):r=r*(n-i)*pow(i+1,m-2,m)%m
 return r
print((pow(2,n,m)-1-c(a)-c(b))%m)

Measured memory_bytes: 3060
a, b, c = map(int, input().split())

result = 0
available_pair = min(b,c)
result += (2 * available_pair)
b -= available_pair
c -= available_pair

if c > 0:
  result += min(c, a)
  c -= min(c, a)
  if c > 0:
    result += 1
else:
  result += b
print(result)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e6+5;
const ll mod = 1e9+7;
const ll INF = 0x3f3f3f3f;
class node{
    public:
	ll x,y;
}p[N];

bool cmp(node a,node b)
{
	return a.y < b.y;
}

int main()
{
	ll i,j,k,n,m,x,y;
	cin>>n>>m;
	for(i = 0;i < m;i++)
	{
		cin>>p[i].x>>p[i].y;
	}
	sort(p,p+m,cmp);
	ll l = 0,sum = 0;
	for(i = 0;i < m;i++)
	{
		if(p[i].x >= l)
		{
			l = p[i].y;
			sum++;
		}
	}
	cout<<sum<<endl;
}




Measured memory_bytes: 1792
#define _USE_MATH_DEFINES

#include <iostream>
#include <string>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <vector>

using namespace std;

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

	vector<int> a(n);

	for (int i = 0; i < n; i++)
	{
		cin >> a.at(i);
	}

	int c = 1;
	for (int i = n - k; i > 0; i -= (k-1))
	{
		c++;
	}
	cout << c << endl;
}

Measured memory_bytes: 640
/*
オーダー
10**6	余裕を持って間に合う	
10**7	おそらく間に合う	余裕を持って間に合う
10**8	非常にシンプルな処理でない限り厳しい	おそらく間に合う
10**9		非常にシンプルな処理でない限り厳しい
logn	:OK
n		:10^7
nlogn	:10^6
n**2	:10^4
n**3	:300
2**n	:20
n!		:10



// 各桁の和を計算する関数
int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) { // n が 0 になるまで
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

sort(a, a + N, greater<int>());  // a[0:N] を大きい順にソート

int num[110] = {0};  // バケット
for (int i = 0; i < N; ++i) {
    num[d[i]]++;  // d[i] が 1 個増える
}

map<string, int> mp; // 連想配列 map<キー型, 値型> オブジェクト名
for (int i = 0; i < N; ++i) {
    auto itr = mp.find(s[i]);        // s[i] が設定されているか？
    if(itr != mp.end() ) {
         mp[s[i]] += 1;
    }
    else {
         mp[s[i]] += 1 ;
    }
}
stack<int> s;	//intをデータとするスタックを用意
s.push(1);		//{} -> {1}
printf("%d\n", s.top());	// 3
s.pop();

queue<int> que;	//intをデータとするキューを用意
que.push(1);		//{} -> {1}
printf("%d\n", que.front());	// 1
que.pop();
*/
#include <iostream>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <string.h>

using namespace std;

// #define for(i,a,b) for (int i=(a);i<(b);++i)
typedef long long ll;
typedef pair<ll,ll> P;
#define REP(i,n) for(long long i = 0; i < (long long)(n); i++)
#define pb push_back // vectorに要素追加
#define INF (ll)1e18
// int 
// // 各桁の和を計算する関数
// int findSumOfDigits(int n) {
//   int amari = 0;
//   int keta = 0;
//   while (n > 0) { // n が 0 になるまで
//     amari += n % 2;
//     if (keta%2==0)
//     n /= 10;
//   }
//   return sum;
// }
const ll MAX_N = 1e5;
ll N;
ll h[MAX_N];
ll dp[MAX_N+1]; // メモ化テーブル
 
// i番目以降の品物から重さの総和がj以下になるように選ぶ
void rec(ll i){
	if (i==0) dp[i] = 0;
	else if (i==1) dp[i] = abs(h[1]-h[0]);
	else dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]));
	return;
}

int main() {
	// 入力
	ll N,D;
	cin >> N>>D;
	
	// 解法
	ll ans = (N-1) / (2 * D + 1) + 1;
	
	// REP(i,N) printf("%d\n", dp[i]);
	printf("%lld\n", ans);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define x first
#define y second
#define mp make_pair
#define up_b upper_bound
#define low_b lower_bound
#define sz(x) (int)x.size()
#define bit __builtin_popcount
#define all(x) x.begin(),x.end()
#define show(x) cout<<(#x)<<" is "<<(x)<<endl

using namespace std;
using namespace __gnu_pbds;

template<typename T> using indexed_set=tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef pair<int,ll> pil;
typedef pair<ll,int> pli;

const ll INF=1e18+123;
const ld EPS=1e-9;
const int inf=1e9+123;
const int MOD=1e9+7;
const int N=1e5+123;
const int M=1e6+123;
const int dx[]={0,0,1,-1};
const int dy[]={1,-1,0,0};

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n,m;
    string s,t;
    cin>>n>>m>>s>>t;
    ll ans=1ll*n*m/__gcd(n,m);
    for(int i=0,j=0;i<m && j<n;){
        if(s[j]!=t[i]){
            cout<<-1;
            return 0;
        }
        j+=ans/m;
        i+=ans/n;
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 640
from collections import Counter

item = str(input())
longest = [0,0]
shortest = [len(item),len(item)]
current = 1

def exchange(item):
    for i in range(1, len(item)):
        if item[i-1] != item[i]:
            return max(exchange(item[0:i]), exchange(item[i:]))
    return len(item)

N = len(item)
T = N
for k in range(1, N):
    if item[k-1] != item[k]:
        tmp = max(k, N-(k))
        if T >= tmp:
            T = tmp

print(T)


Measured memory_bytes: 3572
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <map>
#include <utility>
#include <set>
#include <climits>

using namespace std;

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

char s[100005];

int main() {
    scanf("%s", s);
    int len = strlen(s);
    int num0 = 0, num1 = 0;
    for (int i = 0; i < len; ++i) {
        if (s[i] == '0') {
            ++num0;
        }
    }
    num1 = len - num0;
    printf("%d\n", min(num0, num1) * 2);
    return 0;
}



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

int gcd(int p,int q){
  if(p%q==0)return q;
  else return gcd(q,p%q);
}

int main() {
  int N;
  cin>>N;
  int sum=0;
  for(int i=0;i<N;i++){
    for(int j=0;j<N;j++){
      for(int k=0;k<N;k++){
        sum+=gcd(gcd(i+1,j+1),k+1);
      }
    }
  }
  cout<<sum<<endl;
}


Measured memory_bytes: 3636
/*      ░░█ ▄▀█ █   █▀ █░█ █▀█ █▀▀ █▀▀   █▀█ ▄▀█ █▀▄▀█
        █▄█ █▀█ █   ▄█ █▀█ █▀▄ ██▄ ██▄   █▀▄ █▀█ █░▀░█     */

// Author : Udit "luctivud" Gupta @ (https://www.linkedin.com/in/udit-gupta-1b7863135/)


#include <bits/stdc++.h>
#pragma GCC optimize "trapv"

using namespace std;

typedef long long int lld;
typedef unsigned long long int llu;


#define       TESTCASES()  cin >> (T3X0); T353 = T3X0; while(T3X0--)
#define       _input(V3C)  for(auto &V3C_I7 : (V3C)) cin >> (V3C_I7)
#define mems(A77AY, V4LU)  memset((A77AY), (V4LU), sizeof((A77AY)))
#define  CH3K(I7, E4, S7)  (((S7)<0) ? (I7)>(E4) : (I7)<(E4))
#define for4(I7,S4,E4,S7)  for(auto I7=(S4); CH3K(I7,E4,S7); (I7)+=(S7))




void solveEachTest(lld T35TC453N = 1) {

	string s; cin >> s;
	cout << *s.begin() << (lld) s.length() - 2 << *s.rbegin();
	return;
}


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

	lld T3X0 = 0, T353 = 1;

	// TESTCASES()
	solveEachTest(T353 - T3X0);
	return 0;
}
// Random Thought :  null

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 300
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef vector<vector<int>> Matrix;
typedef unordered_set<int> us;

int n;
Matrix s;

void input() {
    cin >> n;
    s = Matrix(n, vector<int>(n, INF));
    rep(i, n) {
        string x;
        cin >> x;
        s[i][i] = 0;
        rep(j, n) if (x[j] == '1') s[i][j] = 1;;
    }
}

bool not_bin_graph() {
    us g1, g2, now, next, visit;
    g1.insert(0);
    now.insert(0);
    visit.insert(0);
    while (true) {
        for (int i : now) visit.insert(i);
        for (int i : now) {
            for (int j = 0; j < n; j++) {
                if (s[i][j] == 1) {
                    g2.insert(j);
                    if (!visit.count(j)) next.insert(j);
                }
            }
        }
        if (next.size() == 0) break; 
        now = next;
        next.clear();
        swap(g1, g2);
    }
    if (g1.size() > g2.size()) swap(g1, g2);
    for (int x : g1) if (g2.count(x)) return true;
    return false;
}

void warshall_floyd() {
    rep(k, n)rep(i, n)rep(j, n) s[i][j] = min(s[i][j], s[i][k] + s[k][j]);
}

int main() {
    input();
    if (not_bin_graph()) {
        cout << -1 << endl;
        return 0;
    }
    warshall_floyd();
    int ans = 0;
    rep(i, n)rep(j, n) {
        if (s[i][j] == INF) continue;
        ans = max(ans, s[i][j]);
    }
    cout << ans + 1 << endl;
}


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

using ll = long long;
using ull = unsigned long long;

#define MOD 1000000007

int main(void) {
    ll x1, y1, x2, y2;
    ll diff[2];
    ll cords[2][2];
    cin >> x1 >> y1 >> x2 >> y2;
    diff[0] = x2 - x1;
    diff[1] = y2 - y1;
    cords[0][0] = x2 - diff[1];
    cords[0][1] = y2 + diff[0];
    cords[1][0] = x1 - diff[1];
    cords[1][1] = y1 + diff[0];
    cout << cords[0][0] << ' ' << cords[0][1] << ' ' << cords[1][0] << ' ' << cords[1][1] << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <set>
#include <map>
#include <cassert>
#include <cstring>
#include <cstdio>
#include <cstdlib>
using namespace std;

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

	int a, b, c;
	scanf("%d%d%d", &a, &b, &c);
	c -= a - b;
	if (c < 0) c = 0;
	printf("%d\n", c);
}


Measured memory_bytes: 384
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in);) {
            new Main().solve(sc);
        }
    }

    void solve(Scanner sc) {
        long x = sc.nextLong();
        long y = sc.nextLong();
        int ans = 0;
        while (x <= y) {
            x *= 2l;
            ans++;
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 23252
#include<stdio.h>

int main()
{
  int fi[1001];
  int b1 = 1, b2 = 1, now;
  int k;
  int V, d;
  int j, last = -1;
  int ans = 1;
  int i=0;
  while(scanf("%d %d", &V, &d) != EOF)
    {
      for(i=0; i<1001; i++)
	{
	  fi[i] = 0;
	}
      for(k=0; k<V; k++)
	{
	  now = (b1 + b2) % 1001;
	  fi[now] = 1;
	  b2 = b1;
	  b1 = now;
	}
      for(j=0; j<=1000; j++)
	{
	  if(fi[j]==1)
	    {
	      if(last >= 0 && j - last >= d)
		{
		  ans++;
		  last = j;
		}
	      else
		{
		  last = j;
		}
	    }
	}
      printf("%d\n", ans);
      b1 = 1;
      b2 = 1;
      last = -1;
      ans = 1;
    }
  return 0;
}

Measured memory_bytes: 600
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <string>

using namespace std;

int main() {
	string s, t, u;
	int a, b;

	cin >> s >> t;
	cin >> a >> b;

	cin >> u;

	if (s == u) {
		a--;
	}
	else if (u == t) {
		b--;
	}

	cout << a << " " << b;


	return 0;
}

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

int main() {
  string s;
  cin >> s;
  bool ans = (s.find('a') != string::npos) + (s.find('b')  != string::npos) + (s.find('c') != string::npos) == 3;
  cout << (ans ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <limits.h>
#include <math.h>
#include <functional>
#include <bitset>
#include <iomanip>

#define repeat(i,n) for (long long i = 0; (i) < (n); ++ (i))
#define debug(x) cerr << #x << ": " << x << '\n'
#define debugArray(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i] << '\n'
#define debugArrayP(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i].first<< " " << x[i].second << '\n'

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef vector<int> vint;
typedef vector<ll> vll;
const ll INF = INT_MAX;
const ll MOD = 1e9+7;


int main(){
  int X,Y,Z;cin>>X>>Y>>Z;
  vector<string> v(X+Y+Z);
  repeat(i,X)v[i]="a";
  repeat(i,Y)v[X+i]="b";
  repeat(i,Z)v[X+Y+i]="c";
  while(v.size()>1){
    sort(v.begin(),v.end());
    v[0]+=v.back();
    v.pop_back();
  }
  cout<<v[0]<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
int n,m,num[4],nei[400005],cnt,vis[800004],shu[800004];
int tot=1,fir[400005],to[800005],nxt[800005];
void add(int u,int v)
{
    nxt[++tot]=fir[u],fir[u]=tot,to[tot]=v;
}
void dfs(int u,int e,int&op,int&jsq,int dis)
{
    if(vis[u])return op=max(op,(dis-vis[u])&1),void();
    vis[u]=dis,++jsq;
    for(int i=fir[u];i;i=nxt[i])
        if(i/2!=e)dfs(to[i],i/2,op,jsq,dis+1);
}
int main()
{
    cin>>n>>m;
    for(int i=1,u,v;i<=m;++i)
        scanf("%d%d",&u,&v),add(u,v),add(v,u);
    for(int i=1;i<=n;++i)
    {
        if(vis[i])continue;
        int op=0,jsq=0;
        dfs(i,0,op,jsq,1);
        if(jsq==1)op=2;
        ++num[op];
        nei[++cnt]=op;
        shu[cnt]=jsq;
    }
    long long ans=0;
    for(int i=1;i<=cnt;++i){
        if(nei[i]==1)ans+=num[0]+num[1],ans+=num[2]*shu[i];
        else if(nei[i]==0)ans+=2*num[0]+num[1],ans+=num[2]*shu[i];
        else ans+=n;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 14848
#include<bits/stdc++.h>
#define mo 1000000007
#define pi 3.1415926535898
#define eps 1e-9 
using namespace std;
long long read(){
    long long xx=0,flagg=1;
    char ch=getchar();
    while((ch<'0'||ch>'9')&&ch!='-')
        ch=getchar();
    if(ch=='-'){
        flagg=-1;
        ch=getchar();
    }
    while(ch>='0'&&ch<='9'){
        xx=xx*10+ch-'0';
        ch=getchar();
    }
    return xx*flagg;
}
void pus(long long xx,long long flagg){
    if(xx<0){
        putchar('-');
        xx=-xx;
    }
    if(xx>=10)
        pus(xx/10,0);
    putchar(xx%10+'0');
    if(flagg==1)
        putchar(' ');
    if(flagg==2)
        putchar('\n');
    return;
}
int n,k,i,j,x,y,f[100005];
int top,nex[200005],to[200005],fir[100005];
set<pair<int,int> > s;
set<pair<int,int> > :: iterator it;
void lj(int u,int v){
	top++;
	nex[top]=fir[u];
	fir[u]=top;
	to[top]=v;
}
int main(){
	//freopen("a.in","r",stdin);
	//freopen("a.out","w",stdout);
	n=read();
	for(i=1;i<n;i++){
		x=read();
		y=read();
		lj(x,y);
		lj(y,x);
	}
	k=read();
	for(i=1;i<=n;i++)
		f[i]=-1;
	for(i=1;i<=k;i++){
		x=read();y=read();
		f[x]=y;
		s.insert(make_pair(y,x));
	}
	while(s.size()!=0){
		it=s.begin();
		x=(it->second);
		y=(it->first)+1;
		for(int top1=fir[x];top1;top1=nex[top1])
			if(f[to[top1]]==-1){
				f[to[top1]]=y;
				s.insert(make_pair(y,to[top1]));
			}
			else if(abs(f[to[top1]]-f[x])!=1){
				printf("No\n");
				return 0;
			}
		s.erase(it);
	}
	printf("Yes\n");
	for(i=1;i<=n;i++)
		pus(f[i],2);
	return 0;
}

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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2019/03/21  Problem: ABC 060 B / Link: http://abc060.contest.atcoder.jp/tasks/abc060_b  ----- */


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

	LL A, B, C; cin >> A >> B >> C;
	LL ans = 0LL;
	FOR(i, 1, 1000) {
		LL ret = i * A;
		ans |= (ret%B == C);
	}

	auto YesNo = [](bool yes, int mode = 0) {
		if (mode == 0) {
			cout << (yes ? "yes" : "no") << endl;
		}
		else if (mode == 1) {
			cout << (yes ? "Yes" : "No") << endl;
		}
		else if (mode == 2) {
			cout << (yes ? "YES" : "NO") << endl;
		}
		else assert(0);
	};

	YesNo(ans, 2);

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;cin >> n;
  vector<int> a(n);
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  int ans=0;
  int m=1e9;
  for(int i=0;i<n;i++){
    if(a[i]<m){
      m=a[i];
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 1024
#include <iostream>
using namespace std;
int a,b,ans;
int main()
{
    cin>>a>>b;
    if((a+b)%2==0)
    {
    ans=(a+b)/2;
    }
    else 
    {
    ans=(a+b)/2+1;
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256