akhauriyash/Code-Regression huggingface dataset:
import sys, math, collections, heapq, itertools
F = sys.stdin
def single_input(): return F.readline().strip("\n")
def line_input(): return F.readline().strip("\n").split()
def gcd(a, b):
    a, b = max(a, b), min(a, b)
    while a % b > 0:
        a, b = b, a % b
    return b
  
def solve():
    A, B = map(int, line_input())
    grid = [[] for i in range(100)]
    for i in range(50):
        grid[i] = ["#"] * 100
        grid[50 + i] = ["."] * 100

    for a in range(A-1):
        w = a % 25
        h = a // 25
        if h % 2 == 0: grid[h][4 * w] = "."
        else: grid[h][4 * w + 2] = "."

    for b in range(B-1):
        w = b % 25
        h = b // 25
        if h % 2 == 0: grid[51 + h][4 * w] = "#"
        else: grid[51 + h][4 * w + 2] = "#"

    print(100, 100)
    for h in range(100):
        print("".join(map(str, grid[h])))

if __name__ == "__main__":
    solve()

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

using namespace std;

int main(void){
	string str, peach = "peach", apple = "apple";
	getline(cin,str);
	for(int i = 0;i < str.size();i++){
		int j;
		for(j = 0;j < 5;j++){
			if(str[i + j] != peach[j]){
				break;
			}
		}
		if(j == 5){
			for(j = 0;j < 5;j++){
				str[i + j] = apple[j];
			}
			continue;
		}
		for(j = 0;j < 5;j++){
			if(str[i + j] != apple[j]){
				break;
			}
		}
		if(j == 5){
			for(j = 0;j < 5;j++){
				str[i + j] = peach[j];
			}
		}
	}
	cout << str << endl;
	return 0;
}

Measured memory_bytes: 1180
from collections import defaultdict
S = list(input())
T = list(input())
l = len(S)
ds = defaultdict(str)
dt = defaultdict(str)
for i in range(l):
    if ds[S[i]] == "":
        ds[S[i]] = T[i]
    elif ds[S[i]] == T[i]:
        pass
    else:
        print('No')
        exit()
    if dt[T[i]] == "":
        dt[T[i]] = S[i]
    elif dt[T[i]] == S[i]:
        pass
    else:
        print('No')
        exit()

print('Yes')

Measured memory_bytes: 6960
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    s = input()
    n = len(s)

    if (n % 2 == 0) ^ (s[0] == s[-1]):
        print("Second")
    else:
        print("First")


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 3316
def getInts():
    return [ int(x) for x in input().split() ]

[N,K] = getInts()
haveSnak = set()
for i in range(K):
    [d] = getInts()
    xs = getInts()
    for x in xs:
        haveSnak.add(x)
count = 0
for i in range(1,N+1):
    if i not in haveSnak:
        count += 1
print(count)

Measured memory_bytes: 9148
using System;

class Program
{
    static void Main(string[] args)
    {
        var n = int.Parse(Console.ReadLine());
        var L = new long[n + 1];
        L[0] = 2;
        L[1] = 1;
        for (int i = 2; i < n + 1; i++)
        {
            L[i] = L[i - 1] + L[i - 2];
        }
        Console.WriteLine(L[n]);
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)n; ++i)
#define all(obj) (obj).begin(), (obj).end()
static const int dx[4] = { 0, 1, 0, -1 };
static const int dy[4] = { 1, 0, -1, 0 };
static const char dir[4] = { 'u', 'r', 'd', 'l' };
static const ll INF = 1 << 21;
static const ll MOD = 1e9 + 7;

bool isPrime(int num)
{
    if (num < 2)
        return false;
    else if (num == 2)
        return true;
    else if (num % 2 == 0)
        return false;

    for (int i = 3; i * i <= num; i += 2) {
        if (num % i == 0) {
            return false;
        }
    }
    return true;
}

signed main()
{
    ll X;
    cin >> X;
    while (true) {
        if (isPrime(X)) {
            cout << X << endl;
            return 0;
        }
        ++X;
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef pair<int,int> pii;

int main(void) {
  int i,j;
  int n;
  while(1){
    cin>>n;
    if(n<0)break;
    int a=1150;
    n-=10;
    if(n>0){
      a+=125*min(10,n);
      n-=10;
    }
    if(n>0){
      a+=140*min(10,n);
      n-=10;
    }
    if(n>0){
      a+=160*n;
    }
    cout<<4280-a<<endl;
  }
}

Measured memory_bytes: 3060
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 C = sc.nextInt();
		int X = sc.nextInt();
		int Y = sc.nextInt();
		int ans = 0;
		if(A + B <= C*2)
			ans = A*X + B*Y;
		else {
			if(X >= Y) {
				ans = Math.min(A*(X-Y) + 2*C*Y, 2*C*X);
			}
			else {
				ans = Math.min(2*C*X + B*(Y-X), 2*C*Y);
			}
		}
		System.out.println(ans);

	}

}

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

public class Main {
    void run() {
        Scanner sc = new Scanner(System.in);
        char x = sc.next().charAt(0);
        char y = sc.next().charAt(0);

        System.out.println(x == y ? "=" : x < y ? "<" : ">");

    }

    void debug(Object... os) {
        System.err.println(Arrays.deepToString(os));
    }

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


Measured memory_bytes: 22996
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
typedef int long long ll;

using namespace std;
int main(){

    ll n;
    while(cin>>n){
        vector<bool> ip;
        if(ip.size()<n+1){
            ip.resize(n+1,true);
        }
        ip[0]=false;
        ip[1]=false;
        for(int i=2;i<n+1;i++){
            for(int j=2;i*j<n+1;j++){
                ip[i*j]=false;
            }
        }
        ll ans=0;
        for(int i=0;i<n+1;i++){
            if(ip[i])ans++;
        }
        
        
        cout<<ans<<endl;
        
        
        
    }





return 0;
}



Measured memory_bytes: 3248
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


n = int(input())

M = 10**9+7 # 出力の制限
N = n+3 # 必要なテーブルサイズ

g1 = [None] * (N+1) # 元テーブル
g2 = [None] * (N+1) #逆元テーブル
inverse = [None] * (N+1) #逆元テーブル計算用テーブル
g1[0] = g1[1] = g2[0] = g2[1] = 1
inverse[0], inverse[1] = [0, 1] 

for i in range( 2, N + 1 ):
    g1[i] = ( g1[i-1] * i ) % M 
    inverse[i] = ( -inverse[M % i] * (M//i) ) % M # ai+b==0 mod M <=> i==-b*a^(-1) <=> i^(-1)==-b^(-1)*aより
    g2[i] = (g2[i-1] * inverse[i]) % M 

def cmb(n, r, M):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return (g1[n] * g2[r] * g2[n-r]) % M
ans = 0
prev = 0
# s = 0
for i in range((n+1)//2, n):
    tmp = (cmb(i-1, n-i-1, M) * g1[i] * g1[n-1-i])
    ans += i*(tmp-prev)
    prev = tmp
#     print(i, tmp, g1[i], g1[n-1-i])
    ans %= M
print(ans)

Measured memory_bytes: 144432
# coding: utf-8
import sys
import numpy as np
from collections import Counter

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

MOD = 10 ** 9 + 7
# 素因数分解をして、それぞれの因数をどこに入れるか

def cmb(n, k):
    if k < 0 or k > n: return 0
    return fact[n] * fact_inv[k] % MOD * fact_inv[n-k] % MOD

def cumprod(arr, MOD):
    L = len(arr); Lsq = int(L**.5+1)
    arr = np.resize(arr, Lsq**2).reshape(Lsq, Lsq)
    for n in range(1, Lsq):
        arr[:, n] *= arr[:, n-1]; arr[:, n] %= MOD
    for n in range(1, Lsq):
        arr[n] *= arr[n-1, -1]; arr[n] %= MOD
    return arr.ravel()[:L]

def make_fact(U, MOD):
    x = np.arange(U, dtype=np.int64); x[0] = 1
    fact = cumprod(x, MOD)
    x = np.arange(U, 0, -1, dtype=np.int64); x[0] = pow(int(fact[-1]), MOD-2, MOD)
    fact_inv = cumprod(x, MOD)[::-1]
    return fact, fact_inv

U = 10 ** 5 + 100  # 階乗テーブルの上限
fact, fact_inv = make_fact(U, MOD)

def prime_factorize(n): # Nの素因数分解
    A = []
    while n % 2 == 0:
        A.append(2); n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            A.append(f); n //= f
        else:
            f += 2
    if n != 1:
        A.append(n)
    return A

N, M = lr()
primes = prime_factorize(M)
counter = Counter(primes)
answer = 1
for v in counter.values():
    cases = cmb(N-1+v, v)
    answer *= cases
    answer %= MOD

print(answer % MOD)
# np.int64とint型の違いに注意
# 16

Measured memory_bytes: 16400
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <array>
#include <set>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

struct P {
    bool operator<(const P &p) const {
        return s < p.s;
    }
    ll s;
    array<int16_t, 3> i;
};

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

    int x[3], k;
    for (int h = 0; h < 3; h++) {
        cin >> x[h];
    }
    cin >> k;

    vector<ll> a[3];
    for (int h = 0; h < 3; h++) {
        a[h] = vector<ll>(x[h]);
        for (int i = 0; i < x[h]; i++) {
            cin >> a[h][i];
        }
        sort(a[h].begin(), a[h].end(), greater<>());
    }

    set<array<int16_t, 3>> st;
    priority_queue<P> pq;
    pq.push({ a[0][0] + a[1][0] + a[2][0], 0, 0, 0 });

    while (k--) {
        P p = pq.top(); pq.pop();
        cout << p.s << '\n';
        for (int h = 0; h < 3; h++) {
            P q = p;
            if (++q.i[h] >= x[h]) continue;
            q.s += a[h][q.i[h]] - a[h][p.i[h]];
            if (st.count(q.i)) continue;
            pq.push(q);
            st.insert(q.i);
        }
    }
    cout << flush;

    return 0;
}

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

int main() {
  string s;
  cin >> s;
  int count = 0;
  for (int i = 0; i < 4; i++) {
    if (s.at(i) == '2') {
      count++;
    }
  }
  cout << count << endl;
}


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

int main(){
    int a,b;
    cin >> a >> b;
    int r=0;
    for(int i=a;i<=b;i++){
        int s=i%10,t=i/10000;
        int u=i/10%10,v=i/1000%10;
        if(s==t&&u==v)r++;
    }
    cout << r << endl;
}

Measured memory_bytes: 256
H,W,N=map(int,input().split())
X=[0 for i in range(N)]
Y=[0 for i in range(N)]
D={}
for i in range(N):
    X[i],Y[i]=map(int,input().split())
    if X[i] in D:
        D[X[i]].add(Y[i])
    else:
        D[X[i]]={Y[i]}
ans=H
left=1;right=1
for x in range(2,H+1):
    if not(x in D):
        right=min(right+1,W)
    else:
        first=min(D[x])
        if left<=first and first<=right:
            ans=min(ans,x-1)
            break
        if first!=right+1:
            right=min(right+1,W)
print(ans)

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

int main() {
  int w, h, x, y;
  cin >> w >> h >> x >> y;
  double ans = (double)w*h/2;
  int num = (w==x*2 && h==y*2) ? 1 : 0;
  printf("%.10f %d\n", ans, num);
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		//		new Main().solveA();
		new Main().solveB();
		// new Main().solveC();
		// new Main().solveD();
	}

	private void solveA() {
		Scanner scanner = null;
		int numA = 0;
		int numB = 0;
		int numC = 0;
		int numD = 0;

		try {
			scanner = new Scanner(System.in);
			numA = scanner.nextInt();
			numB = scanner.nextInt();
			numC = scanner.nextInt();
			numD = scanner.nextInt();

			boolean canTalk = false;

			canTalk = ((Math.abs(numA - numB) <= numD && Math.abs(numB - numC) <= numD)
					|| Math.abs(numA - numC) <= numD);

			System.out.println(canTalk ? "Yes" : "No");

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private void solveB() {
		Scanner scanner = null;
		int numX = 0;

		try {
			scanner = new Scanner(System.in);
			numX = scanner.nextInt();

			int max = 0;
			for (int i = 1; i <= numX; i++) {
				for (int j = 2; j < 10; j++) {
					if (Math.pow(i, j) <= numX) {
						max = Math.max(max, (int) Math.pow(i, j));
					} else {
						break;
					}
				}
			}

			System.out.println(max);
		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private void solveC() {
		Scanner scanner = null;
		int numN = 0;
		int numK = 0;
		int numS = 0;

		try {
			scanner = new Scanner(System.in);
			numN = scanner.nextInt();

			System.out.println("");

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private void solveD() {
		Scanner scanner = null;
		int numN = 0;
		int numK = 0;
		int numS = 0;

		try {
			scanner = new Scanner(System.in);
			numN = scanner.nextInt();

			System.out.println("");

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}
}

Measured memory_bytes: 23764
// #define _GLIBCXX_DEBUG
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
using ll = long long; using ull = unsigned long long;
using pii = pair<int, int>; using vi = vector<int>; using vvi = vector<vi>; using puu = pair<uint, uint>; using vu = vector<uint>; using vvu = vector<vu>;
using pll = pair<ll, ll>; using vl = vector<ll>; using vvl = vector<vl>; // using pulul = pair<ull, ull>; using vul = vector<ull>; using vvul = vectro<vul>;
using vb = vector<bool>; using vvb = vector<vb>;
#define rep0(TMS) for (int CNT = 0; CNT < (int)(TMS); CNT++)
#define rep(CNT, GOAL) for (int CNT = 0; CNT < (int)(GOAL); CNT++)
#define rep2(CNT, START, GOAL) for (int CNT = (int)(START); CNT < (int)(GOAL); CNT++)
#define rep3(CNT, START, GOAL) for (int CNT = (int)(START); CNT > (int)(GOAL); CNT--)
#define all(CONT) begin(CONT), end(CONT)
template <typename T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template <typename T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }
void prec(const int &DIG) { cout << fixed << setprecision(DIG); cerr << fixed << setprecision(DIG); }
template <typename T> void CERR(const T &ELEM) { cerr << ELEM; }
#define dbl(OBJ) cerr << #OBJ << ": "; CERR(OBJ); cerr << "\n"
template <typename T, typename ...Ts> void CERR(const T &FIRST, const Ts &...REST) { CERR(FIRST); cerr << ", "; CERR(REST...); }
#define dbs(...) cerr << "(" << #__VA_ARGS__ << "): ("; CERR(__VA_ARGS__); cerr << ")\n"
#define itrep(ITR, CONT) for (auto ITR = begin(CONT); ITR != end(CONT); ITR++)
template <typename T> void CERR(const vector<T> &VEC) { cerr << "{ "; itrep(ITR, VEC) { CERR(*ITR); cerr << ", "; } cerr << "}"; }
#define YN(FLG) cout << (FLG ? "YES" : "NO") << "\n"
#define Yn(FLG) cout << (FLG ? "Yes" : "No") << "\n"
#define yn(FLG) cout << (FLG ? "yes" : "no") << "\n"

// #include <atcoder/all>

// using namespace atcoder;

// const ll INF = LONG_LONG_MAX;
const int INF = INT_MAX;
// const ll MOD = 1000000007; // 998244353;

int main() {
	int N, x; cin >> N >> x;
	if (x == 1 or x == 2 * N - 1) {
		cout << "No" << endl;
		return 0;
	} else cout << "Yes" << endl;
	vi v(2 * N - 1); rep(i, 2 * N - 1) v[i] = i + 1;
	// 中央の3要素v[N-2],v[N-1],v[N]を1,x,2N-1とする。
	// それ以外の要素(2~x-1,x+1~2N-2)は，左グループの要素 < 右グループの要素 となるように並べる。
	// { 1, 2,.., N-2; N-1, N, N+1; N+2,.., 2N-2, 2N-1 } を
	// { 1, 2,..,x-1, N, x+1,..; N-1, x, N+1; N+2,.., 2N-1 } とし，
	// { N-1, 2,..,x-1, N, x+1,..; 1, x, 2N-1; N+2,.., N+1 } とする。
	// dbl(v);
	swap(v[x - 1], v[N - 1]);
	// dbl(v);
	swap(v[0], v[N - 2]);
	// dbl(v);
	swap(v[N], v[2 * N - 2]);
	// dbl(v);
	rep(i, 2 * N - 1) cout << v[i] << endl;
}

Measured memory_bytes: 4008
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <complex>
using namespace std;

typedef long long ll;
typedef pair<int,int> P;

#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp make_pair
#define ERASE(v,i) (v).erase(remove(all(v),i),(v).end())
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define each(c,it) for(typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
#define debug(x) cerr<<#x<<" = "<<(x)<<endl;
#define LINE cerr<<"LINE: "<<__LINE__<<endl;

inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class T> void preview(T a,T b){for(T it=a;it!=b;++it)cerr<<*it<<" ";cerr<<endl;}

const int INF = 100000000;
const double PI = acos(-1.0), EPS = 1e-10;

int main() {
	static bool p[1000001];
	memset(p, true, sizeof p);
	p[0] = p[1] = false;
	vector<int> sum;
	for(int j = 4; j <= 1000000;j+=2) p[j] = false;
	sum.pb(2);
	for(int i = 3; i <= 1000000; i++) {
		if(p[i]) {
			sum.pb(i + *sum.rbegin());
			if(i * i <= 1000000) {
				for(int j = 2*i;j<= 1000000;j+=i)
					p[j] = false;
			}
		}
	}
	for(int n; cin >> n, n;) cout << sum[n-1] << endl;
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define all(obj) (obj).begin(),(obj).end() 
#define dump(x)  cout << #x << " = " << (x) << endl;
typedef long long lint;
using namespace std;
int main(){
	int a,b,c;
	cin>>a>>b>>c;
	cout<<a*b*c/(2*max({a,b,c}))<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define F first
#define S second
#define PB push_back
#define REP(i,a,b) for (int i = a ; i <= b ; i++)
#define REPI(i,a,b) for (int i = a ; i >= b ; i--)
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

const ll OO = 1e18+7;
const int MOD = 1e9+7;
const int N = 3e3+7;
int n;
ll dp[N][N][2];
ll a[N];

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    //freopen("teleport.in","r",stdin);
    //freopen("teleport.out","w",stdout);

    cin >> n;
    REP(i,0,n-1) cin >> a[i];

    // dp[l][r][p] = min/max value of X-Y of range [l,r] if p start
    // p == 0 : max
    // p == 1 : min

    REP(i,0,n-1) dp[i][i][1] = -a[i],dp[i][i][0] = a[i];

    REP(len,1,n-1)
    {
        REP(l,0,n-1)
        {
            int r = l+len;
            if (r > n-1) break;

            dp[l][r][0] = max(dp[l+1][r][1]+a[l],dp[l][r-1][1]+a[r]);
            dp[l][r][1] = min(dp[l+1][r][0]-a[l],dp[l][r-1][0]-a[r]);
        }
    }
    cout << dp[0][n-1][0] << endl;
    return 0;
}


Measured memory_bytes: 141568
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define debug(x) cout << #x << '=' << x << '\n'
const long long MOD=1e9+7;
//const long long MOD=998244353;
const int INF=1e9;
const long long IINF=1e18;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const char dir[4]={'D','R','U','L'};

template<typename T>
istream &operator>>(istream &is,vector<T> &v){
    for (T &x:v) is >> x;
    return is;
}
template<typename T>
ostream &operator<<(ostream &os,const vector<T> &v){
    for (int i=0;i<v.size();++i){
        os << v[i] << (i+1==v.size()?'\n':' ');
    }
    return os;
}
template<typename T,typename U>
ostream &operator<<(ostream &os,const pair<T,U> &p){
    cout << '(' << p.first << ',' << p.second << ')';
    return os;
}

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll A,B,N; cin >> A >> B >> N;
    ll x=(B<=N?N/B*B-1:N);
    cout << (A*x)/B-A*(x/B) << '\n';
}

Measured memory_bytes: 3636
from collections import defaultdict
n,m=map(int,input().split())
A=list(map(int,input().split()))
hon2=[1]
hon5=[2,3,5]
hon4=[4]
hon3=[7]
hon6=[6,9]
hon7=[8]
usenum=[]
usematch=defaultdict(int)
for a in A:
    if a in hon2:
        usenum.append(2)
        usematch[2]=max(a, usematch[2])
    if a in hon5:
        usenum.append(5)
        usematch[5]=max(a, usematch[5])
    if a in hon4:
        usenum.append(4)
        usematch[4]=max(a, usematch[4])
    if a in hon3:
        usenum.append(3)
        usematch[3]=max(a, usematch[3])
    if a in hon6:
        usenum.append(6)
        usematch[6]=max(a, usematch[6])
    if a in hon7:
        usenum.append(7)
        usematch[7]=max(a, usematch[7])
usenum=list(set(usenum))
usenum.sort()
dp=[-1]*(n+11)
dp[0]=0
for i in range(n+1):
    if dp[i]==-1:
        continue
    for num in usenum:
        dp[i+num]=max(10*dp[i]+usematch[num], dp[i+num])
print(dp[n])

Measured memory_bytes: 15084
#include <bits/stdc++.h>
using namespace std;
#define loop(i,N) for(int i=0; i<(N); i++)
template<typename T>
auto sum_all(const T& v) { auto z = v[0]; z = 0;
    return std::accumulate(v.begin(),v.end(),z); }

int main(void)
{
    unsigned int L;
    cin >> L;
    vector<int> v;
    auto K = L;
    while (K > 1) {
        v.push_back(K & 1);
        K >>= 1;
    }
    const unsigned int N = v.size() + 1;
    unsigned int unit = 1, val = L;
    unsigned int M = 2*(N-1) + sum_all(v);

    cout << N << " " << M << endl;
    loop(i, N-1) {
        val -= unit*v[i];
        cout << i+1 << " " << i+2 << " " << 0 << endl;
        cout << i+1 << " " << i+2 << " " << unit << endl;
        if (v[i] == 1) {
            cout << i+1 << " " << N << " " << val << endl;
        }
        unit *= 2;
    }

    return 0;
}

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

int main()
{
  int n;
  std::cin >> n;
  std::vector<int> a(n);
  for(int i = 0; i < n; i++)std::cin >> a[i];
  int cnt = 0;
  int max = a[0];
  for(int i = 0; i < n; i++){
    if(a[i] >= max)cnt++;
    max = std::max(max, a[i]);
  }
  std::cout << cnt << std::endl;
}

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

using namespace std;

int main()
{
    int n;
    scanf("%d",&n);
    map<int,int> m;
    for(int i=0;i<n;i++)
    {
        int a;
        scanf("%d",&a);
        if(m.find(a)!=m.end()) m[a]++;
        else m.insert(make_pair(a,1));
    }
    if(m.size()>3)
    {
        printf("No\n");
        return 0;
    }
    if(m.size()==1)
    {
        pair<int,int> p=*m.begin();
        if(p.first==0) printf("Yes\n");
        else printf("No\n");
        return 0;
    }
    bool res=0;
    vector<int> v;
    for(pair<int,int> p:m) v.push_back(p.first);
    int sz=v.size();
    do
    {
        int arr[n];
        map<int,int> t;
        for(int i=0;i<sz;i++) arr[i]=v[i];
        for(int i=sz;i<n;i++) arr[i]=arr[i-2]^arr[i-1];
        for(int i=0;i<n;i++)
        {
            int a=arr[i];
            if(t.find(a)!=t.end()) t[a]++;
            else t.insert(make_pair(a,1));
        }
        bool ok=1;
        for(int i=0;i<n;i++) if((arr[i]^arr[(i+1)%n])!=arr[(i+2)%n]) ok=0;
        if(m!=t) ok=0;
        if(ok) res=1;
    } while(next_permutation(v.begin(),v.end()));
    if(res) printf("Yes\n");
    else printf("No\n");
    return 0;
}


Measured memory_bytes: 3840
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<map>
#include<math.h>
const long long INF = 1LL << 60;
using namespace std;

int main() {
    int N;
    cin >> N;
    vector<int> h(N);
    for (int i = 0; i < N; i++) {
        cin >> h.at(i);
    }
    long long dp[100100];
    for (int i = 0; i < 100100; i++) {
        dp[i] = INF;
    }
    dp[0] = 0;
    dp[1] = abs(h.at(1) - h.at(0));
    for (int i = 2; i < N; i++) {
        long long d1 = dp[i-1] + abs(h.at(i) - h.at(i-1));
        long long d2 = dp[i-2] + abs(h.at(i) - h.at(i-2));
        dp[i] = min(dp[i],d1);
        dp[i] = min(dp[i],d2);
    }
    cout << dp[N-1] << endl;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,x,h,ans=0;
	cin>>n>>x;
	int f[n];
	f[0]=0;
	for(int i=0;i<n;i++)
	{
		cin>>h;
		f[i+1]=f[i]+h;
	}
	for(int i=0;i<=n;i++)
	{
		if(f[i]<=x)
		{
			ans++;
		}
		else
			break;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ls rt<<1
#define rs rt<<1|1
#define lson rt<<1,l,M
#define rson rt<<1|1,M+1,r
#define PI acos(-1)
#define MM int M=(l+r)>>1;
#define fu(i,r,t) for(int i=r;i<=t;i++)
#define fd(i,r,t) for(int i=r;i>=t;i--)
#define fh(i,be,e) for(int i=head[be];~i;i=e[i].next)
#define fa(i,V) for(auto i:V)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long
#define endl '\n'
#define lcm(a,b) (a*b)/__gcd(a,b)
#define cp(i,ans) printf("%.if",ans);
#define cpp(i,ans) cout<<setprecision(i)<<fixed<<ans<<endl;
#define ppb pop_back
#define ppf pop_front
#define pb push_back
#define pf push_front
#define pq priority_queue
#define lowbit(x) (x)&(-x)
#define all(V) V.begin(),V.end()
#define ms multiset
#define mod(x) ((x+mo_num)%mo_num)
#define vc vector
#define vct vector<int>
#define out(i) cout<<(i)<<endl;
#define fi first
#define se second
#define fun(i) fu(i,1,n)
#define fut(i) fu(i,1,t)
#define fum(i) fu(i,1,m)
#define ld long double
#define umap unordered_map
#define P pair<int,int>
#define SET set<int>
#define mp map<int,int>
#define mk make_tuple
#define low lower_bound
#define upp upper_bound
#define yn(key) out(key?"YES":"NO")
#define in(i) i+1,i+1+n
#define im(i) i+1,i+1+m
#define bffs(i) __builtin_ffs(i)
#define bcount(i) __builtin_popcount(i)
#define bone(i) ((1<<i)-1)
using namespace std;
const int INF=LLONG_MAX-1e10;
const int dx[]={0,0,-1,1},dy[]={-1,1,0,0};//up down left right
const int maxn=1e6+1e5;
const int mo_num=1e9+7;
int n,m,t,a[maxn],b[maxn],ans;

main()
{
    IOS
    cin>>n;
    double h=1.01;
    int num=100;
    int i=1;
    for(;;i++)
    {
        num*=h;
        if(num>=n)break;
    }
    out(i)

    return 0;
}


Measured memory_bytes: 3644
#include<cstdio>
#include<cmath>
using namespace std;
int main(){
    int k,s,i,j;
    while(~scanf("%d%d",&k,&s)){
        long long ans=0;
        for(j=0;j<=k;j++){
            for(i=0;i<=k;i++){
                if(s-j-i<=k&&s-j-i>=0){
                    ans++;
                }
            }
        }
        printf("%lld\n",ans);
    }
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
  int x;
  cin>>x;
  set<int> s;

  //setに1000以下のべき乗数を全て用意
  for(int i=1;i<=31;i++){
    for(int j=2;j<=9;j++){
      int a=i;
      for(int k=0;k<j-1;k++) a*=i;
      if(1000<a) break;
      s.insert(a);
    }
  }

  //x以下の最大べき乗数を出力する
  auto itr = s.end();
  itr--;
    while (1) {
      if(*itr<=x){ cout<<*itr; return 0; }
      if(itr==s.begin()) break;
      itr--;
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<map>
#include<string>
#include<sstream>
using namespace std;
int inf = 1000000000;

int main(){

  string s; cin >> s;
  int cnt = 0;
  for(int i=0; i<4; i++) {
    if(s[i]=='+') cnt++;
    else cnt--;
  }
  cout << cnt << endl;

  return 0;
}



//


Measured memory_bytes: 256
import java.util.Random;
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        String str;
        Random random = new Random();
        int j,i,res;
        int[] x = new int[6];
        int[] y = new int[6];
        str = scan.nextLine();
        String[] num = str.split(" ", 0);
        for(i = 0; i < 6; i++){
            x[i] = Integer.valueOf(num[i]);
        }
        str = scan.nextLine();
        num = str.split(" ", 0);
        res = 0;
        for(i = 0; i < 6; i++){
            y[i] = Integer.valueOf(num[i]);
        }

        for(i = 0; i < 10000; i++){
            if(x[0]==y[0]&&x[1]==y[1]&&x[2]==y[2]&&x[3]==y[3]){
                res = 1;
                break;
            }
            turn(x,random.nextInt(4));
        }
        if(res == 1){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }

        scan.close();
    }

    static void set(int[] x,int a,int b,int c,int d,int e,int f){
        x[0] = a;
        x[1] = b;
        x[2] = c;
        x[3] = d;
        x[4] = e;
        x[5] = f;
    }
    static void turn(int[] x,int i){
        switch (i){
            case 0:
                set(x,x[4],x[0],x[2],x[3],x[5],x[1]);
                break;
            case 1:
                set(x,x[3],x[1],x[0],x[5],x[4],x[2]);
                break;
            case 2:
                set(x,x[2],x[1],x[5],x[0],x[4],x[3]);
                break;
            case 3:
                set(x,x[1],x[5],x[2],x[3],x[0],x[4]);
                break;
        }
    }
}



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

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define REP(i,n) FOR(i,0,n)
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using mii = map<int, int>;
using msi = map<string, int>;
using pii = pair<int, int>;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h, w, a, b;
    cin >> h >> w >> a >> b;
    FOR(i, 1, h + 1) {
        FOR(j, 1, w + 1) {
            if(j <= a && i <= b) cout << 1;
            if(j > a && i <= b) cout << 0;
            if(j <= a && i > b) cout << 0;
            if(j > a && i > b) cout << 1;
        }
        cout << endl;
    }


    return 0;
}

Measured memory_bytes: 1280
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>

using namespace std;
using ll = long long;

void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
int gcd(int a, int b){ return (b == 0) ? a : gcd(b, a % b); }

#define Sq(x) (x)*(x)
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Reverse(c) reverse(Range(c))
#define Unique(a) a.erase(unique(Range(a)), a.end())
#define Cusum(T, xs, sxs) vector<T> sxs(xs.size()+1); For(i, (int)xs.size()) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) { for(const auto &e : xs) cout << e << " "; cout << "\n"; }
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")
#define vc vector
#define Mini(a, x) a = min(a, x)
#define Maxi(a, x) a = max(a, x)

// constexpr int MOD = 1e9+7;

int main(void){
    Cin(string, s);
    int ans = 0;

    string s0, t;
    for(int i = 0; i < (int)s.size(); i ++){
        t += s[i];
        if(t != s0){
            s0 = t;
            t = "";
            ans ++;
        }
    }
    Cout(ans);
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define pb          emplace_back
#define ll          long long
#define fi          first
#define se          second
#define mp          make_pair

using namespace std;

typedef pair<int, int> pii;
const int N = int(1e5) + 7;
const int inf = int(1e9);

int k, x, y, dis[N];
deque<int> Q;

int32_t main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    #define Task        "test"
    if(fopen(Task".inp", "r")) {
        freopen(Task".inp", "r", stdin);
        freopen(Task".out", "w", stdout);
    }
    cin >> k;
    fill_n(dis, k + 1, inf);
    dis[1] = 1; Q.push_back(1);
    while(!Q.empty()) {
        x = Q.front(); Q.pop_front();
        y = (x + 1) % k;
        if(dis[y] > dis[x] + 1) dis[y] = dis[x] + 1, Q.push_back(y);
        y = x * 10 % k;
        if(dis[y] > dis[x]) dis[y] = dis[x], Q.push_front(y);
    }
    cout << dis[0];
}


Measured memory_bytes: 896
#include<cstdio>
#include<algorithm>
using namespace std;
const int MAXN = 2 * int(1E5);
struct node{
	int A, B;
}a[MAXN + 5];
int main() {
	int N;
	scanf("%d", &N);
	bool flag = true;
	long long Sum = 0, Min = (1ll << 60);
	for(int i=1;i<=N;i++) {
		scanf("%d%d", &a[i].A, &a[i].B);
		if( a[i].A > a[i].B )
			Min = min(Min, 1ll*a[i].B);
		if( a[i].A != a[i].B )
			flag = false;
		Sum += a[i].A;
	}
	if( flag ) {
		printf("0\n");
		return 0;
	}
	printf("%lld", Sum - Min);
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
typedef long long ll;

using namespace std;

int main() {
	ll D, G;
	cin >> D >> G;
	vector<ll> p(D);
	vector<ll> c(D);
	vector<ll> pscore(D);
	for (int i = 0; i < D; i++) {
		cin >> p[i] >> c[i];
		pscore[i] = 100*(i + 1)*p[i] + c[i];
	}

	int res = 1e8;
	vector<int> b(D, 0);
	for (int i = 0; i < pow(2, D); i++) {
		for (int j = 0; j < D; j++) b[j] = 0;
		int x = i;
		int cnt = 0;
		while (x != 0) {
			b[cnt++] = x % 2;
			x /= 2;
		}

		ll sub_score = 0;
		int tmp = 0;
		for (int j = 0; j < D; j++) {
			if (b[j] == 1) {
				tmp += p[j];
				sub_score += pscore[j];
			}
		}

		if (i == pow(2, D) - 1) {
			res = min(res, tmp);
			break;
		}

		int key = D - 1;
		while ((b[key] == 1) && (key >= 0)) {
			key--;
		}

		for (int j = 0; j < p[key]; j++) {
			if (sub_score >= G) {
				res = min(res, tmp);
				break;
			}

			sub_score += 100 * (key + 1);
			tmp++;

		}
	}

	cout << res << endl;
	return 0;
}


Measured memory_bytes: 256
#[macro_use]
mod input {

use std;
use std::io;

const SPLIT_DELIMITER: char = ' ';

#[macro_export]
#[allow(unused_macros)]
macro_rules! input {
    ( $($x:expr ),*) => {
        {
            let temp_str = input_line_str();
            let mut split_result_iter = temp_str.split_whitespace();
                $(
                let buf_split_result = split_result_iter.next();
                let buf_split_result = buf_split_result.unwrap();
                    ($x) = buf_split_result.parse().unwrap();
                )*
        }
    };
}

#[allow(dead_code)]
pub fn input_line_str() -> String {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

#[allow(dead_code)]
pub fn p<T>(t: T)
where
    T: std::fmt::Display,
{
    println!("{}", t);
}

#[allow(dead_code)]
pub fn input_vector2d<T>(line: usize) -> Vec<Vec<T>>
where
    T: std::str::FromStr,
{
    let mut v: Vec<Vec<T>> = Vec::new();

    for _ in 0..line {
        let vec_line = input_vector();
        v.push(vec_line);
    }
    v
}

#[allow(dead_code)]
pub fn input_vector<T>() -> Vec<T>
where
    T: std::str::FromStr,
{
    let mut v: Vec<T> = Vec::new();

    let s = input_line_str();
    let split_result = s.split(SPLIT_DELIMITER);
    for z in split_result {
        let buf = match z.parse() {
            Ok(r) => r,
            Err(_) => panic!("Parse Error"),
        };
        v.push(buf);
    }
    v
}

#[allow(dead_code)]
pub fn str2vec(s: &str) -> Vec<char> {
    let mut v: Vec<char> = Vec::new();
    for c in s.chars() {
        v.push(c);
    }
    v
}
}

use input::*;
use std::cmp;
use std::collections::BinaryHeap;
use std::collections::VecDeque;

fn main() {
    let (n, k): (usize, usize);
    input!(n, k);
    let v = input_vector::<isize>();
    let v = v.iter().collect::<VecDeque<_>>();
    let mut ans = 0;

    for a in 0..k + 1 {
        for b in 0..k + 1 - a {
            let mut ans_buf = 0;
            let mut vcopy = v.clone();
            let remove = k - a - b;
            let mut heap = BinaryHeap::new();

            for _ in 0..a {
                if let Some(x) = vcopy.pop_front() {
                    heap.push(-1 * *x);
                    ans_buf += *x;
                }
            }
            for _ in 0..b {
                if let Some(x) = vcopy.pop_back() {
                    heap.push(-1 * *x);
                    ans_buf += *x;
                }
            }

            for _ in 0..remove {
                if let Some(x) = heap.pop() {
                    if x < 0{
                        break;
                    }
                    ans_buf += x;
                }
            }

            ans = cmp::max(ans, ans_buf);
        }
    }
    p(ans);
}

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

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	string S; cin >> S;
	deque<char> dq(S.begin(), S.end());
	bool flip = false;
	int Q; cin >> Q;
	while (Q--) {
		int T; cin >> T;
		if (T == 1) {
			flip ^= 1;
		} else if (T == 2) {
			int F; char C; cin >> F >> C;
			if ((F == 2) ^ flip) {
				dq.push_back(C);
			} else {
				dq.push_front(C);
			}
		} else assert(false);
	}

	string ans(dq.begin(), dq.end());
	if (flip) {
		reverse(ans.begin(), ans.end());
	}
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 1232
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef vector<int> vi;

int main(void) {
	int n,m;
	cin >> n >> m ;

	int ans = 0;

	for (int i = 0; i < m;i++) {
		int a;
		cin >> a;
		ans += a;
	}

	if (n >= ans) {
		cout << n-ans;
		return 0;
	}

	else {
		cout << -1;
		return 0;
	}

	return 0;
}

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

namespace ABC086A
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = int.Parse(Console.ReadLine());
            var result = input == 0 ? 1 : 0;
            System.Console.WriteLine(result);
        }
    }
}


Measured memory_bytes: 27516
#輸入字串並分隔，以list儲存
str_in = input()
num = [int(n) for n in str_in.split()]
num =list(map(int, str_in.strip().split()))  
#print(num) #D,T,S

#若T<(D/S)->遲到
if num[1] > (num[0]/num[2]):
    print("Yes")
elif num[1] == (num[0]/num[2]):
    print("Yes")
else:
    print("No")




Measured memory_bytes: 9068
#include<cmath>
#include<cstdio>
#include<iostream>
using namespace std;
typedef long long int ll;
const int MAXN=2e5+1;
int n,cut1,cut2,cut3;
ll ans,arr[MAXN],presum[MAXN];
inline ll getsum(int Start,int End){
	if(Start>End) return 0;
	return presum[End]-presum[Start-1];
}
inline int read(){
	int x=0,f=1;char c=getchar();
	for(;c<'0'||c>'9';c=getchar()) if(c=='-') f=-1;
	for(;c>='0'&&c<='9';c=getchar()) x=(x<<3)+(x<<1)+c-'0';
	return x*f;
}
int main(){
	n=read();
	for(int i=1;i<=n;++i) presum[i]=presum[i-1]+(arr[i]=read());
	ans=presum[n];cut1=1;cut3=3;
	for(cut2=3;cut2<=n-1;++cut2){
		while(getsum(1,cut1-1)<=getsum(cut1,cut2-1)) ++cut1;
		while(getsum(cut2,cut3-1)<=getsum(cut3,n)) ++cut3;
		while(getsum(1,cut1-1)>getsum(cut1,cut2-1)) --cut1;
		while(getsum(cut2,cut3-1)>getsum(cut3,n)) --cut3;
		if(cut1==cut2) --cut1;if(cut1<=1) cut1=2;
		if(cut3>n) cut3=n;if(cut3<=cut2) cut3=cut2+1;
		ll P=getsum(1,cut1-1),Q=getsum(cut1,cut2-1),R=getsum(cut2,cut3-1),S=getsum(cut3,n);
		if(abs(getsum(1,cut1)-getsum(cut1+1,cut2-1))<abs(P-Q)) {P=getsum(1,cut1);Q=getsum(cut1+1,cut2-1);}
		if(abs(getsum(cut2,cut3)-getsum(cut3+1,n))<abs(R-S)) {R=getsum(cut2,cut3);S=getsum(cut3+1,n);}
		//cout<<P<<" "<<Q<<" "<<R<<" "<<S<<endl;
		ans=min(ans,max(max(P,Q),max(R,S))-min(min(P,Q),min(R,S)));
	}
	//if(n==4) ans=max(max(arr[1],arr[2]),max(arr[3],arr[4]))-min(min(arr[1],arr[2]),min(arr[3],arr[4]));
	printf("%lld",ans);
	return 0;
}

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

using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define FILL(a,n,x); REP(i,(n)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define FILL2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"

#define umap unordered_map
//cout << setfill('0') << right << setw(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
int __stoi(string s){ return atoi(s.c_str()); }
ll sum(ll a[],ll N){ return accumulate(a,a+N,0LL);}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a/gcd(a,b)*b;}
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;} }


struct UnionFind_alpha{
    vector<int> par,s,b,nl;
    UnionFind_alpha(int N) : par(N+1),s(N+1),b(N+1),nl(N+1){
        REP(i,N+1){
            par[i] = i;
            s[i] = 1;
            b[i] = 0;
            nl[i] = 0;
        }
    }
    int root(int x){
        if(par[x]==x){ return x; }
        else{
          par[x] = root(par[x]);
          return par[x];
        }
    }
    void unite(int x, int y){
        int rx = root(x);
        int ry = root(y);
        if( rx!=ry ){
            par[rx] = ry;
            s[ry] += s[rx];
        }
    }
    bool same(int x, int y){
        int rx = root(x);
        int ry = root(y);
        return (rx==ry);
    }
    int size(int x){
        int rx = root(x);
        return s[rx];
    }
    void block(int x, int y){
        if(same(x,y)){
          ++b[x];
          ++b[y];
        }
    }
    void link(int x, int y){
      ++nl[x];
      ++nl[y];
    }
};

int main(){
  int N,M,K; cin>>N>>M>>K;
  UnionFind_alpha uft = UnionFind_alpha(N);
  REP(count,M){
    int a,b; cin>>a>>b;
    uft.unite(a,b);
    uft.link(a,b);
  }
  REP(count,K){
    int c,d; cin>>c>>d;
    uft.block(c,d);
  }
  for(int i=1;i<=N;++i){
    int ans = uft.size(i)-1-uft.nl[i]-uft.b[i];
    if(i<N){ cout << ans <<" ";}
    else{ cout << ans <<"\n"; }
  }
}

Measured memory_bytes: 3200
n,m=map(int,input().split())
edge=[list(map(int,input().split())) for i in range(m)]
node=[-float('inf') for i in range(n+1)]
node[1]=0
inf=False
for i in range(2*n+1):
  loop=False
  for s,e,c in edge:
    if node[e]<node[s]+c:
      node[e]=node[s]+c
      if e==n:
        loop=True
  if i>=n and loop:
    inf=True
    break
if inf:
  print('inf')
else:
  print(node[-1])

Measured memory_bytes: 3700
import java.util.*;
class Main{
	public static void main(String[]args){
    	Scanner in = new Scanner(System.in);
      	int x = in.nextInt(), y = in.nextInt(), z = 0;	
      	if(x==1&&y==2||x==2&&y==1)
          z = 3;
        else if(x==2&&y==3||x==3&&y==2)
       	  z = 1;
      	else if(x==3&&y==1||x==1&&y==3)
          z = 2;
      	System.out.println(z);
    }
} 

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

int main() {
    int N; cin >> N;
    vector<int> C(N), S(N), F(N), ans(N);
    rep(i, 0, N - 1) cin >> C[i] >> S[i] >> F[i];
    rep(i, 0, N - 1) rep(j, i, N - 1)  {
        if(ans[i] <= S[j]) ans[i] = S[j] + C[j];
        else {
            int a = ans[i] % F[j];
            if(a) ans[i] += F[j] - a;
            ans[i] += C[j];
        }
    }
    rep(i, 0, N) cout << ans[i] << endl;
    return 0;
}


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

int main()
{
    long N, M;
	cin>> N >>M;
	int A, S=0;
	int i;
	for(i=0;i<M;i++){
		cin>>A;
		S=S+A;
	}
	if(S>N){cout<<-1;}
	else{cout<<N-S;}
   return 0;
}

Measured memory_bytes: 3592
#include<iostream>
using namespace std;
int a[200000];
int main()
{
	int k,n,i;
	cin>>k>>n;
	for(i=0;i<n;i++)
	cin>>a[i];
	int s=0,max=0;
	for(i=0;i<n-1;i++)
	{
		s=a[i+1]-a[i];
		if(s>max)
		max=s;
	}
	s=k-a[n-1]+a[0];
	if(s>max)
	max=s;
	cout<<k-max;
}

Measured memory_bytes: 1024
#include <iostream>
using namespace std;
int main(){
    int N;
    cin>>N;
    int A[N];
   int a=0;
 for (int i=0;i<N;i++)
 cin>>A[i];
    while(true){
       int s=0;
        for(int i=0;i<N;i++){
            
            if(A[i]%2==0){
                s+=1;
            }
            A[i]=A[i]/2;
         }
            if (s==N){
                a+=1;
            }else{
                break;
            }
        }
    cout<<a<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void){
	int S,h,m,s;
	scanf("%d",&S);
	s=S%60;
	m=(S-s)%3600/60;
	h=(S-s-60*m)/3600;
	printf("%d:%d:%d\n",h,m,s);
	
	return 0;
}

Measured memory_bytes: 592
#include <bits/stdc++.h>
#include <string>
#include <algorithm>
#include <string.h>
#include <ctype.h>
#include <math.h>
#include <float.h>
#include <iomanip>
#include <iostream>
using namespace std;


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

    for(int i=1;i<=S.length();i++){
        cout << 'x';
    }

}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<stdio.h>
#define int long long
using namespace std;
const int N=110;
int n;
signed main(){
	cin>>n;
	int c=0;
	for(int a,b,i=1;i<=n;i++){
		cin>>a>>b;
		if(a==b)
			c++;
		else
			c=0;
//		cout<<i<<" "<<c<<endl;
		if(c==3){
			cout<<"Yes"<<endl;
			return 0;
		}
	}
	cout<<"No"<<endl;
}

Measured memory_bytes: 3620
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define mod 1000000007
#define INF2 9999999999
#define INF (1 << 30)
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)

using namespace std;
using ll = __int64_t;

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

ll gcd(ll a, ll b){
    ll x = max(a, b);
    ll y = min(a, b);

    if(y == 0) return x;
    return gcd(y, x%y);
}

void solve(){
    int n;
    ll a[100005], l[100005], r[100005];    
    ll res=0;

    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    for(int i = 0; i < n; i++){
        if(i == 0){
            l[i] = 0;
        }else{
            l[i] = gcd(l[i-1], a[i-1]);
        }
    }
    for(int i = n; i >= 0; i--){
        if(i == n){
            r[i] = 0;
        }else{
            r[i] = gcd(r[i+1], a[i]);
        }
    }
    for(int i = 0; i < n; i++){
        ll m = gcd(l[i], r[i+1]);
        res = max(res, m);
    }
    cout << res << endl;
}

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

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

#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

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

    vector p(n * n, 0L);
    for (auto i : irange(0L, n * n)) {
        cin >> p[i];
        --p[i];
    }

    vector costs(n * n, 0L);
    for (auto i : irange(0L, n * n)) {
        auto r = i / n;
        auto c = i % n;

        costs[i] = min({r, c, n - r - 1, n - c - 1});
    }

    array dxs{-1L, 1L, 0L, 0L};
    array dys{0L, 0L, -1L, 1L};

    vector absent(n * n, false);
    int64_t ans = 0;
    for (auto pp : p) {
        // cerr << pp << ":" << costs[pp] << endl;
        ans += costs[pp];

        absent[pp] = true;

        vector st(1L, pp);
        while (!st.empty()) {
            auto v = st.back();
            st.pop_back();

            auto r = v / n;
            auto c = v % n;
            auto cost = costs[v] + (absent[v] ? 0 : 1);
            for (auto i : irange(0L, 4L)) {
                auto nr = r + dxs[i];
                auto nc = c + dys[i];
                if (nr < 0 || nr >= n || nc < 0 || nc >= n) {
                    continue;
                }

                auto u = nr * n + nc;

                // cerr << v << "->" << u << ":" << costs[u] << "=>" << cost
                    //  << endl;
                if (cost < costs[u]) {
                    costs[u] = cost;
                    st.push_back(u);
                }
            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 9152