akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define x first
#define y second
#define pii pair<int,int>
#define pb push_back
#define eb emplace_back
#pragma GCC optimize("unroll-loops")

using namespace std;
using namespace __gnu_pbds;

typedef long long int ll;
typedef unsigned long long int ull;
int MOD=1000000007;
int MOD2=998244353;
vector<int> bases;
const ll LLINF=1ll<<60;
const char en='\n';

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
void yes() {cout<<"YES"<<en; exit(0);}
void no() {cout<<"NO"<<en; exit(0);}
inline int rund() {int x576363482791fuweh=rng();return abs(x576363482791fuweh)%RAND_MAX;}
template<class T>
void prVec(vector<T> w)
{
	cout<<w.size()<<endl;
	for (int i=0;i<int(w.size())-1;++i) cout<<w[i]<<' ';
	if (w.size()) cout<<w[w.size()-1]<<endl;
}

void M998()
{
	swap(MOD,MOD2);
}

ll raand()
{
	ll a=rund();
	a*=RAND_MAX;
	a+=rund();
    return a;
}

#define rand raand

ll raaand()
{
	return raand()*(MOD-7)+raand();
}

string to_upper(string a)
{
	for (int i=0;i<(int)a.size();++i) if (a[i]>='a' && a[i]<='z') a[i]-='a'-'A';
	return a;
}

string to_lower(string a)
{
	for (int i=0;i<(int)a.size();++i) if (a[i]>='A' && a[i]<='Z') a[i]+='a'-'A';
	return a;
}

ll sti(string a)
{
	ll k=0;
	for (int i=0;i<(int)a.size();++i)
	{
		k*=10;
		k+=a[i]-'0';
	}
	return k;
}

string its(ll k)
{
	if (k==0) return "0";
	string a;
	while (k)
	{
		a.push_back((k%10)+'0');
		k/=10;
	}
	reverse(a.begin(),a.end());
	return a;
}

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

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

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

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

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

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

template<class T,class K>
pair<T,K> mp(T a,K b)
{
	return make_pair(a,b);
}

inline int mult(ll a,ll b)
{
	return (a*b)%MOD;
}

inline int pot(int n,int k)
{
	if (k==0) return 1;
	ll a=pot(n,k/2);
	a=mult(a,a);
	if (k%2) return mult(a,n);
	else return a;
}

int divide(int a,int b)
{
	return mult(a,pot(b,MOD-2));
}

inline int sub(int a,int b)
{
	if (a-b>=0) return a-b;
	return a-b+MOD;
}

inline int add(int a,int b)
{
	if (a+b>=MOD) return a+b-MOD;
	return a+b;
}

bool prime(ll a)
{
	if (a==1) return 0;
	for (int i=2;i<=round(sqrt(a));++i)
	{
		if (a%i==0) return 0;
	}
	return 1;
}

ll has(string x)
{
	ll h1=0,h2=0;
	x=to_lower(x);
	for (char a: x)
	{
		h1*=bases[0];
		h1+=a-'a';
		h1%=bases[3];
		h2*=bases[1];
		h2+=a-'a';
		h2%=bases[4];
	}
	return h1*(MOD+13893829)+h2;
}

const int N=300010;
int n,z;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	for (int i=0;i<10;++i) bases.push_back(rand()%(MOD-13893829)+13893829);
	cin>>n>>z;
	cout<<(n+z+z)/(z+z+1);
}




Measured memory_bytes: 256
N = int(input())
S = {i*(i+1): (i, i+1) for i in range(1, 10**5)}

if N * 2 in S:
    a, b = S[N * 2]
    print('Yes')
    print(b)
    R = [[0]*a for _ in range(b)]
    cnt = 1
    for i in range(a):
        for j in range(i,a):
            R[i][j] = cnt
            cnt += 1
    for i in range(1, a):
        for j in range(i):
            R[i][j] = R[j][i]
    for i in range(a):
        R[-1][i] = R[i][i]
    for x in R:
        print(a, *x)
else:
    print('No')

Measured memory_bytes: 31332
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <vector>
using namespace std;
template <class T>
inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

typedef long long ll;
ll MOD = 1000000007;

// a^p
// 2^3 = 2 * 2^2
// 2^2 = 2 * (2^1)
// 2^1 = 2
ll modpow(ll a, ll p, ll mod) {
  if (p == 0) return 1;

  if (p % 2 == 0) {
    ll half = modpow(a, p / 2, mod) % mod;
    return half * half % mod;
  } else {
    return a * modpow(a, p - 1, mod) % mod;
  }
}

// nCa を求める
ll modCombination(ll n, ll a, ll mod) {
  if (n - a < a) {
    return modCombination(n, n - a, mod);
  }

  ll denominator = 1;  // 分母
  ll numerator = 1;    // 分子

  for (ll i = 0; i < a; i++) {
    denominator *= a - i;
    numerator *= n - i;
    denominator %= mod;
    numerator %= mod;
  }

  return numerator * modpow(denominator, mod - 2, mod) % mod;
}

class UnionFind {
 private:
  vector<ll> parents;

 public:
  UnionFind(ll n) : parents(n, -1) {}

  bool issame(ll x, ll y) { return root(x) == root(y); }

  bool merge(ll x, ll y) {
    if (issame(x, y)) return false;

    ll rx = root(x);
    ll ry = root(y);
    if (parents[rx] > parents[ry]) swap(rx, ry);
    // サイズ情報を更新
    parents[rx] += parents[ry];
    // yの親を更新
    parents[ry] = rx;

    return true;
  }

  ll size(ll x) { return -parents[root(x)]; }

 private:
  ll root(ll x) {
    if (parents[x] < 0) return x;
    // 根の親の値に木の(-)サイズの情報を入れる
    return parents[x] = root(parents[x]);
  }
};

void dfs(ll current, ll use, ll N, ll &count) {
  if (current > N) return;
  if (use == 0b111) {
    count++;
  }

  dfs(current * 10 + 7, use | 0b100, N, count);
  dfs(current * 10 + 5, use | 0b010, N, count);
  dfs(current * 10 + 3, use | 0b001, N, count);
}

int main() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);

  ll N;
  cin >> N;

  ll ans = 0;
  dfs(0, 0b000, N, ans);

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int N=1e3+5;
const int inf=80000;
#define endl '\n'

int *p[N];
int vs[N][N];
int idx[N];
bool vis[N],flag;

int getint()
{
	int w = 0, q = 0;
	char c = getchar();
	while (c<'0' || c>'9'&&c != '-')c = getchar();
	if (c == '-')q = 1, c = getchar();
	while (c >= '0'&&c <= '9')w = w * 10 + c - '0', c = getchar();
	return q ? -w : w;
}

int main(){
	int n,sum;
	n=getint();
	for(int i=1;i<=n;i++)
	for(int j=1;j<n;j++)
	vs[i][j]=getint();
	
	for(int i=1;i<=n;i++) p[i]=vs[i]+1,vs[i][n+1]=0;
	
	flag=0;
	sum=0;
	memset(vis,0,sizeof(vis));
	while(!flag&&sum<inf){
		flag=1;
		int cnt=0;
		for(int i=1;i<=n;i++){
			if(*p[i]==0) continue;
			int cp=*p[i];
			if(*p[cp]==0) continue;
			int tp=*p[cp];
			if(tp==i&&!vis[i]&&!vis[cp]){
			vis[i]=vis[cp]=1;
			p[i]++;
			p[cp]++;
			idx[cnt++]=i;
			idx[cnt++]=cp;
			if(flag) flag=0;
			}
		}
		for(int i=0;i<cnt;i++) vis[idx[i]]=0;
		sum++;
	}
	
	if(sum==inf){
		printf("%d\n",n*(n-1)/2);
		return 0;
	}
	for(int i=1;i<=n;i++){
		if(*p[i]!=0){
			flag=0;
			break;
		}
	}
	
	if(!flag) sum=0;
	printf("%d\n",sum-1);
	return 0;
}

Measured memory_bytes: 4224
import sys
sys.setrecursionlimit(10**6)
input = lambda: sys.stdin.readline().rstrip()
inf = float("inf") # 無限

a,b,c,d,h = map(int,input().split())
wake_up = 60*a+b
start_time = 60*c+d - h
print(start_time-wake_up)

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

int main(){
  int a,b;
  cin >> a >> b;
  int ans = 0;
  int ts = 0; int s = 0;
  int t = 0; int o = 0;
  for(int i = a;i <= b;i++){
    ts = i/10000; s = (i%10000)/1000;
    t = (i%10000%1000%100)/10;
    o = i%10000%1000%100%10; 
	if(ts == o && s == t){
      ans++;
    }
  }
  cout << ans << endl;    
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(),(x).end())
#define ALL(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < n; i++)
#define reps(i, m, n) for(int i = m; i < n; i++)
#define repr(i, m, n) for(int i = m; i >= n; i--)
#define db(x) cout<<#x<<"="<<x<<endl
#define deb(x) each(x.begin(),x.end(),(int& y){cout << y <<" ";})
template<class T>bool maxi(T &a,const T &b){if(a<b){ a=b; return 1;} return 0;}
template<class T>bool mini(T &a,const T &b){if(b<a){ a=b; return 1;} return 0;}
#define y0 y3487465 //j0
#define y1 y1347829 //j1
#define INF2 4000000000000000037
#define INF 1000000007
#define PI (acos(-1))
#define MOD 998244353
using namespace std;
typedef long long ll;

vector<int> divisors(int n) {
    vector<int> res;
    for(int i = 1; i*i <= n; ++i) {
        if(n % i != 0) continue;
        res.push_back(i);
        if(n/i == i) continue; // 上の行で追加済み。
        res.push_back(n/i);
    }
    SORT(res);
    return res;
}

ll dp[200010];

void Main(){

    int N; cin>>N;
    string S; cin>>S;

    vector<int> div=divisors(N);

    ll ct=0;
    ll ct2=0;

    repr(i,div.size()-1,1){
        int kiyaku=div[i]; // Nの約数
        if(kiyaku%2==0) continue;
        ll now=N/kiyaku; //kiyaku個の(任意のnow文字+その反転)があるなら2*nowになる
        //if(now==N) continue;

        ll skiyabit=0;

        rep(j,now){
            skiyabit*=2;
            skiyabit+= (S[j]=='1');
            skiyabit%=MOD;
        }

        vector<int> div2=divisors(now);

        rep(j,div2.size()){
            skiyabit=(skiyabit-dp[div2[j]]+MOD)%MOD;
        }

        rep(j,S.size()){
            int x=(S[j%now]=='1' xor !((j/now)%2==0) );

            int kazu= (S[j]=='1');

            if(kazu>x){
                ++skiyabit;
                break;
            }
            if(kazu<x){
                break;
            }
            if(j==S.size()-1){
                ++skiyabit;
                break;
            }
        }

        dp[now]=skiyabit;

        ct+=skiyabit;

        ct2+=skiyabit*now;
        ct2%=MOD;
    }

    ll ans=0;

    rep(i,N){
        ans*=2;
        ans+= (S[i]=='1');
        ans%=MOD;
    }

    ans+=1;

    ans=(ans-ct%MOD+MOD)%MOD;

    ans=ans*2*N%MOD;

    ans=(ans+ct2*2)%MOD;

    cout<< ans<<"\n";


}

//-----------------------------------
int main(){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}
//-----------------------------------


Measured memory_bytes: 720
import bisect,collections,copy,heapq,itertools,math,string
import sys
def S(): return sys.stdin.readline().rstrip()
def M(): return map(int,sys.stdin.readline().rstrip().split())
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())
li = LI()
li.sort(reverse=True)
print(int(str(li[0]) + str(li[1])) + li[2])

Measured memory_bytes: 74472
package main

import "fmt"

func main() {
	// Code for B - A to Z String
	var s string
	fmt.Scanf("%s", &s)

	var A, Z int
	var flag int = 0
	for i := 0; i < len(s); i++ {
		if s[i] == 'A' && flag == 0 {
			A = i
			flag = 1
		} else if s[i] == 'Z' {
			Z = i
		}
	}

	fmt.Println(Z - A + 1)
}


Measured memory_bytes: 3272
def Labeling(terrain):

    label = terrain

    offset = [[-1, 0], [0, -1], [1, 0], [0, 1]]
    signs = ["@", "#", "*"]
    rowLength, colLength = len(label) - 1, len(label[0]) - 1

    step = 0

    for row in range(1, rowLength):
        for col in range(1, colLength):
            mark = label[row][col]

            if mark in signs:
                pointStack = [[row, col]]
                label[row][col] = step

                while 0 < len(pointStack):
                    rowIndex, colIndex = pointStack.pop()

                    for x, y in offset:
                        offsetRow, offsetCol = rowIndex + x, colIndex + y

                        if label[offsetRow][offsetCol] == mark:
                            pointStack.append([offsetRow, offsetCol])
                            label[offsetRow][offsetCol] = step

                step += 1

    return step


Sentinel = "1"

while True:
    col, row = [int(item) for item in input().split()]

    if row == 0 and col == 0:
        break

    land = []
    sentinels = [item for item in Sentinel * row + Sentinel * 2]
    land.append(sentinels)

    for lp in range(col):
        part = [item for item in input()]
        part = [Sentinel] + part + [Sentinel]
        land.append(part)

    land.append(sentinels)

    result = Labeling(land)

    print(result)



Measured memory_bytes: 5992
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main() {
      int k,a,b; cin>>k>>a>>b;
      a=(a+k-1)/k;
      b=b/k;
      cout<<(a>b ? "NG" : "OK")<<endl;
}

Measured memory_bytes: 3636
#include <stdio.h>
#include <vector>
using namespace std;

struct edge{int x,y,c;};
int N = 14; vector<edge> A;

int main()
{
	for (int i=0,p=1;i<12;i++,p*=3){
		A.push_back({N-i-1,N-i,0});
		if (p <= 1000000) A.push_back({N-i-1,N-i,p});
		if (p * 2 <= 1000000) A.push_back({N-i-1,N-i,p*2});
	}
	int L; scanf ("%d",&L); L--;
	A.push_back({1,N,L});
	for (int i=0,p=1;L;i++,p*=3,L/=3){
		int u = L % 3;
		for (int k=0;k<u;k++){
			A.push_back({1,N-i,(L-u+k)*p});
		}
	}

	printf ("%d %d\n",N,A.size());
	for (auto &e : A) printf ("%d %d %d\n",e.x,e.y,e.c);
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<map>
#include<vector>
#include<set>
using namespace std;
typedef long long ll;
typedef long long int llint;
typedef pair<ll, ll> pa;
#define MM 1e9
#define MOD MM+7
#define MAX 101000
#define MAP 110
#define initial_value -1
#define Pair pair<int,int>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define INF (1 << 29) //536870912
int dx[4] = {-1,0,1,0};
int dy[4] = {0,-1,0,1};
ll N,K;
ll h[100010];
int main(){
    cin >> N >> K;
    for(int i = 0; i < N; i++){
        cin >> h[i];
    }
    sort(h,h+N);
    ll mn = 1e10;
    for(int i = 0; i+K-1 < N; i++){
        mn = min(mn, h[i+K-1]-h[i]);
    }
    cout << mn << endl;
}



Measured memory_bytes: 1024
#include<iostream>
#define rep(i,n) for (int i=0;i<(n);i++)
using namespace std;
int main() {
	//input
	int n,count=0;
	char d[100000];
	cin >> n;

	rep(i, n) {
		cin >> d[i];
	}
	
	//compute
	rep(i, n - 1) {
		if (d[i] != d[i + 1]) count++;
	}
	if (d[n - 1] != d[n])count++;


	//output
	cout << count;

	return 0;
}

Measured memory_bytes: 384
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"

using namespace std;

const long long int MOD = 1000000007;
//const int MOD = 998244353;

long long int N, M, K, H, W, L, R;
//int N, M, K, H, W, L, R

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

	cin >> N;
	vector<int>v(N);
	map<int, vector<int>>m;
	for (int i = 0; i < N; i++) {
		cin >> v[i];
		m[v[i]].push_back(i);
	}
	vector<int>l(N);
	vector<int>r(N);
	vector<int>w(N);
	int ans = 0;
	for (int i = 0; i < N; i++) {
		if (v[i]) {
			ans = 1;
			w[i] = 1;
			break;
		}
	}
	for (int i = 0; i < N; i++)l[i] = i - 1;
	for (int i = 0; i < N; i++)r[i] = i + 1;
	int box = ans;
	for (auto i : m) {
		for (auto j : i.second) {
			if (l[j] >= 0)r[l[j]] = r[j];
			if (r[j] < N) {
				l[r[j]] = l[j];
				box += 1 - w[r[j]];
				w[r[j]] = 1;
			}
			box -= w[j];
			w[j] = 0;
		}
		ans = max(ans, box);
	}
	cout << ans << endl;
}


Measured memory_bytes: 15292
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,x,t,ans;
    scanf("%d%d%d", &n,&x,&t);
    ans=n/x;
    if(n%x!=0){
        printf("%d", (ans+1)*t);
    }
    else{
        printf("%d", ans*t);
    }
}


Measured memory_bytes: 3824
//Created by Kira

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

#define IOS cin.sync_with_stdio(0);cin.tie(0); cout.tie(0);
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
#define pii pair<int,int> 
#define pb push_back
#define vi vector<int> 
using ll = long long;

const int mod = 1e9 + 7;

ll pwr(ll a, ll b);
    



int main(){
   IOS

    int r; cin>>r;
    cout<<r * r<<"\n";
    







}

ll pwr(ll a, ll b){
   a %= mod;	//Remove mod if not required
   ll res = 1;
   while(b > 0){
    if(b&1) res = res * a % mod;
        a = a * a % mod;
    b >>= 1;
    }

    return res;
}



Measured memory_bytes: 3624
#include <iostream>
#include <sstream>
#include <iomanip>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <algorithm>
#include <climits>
using namespace std;

int formula(istringstream& iss)
{
	char c;
	iss >> c;
	if('0' <= c && c <= '2')
		return c - '0';
	if(c == '-')
		return 2 - formula(iss);

	int tmp1 = formula(iss);
	iss >> c;
	int tmp2 = formula(iss);
	if(c == '*'){
		if(tmp1 != 2 || tmp2 != 2){
			if(tmp1 == 0 || tmp2 == 0)
				tmp1 = 0;
			else
				tmp1 = 1;
		}
	}else{
		if(tmp1 != 0 || tmp2 != 0){
			if(tmp1 == 2 || tmp2 == 2)
				tmp1 = 2;
			else
				tmp1 = 1;
		}
	}
	iss >> c;

	return tmp1;
}

void solve(string s)
{
	int answer = 0;
	for(int p=0; p<=2; ++p){
		for(int q=0; q<=2; ++q){
			for(int r=0; r<=2; ++r){
				string tmp = s;
				for(unsigned i=0; i<s.size(); ++i){
					if(tmp[i] == 'P')
						tmp[i] = p + '0';
					else if(tmp[i] == 'Q')
						tmp[i] = q + '0';
					else if(tmp[i] == 'R')
						tmp[i] = r + '0';
				}
				istringstream iss(tmp);
				if(formula(iss) == 2)
					++ answer;
			}
		}
	}
	cout << answer << endl;
}

int main()
{
	for(;;){
		string s;
		cin >> s;
		if(s == ".")
			break;

		solve(s);
	}
}

Measured memory_bytes: 0
import sys


def gcd(m, n):
  if n > m:
    m, n = n, m
  if n == 0:
    return m
  else:
    return gcd(n, m % n)


for line in sys.stdin:
  try:
    a, b = [int(i) for i in line.split()]
    g = gcd(a, b)
    l = a * b / g
    print("%d %d" % (g, l))
  except:
    break

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

//{ SFT
using namespace std;
#define int int64_t
#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define reps(i, a, n) for (int i = (a); i > (n); --i)
#define arep(i, a) for (auto &&i : (a))
#define irep(i, x) for (auto i = (x).begin(); i != (x).end(); ++i)
//降順はgreater<T>()
#define all(x) (x).begin(), (x).end()
#define rv(s) reverse((s).begin(), (s).end())
//gcd lcmはそのままok
#define gcd(a, b) __gcd(a, b)
#define bits(n) (1LL << (n))
#define pcnt(x) __builitin_popcountll(x)
//配列内等要素削除
#define unique(x) (x).erase(unique(x).begin(),(x).end()),(x).end());
#define Fixed(n) fixed << setprecision(n)
//総和
#define sowa(n) ((n) * ((n) + 1)) / 2
#define pb(x, a) (x).push_back(a)
#define fb(x, a) (x).flont_back(a)
#define eb(x, a) (x).emplaes_back(a)
#define F first
#define S second
#define cauto (const auto &)
template <class A, class B>
using pii = vector<pair<A, B>>;
//昇順
template <class T>
using min_heap = priority_queue<T, vector<T>, greater<T>>;
//降順
template <class T>
using max_heap = priority_queue<T>;
template <class A, class B>
using umap = unordered_map<A, B>;
template <class A>
using uset = unordered_set<A>;
template <class T>
bool chmax(T &a, const T &b) //最大値更新 返り値はbool
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) //最小値更新 返り値はbool
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
constexpr int INF = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr long long mod1 = 1e9 + 7;
constexpr long long mod2 = 998244353;
//} END

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

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

    while(1){
        c -= b;
        a -= d;
        if(c <= 0){
            cout<<"Yes\n";
            return 0;
        }else if(a <= 0){
            cout<<"No\n";
            return 0;
        }
    }
}

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

#define STRING(str) #str
#define ll long long

template <typename T >
void print_vec_1d(vector<T> x, string name) {
	cout << name << endl;
	cout << "[ ";
	for (int i=0;i<x.size();i++) {
		cout << x[i];
		if (i != x.size()-1) cout << ", ";
		else cout << " ]" << endl;
	}
}

struct S {
	ll zero, one, inv;
};

S op(S l, S r) {
	return S{l.zero+r.zero, l.one+r.one, l.inv+r.inv+l.one*r.zero};
}

S e() {
	return S{0ll, 0ll, 0ll};
}

using F = bool;

S mapping(F f, S x) {
	if (!f) return x;
	return S{x.one, x.zero, x.zero*x.one-x.inv};
}

F composition(F x, F y) {
	// return ((!x && y) || (x && !y));
	return x^y;
}

F id() {
	return false;
}

int main() {
	int N, Q;
	cin >> N >> Q;
	lazy_segtree<S, op, e, F, mapping, composition, id> seg(N);
	for (int i=0;i<N;i++) {
		int A;
		cin >> A;
		seg.set(i, S{1LL, 0LL, 0LL});
		if (A == 1) {
			seg.apply(i, true);
		}
	}

	for (int i=0;i<Q;i++) {
		int T, L, R;
		cin >> T >> L >> R;
		if (T == 1) {
			seg.apply(L-1, R, true);
		} else { // T == 2
			cout << seg.prod(L-1, R).inv << endl;
		}
	}
}

Measured memory_bytes: 20104
import numpy as np

def do():
    data = np.array(input().split(" "), dtype="int64")
    life = np.array(input().split(" "), dtype="int64")
    monsters = data[0]
    smash = data[1]
    if smash == 0:
        print(np.sum(life))
    elif smash >= monsters:
        print(0)
    else:
        a = np.sort(life)[-smash]
        leftover = np.where(life < a, life, 0)
        print(np.sum(leftover))

do()

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

public class Main {
  private static int solve(long x, long y) {
    long n = y / x;
    for (int i = 0; true; i++) {
      if (1L << i > n) {
        return i;
      }
    }
  }
  
  private static void execute(ContestReader reader, PrintWriter out) {
    long x = reader.nextLong();
    long y = reader.nextLong();
    out.println(solve(x, y));
  }
  
  public static void main(String[] args) {
    ContestReader reader = new ContestReader(System.in);
    PrintWriter out = new PrintWriter(System.out);
    execute(reader, out);
    out.flush();
  }
}

class ContestReader {
  private BufferedReader reader;
  private StringTokenizer tokenizer;
  
  ContestReader(InputStream in) {
    reader = new BufferedReader(new InputStreamReader(in));
  }
  
  public String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }
  
  public int nextInt() {
    return Integer.parseInt(next());
  }
  
  public long nextLong() {
    return Long.parseLong(next());
  }
  
  public double nextDouble() {
    return Double.parseDouble(next());
  }
  
  public String[] next(int n) {
    String[] array = new String[n];
    for (int i = 0; i < n; i++) {
      array[i] = next();
    }
    return array;
  }
  
  public int[] nextInt(int n) {
    int[] array = new int[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextInt();
    }
    return array;
  }
  
  public long[] nextLong(int n) {
    long[] array = new long[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextLong();
    }
    return array;
  }
  
  public double[] nextDouble(int n) {
    double[] array = new double[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextDouble();
    }
    return array;
  }
  
  public char[] nextCharArray() {
    return next().toCharArray();
  }
  
  public int[][] nextInt(int n, int m) {
    int[][] matrix = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextInt();
      }
    }
    return matrix;
  }
  
  public long[][] nextLong(int n, int m) {
    long[][] matrix = new long[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextLong();
      }
    }
    return matrix;
  }
  
  public double[][] nextDouble(int n, int m) {
    double[][] matrix = new double[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextDouble();
      }
    }
    return matrix;
  }
  
  public char[][] nextCharArray(int n) {
    char[][] matrix = new char[n][];
    for (int i = 0; i < n; i++) {
      matrix[i] = next().toCharArray();
    }
    return matrix;
  }
}


Measured memory_bytes: 21204
using System;
using System.Collections.Generic;
using System.Runtime.InteropServices.ComTypes;

namespace abc171_d
{
  class Program
  {
    static void Main(string[] args)
    {
      var N = CIn.ReadInt();
      var A = CIn.ReadIntArray(N);
      var Q = CIn.ReadInt();
      var B = new int[Q];
      var C = new int[Q];

      for (int i = 0; i < Q; i++)
      {
        B[i] = CIn.ReadInt();
        C[i] = CIn.ReadInt();
      }

      var sum = 0L;
      var d = new Dictionary<int, int>();

      for (int i = 0; i < N; i++)
      {
        sum += A[i];

        if (d.ContainsKey(A[i])) d[A[i]]++;
        else d.Add(A[i], 1);
      }

      for (int i = 0; i < Q; i++)
      {
        if (d.ContainsKey(B[i]))
        {
          sum += (long)(C[i] - B[i]) * d[B[i]];

          if (d.ContainsKey(C[i])) d[C[i]] += d[B[i]];
          else d.Add(C[i], d[B[i]]);

          d[B[i]] = 0;

        }

        Console.WriteLine(sum);
      }
    }
  }

  static class CIn
  {
    private static readonly Queue<string> fieldBuffer = new Queue<string>();

    public static string Read()
    {
      if (fieldBuffer.Count == 0)
      {
        foreach (var field in Console.ReadLine().Split())
        {
          fieldBuffer.Enqueue(field);
        }
      }
      return fieldBuffer.Dequeue();
    }

    public static int ReadInt() => int.Parse(Read());
    public static long ReadLong() => long.Parse(Read());
    public static double ReadDouble() => double.Parse(Read());

    public static string[] ReadStringArray(int n)
    {
      var array = new string[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = Read();
      }
      return array;
    }

    public static int[] ReadIntArray(int n)
    {
      var array = new int[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = ReadInt();
      }
      return array;
    }

    public static long[] ReadLongArray(int n)
    {
      var array = new long[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = ReadLong();
      }
      return array;
    }

    public static double[] ReadDoubleArray(int n)
    {
      var array = new double[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = ReadDouble();
      }
      return array;
    }

    public static char[,] ReadCharMatrix(int h, int w)
    {
      var array = new char[h, w];
      for (var i = 0; i < h; i++)
      {
        var l = Console.ReadLine().ToCharArray();
        for (var j = 0; j < w; j++)
        {
          array[i, j] = l[j];
        }
      }
      return array;
    }
  }
}


Measured memory_bytes: 50796
/*|In The Name of Allah|*/

#include <bits/stdc++.h>

using namespace std;

const int N = 7e3+5;

int n;

int get(string s , string b){
    int cnt = 0;
    for(int i = 0; i < s.size(); i++){
        cnt += (s[i] != b[i]);
    }
    return cnt;
}

int main(){
    string s;
    cin >> s;
    n = (int)s.size();
    string a = "" , b = "";
    for(int i = 0; i < n; i++){
       b += (i & 1) ? '1' : '0';
       a += (i & 1) ? '0' : '1';
    }
    int best = min(get(a , s) , get(b , s));
    cout << best << endl;
    return 0;
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0; i<(n); i++)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
int main(){
    ll n; cin>>n;
    vector<ll> norimono(5);
    ll nin=1e17;
    rep(i,5){
        cin>>norimono[i];
        chmin(nin, norimono[i]);
    }
    ll res=5;
    if(n%nin==0){
        res+=n/nin-1;
    }else{
        res+=n/nin;
    }
    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 256
class Unionfind():  # Unionfind
    def __init__(self, N):
        self.N = N
        self.parents = [-1] * N

    def find(self, x):  # グループの根
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):  # グループの併合
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):  # グループのサイズ
        return -self.parents[self.find(x)]


n = int(input())
xy = [list(map(int, input().split())) for _ in range(n)]
xysort = [None] * n
for x, y in xy:
    xysort[x - 1] = y - 1

# 解説AC O(n)
uf = Unionfind(n)
cnt, yflag = 0, [0] * n
for x, y in enumerate(xysort[:n - 1]):
    yflag[y] = 1
    cnt += yflag[n - x - 1] + (y > n - x - 1)
    if cnt < x + 1:
        uf.union(x, x + 1)

for x, y in xy:
    print(uf.size(x - 1))


Measured memory_bytes: 116496
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define rep(i,m,n) for(int (i)=(m);(i)<(n);++(i))
#define rREP(i,m,n) for(int (i)=(n)-1;(i)>=(m);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 1000000001;
constexpr ll mod = 1000000007;
constexpr double PI = 3.1415926535897932;

template<class T>inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T>inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

int main() {
	init();

	int a, b; cin >> a >> b;
	double H, M; cin >> H >> M;
	H=H*30+0.5*M; M *= 6;
	double c = (H - M);
	if (c >= 180)c = 360 - c;
	double C = (double)c * PI / 180;
	double ans = a * a + b * b - 2 * a * b * cos(C);
	cout << sqrt(ans) << "\n";

	return 0;
}

Measured memory_bytes: 4272
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}
{-# LANGUAGE RankNTypes #-}
import qualified Data.ByteString.Lazy.Char8 as B
import Data.Maybe
-- import Data.List
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM
import Control.Monad
import Control.Monad.ST
-- import Debug.Trace
-- trace _ = id

solve :: Int -> [Int] -> Int
solve bN as = cost
  where
  vA = VU.fromListN bN as
  acc = VU.scanl' (+) 0 vA

  enc (len,i) = len * bN + i
  size = bN*(bN+1)
  cost = func_memo enc (memovec enc size mf [(bN,0)]) (bN,0)
  mf rd (1,_) = return 0
  mf rd (len,i) = top <$> mapM f [1 .. len-1]
    where
      top lst = (minimum lst) + (acc VU.! (i+len)) - (acc VU.! i)
      f k = (+) <$> rd (k, i) <*> rd (len-k, i+k)

readBInt :: B.ByteString -> Int
readBInt = fst . fromJust . B.readInt

tmain :: B.ByteString -> Int
tmain cont =
  let remLines0 = map B.words (B.lines cont)
      [bs_bN]:remLines1 = remLines0
      bN = readBInt bs_bN
      line2:remLines2 = remLines1
      as = map readBInt line2
  in solve bN as

outAnswer :: Int -> IO ()
outAnswer = putStrLn . show

main :: IO ()
main = outAnswer . tmain =<< B.getContents


-------------------------------------------------------------------------------

memovec :: forall a d. (VU.Unbox a, Show a, Show d) =>
           (d -> Int) -> Int -> 
           (forall m. Monad m => (d -> m a) -> d -> m a) ->
           [d] -> VU.Vector a
memovec encode size mf ds = VU.create $ do
  vec <- VUM.new size
  flags <- VUM.replicate size False
  mapM_ (calc vec flags) ds
  return vec
  where
    calc vec flags d = do
      fv <- VUM.read flags (encode d)
      if fv then VUM.read vec (encode d)
        else do
        val <- mf (calc vec flags) d
        VUM.write vec   (encode d) val
        VUM.write flags (encode d) True
        return val

func_memo :: VU.Unbox a => (d->Int) -> VU.Vector a -> d -> a
func_memo encode vecV d = vecV VU.! (encode d)

-------------------------------------------------------------------------------

inp1 = "4\n10 20 30 40\n"
inp2 = "5\n10 10 10 10 10\n"
inp3 = "3\n1000000000 1000000000 1000000000\n"
inp4 = "6\n7 6 8 6 1 1\n"
tv1 = tmain $ B.pack inp1
tv2 = tmain $ B.pack inp2
tv3 = tmain $ B.pack inp3
tv4 = tmain $ B.pack inp4
test1 = tv1 == 190
test2 = tv2 == 120
test3 = tv3 == 5000000000
test4 = tv4 == 68
alltest = test1 && test2 && test3 && test4



Measured memory_bytes: 5884
N,M = map(int,input().split())
for i in range(N):
    if i == 0:
        lista = list(map(int,input().split()))
        del lista[0]
    else:
        listb = list(map(int,input().split()))
        del listb[0]
        lista = list(set(lista) & set(listb))
print(len(lista))

Measured memory_bytes: 3060
using System;
using System.Linq;
class AIDU0021
    {
        public static void Main(){
            decimal[] vertices = new decimal[8], VAB = new decimal[2], VCD = new decimal[2];
            int N=int.Parse(Console.ReadLine()),i=0;
            string s;
            
            bool[] result=new bool[N];
            for (int l = 0; l<N; l++) {
                s=Console.ReadLine();
                vertices=s.Split(' ').Select(decimal.Parse).ToArray(); //#850520
                for (i = 0; i<2; i++) {
                    VAB[i]=vertices[i+2]-vertices[i];
                    VCD[i]=vertices[i+6]-vertices[i+4];
                }
                result[l]= VAB[0]*VCD[1]-VAB[1]*VCD[0]==0;
            }
            for (i = 0; i<N; i++) {
                Console.WriteLine(result[i] ? "YES" : "NO");
            }
        }
    }

Measured memory_bytes: 9680
#include <iostream>

using namespace std;

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

	int num = 0;

	for (int i = 1; i < 10; ++i) {
		for (int j = 0; j < 10; ++j) {
			for (int k = 0; k < 10; ++k) {
				int n = 10000*i + i + 1000*j + 10*j + 100*k;
				if (a <= n && n <= b) {
					++num;
				}
			}
		}
	}

	cout << num << endl;
}



Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
  int n;
  while(1){
    cin >> n;
    if(n==0) break;
    int a[21][21] = {0}, x, y;
    for(int i=0; i<n; i++){
      cin >> x >> y;
      a[x][y] = 1;
    }
    int m, X=10, Y=10, cnt=0;
    char d;
    int l;
    cin >> m;
    for(int j=0; j<m; j++){
      cin >> d >> l;
      for(int k=0; k<l; k++){
        if(d=='N') Y++;
        else if(d=='E') X++;
        else if(d=='S') Y--;
        else if(d=='W') X--;
        if(a[X][Y]==1){
          cnt++;
          a[X][Y]=0;
        }
      }
    }
    if(cnt==n) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
  return 0;
}

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

int posMod(int n, int m){return (n % m + m) % m;}

const long MOD = 1e9 + 7;
string s;
char c;
int n, t, d, a;
long dp[100010][13];
long digit[3] = {1, 10, 100};
long sign[2] = {1, -1};

int main(){
	cin >> s;
	n = s.size();
	memset(dp, 0, sizeof(dp));
	dp[0][0] = 1;
	for (int i = 0; i < n; ++i){
		c = s[n-i-1];
		d = digit[i%3];
		a = sign[(i/3)%2];
		for (int j = 0; j < 13; ++j){
			if (c == '?'){
				for (int k = 0; k < 10; ++k){
					dp[i+1][j] = (dp[i+1][j] +  dp[i][posMod(j-a*d*k, 13)]) % MOD;
				}
			}
			else{
				t = c - '0';
				dp[i+1][j] = (dp[i+1][j] +  dp[i][posMod(j-a*d*t, 13)]) % MOD;
			}
		}
	}

	printf("%ld\n", dp[n][5]);
}

Measured memory_bytes: 10624
#include<bits/stdc++.h>
#define for(i,a,b) for(int i=a;i<=b;i++)
#define _inline __inline__ __attribute__((always_inline))
using namespace std;
template<class T> _inline void read(T &x){
	T res=0,f=1;
	char c=getchar();
	if(c=='-') f=-1;
	while(c>'9'||c<'0') c=getchar();
	while(c>='0'&&c<='9'){
		res=res*10+c-'0';
		c=getchar();
	}
	x=res*f;
}
template<class T> inline void print(T x){
    if(x<0) putchar('-'),x=-x;
    if(x>9) print(x/10);
    putchar(x%10+'0');
}
int n,k;
int h[200005];
int main(){
	read<int>(n);
	read<int>(k);
	for(i,1,n) read<int>(h[i]);
	if(k>=n){
		puts("0");
		exit(0);
	}
	if(k==0){
		long long sum=0ll;
		for(i,1,n) sum+=h[i];
		print<long long>(sum);
		puts("");
		exit(0);
	}
	sort(h+1,h+n+1);
	int t=n-k;
	long long cnt=0ll;
	for(i,1,t) cnt+=h[i];
	print<long long>(cnt);
	puts("");
	exit(0);
}

Measured memory_bytes: 1024
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
typedef pair<int,int> p;
const int inf=(1<<30);
#define rep(i,a,n)	for(int i=a;i<n;i++)
#define rrep(i,a,n) for(int i=(a-1);i>=n;i--)
	
int main(){
	ll a[100010];
	ll n;
	cin>>n;
	rep(i,0,n)cin>>a[i];
	ll dp[100010];
	rep(i,0,n+1)dp[i]=inf;
	dp[0]=0;
	rep(i,0,n){
		dp[i+1]=min(dp[i+1],dp[i]+abs(a[i+1]-a[i]));
		dp[i+2]=min(dp[i+2],dp[i]+abs(a[i+2]-a[i]));
	}
	cout<<dp[n-1]<<endl;
}

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

int main()
{
	int64_t n;
	cin >> n;

	int64_t ans = 0;
	for (int64_t i = 2; i * i <= n; i++)
	{
		int64_t tmp = 0;
		while (n % i == 0)
		{
			tmp++;
			n /= i;
		}

		for (int64_t j = 1;; j++)
		{
			if (tmp < (j + 1) * j / 2)
			{
				ans += (j - 1);

				break;
			}
		}
	}

	if (n != 1)
	{
		ans++;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define ll          long long int
#define lld          long double
#define pb          push_back
#define pii         pair<ll,ll>
#define mi          map<ll,ll>
#define vec         vector<ll>
#define all(a)     (a).begin(),(a).end()
#define F           first
#define S           second
#define mod         1000000007
#define rep(i,a,b)	for(ll  i=a;i<b;i++)
#define repi(i,a,b)	for(ll  i=a;i<=b;i++)
#define per(i,a,b)  for(ll i=a;i>=b;i--)
#define mp          make_pair
#define mit         map<ll,ll>::iterator
#define sit         set<ll>::iterator
#define pit         pair<ll,ll>::iterator
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
using namespace std;
ll xo(ll x, ll y) 
{ 
   return (x | y) & (~x | ~y); 
}  
ll bin_Expo(ll x,ll n)
{
		if(x==0)
		return 0;
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return bin_Expo(x*x,n/2);
    else                             //n is odd
        return x*bin_Expo(x*x,(n-1)/2);
}
ll mod_Expo(ll x,ll n,ll M)
{
		if(x==0)
		return 0;
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return mod_Expo((x*x)%M,n/2,M);
    else                             //n is odd
        return (x*mod_Expo((x*x)%M,(n-1)/2,M))%M;
 
}
ll NcR(int n, int r) 
{ 
    ll p = 1, k = 1; 
    if (n - r < r) 
        r = n - r; 
  
    if (r != 0) { 
        while (r) { 
            p *= n; 
            k *= r; 
            ll m=__gcd(p, k); 
            p /= m; 
            k /= m; 
            n--; 
            r--; 
        } 
    } 
    else
        p = 1; 
    return p;
}
bool prime_check(ll x)
{
    bool prime = (x >= 2);
    for (ll i = 2; i * i <= x; i++) 
    {
        if (x % i == 0) 
        {
            prime = false;
            break;
        }
    }
    return prime;
}
ll logg(ll base,ll x)
{
    return (ll)(log(x)/log(base));
}
ll po(ll n)
{
	ll k=0;
	while(n%2==0)
	{
		k++;
		n=n/2;
	}
	return k;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int TESTS=1;
//	cin>>TESTS;
    while(TESTS--)
    {
    	ll i,j,l,m,k,n,lcm;
    	cin>>n>>m;
    	ll a[n];
    	rep(i,0,n)
    	cin>>a[i];
    	l=po(a[0]);
    	rep(i,1,n)
    	{
    		if(l!=po(a[i]))
    		{
    			cout<<0;
    			return 0;
			}
		}
    	if(n==1)
    	lcm=a[0];
    	else
    	{
    		lcm=(a[0]*a[1])/__gcd(a[0],a[1]);
    		rep(i,2,n)
    		lcm=(lcm*a[i])/__gcd(lcm,a[i]);
		}
		j=0;
		if(lcm%2!=0)
		cout<<0;
		else
		{
			lcm=lcm/2;
			j=m/lcm;
			j=(j+1)/2;
		}
		cout<<j;
    }
	return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>

int main()
{
    int i;
    int x,y;
    for(i=0;i<3000;i++){
        scanf("%d %d",&x,&y);
        if(x==0 && y==0){
            break;
        }
        if(x<y){
            printf("%d %d\n",x ,y);
        }else {
            printf("%d %d\n",y ,x);
        }
    }
    return 0;
}


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

int main() {
  int A, B , C;
  cin >> A >> B >> C;
  if(A == B && B == C){
    cout << 1 << endl;
  }
  else if(A != B && B != C && A != C){
    cout << 3 << endl;
  }
  else{
    cout << 2 << endl;
  }
}

Measured memory_bytes: 764
#include <iostream>
#include <cstdio>

using namespace std;
typedef long long ll;

ll n,k;
int a[100000];
int check(ll m) {
	int i=0, j;
	for (j = 0; j < k; j++) {
		ll num = 0;
		while (num + a[i] <= m) {
			num += a[i];
			i++;
			
			if (i == n) {
				return n;
			}

		}
	}
	return i;
}



int Search() {
	ll l = 0, r = 100000*10000;
	ll mid;
	while (r - l > 1) {
		mid = (l + r) / 2;
		int m = check(mid);
		if (m >= n) {
			r = mid;
		}
		else {
			l = mid;
		}
		
	}
	return r;

}


int main()
{
	

	
	cin >> n >> k;
	for (int i = 0; i < n; i++) {
		scanf("%d", &a[i]);
	
		
		
	}
	ll p = Search();
	cout << p<<endl;






	return 0;
}


Measured memory_bytes: 3628
#include "bits/stdc++.h"
using namespace std;

typedef long long int ll;

int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int x, y;
	cin >> x >> y;
	if (y & 1){
		cout << "No\n";
	} else {
		y /= 2;
		if (2*x >= y && x <= y) cout << "Yes\n";
		else cout << "No\n";
	}
}

Measured memory_bytes: 3620
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <math.h>
#include <string>
#include <sstream>
#include <stack>
#include <deque>
#define pb push_back
#define make make_pair
#define kaku(a) cout << a << endl;
 
using namespace std;
 
#define ll long long
#define rep(i,n) for(ll i=0;i<n;i++)
#define PI 3.14159265359
long long gcd(long long a,long long b){ return b==0?a:gcd(b,a%b);}
long long lcm(long long a,long long b){ return a/gcd(a,b)*b;}
 
typedef pair<ll,ll> Pair;
const ll inf =1000000007;



vector<ll> ans;

void dfs(string a,ll b){
    if(a.size()==b){
        ll c=stoll(a);
        ans.pb(c);
    }
    else{
        ll c=a.size()-1;//aの末尾の
        ll ua=a[c]-'0';
        for(ll i=-1;i<=1;i++){
            if(ua+i<0) continue;
            if(ua+i>9) continue;
            string e;
            e=to_string(ua+i);
            dfs(a+e,b);
        }
    }
}

void solve(){
    for(ll i=1;i<=10;i++){
        for(ll j=1;j<=9;j++){
            dfs(to_string(j),i);
        }
    }
}

int main(){
    solve();
    sort(ans.begin(),ans.end());
    
    ll k;
    cin >> k;
    cout << ans[k-1]<< endl;
}



Measured memory_bytes: 2420
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <ctype.h>
#include <math.h>
#include <stack>
#include <string>
#include <string.h>
using namespace std;
double PI = 3.1415926535897932;
long mod = 1000000007;

const long INF = 1e9 + 1;

int main() {
  int n,i;
  cin >> n >> i;
  cout << n-i+1 << endl;
}


Measured memory_bytes: 3632
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cctype>
#include <climits>
#include <complex>
using namespace std;

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

vector<string> split(string s,char ch){
  int idx = 0;
  vector<string> res;

  while(idx < s.length()){
    if(s[idx] == ch){
      res.push_back(s.substr(0,idx));
      s = s.substr(idx+1);
      idx = 0;
    }
    else{
      idx++;
    }
  }

  res.push_back(s);

  return res;
}

int main(){
  string s;

  while(cin>>s,s!="#"){
    vector<string> v = split(s,'|');
    bool ans = false;

    rep(i,v.size()){
      vector<string> vv = split(v[i].substr(1,v[i].length()-2),'&');
      char name[3];
      bool flg[3];

      rep(j,3){
        if(vv[j][0] == '~'){
          name[j] = vv[j][1];
          flg[j] = false;
        }
        else{
          name[j] = vv[j][0];
          flg[j] = true;
        }
      }

      if(name[0] == name[1] && name[0] == name[2]){
        if(flg[0] == flg[1] && flg[0] == flg[2]){
          ans = true;
          break;
        }
      }
      else if(name[0] != name[1] && name[0] != name[2] && name[1] != name[2]){
        ans = true;
        break;
      }
      else if(name[0] == name[1]){
        if(flg[0] == flg[1]){
          ans = true;
          break;
        }
      }
      else if(name[0] == name[2]){
        if(flg[0] == flg[2]){
          ans = true;
          break;
        }
      }
      else if(name[1] == name[2]){
        if(flg[1] == flg[2]){
          ans = true;
          break;
        }
      }
    }

    cout<<(ans ? "yes" : "no")<<endl;
  }
}

Measured memory_bytes: 900
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		for (int i=0;i<N;i++) {
			String s =sc.next();
			if ("Y".equals(s)) {
				System.out.println("Four");
				return;
			}
		}
		System.out.println("Three");
	}

}

Measured memory_bytes: 22996
import numpy as np
N = int(input())
A = np.array([int(x) for x in input().split()])
mi= np.min(A)
ma= np.max(A)
mai = np.where(A==ma)
mii = np.where(A==mi)
ans = []
if ma<=0 and mi<=0:
  for i in range(N,1,-1):
    ans.append((i,i-1))
  print(len(ans))
  for i in range(len(ans)):
    print(*ans[i])
  exit()
if ma>=0 and mi>=0:
  for i in range(1,N):
    ans.append((i,i+1))
  print(len(ans))
  for i in range(len(ans)):
    print(*ans[i])
  exit()

if abs(mi)<=abs(ma):
  ans= [(int(mai[0][0])+1,i) for i in range(1,N+1)]
  for i in range(1,N):
    ans.append((i,i+1))
  print(len(ans))
  for i in range(len(ans)):
    print(*ans[i])
  exit()
else:
  ans= [(int(mii[0][0])+1,i) for i in range(1,N+1)]
  for i in range(N,1,-1):
    ans.append((i,i-1))
  print(len(ans))
  for i in range(len(ans)):
    print(*ans[i])
  exit()

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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
    string s;
    cin >> s;
    if(s.front() == s.back()){
        if(s.size() % 2 == 0)
            cout << "First" << endl;
        else
            cout << "Second" << endl;
    }else{
        if(s.size() % 2 == 1)
            cout << "First" << endl;
        else
            cout << "Second" << endl;
    }

	return 0;
}


Measured memory_bytes: 512
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>
#include <stack>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto i:mp)
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll half_inf = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

ll n, a, b;
vector<ll> v;
unordered_map<ll, ll> mp;

// nCr: v[n][r]
vector<vector<ll>> comb(ll n, ll r) {
    vector<vector<ll>> v(n + 1, vector<ll>(n + 1, 0));
    for (int i = 0; i < v.size(); i++) {
        v[i][0] = 1;
        v[i][i] = 1;
    }
    for (int j = 1; j < v.size(); j++) {
        for (int k = 1; k < j; k++) {
            v[j][k] = (v[j - 1][k - 1] + v[j - 1][k]);
        }
    }
    return v;
}


void solve() {
    sort(v.begin(), v.end(), greater<>());
    double tmp = 0;
    rep(i, a) tmp += v[i];
    tmp /= a;
    cout << fixed << tmp << endl;

    if (v[0] == v[a - 1]) {
        ll ans = 0;
        vector<vector<ll>> table = comb(mp[v[0]], min(mp[v[0]], b));
        for (ll i = a; i <= min(mp[v[0]], b); i++) ans += table[mp[v[0]]][i];
        cout << ans << endl;
    } else {
        ll prev = 0;
        rep(i, a) if (v[i] != v[a - 1]) prev++;
        vector<vector<ll>> table = comb(mp[v[a - 1]], a - prev);
        cout << table[mp[v[a - 1]]][a - prev] << endl;
    }
}

int main() {
#ifdef MY_DEBUG
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wmissing-noreturn"
    while (true) {
        mp = unordered_map<ll, ll>();
#pragma clang diagnostic pop
#endif
        cin >> n >> a >> b;
        v.resize(n);
        rep(i, n) {
            cin >> v[i];
            mp[v[i]]++;
        }
        solve();

#ifdef MY_DEBUG
    }
#endif
    return 0;
}

Measured memory_bytes: 256