akhauriyash/Code-Regression huggingface dataset:
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Spandan Mishra
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CMultiplication3 solver = new CMultiplication3();
        solver.solve(1, in, out);
        out.close();
    }

    static class CMultiplication3 {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            long a = in.readLong();
            double d = Double.parseDouble(in.readString());

            long b = (long) Math.round(d * 100);

            long ans = a * b;

            System.out.println(ans / 100);


        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1)
                throw new RuntimeException();
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new RuntimeException();
                }
                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public String readString() {
            final StringBuilder stringBuilder = new StringBuilder();
            int c = read();
            while (isSpaceChar(c))
                c = read();
            do {
                stringBuilder.append((char) c);
                c = read();
            } while (!isSpaceChar(c));
            return stringBuilder.toString();
        }

        public long readLong() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            long res = 0;
            do {
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

    }
}



Measured memory_bytes: 32776
import java.io.*;
import java.util.Arrays;
import java.util.Scanner;

class Main{
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] line = (br.readLine()).split(" ");
		int a = Integer.parseInt(line[0]);
		int b = Integer.parseInt(line[1]);
		int x,y;
		if (a>b) {
			x = a;
			y = b;
		}else{
			x = b;
			y = a;
		}
		int work;
		while(x%y != 0) {
			work = y;
			y = x%y;
			x = work;
		}
		System.out.println(y);
	}
}

Measured memory_bytes: 24440
INT_MAX=10**11+7
MOD=10**9+7
def INPUT():return list(int(i) for i in input().split())
def LIST_1D_ARRAY(n):return [0 for _ in range(n)]
def LIST_2D_ARRAY(m,n):return [[0 for _ in range(n)]for _ in range(m)]
GETA=12
#import sys,os,multiprocessing
#print(3)
###############################################################################\
n=int(input())
A=INPUT()
D=[0]*(10**5+1)
for ele in A:
    D[ele]+=1
s=0
for i in range(10**5+1):
    s+=D[i]*i
for i in range(int(input())):
    b,c=INPUT()
    if D[b]!=0:
        if D[c]!=0:
            s+=(c-b)*(D[b])
            D[c]+=D[b]
            D[b]=0
        else:
            D[c]=D[b]
            s+=(c-b)*D[c]
            D[b]=0
    print(s)


Measured memory_bytes: 85600
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        
        int count = 0;
        for (int i = a; i <= b; i++) {
            if (i / 10000 == i % 10) {
                if ((i / 1000) % 10 == (i / 10) % 10) {
                    count++;
                }
            }
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n,q;
    cin>>n;
    long long cur_sum=0;
    unordered_map<int,int> store;
    for(int i=0;i<n;i++)
    {
        int x;
        cin>>x;
        store[x]++;
        cur_sum+=x;
    }
    cin>>q;
    while(q--)
    {
        int b,c;
        cin>>b>>c;
        int occurences=store[b];
        if(occurences>0)
        {
            cur_sum-=(occurences*(1ll)*b);
            cur_sum+=(occurences*(1ll)*c);
            store[b]=0;
            store[c]+=occurences;
        }
        cout<<cur_sum<<endl;
    }
    
    return 0;
}

Measured memory_bytes: 7036
//Radhe Radhe
#include<bits/stdc++.h>
#define godspeed  ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0);

#define ll long long
#define ld long double
#define fi first
#define se second
#define mp make_pair
#define rep1(i,a,b)    for(ll i=a; i<=b; i++)
#define repVect(i,n)    for(ll i=0; i<sum.size(); i++)
#define fixed cout.setf(ios::fixed);
#define Precise cout.precision(7);
#define yes cout<<"Yes"<<'\n'
#define no cout<<"No"<<'\n'
using namespace std;

int main()
{
    godspeed
    ll  i,j,k,l,n,digiS=0;
    string s;
    cin>>n;
    ll cpn=n;
    while(n>0)
    {
        digiS+=n%10;
        n/=10;
    }
    if(cpn%digiS==0)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    return 0;
}





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

using namespace std;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

typedef long long ll;
#define endl '\n'


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


const int MOD = 1000000007;





int main() {

    cin.tie(0);
    ios::sync_with_stdio(false);

    int n;
    ll squares[100005];

    cin >> n;

    for(int i = 0; i < n; i++) {

        cin >> squares[i];
    }

    int ans = 0;
    int max_ans = 0;

    for(int i = 0; i < n-1; i++) {

        if(squares[i] >= squares[i+1]) {

            ans++;
            max_ans = max(max_ans, ans);
        }
        else {

            ans = 0;
        }
    }

    cout << max_ans << endl;

}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;

/* short */
#define pb push_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)

/* REPmacro */
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define FORR(i, a, b) for(int i = (a); i >= (b); i--)
#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOREACH(x, a) for(auto x : a)

/* exchange */
#define CHMIN(a, b) (a) = min((ll)(a), (ll)(b))
#define CHMAX(a, b) (a) = max((ll)(a), (ll)(b))

/* function */
#define IN(x) cin >> x
#define DEBUG(x) cerr << (x) << " "
#define LN() cerr << "\n"
#define PRINT(x) cout << (x) << endl
#define BR cout << endl

/* const */
const int ARRAY = 100005;
const int INF = 1001001001; // 10^9
const ll LINF = 1001001001001001001; // 10^18
const int MOD = 1e9 + 7;

ll N = 0;
ll K = 0;
ll t;
ll ret = 0;
string s;

void input() {
  IN(s);
}

void solve() {
  REP(i, s.length()) {
    cout << 'x';
  }
  cout << endl;
}

int main(void){
  input();
  solve();
}


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

int main(){
    int V, E;
    cin >> V >> E;
    vector<pair<int, int> > edge(E);
    for (int i = 0; i < E; i++) {
        cin >> edge[i].first >> edge[i].second;
    }
    vector<int> ans;
    vector<int> state(V, 0);

    for (int i = 0; i < E; i++) {
        state[edge[i].second]++;
    }
    for (int i = 0; i < state.size(); i++) {
        if (state[i] == 0) ans.push_back(i);
    }
    for (int i = 0; i < ans.size(); i++) {
        for (int j = 0; j < edge.size(); j++) {
            if (edge[j].first != ans[i]) continue;
            state[edge[j].second]--;
            if (state[edge[j].second] == 0) {
                ans.push_back(edge[j].second);
            }
            edge[j] = edge.back();
            edge.pop_back();
            j--;
        }
    }
    for (int i = 0; i < ans.size(); i++) {
        cout << ans[i] << endl;
    }

    return 0;
}



Measured memory_bytes: 3484
#include <stdio.h>
#include <math.h>
#include <algorithm>

using namespace std;

int main(){
	double a[10],v1,v2,sum_length,distance;

	while(scanf("%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf",
			&a[0],&a[1],&a[2],&a[3],&a[4],&a[5],&a[6],&a[7],&a[8],&a[9],&v1,&v2) != EOF){
		sum_length = 0;
		for(int i=0; i < 10; i++){
			sum_length += a[i];
		}
		distance = v1*((sum_length)/(v1+v2));

		if(distance == 0){
			printf("1\n");
		}else{
			sum_length = 0;
			for(int i=0;i<10;i++){
				sum_length += a[i];
				if(distance <= sum_length){
					printf("%d\n",i+1);
					break;
				}
			}
		}
	}

    return 0;
}

Measured memory_bytes: 2580
Sa=[]
Sb=[]
Sc=[]
Sa=list(str(raw_input()))
Sb=list(str(raw_input()))
Sc=list(str(raw_input()))
state="a"
while True:
    if state=="a":
        if (len(Sa) == 0):
            break
        else:
            state=Sa.pop(0)

    elif state=="b":
        if (len(Sb) == 0):
            break
        else:
            state=Sb.pop(0)
    elif state=="c":
        if (len(Sc) == 0):
            break
        else:
            state=Sc.pop(0)
print(state.upper())


Measured memory_bytes: 2568
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,i,sum=0;
    cin>>n;
    string s;
    cin>>s;
    for(i=0;i+1<n;i++)
    {
        if(s[i]!=s[i+1])
        {
            sum++;
        }
    }
    cout<<sum+1;
}


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

using namespace std;

typedef long long int ll;
#define inf 0x3f3f3f3f
#define endl '\n'
// #define case(i) "Case #" << i << ": "

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

    int n;
    cin >> n;
    
    int a[n][3];
    for(int i = 0; i < n; ++i) {
        for(int j = 0; j < 3; ++j) {
            cin >> a[i][j];
        }
    }

    int dp[n][3];
    memset(dp, 0, sizeof(dp));

    for(int i = 0; i < n; ++i) {
        for(int j = 0; j < 3; ++j) {
            if(i == 0) dp[i][j] = a[i][j];
            else {
                if(j == 0) {
                    dp[i][j] = a[i][j] + max(dp[i-1][1], dp[i-1][2]);
                }
                else if(j == 1) {
                    dp[i][j] = a[i][j] + max(dp[i-1][0], dp[i-1][2]);
                }
                else {
                    dp[i][j] = a[i][j] + max(dp[i-1][0], dp[i-1][1]);
                }
            }
        }
    }
    cout << max(dp[n-1][0], max(dp[n-1][1], dp[n-1][2])) << endl;
}

Measured memory_bytes: 2560
#include<iostream>
#include<vector>
#include<stdio.h>
using namespace std;

typedef unsigned long long int lli;

char s[1000001];
int cnt[1000001];

void subs(int l,int r){


    int qt = 0;
    cnt[0] = 0;

    for(int i = l+1;i<r;i++){
        cnt[i] = cnt[i-1];
        if(s[i-1] == 'A' && s[i] == 'C'){
            cnt[i]++;
        }
    }

}

int main(){

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    /*cout<<std::fixed;
    cout<<std::setprecision(3);*/

    int n,q,l,r;


    scanf("%d %d",&n,&q);

    scanf("%s",s);
    subs(0,n);



    while(q--!=0){

        scanf("%d %d",&l,&r);
        printf("%d\n",cnt[r-1]-cnt[l-1]);
    }

    return 0;
}


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

int main(void){
    char s[16];
    scanf("%s", s);
    int k = strlen(s);
    int count = 0;
    for (int i = 0; i < k; i++){
        if (s[i] == 'x'){
            count += 1;
        }
    }
    printf("%s\n", (count > 7) ? "NO" : "YES");
    return 0; 
}


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

const int MAXN = 1e5 + 5;

int n;
long long D[MAXN], M[MAXN];

int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> D[i];
		if (i % 2 == 0)
			M[0] += D[i];
		else
			M[0] -= D[i];
	}
	for (int i = 1; i < n; i++) {
		M[i] = 2 * D[i - 1] - M[i - 1];
	}
	for (int i = 0; i < n; i++) {
		cout << M[i] << " \n"[i == n - 1];
	}
	return 0;
}


Measured memory_bytes: 2816
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <tuple>
#include <queue>
using namespace std;
using ll=long long;
//using R=double;

const int INF = 10000000;
typedef pair<int, int> p;


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

    sort(A,A+3);

    cout << (A[1]-A[0])+(A[2]-A[1]) << endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ld long double
#define ll long long int
#define pb push_back
#define ins insert
#define ff first
#define ss second
#define Ln 20
#define mp make_pair
#define INF (ll)1e9+5
#define dif 0.0000000001
#define pp pair<ll,ll> 
#define sp set<pp>
#define vv vector< pair<ll ,ll> > 
#define vi vector<ll> 
#define SZ 100005
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;

//vi adj[100005];

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

int main() {
    fastio;
    ll n,i,cnt,x,y;
    ll a[SZ];
    
    cin>>n;
    
    cnt=x=0;
    for(i=0;i<n;i++)
    {
        cin>>a[i];
        if(a[i]%4==0)
            cnt++;
        else if(a[i]%2==0)
            x++;    
            
    }
    
    y=n;
    
    if(x>=y)
        cout<<"Yes";
    else 
    {
        if(x>0)
        {
        y-=x;
        
        if(y%2)
            y=y/2+1;
        else
            y/=2;
        
        
        if(cnt>=y)
            cout<<"Yes";
        else
            cout<<"No";
        }
        
        else
        {
            if(cnt>=(n/2))
                cout<<"Yes";
            else
                cout<<"No";
            
        }
    }
    
  
    
	return 0;
}

Measured memory_bytes: 1024
//Love and Freedom.
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
#define ll long long
#define inf 20021225
#define N 500010
#define mdn 998244353
using namespace std;
int read()
{
	int s=0,t=1; char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')	t=-1; ch=getchar();}
	while(ch>='0' && ch<='9')	s=s*10+ch-'0',ch=getchar();
	return s*t;
}
int ksm(int bs,int mi)
{
	int ans=1;
	while(mi)
	{
		if(mi&1)	ans=1ll*ans*bs%mdn;
		bs=1ll*bs*bs%mdn; mi>>=1; 
	}
	return ans;
}
int fac[N],inv[N],n,k;
int C(int n,int m){return n<m?0:1ll*fac[n]*inv[m]%mdn*inv[n-m]%mdn;}
void upd(int &x,int y){x+=x+y>=mdn?y-mdn:y;}
int main()
{
	n=read(),k=read(); fac[0]=1;
	for(int i=1;i<=k;i++)	fac[i]=1ll*fac[i-1]*i%mdn;
	inv[k]=ksm(fac[k],mdn-2); int ans=0;
	for(int i=k;~i;i--)	inv[i-1]=1ll*inv[i]*i%mdn;
	for(int i=n;i<=k;i++)	upd(ans,C(k-1,i-1));
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 4096
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
typedef long long ll;
#define MOD 1000000007
using namespace std;
template <typename Mnd> struct segment_tree {
    int sz;
    vector<Mnd> data;
    function<Mnd(Mnd, Mnd)> f;
    Mnd e;
    //サイズだけ指定して初期化
    segment_tree(int _sz, function<Mnd(Mnd, Mnd)> _f, Mnd _e) : f(_f), e(_e) {
        sz = 1;
        while(sz < _sz)
            sz <<= 1;
        data.assign(sz * 2, e);
    }
    //参照渡しなので代入とかもできる
    Mnd &operator[](const int &k) { return data[k + sz]; }
    //木を構築 O(n)
    void build() {
        for(int i = sz - 1; i > 0; i--)
            data[i] = f(data[2 * i], data[2 * i + 1]);
    }
    //更新しつつ木を再構築 O(log n)
    void update(int k, Mnd x) {
        data[k += sz] = x;
        while(k >>= 1)
            data[k] = f(data[2 * k], data[2 * k + 1]);
    }
    //[a,b)でのクエリに答える　O(log n)
    Mnd query(int a, int b) const {
        Mnd l = e, r = e;
        for(a += sz, b += sz; a < b; a >>= 1, b >>= 1) {
            if(a & 1)
                l = f(l, data[a++]);
            if(b & 1)
                r = f(r, data[--b]);
        }
        return f(l, r);
    }
};
int main() {
    int n, q;
    string s;
    cin >> n >> s >> q;
    vector<segment_tree<int>> seg(
        26, segment_tree<int>(n, [](int a, int b) { return a + b; }, 0));
    for(int i = 0; i < n; i++) {
        seg[s[i] - 'a'].update(i, 1);
    }
    while(q--) {
        int ord;
        cin >> ord;
        if(ord == 1) {
            int ind;
            char c;
            cin >> ind >> c;
            ind--;
            seg[s[ind] - 'a'].update(ind, 0);
            s[ind] = c;
            seg[s[ind] - 'a'].update(ind, 1);
        }
        if(ord == 2) {
            int l, r;
            cin >> l >> r;
            l--;
            int ans = 0;
            for(int i = 0; i < 26; i++) {
                ans += min(1, seg[i].query(l, r));
            }
            cout << ans << endl;
        }
    }
}

Measured memory_bytes: 111620
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>

using namespace std;

vector<int> G[100000];
bool vis[100000];
int qtype[100000], vertex[100000], marked[100000];

int par[100000], pp[100000];

void init()
{
	for (int i = 0; i < 100000; i++) par[i] = i;
}

int find(int x)
{
	if (par[x] == x) return (x);
	return (par[x] = find(par[x]));
}

void merge(int x, int y)
{
	x = find(x); y = find(y);
	if (x != y){
		par[y] = x;
	}
}

void dfs(int v, int p, int m)
{
	int nm = m;
	if (marked[v]) nm = v;
	pp[v] = p;
	
	merge(nm, v);
	
	for (int i = 0; i < G[v].size(); i++){
		dfs(G[v][i], v, nm);
	}
}

int main()
{
	int N, Q;
	
	while (scanf("%d %d", &N, &Q) && N){
		for (int i = 0; i < N; i++) G[i].clear();
		
		for (int i = 1; i < N; i++){
			int v;
			scanf("%d", &v);
			G[--v].push_back(i);
		}
		
		init();
		
		memset(marked, 0, sizeof(marked));
		marked[0]++;
		for (int i = 0; i < Q; i++){
			char t[10];
			scanf("%s %d", t, vertex + i);
			qtype[i] = (t[0] == 'Q');
			--vertex[i];
			if (!qtype[i]) ++marked[vertex[i]];
		}
		
		dfs(0, -1, -1);
		
		long long int ans = 0;
		for (int i = Q - 1; i >= 0; i--){
			if (qtype[i]){
				ans += find(vertex[i]) + 1;
			}
			else {
				--marked[vertex[i]];
				if (!marked[vertex[i]]) merge(pp[vertex[i]], vertex[i]);
			}
		}
		
		printf("%lld\n", ans);
	}
	
	return (0);
}

Measured memory_bytes: 13736
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
using namespace __gnu_pbds; 
#define gc getchar_unlocked
#define fo(i,n) for(int i=0;i<n;i++)
#define Fo(i,k,n) for(int i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long int
#define s(x)	cin>>x
#define p(x)	cout<<x<<"\n"
#define goog(x, y)  cout<<"Case #"<<x<<": "<<y<<"\n"
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
#define INF 100000000000
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pl;
typedef vector<int>		vi;
typedef vector<ll>		vl;
typedef vector<pii>		vpi;
typedef vector<pl>		vpl;
typedef vector<vi>		vvi;
typedef vector<vl>		vvl;
typedef long double ld;

mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
int rng(int lim) {
	uniform_int_distribution<int> uid(0,lim-1);
	return uid(rang);
}
int mpow(int base, int exp); 
void ipgraph(int n, int m);
void dfs(int u, int par);
int gcd(int a, int b) ;

const int mod = 1'000'000'007;
const int N = 3e5, M = N;
//=======================

vi g[N];
int a[N];





void solve() {
  int n;cin>>n;
  int a[n];
  fo(i,n) cin>>a[i];
  int res=0;
  set<int>prims;
  int k=0;
  for(;k<n;++k)
  { int tp=a[k];
    bool stat=0;
    for(int p=2;p*p<=tp;++p)
    {   if(tp%p==0)
        {   if(prims.count(p))
            {stat=1;break;}
            else
            {   prims.insert(p);
                while(tp%p==0)
                tp/=p;
            }
        }
    }
    if(tp>1)
    {   if(prims.count(tp))
        stat=1;
        prims.insert(tp);
    }
    
    if(stat) break;
  }
  if(k==n) res=2;
  if(res!=2)
  { int gval=a[0];
    fo(i,n)
    {   gval=gcd(gval,a[i]);}
    if(gval==1) res=1;
  }
  if(res==2)
  p("pairwise coprime");
  else if(res==1)
  p("setwise coprime");
  else
  p("not coprime");

}

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    srand(chrono::high_resolution_clock::now().time_since_epoch().count());

    int t = 1;
    //cin >> t;
    while(t--) {
      solve();
    }

    return 0;
}

int mpow(int base, int exp) {
  base %= mod;
  int result = 1;
  while (exp > 0) {
    if (exp & 1) result = ((ll)result * base) % mod;
    base = ((ll)base * base) % mod;
    exp >>= 1;
  }
  return result;
}

void ipgraph(int n, int m){
	int i, u, v;
	while(m--){
		cin>>u>>v;
    //u--, v--;
		g[u].pb(v);
		g[v].pb(u);
	}
}

void dfs(int u, int par){
	for(int v:g[u]){
		if (v == par) continue;
		dfs(v, u);
	}
}

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

Measured memory_bytes: 14628
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define pb push_back
#define eb emplace_back
template<class T>void chmax(T &a,T b){if(a<b)a=b;}
template<class T>void chmin(T &a,T b){if(a>b)a=b;}
constexpr int INF=1000000000000000000;
constexpr int mod=998244353;
constexpr double eps=1e-8;
const double pi=acos(-1);
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int Random(int mi,int ma){
    random_device rnd;
    mt19937 mt(rnd());//32bit
    //[mi,ma]
    uniform_int_distribution<int>engine(mi,ma);
    return engine(mt);
}
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
int modpow(int a,int b){
    if(b==0)return 1;
    if(b%2)return modpow(a,b-1)*a%mod;
    int memo=modpow(a,b/2);
    return memo*memo%mod;
}
vector<int>kaijo,invkaijo;
void init_fact(int n){
    kaijo.resize(n+1);
    invkaijo.resize(n+1);
    kaijo[0]=1;
    for(int i=1;i<=n;i++){
        kaijo[i]=kaijo[i-1]*i;
        kaijo[i]%=mod;
    }
    rep(i,n+1)invkaijo[i]=modpow(kaijo[i],mod-2);
}
int comb(int a,int b){
    if(a<b)return 0;
    if(a<0||b<0)return 0;
    return kaijo[a]*modpow(kaijo[a-b],mod-2)%mod*modpow(kaijo[b],mod-2)%mod;
}
int inv(int x){
    x=modpow(x,mod-2);
    return x;
}
struct UnionFind{
    vector<int>par,siz;
    UnionFind(int n){
        par.resize(n);
        siz.resize(n);
        rep(i,n){
            par[i]=i;
            siz[i]=1;
        }
    }
    int find(int x){
        if(par[x]==x)return x;
        return par[x]=find(par[x]);
    }
    void unite(int x,int y){
        x=find(x),y=find(y);
        if(x==y)return;
        if(siz[x]<siz[y])swap(x,y);
        par[y]=x;
        siz[x]+=siz[y];
    }
    bool same(int x,int y){
        return find(x)==find(y);
    }
};
signed main(){
    cin.tie(0);ios::sync_with_stdio(false);
    int n,q;
    cin>>n>>q;
    UnionFind uf(n);
    rep(i,q){
        int t,u,v;
        cin>>t>>u>>v;
        if(t==0){
            if(!uf.same(u,v))uf.unite(u,v);
        }
        else{
            cout<<uf.same(u,v)<<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 6348
import sys

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def main():
    X = input().strip()


    scount = 0
    ans = 0
    for s in X:
        if s == "S":
            scount += 1
        elif s == "T":
            if scount == 0:
                continue
            else:
                scount -= 1
                ans += 2

    print(len(X) - ans)



if __name__ == '__main__':
    main()


Measured memory_bytes: 3500
#include <stdio.h>

int main(void)
{
    double a,b,c,d,e,f;
    double c2,f2,b2,e2;
    double x,y;

    while(scanf("%lf %lf %lf %lf %lf %lf", &a, &b, &c, &d, &e, &f) != EOF){
        c2 = c * d;
        f2 = f * a;
        b2 = b * d;
        e2 = e * a;
        y = (c2 - f2) / (b2 - e2);
        x = (c - (b * y)) / a;

        printf("%.3lf %.3lf\n", x, y);
    }
    return (0);
}



Measured memory_bytes: 2036
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i,n) for (ll i=0; i<(n); ++i)
#define rep1(i,n) for (ll i=1; i<=(n); ++i)
typedef long long ll;
bool debug=false;
string yes = "Yes";
string no = "No";
const ll mod = 998244353;
const double e = 0.000000001;
int main(){
  ll n; cin >> n;
  if(n==1){
    printf("Hello World");
    return 0;
  }
  ll a,b; cin >> a >> b;
  cout << a+b;
  return 0;
}

Measured memory_bytes: 3628
#include <stdio.h>

int main(int argc, char const *argv[]) {
   int D,N;
  scanf("%d %d",&D,&N );

  if(D==0){
    if(N<100) printf("%d",N );
    else if(N==100) printf("%d",N+1 );
  }

  else if(D==1){
    if(N<100) printf("%d",N*100 );
    else if(N==100) printf("%d",N*100+100 );
    return 0;
  }

  else if(D==2){
    if(N<100) printf("%d",N*10000 );
    else if(N==100) printf("%d",N*10000+10000 );
    return 0;
  }

  return 0;
}


Measured memory_bytes: 128
N,M,K = map(int,input().split())
Fri = [list(map(int,input().split())) for _ in range(M)]
Blo = [list(map(int,input().split())) for _ in range(K)]

#union-find
par = [i for i in range(N+1)]
relation = [1 for _ in range(N+1)] #自身を含む同グループの数
rank = [0 for _ in range(N+1)]
def find(x):
    if par[x] == x:
        return x
    else:
        par[x] = find(par[x])
        return par[x]

def unite(x,y):
    x,y = find(x),find(y)
    if x != y:
        if rank[x] < rank[y]:
            par[x] = y
            relation[y] += relation[x]
        else:
            par[y] = x
            relation[x] += relation[y]
            if rank[x] == rank[y]:
                rank[x] += 1

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

ans = [relation[find(i)] for i in range(N+1)]
for m in range(M):
    unite(Fri[m][0],Fri[m][1])
    ans[Fri[m][0]] -= 1
    ans[Fri[m][1]] -= 1

for k in range(K):
    if same(Blo[k][0],Blo[k][1]):
        ans[Blo[k][0]] -= 1
        ans[Blo[k][1]] -= 1

for i in range(1,N+1):
    ans[i] += (relation[find(i)] - 2)
    if i != 1:
        print(" ",end="")
    print(ans[i],end="")


Measured memory_bytes: 59688
a,b,c = map(int, input().split())
x = 0
if a<=c:
  x += a
  c -= a
  a = 0
elif a>c:
  x += c
  c = 0
  a -= c
if c<=b:
  x += (c+b)
  c = 0
  b = 0
elif c>b:
  x += (2*b)
  b = 0
  c -= b
if c>0:
  x += 1
print(x)
  

Measured memory_bytes: 9120
# coding: utf-8

import sys
import math
import collections
import itertools
def input(): return sys.stdin.readline().strip()
def gcd(x, y): return y if x % y == 0 else gcd(y, x % y)
def lcm(x, y): return (x * y) // gcd(x, y)
MOD = 10 **9 + 7

# N = int(input())
# S = input()
N, Q = map(int, input().split())
# 横
# L = [int(x) for x in input().split()]
# 縦
# A = [int(input()) for _ in range(N)]
# 多次元
AB = [[int(x) for x in input().split()] for _ in range(N - 1)]
PX = [[int(x) for x in input().split()] for _ in range(Q)]

AB.sort(key=lambda x : x[1])
PX.sort(key=lambda x : x[0])

S = [0] * (N + 1)
ab = 0
px = 0

for i in range(1, N + 1) :
    while px < Q and PX[px][0] == i :
        S[i] += PX[px][1]
        px += 1

    while ab < (N - 1) and AB[ab][1] == i :
        S[i] += S[AB[ab][0]]
        ab += 1
    
    print(S[i], end=" ")

print()


Measured memory_bytes: 125020
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>

using namespace std;

void solve()
{
	string S;
	cin >> S;
	string nextS = "";
	if (S.size() % 2 == 0)
	{
		for (int i = 0; i < S.size() - 2; ++i)
		{
			nextS += S[i];
		}
	}
	else
	{
		for (int i = 0; i < S.size() - 1; ++i)
		{
			nextS += S[i];
		}
	}
	S = nextS;
	bool isOK = false;
	while(!isOK)
	{
		isOK = true;
		for (int j = 0; j < S.size() / 2; ++j)
		{
			if (S[j] != S[S.size() / 2 + j])
			{
				isOK = false;
				break;
			}
		}
		if (!isOK)
		{
			nextS = "";
			for (int i = 0; i < S.size() - 2; ++i)
			{
				nextS += S[i];
			}
			S = nextS;
		}
	}
	cout << S.size() << endl;
}

int main()
{
	solve();
	return(0);
}

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

#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, m, n) for(int i = (int)(m); i < (int)(n); ++i)


// 長さを長くするべきかどうか
bool check(int x, int c, vector<long long>& A, int N)
{
    if(N <= 2*c) return false;
    return abs(A[N-1-2*c]-x) <= abs(A[N-1-c]-x);
}

// 高橋くんがとる右側の数列の長さを二分探索
int searchLength(int x, vector<long long>& A, int N)
{
    int l = 0;
    int r =  N;
    while(r-l > 1){
        int c = (l+r)/2;
        if(check(x, c, A, N)) l = c;
        else r = c;
        //if(x == 10) cout << left << " " << right << endl;
    }
    return r;
}

int main()
{
    int N, Q;
    cin >> N >> Q;
    vector<long long> A(N), X(Q);
    REP(i, N) cin >> A[i];
    REP(i, Q) cin >> X[i];

    vector<long long> cumsum_A(A), alt_A(A);
    REP(i, N-1){
        cumsum_A[i+1] += cumsum_A[i];
        if(i < N-2) alt_A[i+2] += alt_A[i];
    }

    REP(i, Q){
        int length = searchLength(X[i], A, N);
        // cout << length << " ";
        long long ans = cumsum_A[N-1]-cumsum_A[N-1-length];
        if(N-1-2*length >= 0) ans += alt_A[N-1-2*length];
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 4864
from collections import defaultdict
mod = 998244353

## nCkのmodを求める関数
# テーブルを作る(前処理)
max = 3 * 10**5 + 100
fac, finv, inv = [0]*max, [0]*max, [0]*max

def comInit(max):
    fac[0] = fac[1] = 1
    finv[0] = finv[1] = 1
    inv[1] = 1

    for i in range(2,max):
      fac[i] = fac[i-1]* i% mod
      inv[i] = mod - inv[mod%i] * (mod // i) % mod
      finv[i] = finv[i-1] * inv[i] % mod

comInit(max)

# 二項係数の計算
def com(n,k):
    if(n < k):
        return 0
    if( (n<0) | (k < 0)):
        return 0
    return fac[n] * (finv[k] * finv[n-k] % mod) % mod

n,a,b,k = map(int,input().split())

red = defaultdict(int)
for i in range(n+1):
    red[i*a] = com(n,i)

ans = 0
for i in range(n+1):
    point = k - b*i
    if(point < 0):
        break
    ans += red[point] * com(n,i)
    ans %= mod

print(ans)

Measured memory_bytes: 166832
#include <iostream>
#include <vector>
#include <algorithm>
#include <array>
using namespace std;
using lli = long long int;


lli N, X;
vector<lli> A;
vector<lli> B;

inline lli sum(){
  lli tmp = 0;
  for(int i = 0; i < N; i++){
    tmp += B[i];
  }
  return tmp;
}

void solve(){
  lli ans = 10000000000000;
  for (lli i = 0; i < N; i++){
    for (lli j = 0; j < N; j++){
      if(i > j){
        if (B[j] > A[j + N - i]) B[j] = A[j + N - i];
      }
      else{
        if(B[j] > A[j - i]) B[j] = A[j - i];
      }
    }
    lli tmp = 0;
    tmp = sum() + i * X;
    if (ans > tmp) ans = tmp;
  }
  cout << ans << endl;
  return ;
}


int main(){
  cin >> N >> X;
  for(lli i = 0; i < N; i++){
    lli tmp;
    cin >> tmp;
    A.push_back(tmp);
    B.push_back(tmp);
  }
  solve();
  return 0;
}


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

int main() {
    int N; // あられ数
    int count = 0;
    string A = "PWGY";
    cin >> N;

    for (int i = 0; i < N; i++) {
        string S; // あられ種類
        cin >> S;

        for(int j = 0; j < (int)(A.length()); j++ ) {
            if (A[j] == *S.c_str()) {
                count++;
                A[j] = ' ';
                break;
            }
        }

        if (count == 4) {
            break;
        }
    }
    
    if (count == 3) {
        cout << "Three" << endl;
    }
    else if (count == 4){
        cout << "Four" << endl;
    }
}

Measured memory_bytes: 3576
/**
 *    Coded by : lucky_21
 *               --------Lokesh Singh
**/

#include<bits/stdc++.h>
using namespace std;

#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template<class T> using oset=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

#define     F           first
#define     S           second
#define     pb          push_back
#define     lb          lower_bound
#define     ub          upper_bound
#define     pii         pair<int,int>
#define     all(x)      x.begin(),x.end()
#define     fix         fixed<<setprecision(10)
#define     rep(i,a,b)  for(int i=int(a);i<=int(b);i++)
#define     repb(i,b,a) for(int i=int(b);i>=int(a);i--)
#define     FastIO      ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)

typedef double db;
typedef long long ll;

const int N=2e5+5;
const int mod=1e9+7;

signed main(){
    FastIO;
    char c;
    cin>>c;
    if(isupper(c)) cout<<"A";
    else cout<<'a';
    return 0;
}


Measured memory_bytes: 3644
import sys

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def main():
    S = input().strip()

    prev = S[0]
    c = ""
    cnt = 1
    for s in S[1:]:
        c += s
        if prev != c:
            cnt += 1
            prev = c
            c = ""

    print(cnt)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3500
using System;
using System.Collections.Generic;
using System.Text;

class TEST{
	static void Main(){
		while(true){
			var n=int.Parse(Console.ReadLine());
			if(n==0)break;
			
			int[] ARR=new int[n];
			for(int i=0;i<ARR.Length;i++)ARR[i]=0;
			
			for(int j=0;j<n;j++){
				String[] s=Console.ReadLine().Split(' ');
				int sum=0;
				for(int i=0;i<ARR.Length;i++){
					Console.Write("{0,5}",int.Parse(s[i]));
					ARR[i]+=int.Parse(s[i]);
					sum+=int.Parse(s[i]);
				}
				Console.WriteLine("{0,5}",sum);
			}
			int sum2=0;
			for(int i=0;i<ARR.Length;i++){
				Console.Write("{0,5}",ARR[i]);
				sum2+=ARR[i];
			}
			Console.WriteLine("{0,5}",sum2);
		}
	}
}

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

int main()
{
    string s;

    cin >> s;

    int cnt = 0;
    for( int i = 0; i < s.size() / 2; i++ )
    {
        if( s[i] == ' ' && s[s.size()-1-i] == ' ' )
            cnt += 2;
        else if( s[i] == s[s.size()-1-i] && ( s[i] == '(' || s[i] == ')' ) )
            cnt++;
        else if( s[i] == s[s.size()-1-i] );
        else if( s[i] == '(' && s[s.size()-1-i] == ')' || s[i] == ')' && s[s.size()-1-i] == '(' );
        else
            cnt++;
    }

    char c = s[s.size()/2];
    if( s.size() % 2 == 1 && ( c == '(' || c == ')' ) )
        cnt++;

    cout << cnt << endl;

    return 0;
}


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

using namespace std;

#define REP1(i,n) for(int i=1, i##_len=(n); i<i##_len; ++i)
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define pow(x) x*x
#define ll long long
static const ll MAX = 1000000;
static const ll INFTY = 1e12;

struct edge {
    ll to;
    char cost;
};

using Graph = vector<vector<int>>;
using _Graph = vector<vector<edge>>;
// 入力
int H, W;
vector<vector<char>> field;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

// 深さ優先探索
vector<bool> seen;
vector<int> colors;

int N;

int main(void){
    
    ll N;
    cin >> N;
    vector<ll> A(N);
    REP(i, N) {
        cin >> A[i];
        A[i]*= 2;
    }

    ll x = 0;
    REP(i, N){
        x = A[i] - x;
    }
    x /= 2;
    REP(i, N){
        cout << x << endl;
        x = A[i] - x;
    } 
}
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         pass System Test!
*/


Measured memory_bytes: 2048
#include <stdio.h>

int MAX(int,int);

int main()

{
  int kazu1,kazu2,kouyakusuu;

  scanf("%d%d",&kazu1,&kazu2);

  kouyakusuu = MAX(kazu1,kazu2);

  printf("%d\n",kouyakusuu);

  return 0;
}

int MAX(int a,int b)
{
  int x;

  if(a<b)
    {
      x = a;
      a = b % a;
      b = x;
      if(a == 0) return b;
      else MAX(a,b);
    }
  
  else if(a>b)
    {
      x = b;
      
      b = a%b;
      
      a = x;

      if(b == 0)return a;
      else MAX(a,b);
    }
  else if(a == b) return b;
}


Measured memory_bytes: 2692
#include <stdio.h>

int main(void){
	int a[10000],b[10000];
	int i,n,aa,ab;
	scanf("%d",&n);
	while(n!=0){
		aa=0;
		ab=0;
		for(i=0;i<n;i++){
			scanf("%d %d",&a[i],&b[i]);
			if(a[i]>b[i])aa+=a[i]+b[i];
			else if(a[i]<b[i])ab+=a[i]+b[i];
			else if(a[i]==b[i])aa+=a[i],ab+=b[i];
		}
		printf("%d %d\n",aa,ab);
		scanf("%d",&n);
	}
	return 0;
}

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

int main(){
  int n, d;
  cin >> n >> d;
  vector<vector<int>> vec(n, vector<int>(d));
  rep(i,n){
    rep(j,d) cin >> vec.at(i).at(j);
  }
  int cnt=0;
  rep(i,n){
    for (int j=i+1;j<n;j++){
      int tmp=0;
      if (i==j) continue;
      rep(k,d) tmp += pow((vec.at(i).at(k)-vec.at(j).at(k)),2);
      rep(l,tmp+1){
        if (l*l==tmp) cnt++;
      }
    }
  }
  cout << cnt;
}

Measured memory_bytes: 256
from math import gcd


def lcm(X, Y):  # 最小公倍数
    return (X * Y) // gcd(X, Y)

n, m = map(int, input().split())
s, t = input(), input()

l = lcm(n,m)
ln, lm = l // n, l // m
for i in range(0, l, lcm(ln, lm)):
    if s[i // ln] != t[i // lm]:
        print(-1)
        break
else:
    print(l)


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

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

typedef long long ll;

const int INF = 1 << 30;
const ll LLINF = 1LL << 60;

int mod = 1000000007;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int X; cin >> X;
    int ans = 0;
    while(X >= 500){
        ans += 1000;
        X -= 500;
    }
    while(X >= 5){
        ans += 5;
        X -= 5;
    }
    cout << ans << endl;
    return 0;
}

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

int main()
{
  int n;
  cin >> n;
  valarray<int> u(n), l(n);
  for (auto&& e : u) cin >> e;
  for (auto&& e : l) cin >> e;
  for (int i = 1; i < n; i++) {
    u[i] += u[i - 1];
    l[n - i - 1] += l[n - i];
  }
  cout << (u + l).max() << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
#define LL long long
int N;
LL A[200010];

bool judge(LL x){
    for(int s = 0; s < N; s++){//始点
        int lb = s, ub = s + N + 1;
        while(ub - lb > 1){
            int mid = (ub + lb) / 2;
            if(A[mid] >= x + A[s]){
                ub = mid;
            }else{
                lb = mid;
            }
        }
        int t = ub;
        lb = ub;
        ub = s + N + 1;
        while(ub - lb > 1){
            int mid = (ub + lb) / 2;
            if(A[mid] >= x + A[t]){
                ub = mid;
            }else{
                lb = mid;
            }
        }
        if(A[s + N] - A[ub] >= x) return true;
    }
    return false;
}

int main(){
    cin >> N;
    for(int i = 1; i <= N; i++){
        cin >> A[i];
        A[i + N] = A[i];
    }
    for(int i = 1; i <= N * 2; i++){
        A[i] += A[i - 1];
    }
    LL lb = 0;
    LL ub = A[N];
    while(ub - lb > 1){
        LL mid = (ub + lb) / 2;
        if(judge(mid)){
            lb = mid;
        }else{
            ub = mid;
        }
    }
    cout << lb << endl;
    return 0;
}


Measured memory_bytes: 4676
#if !defined(__clang__) && defined(__GNUC__)
#include <bits/stdc++.h>
#else
#include <cstdlib>
#include <climits>
#include <iostream>
#include <cstdint>
#include <vector>
#include <string>
#include <complex>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#endif //  !defined(__clang__) && defined(__GNUG__)
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/math/common_factor_rt.hpp>

using namespace std;



int main()
{
    int64_t H, W;
    std::cin >> H >> W;

    std::vector<int64_t> cands;

    // 同じ方向に3分割
    if (H % 3 != 0) {
        cands.push_back(W);
    }
    else {
        cands.push_back(0);
    }

    if (W % 3 != 0) {
        cands.push_back(H);
    }
    else {
        cands.push_back(0);
    }

    for (int64_t i = 1; i < H; ++i) {
        auto a = i * W;

        auto b = (H-i) * (W/2);
        auto c = (H-i) * (W - W/2);

        auto ma = std::max({a, b, c});
        auto mi = std::min({a, b, c});
        cands.push_back(ma - mi);
    }

    for (int64_t i = 1; i < W; ++i) {
        auto a = i * H;

        auto b = (W-i) * (H/2);
        auto c = (W-i) * (H - H/2);

        auto ma = std::max({a, b, c});
        auto mi = std::min({a, b, c});
        cands.push_back(ma - mi);
    }

    std::cout << *std::min_element(cands.begin(), cands.end()) << std::endl;

    return 0;
}


Measured memory_bytes: 2420
#include<bits/stdc++.h> 
using namespace std;
int a,b;
int main()
{
    cin>>a>>b;
    if(a+b==15)
    {
    	cout<<"+"<<endl;
    	return 0;
	}
	if(a*b==15)
	{
		cout<<"*"<<endl;
		return 0;
	}
	cout<<"x"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
	long long a,b,e,f;
	cin>>a>>b;
	e=a;
	f=b;
	if(a<b)
	{
		int t;
		t=a;
		a=b;
		b=t;
	}
	while(a%b)
	{
		a=a%b;
		if(a<b)
		{
			long long t;
			t=a;
			a=b;
			b=t;
		}
		
	}
	long long c;
	c=e*f/b;
	cout<<c;
} 


Measured memory_bytes: 256
/*-----------------------------------------------,
|  __                                       __   |
| |  |--.-----.---.-.----.----.-----.-----.|  |_ |
| |  _  |  -__|  _  |  __|  __|  -__|  _  ||   _||
| |_____|_____|___._|____|____|_____|   __||____||
|                                   |__|         |
`-----------------------------------------------*/
#include <cstdint>
#define DEBUG
#include<algorithm>
#include<array>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<tuple>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>
typedef long long ll; using namespace std;
#define INF 1000000000000
#define MOD 10000007
#define REP(counter, limit) for (long long counter = 0; counter < limit; counter++)
int gcd(int a, int b) { if (a % b == 0) { return(b); } else { return(gcd(b, a % b)); } }
int lcm(int a, int b) { return a * b / gcd(a, b); }
bool primenum(int a) { if (a == 1) { return false; }if (a == 2) { return true; }if (a % 2 == 0) { return false; }for (int i = 3; i < sqrt(a) + 1; i += 2) { if (a != i) { if (a % i == 0) { return false; } } }return true; }
struct setupios{setupios(){cin.tie(0);ios::sync_with_stdio(0); /*cout<<fixed<<setprecision(20);*/};}setupios;
int main() {

  int h,a;
  cin>>h>>a;
  int ans=0;
  ans=h/a;
  if(h%a > 0){
    ans++;
  }
  cout<<ans<<endl;

}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <sstream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <queue>
using namespace std;

int main() {
    int H;
    cin>>H;
    
    int ans=180*(H-2);
    
    cout << ans << endl;
}


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


int main(){
    string s;
    long long int k;
    cin >> s >> k;
    long long int n=s.size();
    long long int ans;
    bool all=true,same=false;
    if(s[0]==s[s.size()-1])same=true;

    for(long long int i=0; i<n-1; i++){
        if(s[i]!=s[i+1]){
            all=false;
            //cout << "OK!" << endl;
            break;
        }
    }

    long long int cnt_x=1,x=0;
    long long int cnt_y=1,y=0;
    string t=s+s;

    for(long long int i=0; i<n-1; i++){
        if(s[i]==s[i+1]){
            cnt_x++;
            if(i==n-2)x+=cnt_x/2;
        }
        else{
            x+=cnt_x/2;
            cnt_x=1;
        }
    }
    for(long long int i=0; i<2*n-1; i++){
        if(t[i]==t[i+1]){
            cnt_y++;
            if(i==2*n-2)y+=cnt_y/2;
        }
        else{
            y+=cnt_y/2;
            cnt_y=1;
        }
    }

    if(all==true){
        switch (k%2){
        case 0:
            cout << y*(k/2);
            break;
        case 1:
            cout << y*(k/2)+x;
        default:
            break;
        }
    }
    else if(same==true)cout << x+(y-x)*(k-1);
    else cout << x*k;
    cout << endl;
}


Measured memory_bytes: 256
s = gets.chomp
arr = s.split('')
def chk (arr)
  i = 0
  j = arr.size - 1
  while i < arr.size / 2
    flg = 'no' unless arr[i] == arr[j]
    i += 1
    j -= 1
  end
  flg
end
flg = chk(arr)
if flg  == 'no'
  puts 'No'
  exit
end
arr_f = arr[0..(arr.size / 2 - 1)]
flg = chk(arr_f)
if flg  == 'no'
  puts 'No'
  exit
end
arr_s = arr[(arr.size / 2 + 1)..(arr.size - 1)]
flg = chk(arr_s)
if flg  == 'no'
  puts 'No'
  exit
else
  puts 'Yes'
end









Measured memory_bytes: 3836
n,k,q = gets.split(" ").map(&:to_i)
a = Array.new(q)
point = Array.new(n, 0)
0.step(q-1){|i|
    a[i] = gets.to_i
    point[a[i]-1] += 1
}
if q < k
    1.step(n){
        puts "Yes"
    }
else
    0.step(n-1){|i|
        if q - point[i] >= k
            puts "No"
        else
            puts "Yes"
        end
    }
end

Measured memory_bytes: 3964
#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

typedef long long ll;
//typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector<vector<int>> mat;
//typedef unsigned int uint;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

int N, M;
vector<int> G[100010];
int dp[100010];

int dfs(int n)
{
	if (dp[n] > 0)return dp[n];

	int res = 0;
	for (auto& e : G[n])
	{
		chmax(res, 1 + dfs(e));
	}

	dp[n] = res;
	return dp[n];
}

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

	cin >> N >> M;
	int x, y;
	rep(j, 0, M)
	{
		cin >> x >> y;
		x--; y--;
		G[x].push_back(y);
	}

	int ans = 0;
	rep(i, 0, N)
	{
		chmax(ans, dfs(i));
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 8576
use proconio::input;

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

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

//#[proconio::fastout]
fn main() {
    input! {
        n: usize,
        d: [(usize,usize);n],
    }

    let mut ans = "No";
    for i in 0..n-2 {
        if d[i].0 == d[i].1 && d[i+1].0 == d[i+1].1 && d[i+2].0 == d[i+2].1 {
            ans = "Yes";
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 2160