akhauriyash/Code-Regression huggingface dataset:
import math
n, k = map(int, input().split())

if n < k:
    if n > k / 2:
        print(k - n)
    else:
        print(n)
else:
    s = math.ceil(n / k)
    ans = abs(n - s  * k)
    while True:
        x = abs(ans - k)
        if x > ans:
            break
        else:
            ans = x
    print(ans)


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ITR(x,c) for(__typeof(c.begin() x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin() x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

#define lf double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	ll r, d, x; cin >> r >> d >> x;

	rep(i, 10){
		x = r*x - d;
		cout << x << "\n";
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define vi vector<int>
#define pii pair<int,int>
#define F first
#define S second
#define pb push_back
#define rep(i, b) for(int i = 0; i < b; i++)
#define repr(i, b) for(int i = b - 1 ;i >= 0; i--)
#define It(m) for(auto it = m.begin(); it != m.end(); it++)
#define N 500500
#define PI 3.14159265358979323846264338327950L
#define speed ios_base :: sync_with_stdio(0);cin.tie(0);cout.tie(0);

int main(){
    vi v(3);
    rep(i, 3) cin >> v[i];
    int k; cin >> k;
    while(k!=0) {
        if(v[1] <= v[0]) {
            v[1] *= 2;
        }
        else if(v[2] <= v[1]) {
            v[2] *= 2;
        }
        k--;
    }
    if (v[0] < v[1] && v[1] < v[2]) cout << "Yes";
    else cout << "No";
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;
//typedef tuple<ll, ll, ll> T;

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

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

int N,C,X;
int D[30][39];
int t[3][30];

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b;
    cin>>a>>b;
    int ans=max({2*a-1,2*b-1,a+b});
    cout<<ans<<endl;
}

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

using namespace std;

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

    // ????????´?????\??°
    auto numberOfDaysInYear = [](int y) {
        if (y % 3 == 0) {
            return 20 * 10;
        }
        else {
            return 20 * 5 + 19 * 5;
        }
    };

    // y + 1??´??????999/10/20?????§?????\??°
    vector<int> ym(1001, 0);
    ym[1] = numberOfDaysInYear(1000 - 1);
    for (int i = 2; i < ym.size(); ++i) {
        ym[i] = numberOfDaysInYear(1000 - i) + ym[i - 1];
    }

    auto remainThisYear = [](int y, int m, int d) {
        if (y % 3 == 0) {
            return (10 - m) * 20 + 20 - d;
        }
        else {
            if (m % 2 == 0) {
                return (10 - m) * 20 - ((10 - m) / 2 + 1) + 20 - d;
            }
            else {
                return (10 - m) * 20 - ((10 - m) / 2) + 19 - d;
            }
        }
    };

    auto remainDays = [&remainThisYear, &ym](int y, int m, int d) {
        // ?????´??????????????\??° + ??\??´???1/1??????999/10/20?????§?????\??° + 1??\
        return remainThisYear(y, m, d) + ym[1000 - y - 1] + 1;
    };

    for (int i = 0; i < n; ++i) {
        int y, m, d;
        cin >> y >> m >> d;
        cout << remainDays(y, m, d) << endl;
    }
}

Measured memory_bytes: 3092
n = int(input())
l = list(map(int,input().split()))
count = 0
for i in range(n):
    min_value = i
    for j in range(i,n):
        if l[min_value] > l[j]:
            min_value = j
    t = l[i]
    r = l[min_value]
    if l[i] > l[min_value]:
        l[i] = r
        l[min_value] = t
        count +=1
for s in range(n-1):
        print(l[s],end=' ')
print(l[-1])
print(count)


Measured memory_bytes: 5608
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T> >;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define repb(i, n) for(ll i = (n)-1; i >= 0; i--)
#define repr(i, a, b) for(ll i = (a); i < (b); i++)
#define reprb(i, a, b) for(ll i = (b)-1; i >= (a); i--)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
const ll MOD = 1000000007;
const ll INF = 100000000000000000LL;
inline ll GCD(ll a, ll b){ return b?GCD(b, a % b):a; }
inline ll LCM(ll a, ll b){ return a/GCD(a, b)*b; }
inline ll powint(unsigned long long x, ll y){ ll r=1; while(y){ if(y&1) r*=x; x*=x; y>>=1; } return r; }
inline ll powmod(ll x, ll y, ll m = MOD){ ll r=1; while(y){ if(y&1) r*=x; x*=x; r%=m; x%=m; y>>=1; } return r; }
template<class T>bool chmax(T &a, const T &b){ if(a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a) { a=b; return 1; } return 0; }
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif

void prvec(vll& a){
    ll n = SZ(a);
    rep(i, n){
        cout << a[i] << " \n"[i==n-1];
    }
}

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll n;
    cin >> n;
    vll p(n);
    rep(i, n){
        cin >> p[i];
        p[i]--;
    }
    vll a(n);
    rep(i, n){
        a[i] = 1 + 40000 * i;
    }
    vll b(a);
    reverse(ALL(b));
    rep(i, n){
        a[p[i]] += i;
    }
    prvec(a);
    prvec(b);
    /*
    vll c(n);
    rep(i, n) c[i] = a[i]+b[i];
    prvec(c);
     */
    return 0;
}

Measured memory_bytes: 1152
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <fstream>
#include <cmath>
#include <random>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)
using namespace std;
typedef vector<ll> vec;
typedef vector<vec> mat;

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

    ll N;
    cin >> N;

    if (N % 2 == 1) {
        cout << 0 << endl;
        return 0;
    }

    ll ans = 0;
    while (N > 0) {
        ans += N / 10;
        N /= 5;
    }   

    cout << ans << endl;
}

Measured memory_bytes: 256
n=int(input())
t,a=map(int,input().split())
h=list(map(int,input().split()))
m=10000000
for i in range(n):
    f=t-h[i]*0.006
    if m>abs(a-f):
        m=abs(a-f)
        ans=i+1
print(ans)


Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <set>
#include <cmath>
#include <map>
#include <cstring>
#include <stack>
#include <cstdio>
#include <complex>
#include <iomanip>
#include <cctype>
#include <cassert>
#include <numeric>
#include <climits>
#include <deque>
#include <random>
#include <functional>
#include <unordered_map>
#define rep(i,n) for(int i=0;i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define show(x) cout << #x << " = " << x << endl;
int main(){
    int a[3];
    rep(i,3)cin >> a[i];
    sort(a,a+3);
    if(a[0]==a[1]){
        cout << a[2] << endl;
    }else cout << a[0] << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int n, m;
    cin >> n >> m;
  
  vector<int> a(m);
  vector<int> b(m);
  
  for(int i=0; i<m; i++){
    cin >> a.at(i);
  }
  
  for(int i=0; i<m; i++){
    cin >> b.at(i);
  }
  
  vector<int> road(n);
  
  for(int i=0; i<n; i++){
    cin >> road.at(i);
  }
  
  for(int i=0; i<m; i++){
    road.at((a.at(i))-1) += 1;
    road.at((b.at(i))-1) += 1;
  }
  
  for(int i=0; i<n; i++){
    cout << road.at(i) << endl;
  }
}

Measured memory_bytes: 256
// abc093_b
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <typeinfo>
#include <unordered_map>
#include <utility>
#include <vector>
#define loop(i, a, b) for (int i = a; i < b; i++)
#define rep(i, a) loop(i, 0, a)
#define FOR(i, a) for (auto i : a)
#define pb push_back
#define all(in) in.begin(), in.end()
#define shosu(x) fixed << setprecision(x)
#define show1d(v)                                                              \
  rep(i, v.size()) cout << " " << v[i];                                        \
  cout << endl << endl;
#define show2d(v)                                                              \
  rep(i, v.size()) {                                                           \
    rep(j, v[i].size()) cout << " " << v[i][j];                                \
    cout << endl;                                                              \
  }                                                                            \
  cout << endl;
using namespace std;
typedef long long ll;
typedef int Def;
typedef pair<Def, Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def, pii> pip;
typedef vector<pip> vip;
template <typename A, typename B> bool cmin(A &a, const B &b) {
  return a > b ? (a = b, true) : false;
}
template <typename A, typename B> bool cmax(A &a, const B &b) {
  return a < b ? (a = b, true) : false;
}
const double PI = acos(-1);
const double EPS = 1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9 + 10;
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
int main(int argc, char *argv[]) {
  int a, b, k;
  cin >> a >> b >> k;
  if (b - a + 1 > 2 * k) {
    for (int i = 0; i < k; i++) {
      cout << a + i << endl;
    }
    for (int i = k - 1; i >= 0; --i) {
      cout << b - i << endl;
    }
  } else {
    for (int i = 0; i < (b - a + 1); ++i) {
      cout << a + i << endl;
    }
  }
  return 0;
}


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

using namespace std;

const int MAX_N = 30;
const int MAX_X = 1000000 + 1;

int kin[MAX_N];
bool dp[MAX_X];

bool isPrime ( int n )
{
	for (int i = 2; i*i <= n; ++i) {
		if (n % i == 0) return false;
	}
	return n >= 2;
}

int main ( void )
{
	vector<int> prime;
	prime.push_back(2);
	for (int i = 3; i < MAX_X; i+=2) {
		if (isPrime(i)) { prime.push_back(i); }
	}

	int n, x;

	while (cin >> n >> x, n | x) {
		fill(dp, dp+x, false);
		for (int i = 0; i < n; ++i) {
			cin >> kin[i];
		}

		dp[0] = true;
		for (int i = 0; i < x; ++i) {
			if (!dp[i]) { continue; }
			for (int j = 0; j < n; ++j) {
				if (i+kin[j] <= x) {
					dp[i+kin[j]] = true;
				}
			}
		}

		int ans;
		for (ans = x; ans >= 0; --ans) {
			if (dp[ans] && binary_search(prime.begin(), prime.end(), ans)) {
				break;
			}
		}

		if (ans < 0)
			cout << "NA" << endl;
		else
			cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 2512
#include <iostream>
#include <cassert>
#include <climits>
#include <bitset>
#include <stack>
#include <queue>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>

using namespace std;
typedef long long ll;

typedef pair<ll,ll> P;
long long int INF = 1e18;
double Pi = 3.1415926535897932384626;
long long int mod = 1000000007;

vector<ll> G[500005];
vector<P> tree[500010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
priority_queue <P,vector<P>,greater<P> > pqps2;
//small priority queue
//top pop

int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "RULD";
ll bit[500005];
//↓,→,↑,←


#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define ps(x) cout<<fixed<<setprecision(15)<<x<<endl;
#define pu(x) cout<<x;
#define re(i,a,b) for(i=a;i<=b;i++);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define deba(x) cout<< #x << " = " << x <<endl

ll rui(ll abc,ll bed){
    //abcのbed乗を計算する
    if(bed==0){return 1;}
    else{
        ll ced = rui(abc,bed/2);
        ced *= ced;
        ced %= mod;
        if(bed%2==1){ced*=abc; ced%=mod;}
        return ced;
    }
}
ll gcd(ll number1,ll number2){
	if(number1 > number2){
		swap(number1,number2);
	}
	if(number1 == 0 || number1 == number2){
		return number2;
	}else{
		return gcd(number2 % number1,number1);
	}
}

ll i,j,k,ii,jj,r,l;
ll n,m,num,ans;
ll a,b,c,d,e,g,h,w;
ll x[500005],y[500005],z[500005];
char s[5005][5005];
bool booli[5005],boolj[5005];

ll bitsum(ll i){
	ll s = 0;
	while(i>0){
		//p("hoi");
		s += bit[i];
		i -= i & -i;
	}
	return s;
}
void bitadd(ll b,ll x){
	while(b <= n){
		//p("hoi");
		bit[b] += x;
		b += b & -b;
	}
}

int main(){
    cin >> h >> w;
	for(i=0;i<h;i++){
		cin >> s[i];
	}
	for(i=0;i<h;i++){
		bool flag = true;
		for(j=0;j<w;j++){
			if(s[i][j] == '#')flag = false;
		}
		if(flag)booli[i] = true;
	}
	for(j=0;j<w;j++){
		bool flag = true;
		for(i=0;i<h;i++){
			if(s[i][j] == '#')flag = false;
		}
		if(flag)boolj[j] = true;
	}
	for(i=0;i<h;i++){
		if(booli[i])continue;
		for(j=0;j<w;j++){
			if(boolj[j])continue;
			pu(s[i][j]);
		}
		el;
	}
	
    return 0;
}

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

#define int long long
int MOD = 1000000007;
signed main() {
	int n;
	cin >> n;
	if (n == 1) {
		cout << 1 << endl; return 0;
	}
	if (n == 2) {
		cout << 4 << endl; return 0;
	}
	if (n == 3) {
		cout << 15 << endl; return 0;
	}
	vector<int> dp(n+5);
	dp[0] = n-1;
	dp[1] = n*n - n;
	dp[2] = n*n - n;
	int sum = dp[0] + dp[1] + dp[2];
	for (int i = 3; i < n; i++) {
		dp[i] = ((sum - dp[i - 2]) + MOD) % MOD;
		sum = (sum + dp[i]) % MOD;
	}
	cout << ((sum+1) % MOD) << endl;
	return 0;
}

Measured memory_bytes: 8064
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int64_t INF = 1LL << 60;

int main() {
 string s;
 cin>>s;
 reverse(s.begin(),s.end());
 int w=s.size()+1;
 for(int i=0;i<s.size();i++){
     if(s[i]=='W'){w=i;break;}
 }
 int64_t ans=0;
 for(int i=0;i<s.size();i++){
     if(i>w&&s[i]=='B'){ans+=(i-w);w++;}
 }
 cout<<ans<<endl;
 return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include <bitset>
#include <math.h>
#define inp(X) cin >> X
#define out(X) cout << X << endl
#define rep(i,n) for(int i=0;i<n;i++ )
#define rep2(i,f,n) for(int i=f;i<n;i++ )
#define SORT(A) sort(A.begin(),A.end())
using namespace std;

typedef long long int ll;
const ll MOD = 1e9+7;
#define INF 1000000001

class Tree
{
	public:
//		Tree(int _root);
		int root;
		vector<int> next;
		int value = 0;
};


vector<vector<int>> G;
	
int GetMaxPath( vector<int> &dp, int v)
{
	if(dp[v] != -1) return dp[v];
	if(G[v].size() == 0){
		dp[v] = 0;
		return dp[v];
	}
	int ret = -1;	
	rep(i,G[v].size()){
		ret = max(ret, GetMaxPath(dp,G[v][i])+1);
	}
	dp[v] = ret;
	return dp[v];
	
}

int main(void) {
	
	int N,M;
	inp(N);
	inp(M);
	G.assign(N, vector<int>());
	rep(i,M){
		int x,y;
		inp(x);inp(y);
		--x; --y;
		G[x].push_back(y);
	}
	vector<int> dp(N,-1);
	int ans = -1;
	rep(v,N) ans = max(ans,GetMaxPath(dp,v));
	
	
	out(ans);
	
		
}


Measured memory_bytes: 8192
#include <bits/stdc++.h>
#include<unordered_map>
#define ll long long
using namespace std;
#define sd(n) scanf("%d",&n)
#define clr(a) memset(a,0,sizeof(a))
using namespace std;
const int maxn = 1010;
int A[maxn],cnt = 0,
B[maxn],C[maxn],ans=0;
int check(int x)
{
    memset(A,0,sizeof(A));
    cnt = 0;
    if(x != 0)
    while(x)
    {
       A[cnt++] = x%10;
       x/=10;
    }
    else{
        A[0] = 0;
        cnt++;
    }
    for(int i=0;i<cnt;i++){
        for(int j=0;j<ans;j++ ){
            if(A[i] == C[j])
                return 0;
        }

    }
    return 1;

}
int main()
{
    int n,sum;
    cin>>sum>>n;
    memset(B,0,sizeof(B));
    for(int i=0;i<n;i++){
        int temp;
        cin>>temp;
        B[temp] = 1;
    }
    ans = 0;
    for(int i=0;i<10;i++)
    {
        if(B[i]==1)
            C[ans++]=i;
    }
    for(int i=sum;i<100010;i++)
    {
        if(check(i)){
            cout<<i<<endl;
            break;
        }
    }
    return 0;
}


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

int main() {
    int R;
    cin >> R;

    printf("%.10f\n", 2 * R * acos(-1));

    return 0;
}

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

const ll MAX = 200000;
const ll INF = 1001001001;
const ll MOD = 1000000007;

ll N, ans=0, tmp1=0, tmp2=0;
vector<ll> A, S;

ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

signed main(){
    cin >> N;
    S.resize(N,0);
    for(int i=0;i<N;i++) {
        ll a;
        cin >> a;
        A.push_back(a);
    }
    sort(A.begin(),A.end());
    for(int i=0;i<N;i++) {
        tmp1 = A[i]*modpow(2,i,MOD);
        tmp1 %= MOD;
        tmp2 = modpow(2,N-i-1,MOD);
        if(N-2-i>=0) tmp2 += (N-1-i)*modpow(2,N-2-i,MOD);
        tmp2 %= MOD;
        ans += tmp1*tmp2;
        ans %= MOD;
        //cout << ans << endl;
    }
    ans *= modpow(2,N,MOD);
    ans %= MOD;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6824
import java.io.*;

class Main{
public static void main(String[] args) throws IOException{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
String str;
boolean[] flag=new boolean[10];
while((str=br.readLine())!=null){
int n=Integer.parseInt(str);
int max=0;
int t=9;
while(t>=0){
int p=(int)Math.pow(2,t);
if(n>=p){
n-=p;
flag[t]=true;
}
else{
flag[t]=false;
}
t--;
}
for(int i=0;i<10;i++){
if(flag[i]){
max=i;
}
}
for(int i=0;i<10;i++){
if(flag[i]){
System.out.print((int)Math.pow(2,i));
if(i==max){
System.out.print("\n");
}
else{
System.out.print(" ");
}
}
}
}
}
}

Measured memory_bytes: 16888
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
    
  int n;
  cin>>n;
  
     long double split=(long double)n/3;
     long double res=split*split*split;
     printf("%.12Lf",res);
  
}

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

#define all(x) (x).begin(),(x).end()
#define SP <<" "<<
#define MOD 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000

typedef long long LL;
typedef long double LD;

int main(){
  int n;
  cin >> n;
  vector<int> x(n);
  for(int i=0;i<n;i++){
    cin >> x[i];
  }
  int l;
  cin >> l;
  int sz=0,c=1;
  while(c<n) c*=2,sz++;

  vector<vector<int>> lp(n,vector<int>(sz));
  for(int i=0;i<n;i++){
    lp[i][0]=upper_bound(all(x),x[i]+l)-x.begin()-1;
  }
  for(int i=1;i<sz;i++){
    for(int j=0;j<n;j++){
      lp[j][i]=lp[lp[j][i-1]][i-1];
    }
  }

  vector<vector<int>> rp(n,vector<int>(sz));
  for(int i=0;i<n;i++){
    rp[i][0]=lower_bound(all(x),x[i]-l)-x.begin();
  }
  for(int i=1;i<sz;i++){
    for(int j=0;j<n;j++){
      rp[j][i]=rp[rp[j][i-1]][i-1];
    }
  }

  int q;
  cin >> q;
  int a,b;
  for(int t=0;t<q;t++){
    cin >> a >> b;
    a--,b--;
    int ans=0;
    if(a<b){
      for(int i=sz-1;i>=0;i--){
        if(lp[a][i]<b){
          ans|=(1<<i);
          a=lp[a][i];
          if(a==b) break;
        }
      }
    }else{
      for(int i=sz-1;i>=0;i--){
        if(rp[a][i]>b){
          ans|=(1<<i);
          a=rp[a][i];
          if(a==b) break;
        }
      }
    }
    cout << ans+1 << endl;
  }
  return 0;
}


Measured memory_bytes: 21504
parseInt(x) = parse(Int, x)
parseBigInt(x) = parse(BigInt, x)
parseFloat(x) = parse(Float64, x)
parseBigFloat(x) = parse(BigFloat, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    n::Int=parseInt(readline())
    a::Vector{Int64}=sort(parseMap(split(readline())))
    ans::BigInt=1
    for i in a
        ans*=i
        if ans>10^18
            ans=-1
            break
        end
    end
    println(ans)
end
main()

Measured memory_bytes: 192668
#include <iostream>
using namespace std;
int era(int x,int y,int m,int d){
	switch(x){
	case 1:
		cout<<"pre-meiji"<<endl;
		break;
	case 2:
		cout<<"meiji "<<y-1867<<" "<<m<<" "<<d<<endl;
		break;
	case 3:
		cout<<"taisho "<<y-1911<<" "<<m<<" "<<d<<endl;
		break;
	case 4:
		cout<<"showa "<<y-1925<<" "<<m<<" "<<d<<endl;
		break;
	case 5:
		cout<<"heisei "<<y-1988<<" "<<m<<" "<<d<<endl;
		break;
	}
	return 0;
}

int main(){
	int y,m,d,x;
	while(cin>>y>>m>>d){
		if(y<1868) x=1;
		else if(y==1868){
			if(m<9) x=1;
			else if(m==9){
				if(d<8) x=1;
				else x=2;
			}
			else x=2;
		}
		else if(y>1868 && y<1912) x=2;
		else if(y==1912){
			if(m<7) x=2;
			else if(m==7){
				if(d<30) x=2;
				else x=3;
			}
			else x=3;
		}
		else if(y>1912 && y<1926) x=3;
		else if(y==1926){
			if(m<12) x=3;
			else if(m==12){
				if(d<25) x=3;
				else x=4;
			}
		}
		else if(y>1926 && y<1989) x=4;
		else if(y==1989){
			if(m==1){
				if(d<8) x=4;
				else x=5;
			}
			else x=5;
		}
		else x=5;

		era(x,y,m,d);
	}
	return 0;
}

Measured memory_bytes: 1160
using System;
using System.Linq;
using System.Collections.Generic;
namespace Sample
{
  class Sample
  {
    static void Main(string[] args)
    {
    int[] input=new int[5];
      bool flg=false;
      for(int i=0;i<5;i++){
       input[i]=int.Parse(Console.ReadLine()); 
      }
      int k=int.Parse(Console.ReadLine());
      for(int i=0;i<5;i++){
        for(int j=i;j<5;j++){
       if(input[j]-input[i]>k){
         flg=true;
         break;
       }
        }
      }
      if(flg){
        Console.WriteLine(":(");
      }else{
        Console.WriteLine("Yay!");
      }
    }
    
  }

}


Measured memory_bytes: 27320
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <complex>
#include <string.h>
#include <numeric>
using namespace std;

//#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) rep(i,(n)+1)
#define repst(i,s,n) reps(i,s,(n)+1)
#define reprt(i,n,t) for(int (i)=(n);(i)>=(t);--(i))
#define repr(i,n) reprt(i,n,0)
#define each(i,v) for(auto &(i):(v))
#define eachr(i,v) for(auto &(i)=(v).rbegin();(i)!=(v).rend();(i)++)
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define bln(i,n) (((i)==(n)-1)?'\n':' ')
#define dbg(x) cout<<#x" = "<<(x)<<ln<<flush
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ')<<flush;}}
#define zero(a) memset(a,0,sizeof(a))
#define unq(a) sort(all(a)),a.erase(unique(all(a)),a.end())

//typedef complex<double> P;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vst;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

ll mop(ll a,ll b,ll m=mod) {ll r=1;a%=m;for(;b;b>>=1){if(b&1)r=r*a%m;a=a*a%m;}return r;}
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) {return a/gcd(a,b)*b;}
bool ool(int x,int y,int h,int w) {return((x<0)||(h<=x)||(y<0)||(w<=y));}
bool deq(double a,double b) {return abs(a-b)<eps;}

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;



int n;

void ans(int k) {
	cout << "Yes" << endl << k << endl;
	vector<vector<int> > res(k);
	int t = 1;
	rep(i,k) reps(j,i+1,k) res[i].push_back(t), res[j].push_back(t++);
	rep(i,k) {
		cout << k-1 << ' ';
		rep(j,k-1) cout << res[i][j] << " \n"[j==k-2];
	}
}

signed main() {
	cin >> n;
	reps(k,2,1010) if (k*(k-1)/2==n) {
		ans(k);
		return 0;
	}
	cout << "No" << endl;
}

Measured memory_bytes: 2304
// G++ MACRO.CPP -STD=C++17
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;
 
#define dump(x)  cout << #x << " = " << (x) << endl;
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl
#define possible(n) cout << ((n) ? "possible" : "impossible"  ) << endl
 
#define SANKOU(n,a,b) cout << ((n) ? (#a) : (#b) ) << endl
 
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
 
#define FOREACH(x,a) for(auto& (x) : (a) )
 
#define WFA(d,v) REP(k,v)REP(i,v)REP(j,v)d[i][j]=min(d[i][j],d[i][k]+d[k][j])
 
#define SCOUT(x) cout<<(x)<<" "
#define ENDL cout<<endl
 
#define VECCIN(x) for(auto&youso_: (x) )cin>>youso_
#define VECIN2(x,y) REP(i,x.size())cin>>x[i]>>y[i]
#define VECCOUT(x) if(1){for(auto tt=x.begin();tt!=x.end();tt++){if(tt!=x.begin())cout<<" ";cout<<(*tt);}cout<<endl;}
 
#define ALL(obj) (obj).begin(),(obj).end()
 
#define EXIST(n,x) (find(ALL(n),x)!=n.end())
#define UNIQUE(obj) sort(ALL( obj )); obj.erase(unique(ALL(obj)),obj.end())
#define EN(x) if(1){cout<<#x<<endl;return 0;}
#define COUT(x) cout<<(x)<<endl
void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail){
    cin>>head;
    CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)
 
template <class T = ll>
T IN(){T x;cin>>x;return (x);}
 
template <class Head>
void VT(Head head){}
template <class Head,class Seco,class... Tail>
void VT(Head&& head,Seco&& seco,Tail&&... tail){
    seco.resize(head);
    VT(head,move(tail)...);
}
void VT2(){}
template <class Head,class... Tail>
void VT2(Head&& head,Tail&&... tail){
  VECCIN(head);
  VT2(move(tail)...);
}
 
template <class Head>
void VT3(Head&& head){}
template <class Head,class Seco,class... Tail>
void VT3(Head&& head,Seco&& seco,Tail&&... tail){
  seco[head]=IN();
  VT3(head,move(tail)...);
}
 
#define VC1(n,...) V __VA_ARGS__;VT(n,__VA_ARGS__);VT2(__VA_ARGS__); //aaabbbccc
#define VC2(n,...) V __VA_ARGS__;VT(n,__VA_ARGS__);REP(i,n)VT3(i,__VA_ARGS__); //abcabcabc
 
// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision; // cpp_int
 
#define P pair<int,int>
#define V vector<int>
#define M map<int,int>
#define S set<int>
 
#define pb(a) push_back(a)
#define mp make_pair
 
 
int main(){
  VC1(3,v);sort(ALL(v));
  REP(i,INF){
    if(v[0] == v[1] && v[1] == v[2]){
      COUT(i);
      return 0;
    }
    sort(ALL(v));
    if(v[1] - v[0] >= 2)
      v[0]+=2;
    else{
      v[1]++;v[0]++;
    }
  }
  
  
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<iomanip>
#include<map>
#include<utility>
#include<string>
#include<unordered_map>
#include<queue>

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

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
int gcd(int a, int b){return b ? gcd(b, a%b) : a;}

int main(){
    int x; cin >> x;
    for(int i = 1; i <= x; i++){
        if(100*i<=x && 105*i>=x){
            cout << 1 << endl;
            return 0;   
        }
    }
    cout << 0 << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define int ll
#define fr(i,a,b) for(int i=a;i<b;i++)
#define frr(i,a,b) for(int i=b-1;i>=a;i--)
#define mod 1000000007
#define pb push_back
#define son ll t; cin>>t;while(t--)
#define fst ios_base::sync_with_stdio(false); cin.tie(NULL);
#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl
#define mpr make_pair
#define ff first
#define ss second
#define inf 5e18
#define dex(x,y) fixed<<setprecision(x)<<y
void start()
{
    #ifndef ONLINE_JUDGE 
    freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
    #endif
}

int32_t main()
{
    fst
//    start();
 string s;
  cin>>s;
  cout<<s.substr(0,3)<<endl;
      
    
}


Measured memory_bytes: 3604
#include <set>
#include <map>
#include <list>
#include <stack>
#include <queue>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
#define int long long

signed main(void){
  int a,b,c;
  int a_,b_,c_;
  cin >> a >> b >> c;

  int count = 0;
  for(int i = 0; i < 10000; i++){
    if(a%2||b%2||c%2)break;
    a_ = (b+c)/2;
    b_ = (a+c)/2;
    c_ = (a+b)/2;
    a=a_;b=b_;c=c_;
    count++;
  }

  if(count < 10000){
    cout << count << "\r\n";
  }else{
    cout << "-1\r\n";
  }
  return 0;
}


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

bool ok(int *a){
    int sum = 0;
    for(int i = 1; i <= 11; i++){
        int j;
        if(i <= 6)  j = i+1;
        else        j = i-5;
        sum += a[11-i]*j;
    }
    if(sum%11 <= 1) return 0 == a[11];
    return a[11]==11-sum%11;
}

int main(){
    int a[12], ind = -1;
    for(int i = 0; i < 12; i++){
        char c; cin >> c;
        if(c == '?')    ind = i;
        else            a[i] = c-'0';
    }
    int ret = -1;
    for(int i = 0; i <= 9; i++){
        a[ind] = i;
        if(ok(a)){
            if(ret != -1){
                cout << "MULTIPLE" << endl;
                return 0;
            }
            ret = i;
        }
    }
    cout << ret << endl;
    return 0;
}


Measured memory_bytes: 3116
#include <bits/stdc++.h>
const int MAX = 1e4 + 10;
typedef long long i64;
using namespace std;
const double EPS = 1e-6;

int dp[MAX + 1];
int last[MAX];
bool good(int n){
    bool seen[10] = {false};
    while(n > 0){
        if(seen[n % 10])return false;
        seen[n % 10] = true;
        n /= 10;
    }
    return true;
}

int main() {

    #ifdef LOCAL_DEBUG
    freopen ("data.in", "r", stdin );
    //freopen ("data.out", "w", stdout );
    #endif
    ios_base::sync_with_stdio(0); cin.tie(0);
    #define endl '\n'



    //int tests ; cin >> tests;
    //while(tests--){
    	int n, p; cin >> n >> p;
    	i64 tot0 = 1, tot1 = 0;
    	for(int i = 0; i < n ;i++){
    		int a; cin >> a;
    		if(a%2 == 0){
    			tot1 *= 2;
    			tot0 *= 2;
    		}
    		else{
    			i64 tmp = tot0;
    			tot0 += tot1;
    			tot1 += tmp;
    		}
    	}
    	if(p == 0)cout << tot0 << endl;
    	else cout << tot1 << endl;
    //}






}



Measured memory_bytes: 256
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,n) for(ll i=0;i<(n);++i)
#define REPR(i,n) for(ll i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

template<typename T>
void print(const vector<T> &x) {
    int n = x.size();
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x) {
    int n = x.size();
    rep(i,n) {
        rep(j,x[i].size()) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<typename T>
void print(const vector<T> &x, int n) {
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x, int n, int m) {
    rep(i,n) {
        rep(j,m) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

void input_init() {
    cin.tie(0); ios::sync_with_stdio(false);
}

int main(int argc, char const *argv[]) {
    int n; cin>>n;
    vector<P> a(n);
    rep(i,n) {
        string s; cin>>s;
        int sum = 0;
        int mini = INF;
        for (auto &&e: s) {
            if (e == '(') sum++;
            else sum--;
            chmin(mini, sum);
        }
        a[i].first = mini;
        a[i].second = sum;
    }

    auto print = [&]() {
        for (auto &&e: a) cout << e.first << ", " << e.second << '\n';
    };

    vector<P> ans;
    sort(a.begin(), a.end(), greater<>());
    for (auto &&e: a) {
        if (e.second >= 0) {
            ans.push_back(e);
        }
    }

    sort(a.begin(), a.end(), [](const P &l, const P &r) {
        return l.second-l.first > r.second-r.first;
    });

    for (auto&&e: a) {
        if (e.second < 0) {
            ans.push_back(e);
        }
    }

    P c;
    bool ok = true;
    for (auto &&e: ans) {
       if (c.second+e.first < 0) ok = false;
       c.second += e.second;
    }
    
    if (c.second != 0) ok = false;

    if (ok) {
        cout << "Yes" << '\n';
    }
    else {
        cout << "No" << '\n';
    }
    return 0;
}

Measured memory_bytes: 35268
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    String ans = "";
    for(int i = 0; i < s.length(); i++) {
      if(i == 3) {
        ans += "8";
      } else {
        String str = String.valueOf(s.charAt(i));
        ans += str;
      }
    }
    System.out.println(ans);
  }
}


Measured memory_bytes: 21844
#include <iostream>
using namespace std;
 
int gcdtwo(int a, int b){
   if (a%b == 0){
       return(b);
   }else{
       return(gcdtwo(b, a%b));
   }
}
 
int gcdthree(int a, int b, int c){
  int t = gcdtwo(a,b);
  int tt = gcdtwo(t,c);
  return tt;
}
 
int main(int argc, const char * argv[]) {
    int k;
    cin >> k;
    int sumN = 0;
    for(int a=1; a<=k; a++){
      for(int b=1; b<=k; b++){
        for(int c=1; c<=k; c++){
          sumN += gcdthree(a,b,c);
        }
      }
    }
    cout << sumN << endl;
    return 0;
}

Measured memory_bytes: 3624
n,m = gets.split.map(&:to_i)
g = Array.new(n+1) {[]}
m.times do |i|
  s, e = gets.split.map(&:to_i)
  g[s] << e
  g[e] << s
end

def dfs(path, g, end_size)
  return 1 if path.size == end_size

  g[path.last].map do |i|
    path.index(i) ? 0 : dfs([*path, i], g, end_size)
  end.reduce(:+)
end

puts dfs([1], g, n)


Measured memory_bytes: 2044
//============================================================================
// Name        : hoba.cpp :)
// Author      : (O_O Diab) (Why_not) (el 3AQ)
// Version     :
// Copyright   : please, Don't touch me :(
// Description : problem in C++
// MAIN IDEA   :
//============================================================================
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define ld long double
#define rw freopen("graphs_as_a_service.txt","r",stdin),freopen("output.txt","w",stdout);
#define pb push_back
#define F first
#define S second
#define pf push_front
#define lp(i,a,b) for (int i=a;i<=(int)b;++i)
#define lp2(i,a,b) for (int i=a;i>=b;--i)
#define f(x) return cout<<x<<"\n",0
#define pii pair<int,int>
#define pll pair<ll,ll>
#define all(c) c.begin(),c.end()
#define allr(c) c.rbegin(),c.rend()
#define p(x) cout<<#x<<" = { "<<x<<" } \n"
#define vi vector<int>
#define vl vector<ll>
#define vii vector<pii>
#define vll vector<pll>
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define EPS 1e-6
// to convert string to number use int a = stoi(string);
// to convert number to string use string s = to_string(int);
#define FAST ios::sync_with_stdio(0),ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define clr(c,x) memset(c,x,sizeof(c));
using namespace __gnu_pbds;
using namespace std;
const ll INFL = 0x3f3f3f3f3f3f3f3fLL;
const int dx[] = { 0, 1, 0, -1, 1, -1, 1, -1 };
const int dy[] = { 1, 0, -1, 0, 1, -1, -1, 1 };
const int N = 200 + 10, mod = (int) 1e9 + 7, INF = 0x3f3f3f3f;
string s;
int n;
int main() {
#ifdef ONLINE_JUDGE
	FAST
#endif
	cin >> n >> s;
	int curl = 0, l = 0;
	lp(i,0,n-1)
	{
		if (s[i] == ')' && curl > 0)
			curl--;
		else if (s[i] == ')')
			l++;
		else if (s[i] == '(')
			curl++;
	}
	string ss = "";
	lp(i,1,l)
		ss += "(";
	ss += s;
	lp(i,1,curl)
		ss += ")";
	cout << ss << "\n";
	return 0;
}

Measured memory_bytes: 256
def primes(n):
  is_prime=[True]*(n+1)
  is_prime[0]=False
  is_prime[1]=False
  for i in range(2,int(n**0.5)+1):
    if not is_prime[i]:
      continue
    for j in range(i*2,n+1,i):
      is_prime[j]=False
  return [i for i in range(n+1) if is_prime[i]]

def fact(n):
  l=primes(int(n**0.5)+1)
  L=[]
  for i in range(len(l)):
    while n%l[i]==0:
      n=n//l[i]
      L.append(l[i])
    if n==1:
      break
  if n!=1:
    L.append(n)
  return L

import sys
a,b=map(int,input().split())
if a==1 or b==1:
  print(1)
  sys.exit()
a2=list(set(fact(a)))
b2=list(set(fact(b)))
ct=1
for i in range(len(a2)):
  if a2[i] in b2:
    ct+=1
print(ct)

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

int main() {

    int k, a, b;
    cin >> k >> a >> b;
    long double l = ceill(a / k), u = floorl(b / k);
    if(a<=l*k&&l*k<=b||a<=u*k&&u*k<=b){
        cout << "OK" << endl;
    }
    else{
        cout << "NG" << endl;
    }
}

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

int main(){

    queue<int> a;
    queue<string> s;

    int n,limit;
    cin >> n >> limit;
    for(int i=0;i<n;i++){
        int c;
        string b;
        cin >> b >> c;
        a.push(c);
        s.push(b);
    }

    int time = 0;
    while(true){

        if(a.empty())
            break;
        if(a.front() - limit > 0){
            a.push(a.front() - limit);
            a.pop();
            s.push(s.front());
            s.pop();
            time += limit;
        }else{
            time += a.front();
            cout << s.front() << " "<< time << endl;
            a.pop();
            s.pop();
        }
    }   
}
    


Measured memory_bytes: 5656
#include "bits/stdc++.h"
using namespace std;
#define Rep(i,n) for(int i=0;i<n;i++)
#define For(i,n1,n2) for(int i=n1;i<n2;i++)
#define REP(i,n) for(ll i=0;i<n;i++)
#define RREP(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,n1,n2) for(ll i=n1;i<n2;i++)
#define put(a) cout<<a<<"\n"
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
typedef long long ll;
typedef pair<int, int> P;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){if(a>b){a=b;return 1;}return 0;}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){if(a<b){a=b;return 1;}return 0;}

int main(){
    int a,b,c;
    cin >> a >> b >> c;
    put(a*b/2);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define PI acos(-1)

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

int main(){
    int h,w,i,j,maxi = 0;
    cin >> h >> w;
    vector<string> m(h);
    for(int i = 0;i < h;i++){
        cin >> m[i];
    }

    for(i = 0;i < h;i++){
        for(int j = 0;j < w;j++){
            if(m[i][j] == '#')continue;
            vector<vector<int>> dist(h,vector<int>(w,-1));
            dist[i][j] = 0;
            queue<pair<int,int>> que;
            que.push(make_pair(i,j));

            while(!que.empty()){
                pair<int,int> cur = que.front();
                int x = cur.first;
                int y = cur.second;
                que.pop();
                maxi = max(maxi,dist[x][y]);

                for(int dir = 0;dir < 4;dir++){
                    int next_x = x + dx[dir];
                    int next_y = y + dy[dir];
                    if(next_x >= h ||next_x < 0||next_y >= w ||next_y < 0)continue;
                    if(m[next_x][next_y] == '#')continue;

                    if(dist[next_x][next_y] == -1){
                        que.push(make_pair(next_x,next_y));
                        dist[next_x][next_y] = dist[x][y] + 1;
                    }
                }
            }
        }
    }
    cout << maxi <<endl;
}


Measured memory_bytes: 256
let rec f n ls =
  if
    List.exists
      (fun e ->
        let i = n mod e in
        i = 0 && n / e > 0 && n / e < 10)
      ls
  then "Yes"
  else "No"

let () =
  let n = read_int () and ls = [1; 2; 3; 4; 5; 6; 7; 8; 9] in
  f n ls |> print_string


Measured memory_bytes: 4480
package main
import(
	"fmt"
)
func main(){
	var n int
	fmt.Scanln(&n)
	var in [100000] bool
	var c string
	fmt.Scanln(&c)
	for i := 0; i < n; i++ {
		if c[i] == 'o' {
			in[i] = true
		}else{
			in[i] = false
		}
	}
	if doesExist(n, in, true, true) {
		answer(n, in, true, true);
		return
	}
	if doesExist(n, in, true, false) {
		answer(n, in, true, false);
		return
	}
	if doesExist(n, in, false, true) {
		answer(n, in, false, true);
		return
	}
	if doesExist(n, in, false, false) {
		answer(n, in, false, false);
		return
	}
	fmt.Println(-1)
}

func doesExist(n int, in [100000]bool, first bool, second bool) bool {
	var res [100000] bool
	res[0] = first
	res[1] = second
	for i := 1; i < n-1; i++ {
		if res[i]==in[i] {
			res[i+1] = res[i-1]
		} else {
			res[i+1] = !res[i-1]
		}
	}
	return (((in[n-1]==res[n-1])==(res[0] == res[n-2])) && ((in[0]==res[0])==(res[1] == res[n-1])) )
}

func answer(n int, in [100000]bool, first bool, second bool) {
	var res [100000] bool
	res[0] = first
	res[1] = second
	outSW(res[0])
	outSW(res[1])
	for i := 1; i < n-1; i++ {
		if res[i]==in[i] {
			res[i+1] = res[i-1]
		} else {
			res[i+1] = !res[i-1]
		}
		outSW(res[i+1])
	}
	fmt.Println()
}
func outSW(in bool) {
	if in {
		fmt.Print("S")
	} else {
		fmt.Print("W")
	}
}

Measured memory_bytes: 3328
N,M=map(int,input().split())
PY=[]
for i in range(M):
  p,y=map(int,input().split())
  PY.append([i,p,y])
ans=['']*M
PY1=sorted(PY,key=lambda x:x[2])
dict={}
for i in range(M):
  ans[PY1[i][0]]+=str(PY1[i][1]).zfill(6)
  if not (PY1[i][1] in dict):
    ans[PY1[i][0]]+='1'.zfill(6)
    dict[PY1[i][1]]=1
  else:
    ans[PY1[i][0]]+=str(int(dict[PY1[i][1]])+1).zfill(6)
    dict[PY1[i][1]]+=1
for i in range(M):
  print(ans[i])

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

struct edge { ll u, v, d, c; };

class Dijkstra {
public:
  struct edge { ll v, dist; };

  struct state {
    ll v, cost;
    bool operator>(const state s) const { return cost > s.cost; }
  };

  const ll INF = (1LL << 60);
  ll N;
  vector< vector<edge> > E;

  Dijkstra(ll n): N(n), E(n) {}

  void add_directed_edge(ll u, ll v, ll d) {
    E[u].push_back((edge) { v, d });
  }

  void add_undirected_edge(ll u, ll v, ll d) {
    E[u].push_back((edge) { v, d });
    E[v].push_back((edge) { u, d });
  }

  vector<ll> shortest_path(ll S) {
    vector<ll> dp(E.size(), INF);
    priority_queue<state, vector<state>, greater<state> > q;
    q.push((state) { S, 0 });
    while(!q.empty()) {
      ll v = q.top().v, cost = q.top().cost;
      q.pop();
      if(dp[v] <= cost) continue;
      dp[v] = cost;
      REP(i, 0, E[v].size()) {
        ll nv = E[v][i].v, ncost = cost + E[v][i].dist;
        if(dp[nv] > ncost) q.push((state) { nv, ncost });
      }
    }
    return dp;
  }
};

class MaxFlow {
public:
  struct edge { ll to, cap, rev; };

  const ll INF = 1LL << 60;
  ll N;
  vector< vector<edge> > E;
  vector<bool> used;

  MaxFlow(ll n): N(n), E(n), used(n) {};

  void add_directed_edge(ll from, ll to, ll cap) {
    E[from].push_back((edge) { to, cap, (ll) E[to].size() });
    E[to].push_back((edge) { from, 0, (ll) E[from].size() - 1 });
  }

  void add_undirected_edge(ll from, ll to, ll cap) {
    E[from].push_back((edge) { to, cap, (ll) E[to].size() });
    E[to].push_back((edge) { from, cap, (ll) E[from].size() - 1 });
  }

  ll dfs(ll v, ll t, ll f) {
    if(v == t) return f;
    used[v] = true;
    REP(i, 0, E[v].size()) {
      edge &e = E[v][i];
      if(!used[e.to] && e.cap > 0) {
        ll d = dfs(e.to, t, min(f, e.cap));
        if(d > 0) {
          e.cap -= d;
          E[e.to][e.rev].cap += d;
          return d;
        }
      }
    }
    return 0;
  }

  ll max_flow(ll s, ll t) {
    ll flow = 0;
    while(1) {
      REP(i, 0, N) used[i] = false;
      ll f = dfs(s, t, INF);
      if(f == 0 || f == INF) break;
      flow += f;
    }
    return flow;
  }
};

int main(void) {
  ll N, M, S, T; cin >> N >> M >> S >> T; S--; T--;
  vector<edge> edges(M);
  REP(i, 0, M) {
    ll U, V, D, C; cin >> U >> V >> D >> C; U--; V--;
    edges[i] = (edge) { U, V, D, C };
  }

  Dijkstra dijkstraS(N), dijkstraT(N);
  for(edge &e : edges) dijkstraS.add_directed_edge(e.u, e.v, e.d);
  for(edge &e : edges) dijkstraT.add_directed_edge(e.v, e.u, e.d);
  vector<ll> distS = dijkstraS.shortest_path(S);
  vector<ll> distT = dijkstraT.shortest_path(T);

  MaxFlow flow(N);
  for(edge &e : edges) {
    if(distS[e.u] + e.d + distT[e.v] == distS[T]) {
      flow.add_directed_edge(e.u, e.v, e.c);
    }
  }
  cout << flow.max_flow(S, T) << endl;
}



Measured memory_bytes: 3292
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include <map>
#include <cmath>
#include <string>
using namespace std;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define REP(i,a,b)for(int i=(int)(a);(i)<(int)(b);i++)
typedef long long ll;


ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll c, ll d) { return c / gcd(c, d) * d; }

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

  int ans = 0;
  while (h > 0)
  {
      /* code */
      h -= a;
      ans++;
  }
  cout << ans << endl;
}

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

int a[101];
int dp[100007];
int n,k;
int main() {
  cin >> n >> k;
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  for(int i=0;i<=k;i++){
    for(int j=0;j<n;j++){
      if(i>=a[j] && !dp[i-a[j]]){
        dp[i] = 1;
      }
    }
  }
  if(dp[k]) cout<<"First"<<endl;
  else cout << "Second" << endl;
  return 0;
}


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



int main(){
	ll H;
	cin >> H;
	ll sum = 1;

	if(H == 1){
		cout << 1 << endl;
		return 0;
	}
//	sum = atk(H);
	ll i = 1;
	H = floor(H/2);
	while(H > 0){
		sum += i*2;
//	      cout << i << endl;
		i *= 2;
		H = floor(H/2);
	}
	cout << sum << endl;
}

Measured memory_bytes: 256