akhauriyash/Code-Regression huggingface dataset:
a, b, c, d, e, f = map(int, input().split())

water = [False] * (f//100 + 1)
for i in range(0, len(water), a):
    water[i] = True
for i in range(len(water) - b):
    if water[i]:
        water[i + b] = True

sugar = [False] * ((f//100) * e + 1)
for i in range(0, len(sugar), c):
    sugar[i] = True
for i in range(len(sugar) - d):
    if sugar[i]:
        sugar[i + d] = True

# denominator: 分母, numerator: 分子
deno = a * 100
nume = 0

for i in range(1, len(water)):
    if water[i]:
        j = min([i*e, f - 100*i])
        while not sugar[j]:
            j -= 1
        i = 100 * i + j

        if nume * i < deno * j:
            deno = i
            nume = j

print(deno, nume)

Measured memory_bytes: 63544
#include <iostream>
#include <vector>
#include <map>
#include <cmath>
using namespace std;



int main(void){
    int a, b;
    cin >> a >> b;
    int n=1, i=0;
    while(n<b) {
        n += (a-1);
        i++;
    }
    cout <<i << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 25, M = 1e6 + 25, oo = 1e9+7, mxmsk = 1 << 16;
const long long OO = 1e18+25;
#define par pair<pair<int,int>, int>
#define f first
#define s second
    
int n,a[N], mx, m;

int main()
{
    
        scanf("%d",&n);
        for(int i=0; i<n; i++)scanf("%d",a+i);
        for(int i=1; i<n; i++)
        {
            if(a[i] <= a[i-1]) m++;
            else m = 0;
            mx = max(m, mx);
        }
        printf("%d",mx);
    return 0;
}

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

int main() {
    int N;
    cin >> N;
    vector<long> A(N);
    rep(i,N) cin >> A.at(i);
    long total = 0;
    long ans;
    rep(i,N) {
        if (i == 0) {
            total += abs(A.at(0));
        } else if (i == N - 1) {
            total += abs(A.at(i) - A.at(i - 1)) + abs(A.at(i));
        } else {
            total += abs(A.at(i) - A.at(i - 1));
        }
    }
    rep(i,N) {
        if (i == 0) {
            ans = total - (abs(A.at(0)) + abs(A.at(1) - A.at(0))) + abs(A.at(1));
        } else if (i == N - 1) {
            ans = total - (abs(A.at(i) - A.at(i - 1)) + abs(A.at(i))) + abs(A.at(i - 1));
        } else {
            ans = total - (abs(A.at(i + 1) - A.at(i)) + abs(A.at(i) - A.at(i - 1))) + abs(A.at(i + 1) - A.at(i - 1));
        }
        cout << ans << endl;
    }
}


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

using namespace std;

// when range [l, r), has property notP~P, want first P.
// when return r, means not found.
template <typename T>
T bs_first(T l, T r, function<bool (T)> f) {
    assert(l < r);
    T mid;
    while (l != r) {
        mid = l + (r-l)/2;
        if (f(mid)) {
            r = mid;
        }else {
            l = mid + 1;
        }
    }
    return r;
}

int dp[64][11][2];
using ll=long long;
void solve() {
    int K; cin >> K;
    auto ck = [&](ll x){
        vector<int> d;
        while (x > 0) {
            d.push_back(x%10);
            x/=10;
        }
        memset(dp, 0, sizeof dp);
        d.push_back(0);
        reverse(d.begin(), d.end());
        int n = d.size();
        dp[0][10][0] = 1;
        for (int i = 0; i < n; i++) {
            int z = d[i];
            for (int j = 0; j <= 10; j++) {
                for (int k:{0,1}) {
                    if (j == 10) {
                        for (int jj = 1; jj < 10; jj++) if(k || jj<=z){
                            dp[i+1][jj][k||jj<z] += dp[i][j][k];
                        }
                        dp[i+1][10][k||0<z] += dp[i][j][k];
                    } else {
                        for (int jj:{j-1,j,j+1})if(0<=jj && jj<10){
                            if (k || jj <= z) {
                                dp[i+1][jj][k||jj<z] += dp[i][j][k];
                            }
                        }
                    }
                }
            }
        }
        int res = 0;
        for (int j = 0; j < 10; j++) {
            res += dp[n][j][0] + dp[n][j][1];
        }
        return res >= K;
    };
    ll res = bs_first<ll>(1, 1e15, ck);
    cout << res;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Scanner;
import java.util.*;

// 1 2 3 2 3 3
// 3 3 3 1 2 2

public class Main {
	static int vert=100005;
static boolean visited[];
static int dp[];
static ArrayList<Integer>[] adj;
public static void visit(int src) {
	visited[src]=true;
	dp[src]=0;
	for(int i=0;i<adj[src].size();i++) {
		if(!visited[adj[src].get(i)]) {
			visit(adj[src].get(i));
		}
		dp[src]=Math.max(dp[src], 1+dp[adj[src].get(i)]);
	}
	
}

	public static void main (String[] args) {
		visited=new boolean[vert];
		dp=new int[vert];
		adj=new ArrayList[vert];
		
	FastScanner sc=new FastScanner();
	int n=sc.nextInt(),m=sc.nextInt();

	for(int i=1;i<=n;i++) adj[i]=new ArrayList<Integer>();
	
	for(int i=0;i<m;i++) {
		int x=sc.nextInt(),y=sc.nextInt();
		//System.out.println(x+" "+y);
		adj[x].add(y);
	}

	int ans=0;
	for(int i=1;i<=n;i++) {
		if(!visited[i]) {
			visit(i);
		}
	}
	for(int i=1;i<=n;i++)
	ans=Math.max(dp[i], ans);
	
	System.out.println(ans);
	
		    	
		    }

	static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		String next() {
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}
		
		int nextInt() {
			return Integer.parseInt(next());
		}
		int[] readArray(int n) {
			int[] a=new int[n];
			for (int i=0; i<n; i++) a[i]=nextInt();
			return a;
		}
		long nextLong() {
			return Long.parseLong(next());
		}
}

		    
		}

Measured memory_bytes: 70648
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto N = readln.chomp.to!int;
    auto AS = readln.split.to!(long[]);

    long b;
    foreach (i, a; AS) {
        if (i%2 == 0) {
            b += a;
        } else {
            b -= a;
        }
    }
    long[] r = [b];
    auto c = b;
    foreach (a; AS[0..$-1]) {
        c = (a-c/2)*2;
        r ~= c;
    }
    writeln(r.map!(i => i.to!string).join(" "));
}

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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<pdd> vdd;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mem(a,b) memset(a, b, sizeof(a) )
#define all(x) (x).begin(),(x).end()
#define INF 1000000000000
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

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

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

int main(){
	int n;cin>>n;
	map<string,int>s,t;
	vector<string>S(n);
	rep(i,n){
		cin>>S[i];
		s[S[i]]++;
	}
	int m;cin>>m;
    vector<string>T(m);
	rep(i,m){
		cin>>T[i];
		t[T[i]]++;
	}
	sort(all(S));
	S.erase(unique(all(S)),S.end());
	int ans=0;
	rep(i,s.size()){
		ans=max(ans,s[S[i]]-t[S[i]]);
	}
    if(ans<0)ans=0;
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define debug cerr << __LINE__ << endl
using namespace std;
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vi> vvi;

int n, k, a[114514];
int main(void){
	cin >> n >> k;
	int idx;
	for(int i=0;i<n;i++){
		cin >> a[i];
		if (a[i]==1) idx = i;
	}
	cout << ((n-1) + (k-1) - 1) /(k-1) << endl;
	return 0;

}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <cmath>

using namespace std;

int main(){
    int A,B;
    cin >> A >> B;

    // n * 10/100 = A
    // 10n = 100A
    // n = 10A
    //
    for(int i = 10*B ; i <= 12 * A + A * 3 ;i ++){
        
        //cout  << "DEBUG : " << floor(i * 0.08) << " " << floor(i * 0.1) << endl;

        if(floor(i * 0.08) == A && floor(i * 0.1) == B){
            cout << i << endl;
            exit(0);
        }
        
    }
    cout << "-1" << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

        int[] nums = new int[n];

        for (int i=0; i<n; ++i) {
            nums[i] = sc.nextInt();
        }
        for (int i=n-1; i>0; --i) {
            System.out.print(nums[i] + " ");
        }
        System.out.println(nums[0]);
        sc.close();
    }
}


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

public class Main {

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

        final Solver solver = new Solver();
        solver.solve(N, R);
    }
}

class Solver {
    public void solve(long N, long R) {
        if (N < 10) {
            System.out.println(R + (100 * (10 - N)));
        }
        else {
            System.out.println(R);
        }
    }
}



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

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using WGraph = vector<vector<pair<int, ll>>>;

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

constexpr int dx[4] = {-1, 0, 0, 1}, dy[4] = {0, -1, 1, 0};
constexpr int INF = 1e9;
constexpr int MOD = 1e9 + 7;
constexpr long long LINF = 1e18;
constexpr double EPS = 1e-10;
constexpr double PI = M_PI;

void solve() {
    int n, c, k;
    cin >> n >> c >> k;
    vector<int> t(n);
    for (int i=0; i<n; ++i) {
        cin >> t.at(i);
    }

    sort(t.begin(), t.end());
    int res = 0;
    for (int i=0; i<n; ++i) {
        int tmp = 0;
        while (tmp < c && i+tmp < n && t.at(i+tmp) <= t.at(i)+k) ++tmp;
        i += tmp-1;
        ++res;
    }
    cout << res << '\n';
}

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

    solve();

    return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<queue>
#include<string>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>

#define REP(i,n) for(int i=0;i<(n);i++)
#define EPS (1e-7)
#define INF (3e9)

using namespace std;
typedef long long int ll;

int N;
int main(void){
    cin >> N;
    if( N % 2 == 0) cout << 0.5 << endl;
    else cout << float(1 + N / 2) / N << endl;

    return 0;
}



Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
char s[100];
int main() 
{
	scanf("%s",s+1);
	int n=strlen(s+1);
	for(int i=1;i<=n-8;i++)
	{
		cout<<s[i];
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<algorithm>
#include<stdint.h>
#include<vector>
#include<deque>
#include<stack>
#include<functional>
#include<string>
#include<cstring>
#include<array>
#include<iomanip>
#include<list>
#include<set>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<bitset>
#include <queue>
#include<boost/multiprecision/cpp_int.hpp>


using namespace std;
using namespace boost::multiprecision;

using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using ldb = long double;

#define REP(i,a,b) for(ll i = a; i < b; ++i)
#define PRI(s) cout << s << endl
#define PRIF(v, n) printf("%."#n"f\n", (double)v)
#define PRIY PRI("Yes")
#define PRIN PRI("No")
template<typename A, typename B>
void mins(A& a, const B& b) { a = min(a, (A)b); };
template<typename A, typename B>
void maxs(A& a, const B& b) { a = max(a, (A)b); };




int main() {
	ll N; cin >> N;
	vector<ll> A(N); REP(i, 0, N)cin >> A[i];
	sort(A.begin(), A.end(), greater<ll>());
	vector<ll> B(N - 1);
	ll ans = 0;
	REP(i, 0, N - 1)B[i] = (A[i] - A[i+1]) / (1 + N);
	REP(i, 0, N) {
		ll sum = 0;
		REP(j, 0, i) sum += (j+1)*B[j];
		REP(j, i, N-1) sum -= (N + 1 - (j + 1)) * B[j];
		A[i] += sum;
	}
		REP(i, 0, N - 1) ans += (i + 1) * B[i];
	ll tmp = A[N - 1] - (N - 1);
	if (tmp > 0) {
		ans += tmp * N;
		REP(i, 0, N) A[i] -= tmp;
	}
	while (true) {
		ll maxind = 0;
		REP(i, 0, N) if (A[maxind] < A[i]) maxind = i;
		if (A[maxind] < N) break;

		A[maxind] -= N;
		REP(i, 0, N) if (i != maxind) ++A[i];

		++ans;
	}
	PRI(ans);
	return 0;
}

Measured memory_bytes: 3568
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<complex>

#define f first
#define s second
#define mp make_pair

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define ALL(c) (c).begin(), (c).end()
#define EPS (1e-10)
using namespace std;

typedef unsigned int uint;
typedef long long ll;
typedef complex<double> P;

int main(){
  int cnt[101] = {0};
  int x;
  while(cin>>x) cnt[x]++;
  int m = -1;
  REP(i,101) m = max(m, cnt[i]);
  REP(i,101) if(m == cnt[i]) cout << i << endl;
  return 0;
}

Measured memory_bytes: 0
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

const ll inf = (ll)1e9;
const ll mod = (ll)1e9 + 7;

int main()
{
	string s;

	ll sum = 0;
	while (cin >> s)
	{
		ll add = 0;
		for (int i = 0; i < s.length(); i++)
		{
			char c = s.at(i);
			if ('0' <= c && c <= '9')
			{
				add = add * 10 + (c - '0');
			}
			else
			{
				sum += add;
				add = 0;
			}
		}

		sum += add;
	}


	cout << sum << endl;
}


Measured memory_bytes: 3188
import java.util.Scanner;

class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int m = sc.nextInt();
        int f = sc.nextInt();
        int b = sc.nextInt();

        if(m < b && m + f >= b){
            System.out.println(b - m);
        }else if (m >= b) {
            System.out.println(0);
        }else if (m < b && m + f < b) {
            System.out.println("NA");
        }
        // System.out.println();
    }
}


Measured memory_bytes: 26304
n = int(input())
a = list(map(int, input().split()))

ans = 1

flag = 0

for i in range(n-1):
    if flag == 1:
        if a[i+1]>=a[i]:
            continue
        else:
            ans += 1
            flag = 0
    elif flag == -1:
        if a[i+1]<=a[i]:
            continue
        else:
            ans += 1
            flag = 0
    else:
        if a[i+1]>a[i]:
            flag = 1
        elif a[i+1]<a[i]:
            flag = -1

print(ans)

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

#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define pll         pair<long,long>
#define vi          vector<int>
#define vll         vector<ll>
#define vii         vector<pii>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define f         first
#define s           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define mod        1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define rem(i,a,b)  for(int i=a;i>b;i--)
#define mp(a,b)     make_pair(a,b)



void solve(){
    string s,t;
    cin>>s>>t;
    cout<<t<<s;

}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    long t=1;
    //cin>>t;
    while(t--){

        solve();
    }
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include<vector>
#include<iomanip>
#include<map>
#include <queue>
#include<cmath>
#include<cstdio>
#include<iomanip>
#include<set>
#include <bits/stdc++.h>
 
using namespace std;
using ll = long long int;
 
#define REP(i,n) for(ll i=0;i<(ll)(n);i++) //REP(i, 5) cout<<i;
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define MOD 1000000007 //10^9+7
//#define MOD 1
 
ll gcd(ll a, ll b) {
  ll tmp;
  if ( b > a) {
    tmp = a;
    a = b;
    b = tmp;
  }
  while (a % b !=0) {
    tmp = b;
    b = a % b;
    a = tmp;
  }
  return b;
}
 
const int MAX = 1000;
 
ll table[MAX][MAX];
 
// テーブルを作る前処理
void COMinit() {
    table[0][0] = table[0][1] = 1;
    FOR(i, 1, MAX-1){
      FOR(j, 0, i+1){
        if(j==0) table[i][j] = 1;
        else if(j == i+1) table[i][j] = 1;
        else table[i][j] = table[i-1][j-1]+table[i-1][j];
      }
    }
}
 
// 二項係数計算
ll COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return table[n-1][k];
}

void sosuu(ll n, vector<ll> &v){

  vector<ll> num(n, 0);

  FOR(i, 1, sqrt(n)){
    if(num[i]==0){
      FOR(j, 0, n/i){
        num[i+(j*i)] = 1;
      }
    }
  }
  REP(i, n){
    if(num[i]==0) v.push_back(i+1);
  }
}


int main(void){

  ll n;
  cin>>n;
  if(n%10==3){
    cout<<"bon"<<endl;
    return 0;
  }else if(n%10==0 || n%10==1 || n%10==6 || n%10==8){
    cout<<"pon"<<endl;
  }else{
    cout<<"hon"<<endl;
  }
  return 0;
}

Measured memory_bytes: 3624
from sys import stdin
def main():
    #入力
    readline=stdin.readline
    n=int(readline())
    li=[0]*4
    for i in range(n):
        tmp=readline().strip()
        if tmp=="AC":
            li[0]+=1
        elif tmp=="WA":
            li[1]+=1
        elif tmp=="TLE":
            li[2]+=1
        elif tmp=="RE":
            li[3]+=1
    
    for i in range(4):
        if i==0:
            print("AC x {}".format(li[0]))
        elif i==1:
            print("WA x {}".format(li[1]))
        elif i==2:
            print("TLE x {}".format(li[2]))
        elif i==3:
            print("RE x {}".format(li[3]))

if __name__=="__main__":
    main()

Measured memory_bytes: 9244
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <iomanip>
#include <map>
#include <bitset>
#include <cstdio>
//#include <bits/stdc++.h>
#define rep(i,n) Rep(i,0,n)
#define Rep(i,k,n) for(int i=k ; i<n ; i++)
#define rep1(i,n) for(int i=1 ; i<=n ; i++)
#define vi vector<int>
#define vii vector<int,int>
#define Sort(v) sort(v.begin(),v.end())
#define Reverse(v) reverse(v.begin(),v.end())

//const int MOD = 1000000007;
//const int INF = 1<<30;
using namespace std;

string yn(bool x){
    return x ? "Yes" : "No";
}
int main(){
    string s; cin >> s;
    
    int x = 0;
    
    rep(i,3){
        if(s[i] == 'a') x += 1<<0;
        if(s[i] == 'b') x += 1<<1;
        if(s[i] == 'c') x += 1<<2;
    }
    
    cout << yn(x == 7) << endl;
}






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

long long gcd(int x, int y)
{
	if (y == 0) return x;
	return gcd(y, x%y);
}
long long lcm(int x, int y)
{
	return x * y / gcd(x, y);
}
signed main(void)
{
	int n;
	cin >> n;
	cout << (long long)lcm(2, n) << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using PLL = pair<ll, ll>;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repn(i,n) for(int i = 0; i <= (int)(n); i++)
#define srep(i,l,n) for(int i = l; i < (int)(n); i++)
#define srepn(i,l,n) for(int i = l; i <= (int)(n); i++)
#define drep(i,n) for(int i = (int)(n-1); i >= 0; i--)
#define drepn(i,n) for(int i = (int)(n); i >= 0; i--)
#define size(s) (int)s.size()
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
template<typename T> inline istream& operator>>(istream &i, vector<T> &v) {rep(j, size(v)) i >> v[j]; return i;}
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; }
template<class T> T gcd(T a, T b) {if(b==0)return a; else return gcd(b,a%b);}
template<class T> T lcm(T a, T b) {return a/gcd(a,b)*b;}
template<class T = int> using V = vector<T>;
template<class T = int> using VV = vector<V<T>>;
bool isIn(int i, int j, int h, int w) {return i >= 0 && i < h && j >= 0 && j < w;}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void err() {cout << -1 << endl;}
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define ep emplace_back

const int MOD = 1000000007;
const int INF = 1e9;

#define PI acos(-1);
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    V<> l(n);
    for(int i = 0; i < n; i++) cin >> l[i];
    int ans = 0;
    for(int i = 0; i < n; i++) {
        for(int j = i + 1; j < n; j++) {
            for(int k = j + 1; k < n; k++) {
                if(l[i] != l[j] && l[j] != l[k] && l[i] != l[k] && abs(l[i] - l[j]) < l[k] && l[k] < l[i] + l[j]) ans++;
            }
        }
    }
    cout << ans << endl;
}

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

int main() {
    int n;
    cin >> n;
    float ans;
    for (int i=0; i<n; i++) {
        float x;
        string u;
        cin >> x >> u;
        if (u=="JPY") {
            ans += x;
        } else {
            ans += x*380000.0;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;

class Main {
    public static void main(String[] args) {
        new Solver().run();
    }
}

class Solver {

    private long calc(long H, Map<Long, Long> map) {
        if (map.containsKey(H)) {
            return map.get(H);
        }

        long nr = calc(H/2, map) + calc(H/2, map) + 1;
        map.put(H, nr);

        return nr;
    }

    public void run() {
        Scanner sc = new Scanner(System.in);
        long H = sc.nextLong();

        Map<Long, Long> map = new HashMap<Long, Long>();
        map.put(0L, 0L);
        map.put(1L, 1L);

        long ret = calc(H, map);
        System.out.println(ret);

        return;
    }

}

Measured memory_bytes: 21972
#include <cmath>
#include <cstdio>
#include <algorithm>
using namespace std;

typedef long long ll;

int n;
int a[200010];
ll s1, s2;
ll ans;

int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; ++i) {
		scanf("%d", &a[i]);
		s2 += a[i];
	}
	ans = s2;
	for (int i = 1; i < n; ++i) {
		s1 += a[i]; s2 -= a[i];
		ans = min(ans, abs(s1 - s2));
	}
	printf("%lld\n", ans);
	return 0;
}

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

int main(){
  vector<pair<string, int> > p;
  int N;
  cin >> N;
  for(int i=0; i<N; i++){
    string s;
    int t;
    cin >> s >> t;
    p.push_back(make_pair(s,t));
  }
  string S;
  cin >> S;
  int idx;
  for(idx=0; idx<N; idx++){
    if(p[idx].first==S) break;
  }
  int ans =0;
  for(int i=idx+1; i<N; i++){
    ans += p[i].second;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main ()
{
    int l,r,d;
    scanf("%d %d %d",&l,&r,&d);
    int m,h;
    if(l%d==0)
        m=l/d-1;
    else
        m=l/d;
    h=r/d;
    printf("%d\n",h-m);
	return 0;
}


Measured memory_bytes: 3820
#include<bits/stdc++.h>
using namespace std;
char s[2333];int len,ans;
int main()
{
	scanf("%s",s+1);len=strlen(s+1);
	ans=s[1]-'0'+(len-1)*9;
	for(int i=2;i<=len;++i)
	{
		if(s[i]!='9')
		{
			--ans;
			break;
		}
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#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<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
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()
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy
 
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);    
	
	ll N; cin >> N;
	ll ans = N - 1;
	FOR(i, 1, 1000010) {
		if (N % i == 0) {
			ans = min(ans, i + N / i - 2);
		}
	}
	
	cout << ans << endl;
	
	return 0;
}
 
// read the question correctly (ll vs int)
// template by bqi343


Measured memory_bytes: 256
/* One original thought is worth a thousand mindless quotings */

#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<unordered_map>
#include<algorithm>
#include<bitset>
#include<queue>
#include <math.h>
#define ll long long
#define ld long double
#define ull unsigned long long
#define boost ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);cout.precision(10);cout << fixed;
#define dbset(x) for(int i=0 ; i<x.size(); i++) cerr << x[i] << " "; cerr << endl;
#define inf 1000000007
#define INF 1000000000000000000LL
#define PI 3.14159265358979323846
#define mod 1000000007
#define mod1 1000696969
#define flusz fflush(stdout);
#define VI vector<int>
#define VPI vector < pair<int,int> >
#define PII pair<int, int>
#define BIT bitset<N>
#define st first
#define nd second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define endl '\n'
#define REP(x, y) for(int x = 0; x < (y); ++x)
#define FOR(x, y, z) for(int x = y; x <= (z); ++x)
#define FORR(x, y, z) for(int x = y; x >= (z); --x)
using namespace std;

template<class TH> void _dbg(const char *sdbg, TH h){cerr<<sdbg<<"="<<h<<"\n";}
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;cerr<<"="<<h<<","; _dbg(sdbg+1, a...);
}
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)

#define int long long
const int N = 1000*1000 + 7;

int test;

int n,k;

void solve()
{
	cin >> n >> k;



	cout << 1 + (n-k)/(k-1) + ((n-k)%(k-1) != 0);

    return;
}

int32_t main()
{
    boost

    test=1;

	for(int i=1; i <= test; i++){
        solve();
	}

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long gcd(long long m, long long n) {
  if (m < n) {
	  return gcd(n, m);
	} if (n == 0LL) {
	  return m;
	}
  return gcd(n, m % n);
}

int main() {
  long long a, b;
  cin >> a >> b;
  cout << a * b / gcd(a, b) << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>

using namespace std;

long long int t[200006]={},k[200006];
int main(){
	queue<long long int>que;
	string str;
	cin>>str;
	if(str.substr(0,4)=="YAKI"&&str.length()>=4){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
}


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

int main(){
    int x,y;
    cin >> x >> y;
    if(y<2*x || y>4*x || y%2)
    cout << "No" << endl;
    else
        cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 3632
#include <iostream>

using namespace std;

int main() {
  int a, b, c, k;
  cin >> a >> b >> c >> k;
  for (int i = 0; i < k; i++){
    if(b >= c){
      c *= 2;
    }else if(a >= b){
      b *= 2;
    }
  }
  
  if (c>b && b>a) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

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

int main() {
  int n, alice, bob;
  cin >> n;
  
  vector<int> a(n);
  
  for (int i = 0; i < n; i++)
    cin >> a.at(i);
  
  sort(a.begin(), a.end());
  reverse(a.begin(), a.end());
  
  alice = 0, bob = 0;
  for (int i = 0; i < n; i++) {
    if (i % 2 == 0)
      alice += a.at(i);
    else
      bob += a.at(i);
  }
  cout << abs(alice - bob) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,a,n) for(int i=a;i<n;i++)
#define been(ix) (ix).begin(),(ix).end()
using namespace std;
typedef long long ll; 
typedef vector<int> vi;
typedef vector<long long> vl;
const ll INFL = 1e18;
const int INF = 1001001001; 
typedef pair<int,int> P;
#define foreach(ix,i) for(auto& (ix) : (i))
typedef long double ld;
const int mod =1000000007;
int main(){
    int n;cin>>n;
    int res[26];
    rep(i,26)res[i]=INF;
    rep(_,n){
        string s;
        cin>>s;
        int k =s.length();
        int sum[26];
        rep(i,26)sum[i]=0;
        rep(i,k){
            sum[s[i]-'a']++;
        }
        rep(i,26)res[i]=min(res[i],sum[i]);
        }
    string ans;
    for(char i ='a';i<='z';i++){
        rep(x,res[i-'a'])ans+=i;
    } 
    cout<<ans<<endl;
    }

Measured memory_bytes: 256
S = list(input())

A = []
for i in S:
    if i != 'A' and i != 'C':
        A.append(i)
A=''.join(A)

B= list(S[2:-1])
#print(B)

if S[0] == 'A':
    if B.count('C') == 1:
        if A.islower():
            print('AC')
        else:
            print('WA')
    else:
        print('WA')
else:
    print('WA')

Measured memory_bytes: 3060
n, a, b = map(int, input().split())

if(b < a):
    swap(a, b)

ans = -1
if a%2 == b%2:
    ans = (b - a) // 2

else:
    x = a + (b - a) // 2
    a = n - a + 1
    b = n - b + 1
    y = a + (b - a) // 2
    ans = min(x, y)

print(ans)


Measured memory_bytes: 9184
#include <bits/stdc++.h>
#define F(i,a,b) for(int i=(a);i<=(b);++i)
#define F_(i,a,b) for(int i=(a);i>=(b);--i)
#define G(i,u) for(int i=head[u];i;i=nxt[i])

template<typename T> inline T max(T& a, T b) { return a>b?a:a=b; }
template<typename T> inline T min(T& a, T b) { return a<b?a:a=b; }

const int N = 2005;

int a[N], b[N], c[N], ans;

int main() {
	ans = 0x7fffffff;
	int n, k, q;
	scanf("%d%d%d", &n, &k, &q);
	F(i,1,n) scanf("%d", &a[i]);
	F(i,1,n) {
		int x = a[i], tot = 0;
		F(j,1,n) {
			int st = j, siz = 0;
			if(a[st] < x) continue;
			b[siz++] = a[st];
			while(j<n && a[j+1]>=x) b[siz++] = a[++j];
			std::sort(b,b+siz);
			for(int l = 0; l <= siz-k; ++ l) c[tot++] = b[l];
		}
		std::sort(c,c+tot);
		if(q <= tot) ans = std::min(ans,c[q-1]-x);
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 256
n,k = map(int,input().split())
h = list(map(int,input().split()))
dp = [10000000000]*n
dp[0] = 0
for i in range(n-1):
    for j in range(1,min(k+1,n-i)):
        dp[i+j] = min(dp[i+j],dp[i]+abs(h[i+j]-h[i]))
print(dp[n-1])


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

int main() {
    int n, m; cin >> n >> m;
    map<pair<int, int>, int> mp;
    for (int i = 0; i < m; i++) {
        int a, b; cin >> a >> b;
        mp[{a, b}]++;
    }
    vector<long long> imos(n, m);
    for (auto &p: mp) {
        long long a = p.first.first, b = p.first.second, c = p.second;
        imos[0] += a * c;
        for (int i = b - a - 1; i < n; i += b) imos[i] -= b * c;
    }
    for (int i = 0; i + 1 < n; i++) imos[i + 1] += imos[i];
    for (auto x: imos) cout << x << endl;
    return 0;
}



Measured memory_bytes: 9668
#include <cstdio>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;

struct Point {
	int x; int y;
	Point(int p1, int p2) {
		x = p1; y = p2;
	}
};

int manhattan(Point a, Point b) {
	return (int)(abs((float)a.x - b.x) + abs((float)a.y - b.y));
}

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

	int temp1, temp2;

	vector<Point> students;
	for (int i = 0; i < N; ++i) {
		scanf("%d %d", &temp1, &temp2);
		students.emplace(students.end(), temp1, temp2);
	}

	vector<Point> checkpoints;
	for (int i = 0; i < M; ++i) {
		scanf("%d %d", &temp1, &temp2);
		checkpoints.emplace(checkpoints.end(), temp1, temp2);
	}

	for (int student = 0; student < N; ++student) {
		Point cLoc = students[student];
		int cClosestCP = 0;
		for (int potCP = 0; potCP < M; ++potCP) {
			if (manhattan(cLoc, checkpoints[potCP]) <
				manhattan(cLoc, checkpoints[cClosestCP])) {
				cClosestCP = potCP;
			}
		}
		printf("%d\n", cClosestCP + 1);
	}
	return 0;
}

Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
    	s: chars,
        t: chars,
        a: usize,
        b: usize,
        u: chars
    }
    let (aa, bb) = calc(s,t,a,b,u);
    println!("{} {}", aa, bb);
}

fn calc(s:Vec<char>, t:Vec<char>, a:usize, b:usize, u:Vec<char>) -> (usize, usize) {
	if u==s { (a-1, b) } else { (a, b-1) }
}

Measured memory_bytes: 4352
package main

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

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024*1024), bufio.MaxScanTokenSize)
}

func nextString() string {
	sc.Scan()
	return sc.Text()
}

//func nextInt() int {
//	sc.Scan()
//	i, e := strconv.Atoi(sc.Text())
//	if e != nil {
//		panic(e)
//	}
//	return i
//}

//func nextUint64() uint64 {
//	sc.Scan()
//	i, e := strconv.ParseUint(sc.Text(), 10, 64)
//	if e != nil {
//		panic(e)
//	}
//	return i
//}

func main() {
	n := nextString()
	list := strings.Split(n, "")
	sum := (uint64)(0)

	for _, c := range list {
		num, _ := strconv.Atoi(c)
		sum += uint64(num)
	}

	if sum % 9 == 0 {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 5552
#include<bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
using LL = long long;
const LL LINF = 1e18;
using namespace std;
#define COUT(v) cout<<(v)<<endl
#define CIN(n)  int(n);cin >> (n)
#define SCIN(n) string(n);cin >> (n)
#define YES(n) cout<<((n)? "YES" : "NO")<<endl
#define Yes(n) cout<<((n)? "Yes" : "No")<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) <<endl

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)

#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(obj) (obj).begin(),(obj).end()

#define P pair<int,int>
#define I vector<int>
#define S set<int>
#define pb(v) push_back(v)
#define V vector
#define rt return
#define rmsame(a) sort(ALL(a)),a.erase(unique(ALL(a)), a.end())

class Edge{
public:
    int from,to,value;
    Edge(int a,int b,int c){
        from = a;
        to = b;
        value = c;
    }
    Edge(int a,int b){
        from = a;
        to = b;
    }
};

int main(){
    CIN(N);CIN(C);
    V<V<int>> vec;
    REP(a,C){
        V<int> q;
        REP(b,C){
            CIN(w);
            q.pb(w);
        }
        vec.pb(q);
    }
    V<V<int>> mass;
    REP(a,N){
        V<int> q;
        REP(b,N){
            CIN(w);
            q.pb(w);
        }
        mass.pb(q);
    }
    V<int> calc1,calc2,calc3;
    REP(a,C){
        int e = 0;
        REP(x,N){
            REP(y,N){
                if((x+y+1+1)%3==0){
                    e += vec.at(mass.at(x).at(y)-1).at(a);
                }
            }
        }
        calc1.pb(e);
    }
    REP(a,C){
        int e = 0;
        REP(x,N){
            REP(y,N){
                if((x+y+1+1)%3==1){
                    e += vec.at(mass.at(x).at(y)-1).at(a);
                }
            }
        }
        calc2.pb(e);
    }
    REP(a,C){
        int e = 0;
        REP(x,N){
            REP(y,N){
                if((x+y+1+1)%3==2){
                    e += vec.at(mass.at(x).at(y)-1).at(a);
                }
            }
        }
        calc3.pb(e);
    }
    int ans = INF;
    REP(a,C){
        REP(b,C){
            REP(c,C){
                if(a==b||b==c||a==c)continue;
                ans = min(ans,calc1.at(a)+calc2.at(b)+calc3.at(c));
            }
        }
    }
    COUT(ans);
    return 0;
}


Measured memory_bytes: 1280
#define _USE_MATH_DEFINES

#include <iostream>
#include <cstdio>
#include <memory>
#include <string>
#include <cstdlib>
#include <set>
#include <utility>
#include <vector>
#include <list>
#include <algorithm>
#include <regex>
#include <cmath>
#include <map>
#include <iterator>
#include <climits>
#include <numeric>
#include <bitset>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <array>
#include <valarray>
#include <complex>
#include <random>
#include <functional>
#include <cassert>
#include <chrono>
#include <memory>

using namespace std;

#define int long long
//region TEMPLATE
////@formatter:off
#define double long double
typedef long long ll;
typedef unsigned long long ull;
template<typename T>void __read(T &a) { cin >> a; }
template<typename T, typename ... Args> void __read(T &a, Args &... args) { cin >> a;__read(args...);}
#define make(t, ...) t __VA_ARGS__; __read(__VA_ARGS__)
#define makev(a, n) VI a(n); FOR(n) cin >> a[i];
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define FORIT(p) for(auto it = p.begin(); it != p.end(); it++)
#define FOR(b) for(signed i = 0; i <(b); i++)
#define FORE(i, l, r) for(int i = (l); i < (r); i++)
#define NFOR(i, n) for(int i = (((int) n)-1); i >= 0; i--)
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
typedef pair<pair<int, int>, int> PPII;
constexpr ll M7 = 1000000007ll;
constexpr ll M9 = 1000000009ll;
constexpr ll MFFT = 998244353ll;
template<class T> void outv(T &a) { for (auto &x : a) cout << x << ' '; }
static mt19937 rnd(static_cast<unsigned>(chrono::steady_clock::now().time_since_epoch().count())); // NOLINT(cert-err58-cpp)
auto __fast_io__ = (ios_base::sync_with_stdio(false), cin.tie(nullptr)); // NOLINT(cert-err58-cpp,cppcoreguidelines-interfaces-global-init)
////@formatter:on
//endregion



int32_t main() {
    make(int, x, y, z);
    swap(x, y);
    swap(x, z);
    cout << x << ' ' << y << ' ' << z;

    return 0;
}

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

using namespace std;

const int N = 1e5;

vector < pair < int , int > > lst;
set < int > poss;

int cnt[N + 5];
int main(){
	poss.clear();
	int n,q;
	scanf("%d %d",&n,&q);
	for(int i=1; i<=q; i++){
		int u,v;
		scanf("%d %d",&u,&v);
		lst.push_back( make_pair( u,v ) );
	}
	for(int i=1; i<=n; i++) cnt[i] = 1;
	int ans = 0;
	poss.insert(1);
	for(int i=0; i<q; i++){
		int u = lst[i].first;
		int v = lst[i].second;
		cnt[u]--;
		cnt[v]++;
		if(poss.find(u) != poss.end()){
			if(cnt[u] == 0){
				poss.erase(u);
//				printf("pop %d\n",u);
			}
			poss.insert(v);
//			printf("insert %d\n",v);
		}
	}
	printf("%d\n",(int)poss.size());
	return 0;
}

Measured memory_bytes: 6132
from bisect import bisect_left, bisect_right
a, b, q = map(int, input().split())
inf = 10**18
shrine = [-inf] + [int(input()) for _ in range(a)] + [inf]
temple = [-inf] + [int(input()) for _ in range(b)] + [inf]

for _ in range(q):
    ans = inf
    x = int(input())
    index_s = bisect_left(shrine, x)
    index_t = bisect_right(temple, x)
    
    for s in [shrine[index_s-1], shrine[index_s]]:
        for t in [temple[index_t-1], temple[index_t]]:
            ans = min(
                ans,
                abs(x-s) + abs(s-t),
                abs(x-t) + abs(s-t)
            )

    print(ans)

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

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

int main(){
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    string s; cin>>s;
    deque<char> dq;
    rep(i,s.size()) dq.push_back(s[i]);
    int q,cnt; cin>>q;
    rep(i,q){
        int t; cin>>t;
        if(t==1) cnt++;
        else{
            int f; cin>>f;
            char c; cin>>c;
            if((f+cnt)%2) dq.push_front(c);
            else dq.push_back(c);
        }
    }
    if(cnt%2) rep(i,dq.size()) cout<<dq[dq.size()-i-1];
    else rep(i,dq.size()) cout<<dq[i];
    cout<<endl;
}

Measured memory_bytes: 976
//Ruthless Coding 
#include <bits/stdc++.h>

#define uni(x)      (x).resize(unique(ALL(x)) - (x).begin())
#define fprint(v)   for(auto x : v) cout << x << ' '
#define ALL(x)      (x).begin(), (x).end()
#define MP(x, y)    make_pair(x, y)
#define SZ(x)       int((x).size())
#define PB(x)       push_back(x)
#define ll          long long
#define S           second 
#define F           first
#define nl          '\n'

using namespace std;
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
mt19937_64 rnd;

const int N = 2e5 + 5;

int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);
    int n;
    cin >> n;
    vector<int> a(n);
    for(auto &x : a){
        cin >> x;
    }
    vector<int> t = a;
    sort(ALL(t));
    int mid = n / 2 - 1;
    debug(t, mid);
    for(auto &x : a){
        int pos = lower_bound(ALL(t), x) - t.begin();
        if(pos <= mid){
            cout << t[mid + 1] << nl;
        }else{
            cout << t[mid] << nl;
        }
    }
    return 0;
}
/*
    *** Most Impo.. -> check base case always
    1. Overflow Check (*, +)
    2. Index check (0 - based or 1 - based)
    3. Check for n = 1, 2, 3, 4....
    4. Corner Cases
*/

Measured memory_bytes: 3824
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int x,y;
    cin>>x>>y;
    if(x==y)
        cout<<"Draw"<<endl;
    else if(x==1||(x>y&&y!=1))
        cout<<"Alice"<<endl;
    else
        cout<<"Bob"<<endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<queue>
#include<vector>
#include<functional>
#include<cmath>
#include<map>
#include<stack>
#include<set>
#include<numeric>
#include<limits>
#include<iomanip>
#include<iterator>

#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define rep(i,n) for(int i=0; i<n; i++)
#define FOR(i,a,n) for(int i=a; i<n; i++)

using namespace std;
typedef long long ll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ll, char> plc;

int main()
{
	string S,T,S_tmp,ans;
	cin >> S >> T;
	S_tmp = S;

	rep(i, S.size()) {
		if (S[i] == '?' || S[i] == T[0]) {
			int s_idx = i;
			bool f = true;
			rep(j,T.size()) {
				if (S[s_idx] == '?' || S[s_idx] == T[j]) {
					S[s_idx] = T[j];
					s_idx++;
				}
				else {
					f = false;
					break;
				}
			}
			if (f) {
				rep(k, S.size()) {
					if (S[k] == '?')S[k] = 'a';
				}
				if (ans == "")ans = S;
				else if (ans > S)ans = S;
			}
		}
		S = S_tmp;
	}
	if(ans.size()!=0)cout << ans << endl;
	else cout << "UNRESTORABLE" << endl;
	return 0;
}


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

using namespace std;

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

inline int toInt(string s) {int v; istringstream sin(s);sin>>v; return v;}

typedef long long ll;

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++) cin >> a[i];

    ll res = 0;
    int right  = 0;
    int sum = 0;

    for(int left = 0; left < n; left++){
        while(right < n && (sum ^ a[right]) == (sum + a[right]) ){
            sum += a[right];
            right++;
        }

        res += right - left;

        if(left == right) right++;
        else sum -= a[left];
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 1024