akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

typedef long long ll;

const int MN = 200010;

int N;
int A[MN];
ll psum[MN];
ll mx1[MN], mn1[MN], mx2[MN], mn2[MN];

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

    for(int i = 0; i < N; i++) {
        scanf("%d", &A[i]);
    }
    for(int i = 0; i < N; i++) {
        psum[i] = A[i];
        if(i) psum[i] += psum[i - 1];
    }

    for(int i = 1; i < N; i++) {
        int s = 0, e = i, p = -1;
        while(s <= e) {
            int m = (s + e)>>1;

            if(psum[m] <= psum[i] - psum[m]) {
                p = m;
                s = m + 1;
            }
            else e = m - 1;
        }

        mn1[i] = p == -1? 0 : psum[p];
        mx1[i] = psum[i] - mn1[i];

        s = 0, e = i, p = i + 1;
        while(s <= e) {
            int m = (s + e)>>1;

            ll sum = psum[i] - (m? psum[m - 1] : 0);
            if(sum <= psum[i] - sum) {
                p = m;
                e = m - 1;
            }
            else s = m + 1;
        }

        ll sum = psum[i] - psum[p - 1];
        mn1[i] = max(mn1[i], sum);
        mx1[i] = min(mx1[i], psum[i] - sum);
    }

    reverse(A, A + N);
    for(int i = 0; i < N; i++) {
        psum[i] = A[i];
        if(i) psum[i] += psum[i - 1];
    }

    for(int i = 1; i < N; i++) {
        int s = 0, e = i, p = -1;
        while(s <= e) {
            int m = (s + e)>>1;

            if(psum[m] <= psum[i] - psum[m]) {
                p = m;
                s = m + 1;
            }
            else e = m - 1;
        }

        mn2[i] = p == -1? 0 : psum[p];
        mx2[i] = psum[i] - mn2[i];

        s = 0, e = i, p = i + 1;
        while(s <= e) {
            int m = (s + e)>>1;

            ll sum = psum[i] - (m? psum[m - 1] : 0);
            if(sum <= psum[i] - sum) {
                p = m;
                e = m - 1;
            }
            else s = m + 1;
        }

        ll sum = psum[i] - psum[p - 1];
        mn2[i] = max(mn2[i], sum);
        mx2[i] = min(mx2[i], psum[i] - sum);
    }

    ll ans = 1e18;
    for(int i = 1; i < N - 2; i++) {
        ll mn = min(mn1[i], mn2[N - 2 - i]);
        ll mx = max(mx1[i], mx2[N - 2 - i]);
        ans = min(ans, mx - mn);
    }
    printf("%lld", ans);
}


Measured memory_bytes: 8960
import java.util.Scanner;

public class Main {
	public static int gcd(int a, int b) {
		int tmp;
		while(b!=0) {
			tmp=b;
			b=a%b;
			a=tmp;
		}
		return a;
	}
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];
		for(int i=0; i<n; i++) {
			a[i] = sc.nextInt();
		}
		int[] preGCD = new int[n+1];
		preGCD[0]=0;
		int[] postGCD = new int[n+1];
		postGCD[0]=0;
		for(int i=0, tmp=a[0]; i<n; i++) {
			tmp=gcd(tmp, a[i]);
			preGCD[i] = tmp;
//			System.out.println(preGCD[i]);
		}
		for(int i=0, tmp=a[n-1]; i<n; i++) {
			tmp=gcd(tmp, a[n-1-i]);
			postGCD[n-1-i] = tmp;
//			System.out.println(postGCD[n-1-i]);
		}
		int ans=Math.max(preGCD[n-2], postGCD[1]);
		for(int i=0+1, tmp; i<n-1; i++) {
			tmp=gcd(preGCD[i-1], postGCD[i+1]);
			ans = Math.max(ans, tmp);
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 50304
S = {'a':[], 'b':[], 'c':[]}

for char in ['a', 'b', 'c']:
    S[char] = [c for c in input()]

# 今誰のターンか, 終了フラグ
now = 'a'
end = 0

while end == 0:
    # もしもうカードがなければ終了
    if len(S[now]) == 0 :
        print(now.upper())
        end = 1
    else :
        # 先頭を取得しnow更新, 文字を詰める
        now = S[now].pop(0)

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

using namespace std;

#define fin cin
#define fout cout
//ifstream fin("x.in"); ofstream fout("x.out");

const int nmax = 1e5;

int talbe, ans, nrnod;
int ind, n;

bool viz[nmax + 1], ceva[nmax + 1];
int d[nmax + 1];
string c;
vector< int > g[nmax + 1];

inline int culval (int nod) {
    if (c[ nod ] == 'W')
        return -1;
    return 1;
}

void dfs (int nod, int h = 0) {
    viz[ nod ] = 1;

    int mn = 0, mn2 = 0, nrfii = 0;
    for (auto i : g[ nod ]) {
        if (viz[ i ] == 0) {
            dfs(i, 1);

            d[ nod ] = min(d[ nod ], d[ i ]);
            if (d[ i ] <= mn) {
                mn2 = mn;
                mn = d[ i ];
            } else if (d[ i ] < mn2) {
                mn2 = d[ i ];
            }

            ceva[ nod ] |= ceva[ i ];
            if (ceva[ i ]) ++ nrfii;
        }
    }


    ceva[ nod ] |= (c[ nod ] == 'W');

    if (ceva[ nod ] == 1) {
        ++ nrnod;

        nrfii = (nrfii + h) % 2;
        int vl = culval(nod);
        if (nrfii == 1)
            vl = -vl;
        vl -= 1;

        if (vl == -2)
            talbe ++;

        ans = min(ans, mn + mn2 + vl);
        d[ nod ] += vl;
    }
}

int main() {
    fin.sync_with_stdio(false); fin.tie(); fout.tie();

    fin >> n;

    for (int i = 1; i < n; ++ i) {
        int x, y;
        fin >> x >> y;
        g[ x ].push_back( y );
        g[ y ].push_back( x );
    }
    fin >> c;
    c = '#' + c;

    int rad = -1;
    int cnt = 0;
    for (int i = 1; i <= n; ++ i) {
        if (c[ i ] == 'W') {
            rad = i;
            ++ cnt;
        }
    }

    if (rad == -1) {
        fout << "0\n";
        return 0;
    }
    if (cnt == 1) {
        fout << "1\n";
        return 0;
    }

    dfs( rad );
    ans += 2 * (nrnod - 1) + talbe;
    fout << ans << "\n";

    return 0;
}



Measured memory_bytes: 14188
#define _USE_MATH_DEFINES
#include <array>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;
mt19937 mrand(random_device{}());
int rnd(int x) { return mrand() % x; }

int main() {
  int x, y;
  cin >> x >> y;
  cout << (x * 500 >= y ? "Yes" : "No") << endl;
  return 0;
}


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

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int w = Integer.parseInt(sc.next());
        int h = Integer.parseInt(sc.next());
        int x = Integer.parseInt(sc.next());
        int y = Integer.parseInt(sc.next());
        int r = Integer.parseInt(sc.next());
        if(x < 0 || y < 0){
            System.out.println("No");
            return;
        }

        if(x - r < 0 || w - x < r || y - r < 0 || h - y < r){
            System.out.println("No");
        }else{
            System.out.println("Yes");
        }
    }
}


Measured memory_bytes: 26328
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define INF 999999999
#define ll long long
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int main(){
  int s,a,b;
  cin >> s;
  a = s % 100;
  b = s/100;
  if(((a > 0) && (a < 13)) && ((b > 0) && (b < 13))){
    printf("AMBIGUOUS\n");
  }
  else if((a > 0) && (a < 13)){
    printf("YYMM\n");
  }
  else if((b > 0) && (b < 13)){
    printf("MMYY\n");
  }
  else{
    printf("NA\n");
  }
  return 0;
}

Measured memory_bytes: 256
doubletCount = 0
cases = int(input())
for roll in range(cases):
    d1, d2 = map(int, input().split())
    if d1 == d2:
        doubletCount += 1
    else:
        doubletCount = 0
                
    if doubletCount >= 3:
        print("Yes")
        break
            
    if roll == cases - 1:
        print("No")

Measured memory_bytes: 9172
#include<bits/stdc++.h>
#define int long long
using namespace std;
constexpr int mod=1e9+7;
signed main(){
    int n,a[81];
    cin>>n;
    for(int i=0;i<n;i++)
        cin>>a[i];
    a[n]=0;
    int m=1000,s=0;
    for(int i=0;i<n;i++){
        if(a[i]<a[i+1]){
            s+=m/a[i];
            m-=m/a[i]*a[i];
        }else{
            m+=s*a[i];
            s=0;
        }
    }
    cout<<m<<endl;
}


Measured memory_bytes: 3640
n = gets.chomp.to_i

words = Array.new(n)
n.times { |i|
  words[i] = gets.chomp
}

word_map = words.group_by { |word| word }.map { |k, v| [k, v.size] }.to_h
max = word_map.values.max

puts word_map.select { |k, v| v == max }.to_h.keys.sort


Measured memory_bytes: 94696
N = int(input())
Ws = list(map(int, input().split()))

result = sum(Ws)
for t in range(1, N):
	s1 = sum(Ws[0:t])
	s2 = sum(Ws[t:N])
	diff = abs(s1 - s2)
	if result > diff:
		result = diff
print(result)


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

using namespace std;

#define FO(i, N) for (int (i) = 0; (i) < (N); ++(i))
#define READALL(c) for (auto &e : c) { cin >> e; }
#define PRINTALL(c) for (const auto &e : c) { cout << e << "\t"; } cout << "\n";

template <typename T>
using V = vector<T>;

typedef long double ld;
typedef long long ll;

int N;
ll A[2<<18+5], tmp[4];

void combine(pair<int, int> &ans, pair<int, int> &p) {
	tmp[0] = p.first;
	tmp[1] = p.second;
	tmp[2] = ans.first;
	tmp[3] = ans.second;
	sort(tmp, tmp+4);
	ans.first = tmp[3];
	ans.second = tmp[2];
}

set<pair<int, int>> DP[2<<18+5];

set<pair<int, int>> f(int bs) {
	if (bs == 0) return {{A[0], 0}};
	if (DP[bs].size()) return DP[bs];
	set<pair<int, int>> ans = {{A[bs],bs}};
	FO(i, N) if (bs&(1<<i)) {
		auto s = f(bs&(~(1<<i)));
		int a = s.begin()->first, b = s.rbegin()->first;
		// cout << bs << " " << (bs&(~(1<<i))) << " " << a << " " << b << endl;
		ans.insert(s.begin(), s.end());
		while (ans.size() > 2) ans.erase(ans.begin());
		// combine(ans, p);
	}
	int a = ans.begin()->first, b = ans.rbegin()->first;
	// cout << bs << " = " << a << " " << b << endl;
	return DP[bs] = ans;
}


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

	cin >> N;
	FO(i, 1<<N) {
		DP[i].clear();
		cin >> A[i];
	}

	int ans = 0;
	for (int k = 1; k < (1<<N); ++k) {
		auto s = f(k);
		int a = s.begin()->first, b = s.rbegin()->first;
		ans = max(ans, a+b);
		cout << ans << "\n";
	}
	
}

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

int main(){
    int n = 0, count = 0;

    cin >> n;

    if(n!=0) count++;

    vector<int> d(n);

    for(int i=0;i<n;i++){
        cin >> d.at(i);
    }

    for(int i = 0; i < n-1; i++){
        for(int j = i+1; j < n; j++){
            if(d.at(i) > d.at(j)){
                int temp=0;
                temp = d.at(i);
                d.at(i) = d.at(j);
                d.at(j) = temp;
            }
        }
    }

    for(int i = 0; i < n-1; i++){
        if(d.at(i) != d.at(i+1)){
            count++;
        }
    }
    cout << count << endl;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
#define REPi(i, a, b) for(int i=int(a); i<int(b); i++)
#define MEMS(a,b) memset(a,b,sizeof(a))
#define mp make_pair
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; }
const ll MOD = 1e9+7;

#define MAX_N 1001000
//i番目の素数
int prime[MAX_N];
//trueなら素数
bool is_prime[MAX_N + 1];

//n以下の素数の数を返す O(n log(logn)) ~~ O(n)
int sieve(int n){
    int p = 0;
    for(int i = 0; i <= n; i++) is_prime[i] = true;
    is_prime[0] = is_prime[1] = false;
    for(int i = 2; i <= n; i++){
        if(is_prime[i]){
            prime[p++] = i;
            for(int j = 2*i; j <= n; j += i) is_prime[j] = false;
        }
    }
    return p;
}

int main(){
    ll X;
    cin >> X;

    sieve(1e6);

    REP(i,MAX_N){
        int x = prime[i];
        if(x >= X){
            cout << x << endl;
            return 0;
        }
    }

    return 0;
}


Measured memory_bytes: 1536
#include "bits/stdc++.h"
using namespace std;

#define ii pair<int,int> 
#define iii pair<ii,ii> 
#define state pair<ii,int> 

int X, Y, offset;
string str;
vector<int> moves[2];
bool fAns = false;
const int OFFSET = 8000;

bool ans[4005][2*OFFSET], found[4005][2*OFFSET];

bool dp(vector<int>& m, int pos, int diff){
	if(pos == m.size()){
		return (diff == OFFSET);
	}
	if(found[pos][diff]){
		return ans[pos][diff];
	}
	found[pos][diff] = true;
	return ans[pos][diff] = (dp(m, pos+1, diff+m[pos])|dp(m, pos+1, diff-m[pos]));
}

int main(){
	cin >> str;
	cin >> X >> Y;
	int cons = 0;
	bool onX = false, first = true;
	for(int i = 0; i < str.size(); ++i){
		if(str[i] == 'F')
			cons++;
		else{
			if(first){
				// Must be X positive
				offset = cons;
			}else{
				moves[onX].push_back(cons);
			}
			first = false;
			onX = !onX;
			cons = 0;
		}
	}
	if(first){
		// Must be X positive
		offset = cons;
	}else{
		moves[onX].push_back(cons);
	}
	// for(int i : moves[0]) printf("(%d\n", i); printf("\n");
	// for(int i : moves[1]) printf("[%d\n", i);
	fAns = (dp(moves[0], 0, OFFSET+X-offset));
	// printf("[%d] %d\n", dp(moves[0], 0, OFFSET+X-offset), X-offset);
	memset(found, 0, sizeof found);
	fAns &= (dp(moves[1], 0, OFFSET+Y));
	if(fAns)
		printf("Yes\n");
	else
		printf("No\n");
}

Measured memory_bytes: 125568
class Module
  def tco(name)
    continue = []
    first = true
    arguments = nil

    private_name = "private_" + name.to_s
    alias_method private_name, name
    private private_name

    define_method(name) do |*args|
      if first
        first = false
        while true
          result = send(private_name, *args)
          if result.equal? continue
            args = arguments
          else
            first = true
            return result
          end
        end
      else
        arguments = args
        continue
      end
    end
  end
end


class Solve
  def parent(x)
    return x if $mark[x]
    parent($arr[x])
  end
  tco :parent
end

loop do
  n, q = gets.split.map(&:to_i)
  break if n == 0
  $arr = Array.new(n+1)
  (2..n).each{ |i| $arr[i] = gets.to_i }
  $mark = Array.new(n+1)
  $mark[1] = true
  sum = 0
  qs = []
  q.times do
    qs << gets.split
  end
  s = Solve.new
  qs.each do |cmd, n|
    if cmd == 'M'
      $mark[n.to_i] = true
    else
      sum += s.parent(n.to_i)
    end
  end
  p sum
end

Measured memory_bytes: 53236
n = input()
n = int(n)
lst1 = input().split()

h_mtn = 0
count = 0

for i in range(0, n, 1):
    state = lst1[i]
    state = int(state)
    if state >= h_mtn:
        count += 1
    if state > h_mtn:
        h_mtn = state

print(count)

Measured memory_bytes: 3060
#include <stdio.h>

int main(void){
    double num,d;
    int i;
    char line[15]={0};
    for(;scanf("%lf",&num),num>=0;){
        for(d=128.0,i=0;i<13;i++){
            if(i==8)
                line[i]='.';
            else if(num>=d)
                line[i]='1',num-=d,d/=2;
            else
                line[i]='0',d/=2;
        }
        printf("%s\n",num==0?line:"NA");
    }
    return 0;
}

Measured memory_bytes: 612
#include<stdio.h>
#include<stdlib.h>
int main(){
/*
int n;

for(n =1;;n++){
	if(x==0 && y==0) break;
	
}
*/
int a,b;
scanf("%d",&a);
scanf("%d",&b);

printf("%d %d %lf\n", a/b,a%b,(double)a/b);
return 0;
	}




Measured memory_bytes: 2052
let judge n =
    Array.sort >> fun x -> x.[n / 2] - x.[n / 2 - 1]

//let input = [| 6, [|9; 1; 4; 4; 6; 7|]; 8, [| 9; 1; 14; 5; 5; 4; 4; 14 |]; 14, [| 99592; 10342; 29105; 78532; 83018; 11639; 92015; 77204; 30914; 21912; 34519; 80835; 100000; 1 |] |]
//for n, ds in input do (judge n ds |> printfn "%d")
// expected 2; 0; 42685

[<EntryPoint>]
let main argv =
    let n = stdin.ReadLine() |> int
    stdin.ReadLine().Split()
    |> Array.map int
    |> judge n
    |> printfn "%d"
    0


Measured memory_bytes: 38352
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define reps(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; --i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define repc2(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define inf 2e9
#define linf 9000000000000000000ll
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

#define MAX_N 100009
vector<bool> prime;
vector<int> bin;

void init() {
    prime.resize(MAX_N, true);
    bin.resize(MAX_N);
    prime[0] = prime[1] = false;
    for (int i = 0; i <= sqrt(MAX_N); i++) {
        if (prime[i]) {
            for (int j = 2 * i; j < MAX_N; j += i) {
                prime[j] = false;
            }
        }
    }
    int cnt = 0;
    rep(i, MAX_N) {
        if ((i & 1) && prime[i] && prime[(i + 1) / 2]) {
            cnt++;
        }
        bin[i] = cnt;
    }
}

int q;

int main() {
    init();
    cin >> q;
    rep(i, q) {
        int l, r;
        cin >> l >> r;
        cout << bin[r] - bin[l - 1] << endl;
    }
    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<cstring>
#include<vector>
#include<queue>
#include<cstdio>
#include<algorithm>
using namespace std;

#define LL long long

inline int read(){
	int x=0,f=1;char c=getchar();
	for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;
	for(;isdigit(c);c=getchar()) x=x*10+c-'0';
	return x*f;
}
const int INF=9999999;
const int MAXN=300010;
const int MAXM=2010;
const int Mod = 1e9+7;

int N; int a[MAXN+1],b[MAXN+1];
int f[MAXM*2+1][MAXM*2+1];
LL ifac[MAXN+1],fac[MAXN+1],inv[MAXN+1];
int A[MAXN+1],B[MAXN+1];

inline LL C(LL n,LL m){
	if(n<m) return 0; if(n==m||!m) return 1;
	return fac[n]*ifac[m]%Mod*ifac[n-m]%Mod;
}

int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	N=read(); fac[0]=1; inv[1]=1; ifac[1]=ifac[0]=1; LL ans=0;
	for(int i=1;i<=(MAXM<<2)+100;i++) fac[i]=fac[i-1]*i%Mod;
	for(int i=2;i<=(MAXM<<2)+100;i++){
		inv[i]=(Mod-(Mod/i))*inv[Mod%i]%Mod;
		ifac[i]=ifac[i-1]*inv[i]%Mod;
	}
	for(int i=1;i<=N;i++){
		A[i]=read(),B[i]=read();
		f[MAXM-A[i]][MAXM-B[i]]++;
		ans=(ans-C(A[i]*2+B[i]*2,A[i]*2)%Mod+Mod)%Mod;
	}
	for(int i=1;i<=MAXM*2;i++){
		for(int j=1;j<=MAXM*2;j++){
			(f[i][j]+=f[i-1][j])%=Mod;
			(f[i][j]+=f[i][j-1])%=Mod;
		}
	}
	for(int i=1;i<=N;i++){
		(ans+=f[A[i]+MAXM][B[i]+MAXM])%=Mod;
	} printf("%lld\n",ans*inv[2]%Mod);
	return 0;
}


Measured memory_bytes: 73472
#include<cstdlib>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<queue>
#include<set>
using namespace std;
const int MAXN = (int) 1e5 + 10;
const int INF = (int) 0x3f3f3f3f;
typedef long long LL;

int n,k;
int x[MAXN],b[MAXN];

void work(){
    int QvQ; scanf("%d",&QvQ);
    while(QvQ--){
        scanf("%d%d",&n,&k);
        for(int i=1;i<=n;i++){
            scanf("%d",&x[i]);
        }
        int ans=x[n]-x[1];
//        printf("ans = %d\n",ans);
        if(n<=k) printf("%d\n",0);
        else{
            for(int i=2;i<=n;i++) b[i-1]=x[i]-x[i-1];
//            for(int i=1;i<n;i++) printf("%d ",b[i]);
//            printf("\n");
            sort(b+1,b+n);
//            for(int i=n-1;i>=1;i) printf("%d ",b[i]);
//            printf("\n");
            for(int i=1;i<k;i++) ans-=b[n-i];
            printf("%d\n",ans);
        }
    }
}

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












Measured memory_bytes: 3440
#include <iostream>
#include <cstdio>
using namespace std;
long long int a,b;
long long int mcd(int a,int b){
	long long int t;
	if(a<b){
		t=a;
		a=b;
		b=t;
	}
	while(1){
		t=a%b;
		if(t==0)return b;
		a=b;
		b=t;
	}
}

int main(){
	scanf("%lld %lld",&a,&b);
	long long int d=mcd(a,b);
	long long int ans=a*b/d;
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define fi first
#define se second
#define all(x) x.begin(), x.end()
using namespace std;
using ull = unsigned long long;
using ll = long long;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;

int main(){
    int N;
    string S;
    cin >> N >> S;

    int sum = 1;
    for(int i = 0; i < N - 1; i++)if(S[i] != S[i + 1]) sum++;
    cout << sum << endl;

}

Measured memory_bytes: 512
#include <stdio.h>

int main()
{
	int i, N;
	long long A[301], xor = 0;
	scanf("%d", &N);
	for (i = 1; i <= N; i++) {
		scanf("%lld", &(A[i]));
		xor ^= A[i];
	}
	if (xor == 0) {
		printf("0\n");
		fflush(stdout);
		return 0;
	} else xor ^= A[1] ^ A[2];
	
	long long bit[41], x = A[1] + A[2], y = x - xor;
	for (i = 1, bit[0] = 1; i <= 40; i++) bit[i] = bit[i-1] << 1;
	if (y < 0 || x < y || y % 2 == 1 || y / 2 > A[1]) {
		printf("-1\n");
		fflush(stdout);
		return 0;
	} else y /= 2;
	
	int flag[41];
	long long a = y, b = y, c = y << 1;
	for (i = 0; i <= 40; i++) flag[i] = ((y & bit[i]) > 0)? 1: 0; 
	for (i = 0; i <= 40; i++) {
		if ((x & bit[i]) == (c & bit[i])) continue;
		else if (flag[i] == 1) break;
		flag[i] = -1;
		c += bit[i];
	}
	if (c != x) {
		printf("-1\n");
		fflush(stdout);
		return 0;
	}
	
	for (i = 40; i >= 0; i--) if (flag[i] == -1 && a + bit[i] <= A[1]) a += bit[i];
	if (a > 0) printf("%lld\n", A[1] - a);
	else printf("-1\n");
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 1732
#include<bits/stdc++.h>
#include <vector>
#include <set>
#include <deque>
using namespace std;
int main(){
int n;
	cin>>n;
	int a[n]={0};
	float sum=0;
	for (int i = 0; i < n; ++i)
	{
		cin>>a[i];
		sum+=a[i];
	}
	sum=round(sum/n);
	int ans=0;
	for (int i = 0; i < n; ++i)
	{
		ans+=pow((sum-a[i]),2);
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 512
n = int(input())
s = list(input())


count = 0
for e,i in enumerate(s):
    if e == 0:
        continue
    if i == 'E':
        count += 1

mincount = count
for e,i in enumerate(s):
    if e == len(s)-1:
        break
    if e == 0 and i == 'E':
        continue
    if i == 'W':
        count+=1
    else:
        count-=1

    if s[e+1] == 'E':
        mincount = min(count-1,mincount)
    else:
        mincount = min(count,mincount)

print(mincount)


Measured memory_bytes: 5920
N = int(input())
lista = list(map(int, input().split()))
lista.sort(reverse= True)

count = 0
area = 1

for i in range(len(lista)- 1):
  if(lista[i] == lista[i+ 1]):
    del lista[i]
    area*= lista[i]
    count+= 1
    if(count == 2):
      break
      
if(count == 2):
  print(area)
else:
  print(0)

Measured memory_bytes: 14244
import numpy as np
from numba import njit


@njit("i8, i8, i8[:]")
def myfunc(n, k, A):
    for _ in range(k):
        l = np.zeros((n + 1,), dtype=np.int64)
        for i, a in enumerate(A[:-1]):
            l[max(0, i - a)] += 1
            l[min(n, i + a + 1)] -= 1
        A = np.cumsum(l)
        if np.all(A[:-1] == n):
            break
    return A


def main():
    n, k = map(int, input().split())
    A = np.array(list(map(int, input().split())), dtype=np.int64)
    A = np.append(A, 0)
    print(*myfunc(n, k, A)[:-1])


if __name__ == "__main__":
    main()

Measured memory_bytes: 136764
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < int(n); ++i)
int main(){
    int a,b; cin >> a >> b;
    if(a >= 1 && a <= 9 && b >= 1 && b <= 9) cout << a*b << endl;
    else cout << -1 << endl;
}

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

int main() {
  string s;
  cin >> s;
  if(s.at(0) == '0' + 9 || s.at(1) == '0' + 9) cout << "Yes" << endl;
  else cout << "No" << endl; 
}

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

using ll = long long;

constexpr ll MOD = 1e9+7;
constexpr ll INF = 1ll<<60;

#define FOR(i,a,b) for (ll i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

vector<vector<ll>> G;

int main(int argc, char **argv)
{
	ll N; cin >> N;
	G.resize(N);

	REP(i, N-1)
	{
		ll a, b; cin >> a >> b;
		--a, --b;
		G[a].push_back(b);
		G[b].push_back(a);
	}

	vector<ll> C(N); REP(i, N) cin >> C[i];
	sort(ALL(C), greater<ll>());

	queue<ll> que;
	vector<ll> res(N, -1);
	que.push(0);
	res[0] = C[0];
	ll i{1};

	while (!que.empty())
	{
		ll now = que.front(); que.pop();
		for (auto &nv : G[now])
		{
			if (res[nv] != -1) continue;
			que.push(nv);
			res[nv] = C[i];
			++i;
		}
	}

	std::cout << accumulate(next(C.begin()), C.end(), 0ll)<< std::endl;
	REP(i, N)
		std::cout << (i?" ":"") << res[i];
	std::cout << std::endl;

}


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

int main(){
  int a, b, x = 0;
  string str;

  cin >> a >> b;
  cin >> str;

  for(int i = 0; i < a; i++){
    if(isdigit(str[i])){
        for (int j = a; j < a+b+1; j++){
          if(str[a] == '-'){
            if(isdigit(str[j])){
              x = 1;
            }
          } else {
            x = 0;
          }
        }
    } else {
      x = 0;
    }
  }

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


}

Measured memory_bytes: 256
//Never stop trying
/*#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")*/
#include <bits/stdc++.h>
using namespace std;
#define boost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)

typedef string str;
typedef long long ll;
//#define int ll
typedef double db;
typedef long double ld;
typedef pair<int, int> pi;
#define fi first
#define se second
typedef vector<int> vi;
typedef vector<pi> vpi;
typedef vector<str> vs;
typedef vector<ld> vd;
#define pb push_back
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define endl "\n"

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

const int MOD = 1e9 + 7; //998244353
const ll INF = 1e18;
const int MX = 2e5 + 10;
const int nx[4] = {0, 0, 1, -1}, ny[4] = {1, -1, 0, 0}; //right left down up

template<class T> using V = vector<T>;
template<class T> bool ckmin(T& a, const T& b) { return a > b ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

ll cdiv(ll a, ll b) { return a / b + ((a ^ b) > 0 && a % b); } // divide a by b rounded up
constexpr int log2(int x) { return 31 - __builtin_clz(x); } // floor(log2(x))

#define dbg(x) cerr << " - " << #x << " : " << x << endl;
#define dbgs(x,y) cerr << " - " << #x << " : " << x << " / " << #y << " : " << y << endl;
#define dbgv(v) cerr << " - " << #v << " : " << endl << "[ "; for(auto it : v) cerr << it << ' '; cerr << ']' << endl;

void IO() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}

const ld eps=1e-15;


int main() {
	boost; IO();

	ld D,T,S; 
	cin>>D>>T>>S;
	ld xx=(ld)D/S;
	if(xx>T) cout << "No" << endl;
	else cout << "Yes" << endl;


	return 0;
}

/* Careful!!!
	.Array bounds
	.Infinite loops
	.Uninitialized variables / empty containers
	.Order of input

   Some insights:
	.Binary search
	.Graph representation
	.Write brute force code
	.Change your approach
*/


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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long n;
  cin >> n;
  for (long long i = floor(sqrt(n)); i >= 1; i--) {
    if (n % i == 0) {
      cout << to_string(n / i).length() << '\n';
      return 0;
    }
  }
  return 0;
}

Measured memory_bytes: 3716
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define EPS (1e-10)
#define equals(a, b) (fabs((a)-(b)) < EPS)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
  
int main() {
  int N;
  cin >> N;
  map<ll,vl> mp;
  vl a(N);
  rep(i,N) {
    ll x;
    cin >> x;
    a[i]=x;
    mp[i-x].push_back(i);
  }
  ll ans = 0;
  rep(i,N) {
    ll tar = i+a[i];
    ll cnt = sz(mp[tar]);
    cnt -= (upper_bound(rng(mp[tar]),i)-mp[tar].begin());
    ans += cnt;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 39112
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T> ostream& operator<<(ostream& s,const multiset<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1'000'000'007;
const ll inf=1'000'000'000'000'000'00;
const int INF=1'000'000'000;
const double EPS=1e-10;
const double PI=acos(-1);

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    ll n,k;
    cin>>n>>k;
    vector<ll> a(n+1);
    FOR(i,1,n+1){
        cin>>a[i];
    }
    FOR(i,k+1,n+1){
        if(a[i]>a[i-k]){
            cout<<"Yes"<<endl;
        }else{
            cout<<"No"<<endl;
        }
    }
}

Measured memory_bytes: 4748
#include<stdio.h>

struct test{
    signed short mid;
    signed short fin;
    signed short re;
    char eval;
};char evaluate(int mid, int fin, int re);
int main(){
    struct test test[50];
    int i;
    int count = 0;
    for(i = 0;i < 50;i++){
        scanf("%d %d %d", &test[i].mid, &test[i].fin, &test[i].re);
        if(test[i].mid == -1 && test[i].fin == -1 && test[i].re == -1){
            break;
        }
        test[i].eval = evaluate(test[i].mid, test[i].fin, test[i].re);
        count++;
    }
    for(i = 0;i < count;i++){
        printf("%c\n", test[i].eval);
    }
    return 0;
}

char evaluate(int mid, int fin, int re){
    if(mid == -1 || fin == -1){
        return 'F';
    }
    if(mid + fin >= 80){
        return 'A';
    }
    else if(mid + fin >= 65){
        return 'B';
    }
    else if(mid + fin >= 50){
        return 'C';
    }
    else if(mid + fin >= 30){
        if(re >= 50){
            return 'C';
        }
        else{
            return 'D';
        }
    }
    else{
        return 'F';
    }
}


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

using namespace std;

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

int ans[555][555];
int main(){
	int n;cin >> n;
	REP(i, n){
		REP(j, n){
			if(i == j)continue;
			for(int k = 30;k >= 0;k--){
				if((i & (1 << k)) != (j & (1 << k))){
					ans[i][j] = (k + 1);
					break;
				}
			}
		}
	}
	REP(i, n-1){
		REP(j, n){
			if(i < j)cout << ans[i][j] << (j == n - 1 ? '\n' : ' ');
		}
	}
	return 0;
}


Measured memory_bytes: 1536
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;


namespace ConsoleApplication2
{

    class Program
    {
        static void Main(string[] args)
        {

            int input = int.Parse(Console.ReadLine().Split(' ')[0]);
            string[] input2 = Console.ReadLine().Split(' ');
            string result;
            if(input2[0].Count()< input)
            {
                input = input2[0].Count();
            }

            result=input2[0].Substring(0, input);

            if(input2[0].Count()> input)
            {
                result=string.Concat(result, "...");
            }



            Console.WriteLine(result);
            

        }
    }
}


Measured memory_bytes: 18888
//AOJ 0205
import java.util.*;

class Main{
  public static void main(String[] args){

    //declare
    Scanner in = new Scanner(System.in);
    Set<Integer> zya = new HashSet<Integer>();
    ArrayList<Integer> array  = new ArrayList<Integer>();
    ArrayList<Integer> array2 = new ArrayList<Integer>();
    int a,b,c,d,e;

    //imput
    while (true){
      a = in.nextInt();
      if(a==0){break;}
      zya.add(a);
      array.add(a);
      for(int i=0;i<4;i++){
        b = in.nextInt();
        zya.add(b);
        array.add(b);
      }

      //calculate
      if(!(zya.contains(1)) && zya.contains(2) && zya.contains(3)){
        c = 0; d = 1; e = 2;
      }else if(zya.contains(1) && !(zya.contains(2)) && zya.contains(3)){
        c = 2; d = 0;e = 1;
      }else if(zya.contains(1) && zya.contains(2) && !(zya.contains(3))){
        c = 1; d = 2; e = 0;
      }else{
        c=d=e=3;
      }
      for(int i=0;i<5;i++){
        if(array.get(i) == 1){array2.add(c);}
        if(array.get(i) == 2){array2.add(d);}
        if(array.get(i) == 3){array2.add(e);} 
      }
      array.clear();
      zya.clear();
    }
    
    //output
    for(int s: array2){System.out.println(s);}
  }
}

Measured memory_bytes: 29404
def ABC133C(l, r):
    Min = 1e10
    for i in range(l, r):
        for j in range(i+1, r+1):
            a = (i * j) % 2019
            if a < Min:
                Min = a
                if a == 0: # ここに注目
                    print(Min)
                    return
    print(Min)

l, r = map(int, input().split())
ABC133C(l, r)


Measured memory_bytes: 2940
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;

int main(){
	double r;
	double s, v;
	const static double pi = 4*atan(1.0);

	cin >> r;

	s = 2.0 * pi * r;
	v = 0.5 * s * r;

	printf("%.6f %.6f", v, s);

	return(0);
}

Measured memory_bytes: 1240
/*|In The Name Of Allah|*/

#include <bits/stdc++.h>

using namespace std;

const long longN = 1e2+5;

long long n;
long long k;
vector < pair < long long, long long> > xy;

long long getA(long long a , long long b , long long c , long long d){
    long long X1 = min( min(xy[a].first , xy[b].first) , min(xy[c].first , xy[d].first));
    long long X2 = max( max(xy[a].first , xy[b].first) , max(xy[c].first , xy[d].first));
    long long Y1 = min( min(xy[a].second , xy[b].second) , min(xy[c].second , xy[d].second));
    long long Y2 = max( max(xy[a].second , xy[b].second) , max(xy[c].second , xy[d].second));
    return (X2 - X1) * (Y2 - Y1);

}

long long getX(long long a , long long b , long long c , long long d){
    long long X1 = min( min(xy[a].first , xy[b].first) , min(xy[c].first , xy[d].first));
    long long X2 = max( max(xy[a].first , xy[b].first) , max(xy[c].first , xy[d].first));
    long long Y1 = min( min(xy[a].second , xy[b].second) , min(xy[c].second , xy[d].second));
    long long Y2 = max( max(xy[a].second , xy[b].second) , max(xy[c].second , xy[d].second));
    long long cntpoints = 0;
    for(long long i = 0; i < n; i++){
        if(X1 <= xy[i].first && xy[i].first <= X2 && Y1 <= xy[i].second && xy[i].second <= Y2)
            cntpoints++;
    }
    return cntpoints;
}

int main(){
    scanf("%lld%lld" , &n , &k);
    for(long long i = 1; i <= n; i++){
        long long x , y;
        cin >> x >> y;
        xy.push_back({x , y});
    }
    long long area = 1LL << 63 - 1;
    for(long long a = 0; a < n; a++){
        for(long long b = 0; b < n; b++){
            for(long long c = 0; c < n; c++){
                for(long long d = 0; d < n; d++){
                    if(getX(a , b , c , d) >= k){
                        area = min(area , getA(a , b , c , d));
                    }
                }
            }
        }
    }
    cout << area << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner vd = new Scanner(System.in);
		int n = vd.nextInt();
		int k = vd.nextInt();
		vd.close();
		int s = (int)Math.pow(k-1, n-1);
		System.out.println(k*s);

	}

}


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

#define ll long long
#define fast_io ios::sync_with_stdio(0); cin.tie(0)
#define infl 1e18L+9
#define inf 1e9L+9
#define sz(a) ((int)a.size())
#define all(a) a.begin(),a.end()

const int mod=1e9L+7; 

void solve(){
  int n; cin>>n; 
  int a[n], b[n], c[n]; 
  for(int i=0;i<n;i++) cin>>a[i]; 
  for(int i=0;i<n;i++) cin>>b[i]; 
  for(int i=0;i+1<n;i++) cin>>c[i]; 
  int ans=0; 
  ans+=b[a[0]-1];  
  for(int i=1;i<n;i++){
    ans+=b[a[i]-1]; 
    if(a[i]==a[i-1]+1){
      ans+=c[a[i-1]-1]; 
    }
  }
  cout<<ans<<endl; 
}

int main()
{
	fast_io;
	clock_t beg=clock(); 
	solve(); 
	clock_t end=clock(); 
	fprintf(stderr,"%.2lf sec\n",(double)(end-beg)/CLOCKS_PER_SEC); 
	return 0;
}

Measured memory_bytes: 256
val MOD = 1000000007

fun main(args : Array<String>) {
    val (n, k) = readLine()!!.split(" ").map { it.toLong() }
    val aa = readLine()!!.split(" ").map { it.toInt() }

    val later = IntArray(n.toInt()){0}
    val whole = IntArray(n.toInt()){0}

    for (i in aa.indices) {
        for (j in i+1 until n.toInt()) {
            if (aa[j] < aa[i]) {
                later[i] += 1
            }
        }
        whole[i] = aa.count { it < aa[i] }
    }

    var cnt = 0L

    for (i in aa.indices) {
        cnt += later[i] * k
        cnt %= MOD
        cnt += whole[i] * ((((k-1) * k) / 2L) % MOD)
        cnt %= MOD
    }

    println(cnt)
}

Measured memory_bytes: 39568
#include <iostream>
    	#include <string>
        using namespace std;
             
        int main(){
             string str;
             cin >> str;
             int count = 0;
             if(str[0] == '1') count++;
             if(str[1] == '1') count++;
             if(str[2] == '1') count++;
             cout << count << endl; 
             return 0; 
        }

Measured memory_bytes: 256
import itertools
import numpy as np
d_list = []
sum_d = 0
N, M, Q = map(int, input().split())
abcd = [list(map(int, input().split())) for i in range(Q)]
ans = 0
A = [1 for i in range(N)]
for A in itertools.combinations_with_replacement(range(1, M+1), N):
  for i in range(Q):
    a = abcd[i][0]
    b = abcd[i][1]
    c = abcd[i][2]
    d = abcd[i][3]
    if A[b-1]-A[a-1] == c:
      d_list.append(abcd[i][3])
  if sum_d <= sum(d_list):
    sum_d = sum(d_list)
  d_list.clear()
print(sum_d)

Measured memory_bytes: 26992
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;
using Graph = vector<vector<int>>;

int main(){
    int a, p; cin >> a >> p;
    int ans = (a * 3 + p) / 2;
    cout << ans << endl;
}

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

#define str(a) to_string(a)
#define int long long
#define pb push_back
#define mp make_pair
#define SORT(c) sort(c.begin(),c.end())
#define max_heap priority_queue<int>
#define min_heap priority_queue< int,vector<int>, greater<int> >
#define mod 1000000007
#define setbits(x) __builtin_popcount(x)
#define ps(x,y) fixed<<setprecision(y)<<x
#define start(t) int x;cin>>x;while(x--)
#define inf LLONG_MAX
#define sync ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define endl "\n"
#define N 1000001


int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    if (k <= a + b) {
        if (k <= a) {
            cout << 1 * k << endl;
        } else {
            cout << a << endl;
        }
    } else {
        int rem = k - (a + b);
        cout << a - rem << endl;
    }

}



Measured memory_bytes: 3656
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<utility>
#include<numeric>

using namespace std;

int main()
{
    int N, M, a, b;
    cin >> N >> M;
    vector<int> Height(N, 0);
    vector<int> answer(N, 1);

    for(int i=0;i<N;i++){
        cin >> Height[i];
    }

    for(int i=0;i<M;i++){
        cin >> a >> b;
        if(Height[a-1] > Height[b-1]){
            answer[b-1] = 0;
        }else if(Height[a-1] < Height[b-1]){
            answer[a-1] = 0;
        }else{
            answer[a-1] = answer[b-1] = 0;
        }
    }

    cout << accumulate( answer.begin(), answer.end(), 0) << endl;

    return 0;
}


Measured memory_bytes: 4052
def E_dijkstra(V,AL,S):
    from heapq import heappush,heappop
    INF=float('inf')
    ans=[INF]*V
    ans[S]=0
    used=[0]*V # 0:未確定
    used[S]=1
    que=[]
    for i in range(V):
        heappush(que,(ans[i],i))
    while que:
        x,u=heappop(que)
        used[u]=1
        for v,w in AL[u]:
            if not used[v] and ans[v]>x+w:
                ans[v]=x+w
                heappush(que,(ans[v],v))
    return ans

import sys
input = sys.stdin.readline

V,E,R=map(int,input().split())
AL=[[] for i in range(V)]
for _ in range(E):
    S,T,D=map(int,input().split())
    AL[S].append((T,D))

for ans in E_dijkstra(V,AL,R):
    print('INF' if ans==float('inf') else ans)


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

int main() {
	// your code goes here
	int a,b,c;
	cin>>a>>b>>c;
	if((abs(b-c))&1){
		cout<<"Borys"<<endl;
	}
	else{
		cout<<"Alice"<<endl;
	}
	return 0;
}

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

bool A[1000000 + 10];
int B[200000 + 10];

int main()
{
	int n;
	std::cin >> n;
	for (int i = 0; i < n; ++i)
	{
		std::cin >> B[i];
	}

	std::sort(&B[0], &B[n]);

	if (n <= 0) exit(1);
	int maxN = B[n - 1];
	int ans = 0;
	
	for (int i = 0; i < n; ++i)
	{
		if (A[B[i]]) continue;
		if ((i + 1) >= n || B[i] != B[i + 1])
		{
			++ans;
		}
		for (int j = B[i]; j <= maxN; j += B[i])
		{
			A[j] = true;
		}
	}

	std::cout << ans << std::endl;

	return 0;
}


Measured memory_bytes: 5180
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<cmath>
#include<ctime>
#include<complex>

using namespace std;

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

int main(){

	int x,y; string s;

	cin >> y;
	for(int i=0;;i++){

	cin >> s;
	if(s=="="){
		cout << y << endl;
		break;
	}
	else{
	cin >> x;
	if(s=="+") y+=x;
	if(s=="-") y-=x;
	if(s=="*") y*=x;
	if(s=="/") y/=x;
	}
	}

	return 0;
}

Measured memory_bytes: 1204
N = int(input())
Ss = input().split()
res = 1
for t in range(1, N+1):
	if (N%t != 0): continue
	f = False
	for i in range(N-t):
		if (Ss[i] == Ss[i + t]): continue
		f = True
		break
	if (f): continue
	res = N // t
	break

print(res)


Measured memory_bytes: 20700
# coding: utf-8

def check_divide(n):
    max_v = int(n ** (1/2))
    divide_nums = []
    for i in range(1,max_v + 1):
        if n % i == 0:
            divide_nums.append(i)
    return divide_nums

def check_divide2(n):
    divide_nums = []
    for K in range(2,n+1):
        tmp = n
        while True:
            if tmp % K ==0:
                tmp = tmp // K
            else:break
        if tmp % K == 1:
            divide_nums.append(K)
    return divide_nums

if __name__ == '__main__':
    N = int(input())
    tmp1 = check_divide(N-1)
    if tmp1[-1] ** 2 == N-1:
        tmp1 = len(tmp1) * 2 - 2
    else:
        tmp1 = len(tmp1) * 2 - 1

    candidates = check_divide(N)[1:]

    tmp2 = [N]
    for val in candidates:
        N_ = N
        while True:
            if N_ % val == 0:
                N_ = N_ / val
            else:break
        if N_ % val == 1:
            tmp2.append(val)
    tmp2 = len(tmp2)
    print(tmp1 + tmp2)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(s,i, n) for (int i = (int)s; i < (int)(n); i++)
int N;
string s;
int input(){
    cin>>s;
    return 0;
}

int output(){
    
    return 0;
}

int compute(){
    return 0;
}

int main(){
    input();
    if(s=="AAA")cout<<"No"<<endl;
    else if(s=="BBB")cout<<"No"<<endl;
    else{
        cout<<"Yes"<<endl;
    }
    output();

}

Measured memory_bytes: 256
import sys
import math
import collections
import itertools
import array
import inspect

# Set max recursion limit
sys.setrecursionlimit(10000)


# Debug output
def chkprint(*args):
    names = {
        id(v): k
        for k, v in inspect.currentframe().f_back.f_locals.items()
    }
    print(', '.join(
        names.get(id(arg), '???') + ' = ' + repr(arg) for arg in args))


# Binary converter
def to_bin(x):
    return bin(x)[2:]


def li_input():
    return [int(_) for _ in input().split()]


# --------------------------------------------

dp = None


def main():
    N = int(input())
    L = [105, 135, 165, 189, 195]

    if N < 105:
        print(0)
    elif N < 135:
        print(1)
    elif N < 165:
        print(2)
    elif N < 189:
        print(3)
    elif N < 195:
        print(4)
    else:
        print(5)


main()


Measured memory_bytes: 5140
#include <bits/stdc++.h>
#define mset(a,b) memset(a,b,sizeof a)
#define mcpy(a,b) memcpy(a,b,sizeof b)
#define swap(a,b) a^=b^=a^=b
#define lb(x) ((x)&(-(x)))
#define dalao 1000000007
#define inf 0x3f3f3f3f
#define N 100010
using namespace std;
typedef long long ll;
ll a,b,c,ta,tb,tc;
int main(){
	cin>>a>>b>>c;
	for(int i=0;i<20000000;i++){
		if((a&1)||(b&1)||(c&1))return printf("%d",i),0;
		ta=(b+c)>>1,tb=(a+c)>>1,tc=(a+b)>>1;
		a=ta,b=tb,c=tc;
	}
	puts("-1");
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int cmp(const void *a, const void *b){
    return (strcmp((char *)a,(char *)b));
}


int main(){
    int N;
    char s[200000][11];
    scanf("%d",&N);
    for(int i = 0 ; i < N ; i++){
        scanf("%s",&s[i]);
    }
    qsort((void*)s,N,sizeof(s[0]),cmp);
    int max=0,cnt=0;
    for(int i = 0 ; i < N ; i++){
      cnt++;
      if(max < cnt){
        max = cnt;
      }
      if(i != N -1){
        if(strcmp(s[i],s[i+1]) != 0){
          cnt = 0;
        }
      }
    }


    cnt = 0;
    for(int i = 0 ; i < N ; i++){
      cnt++;
      if(cnt == max){
        printf("%s\n",s[i]);
      }
      if(i != N -1){
        if(strcmp(s[i],s[i+1]) != 0){
          cnt = 0;
        }
      }
    }

    return 0;

}


Measured memory_bytes: 4476
#include <bits/stdc++.h>
using namespace std;
const long long inf=1e10;
long long n, w, V=0, dp[100005], wi[105], vi[105];
 
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie();
	cout.tie();
	cin >> n >> w;
	for(int i=1;i<=n;i++){
		cin >> wi[i] >> vi[i];
		V+=vi[i];
	}
	for(int i=0;i<=V;i++){
		dp[i]=inf;
	}
	dp[0]=0;
	for(int i=1;i<=n;i++){
		for(int j=V;j>=vi[i];j--){
			dp[j]=min(dp[j], dp[j-vi[i]]+wi[i]);
		}
	}
	for(int i=V;i>=0;i--){
		if(dp[i]<=w){
			cout << i << endl;
			return 0;
		}
	}
}

Measured memory_bytes: 1024