akhauriyash/Code-Regression huggingface dataset:
/**
 *    Coded by : lucky_21
 *               --------Lokesh Singh
**/

#include<bits/stdc++.h>
using namespace std;

#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template<class T> using oset=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

#define     F           first
#define     S           second
#define     pb          push_back
#define     lb          lower_bound
#define     ub          upper_bound
#define     pii         pair<int,int>
#define     all(x)      x.begin(),x.end()
#define     fix         fixed<<setprecision(10)
#define     rep(i,a,b)  for(int i=int(a);i<=int(b);i++)
#define     repb(i,b,a) for(int i=int(b);i>=int(a);i--)
#define     FastIO      ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)

typedef double db;
typedef long long ll;

const int N=1e6+5;
const int mod=1e9+7;

int n,a[N];
signed main(){
    FastIO;
    cin>>n;
    int g=0;
    rep(i,1,n){
        cin>>a[i];
        g=__gcd(g,a[i]);
    }
    if(g!=1) return cout<<"not coprime",0;
    set<int>s;
    rep(i,1,n){
        int t=a[i];
        vector<int>v;
        rep(j,2,sqrt(t)) if(t%j==0){
            v.pb(j);
            while(t%j==0) t/=j;
        }
        if(t>1) v.pb(t);
        for(int i:v){
            if(s.count(i)) return cout<<"setwise coprime",0;
            s.insert(i);
        }
    }
    cout<<"pairwise coprime";
    return 0;
}


Measured memory_bytes: 7624
#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 105;
int hist[MAX_N];

int main() {
	int n,w;
	while(1){
		cin >> n >> w;
		if(n==0) break;
		for(int i=0;i<MAX_N;i++) hist[i] = 0;
		int mx = 0;
		for(int i=0;i<n;i++) {
			int v;
			cin >> v;
			if(mx < v) mx = v;
			hist[v/w]++;
		}
		double ans = 0.01;
		int len = mx/w + 1;
		int mhist = 0;
		for(int i=0;i<len;i++) {
			if(hist[i] > mhist) mhist = hist[i];
		}
		for(int i=0;i<len;i++) {
			ans += hist[i]/(double)mhist * (len-1-i)/(double)(len-1);
		}
		cout << fixed << setprecision(15) << ans << endl;
	}
}


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

using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;
#define DEBUG freopen("in.txt", "r", stdin);

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

fastio _fast_io;

const int N = 2e5 + 5;
int n;
ll k, ans;
int a[N];

bool check(int x) {
    ll cnt = 0;
    for (int i = 0; i < n; ++i) {
        if (a[i] >= x) {
            cnt += (a[i] + x - 1) / x - 1;
        }
    }
    return cnt <= k;
}

int main() {
    cin >> n >> k;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    int l = 1, r = 1e9;
    while (l < r) {
        int m = (r - l) / 2 + l;
        if (check(m)) {
            r = m;
        } else {
            l = m + 1;
        }
    }
    cout << l << endl;

    return 0;
}


Measured memory_bytes: 4400
#include<iostream>
#include<cmath>
#include<iomanip>
#include<vector>
#include<algorithm>
using namespace std;

#define MOD 1000000007

int main()
{
    long long n,k;
    cin>>n>>k;
    vector<long long> a(n);
    vector<long long> f(n);
    int i;
    for(i=0;i<n;i++)cin>>a.at(i);
    for(i=0;i<n;i++)cin>>f.at(i);
    sort(a.begin(),a.end());
    sort(f.begin(),f.end());
    reverse(f.begin(),f.end());
    long long ans;
    long long ansl = 0;
    long long ansr = a.at(n-1)*f.at(0);
    long long ansc;
    long long kcount;
    long long num;
    while(ansl<ansr)
    {
        ansc = (ansl+ansr)/2;
        kcount=0;
        for(i=0;i<n;i++)
        {
            num = a.at(i)*f.at(i)-ansc;
            if(num>=0)kcount+=num/f.at(i);
            if(num>=0&&ansc%f.at(i)!=0)kcount++;
        }
        if(kcount<=k)
        {
            ansr=ansc;
        }
        else
        {
            ansl=ansc+1;
        } 
    }
    ans = (ansl+ansr)/2;
    cout << ans << endl;
}

Measured memory_bytes: 3328
def main():
    n,m=map(int,input().split())
    r=set()
    x={}
    for _ in range(m):
        p,s=input().split()
        if p not in r:
            if s=='WA':
                x[p]=x.setdefault(p,0)+1
            else:
                x[p]=x.setdefault(p,0)
                r.add(p)
    print(len(r),sum(x[p] for p in r)) 

main()

Measured memory_bytes: 20480
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
typedef long long int ll;
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (unsigned int i=0;i<(n);i++)
#define EREP(i,n) for (int i=1;i<=(n);i++)
#define ALL(a) (a).begin(),(a).end()
//#define EVEL 1

#ifdef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const int MOD =  1000000007 ;
const int INF = 2000000000;


    int N,A,B,ans;
    string S;
    bool F=true;
int main(){
    cin>>S;

    REP(i,S.size()){
        if(S[i]!=',')cout<<S[i];
        else cout<<" ";
    }
    return 0;

}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main() {
  char *deck, *deck_b, *deck_t;
  int m = 0, h = 0, i = 0;
  deck = (char *)calloc(210, sizeof(char));
  deck_b = (char *)calloc(210, sizeof(char));
  deck_t = (char *)calloc(210, sizeof(char));

  while (1) {
    scanf("%s\n", deck);
    if (!strcmp(deck, "-")) break;
    scanf("%d\n", &m);
    for (i = 0; i < m ; i++) {
      scanf("%d\n", &h);
      strncpy(deck_b, deck, h);
      strcpy(deck_t, (deck + h));
      strcat(deck_t, deck_b);
      strcpy(deck, deck_t);
      free(deck_t);
      free(deck_b);
      deck_b = (char *)calloc(210, sizeof(char));
      deck_t = (char *)calloc(210, sizeof(char));
    }
    printf("%s\n", deck);
  }

  free(deck);
  free(deck_t);
  free(deck_b);

  return 0;
}


Measured memory_bytes: 2072
# 深さ優先探索
def dfs(V, closed): # V:探索頂点, closed:探索済み頂点リスト
 
    # 全頂点を探索したとき
    if not False in closed:
        return 1
    
    answer = 0
    for i in range(N):
        if not graph[V][i]:
            continue
        if closed[i]:
            continue
 
        # 頂点iを探索済みにする
        closed[i] = True
        answer += dfs(i,closed)
 
        # 最深まで探索したとき
        closed[i] = False
    
    return answer
 
N,M = map(int,input().split())
graph = [[False for i in range(N)] for j in range(N)]
 
for i in range(M):
    a,b = map(int,input().split())
    graph[a-1][b-1] = graph[b-1][a-1] = True
 
closed_list = [False]*N
closed_list[0] = True
 
print(dfs(0,closed_list))


Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <map>
#include <set>
#include <queue>
#include <iomanip>
#include <cmath>
using namespace std;
typedef long long int lli;
const lli mod = 1e9+7;
const lli inf = 1e18;
typedef pair<int ,int> pii;
typedef pair<lli, lli> pll;

int main(){
    int n;
    cin >> n;
    vector<int> a(100001);
    lli sum = 0;
    for(int i=0; i<n; i++){
        int c;
        cin >> c;
        sum += c;
        a[c]++;
    }
    int q;
    cin >> q;
    for(int i=0; i<q; i++){
        lli b,c;
        cin >> b >> c;
        sum -= b*a[b];
        sum += c*a[b];
        a[c] += a[b];
        a[b] = 0;
        cout << sum << endl;
    }
    return 0;
}


Measured memory_bytes: 3728
//0049
#include<cstdio>
using namespace std;

int main(void)
{
	int n[26] = {0};
	char str[16];
	while(scanf("%*d,%s", str) == 1)
	{
		if(str[1])
			n[25]++;
		else
			n[str[0]-'A']++;
	}
	printf("%d\n%d\n%d\n%d\n", n['A'-'A'], n['B'-'A'], n[25], n['O'-'A']);
	return 0;
}

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

int main() {
    vector<int> a(2);
    scanf("%d%d", &a[0], &a[1]);
    //sort(a.begin(), a.end());
    if(a[0]*a[1] % 2 == 0) printf("No");
    else printf("Yes");
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<math.h>
using namespace std;
#define mod (1000000000+7)
#define N (10007)
#define INF 1e16
typedef long long ll;
typedef pair<ll,ll> P;



int main(void){
    ll h,n;
    cin>>h>>n;
    ll sum = 0;
    for(ll i=0;i<n;i++){
        ll a;
        cin>>a;
        sum+=a;
    }
    if(sum>=h)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
FAST_IO = 1
if FAST_IO:
    import io, sys, atexit
    rr = iter(sys.stdin.read().splitlines()).next
    sys.stdout = _OUTPUT_BUFFER = io.BytesIO()
    @atexit.register
    def write():
        sys.__stdout__.write(_OUTPUT_BUFFER.getvalue())
else:
    rr = raw_input
rri = lambda: int(rr())
rrm = lambda: map(int, rr().split())
N = rri()
ans= 0
for i in range(1, N+1):
    first = i
    last = i*(N//i)
    ans += (last+first)*(N//i)/2
print(ans)


#26879

Measured memory_bytes: 66832
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using ll = long long;
#define all(x) (x).begin(),(x).end()
#define rp(i,s,e) for(int i=(int)(s);i<(int)(e);++i)
#define irp(i,s,e) for(int i=(int)(s);i>(int)(e);--i)

int main(){
	int N,K; cin>>N>>K;
	vector<ll> A(N);
	// ll pre = 1;
	rp(i,0,K){
		cin>>A[i];
		// pre *= A[i];
	}

	rp(i,K,N){
		cin>>A[i];
		// ll now = pre / A[i-K] * A[i];
		// if(pre < now){
		if(A[i-K] < A[i]){
			cout<<"Yes"<<endl;
		}
		else{
			cout<<"No"<<endl;
		}
	}

}


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

#define ALL(a) (a).begin(), (a).end()
#define llong long long

using namespace std;

bool calc(){
	int n,a,b,c,d; cin >> n >> a >> b >> c >> d;
	a--;b--;c--;d--;
	string str; cin >> str;
	bool cross = a < b && d < c;
	for(int i = 1; i < n; i++){
		if(str[i] == str[i-1] && str[i] == '#'){
			if(a <= i-1 && i <= c) return false;
			if(b <= i-1 && i <= d) return false;
		}
	}
	if(cross){
		for(int i = b+1, ub = min(d+1, n-1); i <= ub; i++){
			if(str[i-2] == str[i-1] && str[i-1] == str[i] && str[i] == '.'){
				return true;
			}
		}
		return false;
	}
	else{
		return true;
	}
}

signed main(){
	if(calc())cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}



Measured memory_bytes: 640
import scala.math._

object Main extends App {

  val YES = "YES"
  val Yes = "Yes"
  val NO = "NO"
  val No = "No"

  val input: Array[Array[Int]] = Array.ofDim(6, 6000000)
  ///////////////////////////////////////////

  val sc = new java.util.Scanner(System.in)
  val a = sc.nextInt
  val b = sc.nextInt
//  val a = List.fill(n)(sc.nextInt)
//  val b = List.fill(n)(sc.nextInt)
//  val c = List.fill(n - 1)(sc.nextInt)

  val ans =
    (b - 1) / (a - 1)
  println(if ((b - 1) % (a - 1) == 0) ans else ans + 1)

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

  def bigIterator(start: BigInt, end: BigInt, step: BigInt = 1) =
    Iterator.iterate(start)(_ + step).takeWhile(_ <= end)

  def lcm(a :Int, b :Int): Int =
    a / gcd(a, b) * b

  def lcm(a :Long, b :Long): Long =
    a / gcd(a, b) * b

  def gcd(a: Int, b: Int): Int =
    if (b == 0) a else gcd(b, a % b)

  def gcd(a: Long, b: Long): Long =
    if (b == 0) a else gcd(b, a % b)

  def setOrUpdated[A, B](a: Map[A, B], key: A, value: B, f: (B, B) => B) =
    a.get(key) match {
      case Some(v) => a.updated(key, f(value, v))
      case _ => a + (key -> value)
    }
}

Measured memory_bytes: 169164
#include <iostream>
using namespace std;
using ll = long long;

ll max(ll X,ll Y){
	if(X>Y){
		return X;
	}else{
		return Y;
	}
}

int  ketasu(ll X){
	if(X>999999999){
		return 10;
	}else{
		if(X>99999999){
			return 9;
		}else{
			if(X>9999999){
				return 8;
			}else{
				if(X>999999){
					return 7;
				}else{
					if(X>99999){
						return 6;
					}else{
						
	
	if(X>9999){
		return 5;
	}else{
		if(X>999){
			return 4;
		}else{
			if(X>99){
				return 3;
			}else{
				if(X>9){
					return 2;
				}else{
					return 1;
				}
			}
		}
	}
					}}}}}
}

int main(){
	
	ll N;
	cin >> N;
	
	ll X=10000000000000;
	ll A;
	for(ll i=0;i<=100000;i++){
		if(X>abs(N-i*i)){
			A=i;
			X=abs(N-i*i);
		}
		if(X==0){
			cout << ketasu(A) << endl;
			return 0;
		}
	}
	
	ll count=0;
	
	while(true){
		if(N%(A-count)==0){
			A=A-count;
			break;
		}
		count++;
	}
	cout << ketasu(max(A,N/A)) << endl;
	return 0;
}


Measured memory_bytes: 256
/*

A try towards peace

*/

#include <bits/stdc++.h>
using namespace std;
#define yo long long int
#define lo mp::cpp_int
#define pb push_back
#define pob pop_back
#define mp make_pair
#define endl "\n"
#define ce(x) cout << x <<"\n"
#define fill(s,v) memset(s,v,sizeof(s))
#define speed  { ios_base::sync_with_stdio(false); cin.tie(0); }
#define for2(i,a,b) for(yo i=a;i<b;i++)
#define for3(i,a,b) for(yo i=a;i<=b;i++)
#define for1(a,b) for(yo i=a;i<b;i++)
#define deb(x) cout<<#x<<" "<<x<<endl; 
#define INFINITE 1000000009
#define ull unsigned long long int
#define take(a,n) for(yo pp=0;pp<n;pp++) { cin>>a[pp]; }
#define take2(a,n) for(yo p=0;p<n;p++) { yo temp;cin>>temp;a.pb(temp); }
#define show(a,n) for(yo p=0;p<n;p++) cout<<a[p]<<" ";
#define _ <<" "<<
#define nl cout<<endl;
#define sq(x) ((x)*(x))
#define call(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define ff first
#define ss second
#define lld long double
#define tc(tt) \
    yo tt;    \
    cin >> tt; \
    for (int _tt = 0; _tt < tt; _tt++) 
 
yo dx[] = {1, 0, -1, 0};
yo dy[] = {0, 1, 0, -1};
const yo N = 1000*1000+5;
const yo size = 1000*100*2+5;
const yo mod = 1000*1000*1000+7;
 
yo gcd(yo a, yo b){if(!b)return a;return gcd(b, a % b);} 
yo power_mod(yo x,yo y,yo p){yo res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;} 
yo lcm(yo a, yo b){return (a*b)/gcd(a, b);}
yo sumofdigits(yo n){yo out=0;while(n){out+=(n%10);n/=10;}return out;}
bool isPrime(yo n){if (n <= 1)  return false; if (n <= 3)  return true; if (n%2 == 0 || n%3 == 0) return false; for (yo i=5; i*i<=n; i=i+6) if (n%i == 0 || n%(i+2) == 0) return false;return true;} 
yo power(yo a,yo b){if(b==0)return 1;if(b&1)return a*power(a,b-1);yo res=power(a,b/2);return res*res;}
yo log(yo d){return log2(d);}
bool isPower(yo x, yo y){if(x==1) return (y==1); yo pow=1; while(pow<y) pow*=x; return(pow == y);}  
bool compare (const pair<yo,yo> &i,const pair<yo,yo> &j){return i.first < j.first;}
yo i,j;

lld polygonArea(lld X[], lld Y[], yo n) 
{   
    lld area = 0.0; 
    yo j = n - 1; 
    for (yo i = 0; i < n; i++) 
    { 
        area += (X[j] + X[i]) * (Y[j] - Y[i]); 
        j = i;  
    }    
    return abs(area); 
} 
bool prime[100200];
vector<yo> dp;
 
void SieveOfEratosthenes(yo n) 
{   
    for (yo p=2; p*p<=n; p++) 
    { 
        if (prime[p] == true) 
        { 
            for ( i=p*p; i<=n; i += p) 
                prime[i] = false;   
        } 
    } 
  
    for (yo p=2; p<=n; p++)  
       if (prime[p]) 
          dp.pb(p); 
} 

int main ()
{
    yo n; cin>>n;
    string s; cin>>s;
    yo count=0;
    for1(0,n-2)
    {
        if(s[i]=='A' && s[i+1]=='B' && s[i+2]=='C')
        {
            count++;
        }
    }
    ce(count);


}
/*


200560490130



*/

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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl





using ll = long long;

const ll mod = 1e9+7;
const int maxn = 1e6 + 5;


ll dvceil(ll x, ll y) {
    return (x+y-1)/y;
}


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

    int m;
    cin>>m;
    ll sum = 0;
    ll cnt = 0;
	
    while (m--) {
	ll d, c;
	cin>>d>>c;
	sum += d*c;
	cnt += c;
    }


    ll res = (cnt-1) + dvceil(sum-9,9);
    cout<<res<<endl;    
    
    return 0;
}


Measured memory_bytes: 3648
fun main(args: Array<String>) {
    val (w, h, x, y) = readLine()!!.split(" ").map { it.toDouble() }

    val m = w.toLong() * h.toLong()

    val s = m / 2.0

    val r = if(x == w/2.0 && y == h/2.0) 1 else 0

    println("$s $r")
}


Measured memory_bytes: 37628
def judge(D):
  n = 0
  while D%4==0:
    n += 1
    D //= 4

  def h1(x,y):
    return ~((x>>n)^(y>>n))&1
  def h2(x,y):
    return ~(x>>n)&1

  return h1 if D%2==1 else h2

N,D1,D2 = map(int,input().split())
j1,j2 = judge(D1),judge(D2)

cnt = 0
for x in range(N*2):
  for y in range(N*2):
    if j1(x,y) and j2(x,y):
      print(x,y)
      cnt += 1
      if cnt >= N*N:
        exit()

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

using namespace std;

template <class T>inline T updmax(T& a, T b) {return a = max(a, b);}
template <class T>inline T updmin(T& a, T b) {return a = min(a, b);}

template <unsigned long long mod> class modint {
public:
	unsigned long long v;
	modint(const long long x = 0) : v(x % mod) {}
	modint operator+(const modint rhs) { return modint(*this) += rhs; }
	modint operator-(const modint rhs) { return modint(*this) -= rhs; }
	modint operator*(const modint rhs) { return modint(*this) *= rhs; }
	modint operator/(const modint rhs) { return modint(*this) /= rhs; }
	modint operator-() { return modint(mod - this->v); }
	modint& operator+=(const modint rhs) {
		v += rhs.v;
		if (v >= mod) v -= mod;
		return *this;
	}
	modint& operator-=(const modint rhs) {
		if (v < rhs.v) v += mod;
		v -= rhs.v;
		return *this;
	}
	modint& operator*=(const modint rhs) {
		v = v * rhs.v % mod;
		return *this;
	}
	modint inverse(modint a) {
		unsigned long long exp = mod - 2;
		modint ret(1ULL);
		while (exp) {
			if (exp % 2) { ret *= a; }
			a *= a;
			exp >>= 1;
		}
		return ret;
	}
	modint& operator/=(modint rhs) {
		(*this) *= inverse(rhs);
		return *this;
	}
	friend ostream& operator<<(ostream& os, modint& u) {
		os << u.v;
		return (os);
	}
	friend istream& operator>>(istream& is, modint& u) {
		is >> u.v;
		return (is);
	}
};

const int MOD = 1000000007;
using mint = modint<MOD>;

const int MAX = 1000005;
mint fact[MAX], invfact[MAX], inv[MAX];

void facinit() {
	fact[0] = fact[1] = 1;	
	invfact[0] = invfact[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++){
		fact[i] = fact[i - 1] * i;
		inv[i] = - inv[MOD%i] * (MOD / i);
		invfact[i] = invfact[i - 1] * inv[i];
	}
}

mint nCr(int n, int r){
	if(n < 0|| r < 0 || n < r)return mint{0};
	return fact[n]*invfact[r]*invfact[n-r];
}

class Solution {
public:
	void solve() {
		int x, y;
		cin >> x >> y;
		if((x + y) % 3 != 0 || x > 2*y || y > 2*x){
			cout << "0\n";
			return;
		}
		if(x < y)swap(x, y);
		int k = (x + y)/3;
		int r = k/2-(x-y)/2;
		facinit();
		cout << (nCr(k, r)).v << endl;

		
		return;
	};
};

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	Solution solution;
	solution.solve();
	return 0;
}

Measured memory_bytes: 23680
import java.util.Scanner;
import java.util.ArrayList;

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    
    ArrayList<String> sa = new ArrayList<>();
    for(String s: scanner.next().split("")) {
      sa.add(s);
    }
    ArrayList<String> sb = new ArrayList<>();
    for(String s: scanner.next().split("")) {
      sb.add(s);
    }
    ArrayList<String> sc = new ArrayList<>();
    for(String s: scanner.next().split("")) {
      sc.add(s);
    }
    
    String player = "a";
    
    while(true) {
      if(player.equals("a")) {
        if(sa.size() == 0) {
          System.out.println("A");
          break;
        }
      	player = sa.get(0);
        sa.remove(0);
      } else if(player.equals("b")) {
        if(sb.size() == 0) {
          System.out.println("B");
          break;
        }
      	player = sb.get(0);
        sb.remove(0);        
      } else {
        if(sc.size() == 0) {
          System.out.println("C");
          break;
        }
      	player = sc.get(0);
        sc.remove(0);
      }
    }
  }
}

Measured memory_bytes: 35632
from collections import deque

h, w = map(int, input().split())
grid = []
for i in range(h):
    grid.append([j for j in input()])

parent = [[-1 for j in range(w)] for i in range(h)]


def bfs(s):
    q = deque()
    check = [[0 for j in range(w)] for i in range(h)]

    q.append(s)
    check[s[0]][s[1]] = 1
    while len(q) != 0:
        u = q.popleft()
        for i in range(h):
            for j in range(w):
                if grid[i][j] == '.' and check[i][j] == 0:
                    dx, dy = abs(i-u[0]), abs(j-u[1])
                    if dx <= 1 and dy <= 1 and dx + dy < 2:
                        check[i][j] = 1
                        parent[i][j] = u
                        q.append((i, j))
        check[u[0]][u[1]] = 2


def main():
    bfs((0, 0))

    if parent[h-1][w-1] != -1:
        x, y = h-1, w-1
        while x != 0 or y != 0:
            grid[x][y] = "#"
            x, y = parent[x][y]
        grid[0][0] = "#"

        pt = 0
        for i in range(h):
            for j in range(w):
                if grid[i][j] == ".":
                    pt += 1

    else:
        pt = -1

    print(pt)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3564
#include <iostream>

int countCn2(int s)
{
	if (s < 0)
		return 0;
	return (s + 2)*(s + 1) / 2;
}

int main()
{
	int s, k;
	std::cin >> k >> s;

	std::cout << countCn2(s) - 3 * countCn2(s - k - 1) + 3 * countCn2(s - k * 2 - 2) - countCn2(s - k * 3 - 3) << std::endl;


	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin >> s;
    int indexA = -1;
    int indexB = -1;
    for(int i = 0; i < s.length(); i++){
        if(s[i]=='A'){
            if(indexA == -1){
                indexA = i;
            }
        }
        if(s[i]=='Z'){
            if(indexA != -1){
                indexB = i;
            }
        }
    }
    cout << indexB - indexA + 1 << endl;
    return 0;
}

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


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

    int N;
    cin >> N;
    int A[N-1];
    int B[N];
    B[N-1]=0;
    rep(i,N-1) {
        cin >> A[i];
        B[i]=0;
    }
    rep(i,N-1){
        B[A[i]-1]++;
    }

    rep(i,N) cout << B[i] << endl;
}

Measured memory_bytes: 5208
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
int main() {
    // ifstream in("data1.txt");
    // cin.rdbuf(in.rdbuf());
    string S,T,U;
    int A, B;
    cin >> S >> T>> A >> B >>U;
    if(U == S){
        cout << A - 1 << " " << B << endl;
    } else {
        cout << A << " " << B - 1 << endl;
    }
}


Measured memory_bytes: 256
#include <stdio.h>
int	main(void)
{
	int n,min,max,i;
	long sum;
	int a[10000];
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	min=max=sum=a[0];
	for(i=1;i<n;i++){
		sum+=a[i];
		if(a[i]<min){
			min=a[i];
		}else if(a[i]>max){
			max=a[i];
		}
	}
	printf("%d %d %ld\n",min,max,sum);
	return	0;
}

Measured memory_bytes: 640
N = int(input())
mydict = []
for i in range(1, N+1):
  a, b=input().split()
  mydict.append([str(a), int(b), i])
mydict = sorted(mydict, key=lambda x:x[1], reverse=True)
mydict = sorted(mydict, key=lambda x:x[0])
for i in mydict:
  print(i[2])

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

using namespace std;
using ll = long long;

#define INF (1LL << 60)
#define MOD 1000000007

#define REP(i,m,n) for(ll (i)=(m),i##_len=(n);(i)<(i##_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define _PR(x) cout << (x) << endl
#define _PS(x) cout << (x) << " "
#define SZ(x) ((int)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define pb push_back

int main()
{
    ll N, M;
    cin >> N >> M;

    if(N == 0) _PR(M*(M-1)/2);
    else if(M == 0) _PR(N*(N-1)/2);
    else _PR(N*(N-1)/2+M*(M-1)/2);


    return 0;
}

/*



*/

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

const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;

bool is_prime(ll n){
	if(n==1)return false;
	for(ll i=2;i*i<=n;i++){
		if(n%i==0)return false;
	}
	return true;
}
vector<ll>divisor(ll n){
	vector<ll>res;
	for(ll i=1;i*i<=n;i++){
		if(n%i==0){
			res.push_back(i);
			if(i!=n/i)res.push_back(n/i);
		}
	}
	return res;
}
map<ll,int>prime_factor(ll n){
	map<ll,int>res;
	for(ll i=2;i*i<=n;i++){
		while(n%i==0){
			res[i]++;
			n/=i;
		}
	}
	if(n!=1)res[n]++;
	return res;
}
vector<ll>prime_enum(int n){
	vector<bool>is_prime(n+1,true);
	is_prime[0]=is_prime[1]=false;
	vector<ll>res;
	for(int i=2;i<=n;i++){
		if(!is_prime[i])continue;
		res.push_back(i);
		for(int j=2*i;j<=n;j+=i){
			is_prime[j]=false;
		}
	}
	return res;
}
int main(){
	int x;cin>>x;
	for(int i=x;;i++){
		if(is_prime(i)){
			cout<<i<<endl;
			return 0;
		}
	}
}

Measured memory_bytes: 256
<?php
  fscanf(STDIN, "%d", $A);
  fscanf(STDIN, "%d", $B);
 if($A == 1 && $B ==2 || $A == 2 && $B ==1){
 echo 3;
 }else if($A == 2 && $B ==3 || $A == 3 && $B ==2){
   echo 1;
 }
else{
  echo 2;
}
   ?>

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

#pragma GCC optimize("O3")
#pragma GCC target("sse4")
// io
#define get(i) scanf("%d", &i)
#define flush fflush(stdin)

// manipulations
#define f(i, n) for (int i = 0; i < n; i++)
#define fr(i, n) for (int i = n - 1; i >= 0; i--)
#define ff(i, a, b) for (int i = a; i <= b; i++)
#define sz(x) int((x).size())
#define fi first
#define se second

// built-in
#define bitcount __builtin_popcount
#define gcd __gcd

// short
#define pb push_back
#define fill(arr, a) memset(arr, a, sizeof(arr))
#define mp(a,b) make_pair(a,b)

// useful bits
#define IN(i,l,r) (i >= l && i <= r);
#define relax(a,b) a = max(a,b);
#define relaxi(a,b) a = min(a,b);

typedef vector<int> VI;
typedef pair<int, int> PII;
typedef long long ll;
typedef long double ld;

ll modpow(ll a, ll b, ll mod = (ll) (1e9 + 7)) 
{if (!b) return 1; a %= mod; return modpow(a * a % mod, b / 2, mod) * (b & 1 ? a : 1) % mod;}

// for rand
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
// use uniform_int_distribution<int>(0, i)(rng)



int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	#ifndef ONLINE_JUDGE
//	freopen("output.txt", "w" , stdout);
	/* freopen("in.txt" , "r" , stdin); */
	/* clock_t start = clock(); */
	#endif
	int n , h;
	cin >> n;
	int mx = -1;
	int ans = 0;
	while(n-- > 0){
		cin >> h;
		if( h >= mx )
			ans++, mx = h;
	}
	cout << ans << endl;

	#ifndef ONLINE_JUDGE
	/* cout << setprecision(12) << ld(clock()-start) / CLOCKS_PER_SEC << endl; */
	#endif
	return 0;
}



Measured memory_bytes: 256
from itertools import product
STR = input()
n = len(STR)
ans = 0
for x in product((True,False), repeat = n-1):
    tmp = 0
    i = 0
    j = 1
    for y in x:
        if y:
            tmp += int(STR[i:j])
            i, j = j, j + 1
        else:
            j += 1
    tmp += int(STR[i:])
    ans += tmp
print(ans)

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

typedef long long ll;
typedef long double ld;

#define pb push_back
#define sort(s) sort(s.begin(),s.end())
#define reverse(s) reverse(s.begin(),s.end())
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)

const ll mod = 1e9+7;

//最大公約数
ll gcd(ll a, ll b) {
    return b ? gcd(b, a%b) : a;
}

//最小公倍数
ll lcm(ll a, ll b) {
    return a / gcd(a, b) * b;
}

//素数判定
bool isPrime(ll x){
    ll i;
    if(x < 2)return 0;
    else if(x == 2) return 1;
    if(x%2 == 0) return 0;
    for(i = 3; i*i <= x; i += 2) if(x%i == 0) return 0;
    return 1;
}

//桁和
int digsum(ll n) {
    int res = 0;
    while(n > 0) {
        res += n%10;
        n /= 10;
    }
    return res;
}

//桁数
int dignum(ll n) {
    int res = 0;
    while(n > 0) {
        res++;
        n /= 10;
    }
    return res;
}

//文字列中の特定の文字カウント
ll stringcount(string s,char c){
    return count(s.cbegin(),s.cend(),c);
}

//階乗
ll ka(ll i){
    ll res=1;
    while(i>0){
        res=res*i;
        i--;
    }
    return res;
}
 
//ncr
ll ncr(ll x,ll y){
    ll a = x;
    ll b = 1;
    if(y>(x/2)){
        y=x-y;
    }
    for(ll i=1;i<y;i++){
        a*=x-i;
        b*=i+1;
    }
    return a/b;
}

//フィボナッチ数列 -92
ll f(ll x){
    ll dp[x+1];
    dp[1]=1;
    dp[2]=1;
    for(ll i=3;i<=x;i++){
        dp[i]=dp[i-1]+dp[i-2];
    }
    return dp[x];
}



int main(){
    string n;
    cin >> n;
    bool ans = false;
    for(int i=0;i<n.size();i++){
        if(n[i]=='7'){
            ans = true;
        }
    }
    if(ans){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3600
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<int, int> P;
typedef pair<int, P> E;
#define MOD (1000000007ll)
#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a += b;
	a %= MOD;
}

int main(void){
	int n,k,i;
	string s;
	cin >> n;
	cin >> s;
	cin >> k; --k;
	for(i=0; i<n; ++i){
		if(s[i]!=s[k]){
			s[i] = '*';
		}
	}
	cout << s << endl;
	return 0;
}


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

#define I inline
#define fi first
#define se second
#define R register
#define LL long long
#define mp make_pair
#define reg register int
#define pii pair<int,int>
#define fo(i, a, b) for(reg i = a; i <= b; i++)
#define fd(i, a, b) for(reg i = a; i >= b; i--)
#define cr const reg&
using namespace std;
const int N = 2e5 + 1;

I int _max(cr x, cr y) {return x > y ? x : y;}
I int _min(cr x, cr y) {return x < y ? x : y;}
I int read() {
	reg x = 0, f = 1; char ch = getchar();
	while(ch < '0' || ch > '9') {if(ch == '-') f = -1; ch = getchar();}
	while(ch >= '0' && ch <= '9') x = (x << 3) + (x << 1) + (ch ^ 48), ch = getchar();
	return x * f;
}
I void ptt(LL x) {if(x >= 10) ptt(x / 10); putchar(x % 10 + '0');}
I void put(LL x) {x < 0 ? putchar('-'), ptt(-x) : ptt(x);}
I void pr1(LL x) {put(x), putchar(' ');}
I void pr2(LL x) {put(x), puts("");}

LL s[N];
map<LL, int> ll;

int main() {
	reg n = read();
	LL ans = 0; ll[0] = 1;
	fo(i, 1, n) s[i] = read() + s[i - 1], ans += ll[s[i]], ll[s[i]]++;
	pr2(ans);
	return 0;
}



Measured memory_bytes: 14336
#include <stdio.h>
 
char str[1005];
char p[1005];
 
int main()
{
    int q, a, b;
    char op[10], *x, *y, c;
     
    scanf("%s%d", str, &q);
    while (q--) {
        scanf("%s%d%d", op, &a, &b);
        if (op[2] == 'i') {             // print
            b++, c = *(str+b), *(str+b) = 0, puts(str+a), *(str+b) = c;
        } else if (op[2] == 'v') {      // reverse
            x = str+a, y = str+b;
            while (x < y) {
                c = *x, *x = *y, *y = c;
                x++, y--;
            }
        } else {                        // replace
            scanf("%s", p);
            x = str+a, y = p;
            while (*y) *x++ = *y++;
        }
    }
    return 0;
}



Measured memory_bytes: 2056
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<time.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
int main(){
	string s;
	int n;
	map<string,vector<int> >in;
	while(cin>>s>>n)in[s].pb(n);
	map<string,vector<int> >::iterator it;
	for(it=in.begin();it!=in.end();it++){
		string d=it->first;
		sort(all(in[d]));
		cout<<d<<endl;
		rep(i,in[d].size()-1)cout<<in[d][i]<<" ";
		cout<<in[d][in[d].size()-1]<<endl;
	}
}

Measured memory_bytes: 1244
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <cmath>
#include <cstdio>
#include <cstdlib>

using namespace std;

int main()
{
  long long int N, A, B;
  cin >> N >> A >> B;
  string S;
  cin >> S;
  
  long long int t = 0; 
  long long int bj = 1;
  for(int i = 0; i < N; i++) {
    if(S[i] == 'a') {
      if(t < A+B) {t++; cout << "Yes" << endl; continue;}
      else {cout << "No" << endl; continue;}
    }
    else if(S[i] == 'b') {
      if(t < A+B && bj <= B) {t++; bj++; cout << "Yes" << endl; continue;}
      else {cout <<"No" << endl; bj++; continue;}
    }
    else cout << "No" << endl;
  }


  return 0;
}


Measured memory_bytes: 896
#include<cstdio>

int main() {
    char S[3];
    int ans = 700;

    scanf("%s", S);

    for (int i = 0; i < 3; i++) {
        if (S[i] == 'o') {
            ans += 100;
        }
    }

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

    return 0;
}

Measured memory_bytes: 128
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<algorithm>
#include<queue>
#include<vector>
#include<set>
#include<set>
#include<map>
#include<ctime>
#include<iostream>
using namespace std;
typedef long long LL;
const int maxn = 1e5 + 5;
char A[maxn];
int main()
{
	LL N;
	while( ~scanf(" %s",A) ){
		scanf(" %lld",&N);
		int len = strlen(A);
		for( int i = 0 ; i < len ; i++ ){
			int m = 'z' - A[i] + 1;
			if( N >= m && m != 26){
				N = N - m;
				A[i] = 'a';
			}
			if( N == 0 ) break;
			if( N > 0 && i == len - 1 && N % 26 != 0 ){
				N = N % 26;
				for( int j = 1 ; j <= N ; j++ ){
					if( A[i] < 'z' )	A[i] += 1;
					else if( A[i] == 'z' )	A[i] = 'a';
				}
			}
		}
		printf("%s\n",A);
		memset( A , ' ' , sizeof(A) );
	}
}

Measured memory_bytes: 384
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;

namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static long Mod = (long)1e9 + 7;
        static void Main(string[] args)
        {
            SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            Out.Flush();
            Read();
        }
        static void Solve()
        {
            var NM = Sarray();
            var N = NM[0];
            var M = NM[1];
            if (N % 2 != 0)
            {
                for (var i = 0; i < M; ++i)
                    WriteLine($"{i + 1} {N - i}");
            }
            else
            {
                var m = Min(M, ((N - 1) / 2 + 1) / 2);
                for (var i = 0; i < m; ++i)
                    WriteLine($"{i + 1} {N - i}");
                for (var i = m; i < M; ++i)
                    WriteLine($"{i + 1} {N - i - 1}");
            }
        }
    }
}

Measured memory_bytes: 36216
#include <queue>
#include <map>
#include <cstdio>
using namespace std;
main(){
	int t=0,T,i,j,k;
	map<int,vector<int> >a;
	for(scanf("%d",&T);t<T;t++)for(scanf("%d%d",&i,&k);k--;a[i].push_back(j))scanf("%d",&j);
	map<int,int>m;
	queue<int>q;
	for(q.push(1),m[1]=1;!q.empty();){
		k=q.front();q.pop();
		for(i=0;i<a[k].size();i++)if(!m[a[k][i]])m[a[k][i]]=m[k]+1,q.push(a[k][i]);
	}
	for(i=1;i<=T;i++)printf("%d %d\n",i,m[i]-1);
}

Measured memory_bytes: 1072
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<cmath>
using namespace std;
#define ll long long
const int MAXN=100000;
int n,k,moe,low;
int a[MAXN+10];ll b[MAXN+10];
bool flag;
ll ans;
ll solve()
{
	ll res=0;
	for(int i=1;i<=n;++i)
	{
		int x=a[i];ll y=b[i];
		if(!flag)
		{
			x>>=low;
			if(x&1)continue;
			x<<=low;
		}
		if((x|moe)^moe)continue;
		res+=y;
	}
	return res;
}
int main()
{
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;++i)scanf("%d%lld",a+i,b+i);
	for(int i=30;~i;--i)
	{
		if(k&(1<<i))
		{
			low=i;
			ans=max(ans,solve());
			moe+=(1<<i);
		}
	}
	flag=true;ans=max(ans,solve());
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5;
int n,now,vi[N],fa[N],vis[N],v[N<<1],deep[N],nex[N<<1],head[N];
void addedges(int x,int y){
	nex[++now]=head[x];
	head[x]=now,v[now]=y;
}
vector<int>b[N];
void dfs(int x){
	deep[x]=deep[fa[x]]+1;
	for(int i=head[x];i;i=nex[i])
		if(v[i]!=fa[x])	fa[v[i]]=x,dfs(v[i]);
	b[deep[x]].push_back(x);
}
int main(){
	scanf("%d",&n);
	for(int i=1;i<n;i++){
		int x,y;
		scanf("%d%d",&x,&y);
		addedges(x,y),addedges(y,x);
	}
	dfs(1);
	for(int i=n;i;i--){
		int si=b[i].size();
		for(int j=0;j<si;j++){
			int k=b[i][j];
			if(!vis[k]){
				if(vis[fa[k]]||k==1){
					puts("First");
					return 0;
				}
				vis[fa[k]]=1;
			}
		}
	}
	puts("Second");
	return 0;
}


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

A = list(map(int, input().strip().split()))

minlen = 0
maxlen = 10**9

while maxlen-minlen > 1:
  mid = (maxlen + minlen)//2
  if mid == 0:
    cur = 1e9
  else:
  	cur = sum((a+mid-1)//mid - 1 for a in A)
  
  if cur > K:
    minlen = mid
  else:
    maxlen = mid

print(maxlen)


Measured memory_bytes: 30772
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;
import std.ascii;


void main()
{
  auto s = readln.chomp.split('/').to!(int[]);
  if (s[0] > 2019) {
    writeln("TBD");
  } else if (s[0] == 2019 && s[1] >= 5) {
    writeln("TBD");
  } else {
    writeln("Heisei");
  }
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
typedef unsigned long long u64;

int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  int a[n+1], num[n+1], c[2*n+1];
  for (int i = 0; i <= n; ++i) {
    a[i] = 0;
  }
  for (int i = 0; i <= 2*n; ++i) {
    c[i] = 0;
  }
  for (int i = 0; i < n; ++i) {
    cin >> num[i+1];
    a[num[i+1]]++;
  }
  int emp = n;
  for (int i = 1; i <= n; ++i) {
    for (int j = 0; j < a[i]; ++j) {
      c[n+i-j]++;
      if (c[n+i-j] == 1 && n+i-j > n) emp--;
    }
  }
  for (int i = 0; i < m; ++i) {
    int x, y;
    cin >> x >> y;
    int xn = num[x];

    if (xn != y) {
      c[n+xn-a[xn]+1]--;
      if (c[n+xn-a[xn]+1] == 0 && n+xn-a[xn]+1 > n) emp++;
      c[n+y-a[y]]++;
      if (c[n+y-a[y]] == 1 && n+y-a[y] > n) emp--;
    }
    cout << emp << endl;

    a[xn]--;
    a[y]++;
    num[x] = y;

  }
  return 0;
}


Measured memory_bytes: 4608
#include<stdio.h>
int main()
{
	int a, b, c,n,num;
	scanf("%d%d%d", &a, &b, &c);
	num = a * c;
	if (b >= num)
	{
		printf("%d\n",c);
	}
	else if(b/a<1)
	{
		printf("0\n");
	}
	else
	{
		printf("%d\n",b/a);
	}
}

Measured memory_bytes: 128
a,b,c,d = list(map(lambda x: int(x), input().split()))
ac, bc, bd, ad = a*c, b*c, b*d, a*d

e1 = ac if ac >= bc else bc
e2 = bd if bd >= ad else ad
ans = e1 if e1 >= e2 else e2
print(ans)

Measured memory_bytes: 9192
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;

int main() {
	int A, B, K;
	cin >> A >> B >> K;
	for (int i = min(A, B); i > 0; i--) {
		if (A % i == 0 && B % i == 0) {
			K--;
		}
		if (K == 0) {
			cout << i << endl;
			break;
		}
	}
}


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

int main(){
   int n;
   cin>>n;
   int a[n];
   for(int i=0; i<n; i++){
        cin>>a[i];
   }
   sort(a, a+n);
   long double as = a[0];
   for(int i = 1; i<n; i++){
        as = (long double)(as + a[i])/2;
   }
   cout<<as<<endl;

return 0;
}


Measured memory_bytes: 256
/*input
1
1

*/
 
/*
                                                    ______________
                                                          |       )
                                                          |   )   /
                                                          |______/
                                                    |     |      \
                                                    |     |   )   \
                                                    |_____|_______)
 
*/
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <iomanip>
#include <fstream>
#include <stack>

using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PII;
typedef pair<ll , ll> PLL;
typedef long double ld;
 
#define pb push_back
#define all(c) c.begin(),c.end()
#define allr(c) c.rbegin(),c.rend()
int mod = 1000000007;
const int inf = 1034567891;
const ll LL_INF = 1234567890123456789ll;
#define PI 3.14159265
#define endl '\n'
#define F first
#define S second
#define debug(x) cout << #x << " = " << x << endl;
#define TRACE
 
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
 
#define out(container) for (auto it : container) cout << it << " "; cout << endl;
 
 
template < typename T > T GCD(T a, T b)            { ll t; while(a) { t = a; a = b % a; b = t; } return b; }
template < typename T > string toString(T a)       { return to_string(a); }
template < typename T > void toInt(string s, T &x) { stringstream str(s); str >> x;}
inline int add(int x, int y){ x += y; if(x >= mod) x -= mod; return x;}
inline int sub(int x, int y){ x -= y; if(x < 0) x += mod; return x;}
inline int mul(int x, int y){ return (x * 1ll * y) % mod;}
inline int powr(int a, ll b){
  int x = 1 % mod;
  while(b){
    if(b & 1) x = mul(x, a);
    a = mul(a, a);
    b >>= 1;
  }
  return x;
}
inline int inv(int a){ return powr(a, mod - 2);}

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  
  int n, k;
  cin >> n >> k;
  vector<int> vec;
  int v;
  for (int i = 0; i < n; i++) {
    cin >> v;
    vec.pb(v);
  }  
  for (int i = k; i < n; i++) {
    if (vec[i] > vec[i - k]) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  }

  return 0;
}

Measured memory_bytes: 4280
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int X = Integer.parseInt(sc.next());
        for (int i = -118; i <= 199; i++) {
            for (int j = -119; j <= 118; j++) {
                if (X == Math.pow(i, 5) - Math.pow(j, 5)) {
                    System.out.println(i + " " + j);
                    return;
                }
            }
        }
    }
}

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

int main(){
    int W,H,x,y,r;
    cin >> W>>H>>x>>y>>r;
    if (x -r >= 0&& x+r <= W && y-r>= 0 && y+r<= H) cout<< "Yes" << endl;
    else cout<< "No" <<endl;
}


Measured memory_bytes: 3096
#include<cstdio>
#include<iostream>
#include<string>
using namespace std;
int main() {
	string t;
	while(getline(cin,t)) {
		for(int i = 0; i < 26; i++) {
			for(int j = 0; j < t.size(); j++) {
				if(t[j] == ' ' || t[j] == '.') continue;
				t[j] += 1;
				if(t[j] > 'z') t[j] -= 26;
			}
			if(t.find("the") != string::npos || t.find("that") != string::npos || t.find("this") != string::npos) {
				cout << t << endl;
				break;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 1176
n = int(input())
X = list(map(int,input().split()))
Y = list(map(int,input().split()))
# p=1,2,3
for p in range(1,4):
    print("{0:.6f}".format(sum([abs(a-b)**p for a,b in zip(X,Y)])**(1/p)))
# p=infinity
print("{0:.6f}".format(max([abs(a-b) for a,b in zip(X,Y)])))


Measured memory_bytes: 5656
import java.io.*;

class Main{
	public static void main(String[] args)throws IOException{
	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

	String str = br.readLine();
	String[] line = str.split(" ");

	int a = Integer.parseInt(line[0]);
	int b = Integer.parseInt(line[1]);
	int c = Integer.parseInt(line[2]);
	int d = Integer.parseInt(line[3]);
	int e = Integer.parseInt(line[4]);
	
	if (c - e  >= 0 && c + e <= a &&  d - e >=0 && d + e <= b){
	System.out.println("Yes");
	}

	else{
	System.out.println("No");
	}
     }
}

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

template<typename T>
void printmatrix(vector<vector<T> > ar){
    for (int i = 0; i < (int)ar.size(); i++) {
        for (int j = 0; j < (int)ar.size(); j++) {
            cout << ar[i][j];
        }
        cout << endl;
    }
}

template<typename T>
void printvector(vector<T> vec){
    for (int i = 0; i < (int)vec.size(); i++) {
        cout << vec[i] << endl;
    }
}


int main(int argc, char const* argv[])
{
    vector<int> vec(3);
    cin >> vec[0] >> vec[1] >> vec[2];
    sort(vec.begin(), vec.end());
    // printvector(vec);

    int d1, d2;
    d1 = vec[1] - vec[0];
    d2 = vec[2] - vec[1];
    // cout << d1 << " " << d2 << endl;

    int total=0;
    total += d2 / 2;
    // cout << total << endl;
    total += (d1 + d2/2 * 2) / 2;
    // cout << total << endl;
    d1 = (d1 + d2/2 * 2) % 2;
    d2 = d2 % 2;
    // cout << d1 << " " << d2 << endl;
    if ((d1 == 0) && (d2 == 1)) {
        total++;
    }else if ((d1 == 1) && (d2 == 0)) {
        total += 2;
    }else if ((d1 == 1) && (d2 == 1)){
        total += 3;
    }
    // vec[1] += (d2 / 2) * 2;

    cout << total << endl;

    return 0;
}

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

using namespace std;

int main(){
    string S;
    cin >> S;
    int N = S.size();
    if(S[0] != S[N-1]){
        if(N%2 == 0) cout << "Second" << endl;
        else cout << "First" << endl;
    }else{
        if(N%2 == 0) cout << "First" << endl;
        else cout << "Second" << endl;
    }
}

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

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

string divide[4] = {"dream","dreamer","erase","eraser"};
string s;

int rec(int k)
{
  if (k == s.size()) return 1;
  int ret = 0;
  REP(i, 4)
  {
    string d = divide[i];
    if (s.substr(k, d.size()) == d)
    {
      ret += rec(k + d.size());
    }
  }
  return ret;
}

int main(void)
{
  cin >> s;
  cout << (rec(0) > 0 ? "YES" : "NO") << endl;
  return 0;
}


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

#define int long long

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

    int tot, n;
    cin >> tot >> n;
    vector <int> dis(n);
    for(int i = 0; i < n; i++){
        cin >> dis[i];
    }
    int maxi = INT_MIN;
    for(int i = 0; i < n-1; i++){
        maxi = max(maxi, dis[(i+1)]-dis[i]);
    }
    maxi = max(dis[0]+tot-dis[n-1], maxi);
    cout << tot-maxi << endl;
    
}

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

int main()
{
	int a, b, c, d;
	scanf("%d%d%d%d", &a, &b, &c, &d);
	
	a = ceil((double)a / (double)d);
	c = ceil((double)c / (double)b);
//	printf("%d\n%d\n", a, c);
	
	if(a >= c)
		printf("Yes\n");
	else
		printf("No\n");
	
	return 0;
}

Measured memory_bytes: 3744