akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++) 
#define FOR(i,ini,n) for(int i=(ini);i<(n);i++)
#define SZ(x) (int)x.size()

using namespace std;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string a,b;
	while(cin >> a >> b){
		string ans = "";
		if(SZ(a) > SZ(b))ans = "GREATER";
		else if(SZ(a) < SZ(b))ans = "LESS";
		else{
			REP(i,SZ(a)){
				if(a[i]-'0' > b[i] - '0'){
					ans = "GREATER";
					break;
				}
				else if(a[i] - '0' < b[i] - '0'){
					ans = "LESS";
					break;
				}
			}
			if(ans == "")ans = "EQUAL";
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 256
import java.io.PrintWriter
import java.util.*
import java.math.*
import java.lang.*

val pw = PrintWriter(System.out)

fun main(args: Array<String>) {
    val n = readInt()

    var p: MutableList<Int> = mutableListOf<Int>()
    for(i in 0 until n) {
        p.add(readInt())
    }

    p = p.sorted().toMutableList()
    val mostHigh = p.last()
    p = p.dropLast(1).toMutableList()

    val rtn = p.sum() + mostHigh / 2
    println(rtn)

    pw.flush()
}

fun inputList() = 
    readLine()!!.split(" ").map(String::toInt)

fun sum_digits(num_: Long): Long {
    var num = num_
    var rtn: Long = 0
    while(num != 0.toLong()) {
        val tmp = num % 10
        rtn += tmp
        num /= 10
    }
    return rtn
}

/****** Decrared Functions ******/

// IO
fun read() = readLine()!!
fun readInt() = read().toInt()
fun readLong() = read().toLong()
fun readDouble() = read().toDouble()
fun readListOfString() = read().split(" ")
fun readListOfInt() = readListOfString().map { it.toInt() }
fun readListOfLong() = readListOfString().map { it.toLong() }
fun readListOfDouble() = readListOfString().map { it.toDouble() }

fun Double.format(digits: Int) = String.format("%.${digits}f", this)

fun println(value : Any) {
    pw.println(value)
}

fun gcd(a: Long, b: Long): Long = 
    if(b != 0L) a else gcd(b, a % b)

fun lcm(a: Long, b: Long) = 
    if(b==0L) a else gcd(b, a % b)


Measured memory_bytes: 36260
#include<bits/stdc++.h>
using namespace std;
int main() {
	int n, v, ans = 0;
	cin >> n;
	vector<int> num(n);
	for (int i = 0; i < n; i++) {
		cin >> num.at(i);
	}
	for (int i = 0; i < n; i++) {
		v = i;
		for (int j = i + 1; j < n; j++) {
			if (num[j] < num[v]) {
				v = j;
			}
		}
		if (i != v) {
			swap(num[i], num[v]);
			ans++;
		}
	}
	for (int k = 0; k < n; k++) {
		printf("%d", num.at(k));
		if (k != n - 1)cout << ' ';
		else cout << endl;
	}
	cout << ans << endl;
}


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

int main(){
    ll n;
    cin >> n;
    ll ans = n*(n+1)*(n+2)/6;
    ll u, v;
    rep(i, n-1) {
        cin >> u >> v;
        if (u>v) swap(u, v);
        ans -= u*(n-v+1);
    }
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3620
#include <stdio.h>



const int MAX_V = 1000000;
int prime[1000001];
int sum[1000002];



int main(){
	int i, k, n;
	int num;
	sum[0] = 0;

	for (i = 2; i <= MAX_V; i++){
		prime[i] = 1;
	}

	for (i = 2; i*i <= MAX_V; i++){
		if (prime[i]){
			for (k = 2 * i; k <= MAX_V; k += i){
				prime[k] = 0;
			}
		}
	}


	for (i = 0; i <= MAX_V; i++){
		sum[i + 1] = sum[i] + prime[i];
	}


	while (scanf("%d", &num) != EOF){
		int cnt = sum[num + 1];
		printf("%d\n", cnt);
	}
	return 0;
}

Measured memory_bytes: 8404
#include<bits/stdc++.h>
#define F first
#define S second
#define endl '\n'
#define lcm( a, b ) ((a)/__gcd(a,b)*(b))
#define MP make_pair
#define pb push_back
#define all(x) (x).begin(),(x).end()

using namespace std;

typedef long long LL;
typedef pair<int, int> P;
typedef pair<int, P> i_P;
typedef pair< LL, LL > L_P;

const int INF = INT_MAX;
const int MIN = INT_MIN;
const LL LINF = LLONG_MAX;
const int MOD = 1000000000 + 7;
const int SIZE = 100005;

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

    int n, d;
    cin >> n >> d;
    int x[n][d];
    for( int i = 0; i < n; ++i ) {
        for( int j = 0; j < d; ++j ) {
            cin >> x[i][j];

        }
    }

    int res = 0;
    for( int i = 0; i < n; ++i ) {
        for( int j = i + 1; j < n; ++j ) {
            int tmp = 0;
            for( int k = 0; k < d; ++k ) {
                tmp += abs( x[i][k] - x[j][k] ) * abs( x[i][k] - x[j][k] );

            }
            double sq = sqrt( tmp );
            int s = sq;
            if( (double)s == sq ) ++res;

        }
    }
    cout << res << endl;

    return 0;
}



Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i, s, n) for(int i = s, i##_len=(n); i < i##_len; ++i)
#define FORS(i, s, n) for(int i = s, i##_len=(n); i <= i##_len; ++i)
#define VFOR(i, s, n) for(int i = s; i < (n); ++i)
#define VFORS(i, s, n) for(int i = s; i <= (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) FORS(i, 0, n)
#define VREP(i, n) VFOR(i, 0, n)
#define VREPS(i, n) VFORS(i, 0, n)
#define RFOR(i, s, n) for(int i = s, i##_len=(n); i >= i##_len; --i)
#define RFORS(i, s, n) for(int i = s, i##_len=(n); i > i##_len; --i)
#define RREP(i, n) RFOR(i, n, 0)
#define RREPS(i, n) RFORS(i, n, 0)
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v), greater<decltype(v[0])>())
#define SZ(x) ((int)(x).size())
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end());

using ll = long long;
using PII = pair<int, int>;
using VI = vector<int>;
using VD = vector<double>;

const int MOD = 1000000007;
const int INF = 1000000000;

template<class T>bool chmax(T &a, const T &b){
    if(a < b){
        a = b; return true;
    }
    return false;
}
template<class T>bool chmin(T &a, const T &b){
    if(b < a){
        a = b; return true;
    }
    return false;
}

int main(){
    int n, m; cin >> n >> m;
    if(n > m) swap(n, m);
    ll ans;
    if(n == 1){
        if(m == 1) ans = 1;
        else ans = m - 2;
    }
    else ans = ll(n - 2) * (m - 2);
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int par1[200001],par2[200001];
vector<pair<int,int>> idx;
map<pair<int,int>,int> cnt;
int rep1(int n)
{
    if(par1[n]==n)
        return n;
    return par1[n]=rep1(par1[n]);
}
int rep2(int n)
{
    if(par2[n]==n)
        return n;
    return par2[n]=rep2(par2[n]);
}
int main()
{
    int i,j;
    int n,k,l;
    int a,b,res=0;
    scanf("%d %d %d",&n,&k,&l);
    for(i=1;i<=n;i++){
        par1[i]=i;
        par2[i]=i;
    }
    for(i=0;i<k;i++){
        scanf("%d %d",&a,&b);
        if(i%2)swap(a,b);
        int r1=rep1(a);
        int r2=rep1(b);
        par1[r1]=r2;
    }
    for(i=0;i<l;i++){
        scanf("%d %d",&a,&b);
        int r1=rep2(a);
        int r2=rep2(b);
        par2[r1]=r2;
    }
    for(i=1;i<=n;i++){
        idx.push_back(make_pair(rep1(i),rep2(i)));
    }

    for(i=0;i<idx.size();i++){
        cnt[idx[i]]++;
        //printf("%d %d\n",idx[i].first,idx[i].second);
    }
    for(i=0;i<idx.size();i++)
        printf("%d ",cnt[idx[i]]);
}


Measured memory_bytes: 15088
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)
#define Yes(condition) if(condition) cout << "Yes" << '\n'; else{ cout << "No" << '\n'; }
#define YES(condition) if(condition) cout << "YES" << '\n'; else{ cout << "NO" << '\n'; }
#define yes(condition) if(condition) cout << "yes" << '\n'; else{ cout << "no" << '\n'; }




int main() {
    ll n;
    cin >> n;
    ll x[100], y[100], h[100];
    REP(i, n){
        cin >> x[i] >> y[i] >> h[i];
    }
    REP(l, n){
        REP(i, 101){
            REP(j, 101){
                ll H = h[l] + abs(x[l] - i) + abs(y[l] - j);
                if(H < 1) continue;
                bool ok = true;
                REP(k, n){
                    if(max(H - abs(x[k] - i) - abs(y[k] - j), 0LL) != h[k]){
                        ok = false;
                    }
                }
                if(ok){
                    cout << i << ' ' << j << ' ' << H << endl;
                    return 0;
                }
            }
        }
    }
}


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

#ifdef DEBUG
#define debug(x) cout << #x << ": " << x << endl
#else
#define debug(x)
#endif

#define int ll

#define REP(i, n) for(int i = 0; i < (n); i++)
#define REPS(i, n) for(int i = 1; i <= (n); i++)
#define ALL(v) (v).begin(), (v).end()

#define pb push_back
#define mp make_pair
#define mt make_tuple

using namespace std;

using ll = long long;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vb = vector<bool>;
using vvi = vector<vi>;
using vvl = vector<vl>;

const ll INF = 1e9;
const ll MOD = 1e9+7;

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

signed main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    
    long double A, B; cin >> A >> B;
    long double m = A*B;
    cout << (ll)m << endl;
}

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

using namespace std;
typedef long long ll;
//#define int ll
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
#define FOR(i, a, b) for (int i = a; i < b; ++i)

typedef pair<int, int> pii;
typedef pair<double, int> pdi;

const int INF = 1000 * 1000 * 1000 + 10;

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

#ifdef LOCAL
    freopen("input.txt", "r", stdin);
#endif

    string s;
    cin >> s;

    if (s[0] == s[1] || s[1] == s[2] || s[2] == s[3])
        cout << "Bad\n";
    else
        cout << "Good\n";
}

Measured memory_bytes: 256
def chocolate(N: int, D: int, X: int, A: list) -> int:
    # i 人目の参加者が食べる個数を m とすると、m は
    # (m-1)ai + 1 <= D
    # を満たす最大の m である。したがって、これを変形して、
    # m = 1 + (D-1)//ai
    # となる。
    # これを各 i について和をとって、残った X 個を足せば
    # 初日に用意されていた個数が算出できる。
    return X + sum(1 + (D-1)//a for a in A)


if __name__ == "__main__":
    N = int(input())
    D, X = map(int, input().split())
    A = [int(input()) for _ in range(N)]
    ans = chocolate(N, D, X, A)
    print(ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
  
using namespace std;
  
template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }
  
#define pb push_back
#define mp make_pair
#define cotu cout
#define itn int
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)
  
#define ordered_set tree<int , null_type,less<int >, rb_tree_tag,tree_order_statistics_node_update> 
  
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
  
const int inf = int(1e9);
const int mod = inf + 7;
const int N = 1e6 + 555; // TL MB
const double PI = acos(-1.0);
 
void mul(ll &x, ll y){
	x *= y;
	if(x >= mod) x %= mod;
}
 
void add(ll &x, ll y){
	x += y;
	if(x >= mod) x -= mod;
	if(x < 0) x += mod;
}
ll bp(ll a, ll n){
	ll r = 1;
	while(n){
		if(n & 1) mul(r, a);
		mul(a, a);
		n >>= 1;
	}
	return r;
}



void solve()
{
	int n;
	cin >> n;
	int gcd = 0;
	for(int i = 0; i < n; ++i)	{
		int x; cin >> x;
		gcd = __gcd(gcd, x);
	}
	cout << gcd;
}


 
 
int main()
{
    Red;
  	// int T; cin >> T; while(T--)
    solve();
    return 0;
}

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

int main()
{
	int n;
	cin >> n;
	bool flag = false;
	while(n--){
		char s;
		cin >> s;
		if(s == 'Y') flag = true;
	}
	if(flag == true) puts("Four");
	else puts("Three");
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N = 1e5+10;

struct DSU
{
	int par[N], sz[N];

	void init(int n) 
	{
		for(int i=1;i<=n;i++)
		{
			par[i]=i;
			sz[i]=1;
		}
	}

	int getPar(int k)
	{
		while(k!=par[k])
		{
			par[k]=par[par[k]];
			k=par[k];
		}
		return k;
	}

	int getSize(int k)
	{
		return sz[getPar(k)];
	}

	bool unite(int u, int v)
	{
		int par1=getPar(u), par2=getPar(v);

		if(par1==par2)
			return false;


		if(sz[par1]>sz[par2])
			swap(par1, par2);

		sz[par2]+=sz[par1];
		sz[par1]=0;
		par[par1]=par[par2];
        return true;
	}
};

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    DSU dsu;
    int n,m;
    cin >> n >> m;
    dsu.init(n);
    int ans = n;
    while(m--)
    {
        int x,y,z;
        cin >> x >> y >> z;

        ans-=dsu.unite(x,y);
        
    }
    
    cout << ans;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { INIT(){
  cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


signed main() {
  int N; 
  cin >> N;

  vector<int> A(N+1, 0);
  REP(i, N) cin >> A[i];


  int ans = 0;

  int sum = 0;
  REP(i, N+1){
    if(A[i] == 0){
      ans += sum/2;
      sum = 0;
    }else{
      sum += A[i];
    }
  }

  cout << ans << "\n";

  return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>

int main()
{
    char str[4];
    scanf("%s",str);
    int q = 0;
        if (str[0] == 'o')
        {
            q++;
        }
        if (str[1] == 'o')
        {
            q++;
        }
        if (str[2] == 'o')
        {
            q++;
        }

    int price = 700 + (q * 100);
    printf("%d\n",price);
}

Measured memory_bytes: 128
import math

N, K = map(int, input().split())
A = list(input().split())
A_lis = [int(A[i]) for i in range(N)]
index = A_lis.index(1)

if N == K:
    print(1)
else:
    left = math.ceil(index / (K-1))
    leftamari = index % (K-1)
    right = math.ceil(max(0, N - 1 - index - (K - 1 - leftamari if leftamari != 0 else 0)) / (K-1))
    print(left + right)
    

Measured memory_bytes: 13924
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <deque>
#include <queue>//for queue and priority_queue
#include <fstream>
#include <iomanip>
#include <stack>
#include <algorithm>
#include <set>
#include <map>
#include <list>
#define endl "\n"
typedef long long ll;
using namespace std;
void Lancer() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); }
bool isPrime(ll n){
	if (n == 2 || n == 3 || n == 5)
		return true;
	else if (n % 2 == 0 || n % 3 == 0 || n % 5 == 0 || n == 1)
		return false;
	else {
		for (int i = 5; i <= sqrt(n); i += 2){
			if (n%i == 0)
				return false;
		}
		return true;
	}
}

int frq[123];
int main(){
	Lancer();
	string str,res="";
	cin >> str;
	for (int i = 0; i < str.length(); i+=2){
		res += str[i];
	}
	cout << res;
	cout << endl;
	return 0;
}


Measured memory_bytes: 3732
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXN = 500500;
int C[MAXN];

int main() {
    int N;
    ll P, Q;
    cin >> N >> P >> Q;
    ll sum = 0;
    vector<pair<ll, int> > ps;
    for (int i = 0; i < N; i++) {
        cin >> C[i];
        sum += C[i];
        ps.emplace_back(C[i]+P*i, i);
    }
    sort(ps.begin(), ps.end());
    ll ans = -1ll<<55;
    for (int i = 0; i <= N; i++) {
        ans = max(ans, sum+P*i*(i-1)+P*Q*i);
        if (i < N) {
            sum -= C[ps[i].second] + P*ps[i].second;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 12700
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int ara[5],k,i,j;
    for(i=0;i<5;i++)
        cin>>ara[i];
    cin>>k;
    int p=0;
    for(i=0;i<5;i++)
        for(j=0;j<5;j++)
    {
        if(i==j) continue;
        if(abs(ara[i]-ara[j])>k)
            p=1;
    }
    if(p==0)
        cout<<"Yay!"<<endl;
    else
        cout<<":("<<endl;

    return 0;

}


Measured memory_bytes: 256
h, w, k = map(int,input().split())
S = [list(map(int, list(input()))) for _ in range(h)]

ans = 10**9+7

for i in range(1<<(h-1)):
    box = [[0] * w]
    bcnt = 0 #縦のindex

    box[bcnt] = [s + b for s, b in zip(S[0], box[bcnt])]

    #横に適当に線を入れる(=その分のboxを増やす)
    #線が入らなかったらその区画にそのまま値を入れる
    #区画ごとの畳み込み
    for j in range(1, h):
        if (i >> (j-1)) & 1:
            bcnt += 1
            box.append([0] * w)
        box[bcnt] = [s + b for s, b in zip(S[j], box[bcnt])]

    #
    if not all([all([i<=k for i in b]) for b in box]):
        continue

    
    cutcnt = len(box) - 1 #すでに縦にに切っている分の個数
    cnt = [0] * len(box)    #区画ごとのcntのbox
    #縦ごとにグループに白チョコの個数を追加していく
    for m in range(w):
        for n in range(len(box)):
            cnt[n] += box[n][m] #n番目のグループにbox n番目m列目の個数を追加する
        if any([c > k for c in cnt]):  #グループ内白チョコの個数がkを超えているグループが1つでもあったら縦線を1つ追加する
            cutcnt += 1
            #個数がオーバーしたので改めて今の列を新しいグループの最初の列としてこれから白チョコを追加していく
            for n in range(len(box)):
                cnt[n] = box[n][m]
    ans = min(ans, cutcnt)

print(ans)

Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
long long arr[200005];

int main(){
	int n;
	cin>>n;
	for(int i=1; i<=n; i++) cin>>arr[i];
	for(int i=1; i<=n; i++) arr[i]+=arr[i-1];
	long long mn = numeric_limits<long long>::max();
	for(int i=1; i<=n-1; i++){
		mn = min(mn,abs(arr[i]-(arr[n]-arr[i])));
	}
	cout<<mn;
}

Measured memory_bytes: 5156
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define il inline
#define outy printf("Yes\n")
#define outn printf("No\n")
#define outf printf("First\n")
#define outs printf("Second\n")
#define FOR(a,b,c) for(int a=b;a<=c;a++)
#define FORD(a,b,c) for(int a=b;a>=c;a--)
#define FORL(a,b) for(int a=head[b];a;a=nxt[a])
#define in(a)  a=read()
#define in2(a,b)  a=read(),b=read()
#define in3(a,b,c)  a=read(),b=read(),c=read()
#define in4(a,b,c,d)  a=read(),b=read(),c=read(),d=read()
#define inl(a)  a=readl()
#define inl2(a,b)  a=readl(),b=readl()
#define inl3(a,b,c)  a=readl(),b=readl(),c=readl()
#define inl4(a,b,c,d)  a=readl(),b=readl(),c=readl(),d=readl()
#define out(a) printf("%d\n",a)
#define out2(a,b) printf("%d %d\n",a,b)
#define out3(a,b,c) printf("%d %d %d\n",a,b,c)
#define out4(a,b,c,d) printf("%d %d %d %d\n",a,b,c,d)
#define outl(a) printf("%lld\n",a)
#define outl2(a,b) printf("%lld %lld\n",a,b)
#define outl3(a,b,c) printf("%lld %lld %lld\n",a,b,c)
#define outl4(a,b,c,d) printf("%lld %lld %lld %lld\n",a,b,c,d)
#define clr(x,y) memset(x,y,sizeof(x))
inline int read(){
    char c;int s=0,t=1;
    while(!isdigit(c=getchar()))if(c=='-')t=-1;
    do{s=s*10+c-'0';}while(isdigit(c=getchar()));
    return s*t;
}
inline ll readl(){
    char c;ll s=0;int t=1;
    while(!isdigit(c=getchar()))if(c=='-')t=-1;
    do{s=s*10+c-'0';}while(isdigit(c=getchar()));
    return s*t;
}
/*------------------------------------------------------------*/
#define mod 1000000007
#define maxn 200010
#define N 1010 
#define inf 0x7fffffff
/*------------------------------------------------------------*/


#define shl(i) (1<<i)
int a[maxn],b[maxn],c[maxn];
int n;			
int check(int x,int w){
//	if(w<10)out(w);
	int l=0,r=n+1;
	while(l+1<r){
		int mid=(l+r)>>1;
		if(c[mid]+x<=w)l=mid;
		 else r=mid;
	}
	return l;
}		
int main(){
	in(n);
	FOR(i,1,n)in(a[i]);
	FOR(i,1,n)in(b[i]);
	int k=0;
	FOR(i,0,28){
		int ans=0;
		FOR(j,1,n)c[j]=b[j]&(shl(i+1)-1);
//		,printf("%d ",c[j]);
//		printf("\n");
		sort(c+1,c+n+1);
		FOR(j,1,n){
			int x=a[j]&(shl(i+1)-1);
			ans+=check(x,shl(i+1)-1)-check(x,shl(i)-1)+check(x,shl(i+2)-1)-check(x,shl(i+2)-1-shl(i));
//			printf("%d %d %d 233 ",ans,check(x,shl(i+1)-1),check(x,shl(i)-1));
		}
//		out(ans);
		if(ans&1)k|=shl(i);
	}
	out(k);
}

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

int main() {
    Int n; cin >> n;
    Int minv = 0;

    rep(i, 5) {
        Int tmp; cin >> tmp;
        if (i == 0) minv = tmp;
        else {
            minv = min(minv, tmp);
        }
    }
    if (n <= minv) {
        cout << 5 << endl;
        return 0;
    }
    Int ans = (n + minv -1) / minv + 4;
    cout << ans << endl;
}

Measured memory_bytes: 3612
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 = sc.nextInt();
		String s = sc.next();


		int x = 0;
		int[] array = new int[n + 1];
		array[0] = x;
		//入力データを処理して、結果を出力
		for(int i = 0; i < n; i++) {
			if(s.charAt(i) == 'I') {
				x++;
			} else {
				x--;
			}
			array[i + 1] = x;
		}
		Arrays.sort(array);
		System.out.println(array[n]);
	}
}



Measured memory_bytes: 35572
n=int(input())
A=list(map(int,input().split()))+[0]
ans=0

while 1:
  for i in range(n):
    if A[i]>0:
      A[i]-=1
      if A[i+1]==0:
        ans+=1
  if not A==[0 for i in range(n+1)]:
    continue
  break
print(ans)


Measured memory_bytes: 3060
# coding:utf-8

while (True):
    inputCount = int(input())

    if inputCount == 0:
        break

    employeeNumber = []
    employeePrice = []

    while 0 < inputCount:
        inputNum = [int(item) for item in input().split(" ")]

        price = inputNum[1] * inputNum[2]

        if inputNum[0] in employeeNumber:
            index = employeeNumber.index(inputNum[0])
            employeePrice[index] += price
        else:
            employeeNumber.append(inputNum[0])
            employeePrice.append(price)

        inputCount -= 1

    isExist = False

    for index in range(0, len(employeeNumber)):
        if 1000000 <= employeePrice[index]:
            print(employeeNumber[index])
            isExist = True

    if not isExist:
        print("NA")



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

int main()
{
    int a ,b,c,x,y,q,w,e,t,p;
    cin>>a>>b>>c>>x>>y;
   if(x>=y)
   {
        q=c*2*y+a*(x-y);
        w=c*2*x;
        e=a*x+b*y;
   }

    else
    {
         q=c*2*x+b*(y-x);
         w=c*2*y;
         e=a*x+b*y;
    }
       t=q>=w?w:q;
       p=t>=e?e:t;
       cout<<p<<endl;

    return 0;
}


Measured memory_bytes: 256
/**
 *  author: mahfuzz
 *  created: 10.05.2020
**/
 
#include <bits/stdc++.h>
using namespace std;
#define all(a) (a).begin(), (a).end()
#define trace(x) cout << #x << ':' << x << "\n"
typedef long long ll;

int main(int argc, char* argv[]){
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    
    int a, b, c, k; cin >> a >> b >> c >> k;
    
    int cnt = 0;
    if(k >= a){
        k -= a;
        cnt += a;
    }else{
        cnt += k;
        
        k -= k;
    }
    
    
    if(k >= b)
        k -= b;
    else
        k -= k;
        
        
    if(k >= c){
        k -= c;
        cnt -= c;
    }else{
        
        cnt -= k;
        k -= k;
    }
    
    cout << cnt << "\n";
    
    return 0;
}



Measured memory_bytes: 3620
#include<iostream>
using namespace std;
int main(){
  int a,b,c,k;
  cin >> a >> b >> c >> k;
  if(k<=a){
    cout << k << endl;
  }
  else if(k<=a+b){
    cout << a << endl;
  }
  else{
    cout << a-(k-a-b) << endl;
  }
}

Measured memory_bytes: 3560
/*         
               JAI SHREE RAM    */
 
 
 
#include<bits/stdc++.h>
using namespace std;
 
#define ff              first
#define ss              second
#define pb              push_back
#define int             long long
#define mp              make_pair
#define pr              pair<long long,long long>
#define vr              vector<long long>
#define mod            1000000007
#define mod2            998244353
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define ll              long long
#define ld	            long double
#define w(x)            int x; cin>>x; while(x--)
#define fill(a,b)       memset(a, b, sizeof(a))
#define ios ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
 

const int N = 1000001;
  vector <int> a;
int power(int x, unsigned int y) 
{ 
    int res = 1;     
   
    while (y > 0) 
    { 
        
        if (y & 1) 
            res = res*x; 
        y = y>>1; // y = y/2 
        x = x*x;  // Change x to x^2 
    } 
    return res; 
}
 
long long maxSubArray(long long a[], int sze)
{
   long long max_so_far = 0, max_ending = 0;
   for (int i = 0; i < sze; i++)
   {
       max_ending = max_ending + a[i];
       if (max_ending < 0)
           max_ending = 0;
       else if (max_so_far < max_ending)
           max_so_far = max_ending;
   }
   return max_so_far;
}
 
 
 
ll factorialNumInverse[N + 1]; 
ll naturalNumInverse[N + 1]; 
ll fact[N + 1]; 
  
 
void InverseofNumber(ll p) 
{ 
    naturalNumInverse[0] = naturalNumInverse[1] = 1; 
    for (int i = 2; i <= N; i++) 
        naturalNumInverse[i] = naturalNumInverse[p % i] * (p - p / i) % p; 
} 
void InverseofFactorial(ll p) 
{ 
    factorialNumInverse[0] = factorialNumInverse[1] = 1; 
  
    
    for (int i = 2; i <= N; i++) 
        factorialNumInverse[i] = (naturalNumInverse[i] * factorialNumInverse[i - 1]) % p; 
} 
void factorial(ll p) 
{ 
    fact[0] = 1; 
  
    // precompute factorials 
    for (int i = 1; i <= N; i++) { 
        fact[i] = (fact[i - 1] * i) % p; 
    } 
} 
  
ll Binomial(ll N, ll R, ll p) 
{ 
    // n C r = n!*inverse(r!)*inverse((n-r)!) 
    ll ans = ((fact[N] * factorialNumInverse[R]) 
              % p * factorialNumInverse[N - R]) 
             % p; 
    return ans; 
} 

 
void solve()
{
   string s;
   cin>>s;
   string ans;
   if(s[s.length()-1]=='s')
   ans=s+"es";
   else
   ans=s+"s";
   
   cout<<ans<<"\n";
    
}
 
int32_t main()
{ 
      
      ios;
      int test;
     
      
      test=1;
   //  cin>>test;
    
      while(test--)
      {
          solve();
      }
       
    
    return 0;
	}

Measured memory_bytes: 3668
import java.util.Scanner;

class Main {

	public static void main(String[] args) {
		Scanner cin=new Scanner(System.in);
		while(true){
			String str=cin.nextLine();
			String data[]=str.split(" ");
			int a=Integer.parseInt(data[0]),b=Integer.parseInt(data[2]),res=0;
			char op[]=data[1].toCharArray();
		
			if(op[0]=='?')break;
			if(op[0]=='+')res=a+b;
			if(op[0]=='*')res=a*b;
			if(op[0]=='-')res=a-b;
			if(op[0]=='/')res=a/b;
		
			System.out.println(res);
		}
	}

}



Measured memory_bytes: 26224
from heapq import heappush, heappop

def main():
    INF = 10 ** 18

    sum_B = 0
    L, R = [INF], [INF]
    sum_L = sum_R = 0
    L_size = R_size = 0

    A = map(int, open(0).read().split())

    Q = next(A)
    for _ in range(Q):
        q = next(A)
        if q == 1:
            a, b = next(A), next(A)

            sum_B += b

            max_L = -heappop(L)
            min_R = heappop(R)

            sum_L -= max_L
            sum_R -= min_R

            l, m, r = sorted((max_L, a, min_R))

            heappush(L, -l)
            heappush(R, r)
            sum_L += l
            sum_R += r

            if L_size == R_size:
                heappush(L, -m)
                L_size += 1
                sum_L += m
            else:
                heappush(R, m)
                R_size += 1
                sum_R += m

        else:
            median = -L[0]
            min_value = sum_B + sum_R - sum_L
            if L_size != R_size:
                min_value += median
            print(median, min_value)


if __name__ == '__main__':
    main()


Measured memory_bytes: 43748
#include <bit>
#include <bitset>
#include <assert.h>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <stdlib.h>
#include <queue>
#include <stack>


typedef long double ld;
typedef long long ll;

using namespace std;

#define MAXN (1 << 20)

ll a[MAXN];
ll s[MAXN];
int n;

ll check(int l, ll b) {
	if (l > n) {
		if (b == 0) {
			return 0;
		} else {
			return -1;
		}
	}
	if (b < a[l]) {
		return -1;
	}
	ll nnext = check(l + 1, min(2 * (b - a[l]), s[l + 1]));
	if (nnext >= 0) {
		return b + nnext; 
	} else {
		return -1;
	}
}


int main() {
	cin >> n;
	for (int i = 0; i <= n; i++) {
		cin >> a[i];
	}
	for (int i = n; i >= 0; i--) {
		s[i] = s[i + 1] + a[i];
	}
	cout << check(0, 1) << endl;
	return 0;
}


Measured memory_bytes: 6720
#include <iostream>
#include <cstdio>
using namespace std;
const int MAXN = 200005;
const int inf = 0x3f3f3f3f;
typedef long long LL;
LL a[MAXN];
int main()
{
    //int T, n;
    char ch;
    scanf("%c", &ch);
    printf("%c\n", ch+1);
    return 0;
}


Measured memory_bytes: 256
#![allow(non_snake_case)]
#![allow(unused_variables)]
#![allow(dead_code)]

fn main() {
    let N: usize = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.trim().parse().unwrap()
    };
    let a: Vec<i64> = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.split_whitespace()
            .map(|x| x.parse().unwrap())
            .collect()
    };

    let m = {
        let mut m = a.iter().scan(0, |s, &x| {
            *s = std::cmp::max(*s, x);
            Some(*s)
        }).collect::<Vec<_>>();
        m.insert(0, 0);
        m
    };
    let mut q = std::collections::BinaryHeap::new();
    let mut k = 0;
    let mut res = std::collections::VecDeque::new();
    for i in (0..N).rev() {
        let mut x = 0;
        if a[i] > m[i] {
            k += 1;
            x += k * (a[i] - m[i]);
            while let Some(&t) = q.peek() {
                if t >= m[i] {
                    k += 1;
                    x += t - m[i];
                    q.pop();
                } else { break; }
            }
        } else { q.push(a[i]); }
        res.push_front(x);
    }
    let ans = res.iter()
        .map(|res| res.to_string())
        .collect::<Vec<_>>()
        .join("\n");

    println!("{}", ans);
}

Measured memory_bytes: 15608
import java.util.*;

public class Main{
   public static void main(String[] args) {
	  Scanner sc =new Scanner(System.in);
 for(;;){
	 int w =sc.nextInt();
	 if(w==-1)System.exit(0);
	 int value=1150;
	for(int i=11; i<=w; i++){
		if(i<=20) value +=125;
		else if(i>30) value +=160;
		else value += 140;
	}
 System.out.println(4280-value);
 }
}
 }

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

using namespace std;

typedef long long LL;
#define N 12000

LL n,a[N],b[N];
map<LL,bool> vis;

LL gcd(LL x,LL y){return y==0?x:gcd(y,x%y);}

bool isp(LL x){
	if (x==1) return 0;
	for (LL i=2;i*i<=x;++i) if (x%i==0) return 0;
	return 1;
}

bool chk(LL p){
	for (LL i=0;i<=n;++i) b[i]=a[i]%p;
	for (LL i=n;i>=p;--i){
		(b[i-(p-1)]+=b[i])%=p;
		b[i]=0;
	}
	for (LL i=0;i<=n;++i) if (b[i]) return 0;
	return 1;
}

int main(){
	scanf("%lld",&n);
	LL d=0;
	for (LL i=0;i<=n;++i){scanf("%lld",a+n-i); d=gcd(d,a[i]);}
	d=abs(d);
	for (LL i=2;i*i<=d;++i){
		if (d%i==0){
			vis[i]=1;
			while (d%i==0) d/=i;
		}
	}
	if (d>1) vis[d]=1;
	for (LL i=1;i<=n+1;++i)
		if (isp(i)&&chk(i)) vis[i]=1;
	for (auto i:vis) printf("%lld\n",i.first);
	
	return 0;
}
			

Measured memory_bytes: 384
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;
 
public class Program{
  public static void Main(){
	string[] input1 = Console.ReadLine().Split(' ');
    string[] input2 = Console.ReadLine().Split(' ');
    int K = int.Parse(input1[0]);
    int N = int.Parse(input1[1]);
	
    List<int> list = new List<int>();
    for (int i = 0; i<N ; i++){
      list.Add(int.Parse(input2[i]));
    }
    
    list.Sort();
    
    int max = list[0] + (K - list[N-1]); 
    for (int j = 0; j < N-1; j++){
      int temp = list[j + 1] - list[j];
      if (temp > max){
        max = temp;
      }
    }
    
    Console.WriteLine(K - max);
  }
}

Measured memory_bytes: 34652
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<map>
#include<utility>
#include<tuple>
#include<algorithm>
#include<cmath>
using namespace std;

#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;

const int mod=1e9+7;

int main(){
  int h, w, k;
  cin >> h >> w >> k;
  vector<vector<ll>> dp(h+1, vector<ll>(w));
  dp[0][0]=1;
  rep(i,h){
    rep(j,w){
      rep(l,1<<w-1){
        int next=0;
        bool connect=false;
        rep(m,w-1){
          if(l>>m&1){
            if(connect){
              next=2;
              break;
            }
            else{
              connect = true;
              if(w-1-m == j+1)
                next=1;
              else if(w-1-m == j)
                next=-1;
            }
          }else
            connect = false;
        }
        if(next!=2){
          dp[i+1][j+next] += dp[i][j];
          dp[i+1][j+next] %= mod;
        }
      }
    }
  }
  cout << dp[h][k-1] << endl;
  return 0;
}

Measured memory_bytes: 256
from sys import stdin, exit
N = int(stdin.readline().rstrip())
A = [int(stdin.readline().rstrip()) for _ in range(N)]
tmp_sum = 0
ans = 0
idx = 0
for i, a in enumerate(A):
    if a == 0:
        ans += (tmp_sum // 2)
        idx = i
        tmp_sum = 0
    else:
        tmp_sum += a
        if i == N-1:
            ans += (tmp_sum // 2)
print(ans)

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

using namespace std;

int main() {
    int a, b, c, d, e, f;
    cin >> a >> b >> c >> d >> e >> f;

    int ans = a + b + c + d - min({a, b, c, d}) + max(e, f);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3072
#include <bits/stdc++.h>
using namespace std;
 
int main() {

int a,b,c,d;
cin >> a>>b>>c>>d;
 while(a>=0){ c=c-b;
    if(c<=0){cout<<"Yes"<<endl;break;}
    a=a-d;
      if(a<=0){cout<<"No"<<endl;break;}
            }
}

Measured memory_bytes: 3632
import java.math.BigInteger;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.PriorityQueue;
import java.util.Scanner;

import javax.xml.crypto.Data;
public class Main{
	static int INF = 2 << 28;
	static int[] vxL = {0,0,1,-1};
	static int[] vxR = {0,0,-1,1};
	static int[] vyL = {1,-1,0,0};
	static int[] vyR = {1,-1,0,0};
	static int w;
	static int h;
	static int Lx;
	static int Ly;
	static int Rx;
	static int Ry;
	static char[][] mapL;
	static char[][] mapR;
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true) {
			int n = sc.nextInt();
			int m = sc.nextInt();
			if(n == 0 && m == 0) break;
			ArrayList<String> type    = new ArrayList<String>();
			ArrayList<String> a1 = new ArrayList<String>();
			ArrayList<String> a2 = new ArrayList<String>();
			for(int i = 0; i < n; i++) {
				String a = sc.next();
				String b = sc.next();
				String c = sc.next();
				type.add(a);
				a1.add(b.replaceAll("\\?", "."));
				a2.add(c.replaceAll("\\?", "."));
			}
			ArrayList<String> list = new ArrayList<String>();
			for(int i = 0; i < m; i++) {
				String a = sc.next();
				String b = sc.next();
				String c = sc.next();
				boolean bad = true;
				for(int j = type.size()-1; j >= 0; j--) {
					if(a.matches(a1.get(j)) && b.matches(a2.get(j))) {
						if(type.get(j).equals("deny")) {
							bad = true;
							break;
						}
						else {
							bad = false;
							break;
						}
					}
				}
				if(!bad)
				list.add((a + " " + b + " " + c));
			}
			System.out.println(list.size());
			for(int i = 0; i < list.size(); i++) {
				System.out.println(list.get(i));
			}
		}
	}
}

Measured memory_bytes: 209828
#include <stdio.h>
#include <ctype.h>
#define MAX 1202
 
int main(void){
    int i;
    char c[MAX];
 
    fgets(c, MAX, stdin);
 
    for(i = 0; c[i] != '\0'; i++){
        if(isalpha(c[i])){
            if(isupper(c[i])){
                printf("%c", tolower(c[i]));
            }
            else if(islower(c[i])){
                printf("%c", toupper(c[i]));
            }
        }
        else{
            printf("%c", c[i]);
        }
    }
    return 0;
}

Measured memory_bytes: 524
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll mod = 1000000007;
//const ll mod = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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 (a>b) { a=b; return 1; } return 0; }



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

  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];

  int left = 0, right = n;
  while (right - left > 1) {
    int mid = (left + right) / 2;
    map<int, int> mp;
    bool f = true;
    rep(i, n - 1) {
      if (a[i] >= a[i + 1]) {
        int res = a[i + 1];
        while (mp.size() && mp.rbegin()->first > res) {
          mp.erase(mp.rbegin()->first);
        }
        if (mp[res] == 0 && mid == 1) {
          f = false;
          break;
        }
        ++mp[res];
        while (mp[res] == mid) {
          mp[res] = 0;
          --res;
          if (res == 0) {
            f = false;
            break;
          }
          ++mp[res];
        }
      }
      if (!f) break;
    }
    if (f) right = mid;
    else left = mid;
  }
  cout << right << '\n';

  




  
  return 0;
}


Measured memory_bytes: 3972
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] arr = new int[n + 1];
        int[] ans = new int[n + 1];
        int total = 0;
        for (int i = 1; i <= n; i++) {
            arr[i] = sc.nextInt();
        }
        ArrayList<Integer> list = new ArrayList<>();
        for (int i = n; i >= 1; i--) {
            int count = 0;
            for (int j = 2; j * i <= n; j++) {
                count += ans[j * i];
            }
            if (count % 2 != arr[i]) {
                ans[i] = 1;
                list.add(i);
            }
        }
        System.out.println(list.size());
        if (list.size() == 0) {
            return;
        }
        StringBuilder sb = new StringBuilder();
        for (int i = list.size() - 1; i >= 0; i--) {
            if (i < list.size() - 1) {
                sb.append(" ");
            }
            sb.append(list.get(i));
        }
        System.out.println(sb);
        
    }
}

Measured memory_bytes: 61112
fun main(args: Array<String>){
    val (a, b, c, d) = readLine()!!.split(" ").map { it.toLong() }
    val divC = (b / c) - (a - 1) / c
    val divD = (b / d) - (a - 1) / d
    val gcd = gcd(c, d)
    val divCD = ((b / (c * d / gcd)) - (a - 1) / (c * d / gcd))
    val count = b - (a - 1)

    println(count - (divC + divD - divCD))
}

fun gcd(a: Long, b: Long): Long {
    if (a < b) return gcd(b, a)
    if (b == 0L) return a
    return gcd(b, a % b)
}

Measured memory_bytes: 37744
#include <bits/stdc++.h>
const int MAXN = 1000;
const int INF = 0x3f3f3f3f;
using namespace std;
inline int read() {
  int x = 0, w = 1;
  char c = ' ';
  while (c < '0' || c > '9') {
    c = getchar();
    if (c == '-') w = -1;
  }
  while (c >= '0' && c <= '9') {
    x = (x << 1) + (x << 3) + (c ^ 48);
    c = getchar();
  }
  return x * w;
}
int n, m, ga[MAXN + 5][MAXN + 5], belong[MAXN + 5], vis[MAXN + 5], sum[2];
bool f;
void dfs(int u, int col) {
  if (f) return;
  belong[u] = col;
  vis[u] = true;
  ++sum[col];
  for (int i = 1; i <= n; ++i) {
    if (i != u && !ga[u][i]) {
      int v = i;
      if (!vis[v]) {
        dfs(v, col ^ 1);
      } else if (col == belong[v]) {
        f = true;
        return;
      }
    }
  }
}
void init() {
  n = read();
  m = read();
 
  for (int i = 1; i <= m; ++i) {
    int u = read(), v = read();
    ga[u][v] = true;
    ga[v][u] = true;
  }
}
bitset<705>S;
int main() {
  init();
  S[0] = 1;
  for (int i = 1; i <= n; ++i) {
    if (!vis[i]) {
      memset(sum, 0, sizeof(sum));
      dfs(i, 0);
      S = (S << sum[0]) | (S << sum[1]);
    }
  }
  if (f) {
    puts("-1");
    return 0;
  }
  int ans = INF;
  for (int i = 0; i < n; ++i) if (S[i]) ans = min(ans, i * (i - 1) / 2 + (n - i) * (n - i - 1) / 2);
  cout<<ans;
  return 0;
}

Measured memory_bytes: 3072
#include <bits/stdc++.h>
#define p(s) cout<<(s)<<endl
#define REP(i,n,N) for(int i=n;i<N;i++)
#define RREP(i,n,N) for(int i=N-1;i>=n;i--)
#define CK(n,a,b) ((a)<=(n)&&(n)<(b))
#define F first
#define S second
typedef long long ll;
using namespace std;
const int inf = 1e9;

int D[55],N;
string s;
int s1,s2;
int main() {
    cin>>N;
    REP(i,0,N){
        cin>>D[i];
    }
    D[N]=0;
    sort(D,D+N+1);

    REP(i,0,N+1){
        if(i%2){
            D[i]=(24-D[i])%24;
        }
    }
    
    int mn=23;
    REP(i,0,N+1) REP(j,i+1,N+1){
        int d = abs(D[i]-D[j]);
        mn=min(mn,min(d,24-d));
    }
    p(mn);
	return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;
import static java.lang.System.out;

public class Main{
    static MyReader in = new MyReader();

    public static void main(String[] args){
        int x = in.i();
        int N = in.i();
        int[] p = in.ii(N);

        boolean[] b = new boolean[102];
        for (int i = 0; i < N; i++) {
            b[p[i]] = true;
        }

        int i = -1;
        while (b[x]) {
            x += i;
            i = i > 0 ? -i - 1 : -i + 1;
        }
        out.println(x);
    }

    static class MyReader extends BufferedReader {
        char[] cbuf = new char[1024];
        int head = 0;
        int tail = 0;

        MyReader() {
            super(new InputStreamReader(System.in));
        }

        char next() {
            if (head == tail) {
                try {
                    tail = read(cbuf, 0, cbuf.length);
                } catch (IOException e) {}
                head = 0;
            }
            return cbuf[head++];
        }

        void back() {
            head--;
        }

        boolean minus() {
            boolean minus;
            while (true) {
                char c = next();
                if (c != ' ' && c != '\n' && c != '\r') {
                    if (!(minus = c == '-')) back();
                    return minus;
                }
            }
        }

        void skip() {
            while (true) {
                char c = next();
                if (c != ' ' && c != '\n' && c != '\r') {
                    back();
                    break;
                }
            }
        }

        char[] s(final int N) {
            skip();
            char[] s = new char[N];
            for (int i = 0; i < s.length; i++) {
                s[i] = next();
            }
            return s;
        }

        int i() {
            boolean minus = minus();
            int n = 0;
            while (true) {
                int k = next() - '0';
                if (k < 0 || 9 < k) break;
                n = 10 * n + k;
            }
            return minus ? -n : n;
        }

        int[] ii(final int N) {
            int[] a = new int[N];
            for (int j = 0; j < a.length; j++) a[j] = i();
            return a;
        }

        long l() {
            boolean minus = minus();
            long n = 0;
            while (true) {
                int k = next() - '0';
                if (k < 0 || 9 < k) break;
                n = 10 * n + k;
            }
            return minus ? -n : n;
        }
    }
}


Measured memory_bytes: 32812
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQG = priority_queue<T, vector<T>, greater<T> >;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) {return a < b && (a = b, true);}
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) {return a > b && (a = b, true);}
template<typename T1, typename T2>
istream &operator>>(istream &is, pair<T1, T2> &p) { return is >> p.first >> p.second;}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) { return os << p.first << ' ' << p.second;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vi a(4);
    rep(i, n) {
        string s;
        cin >> s;
        if(s[0] == 'A') a[0]++;
        if(s[0] == 'W') a[1]++;
        if(s[0] == 'T') a[2]++;
        if(s[0] == 'R') a[3]++;
    }
    cout << "AC x " << a[0] << endl;
    cout << "WA x " << a[1] << endl;
    cout << "TLE x " << a[2] << endl;
    cout << "RE x " << a[3] << endl; 
}

Measured memory_bytes: 3644
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>
using namespace std;

int main() {
	int n, k;
	double prob = 0;

	cin >> n >> k;

	int count = 0;
	double temp = (double)1 / n;

	int ub = n;
	int lb = k;
	while (true) {
		count = 0;
		if (ub <= n) {
			for (int i = ub; i >= lb; i--) {
				count++;
			}
		}
		else if (lb <= n) {
			for (int i = n; i >= lb; i--) {
				count++;
			}
		}
		prob += temp * count;

		ub = lb - 1;
		if (lb % 2 == 0) {
			lb = lb / 2;
		}
		else {
			lb = lb / 2 + 1;
		}
		temp /= 2;
		if (ub == 0) {
			break;
		}
	}

	cout << fixed << setprecision(12) << prob << endl;

}

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

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

using namespace std;

int main() {
  int64_t n, a, b;
  std::cin >> n >> a >> b;

  int64_t dab = b - a;

  if (b - a < 0) {
    std::cout << 0 << std::endl;
  } else if (n == 1) {
    std::cout << (a == b ? 1 : 0) << std::endl;
  } else {
    std::cout << ((n - 1) * b + a) - ((n - 1) * a + b) + 1 << std::endl;
  }
  return 0;
}


Measured memory_bytes: 3620