akhauriyash/Code-Regression huggingface dataset:
#ifdef LOCAL111
#else
	#define NDEBUG
#endif
#include <bits/stdc++.h>
const int INF = 1e8;
using namespace std;

#define endl '\n'
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define RBP(i,a) for(auto& i : a)
#ifdef LOCAL111
	#define DEBUG(x) cout<<#x<<": "<<(x)<<endl
	template<typename T> void dpite(T a, T b){ for(T ite = a; ite != b; ite++) cout << (ite == a ? "" : " ") << *ite; cout << endl;}
#else
	#define DEBUG(x) true
	template<typename T> void dpite(T a, T b){ return; }
#endif
#define F first
#define S second
#define SNP string::npos
#define WRC(hoge) cout << "Case #" << (hoge)+1 << ": "
#define rangej(a,b,c) ((a) <= (c) and (c) < (b))
#define rrangej(b,c) rangej(0,b,c)
template<typename T> void pite(T a, T b){ for(T ite = a; ite != b; ite++) cout << (ite == a ? "" : " ") << *ite; cout << endl;}
template<typename T> bool chmax(T& a, T b){if(a < b){a = b; return true;} return false;}
template<typename T> bool chmin(T& a, T b){if(a > b){a = b; return true;} return false;}

typedef long long int LL;
typedef unsigned long long ULL;
typedef pair<int,int> P;
typedef pair<LL,LL> LP;

void ios_init(){
	//cout.setf(ios::fixed);
	//cout.precision(12);
#ifdef LOCAL111
	return;
#endif
	ios::sync_with_stdio(false); cin.tie(0);	
}

int main()
{
	ios_init();
	string s;
	int k;
	while(cin >> s >> k){
		REP(i,SZ(s)){
			int x = (26+('a'-s[i]))%26;
			DEBUG(x);
			DEBUG(k);
			if(x <= k){
				DEBUG(k);
				k -= x;
				s[i] = 'a';
			}
		}
		s[SZ(s)-1] = 'a'+(s[SZ(s)-1]-'a'+k)%26;
		cout << s << endl;
	}
	return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
template <typename X> ostream& operator << (ostream& x,const vector<X>& v){for(ll i=0;i<v.size();++i) x<<v[i]<<" ";return x;}
template <typename X> ostream& operator << (ostream& x,const set<X>& v){for(auto it:v) x<<it<<" ";return x;}
template <typename X, typename Y> ostream& operator << (ostream& x, const pair<X,Y>& v) {x<<v.ff<<" "<<v.ss;return x;}
template <typename T, typename S> ostream& operator << (ostream& os, const map<T, S>& v) { for (auto it : v) os << it.first << "=>" << it.second << endl; return os; }
struct pair_hash {inline std::size_t operator()(const std::pair<ll, ll> & v) const {return v.first*31+v.second;}};
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL)
#define pb push_back
#define fr first
#define sc second
#define prnt(m) for(auto it = m.begin() ; it != m.end() ; ++it){cout<<*it<<endl;}
#define tra(it,m) for(auto it=m.begin();it!=m.end();++it)
#define DBG(x) cout<<"# # #     "<<x<<'\n';
#define fri(i,s,n) for(long long i=s;i<n;i++)
#define mod 1000000007LL
#define mod2 998244353
#define vct2 vector<vector<ll>>
#define vct vector<ll>
#define pll pair<ll,ll>
#define rz(n) resize(n)
#define all(v) v.begin(),v.end()
#define mkp make_pair
#define arrin(a,n) for(ll i = 0; i < n ; i++){cin>>a[i];}
#define arrout(a,n) for(ll i = 0;i < n; i++){cout<<a[i]<<" ";}
#define ex(s) cout<<s<<endl,exit(0);
#define infy 2e18
#define five 100005;
#define six 1000005;
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
//___________________________________________________________________________________________________________________________________________________________
const int N = five;
int dp[N];
int h[N];
int n;
int f(int i)
{
       if(i<0){return mod;}
       if(i==0){return 0;}
       if(dp[i]!=-1){return dp[i];}
       return dp[i] = min(f(i-1)+abs(h[i]-h[i-1]),f(i-2)+abs(h[i]-h[i-2]));
}
int main(){
       int n;
       cin>>n;
       memset(dp,-1,sizeof dp);
       arrin(h,n);
       cout<<f(n-1)<<endl;
}


Measured memory_bytes: 2560
// Ver19.02
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define INF 1 << 29
#define LLINF 4545454545454545454
#define MOD 1000000007
#define ll long long
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
int upll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? -1 : *(ll *)a > *(ll *)b ? 1 : 0; }
int downll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? 1 : *(ll *)a > *(ll *)b ? -1 : 0; }
void sortup(ll *a, int n) { qsort(a, n, sizeof(ll), upll); }
void sortdown(ll *a, int n) { qsort(a, n, sizeof(ll), downll); }

int main()
{
  int a, b;
  scanf("%d%d", &a, &b);

  puts(a * b % 2 == 0 ? "Even" : "Odd");
  return 0;
}

Measured memory_bytes: 128
import java.util.*; 
import java.io.*; 

public class Main {
	public static void main(String[] args) throws IOException {
     Scanner sc = new Scanner(System.in);
     int n = sc.nextInt(); 
     int m = sc.nextInt(); 
     if(n<m) {
    	 for(int i = 0; i<m; i++) System.out.print(n);
     }
     else for(int i = 0;i<n; i++) System.out.print(m);
   }
}

Measured memory_bytes: 19796
#include <iostream>

using namespace std;

int main() {
	int n, x;
	while (cin >> n >> x && (n || x)) {
		int cnt = 0;
		for (int i = 1; i <= n; ++i)
			for (int j = i + 1; j <= n; ++j)
				for (int k = j + 1; k <= n; ++k)
					if (i + j + k == x) cnt++;
		cout << cnt << endl;
	}

	return 0;
}


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

public class Main {
    private static final int MOD = 1_000_000_007;
    private static final String YES = "Yes";
    private static final String NO = "No";

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();

        System.out.println(solve(A, B, C));
    }

    private static int solve(int A, int B, int C) {
        int[] list = {A, B, C};
        Arrays.sort(list);
        int count = 0;

        count += (list[2] - list[1]) + (list[2] - list[0] - (list[2] - list[1]))/2;
        if ((list[2] - list[0] - (list[2] - list[1])) % 2 != 0) {
            count += 2;
        }

        return count;
    }
}

Measured memory_bytes: 23764
#include<bits/stdc++.h>
#define qmin(x,y) (x=min(x,y))
#define qmax(x,y) (x=max(x,y))
#define vic vector<int>
#define vit vector<int>::iterator
#define pir pair<int,int>
#define fr first
#define sc second
#define mp(x,y) make_pair(x,y)
#define rsort(x,y) sort(x,y),reverse(x,y)
using namespace std;

inline char gc() {
//	static char buf[100000],*p1,*p2;
//	return (p1==p2)&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
	return getchar();
}

template<class T>
int read(T &ans) {
	ans=0;char ch=gc();T f=1;
	while(!isdigit(ch)) {
		if(ch==EOF) return -1;
		if(ch=='-') f=-1;
		ch=gc();
	}
	while(isdigit(ch))
		ans=ans*10+ch-'0',ch=gc();
	ans*=f;return 1;
}

template<class T1,class T2>
int read(T1 &a,T2 &b) {
	return read(a)!=EOF&&read(b)!=EOF?2:EOF;
}

template<class T1,class T2,class T3>
int read(T1 &a,T2 &b,T3 &c) {
	return read(a,b)!=EOF&&read(c)!=EOF?3:EOF;
}

typedef long long ll;
const int Maxn=1100000;
const int inf=0x3f3f3f3f;

int n,m,u,v,cnt,x,y,d[Maxn];
int to[Maxn],nxt[Maxn],first[Maxn],tot=1;

inline void add(int u,int v) {
	to[tot]=v;
	nxt[tot]=first[u];
	first[u]=tot++;
	to[tot]=u;
	nxt[tot]=first[v];
	first[v]=tot++;
}

bool dfs(int root,int fa) {
	for(int i=first[root];i;i=nxt[i])
		if(to[i]==x&&fa!=x) return true;
		else if(to[i]==y) return false;
		else if(to[i]!=fa) return dfs(to[i],root);
}

signed main() {
//	freopen("test.in","r",stdin);
	read(n,m);
	for(int i=1;i<=m;i++) {
		read(u,v);
		add(u,v);
		d[u]++,d[v]++;
	}
	for(int i=1;i<=n;i++) if(d[i]&1) return 0*puts("No");
	for(int i=1;i<=n;i++) if(d[i]>=6) return 0*puts("Yes");
	else if(d[i]==4) {
		cnt++;
		if(cnt==1) x=i;
		else y=i;
	}
	if(cnt>=3) return 0*puts("Yes");
	else if(cnt==2) {
		for(int i=first[x];i;i=nxt[i]) if(dfs(to[i],x)) return 0*puts("Yes");
		return 0*puts("No");
	}
	else return 0*puts("No");
	return 0;
}



Measured memory_bytes: 6784
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, M;
    cin >> N >> M;
    vector<pll> claims;
    for (int i = 0; i < M; i++)
    {
        ll a, b;
        cin >> a >> b;
        claims.emplace_back(a, b);
    }
    sort(claims.begin(), claims.end());
    claims.emplace_back(N + 1, 1e12);
    ll answer = 0;
    ll currentMinRight = 1e12;
    for (pll claim : claims)
    {
        ll left, right;
        tie(left, right) = claim;
        if (left >= currentMinRight)
        {
            answer++;
            currentMinRight = right;
        }
        else
        {
            currentMinRight = min(currentMinRight, right);
        }
    }
    cout << answer << endl;
    return 0;
}


Measured memory_bytes: 2420
#include<stdio.h>
#include<stdlib.h>

 typedef struct tree{
  int p,l,r;
}t;

 t T[25];
 
int Height(int);
int n;

int main(){
  int i,j,id,left,right;
  int s[25],deg[25],dep[25],h[25];
 
  scanf("%d",&n);
  
  for(i=0;i<n;i++){
    T[i].p=T[i].l=T[i].r= s[i]=-1;
    deg[i]=dep[i]= h[i]=0;
  }
 
  for(i=0;i<n;i++){
    scanf("%d%d%d",&id,&left,&right);
 
    if(right!=-1){
      T[right].p=id;
      deg[id]++;
    }
    if(left!=-1){
      T[left].p=id;
      deg[id]++;
    }
 
    T[id].l=left;
    T[id].r=right;
    s[left]=right;
    s[right]=left;
  }
 
  for(i=0;i<n;i++){
    j=i;
     
    while(T[j].p!=-1){
      j=T[j].p;
      dep[i]++;
    }  
   h[i]=Height(i);
  }
 
  for(i=0;i<n;i++){
    printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, ",i,T[i].p,s[i],deg[i],dep[i],h[i]);
 
    if(T[i].p==-1){
      printf("root\n");
    }else if(T[i].l==-1 && T[i].r==-1){
      printf("leaf\n");
    }else{
      printf("internal node\n");
    }
  }
 
  return 0;
}
 
int Height(int a){
  int j,c=0,max=0;
 
  for(j=0;j<n;j++){
    if(T[j].p==a){
      c=Height(j)+1;
 
      if(c>max){
    max=c;
      }
    }
  }
 
  return max;
}

Measured memory_bytes: 612
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <valarray>
#include <vector>

#define EPS 1e-9
#define INF 1070000000LL
#define MOD 1000000007LL
#define fir first
#define foreach(it,X) for(__typeof((X).begin()) it=(X).begin();it!=(X).end();it++)
#define ite iterator
#define mp make_pair
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define pb push_back
#define sec second
#define sz(x) ((int)x.size())

using namespace std;

struct timer{
	time_t start;
	timer(){start=clock();}
	~timer(){cerr<<1.*(clock()-start)/CLOCKS_PER_SEC<<" secs"<<endl;}
};

typedef istringstream iss;
typedef long long ll;
typedef pair<int,int> pi;
typedef stringstream sst;
typedef vector<int> vi;

int N,dist[111][111];
string s[111];
map<string,int> dest;

int main(){
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	
	cin>>N;
	rep(i,N+1)rep(j,N+1){
		dist[i][j]=i==j?0:INF;
	}
	getline(cin,s[0]);
	rep(i,N){
		getline(cin,s[i]);
		if(s[i].find(" ")==-1){
			dest[s[i].substr(0,sz(s[i])-1)] = i;
		}
	}
	rep(i,N){
		if(s[i].find(" ")==-1){
			dist[i][i+1]=0;
		}else{
			string lab=s[i].substr(5,sz(s[i])-6);
			dist[i][i+1]=1;
			dist[i][dest[lab]]=0;
		}
	}
	rep(k,N+1)rep(i,N+1)rep(j,N+1){
		dist[i][j]=min(dist[i][j],dist[i][k]+dist[k][j]);
	}
	cout<<dist[0][N]<<endl;
}

Measured memory_bytes: 1284
#include <bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()
#ifdef _DEBUG_
	#define debug(...) printf(__VA_ARGS__)
#else
	#define debug(...) (void)0
#endif
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;

const int N_MAX = 2e5+10;
int arr[N_MAX];

int main() {
	int n;
	scanf("%d", &n);
	for(int i=1; i<=n; i++)
		scanf("%d", arr+i);

	ll ans=0;
	stack<PII> stk;
	for(int i=n; i>=0; i--) {
		while(!stk.empty() && arr[i] < stk.top().F) {
			PII p = stk.top();
			stk.pop();
			int head = p.S-i;
			int tail = stk.empty() ? n-p.S+1 : stk.top().S-p.S;
			ans += 1ll*tail*head*p.F;
		}
		stk.push(MP(arr[i], i));
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 2688
#!/usr/bin/env python3
s = input()
len_s = len(s)

text = ''
for i in range(len_s):
    if s[i] == '0':
        text += '0'
    elif s[i] == '1':
        text += '1'
    else:
        if text == '':
            pass
        else:
            text = text[:-1]
print(text)


Measured memory_bytes: 9016
#include<bits/stdc++.h>
using namespace std;
using ll = int64_t;
using P = pair<ll, ll>;

const ll INF = 5e15;
const ll MOD = 1e9 + 7;

vector<ll> dp1;
vector<vector<ll>> dp2;


int main(){
    string K;
    cin >> K;
    ll D;
    cin >> D;
    dp1.resize(K.size() + 1);
    dp2.resize(K.size() + 1, vector<ll>(100, 0));
    for(ll i = 0; i < K.size(); i++){
        dp1[i + 1] = (dp1[i] + (K[i] - '0')) % D;
        for(ll j = 0; j < K[i] - '0'; j++) (dp2[i + 1][(dp1[i] + j) % D] += 1) %= MOD;
        for(ll j = 0; j <= 9; j++) for(ll k = 0; k < D; k++) (dp2[i + 1][(j + k) % D] += dp2[i][k]) %= MOD;
    }
    cout << (dp2[K.size()][0] + !dp1[K.size()] - 1 + MOD) % MOD << endl;
    return 0;
}


Measured memory_bytes: 8576
#![allow(
  non_snake_case,
  unused_variables,
  unused_assignments,
  unused_mut,
  unused_imports,
  unused_macros,
  dead_code
)]
//use proconio::fastout;
use proconio::{input, marker::*};
use std::cmp::*;
use std::collections::*;
//use std::collections::VecDeque;

macro_rules! debug {
  ($($a:expr),* $(,)*) => {
      #[cfg(debug_assertions)]
      eprintln!(concat!($("| ", stringify!($a), "={:?} "),*, "|"), $(&$a),*);
  };
}

fn main() {
  input! {
     N:usize,A:[usize;N],B:[usize;N]
  }
  let N: usize = N;
  let A: Vec<usize> = A;
  let B: Vec<usize> = B;
  let mut n = vec![0; N + 1];
  let mut d = 0;
  for i in 0..N {
    n[A[i]] += 1;
    n[B[i]] += 1;
    while A[i] == B[(i + d) % N] {
      d += 1;
      if d >= N {
        println!("No");
        return;
      }
    }
  }
  for i in 0..N {
    if n[i] > N {
      println!("No");
      return;
    }
  }
  let mut flag = true;
  while flag {
    flag = false;
    for i in 0..N {
      while A[i % N] == B[(i + d) % N] {
        flag = true;
        d += 1;
        if d >= N {
          println!("No");
          return;
        }
      }
    }
  }
  for i in 0..N {
    if A[i] == B[(i + d) % N] {
      panic!("crash and burn");
      println!("No");
      return;
    }
  }
  println!("Yes");
  for i in 0..N {
    print!("{} ", B[(i + d) % N]);
  }
}


Measured memory_bytes: 9368
#include <iostream>
#include <vector>
using namespace std;

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

int main() {
    int n;cin>>n;
    
    vector<int> vec(n);
    
    rep(i,n)cin>>vec[i];
    
    int q;cin>>q;
    vector<int> vec2(q);
    vector<bool> ans(q);

    rep(i,q){
        cin>>vec2[i];
        ans[i]=false;
    }
    
    rep(i, (1<<n)){
        int c=0;
        rep(j,n){
            if((i>>j) & 1)c+=vec[j];
        }
        rep(j,q){
            if(c == vec2[j])ans[j]=true;
        }
    }
    rep(i,q){
        if(ans[i]==true)cout<<"yes"<<endl;
        else cout<<"no"<<endl;
    }
	return 0;
}


Measured memory_bytes: 3096
package main

import (
	"fmt"
)

func main() {
	var a, b int
	fmt.Scan(&a, &b)
	fa, fb := float64(a), float64(b)
	for n := int(fa / 0.08); n <= int((fa+13)/0.08); n++ {
		fn := float64(n)
		if (fa/0.08) <= fn && fn < (fa+1.0)/0.08 && (fb/0.1) <= fn && fn < (fb+1.0)/0.1 {
			fmt.Println(n)
			return
		}
	}
	fmt.Println(-1)
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int dx[]={-1,1,0,0};
int dy[]={0,0,-1,1};
vector<long long int> adj[200001];
bool vis[200001];
#define ull unsigned long long int
#define ll long long int
#define MAX 1000000007
//1e9+7
#define pll pair<ll,ll>
#define pii pair<int,int>


int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    ll n,k;
    cin>>n>>k;
    memset(vis,false,sizeof vis);
    ll arr[n+1];
    arr[0]=0;
    for(ll i=1;i<=n;i++) cin>>arr[i];
    vector<ll> v,w;
    ll pos=1;
    while(!vis[pos]){
        v.push_back(pos);
        vis[pos]=true;

        pos=arr[pos];
    }
    memset(vis,false,sizeof vis);
    while(!vis[pos]){
        w.push_back(pos);
        vis[pos]=true;
        pos=arr[pos];
    }
    /*
    for(ll i=0;i<v.size();i++) cout<<v[i]<<" ";
    cout<<"\n";
    for(ll i=0;i<w.size();i++) cout<<w[i]<<" ";
    cout<<"\n";
    */
    ll N=v.size(),M=w.size();
    //cout<<k%M;

    if(k<N) cout<<v[k];
    else cout<<w[(k-N+M)%M];
    return(0);
}


Measured memory_bytes: 14056
#include <iostream>
#include <stdio.h>
#include <vector>
#include <map>
#include <sstream>
#include <string>

#include <algorithm>

#define MAX 1000010
using namespace std;


int main(){
  int a,flag,i,am;

  
  cin >> a ;
  while(a!=0){

    map<string, int> stars;
    for(i=0;i<a;i++){
      cin >> am;
      ostringstream stream;
      stream << am;
      stars[stream.str()]++;
    }
    flag=0;
typedef map<string,int> MSI;
for(MSI::iterator it=stars.begin();it!=stars.end();it++){
  if((*it).second>a/2){
  cout<<(*it).first<<endl;
  flag=1;
  }

 }
    if(flag==0) cout << "NO COLOR" << endl;
    cin >> a ;
  }
  return 0;
}

Measured memory_bytes: 4808
from collections import deque
# N = int(input())
S = input()
Q = int(input())
T = [input().split() for i in range(Q)]
d = deque(S)
cnt = 0
for i in range(Q):
    if T[i][0] == '1':
        cnt += 1
    else:
        if cnt % 2 == 0:
            if T[i][1] == '1':
                d.appendleft(T[i][2])
            else:
                d.append(T[i][2])
        else:
            if T[i][1] == '2':
                d.appendleft(T[i][2])
            else:
                d.append(T[i][2])
if cnt % 2 == 0:
    print(''.join(d))
else:
    print(''.join(d)[::-1])

Measured memory_bytes: 44660
#include <iostream>
#include <vector>
using namespace std;

int main()
{
    int n,i;
    cin >> n;
    vector<int> h(n);
    for(i = 0;i < n;++i){
        cin >> h.at(i);
    }
    for(i = n-2;i >= 0;--i){
        if((h.at(i)-h.at(i+1)) >= 2){
            cout << "No" << endl;
            return 0;
        }else if((h.at(i)-h.at(i+1)) == 1){
            h.at(i) -= 1;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 640
using System;
using System.Linq;
using System.Collections.Generic;

class P
{
    static void Main()
    {
        long[] a = Console.ReadLine().Split().Select(long.Parse).ToArray();
        long res = Math.Min(a[0], a[1] / 2);
        a[1] -= res * 2;
        res += a[1] / 4;
        Console.WriteLine(res);
    }
}

Measured memory_bytes: 13396
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
char a[105],b[105],c[105];
int lena,lenb,lenc,cnta,cntb,cntc;
void F1();
void F2();
void F3();
int main() {
	scanf("%s%s%s",a+1,b+1,c+1);
	lena=strlen(a+1);
	lenb=strlen(b+1);
	lenc=strlen(c+1);
	F1();
}






void F2() {
	cntb++;
	if(lenb==cntb-1) {
		puts("B");
		return;
	}
	if(b[cntb]=='a')
		F1();
	else if(b[cntb]=='b')
		F2();
	else
		F3();
}
void F1() {
	cnta++;
	if(lena==cnta-1) {
		puts("A");
		return;
	}
	if(a[cnta]=='a')
		F1();
	else if(a[cnta]=='b')
		F2();
	else
		F3();
}

void F3() {
	cntc++;
	if(lenc==cntc-1) {
		puts("C");
		return;
	}
	if(c[cntc]=='a')
		F1();
	else if(c[cntc]=='b')
		F2();
	else
		F3();
}


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

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

int main() {
  int n, t=15; cin>>n;
  vector<int> d(n); rep(i,n) cin>>d[i];
  sort(d.begin(),d.end());
  int c[2] = {0,0};
  rep(i,n) {
    t = min(t, d[i]-c[i&1]);
    c[i&1] = d[i];
  }
  t = min(t, 24-c[0]-c[1]);
  cout << t << endl;
  return 0;
}


Measured memory_bytes: 256
N = int(input())
Ts = [int(input()) for i in range(N)]

# 最大公約数
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

# 最大公倍数
def lcm(a, b):
    return a * b // gcd (a, b)

def solve(Ts):
    if len(Ts) == 1:
        print(Ts[0])
    
    else:
        Ts_temp = []
        for i in range(len(Ts)-1):
            Ts_temp.append(lcm(Ts[i], Ts[i+1]))
        solve(Ts_temp)

solve(Ts)

Measured memory_bytes: 3260
#include<iostream>
#include <string> 
#include <vector>  
#include<math.h>
#include <algorithm>
#include<iomanip>
#include<map>
#define INF 1000000000
#define LM 55555
#define LL long long
using namespace::std;

long long now,L,R,D, A[2][100],AA[2][100],num, N, K, M, ans,sosu[100000];
string S, T;
bool h;
char cc;


int main() {

	cin >> S;
	for (int i = 0; i < S.size(); i++) {
		if (S[i] == '1') {
			S[i] = '9';
		}
		else if (S[i] == '9') {
			S[i] = '1';
		}
	}
	cout <<S << endl;
	return 0;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define INF 1000000000
#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
typedef long long LL;
double r,n;
int xl[21];
int xr[21];
int h[21];
int ma[50];
int main(){
   while(cin>>r,cin>>n,r){
       REP(i,n){
             cin>>xl[i]>>xr[i]>>h[i];
               xl[i]+=20;
               xr[i]+=20;
        }
       REP(i,50){
             int now=0;
             REP(j,n){
                    if(xl[j]<i&&i<=xr[j]){
                          now=max(now,h[j]);
                       }
               }
             ma[i]=now;
        }
        /*
       for(int i=20;i>0;i--){
            ma[i-1]=min(ma[i],ma[i-1]);
        }
       for(int i=20;i<=39;i++){
            ma[i+1]=min(ma[i],ma[i+1]);
        }*/
        /*REP(i,40){
              if(i<10)continue;
                cout<<ma[i]<<endl;
          }*/

       double ans=1e6;
       REP(i,41){
             double dx=abs(20-i);
             if(i>20){
                  dx--;
               }
             if(r*r<=dx*dx){
                  continue;
               }
               //cout<<r<<dx<<ma[i]<<endl;
             double yy=-sqrt(double(r)*r-dx*dx)+r+ma[i];
              // cout<<sqrt(double(r)*r-dx*dx)<<endl;
             ans=min(ans,yy);
        }
       cout<<ans<<endl;
   }
   return 0;
 }

Measured memory_bytes: 3236
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

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

  if(a==b){
    if(a!=c){
      cout << "Yes" << endl;
    }else{
      cout << "No" << endl;
    }
  }else if((a==c) || (b==c)){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Yes                \
    cout << "Yes" << endl; \
    return 0;
#define No                \
    cout << "No" << endl; \
    return 0;
using namespace std;
using ll = long long;
const int INF = 1001001001;
const int MOD = 1000000007;
typedef long long ll;

template <typename T>
void print(const T &v);

int main()
{
    int N;
    cin >> N;
    vector<pair<int, int>> tasks(N);
    rep(i, N) cin >> tasks[i].second >> tasks[i].first;

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

    int now = 0;
    for (auto t : tasks)
    {
        now += t.second;
        if (now <= t.first)
        {
            continue;
        }
        else
        {
            No
        }
    }
    Yes
}

// Use For Debug
template <typename T>
void print(T const &v)
{
    for (int i = 0; i < v.size(); i++)
    {
        if (i)
            cout << " ";
        cout << v[i];
    }
    cout << endl;
}


Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <cmath>

using namespace std;
typedef pair<int, int> P;
typedef pair<P, int> PI;
const int LIMIT = 50;

int n, m;
int a[LIMIT], b[LIMIT];

bool graph[LIMIT][LIMIT];
bool visited[LIMIT];

void dfs(int v)
{
	visited[v] = true;
	for (int v2 = 0; v2 < n; ++v2)
	{
		if (graph[v][v2] == false)
		{
			continue;
		}
		if (visited[v2] == true)
		{
			continue;
		}
		dfs(v2);
	}
}

void solve()
{
	cin >> n >> m;
	for (int i = 0; i < m; ++i)
	{
		cin >> a[i] >> b[i];
		a[i]--;
		b[i]--;
		graph[a[i]][b[i]] = graph[b[i]][a[i]] = true;
	}
	int ans = 0;
	for (int i = 0; i < m; ++i)
	{
		graph[a[i]][b[i]] = graph[b[i]][a[i]] = false;
		for (int j = 0; j < n; ++j)
		{
			visited[j] = false;
		}
		dfs(0);
		bool bridge = false;
		for (int j = 0; j < n; ++j)
		{
			if (visited[j] == false)
			{
				bridge = true;
			}
		}
		if (bridge)
		{
			ans += 1;
		}
		graph[a[i]][b[i]] = graph[b[i]][a[i]] = true;
	}
	cout << ans << endl;
}

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

Measured memory_bytes: 256
program main
	implicit none
	integer N, i, ans, score
	integer, allocatable :: s(:)
	read(*, *) N
	allocate(s(1: N))
	do i = 1, N
		read(*, *) s(i)
	end do
	score = sum(s)
	if(mod(score,10) /= 0) then
		write(*, *) score
	else
		ans = score
		do i = 1, N
			if(mod(s(i),10) /= 0) then
				ans = min(s(i), ans)
			end if
		end do
		write(*, *) score - ans
	end if
end program main

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define LL long long
using namespace std;
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int N, K;
  cin >> N >> K;
  vector<int> a(N);
  vector<LL> dp(N);
  dp.assign(N, 100000000000005);
  for (int i = 0; i < N; ++i)
    cin >> a[i];
  dp[0] = 0;
  dp[1] = abs(a[1] - a[0]);
  for (int i = 2; i < N; ++i)
    for (int j = max(0, i - K); j < i; ++j)
      dp[i] = min(dp[i], dp[j] + abs(a[j] - a[i]));
  cout << dp[N - 1] << endl;
  return 0;
}


Measured memory_bytes: 4512
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <climits>
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;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b;
    cin >> a >> b;
    FOR(c, 1, 3) {
        if((a * b * c) % 2 == 1) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}


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

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

	bool isp = true;
	for( int i = 0; i < s.size(); i++ ) {
			if( i == a ) {
				if( s[ i ] != '-' ) {
					isp = false;
					break;
				}
			}
			else if( s[ i ] == '-' ) {
				isp = false;
				break;
			}
	}

	std::cout << ( isp ? "Yes" : "No" ) << std::endl;
	return 0;
}



Measured memory_bytes: 256
def wantp(x):

    wpq = []
    while p[x] != x:
        wpq.append(x)
        x = p[x]

    for i in wpq:
        p[i] = x

    return x


N,H,W = map(int,input().split())

ans = 0
ARC = []

for i in range(N):

    r,c,a = map(int,input().split())

    ARC.append([a,r-1,c-1])

ARC.sort()
ARC.reverse()

huse = [-1] * H
wuse = [-1] * W

p = [i for i in range(N)]
lnum = [0] * N
rank = [1] * N

for i in range(N):

    na = ARC[i][0]
    nr = ARC[i][1]
    nc = ARC[i][2]

    nowp = wantp(i)
    if huse[nr] == -1:
        lnum[nowp] += 1
        huse[nr] = nowp

    else:
        hp = wantp(huse[nr])

        if hp != nowp:

            if rank[hp] > rank[nowp]:
                p[nowp] = hp
                lnum[hp] += lnum[nowp]

            elif rank[hp] < rank[nowp]:
                p[hp] = nowp
                lnum[nowp] += lnum[hp]

            else:
                p[hp] = nowp
                lnum[nowp] += lnum[hp]
                rank[nowp] += 1


    nowp = wantp(i)
    if wuse[nc] == -1:
        lnum[nowp] += 1
        wuse[nc] = nowp

    else:
        wp = wantp(wuse[nc])

        if wp != nowp:

            if rank[wp] > rank[nowp]:
                p[nowp] = wp
                lnum[wp] += lnum[nowp]

            elif rank[wp] < rank[nowp]:
                p[wp] = nowp
                lnum[nowp] += lnum[wp]

            else:
                p[wp] = nowp
                lnum[nowp] += lnum[wp]
                rank[nowp] += 1

    
    nowp = wantp(i)
    if lnum[nowp] > 0:
          ans += na
          lnum[nowp] -= 1

print (ans)
    
        

Measured memory_bytes: 85592
(defun get-input-array2 (n m)
  (let ((rst (make-array (list n m))))
    (loop for x from 0 to (- n 1)
          do (loop for y from 0 to (- m 1)
                   ;do (format t "~A ~A ~%" x y)
                   do (setf (aref rst x y) (read))))
    rst))


(defun main (n m)
  (let* ((input-array (get-input-array2 m 2))
         (rst-array (make-array n :initial-element 0))
         (rst 0))
    (loop for x from 0 to (- m 1)
          for si =  (- (aref input-array x 0) 1)
          for ci = (aref input-array x 1)
          if (or (and (not (equal (aref rst-array si) 0)) (not (equal ci (aref rst-array si))))
                 (and (equal si 0) (equal ci 0) (not (equal n 1))))
          do (progn (setf rst -1)
               (return))
          do (setf (aref rst-array si) ci)
          ;do (format t "1: ~A ~A ~A~%" x si ci)
          finally (if (and (not (equal n 1)) (equal (aref rst-array 0) 0))
                      (setf (aref rst-array 0) 1)))
    (loop for x downfrom (- n 1) downto 0
          for y from 0 to n
          for z = (aref rst-array y)
          if (equal rst -1)
          do (return)
          ;do (format t "2: ~A ~A ~A ~%" x y z)
          do (setf rst (+ rst (* z (expt 10 x)))))
    rst))

          
    

(format t "~A~%" (main (read) (read)))



Measured memory_bytes: 18912
#include <iostream>
#include <stdio.h>
#define ll long long
#define Mod 1000000007
#define sz 1004
#define valid (i>0 && i <= h && j>0 && j<=w && a[i][j]!='#')
using namespace std;
char a[sz][sz];
ll vis[sz][sz];
bool check[sz][sz];
ll cnt;
ll x , y;
ll blockClimbing(int i , int j,int h , int w){
    if(check[i][j])return vis[i][j];
    if(!valid){check[i][j]=true;return vis[i][j]=0;}
	//cout<<i<<' '<<j<<endl;
    blockClimbing(i+1,j,h,w);
    blockClimbing(i,j+1,h,w);
    
    vis[i][j] = (vis[i+1][j] + vis[i][j+1])%Mod;
    check[i][j]=true;
    return vis[i][j];
}
int main(){
    //freopen("test.txt","r",stdin);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int i ,  j , n , m , h , w;
    cin>>h>>w;
    for(i=1;i<=h;i++){
        for(j=1;j<=w;j++){
            cin>>a[i][j];
        }
    }
    check[h][w]=true;
    vis[h][w]=1;
   cout<< blockClimbing(1,1,h,w)<<endl;
   
    return 0;
}

Measured memory_bytes: 10240
N, K = map(int, input().split())

MOD = 10**9 + 7

dp = [[0]*(N+1) for _ in range(N+1)]
dp[0][0] = 1
for i in range(N):
    for j in range(i+1):
        dp[i+1][j] += dp[i][j]
        dp[i+1][j+1] += dp[i][j]

for i in range(1, K+1):
    a = dp[N-K+1][i]
    b = dp[K-1][i-1]
    ans = (a * b) % MOD
    print(ans)


Measured memory_bytes: 356536
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define mp make_pair
#define F first
#define S second
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define INF 0x3f3f3f3f
#include<ext/rope>
using namespace __gnu_cxx;
typedef long long ll;
typedef pair<ll,ll> pii;
typedef pair<double,double> pdd;
ll a,b,n;
ll d[55];
int main()
{
    //IOS;
    while(cin>>n)
    {
        ll sum=0;
        rep(i,n) cin>>d[i];
        for(int i=0;i<n;i++)
        {
            for(int j=i+1;j<n;j++)
            {
                sum+=d[i]*d[j];
            }
        }
        cout<<sum<<'\n';
    }
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
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; }

int primeNumber(const int n){
    for(int ans=n; ans>=2; ans--){
        bool isPrime = true;
        for(int i=2; i*i<=ans; i++){
            if(ans%i==0){
                isPrime = false;
                break;
            }
        }
        if(isPrime) return ans;
    }
    return -1; // error
}

int main(){
    int n;
    cin >> n;
    ll ans = 0;
    //bool isPrime = true;
    for(int i=1; i<n; i++){
        ll a = 1;
        int c = i;
        for(int j=2; j*j<=i; j++){
            //vector<ll> prime(n+1);
            //int c = i;
            ll prime = 0;
            while(c%j==0){
                //isPrime = false;
                c /= j;
                prime++;
            }
            if(prime) a *= (prime + 1);
        } 
        if(c!=1){
            a *= 2;
        }
        ans += a;
        //isPrime = true;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>
#define ll long long

using namespace std;

long long MOD = 1000000007;

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

    vector<ll> cnt(3,0);
    for(int i=0; i<N; i++){
        if(S[i]=='R'){
            cnt[0]++;
        }else if(S[i]=='G'){
            cnt[1]++;
        }else{
            cnt[2]++;
        }
    }
    ll ans=cnt[0]*cnt[1]*cnt[2];

    for(int i=0; i<N; i++){
        for(int j=1; i+2*j<N; j++){
            if(S[i]!=S[i+j] && S[i+j]!=S[i+2*j] && S[i+2*j]!=S[i]){
                ans--;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3640
# ABC047 D
n, t = gets.chomp.split(" ").map(&:to_i)
a = gets.chomp.split(" ").map(&:to_i)
h = Hash.new(0)
amin = a[0]
bmax = a[1] - a[0]
(n - 1).times do |i|
  amin = [amin, a[i]].min
  b = a[i+1] - amin
  bmax = [b, bmax].max
  h[b] += 1 if b > 0
end
puts h[bmax]

Measured memory_bytes: 18436
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <time.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;

ll *min_data,*max_data,*add_data;
int N = 1;

void init(ll first_N){
	while(N < first_N)N *= 2;
}

void add(int left,int right,ll value,int node_id,int node_left,int node_right){

	if(right < node_left || left > node_right){
		return;
	}
	else if(left <= node_left && right >= node_right){

		add_data[node_id] += value;

		while(node_id != 0){

			node_id = (node_id-1)/2;
			min_data[node_id] = min(min_data[2*node_id+1]+add_data[2*node_id+1],min_data[2*node_id+2]+add_data[2*node_id+2]);
			max_data[node_id] = max(max_data[2*node_id+1]+add_data[2*node_id+1],max_data[2*node_id+2]+add_data[2*node_id+2]);
		}
	}else{

		add(left,right,value,2*node_id+1,node_left,(node_left+node_right)/2);
		add(left,right,value,2*node_id+2,(node_left+node_right)/2+1,node_right);
	}
}

ll getMin(int left,int right,int node_id,int node_left,int node_right){
	if(right < node_left || left > node_right)return BIG_NUM;
	else if(left <= node_left && right >= node_right){
		return min_data[node_id]+add_data[node_id];

	}else{

		ll  left_min  = getMin(left,right,2*node_id+1,node_left,(node_left+node_right)/2);
		ll  right_min = getMin(left,right,2*node_id+2,(node_left+node_right)/2+1,node_right);
		return min(left_min,right_min)+add_data[node_id];
	}
}

ll getMax(int left,int right,int node_id,int node_left,int node_right){
	if(right < node_left || left > node_right)return -BIG_NUM;
	else if(left <= node_left && right >= node_right){
		return max_data[node_id]+add_data[node_id];

	}else{

		ll  left_max  = getMax(left,right,2*node_id+1,node_left,(node_left+node_right)/2);
		ll  right_max = getMax(left,right,2*node_id+2,(node_left+node_right)/2+1,node_right);
		return max(left_max,right_max)+add_data[node_id];
	}
}

int main(){

	int first_N,Q;
	scanf("%d %d",&first_N,&Q);

	init(first_N);

	min_data = new ll[2*N-1];
	max_data = new ll[2*N-1];
	add_data = new ll[2*N-1];

	for(ll i = 0; i <= 2*N-2; i++){
		min_data[i] = 0;
		max_data[i] = 0;
		add_data[i] = 0;
	}

	int command,left,right;
	ll value;

	for(int loop = 0; loop < Q; loop++){
		scanf("%d",&command);

		if(command == 0){
			scanf("%d %d %lld",&left,&right,&value);
			add(left,right,value,0,0,N-1);
		}else{
			scanf("%d %d",&left,&right);
			printf("%lld\n",getMin(left,right,0,0,N-1));
		}
	}

	return 0;
}



Measured memory_bytes: 9360
#include <stdio.h>
#include <stdlib.h>

int compare_int(const void* a, const void* b) {
		return *(int*)b - *(int*)a;
}
int main() {
	int n, m, a[103] = { 0 }, i;
	double sum = 0.00;
	scanf("%d %d", &n, &m);

	for (i = 0; i < n; i++) {
		scanf("%d", &a[i]);
		sum += a[i];
	}
	qsort(a, n, sizeof(int), compare_int);

	sum = sum / (4 * m);
	if (a[m - 1] < sum) { printf("No"); }
	else { printf("Yes"); }
	return 0;
}

Measured memory_bytes: 128
import sys
from collections import defaultdict, Counter, namedtuple, deque
import itertools
import functools
import bisect
import heapq
import math

MOD = 10 ** 9 + 7
# MOD = 998244353
# sys.setrecursionlimit(10**8)

n, k = map(int, input().split())
num = [0]*k
for i in reversed(range(1, k+1)):
    count = pow(k//i, n, MOD)
    for j in range(2, (k//i)+1):
        count = (count - num[j*i - 1])%MOD
    num[i-1] = count

# print(num)
print(functools.reduce(lambda s, x: ((x[0]+1) * x[1] + s)%MOD, enumerate(num), 0))


Measured memory_bytes: 69752
#include <bits/stdc++.h>
#include <stdio.h>
 
using namespace std;
 
#define int long long
 
void solve();

signed main()
{
    cout.precision(10);
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
#endif
    solve();
    return 0;
}

int f (int n) {
	int ans = 0;
	int nn = n;
	for (int i = 2; i * i <= nn; i += 1) {
		if (n % i)
			continue;
		ans++;
		while (n % i == 0)
			n /= i;
	}
	if (n > 1)
		ans++;
	return ans;
}

void solve()
{
    int a, b;
    cin >> a >> b;
    int g = __gcd(a, b);
    cout << f(g) + 1;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
    int a[100];
    int n;
    cin>>n;
    int cnt=0;
    for(int i=0;i<n;i++){
        cin>>a[i];
        if(a[i]%2==0){
            cnt++;
        }
    }
    cout<<cnt<<endl;
}
//大丈夫だ問題ない
//略して　　大　問　題　だ



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

#define INF 1000000000

int A,B,C;

int X,Y;

int main(){
	cin >> A >> B >> C >> X >> Y;
	int AB=2*C;
	int ans=0;
	int dif = X-Y;
	if(A + B < AB){
		ans += A*X + B*Y;
	}else{// if(A + B >= AB)
		ans += min(X,Y)*AB;
		if(dif > 0){
			if(A < AB){
				ans += dif*A;
			}else{
				ans += dif*AB;
			}
		}else if(dif < 0){
			if(B < AB){
				ans += -dif*B;
			}else{
				ans += -dif*AB;
			}
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
#include <algorithm> 
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i,n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<"\n"
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define mp make_pair
#define sz(x) (ll)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef tuple<ll,ll,ll> tll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using vc = vector<char>;
using vvc = vector<vc>;
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; 
}
ll dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};
int main(){
  ll a,b,c,d;
  cin>>a>>b>>c>>d;
  vll aa={a*c,a*d,b*c,b*d};
  sort(all(aa));
  COUT(aa[3]);
}

Measured memory_bytes: 3628
import math
import string
import collections
from collections import Counter
from collections import deque


def readints():
    return list(map(int, input().split()))


def nCr(n, r):
    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))


def has_duplicates2(seq):
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor


# coordinates
dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]
ab = readints()
if ab[0] == 1 and ab[1] == 1:
    print('Draw')
    exit()
if ab[0] == 1:
    print('Alice')
    exit()
if ab[1] == 1:
    print('Bob')
    exit()
if ab[0] < ab[1]:
    print('Bob')
    exit()
if ab[0] > ab[1]:
    print('Alice')
    exit()
if ab[0] == ab[1]:
    print('Draw')
#t = list(map(str, input()))
# print(t)
#p_cnt = 0
#d_cnt = 0
# for i in range(len(t)):
#    if t[i] == 'P':
#        p_cnt += 1
#    if t[i] == 'D':
#        d_cnt += 1
# if p_cnt > d_cnt:
#    for i in range(len(t)):
#        if t[i] == '?':
#            if t[i-1] == 'P':
#                t[i] = 'D'
#            if t[i-1] == 'D':
#                t[i] = 'P'
#    tt = ''.join(t)
#    print(tt)
# else:
#    for i in range(len(t)):
#        if t[i] == '?':
#            t[i] = 'D'
#    tt = ''.join(t)
#    print(tt)
#


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

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

struct Vertex {
    vector<pll> node;
};

Vertex V[10005];
ll C[10005];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    REP(i, N) {
        ll n, k;
        cin >> n >> k;
        REP(_, k) {
            ll v, c;
            cin >> v >> c;
            V[n].node.push_back(pll(v, c));
        }
    }
    REP(i, N) {
        C[i] = INF;
    }
    priority_queue<pll, vector<pll>, function<bool(pll, pll)>> q([](pll a, pll b) { return a.second > b.second; });
    q.push(pll(0, 0));
    C[0] = 0;
    while (!q.empty()) {
        pll t = q.top();
        q.pop();
        if (C[t.first] < t.second)
            continue;
        for (auto &n : V[t.first].node) {
            ll nxt = n.first;
            ll cost = n.second + t.second;
            if (C[nxt] <= cost)
                continue;
            C[nxt] = cost;
            q.push(pll(nxt, cost));
        }
    }

    REP(i, N) {
        cout << i << " " << C[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 12152
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
//#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rev(i,b,a) for (ll i = b - 1; i >= a; i--)
#define all(v) v.begin(), v.end()
#define maxe(v) *max_element(v.begin(), v.end())
#define mine(v) *min_element(v.begin(), v.end())
#define pb push_back
#define pf push_front
//#define rem 1000000007
#define cont continue
#define PI 3.141592653589793238462643383279502
#define debug(n1) cout<<"debug... "<<n1<<"\n"
const ll INF=(1ll<<60)-1;//ll ans = 3e18 + 5;
/////////////////////////////////////////////////////////////////
vector<ll> arr;
ll n,k;
bool is_poss( ll x )
{
    ll cuts=0;
    rep(i,0,n)
    {
        if( arr[i] > x )
        {
            cuts+= arr[i]/x;
            if( arr[i]%x == 0 )
            cuts--;
        }
    }
    if( cuts<=k )
    return true;
    return false;
}
/////////////////////////////////////////////////////////////////

int main() {
	//code
	int tc=1;
	//cin>>tc;
	while(tc--)
	{
        cin>>n>>k;
        arr.assign(n,0); 
        rep(i,0,n)
        cin>>arr[i];
        ll low=1;
        ll high = 1e16;
        while( low < high )
        {
            ll mid = ( low + high )/2;
            if( is_poss(mid) )
            {
                high=mid;
            }
            else 
            {
                low=mid+1;
            }
        }   
        cout<<low<<'\n';
	}
	return 0;
}


Measured memory_bytes: 4688
using System;
using System.Numerics;
using System.Linq;
using System.Collections.Generic;
using System.Text;

namespace debug
{
    class ProgramE
    {
        static void Main(string[] args)
        {

            //入力
            string[] t = Console.ReadLine().Split(' ');
            int n = int.Parse(t[0]);
            int k = int.Parse(t[1]);

            int[] ans = new int[n];
            int count = 0;
           

            UnionFind tree = new UnionFind();//UnionFindクラスを設定
            tree.par = new int[n];
            tree.temp = new int[n];
            tree.reset(n);


            for (int i = 0;i < k;i++)
            {
                string[] s = Console.ReadLine().Split(' ');
                int u = int.Parse(s[0]);
                int v = int.Parse(s[1]);
                int w = int.Parse(s[2]);
                tree.unite(u - 1, v - 1);
            }

            for (int i = 0; i < n; i++)
                ans[tree.size(i) -1]++;

            for (int i = 0; i < n; i++)
                count += ans[i] /( i+ 1);


            Console.WriteLine(count);
            return;

        }
    }

    /*UnionFind法のクラス*/
    class UnionFind
    {
 
        public int[] par;
        public int[] temp;


        //マイナスは根を示す。
        public void reset(int n)
        {
            for(int i = 0;i < n;i++)
                par[i] = -1;
        }

        //マイナスならそれはまだ属していないので根である。そうでないならさかのぼる
        public int root(int x)
        {
            if(par[x] < 0)
                return x;
            else
                return root(par[x]);
        }

        //根の併合を行い、根には要素数を足す（マイナスの値）
        public void unite(int x, int y)
        { // xとyの木を併合
            int rx = root(x); //xの根をrx
            int ry = root(y); //yの根をry
            if (rx == ry) 
                 return; //xとyの根が同じ(=同じ木にある)時はそのまま
            if(par[ry] > par[rx])
            {
                 int temp = ry;
                 ry = rx;
                 rx = temp;
            }
            par[ry] += par[rx];
            par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
        }

        // 2つのデータx, yが属する木が同じならtrueを返す
        public bool same(int x, int y) 
        { 
            int rx = root(x);
            int ry = root(y);
            return rx == ry;
        }

        //根の元に入っている
        public int size(int x)
        {
            return -par[root(x)];
        }
    }
}


Measured memory_bytes: 16196
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner sc = new Scanner(System.in);
        
        int N = sc.nextInt();
        
        //1桁
        if(N/10 == 0){
            System.out.println(N%10);
        //2桁
        }else if(N/100 == 0){
            System.out.println(9);
        //3桁
        }else if(N/1000 == 0){
            System.out.println(N%1000-99+9);
        //4桁
        }else if(N/10000 == 0){
            System.out.println(909);
        //5桁
        }else if(N/100000 == 0){
            System.out.println(N%100000-9999+900+9);
        //100000
        }else{
            System.out.println(90909);
        }
    }
}


Measured memory_bytes: 23764