akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
typedef long long LL;
const int N = 2e5+5;
const LL mod = 1e9+7;
char a[N];
//0是左, 1是右
int vis[N];

int main(){
    int n;
    scanf("%d",&n);
    scanf("%s",a+1);
    int cnt = 0;
    for(int i = 1; i <= 2*n; i++){
        int before = 2*n-i;
        if(a[i]=='B'){
            vis[i] = !(before%2);
        }           
        else vis[i] = before%2;
        cnt += vis[i];
    }
    //for(int i = 1; i <= 2*n; i++) printf("i = %d: %d\n",i,vis[i]);
    if(cnt!=n) printf("0\n");
    else{
        LL ans = 1;
        LL l = 0, r = 0;
        for(int i = 2*n; i >= 1; i--){
            if(!vis[i]){
                LL plus = (r-l);
                ans = ans*plus%mod;
                l++;
            }
            else r++;
        }
        for(int i = n; i >= 1; i--){
            ans = ans*(LL)i%mod;
        }
        printf("%lld\n",ans);
    }
    return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define N 200001
int n, m;
ll t1[N << 2], t2[N << 2];
vector<pair<int, int> > a[N];
void up(int x, int L, int R, int l, int r, ll c) {
    if (l <= L && R <= r) return (void)(t1[x] += c, t2[x] += c);
    int mid = (L + R) >> 1;
    if (l <= mid) up(x << 1, L, mid, l, r, c);
    if (r > mid) up(x << 1 | 1, mid + 1, R, l, r, c);
    t1[x] = max(t1[x << 1], t1[x << 1 | 1]) + t2[x];
}
int main() {
    scanf("%d %d", &n, &m);
    for (int i = 1, x, y, z; i <= m; i++) {
        scanf("%d%d%d", &x, &y, &z);
        a[y].push_back(make_pair(x, z));
    }
    for (int i = 1; i <= n; i++) {
        up(1, 1, n, i, i, t1[1]);
        for (int j = 0; j < a[i].size(); j++)
            up(1, 1, n, a[i][j].first, i, a[i][j].second);
    }
    printf("%lld\n", max(t1[1], 0ll));
    return 0;
}

Measured memory_bytes: 22912
def P(*a)puts a.join" ";end
l=gets.to_i
n=l.bit_length-1
P n+1,n*2+l.to_s(2).count(?1)-1
n.times{|i|P i+1,i+2,0;P i+1,i+2,1<<i;P i+1,n+1,l-=1<<i if l[i]==1}

Measured memory_bytes: 1916
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>

using namespace std;
using ll = long long;

void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
int gcd(int a, int b){ return (b == 0) ? a : gcd(b, a % b); }
template<typename S, typename T> ostream& operator<<(ostream &os, const pair<S, T> &p){ cout << "[" << p.first << ", " << p.second << "]"; return os; }

#define Sq(x) (x)*(x)
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Reverse(c) reverse(Range(c))
#define Unique(a) a.erase(unique(Range(a)), a.end())
#define Cusum(T, xs, sxs) vector<T> sxs(xs.size()+1); For(i, (int)xs.size()) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) { for(const auto &e : xs) cout << e << " "; cout << "\n"; }
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")
#define Return(expr) { Cout(expr); return 0; }
#define vc vector
#define Mini(a, x) a = min(a, x)
#define Maxi(a, x) a = max(a, x)

// constexpr int MOD = 1e9+7;

int main(void){
    Cin(int, n, r);
    Cout((n >= 10) ? r : r + 100*(10-n));
}

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

int main() {
    int N;
    int A[200];
    int res = 0;

    cin >> N;
    for (int i=0; i<N; ++i) {
      cin >> A[i];
    }

    while (true) {
      for (int i=0; i<N; ++i) {
        if ( (A[i]%2) == 0 ) {
          A[i] /= 2;
        } else {
          goto OUT;
        }
      }
      res += 1;
    }
    OUT:
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <random>
#include <tuple>
#include <iomanip>
#include <cstring>

using namespace std;

typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define revrep(i, n) for(ll i = (n-1); i >= 0; i--)
#define pb push_back
#define f first
#define s second
const ll INFL = 1LL << 60;//10^18 = 2^60
const int INF = 1 << 30;//10^9
ll MOD = 1000000007;
//ll MOD  = 998244353;
vector<ll> dy = {0, 0, 1, -1, 1, 1, -1, -1, 0};
vector<ll> dx = {1, -1, 0, 0, 1, -1, 1, -1, 0};

ll max(ll a, ll b){return (a > b) ? a : b;}
ll min(ll a, ll b){return (a < b) ? a : b;}

ll pow_long(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2) res *= x;
    x *= x;
    k /= 2;
  }
  return res;
}
ll pow_mod(ll x, ll k){
  x %= MOD; x += MOD; x %= MOD;
  ll res = 1;
  while(k > 0){
    if(k % 2){
      res *= x; res %= MOD;
    }
    x *= x; x %= MOD;
    k /= 2;
  }
  return res;
}

ll inverse(ll x){return pow_mod(x, MOD - 2);};

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

ll lcm(ll x, ll y){return x / gcd(x, y) * y;};

ll kai_mod(ll x){
  if(x == 0) return 1;
  return x * kai_mod(x-1) % MOD;
}

/*
//コンビネーション
const int MAXcomb = 200010;
ll fac[MAXcomb], finv[MAXcomb], inv[MAXcomb];
//facはn!,finvは1/n!
//invは逆元
void COMinit(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < MAXcomb; i++){
        fac[i] = fac[i-1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
        finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
ll comb(int n, int k){
    if(n < k) return 0;
    if(n < 0 || k < 0) return 0;
    return fac[n] * finv[k] % MOD * finv[n-k] % MOD;
}
*/

int main(){
  ll N, M, D;
  cin >> N >> M >> D;
  double ans = (M-1) * (N-D) * 2 / pow(N, 2);
  if(D == 0) ans /= 2;
  cout << fixed << setprecision(10) << ans << endl;

}


Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(){
	int best,set,s1,s2;
	bool t=true;
	while(true){
	best=0;
	for(int i=0;i<5;i++){
		cin>>s1>>s2;
		if(s1==0&&s2==0){
			t=false;
			break;
		}
		if(best<s1+s2){
			set=i;
			best=s1+s2;
		}
	}
	if(t==false)
		break;
	char z='A'+set;
	cout<<z<<" "<<best<<endl;
	}
    return 0;
}

Measured memory_bytes: 1160
import sys
from collections import deque
#import numpy as np
import math
#sys.setrecursionlimit(10**6)
def S(): return sys.stdin.readline().rstrip()
def SL(): return map(str,sys.stdin.readline().rstrip().split())
def I(): return int(sys.stdin.readline().rstrip())
def IL(): return map(int,sys.stdin.readline().rstrip().split())

def solve():
    key = {"A","C","G","T"}
    mx = 0
    count = 0
    for item in s:
        if item in key:
            count += 1
        else:
            mx = max(mx,count)
            count = 0
    mx = max(mx,count)
    print(mx)
    return

if __name__=='__main__':
    s = S()
    solve()

Measured memory_bytes: 9384
using System;
public class Class1
{
	public static void Main()
	{
		string dataSet =Console.ReadLine();
		char[] cs=dataSet.ToCharArray();
		for(int i=0;i<cs.Length;i++)
		{
			if(char.IsUpper(cs[i]))
			{
				cs[i]=char.ToLower(cs[i]);
			}
			else if(char.IsLower(cs[i]))
			{
				cs[i]=char.ToUpper(cs[i]);
			}
			
		}
		string o=new string(cs);
		Console.WriteLine(o);
	}
}

Measured memory_bytes: 9040
#include <bits/stdc++.h>
#define max		  1000000
#define pb		  push_back
#define pairs	  pair<int, int>
#define vi		  vector<int>
#define vb		  vector<bool>
#define vii		  vector<pairs>
#define lb		  lower_bound
#define ub		  upper_bound
#define lli		  long long int
#define endl	  '\n'
#define FastInput ios_base::sync_with_stdio(false), cin.tie(NULL);
#define Cases	  cout << "Case " << ++Case << ": ";
#define __test    \
	int tt;       \
	int Case = 0; \
	cin >> tt;    \
	while (tt--)
#define read(x)	 freopen(x, "r", stdin)
#define write(x) freopen(x, "w", stdout)
#define InputArray(a, n)        \
	for (int i = 0; i < n; i++) \
		cin >> a[i];
#define CopyArray(a, temp, n)   \
	for (int i = 0; i < n; i++) \
		temp[i] = a[i];
#define PrintArray(a, n)        \
	for (int i = 0; i < n; i++) \
		cout << a[i] << " ";    \
	cout << endl;

#define PI 3.14159265358979323846L
using namespace std;

bool hasSeven(int n) {
	int temp;
	while(n > 0) {
		temp = n % 10;
		if(temp == 7) {
			return true;
		}
		n /= 10;
	}
	return false;
}

int main() {
#ifdef Niloy
	read("input.txt");
	write("output.txt");
#endif
	int a;
	cin >> a;

	int result = hasSeven(a);
	if(result) {
		cout << "Yes\n";
	} else {
		cout << "No\n";
	}

	cerr << "time = " << (clock() / CLOCKS_PER_SEC) << " sec" << '\n';
	return 0;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    string s,ss;
    cin>>s>>ss;

    string S = s+ss;
    //cout<<S<<endl;
    ll n=0;
    for(ll i=0;i<S.size();i++)
    {
        S[i]-=48;
        n = n*10+S[i];
       // cout<<n<<endl;
    }
    ll sq = sqrt(n);
    if(sq*sq==n) cout<<"Yes\n";
    else cout<<"No\n";


}



Measured memory_bytes: 256
#include <stdio.h>

int main(int argc, const char * argv[]) {
    // insert code here...
    int w,h;

    while(1){
        scanf("%d %d",&w,&h);

        if(w==0&&h==0){
            break;
        }
        for(int y=1;y<=w;y++){
            for(int x=1;x<=h;x++){
                printf("#");
            }
            printf("\n");
            
        }

        printf("\n");

    }
    return 0;
}


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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;cin >> s;
	vector<int> a(26);
	rep(i,s.size()) a.at(s.at(i)-'a')++;
	rep(i,26){
		if(a.at(i)==0){
			char c=i+'a';
			s+=c;
			cout << s << endl;
			return 0;
		}
	}
	for(int i=24;i>=0;--i){
		char c='z'+1;
		for(int j=i+1;j<26;++j){
			if(s.at(i)<s.at(j)) c=min(c,s.at(j));
		}
		if(c!='z'+1){
			string ans=s.substr(0,i)+c;
			cout << ans << endl;
			return 0;
		}
	}
	cout << -1 << endl;
}

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

using namespace std;

int main(){
    int k, x;
    cin >> k >> x;
    
    int ul = x + (k-1);
    int ll = x - (k-1);
    
    for(int i = ll; i <= ul; ++i){
        cout << i << " ";
    }
    cout << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define sz(x) ((int) (x).size())
#define forn(i,n) for (int i = 0; i < int(n); ++i)
typedef long long ll;
typedef long long i64;
typedef long double ld;
const int inf = int(1e9) + int(1e5);
const ll infl = ll(2e18) + ll(1e10);

int main() {
    #ifdef LOCAL
    assert(freopen("a.in", "r", stdin));
    #else
    #endif
    int n;
    cin >> n;
    string s, t;
    cin >> s >> t;
    for (int i = n; i <= 2 * n; ++i) {
        bool ok = true;
        for (int j = 0; j < n; ++j) {
            if (j + n >= i && s[j] != t[j - i + n])
                ok = false;
        }
        if (ok) {
            cout << i << '\n';
            return 0;
        }
    }
    assert(false);
}


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

#define INF 1000000000

typedef struct{
    int cost;           //ノードのコスト
    char done;          //確定ノード
}Node;

int N;
Node node[100000];

void dijkstra(int g){
    int i, j, k,min;
    for(i = 0; i < N; i++){     //初期化
        node[i].cost = INF;
        node[i].done = 0;
    }
    node[g].cost = 1;           //開始地点のコストは1

    while(1){
        min = INF;
        for(i = 0; i < N; i++){
            if(!node[i].done && min > node[i].cost)min = node[i].cost;
        }
        if(node[0].done==1||min==INF)break;
        for(i = 0; i < N; i++){
            if(node[i].cost == min&&!node[i].done){
                node[i].done=1;
                if(node[(i+1)%N].cost > node[i].cost + 1){
                    node[(i+1)%N].cost = node[i].cost + 1;
                }
                j=(i*10)%N;
                while(node[j].cost>node[i].cost){
                    node[j].cost = node[i].cost;
                    j=(j*10)%N;
                }
            }
        }
    }
}

int main()
{
    scanf("%d",&N);
    int i,j;
    dijkstra(1);

    printf("%d\n",node[0].cost);
    return 0;
}


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


int main()
{
    int x, n;
    int p[105];
    bool t[105];
    memset(t, true, sizeof(t));
    cin >> x >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> p[i];
        t[p[i]] = false;
    }
    int dx = -1;
    do 
    {
        dx++;
    } while (!t[x - dx] && !t[x + dx]);
    cout << (t[x - dx] ? x - dx : x + dx) << endl;
    return 0;
}


Measured memory_bytes: 3592
import java.util.Scanner;

class Main {
  public static void main(String args[]) {
	  Scanner sc=new Scanner(System.in);
	  int i=1;
	  for(;;) {

		int  x=sc.nextInt();
		if(x == 0)break;
		System.out.println("Case "+i+": "+x);
		i=i+1;
	  }
	  sc.close();
  }
}


Measured memory_bytes: 41812
#include <bits/stdc++.h>
using namespace std;
#define rep(i, c) for (int i = 0; i < (int)c; i++)
int main()
{
	string s;
	cin >> s;
	int ans = 0;
	rep(i, s.size()) {
		if(s[i] != s[s.size() - 1 - i]) ans++;
	}
	printf("%d\n", ans / 2);
}

Measured memory_bytes: 3720
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define int long long
using namespace std;

typedef pair<int, int> Pii;

template<typename T>
void readvec(vector<T> &a);
void readindex(vector<int> &a);



signed main(){

    int N, A, B;
    cin >> N;

    int ans = 1000000000000;
    int sumv = 0;
    bool allsame = true;
    REP(i, N){
        cin >> A >> B;
        if(A != B) allsame = false;
        sumv += A;
        if(A > B) ans = min(ans, B);
    }

    if(allsame){
        ans = 0;
    }else{
        ans = sumv - ans;
    }

    cout << ans;
    
    return 0;
}


template<typename T>
void readvec(vector<T> &a){
    REP(i, a.size()){
        cin >> a[i];
    }
}
void readindex(vector<int> &a){
    REP(i, a.size()){
        cin >> a[i];
        a[i]--;
    }
}

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

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 998244353

typedef long long ll;
typedef pair<ll,ll> P;

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

	int n;cin >> n;
	vector<pair<pair<string, ll>, ll>> v;

	REP(i, n){
		string a;
		ll b;cin >> a >> b;
		v.EB(MP(a, -b), i);
	}

	sort(ALL(v));

	REP(i, n){
		cout << v[i].SE + 1 << endl;
	}

	return 0;
}


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

void solve(long long N, vector<long long> a){
	int h = 0;
	for(auto p: a) {
		h += p;
	}
	int idx = 0;
	for(int i = 1; i < N; ++i) {
		if(abs(a[idx] * N - h) > abs(a[i] * N - h)) {
			idx = i;
		}
	}
	cout << idx << endl;
}

int main(){	
	long long N;
	scanf("%lld",&N);
	vector<long long> a((N-1)-0+1);
	for(int i = 0 ; i <= (N-1)-0 ; i++){
		scanf("%lld",&a[i]);
	}
	solve(N, a);
	return 0;
}



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

#define endl '\n'

using namespace std;

struct custom_hash 
{
    static unsigned long long splitmix64(unsigned long long x) 
    {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(unsigned long long x) const 
    {
        static const unsigned long long FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

int k;
void read()
{
	cin >> k;
}

void solve()
{
	long long ans = 0; 
	for (int i = 1; i <= k; i++)
		for (int j = 1; j <= k; j++)
			for (int p = 1; p <= k; p++)
				ans += __gcd(__gcd(i, j), p);

			cout << ans << endl; 
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	
	read();
	solve();
}

Measured memory_bytes: 3636
let n = read_int ()
let rec f n = if n < 10 then 0 else if n mod 10 = 9 then f (n / 10) else -1
let rec g s n b = if n < 10 then s + n + b else g (s + if b = -1 then 9 else n mod 10) (n / 10) b
let _ = Printf.printf "%d\n" @@ g 0 n @@ f n

Measured memory_bytes: 384
# Union-Find
def find(x):
    if par[x] < 0:
        return x
    else:
        par[x] = find(par[x])
        return par[x]


def unite(x, y):
    x = find(x)
    y = find(y)
    if x == y:
        return False
    if par[x] > par[y]:
        x, y = y, x
    par[y] = x
    return True


def same(x, y):
    return find(x) == find(y)


def size(x):
    return -par[find(x)]


N, M = map(int, input().split())
# 負のとき size, 非負のとき parent
par = [-1] * N
for i in range(M):
    x, y, z = map(int, input().split())
    x -= 1
    y -= 1
    unite(x, y)

print(par.count(-1))



Measured memory_bytes: 101752
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define oo 2000000000
const double PI = acos(-1);
const int N = 100010 , K = 201;
int n , m , arr[N] , num = 0;
vector< int > g[N];
vector< int > tmp , v;
bool vis[N];
long long ans = 0;

void DFS(int node){
	vis[node] = true;
	tmp.push_back(arr[node]);
	for(int i=0;i<g[node].size();i++){
		if(vis[g[node][i]]) continue;
		DFS(g[node][i]);
	}
}

int main(){
	scanf("%d%d",&n,&m);
	for(int i=0;i<n;i++)
		scanf("%d",&arr[i]);
	for(int i=0;i<m;i++){
		int u, v;
		scanf("%d%d",&u,&v);
		g[u].push_back(v);
		g[v].push_back(u);
	}
	for(int i=0;i<n;i++){
		if(vis[i]) continue;
		tmp.clear();
		DFS(i);
		num++;
		sort(tmp.begin(),tmp.end());
		for(int i=1;i<tmp.size();i++) v.push_back(tmp[i]);
		ans += tmp[0];
	}
 	sort(v.begin(),v.end());
 	if(num - 2 > (int)v.size()){
 		puts("Impossible");
 	}
 	else{
 		for(int i=0;i<num-2;i++) 
 			ans += v[i];
 		if(num == 1)
 			ans = 0;
 		cout << ans << endl;
 	}
 	return 0;
}

Measured memory_bytes: 7420
#include<bits/stdc++.h>
#define REP(i,first,last) for(int i=first;i<=last;++i)
#define DOW(i,first,last) for(int i=first;i>=last;--i)
using namespace std;
const int MAXN=2e5+5;
int n,m;
int T;
void YES()
{
	printf("YES\n");
}
void NO()
{
	printf("NO\n");
}
void read(int &a)
{
	scanf("%d",&a);
}
void work()
{

}
int main()
{
	double d;
	scanf("%lf",&d);
	printf("%.10lf",d*2*acos(-1));
	return 0;
}

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

int main(){
    int n;
    bool f=false;
    cin >> n;
    rep(i,10){
        rep(k,10){
            if(i*k==n) f=true;
        }
    }
    if(f) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

int main(void){
    int N=0;
    int P[1000];
    char S[1000][100];
    int answer[1000]={0};
    int count=0;
    scanf("%d",&N);
    for(int i=0;i<N;i++){
        scanf("%s %d",S[i],&P[i]);
    }
    for(int i=0;i<N;i++){
        for(int j=0;j<N;j++){
         if(strcmp(S[i],S[j])>0){
             count++;
        }
        else  if(strcmp(S[i],S[j])==0){
            if(P[i]<P[j]){
                count++;
            }
        }
        }
        answer[count]=i;
        count=0;
    }
    for(int i=0;i<N;i++){
    printf("%d\n",answer[i]+1);
    }
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<iostream>
#include<map>
#include<set>
using namespace std;
typedef long long ll;
int main(void)
{
	ll a,b,c;
	scanf("%lld%lld%lld",&a,&b,&c);
	ll flag=0;
	if(a+b<c)
	{
		ll d=c-a-b;
		if(4*a*b<d*d)
		{
			flag=1;
		}
	}
	if(flag)
	{
		printf("Yes\n");
	}
	else
	{
		printf("No\n");
	}
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

n = int(input())

dp = [[[[0]*5 for _ in range(5)] for _ in range(5)] for _ in range(n + 1)]
ng_3 = [(0, 1, 2), (0, 2, 1), (1, 0, 2)]
dp[0][4][4][4] = 1
for i in range(n):
    for j in range(5):
        for k in range(5):
            for l in range(5):
                for m in range(4):
                    if (m, j, k) in ng_3 or (m == 0 and k == 1 and l == 2) or (m == 0 and j == 1 and l == 2):
                        continue
                    dp[i + 1][m][j][k] += dp[i][j][k][l]
ans = 0
for j in range(4):
    for k in range(4):
        for l in range(4):
            ans += dp[-1][j][k][l]
print(ans % (10**9 + 7))

Measured memory_bytes: 45040
#include <iostream>
#include <cstdio>
using namespace std;
int N, M, A, B, C, D, x1, x2, y1, y2;
const int inf = 1001000100;
int K[32][32]={};


int main() {
  scanf("%d%d", &N, &M);

  for (int i=1; i<N+1; i++)
    for (int j=1; j<N+1; j++)
      K[i][j] = inf;
  
  for (int i=0; i<M; ++i){
    scanf("%d,%d,%d,%d", &A, &B, &C, &D);
    //   cerr << "read " << A << " " << B << " " << C << " " << D << endl;
    K[A][B] = C;
    K[B][A] = D;
  }

  scanf("%d,%d,%d,%d", &x1, &x2, &y1, &y2);
  
  for (int k=1; k<N+1; k++){
    for (int i=1; i<N+1; i++){
      for (int j=1; j<N+1; j++){
	if (K[i][j] > K[i][k] + K[k][j])
	  K[i][j] = K[i][k] + K[k][j];
	//cout << K[i][j] << " ";
      }
      //cout << endl;
    }
  }
  cout << y1 - y2 - K[x1][x2] -K[x2][x1] << endl;
}

Measured memory_bytes: 1212
# include <string.h>
# include <iostream>

using namespace std;

int main() {
	char temp[50] = "";
	cin >> temp;
	if ( strcmp( temp, "Sunny" ) == 0 ) {
		cout << "Cloudy";
	} // if 
	
	else if( strcmp( temp, "Cloudy" ) == 0 ) {
		cout << "Rainy";
		
	}// else if
	
	else
		cout << "Sunny";
}// main

Measured memory_bytes: 256
#include <algorithm>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>

using namespace std;

typedef long long ll;
// constexpr ll MOD = 998244353;
constexpr ll MOD = 1000000007;

// struct UnionFind {
//     vector<int> par;
    
//     UnionFind(int N): par(N) {
//         for (int i=0;i<N;i++) par[i] = i;
//     }

//     int root(int x) {
//         if (par[x] == x) return x;
//         else return par[x] = root(par[x]);
//     }

//     void unite(int x, int y) {
//         int rx = root(x);
//         int ry = root(y);
//         if (rx == ry) return;
//         par[rx] = ry;
//     }

//     bool same(int x, int y) {
//         int rx = root(x);
//         int ry = root(y);
//         return rx == ry;
//     }
// };

int digit(int n) {
    int res = 0;
    while (n) {
        n /= 10;
        res++;
    }
    return res;
}

int front(int n) {
    if (digit(n)==1) return n;
    int f = n%10;
    while (n) {
        f = n%10;
        n /= 10;
    }
    return f;
}

int pow10(int b, int e) {
    if (e==0) return b;
    else return 10*pow10(b,e-1);
}

int main(void) {
    int N;
    cin >> N;
    // map<pair<int,int>,ll> A;
    map<pair<int,int>,set<ll>> B;
    int L = digit(N);
    // cout << L << endl;
    for (int i=1;i<=N;i++) {
        int f = front(i), b = i%10;
        if (b == 0) continue;
        B[make_pair(f,b)].insert(i);
    }
    ll res = 0;
    for (int i=1;i<=9;i++) for (int j=1;j<=9;j++) {
        res += B[make_pair(i,j)].size() * B[make_pair(j,i)].size();
    }
    cout << res << endl;

    return 0;
}


Measured memory_bytes: 8704
#include <bits/stdc++.h>
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
#define rep(i,n) for(int i=0;i<int(n);i++)
#define rep1(i,n) for(int i=1;i<=int(n);i++)
#define per(i,n) for(int i=int(n)-1;i>=0;i--)
#define per1(i,n) for(int i=int(n);i>0;i--)
#define foreach(i,n) for(auto &&i:n)
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort(all(x))
#define REV(x) reverse(all(x))
#define MAX(x) *max_element(all(x))
#define MIN(x) *min_element(all(x))
#define LOWitr(x, n) lower_bound(all(x), n)
#define UPRitr(x, n) upper_bound(all(x), n)
#define cii(x) int x;cin >> x
#define cill(x) LL x;cin >> x
#define cis(x) string x;cin >> x
#define co(x) cout << x << endl
#define dump(x)  cout << #x << " = " << (x) << endl
#define truecheck assert
#define pb push_back
#define mp make_pair
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef long long int64;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
template<class T,class U>bool chmax(T &a, const U &b){if (a<b){a=b;return true;}return false;}
template<class T,class U>bool chmin(T &a, const U &b){if (b<a){a=b;return true;}return false;}
template<class T,class U>void vcin(T &v, U n){rep(i, n){typename T::value_type a;cin >> a;v.pb(a);}}
const int INF = 1e9, MOD = 1e9 + 7;
const LL LLINF = 1e16;

int main() {
    fastcin();
    cout << fixed << setprecision(10);
    cii(n);
    string ns = to_string(n);
    if (ns[0]=='7'||ns[1]=='7'||ns[2]=='7')
        co("Yes");
    else
        co("No");

    return 0;
}

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

struct Distance {
  int saki;
  int kyori;
  
  Distance(int s, int k) {
    saki = s;
    kyori = k;
  }
};

using Graph = vector<vector<Distance>>;
vector<int> color;

void coloring(const Graph &G, int v, int d) {
  if ((d % 2) == 0) color[v] = 1;
  else color[v] = 0;
  
  for (auto next_v : G[v]) {
    if (color[next_v.saki] != -1) continue;
    
    int next_d = d + next_v.kyori;
    coloring(G, next_v.saki, next_d);
  }
}

int main() {
  int N; cin >> N;
  
  Graph G(N + 1);
  
  for (int i = 0; i < N; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    G[a].push_back(Distance(b, c));
    G[b].push_back(Distance(a, c));
  }
  
  color.assign(N + 1, -1);
  coloring(G, 1, 0);
  
  for (int i = 1; i < N+1; i++) {
    cout << color[i] << endl;
    //cout << G[i] << endl;
  }
}

Measured memory_bytes: 8192
N, M = map(int,input().split())

sa = set()
sb = set()

for i in range(M):
    a,b = map(int,input().split())
    if a==1 : sb.add(b)
    if b == N : sa.add(a)
    
print("IMPOSSIBLE" if len(sa&sb) == 0 else "POSSIBLE")

Measured memory_bytes: 19128
#include<iostream>
#include<cmath>
using namespace std;
int main(void) {
  long long x, y;
  long long z=0, c=0;
  cin>>x>>y;

  for(int i=0; z<=y; i++) {
    z=x*pow(2LL, i);
    c++;
  }
  cout<<c-1<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <string>
#include <cmath>
#include <vector>
#include <algorithm>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <cctype>
#include <bits/stdc++.h>
#include <queue>

using namespace std;
// for loop
#define F(i, L, R) for(long i = L; i < R; i++)
#define FE(i, L, R) for(long i = L; i <= R; i++)
// for (reversed)
#define FR(i, L, R) for(long i = L; i > R; i--)
#define FRE(i, L, R) for(long i = L; i >= R; i--)

// data types
#define Int long
#define ul unsigned long
#define ll long long
#define ull unsigned long long
#define ui unsigned int
#define us unsigned shoft

// vectors
typedef vector<int> vi;
typedef vector<long> vl;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
#define ALL(c) (c).begin(),(c).end()
#define last(vec) vec.size()-1
#define lastEle(vec) vec[last(vec)]
#define pb push_back
#define InputV(a, n) F(i,0,n){long l; cin >> l; a.pb(l);}

// debug
#define DBG(vari) cerr<<#vari<<" = "<<(vari)<<endl;
#define printA(a, L, R) FE(i, L, R) cout << a[i] << (i==R?'\n':' ')
#define printAF(a, L) printA(a, 0, L-1)
#define printV(a) printA(a, 0, a.size()-1)

// utils
#define char2int(c) (c-'0')
#define bit(x, i) (x&(1<<i))
#define space ' '
#define PI 3.14159265358979323

#define TST 0
int main() {
#if TST==1
    ifstream in ("input.txt");
    cin.rdbuf(in.rdbuf());
#endif
    int s,w;
    cin >> s >> w;
    if(s <= w){
        cout << "unsafe" << endl;
    }else{
        cout << "safe" << endl;
    }
#if TST==1
#endif
}


Measured memory_bytes: 3588
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Map<Integer,Integer> a = new HashMap<>();
        String ret = "YES";
        for(int i=0; i<n; i++){
            Integer wk = sc.nextInt();
            if(a.containsKey(wk)){
				ret = "NO";
                break;
            }else{
                a.put(wk,wk);
              
            }
        }
       System.out.println(ret);
    }
}

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

using ll = long long;

int main(){
    ll n, k;
    std::cin >> n >> k;
    std::vector<ll> a(n);
    for(int i = 0; i < n; i++){
        std::cin >> a[i];
        a[i]--;
    }

    std::vector<ll> arrived(n, -1); // 最後に到着した時間 最初は時刻0で0に到着とする
    ll now = 0;
    ll to;
    arrived[now] = 0;
    ll i;
    for(i = 0; i < k; i++){
        to = a[now];
        if(arrived[to] != -1) break;
        arrived[to] = i + 1;
        now = to;
    }
    // 普通に終わっちゃった場合
    if(i == k){
        std::cout << now + 1 << std::endl;
        return 0;
    }

    ll syuki = (i + 1) - arrived[to];
    ll rest = (k - arrived[to]) % syuki;
    now = to;
    for(ll j = 0; j < rest; j++){
        to = a[now];
        now = to;
    }
    std::cout << now + 1 << std::endl;

    return 0;
}


Measured memory_bytes: 6392
N,K=map(int, input().split())
S=list(input())

beg=[0]
end=[]

for i in range(N):
	if len(beg) != len(end):
		if S[i] == "0":
			end.append(i-1)
	else:
		if S[i] == "1":
			beg.append(i)

if len(beg) != len(end):
	end.append(N-1)

beg.append(N-1)
end.append(N-1)

ans=[1 + end[i+K] - beg[i] for i in range(len(beg)-K)]
print(max(ans) if len(ans) > 0 else N)


Measured memory_bytes: 9380
#include<cstdio>
#include<iostream>
using namespace std;
int a,b,c,d;
int main(){
	cin>>a>>b>>c>>d;
	a+=b;
	b=c+d;
	if(a==b)puts("Balanced");
	if(a<b)puts("Right");
	if(a>b)puts("Left");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define showvp(p) rep(i,p.size()) printf("%d %d\n", p[i].first, p[i].second);
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define incl(v,x) find(rng(v),x)!=v.end()
#define incls(s,c) s.find(c)!=string::npos
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vs = vector<string>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
typedef vector<pii> vp;
typedef vector<tiii> vt;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
#define dame { puts("No"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

char a[1050][1050];

int main () {
  int h, w;
  cin >> h >> w;
  rep(i,h)rep(j,w) cin >> a[i][j];

  vector<vector<ll>> dp(h+1,vector<ll>(w+1,0));
  dp[0][0] = 1;
  rep(i,h) {
    rep(j,w) {
      if (a[i][j+1] != '#') {
        dp[i][j+1] += dp[i][j];
        dp[i][j+1] %= mod;
      }
      if (a[i+1][j] != '#') {
        dp[i+1][j] += dp[i][j];
        dp[i+1][j] %= mod;
      }
    }
  }

  cout << dp[h-1][w-1] << endl;
  return 0;
}

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

// int/long:		-2,147,483,648 - 2,147,483,647 (-2^31 <= int < 2^31)
// long/long long:	-9,223,372,036,854,775,808 - 9,223,372,036,854,775,807 (-2^63 <= long < 2^63)

// lower_bound(A.begin(), A.end(), N)
// upper_bound(...

// A.erase(unique(A.begin(), A.end()), A.end())

// bit: &/and, |/or, ^/xor, ~/not

// getline(cin, String)
// while (getline(cin, S)) {}

// cout <<fixed <<setprecision(10)

// priority_queue<int> q;
// priority_queue<int, vector<int>, less<int>> q; // Default: vector, less
// priority_queue<vector<int>, vector<vector<int>>, greater<vector<int>>> q;

// Graph
// Warshall-Floyd: Distance between each node, N^3
// Dijkstra: Distance from the start node, N^2
// DFS(Depth-First Search)

//
// Notes
//
// When specified less than N, try full scan.
// RE: empty vector
// Check Qs
// long/int
// xor -> count each bit
// Check values
// 	1,000,000 -> Loop
// 	100,000	-> vector(int:400KB, long:800KB) 

#define	INF (1<<30)
//1,073,741,824
//= 536,870,912 *2

#define	MOD 1000000007

#define	Rep0(i, n)	for (int i=0; i<n; i++)
#define	Rep1(i, n)	for (int i=1; i<=n; i++)
#define Sort(P)	sort(P.begin(), P.end())
#define Rev(P)	reverse(P.begin(), P.end())

int	main() {
	int A, B;
	cin >>A >>B;
	if (1==A)
		A=14;
	if (1==B)
		B=14;
	if (A>B)
		cout <<"Alice" <<endl;
	else if (B>A)
		cout <<"Bob" <<endl;
	else
		cout <<"Draw" <<endl;
	return 0;
}



Measured memory_bytes: 256
Imports System
Imports System.Text.RegularExpressions

Module Program
    Sub Main(args As String())

        Dim sInput As String = Console.ReadLine()
        Dim rgx As New Regex("[A-Z]")


        If rgx.IsMatch(sInput) Then
            Console.WriteLine("A")
        Else
            Console.WriteLine("a")
        End If

    End Sub
End Module


Measured memory_bytes: 26860
#include<stdio.h>
int main(void){
	int H,W,i,j;
	while(1){
		scanf("%d %d",&H,&W);
		if(H==0&&W==0){
			break;
		}
		for(i=0;i<H;i++){
			for(j=0;j<W;j++){
				printf("#");
			}
			printf("\n");
		}
printf("\n");
	}
	return 0;
}

Measured memory_bytes: 572
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <stack>
#include <queue>
typedef long long ll;

using namespace std;

struct xyz {
    int a;
    int b;
};

int main() {
    int n;
    cin >> n;
    
    vector<xyz> v(n);
    for(int i = 0; i < n; i++) {
        cin >> v[i].a >> v[i].b;
    }
    
    sort(v.begin(), v.end(), [](const xyz &a, const xyz &b){return a.b < b.b;});
    
    bool flag = true;
    int index = 0;
    int time = 0;
    while(flag) {
        if(time + v[index].a <= v[index].b) {
            time += v[index].a;
            if(index == n - 1) {
                cout << "Yes" << endl;
                return 0;
            }
            else {
                index++;
            }
        }
        else {
            break;
        }
    }
    
    cout << "No" << endl;
    
    return 0;
}



Measured memory_bytes: 1792
#include<bits/stdc++.h> 
#define ll                 long long                            
#define ra                 return a;                                          
#define pb                 push_back                                                     
#define sti                stack<ll>
#define spi                stack<pair<ll,ll>>
#define S                  second
#define msi                map<string,ll >
#define msi                map<string,ll >
#define mii                map<ll ,ll >
#define dbg(x)             { cerr<<#x<<": "<<x<< endl; }
#define dbg2(x,y)          { cerr<<#x<<": "<<x<<" , "<<#y<<": "<<y<<endl; }
#define dbg3(x,y,z)        { cerr<<#x<<": "<<x<<" , "<<#y<<": "<<y<<" , "<<#z<<": "<<z<<endl; }
#define mis                map<ll , string>
#define rep(i,a,b)         for(ll  i=a;i<b;i++)
#define mpi                map<pair<ll ,ll >,ll >                                                
#define pii                pair<ll ,ll >
#define ppb                pop_back
#define F                  first 
#define vi                 vector<ll >
#define vii                vector<pair<ll , ll >>
#define si                 set <ll>
#define vs                 vector<string>
#define all(a)             (a).begin(),(a).end()
#define sz(x)              (ll )x.size()
#define hell               1000000007
#define bs                 binary_search
#define mp                 make_pair
#define qi                 queue<ll>
#define qs                 queue<string>
#define qpi                queue<pair<ll,ll>>
#define qps                queue<pair<ll,string>> 
#define endl               '\n' 
#define itr(a,it)          for(typeof(a.begin()) it=a.begin();it!=a.end();it++)// This will produce const_iterator for const object and normal iterator for non-const object
#define ss                 set<string>
using namespace std;
#define N  300005



int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll n,w;
    cin>>n>>w;
    pair<ll,ll> a[n];
    for(ll i=0;i<n;i++)
    {
        ll q,r;
        cin>>q>>r;
        a[i]=make_pair(q,r);
    }
    sort(a,a+n);
    /*for(ll i=0;i<n;i++)
    {
        cout<<a[i].first<<" "<<a[i].second<<endl;
    }*/
    ll table[n][w+1];
    for(ll i=0;i<=w;i++)
    {
        if(i<a[0].first){table[0][i]=0;}
        else{table[0][i]=a[0].second;}
    }
    for(ll i=0;i<n;i++)
    {
        table[i][0]=0;
    }
    ll z=0;
    for(ll i=1;i<n;i++)
    {
        for(ll j=1;j<=w;j++)
        {
            if(j<a[i].first)
            {
                table[i][j]=table[i-1][j];
            }
            else
            {
                  table[i][j]=max(table[i-1][j],a[i].second+table[i-1][j-a[i].first]);
        
            }
        }
    }
    /*for(ll i=0;i<n;i++)
    {
        for(ll j=0;j<=w;j++)
        {
            cout<<table[i][j]<<" ";
        }
        cout<<endl;
    }*/
    cout<<table[n-1][w];
    
    
    return 0;
}

Measured memory_bytes: 78336
package main

import (
  "bufio"
  "fmt"
  "os"
  "strconv"
  "strings"
)

func main() {
  input := Input{bufio.NewReaderSize(os.Stdin,1000000)}
  n := input.NextInt()
  x := append(append([]int{0},input.NextIntArray()...),2100000000)
  l := input.NextInt()
  q := input.NextInt()
  r := make([][]int,31)
  p := make([]int,31);p[0] = 1
  for k:=0;k<31;k++ { r[k] = make([]int,n+1) }
  for i:=1;i<n+1;i++ { r[0][i] = binarySearch(x,i,l) }
  for k:=0;k<30;k++ {
    p[k+1] = 2*p[k]
    for i:=1;i<n+1;i++ {
      r[k+1][i] = r[k][r[k][i]]
    }
  }
  for j:=0;j<q;j++ {
    a,b := input.NextInts()
    if a > b { a,b = b,a }
    inf,max := 0,b-a
    for max-inf > 1 {
      m := (max+inf)/2
      t := m
      s := a
      for k:=30;k>-1;k-- {
        if t < p[k] { continue }
        t -= p[k]
        s = r[k][s]
      }
      if s < b {
        inf = m
      } else {
        max = m
      }
    }
    fmt.Println(max)
  }
}
func binarySearch(x []int,i int,l int) int {
  sup,min := len(x),i
  for sup-min > 1 {
    m := (sup+min)/2
    if x[m] <= x[i]+l {
      min = m
    } else {
      sup = m
    }
  }
  return min
}

type Input struct { reader *bufio.Reader }
func(i *Input) NextLine() string {
  var buffer []byte
  for {
    line,isPrefix,err := i.reader.ReadLine()
    if err != nil { panic(err) }
    buffer = append(buffer,line...)
    if !isPrefix { break }
  }
  return string(buffer)
}
func(i *Input) NextInt() int {
  n,_ := strconv.Atoi(i.NextLine())
  return n
}
func(i *Input) NextInts() (int,int) {
  s := strings.Split(i.NextLine()," ")
  x,_ := strconv.Atoi(s[0])
  y,_ := strconv.Atoi(s[1])
  return x,y
}
func(i *Input) NextIntArray() []int {
  s := strings.Split(i.NextLine()," ")
  a := make([]int,len(s))
  for i:=0;i<len(s);i++ { a[i],_ = strconv.Atoi(s[i]) }
  return a
}

Measured memory_bytes: 35456
import os
import math

n = int(input())
t,x,y = 0,0,0
for i in range(n):
    ti,xi,yi = (int(x) for x in input().split())
    dt = ti-t
    dist = abs(xi-x) + abs(yi-y)
    if dist>dt:
        print("No")
        exit()
    if dist%2!=dt%2:
        print("No")
        exit()
    t,x,y = ti,xi,yi
print("Yes")


Measured memory_bytes: 3064
#include "bits/stdc++.h"

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

int main() {
	ll a, b, c;

	cin >> a >> b >> c;

	if (b - a == c - b) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a[100100],b[100100];
int main(){
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n+1;i++){
		scanf("%lld",&a[i]);
	}
	for(int i=1;i<=n;i++){
		scanf("%lld",&b[i]);
	}
	ll cnt=0,ans=0;
	for(int i=1;i<=n+1;i++){
		ll delt=min(a[i],b[i]+cnt);
		if(delt<=cnt){
			cnt=b[i];
		}
		else{
			cnt=b[i]+cnt-delt;
		}
		ans+=delt;	
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 1792
#include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

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

	ll A=in<ll>(),B=in<ll>();
	int sum = 0;
	while(A<=B){
		A*=2LL;
		sum++;
	}
	
	out(sum);
	return 0;
}


Measured memory_bytes: 768
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <vector>
#include <string>
#include <iostream>
#include <algorithm>
#include <map>
#include <iterator>
#include <functional>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <fstream>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <list>
#include <sstream>
#include <cstring>
#include <stdio.h>
#include <complex>
using namespace std;
#pragma GCC optimize("O3")
#pragma GCC target("sse4")

typedef long double LD;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int, int> PII;
typedef pair<LD, LD> PDD;
typedef pair<LL, int> PLL;
typedef vector<int> VI;
typedef vector<LL> VLL;
typedef vector<char> VCH;
typedef vector<LD> VLD;
typedef vector<string> VS;
typedef vector<VS> VSS;
typedef vector<VI> VVI;
typedef vector<VLL> VVLL;
typedef vector<VCH> VVCH;
typedef vector<PII> VPII;
typedef vector<PLL> VPLL;
typedef vector<PDD> VPDD;
#define MP make_pair
#define PB push_back
#define X first
#define Y second
#define next fake_next
#define prev fake_prev
#define left fake_left
#define right fake_right

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define RFOR(i,b,a) for(int i = (b) - 1; i >= (a); --i)
#define REP(i, t) FOR(i,0,t)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())
#define FILL(a, value) memset(a, value, sizeof(a))

const LD PI = acos(-1.0);
const LD EPS = 1e-4;
const LL INF = 1e7 - 1;
const LL mod = 1000000007;
const LL LINF = 1e18 + 10;
const int MAXN = 100001;
const int MAXK = 101;

LL gcd(LL x, LL y)
{
	if (!y)
		return x;
	return gcd(y, x%y);
}

LL n;
VLL a;

bool solve()
{
	LL s = 0;
	FOR(i, 0, n)
		s += a[i];

	if ((s - n) & 1)
		return 1;

	FOR(i, 0, n)
		if (a[i] == 1)
			return 0;

	int cnt = 0;
	FOR(i, 0, n)
		cnt += (a[i] & 1);

	if (cnt > 1)
		return 0;

	int g = 0;
	FOR(i, 0, n)
	{
		if (a[i] & 1)
			g = gcd(g, a[i] - 1);
		else
			g = gcd(g, a[i]);
	}

	FOR(i, 0, n)
		if (a[i] & 1)
			if (a[i] % g > 1)
				return 0;

	LL sum = 0;
	FOR(i, 0, n)
		sum += a[i] / g;

	if (sum & 1)
	{
		FOR(i, 0, n)
			a[i] /= g;

		return !solve();
	}

	return 0;
}

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//freopen("In.txt", "r", stdin);
	cin >> n;
	a.resize(n);
	FOR(i, 0, n)
		cin >> a[i];

	if (solve())
		cout << "First";
	else
		cout << "Second";

	cin >> n;
	return 0;
}

Measured memory_bytes: 1024
import sys, math
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial, gcd
from bisect import bisect_left #bisect_left(list, value)
sys.setrecursionlimit(10**7)
enu = enumerate
MOD = 10**9+7
def input(): return sys.stdin.readline()[:-1]
def pri(x): print('\n'.join(map(str, x)))

A, B, C, D = map(int, input().split())


while 1:
    C -= B
    if C<=0:
        print('Yes')
        exit()
    A -= D
    if A<=0:
        print('No')
        exit()



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

int main(){
  string S;
  bool rel;
  bool subbed = true;
  cin >> S;

  reverse(S.begin(),S.end());
  vector<string> words =
    {"dream","dreamer", "erase","eraser"};
  for(int i = 0;i< words.size(); i++){
    reverse(words.at(i).begin(),words.at(i).end());
  }

  while(subbed){
    string old_S = S;
    for(int i = 0;i< words.size(); i++){
      if(S.substr(0,words.at(i).size()) == words.at(i)){
        S = S.substr(words.at(i).size(),S.size());
        subbed = true;
      }
      if(S.size()==0){
        subbed = false;
        rel = true;
      }
    }


    if(S == old_S){
      subbed = false;
      rel = false;
    }
  }
  if(rel){
    cout << "YES" << endl;
  }
  else{
    cout << "NO" << endl;
  }
}


Measured memory_bytes: 616