akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;

public class Main {
	private static final int MOD = 1000000007;

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		long N = sc.nextLong();

		long top = N;
		long sum = 0;
		for (long i = 1; i <= N; i++) {
			long bottom = N / (i + 1);
			if (top == bottom) {
				break;
			}

			for (long j = top; j > bottom; j--) {
				long mod = N % j;
				if (mod == i) {
					sum += j;
				}
				if (mod >= i) {
					break;
				}
			}
			top = bottom;
		}
		System.out.println(sum);
	}

	private static boolean isDebug = System.getProperty("sun.desktop") != null;

	private static void debug(Object... o) {
		if (isDebug) {
			System.err.println(Arrays.deepToString(o));
		}
	}

	public static class Scanner {
		private BufferedInputStream inputStream;

		public Scanner(InputStream in) {
			inputStream = new BufferedInputStream(in);
		}

		public char nextChar() throws IOException {
			return (char) skip();
		}

		public int nextInt() throws IOException {
			int num = 0;

			int read = skip();
			do {
				num = num * 10 + (read - 0x30);
			} while ((read = inputStream.read()) > 0x20);

			return num;
		}

		public void fill(int[] a) throws IOException {
			for (int i = 0; i < a.length; i++) {
				a[i] = nextInt();
			}
		}

		public void fill(int[] a, int[] b) throws IOException {
			if (a.length != b.length) {
				throw new IllegalArgumentException();
			}

			for (int i = 0; i < a.length; i++) {
				a[i] = nextInt();
				b[i] = nextInt();
			}
		}

		public long nextLong() throws IOException {
			long num = 0;

			int read = skip();
			do {
				num = num * 10 + (read - 0x30);
			} while ((read = inputStream.read()) > 0x20);

			return num;
		}

		public void fill(long[] a) throws IOException {
			for (int i = 0; i < a.length; i++) {
				a[i] = nextLong();
			}
		}

		public void fill(long[] a, long[] b) throws IOException {
			if (a.length != b.length) {
				throw new IllegalArgumentException();
			}

			for (int i = 0; i < a.length; i++) {
				a[i] = nextLong();
				b[i] = nextLong();
			}
		}

		public long[] nextLong(int n) throws IOException {
			long[] array = new long[n];
			for (int i = 0; i < n; i++) {
				array[i] = nextLong();
			}

			return array;
		}

		public String next() throws IOException {
			StringBuilder builder = new StringBuilder();

			int read = skip();
			do {
				builder.append((char) read);
			} while ((read = inputStream.read()) > 0x20);

			return builder.toString();
		}

		private int skip() throws IOException {
			int read;
			while ((read = inputStream.read()) <= 0x20)
				;

			return read;
		}
	}
}

Measured memory_bytes: 22740
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#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;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define INF 2e9
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n,sum=0;
  vint b(103,0);
  cin>>n;
  rep(i,n-1){
    cin>>b[i];
  }
  sum+=min(1145144,b[0]);
  sum+=min(1145144,b[n-2]);
  rep(i,n-1){
    sum+=min(b[i],b[i+1]);
  }
  cout<<sum<<'\n';
  return(0);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
  
long long pow_kai(long long a, long long n){
  long long x = 1;
  while(n > 0){
    if(n&1){
      x = x*a%998244353ll;
    }
    a = a*a%998244353ll;
    n >>= 1;
  }
  return x%998244353ll;
}

int main() {
  long long mod = 998244353;
  long long N;
  cin >> N;
  long long ans = N;
  for (int i=0; i<N-1; i++) {
    ans *= 2;
    ans %= mod;
  }
  
  vector<tuple<long long,long long,long long,long long>> yxmm(N);
  
  for (int i=0; i<N; i++) {
    cin >> get<0> (yxmm[i]) >> get<1> (yxmm[i]);
  }
  sort(yxmm.begin(),yxmm.end());
  for (int i=0; i<N; i++) {
    get<3> (yxmm[i]) = i;
    swap(get<0> (yxmm[i]),get<1> (yxmm[i]));
  }
  
  sort(yxmm.begin(),yxmm.end());
  
  vector<int> st = {};
  int nnn;
  for (int i=0; i<N; i++) {
    auto itr = lower_bound(st.begin(),st.end(),(get<1> (yxmm[i])));
    get<2> (yxmm[i]) = itr - st.begin();
    get<3> (yxmm[i]) -= get<2> (yxmm[i]);
    nnn = get<1> (yxmm[i]);
    st.insert(st.begin() + get<2> (yxmm[i]),nnn);
  }
  
  long long term;
  for (long long i=1; i<N-1; i++) {
    term = pow_kai(2,i)-1;
    term *= pow_kai(2,N-1-i)-1;
    term %= mod;
    term -= (pow_kai(2,get<2> (yxmm[i]))-1) * (pow_kai(2,get<3> (yxmm[i]))-1) % mod;
    term += mod;
    term %= mod;
    term -= (pow_kai(2,i-get<2> (yxmm[i]))-1) * (pow_kai(2,N-1-i-get<3> (yxmm[i]))-1) % mod;
    term += mod;
    term %= mod;
    ans += term;
    ans %= mod;
  }
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 7672
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        String op = sc.next();
        int b = sc.nextInt();
        int ans = 0;
        if(op.equals("+")) {
            ans = a + b;
        } else if (op.equals("-")) {
            ans = a - b;
        }
        System.out.println(ans);
    }
}


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

#define fi first
#define se second
#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 all(x) (x).begin(), (x).end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define pb push_back
#define sz(x) (int)(x).size()
#define PQ(T) priority_queue<T, v(T), greater<T> >

using namespace std;
typedef long long ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;

const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;

const int mod = 1000000007;

int main() {
    int n;
    cin >> n;
    ll ans = 0;
    rep(i,n) {
        ll cnt = 0;
        int v = i+1;
        int al = v % 10;
        if (al==0) continue;
        
        int af;
        int now = al;
        while (v>0) {
            af = now;
            v /= 10;
            now = v % 10;
        }
        // d == 1
        if (af==al) ++ans;
        // d == 2
        if (al * 10 + af <= n) ++ans;
        else continue;
        // d > 0
        int d = 3;
        int from = al * 100 + af;
        while (from <= n) {
            int lb = 0;
            int ub = 0;
            rep(i,d-2) ub += 9 * pow(10,i);
            ub += 1;
            while(ub - lb > 1) {
                int mid = (ub + lb) / 2;
                if (al * pow(10,d-1) + mid * 10 + af <= n) lb = mid;
                else ub = mid;
            }
            ans += (lb+1);
            ++d;
            from = al * pow(10,d-1) + af;
        }
    }
    cout << ans << endl;
    return 0;
}


































Measured memory_bytes: 256
#include<cstdio>

using namespace std;

int main(){
    int h, w;
    scanf("%d %d", &h, &w);
    char s[h+1][w+1];
    for(int i = 0; i < h; i++){
        scanf("%s", s[i]);
    }
    int dx[2] = {-1,1};
    int dy[2] = {-1,1};
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            bool flag = false;
            if (s[i][j] == '.') continue;
            if (i - 1 >= 0 && s[i-1][j] == '#') flag = true;
            else if  (i + 1 < h && s[i+1][j] == '#') flag = true;
            else if  (j - 1 >= 0 && s[i][j-1] == '#') flag = true;
            else if  (j + 1 < w && s[i][j+1] == '#') flag = true;
            if (!flag){
                puts("No");
                return 0;
            }
        }
        
    }
    
    puts("Yes");

}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define pp pop_back
#define in insert
#define ff first
#define ss second
#define  show for(int j=0;j<v.size();j++) cout<<v[j]<<" ";
#define ld long double
#define e endl
#define bc __builtin_popcount
#define MOD 1000000007
int main()
{
   int n,x,t;
   cin>>n>>x>>t;
   int ans=n/x+(n%x!=0);
   cout<<ans*t;
}


Measured memory_bytes: 3620
/*
This code By @1353055672(Ligen)
[Warning]You're not excepted to understand this code!
RP++
*/
#pragma GCC optimize(3)
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#define ll long long
#define ull unsigned long long
#define mn 5000020
#define mod (int)(1e9+7)
#define FOR(a,b,c) for (register ll a=b;a<=c;a++)
#define FORD(a,b,c) for (register ll a=b;a>=c;a--)
using namespace std;
inline ll read(){
    ll x=0,f=1;
    char c=getchar();
    while (c<'0'||c>'9'){
        if (c=='-')f=-1;
        c=getchar();
    }
    while (c>='0'&&c<='9'){
        x=x*10+c-'0';
        c=getchar();
    }
    return x*f;
}
inline ll Max(ll a,ll b){return (a>b)?a:b;}
inline ll Min(ll a,ll b){return (a<b)?a:b;}
inline ll Abs(ll x){return (x<0)?-x:x;}

int main(){
	ll n=read(),k=read(),ans=(k%2==0)?pow(n/k,3)+pow((n+(k/2))/k,3):pow(n/k,3);
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 640
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstring>
#include <queue>
#include <stack>
#define rep(i, s, g) for (i = s; i <= g; i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const ll MOD = 1e9 + 7;

int main(void)
{
    int N;
    string S;
    int i;
    int ans = 0;

    cin >> N >> S;

    rep(i, 0, N - 1)
    {
        if (S[i] == 'A' && S[i + 1] == 'B' && S[i + 2] == 'C')
        {
            ans++;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
from collections import defaultdict,deque
printn = lambda x: print(x,end='')
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 10**18
R = 10**9 + 7
#R = 998244353

def ddprint(x):
  if DBG:
    print(x)

n = inn()
a = inl()
b = inl()
b.reverse()
left = n
same = -1
for i in range(n):
    if a[i]==b[i]:
        left = i
        same = a[i]
        break
if left==n:
    print('Yes')
    print(' '.join([str(x) for x in b]))
    exit()
for i in range(n):
    if same in [a[i],b[i]]:
        l2 = i
        break
right = r2 = -1
for i in range(n-1,-1,-1):
    if r2<0 and (same in [a[i], b[i]]):
        r2 = i+1
    if a[i]==b[i]:
        right = i+1
        break
if l2>=right-left:
    tmp = b[:right-left]
    b[:right-left] = b[left:right]
    b[left:right] = tmp
else:
    tmp = b[:l2]
    b[:l2] = b[left:left+l2]
    b[left:left+l2] = tmp
    if right+r2-left-l2>n:
        print('No')
        exit()
    tmp = b[r2:r2+right-l2-left]
    b[r2:r2+right-l2-left] = b[l2+left:right]
    b[l2+left:right] = tmp
print('Yes')
print(' '.join([str(x) for x in b]))


Measured memory_bytes: 119192
#include <bits/stdc++.h>
#include <cstdlib>
#define ll long long
#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define MX 100010
using namespace std;

string S;
int c;
int main(){
        cin >> S;
        FOR(i,0,S.length()){
                if(S[i] == '0') c++;
        }
        int ans = min(c,(int)S.length()-c)*2;
        cout << ans << endl;

       
        return 0;
}


Measured memory_bytes: 512
import sys

def input():
    return sys.stdin.readline()[:-1]

N,M,L = list(map(int,input().split()))

e_list = [[] for i in range(N)]

def warshall_floyd(d):
    #d[i][j]: iからjへの最短距離
    for k in range(N):
        for i in range(N):
            for j in range(N):
                d[i][j] = min(d[i][j],d[i][k] + d[k][j])
    return d

d = [[float("inf") for i in range(N)] for i in range(N)] 
#d[u][v] : 辺uvのコスト(存在しないときはinf)
for i in range(M):
    x,y,z = list(map(int,input().split()))
    if z<=L:
        d[x-1][y-1] = z
        d[y-1][x-1] = z

for i in range(N):
    d[i][i] = 0 #自身のところに行くコストは０

d = warshall_floyd(d)

e_list = [[] for i in range(N)]

d2 = [[float("inf") for i in range(N)] for i in range(N)]

for i in range(N):
    for j in range(i+1,N):
        if d[i][j] <= L:
            d2[i][j] = 1
            d2[j][i] = 1

d2 = warshall_floyd(d2)

Q = int(input())
for i in range(Q):
    s,t = list(map(int,input().split()))
    s,t = s-1,t-1
    if d2[s][t]>10**9:
        print(-1)
    else:
        print(d2[s][t]-1)


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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());

            for (int i = n; ; ++i)
            {
                if (Check(i.ToString())) {
                    Console.WriteLine(i);

                    return;
                }
            }
        }

        static bool Check(String val)
        {
            var first = val.First();
            foreach (var v in val.Skip(1))
            {
                if (first != v)
                {
                    return false;
                }
            }

            return true;
        }
    }
}


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

int main() {
  ll x;
  cin >> x;
  if(x>=2000)cout<<1<<endl;
  else if(x%105==0)cout<<1<<endl;
  else if(x/100==x/105+1)cout<<1<<endl;
  else cout<<0<<endl;
}

Measured memory_bytes: 256
use proconio::input;

#[allow(unused_imports)]
use proconio::marker::{Bytes, Chars, Usize1};
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::ops::*;

#[derive(Clone, Debug, Default)]
struct Struct;

//#[proconio::fastout]
fn main() {
    input! {
        r: f64,
    }

    println!("{}", r*2.0*std::f64::consts::PI);
}


Measured memory_bytes: 2172
N = int(input())
A = list(map(int, input().split()))
ans = 0
flag = True
while flag:
    for i in range(N):
        if A[i] % 2 == 0:
            A[i] /= 2
        else:
            flag = False
            break
    if flag: ans += 1
print(ans)

Measured memory_bytes: 8976
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <functional>
#include <set>
#include <queue>
#include <cctype>
#include <climits>
#include <stack>
using namespace std;
 

 
int main(){
 
	int n; 
	while(scanf("%d",&n),n){

		vector<pair<int,int> > rw(n);
		int sum_r=0,sum_w=0;
		for(int i=0;i<n;i++){
			cin>>rw[i].first>>rw[i].second;
			sum_r+=rw[i].first;
			sum_w+=rw[i].second;
		}
		sort(rw.begin(),rw.end(),greater< pair<int,int> >());

		int r0=rw[0].first;
		int r=sum_r-r0;

		if(r0 <= r){
			cout<<sum_r+sum_w<<endl;
		}else{

			int res=2*rw[0].first;
			vector<vector<bool> > dp(1001,vector<bool>(10000,false));

			//r0-r???w?????°??????
			//dp[pos][sum]

			dp[1][0]=true;
			for(int i=1;i<n;i++){
				for(int j=0;j<=10000;j++){
					if(dp[i][j]){
						dp[i+1][j]=true; //??°?????????
						if(j+rw[i].second<=10000)
							dp[i+1][j+rw[i].second]=true; //??°??????
					}
				}
			}

			int opt=0;
			for(int i=1;i<=r0-r;i++){
				if(dp[n][i]) opt=i;
			}

			res+=sum_w-opt;
			cout<<res<<endl;



		}
		
		
	}
}

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

using namespace std;

long long A,B,C,D;
long long calc_num(long long num) {
	long long res = (B/num) - (A/num);
	if (A%num == 0) {
		++res;
	}
	return res;
}
long long gcd(long long n, long long m) {
	if (n < m) {
		swap(n,m);
	}
	if (m == 0) {
		return n;
	}
	return gcd(m,n%m);
}
long long lcm(long long n, long long m) {
	return (n*m)/gcd(n,m);
}

int main(void) {
	cin >> A >> B >> C >> D;
	cout << B-A-calc_num(C)-calc_num(D)+calc_num(lcm(C,D))+1 << endl;

	return 0;
}


Measured memory_bytes: 256
import math
def is_prime(n):
    if n == 1: return False
    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False
    return True
Q = int(input())
cnt = [0]*(10**5+1)
for i in range(1,10**5+1):
    if i % 2 == 0:
        cnt[i] = cnt[i-1]
        continue
    if is_prime(i) and is_prime((i+1)//2):
        cnt[i] = cnt[i-1] + 1
    else:
        cnt[i] = cnt[i-1]
for _ in range(Q):
    l, r = map(int, input().split())
    print(cnt[r]-cnt[l-1])

Measured memory_bytes: 94380
#include <iostream>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <functional>
using namespace std;

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

    cout << "Christmas";
    for(int i = 0; i < 25-n; i++){
        cout << " Eve";
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 888
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <tuple>
#include <random>
using namespace std;

#define endl '\n'
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef complex<double> comp;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const int inf = 1e9 + 9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1);

ll n, m, d;

double solve() {
    if (d == 0) return (double)(m-1) / n;
    return 2.0 * (n - d) * (m - 1) / n / n;
}

void input() {
    cin >> n >> m >> d;
}

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

    input();
    cout << solve() << endl;
}


Measured memory_bytes: 256
n = input()
C = [map(int, raw_input().split()) for i in xrange(n)]
memo = {(i, i): 0 for i in xrange(n)}
def calc(i, j):
    if (i, j) in memo:
        return memo[i, j]
    res = memo[i, j] = min(calc(i, k) + calc(k+1, j) + C[i][0]*C[k][1]*C[k+1][0]*C[j][1] for k in xrange(i, j))
    return res
print calc(0, n-1)

Measured memory_bytes: 6520
#define _GLIBCXX_DEBUG
#include <iostream>
#include <cstdio>
#include <bits/stdc++.h>//"geometry.cpp"
#include <iomanip>//"cout<<fixed<<setprecision(n)<<sth<<endl;"
#include <queue>
#include <string>
#include <vector>
#include <utility>
#include <set>
#include <map>
#include <algorithm>//"lower_bound(it,it,v)", "next_permutation(a,a+n)"
#include <functional>//"greater<T>" Ex. sort(a,a+n,greater<int>());
#include <cmath>//"abs", "sqrt"
using namespace std;
#define pb push_back
#define fi first
#define sc second
#define mp make_pair
#define is insert
typedef pair<int,int> pii;//Add other types in the same way.

bool q(long long n){
	char ans;
	cout<<"? "<<n<<endl;
	cin>>ans;
	if(ans=='Y') return true;
	else return false;
}

int main(){
	long long m=1;
	for(;m<=1000000000;m*=10){
		if(!q(m)) break;
	}
	if(m==10000000000){
		m=1;
		for(long long i=2;i<=2000000000;i*=10){
			if(q(i)) break;
			m*=10;
		}
	}else{
		long long lb=m/10,ub=m-1;
		while(ub-lb>1){
			long long mid=(lb+ub)/2;
			if(q(10*mid)){
				ub=mid;
			}else{
				lb=mid;
			}
		}
		m=ub;
	}
	cout<<"! "<<m<<endl;
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
#ifdef DEBUG
#define FPEN freopen("in.txt", "r", stdin);
#define TEST(...)                                                              \
    { printf("! "), printf(__VA_ARGS__); }
#else
#define TEST(...)
#define FPEN
#endif
const int maxn = 200009;
typedef long long i64;
typedef pair<i64, i64> pi64;
typedef pair<int, int> pi;
const i64 MOD = 119 << 23 | 1;
class {
  public:
    int a[maxn];
    void solve() {
        int n;
        cin >> n;
        for (int i = 2; i <= n; ++i) {
            int f;
            cin >> f;
            a[f]++;
        }
        for (int i = 1; i <= n; ++i) {
            cout << a[i] << '\n';
        }
    }
} NSPACE;
int main() {
    // FPEN;
    ios_base::sync_with_stdio(false);
    cout.tie(0);
    cin.tie(0);
    NSPACE.solve();
}

Measured memory_bytes: 4396
#pragma GCC optimize ("-O3")
#include <bits/stdc++.h>
#define pb push_back
#define pll pair<ll, ll>
#define mll map<ll, ll>
#define ff first
#define oo 1000000000000000005
#define ss second
#define el "\n"
#define maxS 100005
#define MOD 1000000007
using namespace std;
typedef long long ll;

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

    // ll t;cin>>t;while(t--)
    {
        ll ah, as, bh, bs;
        cin>>ah>>as>>bh>>bs;
        
        while(ah>0 and bs>0)
        {
            bh -= as;
            if(bh <= 0)
                break;
            ah -= bs;
        }
        
        if(ah > 0)
            cout<<"Yes\n";
        else
            cout<<"No\n";
    }
    return 0;
}

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

using namespace std;

const int MOD = 1e9 + 7, maxn = 2e5 + 9;
int64_t gt[maxn + 1], n, m, k;

int64_t Pow(int x, int y)
{
    if (y == 0)
        return 1;
    else
    {
        int64_t tmp = Pow(x, y/2);
        int64_t res = (tmp % MOD * tmp % MOD) % MOD;
        if (y % 2 == 0)
            return res;
        else
            return (res * x % MOD) % MOD;
    }
}

int64_t Comb(int n, int k)
{
    int64_t a = gt[n];
    int64_t b = (gt[k] % MOD * gt[n - k] % MOD) % MOD;
    int64_t c = (a * Pow(b, MOD - 2)) % MOD;  /// (a / b) % MOD = a * inverse(b) % MOD
    return c;
}

void Enter()
{
    cin >> n >> m >> k;
}

void Init()
{
    gt[0] = 1;
    for (int i = 1; i <= maxn; i++)
        gt[i] = (gt[i - 1] % MOD * i % MOD) % MOD;
}

int64_t SumX()
{
    int64_t s = 0;
    for (int i = 1; i <= m; i++)
    {
        int64_t l = i - 1, r = m - i;
        s = (s + l * i - r * i) % MOD;
    }
    s = (s % MOD * Pow(n, 2)) % MOD;
    return s;
}

int64_t SumY()
{
    int64_t s = 0;
    for (int i = 1; i <= n; i++)
    {
        int64_t l = i - 1, r = n - i;
        s = (s + l * i - r * i) % MOD;
    }
    s = (s % MOD * Pow(m, 2)) % MOD;
    return s;
}

void Solve()
{
    cout << ((SumX() + SumY()) % MOD * Comb(m * n - 2, k - 2)) % MOD;
}

int main()
{
    Enter();
    Init();
    Solve();
    return 0;
}


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


using namespace std;


int main() {
	string enki;
	cin >> enki;
	if (enki == "A") cout << "T" << endl;
	if (enki == "T") cout << "A" << endl;
	if (enki == "C") cout << "G" << endl;
	if (enki == "G") cout << "C" << endl;

	return 0;
}

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

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

	int G[100][100]={0};

	for(int i=0; i<n; i++){
		int u,k;
		cin >> u >> k;
		
		for(int j=0 ; j<k; j++){
			int v;
			cin >> v;
	
			G[u-1][v-1] = 1;
		}
	}

	int d[100] = {0};
	int f[100] = {0};

	stack<int> S;
	int T=0;

	for(int i=0; i<n; i++){
		if(d[i]!=0)
			continue;
		S.push(i);
		d[i] = ++T;

		while(!S.empty()){
			int u = S.top();
			int v = -1;
			for(int j=0; j<n; j++){
				if(G[u][j]==1 && d[j]==0){
					v = j;
					break;
				}
			}

			if(v!=-1){
				S.push(v);
				d[v] = ++T;
			}else{
				S.pop();
				f[u] = ++T;
			}
		}
	}
	
	for(int i=0; i<n; i++){
		cout << i+1 << ' ' << d[i] << ' ' << f[i] << endl;
	}
	return 0;
}


Measured memory_bytes: 1248
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(x) (x).begin(),(x).end()
template <class T> inline bool chmin(T &a, T b) {if (a > b){a = b;return true;}return false;}
template <class T> inline bool chmax(T &a, T b) {if (a < b){a = b;return true;}return false;}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b,c,d; cin>>a>>b>>c>>d;
    for(int i=1; i<=1100; i++){
        if(i%2==1){
            c -= b;
        }else{
            a -= d;
        }
        if(a<=0) {
            cout<<"No"<<endl;
            return 0;
        } 
        if(c<=0) {
            cout<<"Yes"<<endl;
            return 0;
        }
    }
}

Measured memory_bytes: 3652
fn main() {
    let mut a = input();
    a.sort();

    println!("{} {} {}", a[0], a[1], a[2]);
}

fn input() -> Vec<i32> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|q| q.parse::<i32>().unwrap()).collect()
}



Measured memory_bytes: 5040
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<stack>
#include<queue>
#include<deque>
#include<map>
#include<set>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
#define FOR(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR1(i,n) for(int (i)=1;(i)<(n);(i)++)
#define eFOR(i,n) for(int (i)=0;(i)<=(n);(i)++)
#define eFOR1(i,n) for(int (i)=1;(i)<=(n);(i)++)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
constexpr auto INF = 1000000000;
constexpr auto LLINF = 1LL << 62;
constexpr auto mod = 1000000007;
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; }

int main() {
    int n;
    cin >> n;
    vector<ll> a(n);
    int g = 0;
    FOR(i, n) {
        cin >> a[i];
        if (a[i] % 2)g++;
    }
    cout << (g % 2 ? "NO" : "YES") << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#include "string"
#define int long long
#define pi pair<int,int>
#define ff first
#define ss second
#define boost ios_base::sync_with_stdio(false);cin.tie(nullptr)

const int inf = 1e9;
array<int,4> a[55];
int n,m,q,ans=0;
int b[13];
int okk(){
	int ans = 0;
	for(int i=0;i<q;i++){
		if(b[a[i][1]] - b[a[i][0]] == a[i][2])
			ans+=a[i][3];
	}
	return ans;
}

void dfs(int u){
	if(u == 0){
		ans = max(ans,okk());
		return;
	}
	for(int i = b[u+1];i>=1;i--){
		b[u] = i;
		dfs(u-1);
	}
}

int32_t main() { 
    boost;
    cin>>n>>m>>q;
    for(int i=0;i<q;i++)
    	cin>>a[i][0]>>a[i][1]>>a[i][2]>>a[i][3];
    b[n+1] = m;
    dfs(n);
    cout<<ans<<endl;
}


Measured memory_bytes: 3640
def main():
    N, X = (int(i) for i in input().split())
    L = [int(i) for i in input().split()]
    from itertools import accumulate
    S = list(accumulate([0] + L))
    ans = 0
    for s in S:
        if X < s:
            break
        ans += 1
    print(ans)


if __name__ == '__main__':
    main()


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

using namespace std;
using ll = long long;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int q; cin >> q;
    while (q--) {
        int a, b; cin >> a >> b;
        ll n = a*1LL*b, sn = sqrt(n);
        if (sn*(sn+1) < n) cout << sn*2-1 << '\n';
        else if (sn*sn == n) cout << (a == b ? (sn-1)*2 : (sn-1)*2-1) << '\n';
        else cout << (sn-1)*2 << '\n';
    }
    return 0;
}

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

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        long[] ary = new long[n];
        for (int i = 0; i < n; i++) {
            ary[i] = Long.parseLong(sc.next());
        }
        long sum = Arrays.stream(ary).sum();
        long sub = Long.MAX_VALUE;
        long temp = 0;
        long idx = 0;
        for (int i = 0; i < n - 1; i++) {
            temp += ary[i];
            sub = Math.min(sub, Math.abs(sum - temp - temp));
        }
        System.out.println(sub);
    }
}

Measured memory_bytes: 50808
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <map>
#include <deque>
#include <string.h>
using namespace std;

#define REP(i,n) for(int i = 0; i < n; i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef pair<string,string> pss;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pi> vpi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

double EPS = 1e-9;
int INFi = 1000000005;
long long INFll = 1000000000000000005ll;
double PI = acos(-1);
int dirx[8] = {-1,0,0,1,-1,-1,1,1};
int diry[8] = {0,1,-1,0,-1,1,-1,1};
ll MOD = 1000000007;

int N;
const int MAX_N = 20000;
int p[MAX_N];

int main(){
  cin >> N;
  REP(i, N) cin >> p[i];
  int a[N], b[N];

  REP(i, N) {
    a[i] = (i + 1) * 20000;
    b[N - i - 1] = (i + 1) * 20000;
  }

  REP(i, N) a[p[i] - 1] += i;

  REP(i, N) {
    cout << a[i];
    if(i == N - 1) cout << endl;
    else cout << " ";
  }

  REP(i, N) {
    cout << b[i];
    if(i == N - 1) cout << endl;
    else cout << " ";
  }

  return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int i = (int)(n); i >= 0; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;

int main(){
    int X;
    cin >> X;
    vector<int> prime(0);
    prime.push_back(2);
    for(int i = 3; i <= 400; i++){
        if (i >= X){
            break;
        }
        bool isPrime = true;
        int len_prime = prime.size();
        rep(j,len_prime){
            if (i % prime[j] == 0){
                isPrime = false;
            }
        }
        if (isPrime){
            prime.push_back(i);
        }
    }
    int ans = 0;
    int len_prime = prime.size();
    for (int i = X; i <= 2 * X; i++){
        bool isPrime = true;
        rep(j,len_prime){
            if (i % prime[j] == 0){
                isPrime = false;
            }
        }
        if (isPrime && X != 2){
            ans = i;
            break;
        }
    }
    if (X == 2) cout << 2 << endl;
    else cout << ans << endl;
}


Measured memory_bytes: 256
from sys import stdin


def get_result(data):
    N, K = data[0]
    A = data[1]
    trans_num = [0] * N
    curr_pos = 1
    arrival_pos = set()
    for i in range(N):
        trans_num[curr_pos-1] = i
        arrival_pos.add(curr_pos)

        # see next
        next_pos = A[curr_pos-1]
        if next_pos in arrival_pos:
            loop_start = trans_num[next_pos-1]
            loop_trans_num = i + 1 - loop_start
            break

        # update
        curr_pos = next_pos

    # K が loop 開始より小さい可能性を忘れていた
    loop = K if (K - loop_start) < 0 else \
        loop_start + (K - loop_start) % loop_trans_num
    curr_pos = 1
    for _ in range(loop):
        next_pos = A[curr_pos-1]
        curr_pos = next_pos
    return next_pos


if __name__ == '__main__':
    raw_data = [val.rstrip() for val in stdin.readlines()]
    data = [list(map(int, val.split(' '))) for val in raw_data]
    result = get_result(data)
    print(result)


Measured memory_bytes: 37400
#include"bits/stdc++.h"
#define rep(i,n) for(ll i=0;i<n;++i)
#define ALL(x) x.begin(),x.end()

using namespace std;
typedef long long ll;

template<typename T>
T gcd(T a, T b) {
	if (a % b == 0) {
		return(b);
	}
	else {
		return(gcd(b, a % b));
	}
}


template<typename T>
T lcm(T a, T b) {
	return a / gcd(a, b) * b;
}

int main(void) {
	int a, b, c, d, e;
	cin >> a >> b >> c >> d >> e;
	cout << 15 - a - b - c - d - e;
}

/*

*/


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

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

    string str;
    cin >> str;

    int x = 0;
    int ans = 0;
    for (const auto& c : str)
    {
        x += c == 'I' ? 1 : -1;
        ans = max(x, ans);
    }
    cout << ans << endl;

    return 0;
}

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

typedef pair<int,int>   II;
typedef vector< II >      VII;
typedef vector<int>     VI;
typedef vector< VI > 	VVI;
typedef long long int 	LL;
typedef unsigned long long int ULL;

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(a) (int)(a.size())
#define ALL(a) a.begin(),a.end()
#define SET(a,b) memset(a,b,sizeof(a))
#define LET(x,a) __typeof(a) x(a)

#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
//Works for forward as well as backward iteration

#define gu getchar
#define pu putchar
#define si(n) scanf("%d",&n)
#define dout(n) printf("%d\n",n)
#define sll(n) scanf("%lld",&n)
#define lldout(n) printf("%lld\n",n)

#define DRT() int t; si(t); while(t--)

#define PlUSWRAP(index,n) index = (index+1)%n		//index++; if(index>=n) index=0
#define MINUSWRAP(index,n) index = (index + n -1)%n 	//index--; if(index<0) index=n-1
#define ROUNDOFFINT(d) d = (int)((double)d + 0.5)	//Round off d to nearest integer

#define FLUSHN while(gu()!='\n')
#define FLUSHS while(gu()!=' ')

#define TRACE

#ifdef TRACE
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;

#else

#define trace1(x)
#define trace2(x, y)
#define trace3(x, y, z)
#define trace4(a, b, c, d)
#define trace5(a, b, c, d, e)
#define trace6(a, b, c, d, e, f)

#endif

#define off ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
const LL N = 4100 + 1;
LL n,m,x;
LL dp[N];
LL SET_IT(LL k,LL pos)
{
	return k|(1<<pos);
}
int main() {
	// #ifndef ONLINE_JUDGE
 //    freopen("../input.txt", "r", stdin);
 //    freopen("../output.txt", "w", stdout);
	// #endif
	off;
	cin>>n>>m;
	LL lmt = 1<<n;
	for(LL i=0;i<N;i++)
	dp[i] = INT_MAX;
	vector<LL> cost(m);
	vector<LL> bitstate(m,0);
	rep(i,0,m)
	{
		LL t;
		cin>>cost[i]>>t;
		LL val = 0;
		while(t--)
		{
			cin>>x;
			val = SET_IT(val,x-1);
		}
		bitstate[i] = val;
		dp[val] = min(dp[val],cost[i]);
	}
	rep(i,0,m)
	{
		rep(j,0,lmt)
		{
			dp[j|bitstate[i]] = min(dp[j|bitstate[i]] , cost[i]+dp[j]);
		}
	}
	if(dp[lmt-1] != INT_MAX)
		cout<<dp[lmt-1];
	else
		cout<<-1;
  	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;

namespace AtCoder
{
    class Program
    {
        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        static int Solve(int[] A)
        {
            return new[] { Math.Abs(A[0] - A[1]) + Math.Abs(A[1] - A[2]),
                           Math.Abs(A[0] - A[2]) + Math.Abs(A[2] - A[1]),
                           Math.Abs(A[1] - A[0]) + Math.Abs(A[0] - A[2]),
                           Math.Abs(A[1] - A[2]) + Math.Abs(A[2] - A[0]),
                           Math.Abs(A[2] - A[0]) + Math.Abs(A[0] - A[1]),
                           Math.Abs(A[2] - A[1]) + Math.Abs(A[1] - A[0])}.Min();
        }
        static void Main(string[] args)
        {
            int[] A = ReadInts();
            Console.WriteLine(Solve(A));
        }
    }
}


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

vector< vector<long long> > dp(101 , vector<long long>(100001,-1));

long long  doWork(vector<long long > &a,vector<long long > &b,long long  i,long long  w){
	if(w<=0 || i>a.size())
		return 0;

	if(dp[i][w]!=-1)
		return dp[i][w];

	if(w<a[i])
		return (dp[i][w] = doWork(a,b,i+1,w));

	return (dp[i][w] = max( doWork(a,b,i+1,w) , doWork(a,b,i+1,w-a[i])+b[i] ));
}

int  main(){

	long long  n,w;
	cin >> n >> w;

	vector<long long > a(n),b(n);

	for(long long  i=0;i<n;i++){
		cin >> a[i] >> b[i];
	}

	cout << doWork(a,b,0,w) << "\n";

	return 0;
}

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

int main(){
  vector<int> s(3);
  
  for(int i = 0; i < 3 ; i ++){
    	cin >> s[i];
  }
  
  sort(s.begin(), s.end());
  s.erase(unique(s.begin(), s.end()), s.end());
  
  cout << s.size() << endl;
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

void Main() {
  ll n,m;
  cin >> n >> m;
  ll ans=MAX;
  rep(i,n) {
    ll x,y;
    cin >> x >> y;
    if(y<=m) ans=min(ans,x);
  }
  if(ans==MAX) pr("TLE");
  else pr(ans);
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


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

int main() {
  string N ; 
  cin >> N ;
  
  
  
  int sum = 0;
  
  for ( int i = 0 ; i < N.size() ; i++ ){
  	int f = N.at(i) - '0' ; 
    sum += f ; 
  }
  
  int ans = stoi(N) % sum ; 
  
  //cout << ans << endl ;
  if ( ans == 0 )
    cout << "Yes" << endl ; 
  else 
    cout << "No" << endl ; 
  
}




Measured memory_bytes: 256
#include<stdio.h>
char d[9];

void solve()
{
	int i;
	{
		for(i=0;i<3;i++)
		{
			if(d[i]==d[i+3]&&d[i+3]==d[i+6]&&d[i]!='s')
			{
				printf("%c\n",d[i]);
				return;
			}
			else if(d[3*i]==d[3*i+1]&&d[3*i+1]==d[3*i+2]&&d[3*i]!='s')
			{
				printf("%c\n",d[3*i]);
				return;
			}
		}
		if(((d[0]==d[4]&&d[4]==d[8])||(d[2]==d[4]&&d[4]==d[6]))&&d[4]!='s')
			printf("%c\n",d[4]);
		else
			puts("d");
	}
}
int main()
{
	while(scanf("%s",d)!=EOF)
		solve();
	return 0;
}

Measured memory_bytes: 552
var lines = require('fs').readFileSync('/dev/stdin', 'utf8').split('\n'),
    count = parseInt(lines[0]),
    nums = lines[1].split(/\s+/).map(function (n) { return parseInt(n, 10); }),
    counter = 0;
 
 
for (var i = 0; i < count; ++i) {
	if (nums[i] !== (i + 1))
      ++counter;
}
console.log(counter === 0 || counter === 2 ? 'YES' : 'NO');


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

int main(void){
    char str[100001];
    int check[26] = {0};
    scanf("%s",str);
    int len = strlen(str);

    for(int i = 0;i<len;i++){
        check[str[i] % 97] = 1;
    }

    for(int i = 0;i < 26;i++){
        if(check[i] == 0){
            printf("%c",(char)i+97);
            return 0;
        }
    }

    printf("None");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define f first
#define s second
#define pb push_back
#define eb emplace_back
#define mk make_pair
#define mt make_tuple
#define MOD 1000000007
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
#define all(x) x.begin(), x.end()
#define vi vector<int>
#define vl vector <long long int>
#define pii pair <int,int>
#define pll pair <long long int, long long int>
#define vpii vector< pair<int,int> >
#define vpll vector < pair <long long int,long long int> >
#define boost ios::sync_with_stdio(false); cin.tie(0)
using namespace std;
const int inf = 1e9 + 5;
const ll inf64 = 1e18 + 5;
int main()
{
	boost;
	int a, b, k, i;
	cin >> k;
	cin >> a >> b;
	foe(i, a, b) {
		if(i % k == 0) {
			cout << "OK";
			return 0;
		}
	}
	cout << "NG";
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(a);i>(b);--i)
#define eper(i,a,b) for(int i=(a);i>=b;--i)
#define pb push_back
#define mp make_pair
#define INF 100100100100
#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
#define vii vector<int>
#define vll vector<long long>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
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; }
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a, b)*b;}

int n;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
    cin >> n;
    int ans = 1;
    while (ans * ans <= n) ans++;
    ans--;
    cout << ans * ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<double,double> pd;

typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pi> vpi;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001;

vi A;
int N;
pi bes = {MOD,MOD};

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> N; A.resize(N); F0R(i,N) cin >> A[i];
    sort(all(A));
    F0R(i,N-1) bes = min(bes,{abs(2*A[i]-A[N-1]),A[i]});
    cout << A[N-1] << " " << bes.s;
}

// read the question correctly (is y a vowel? what are the exact constraints?)
// look out for SPECIAL CASES (n=1?) and overflow (ll vs int?)

Measured memory_bytes: 640
#include<stdio.h>
    int main()
    {
        int r,g,b,N;
        scanf("%d %d %d",&r,&g,&b);
        N = 100*r+ 10*g + b;
        if(N % 4 == 0) printf("YES\n");
        else printf("NO\n");
        return 0;
    }

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

using namespace std;

#define lli long long 
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(),i.rend()
#define rep0(i,j) for(lli i=0;i<j;i++)
#define rep1(i,j) for(lli i=1;i<=j;i++)
#define rep0d(i,j) for(lli i=j-1;i>=0;i--)
#define MAX 1000000007
bool cmpf(const pair<lli, lli> left, const pair<lli, lli> right) {
          return left.first < right.first;
}
bool cmps(const pair<double, double> left, const pair<double, double> right) {
          return left.second < right.second;
}


int main(){
    int n;
    cin >> n;
    vector<int> vec(n);
    rep0(i,n){
        cin >> vec[i];
    }

    int num=0,minnum=MAX;
    rep1(i,100){
        num=0;
        rep0(j,n){
            num += (i-vec[j])*(i-vec[j]);
        }
        if(minnum > num){
            minnum=num;
        }
    }
    cout << minnum ;
}

Measured memory_bytes: 256
import math
import sys 
import collections
n = int(input())
a = list(map(int,input().split()))
tmp = 0
# comb = [tmp+=i for i in range(1,n+1)]
comb = []
diff = []
su = 0
for i in range(0,n):
    su = su+i
    comb.append(su)
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
c = collections.Counter(a)
total = 0
for i in c.values():
    total += comb[i-1]
for i in a:
    print(total - (c[i]-1))

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

typedef int64_t Int;
#define all(x) (x).begin(), (x).end()
 
const double EPS = 1e-10;
const Int INF = 1e18;
const int inf = 1e9;
const Int mod = 1e9+7;

bool print_space_enable = false;
void print() { 
    cout << endl; 
    print_space_enable = false;
}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
    if (print_space_enable) cout << " ";
    cout << fixed << setprecision(15) << head;
    print_space_enable = true;
    print(std::forward<Tail>(tail)...);
}

template<typename T>
void print(vector<T> v) {
    for (size_t i = 0; i < v.size(); i++) {
        if (i > 0) std::cout << " ";
        std::cout << v[i];
    }
    std::cout << std::endl;
}

int main() {
    Int n;
    cin >> n;
    vector<Int> a(n), b(n);
    for (Int i = 0; i < (Int)n; i++) {
        cin >> a[i] >> b[i];
    }
    sort(all(a));
    sort(all(b));
    if (n % 2 == 0) {
        double am = (double)(a[n / 2 - 1] + a[n / 2]) / 2.0;
        double bm = (double)(b[n / 2 - 1] + b[n / 2]) / 2.0;
        Int res = 2.0 * (bm - am);
        print(res + 1);
    } else {
        print(b[n / 2] - a[n / 2] + 1);
    }
    return 0;
}

Measured memory_bytes: 6372
<?php
list($n) = ints();
for ($i = 0; $i < $n - 1; ++$i) {
    list($a, $b) = ints();
    $a--; // 0スタートに合わせる
    $b--;
    $g[$a][] = $b;
    $g[$b][] = $a; // 無向グラフの場合
}
$c = ints();
rsort($c);
// BFS（幅優先探索）：最短経路アルゴリズムとして活用
$q = new SplQueue(); // キューを用意
$dist = array_fill(0, $n, -1); // 距離を格納する配列（-1の場合はその頂点が未発見）

$dist[0] = 0; // 頂点0からの距離格納配列
$q->enqueue(0); // キューに0を追加
$i = 0;
while (!$q->isEmpty()) {
    $v = $q->dequeue();
    $d[$v] = $c[$i];
    ++$i;
    foreach ($g[$v] as $next_v) {
        if ($dist[$next_v] !== -1) continue; // 発見済み

        $dist[$next_v] = $dist[$v] + 1;
        $q->enqueue($next_v);
    }
}
ksort($d);
$m = array_sum($c) - max($c);
echo $m . PHP_EOL;
echo implode(' ', $d);
function ints()
{
    return array_map('intval', explode(' ', trim(fgets(STDIN))));
}


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

using namespace std;

const int MAXK = 1e5 + 10;
const int MOD = 1e9 + 7;

int pref[MAXK],dp[MAXK],N,K;

int calc(int a,int b){
	int ans = pref[b];
	if(a < 0) return ans;
	if(a != 0) ans -= pref[a-1];
	return ans % MOD;
}

int main(){
	cin >> N >> K;
	dp[0] = 1;
	for(int kid = 1;kid<=N;kid++){
		int c;
		cin >> c;
		pref[0] = dp[0];
		dp[0] = 0;
		for(int i = 1;i<=K;i++){
			pref[i] = (pref[i-1] + dp[i]) % MOD;
		}
		for(int i = 0;i<=K;i++){
			dp[i] = calc(i-c,i);
		}
	}

	int ans = dp[K];
	if(ans < 0) ans += MOD; 
	printf("%d\n",ans);

	return 0;
}


Measured memory_bytes: 1024
#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;
  cin >> n;
  string s;
  cin >> s;
  rep (i, s.size()) {
    s[i] = (s[i] - 'A' + n) % 26 + 'A';
  }
  cout << s << endl;
  return 0;
}

Measured memory_bytes: 256