akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main {

    static final int NONE = -1;
    static final int A_MAX = 2 * 100000;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        long K = sc.nextLong();
        int[] A = new int[N];

        for (int i = 0; i < N; i++) A[i] = sc.nextInt();

        int[] toNext = new int[N];
        int[] first = new int[A_MAX + 1];
        int[] last = new int[A_MAX + 1];
        Arrays.fill(first, -1);
        Arrays.fill(last, -1);

        for (int i = 0; i < N; i++) {
            if (first[A[i]] == NONE) {
                first[A[i]] = i;
                last[A[i]] = i;
            } else {
                toNext[last[A[i]]] = i - last[A[i]] + 1;
                last[A[i]] = i;
            }
        }

        for (int i = 0; i < N; i++) {
            if (first[A[i]] != NONE) {
                toNext[last[A[i]]] = N - last[A[i]] + first[A[i]] + 1;
            }
        }

        int pos = 0;
        long ops = 0;
        long[] firstVisit = new long[N];
        Arrays.fill(firstVisit, NONE);

        while (true) {
            if (firstVisit[pos] != NONE) {
                long cycleLength = ops - firstVisit[pos];
                ops += ((N * K - ops) / cycleLength) * cycleLength;
            } else {
                firstVisit[pos] = ops;
            }
            if (ops + toNext[pos] > N * K) break;
            ops += toNext[pos];
            pos = (pos + toNext[pos]) % N;
        }

        long remainingOps = N * K - ops;

        LinkedList<Integer> sol = new LinkedList<>();
        boolean[] contains = new boolean[A_MAX + 1];

        for (int i = 0; i < remainingOps; i++) {
            int a = A[(pos + i) % N];
            if (contains[a]) {
                int x = sol.pollLast();
                while (x != a) {
                    contains[x] = false;
                    x = sol.pollLast();
                }
                contains[x] = false;
            } else {
                contains[a] = true;
                sol.addLast(a);
            }
        }

        for (int s : sol) {
            System.out.print(s + " ");
        }
    }
}


Measured memory_bytes: 91316
#include <bits/stdc++.h>
#define F first
#define S second
#define mp make_pair
#define pb push_back
//#define ll __int128
#define ll long long
#define int long long
//#define int __int128
#define LEFT(a) ((a)<<1)
#define RIGHT(a) (LEFT(a) + 1)
#define MID(a,b) ((a+b)>>1)
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define y1 y122

/*
#pragma GCC optimize ("O3")
#pragma GCC optimize("Ofast")

#pragma GCC target("avx2,fma")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC target ("avx2")
#pragma GCC optimization ("unroll-loops")

#pragma comment(linker, "/STACK: 20000000005")
*/

using namespace std;

const int N = 605, MOD = 998244353;

int n=1, m, k;
string S;
int a[N];
int dp[N][N], DP[N][N];

main()
{
    //freopen ("in.in", "r", stdin);freopen ("out.out", "w", stdout);
    ios_base::sync_with_stdio(0);
    cin >> S >> k;
    for (int i = 0; i < S.size(); i++){
        if (S[i] == '0')
            n++;
        else {
            a[n]++;
            m++;
        }
    }
    int sum = m, ss = 0;
    dp[0][0] = 1;
    for (int t, I = 1; I <= n; I++){
        sum -= a[I];
        ss += a[I];
        for (int i = 0; i <= sum+a[I]; i++)
            for (int j = 0; j <= ss; j ++)
                for (int x = -min (i, a[I]); x+i <= sum; x++){
                    t = j;
                    if (x < 0)
                        t += -x;
                    DP[i+x][t] += dp[i][j];
                }
        for (int i = 0; i <= m; i++)
            for (int j = 0; j <= ss; j++){
                DP[i][j] %= MOD;
                dp[i][j] = DP[i][j];
                DP[i][j] = 0;
            }
    }
    int ans = 0;
    for (int i = 0; i <= min (m,k); i ++){
        ans += dp[0][i];
    }
    cout << ans % MOD << endl;
}


Measured memory_bytes: 6412
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    string S;
    cin >> S;
    int cntS = 0, cntT = 0;
    int ans = S.size();
    for (int i = 0; i < S.size(); i++) {
        if (S[i] == 'S') cntS++;
        else if (cntS > 0) cntS--, ans-= 2;
    }
    cout << ans << '\n';
}


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

map<string, int> weight;

int idx;
string s;
char cur;
bool notfound;
bool cont;
bool next(){
	if(idx >= s.size()) return cont = false;
	cur = s[idx++];
}
int number(){
	int ans = cur - '0';
	if(next() && '0' <= cur && cur <= '9'){
		ans = ans * 10 + cur - '0';
		next();
	}
	return ans;
}


int atom(){
	string key;
	if(next() && 'a' <= cur && cur <= 'z'){
		key = s.substr(idx - 2, 2);
		next();
	}else{
		key = s.substr(idx - 2 + !cont, 1);
	}
	if(weight.count(key)){
		return weight[key];
	}else{
		notfound = true;
		return 0;
	}
}
int molecule();
int m2(){
	if(cur == '('){
		next();
		int ret = molecule();
		next();
		ret *= number();
		return ret;
	}
	int w = atom();
	if('0' <= cur &&  cur <= '9'){
		return w * number();
	}else{
		return w;
	}
}


int molecule(){
	int ans = m2();
	while(cont && 'A' <= cur && cur <= 'Z' || cur == '('){
		ans += m2();	
	}
	return ans;
}


int main(){
	string str;
	while(cin >> str, str != "END_OF_FIRST_PART"){
		int w;
		cin >> w;
		weight[str] = w;
	}
	while(cin >> s, s != "0"){
		idx = 0;
		notfound = false;
		cont = true;
		next();
		int val = molecule();
		if(notfound){
			cout << "UNKNOWN" << endl;
		}else{
			cout << val << endl;
		}
	}
}

Measured memory_bytes: 3156
#include <bits/stdc++.h>
using namespace std;
const int N=2e5+10;
char q[N];
int main()
{
	cin.tie(0);cout.tie(0);ios::sync_with_stdio(0);
	int n;
	cin>>n;
	for(int i=0;i<n;i++)cin>>q[i];
	int r=0;
	for(int i=0;i<n;i++)
	{

		if(q[i]=='R')r++;
	}
	int R=r;
	for(int i=0;i<R;i++)
	{
		if(q[i]=='R')r--;
	}
	cout<<r;


}


Measured memory_bytes: 3840
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<bitset>
using namespace std;
typedef bitset<4000001>bi;
bi now;
int main()
{
	int num;
	scanf("%d", &num);
	int s = 0;
	now[0] = 1;
	for (int i = 0; i < num; i++)
	{
		int z;
		scanf("%d", &z);
		s += z;
		now |= now << z;
		//for (int j = 0; j < 10; j++)printf("%d", int(now[j])); printf("\n");
	}
	s = (s + 1) / 2;
	for (;;)
	{
		if (now[s])
		{
			printf("%d\n", s);
			return 0;
		}
		s++;
	}
}

Measured memory_bytes: 1664
def management():
    N=int(input())
    static_list=list(map(int,input().split()))
    result_list=[]
    for i in range(0,N):
        result_list.append(0)
    for i in range(0,len(static_list)):
            result_list[static_list[i]-1]=result_list[static_list[i]-1]+1
    for i in range(0,N):
        print(result_list[i])


if __name__=="__main__":
    management()


Measured memory_bytes: 32156
const int LG = 21;
const int FN = 400005;
const long long MOD = 1e9 + 7;
const long long INF = 1e9;
const long long INFLL = 1e18;

#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#include <time.h>
#include <unordered_set>
#include <bitset>
#include <deque>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<ll> vi;

#define forn(i, n) for (int (i) = 0; (i) != (n); (i)++)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define fi first
#define se second
#define re return
#define uniq(x) sort(all(x)); (x).resize(unique(all(x)) - (x).begin())

#ifdef LOCAL
#define dbg(x) cerr << __LINE__ << " " << #x << " " << x << endl
#define ln cerr << __LINE__ << endl
#else
#define dbg(x) void(0)
#define ln void(0)
#endif // LOCAL

int cx[4] = {-1, 0, 1, 0};
int cy[4] = {0, -1, 0, 1};

ll inq(ll x, ll y)
{
    if (!y) re 1 % MOD;
    ll l = inq(x, y / 2);
    if (y % 2) re l * l % MOD * x % MOD;
    re l * l % MOD;
}

ll rev(ll x)
{
    return inq(x, MOD - 2);
}

bool __precomputed_combinatorics = 0;
vector<ll> __fact, __ufact, __rev;

void __precompute_combinatorics()
{
    __precomputed_combinatorics = 1;
    __fact.resize(FN);
    __ufact.resize(FN);
    __rev.resize(FN);
    __rev[1] = 1;
    for (int i = 2; i < FN; i++) __rev[i] = MOD - __rev[MOD % i] * (MOD / i) % MOD;
    __fact[0] = 1, __ufact[0] = 1;
    for (int i = 1; i < FN; i++) __fact[i] = __fact[i - 1] * i % MOD, __ufact[i] = __ufact[i - 1] * __rev[i] % MOD;
}

ll fact(int x)
{
    if (!__precomputed_combinatorics) __precompute_combinatorics();
    return __fact[x];
}

ll cnk(int n, int k)
{
    if (!__precomputed_combinatorics) __precompute_combinatorics();
    return __fact[n] * __ufact[n - k] % MOD * __ufact[k] % MOD;
}

const int N = 100500;
ll n;
ll a[N], b[N];

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n;
    for (int i = 0; i < n; i++) cin >> a[i] >> b[i];
    ll cur = 1;
    for (int i = 1; i < n; i++)
    {
        ll L = 0, R = INFLL / (a[i] + b[i]) + 2;
        while (L + 1 < R)
        {
            ll M = (L + R) / 2;
            if (M * (a[i] + b[i]) >= cur * (a[i - 1] + b[i - 1]) && M * a[i] >= cur * a[i - 1] && M * b[i] >= cur * b[i - 1]) R = M;
            else L = M;
        }
        cur = R;
    }
    cout << a[n - 1] * cur + b[n - 1] * cur;
}

/* Note:
Check constants at the beginning of the code.
    N is set to 4e5 but be careful in problems with large constant factor.
    Setting N in every problem is more effective.
Check corner cases.
    N = 1
No def int long long for now.
Add something here.
*/


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

const int MAX_N	= 100000;
int a[ MAX_N + 5 ];
int b[ MAX_N + 5 ];

int main()
{
int i;
int N;
int H;
int iMax;
int iSum;
int iCnt;
int X;

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

	cin >> N;
	cin >> H;

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

	sort( a, a + N, std::greater<int>() );
	sort( b, b + N, std::greater<int>() );
	iMax = a[ 0 ];

	iSum = 0;
	iCnt = 0;
	for( i = 0; i < N; i++ )
	{
		if( b[ i ] >= iMax )
		{
			iCnt++;
			iSum += b[ i ];
			if( iSum >= H ) break;
		}
	}

	if( i == N )
	{
		X = H - iSum;
		iCnt += X / iMax;
		if( X % iMax != 0 ) iCnt++;
	}

	cout << iCnt << endl;

	return 0;
}




Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
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(){
    ll n;cin >> n;
    vpl left,right;
    rep(i,n){
        string s;cin >> s;
        ll tot=0,mi=0;
        rep(j,s.size()){
            if(s[j]=='(')tot++;
            else tot--;
            chmin(mi,tot);
        }
        if(tot>0)left.pb({mi,tot});
        else right.pb({mi-tot,-tot});
    }
    sort(all(left));sort(all(right));
    rev(all(left));rev(all(right));
    //for(auto p:right)cout << p.fi <<" " <<p.se <<endl;
    bool check=true;
    ll total=0;
    rep(i,left.size()){
        if(total<-left[i].fi)check=false;
        total+=left[i].se;
    }
    ll whole=0;
    rep(j,right.size()){
        if(whole<-right[j].fi)check=false;
        whole+=right[j].se;
    }
    if(check&&total==whole)cout <<"Yes" <<endl;
    else cout <<"No" <<endl;
}

Measured memory_bytes: 19008
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define PI 3.14159265359
#define INF 1000100100
#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define P pair<int, int>
#define PP pair<P,P>
#define T tuple<int,int,int> 
using namespace std;

int main(){
    int n,x; cin >> n >> x;
    vector<int> p(n);
    rep(i,n){
        int d; cin >> d;
        p[i]=abs(x-d);
    }
    int ans;
    if(n==1) ans=p[0];
    else ans=gcd(p[0],p[1]);
    for(int i=2; i<n; i++){
        ans = gcd(ans,p[i]);
    }

    cout << ans << endl;
return 0;
}

Measured memory_bytes: 3692
#!/usr/bin/env python3
import sys
try:
    from math import gcd
except Exception:
    from fractions import gcd


def solve(N: int, M: int, C: int, B: "List[int]", A: "List[List[int]]"):
    ret = 0
    for aa in A:
        if 0 < sum([a * b for (a, b) in zip(aa, B)]) + C:
            ret += 1
    return ret


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    B = [ int(next(tokens)) for _ in range(M) ]  # type: "List[int]"
    A = [ [ int(next(tokens)) for _ in range(M) ] for _ in range(N) ]  # type: "List[List[int]]"
    result = solve(N, M, C, B, A)
    print(result)

if __name__ == '__main__':
    main()


Measured memory_bytes: 5076
object Main extends App {
  val Array(n, m) = io.StdIn.readLine.split(" ").map(_.toInt)
  val kas = for (_ <- 1 to n) yield io.StdIn.readLine.split(" ").map(_.toInt)

  val as = kas.map(_.tail)
  val a_series = as.reduce(_ intersect _)
  println(a_series.length)
}

Measured memory_bytes: 55096
#include <iostream>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <vector>
#include <set>
#include <cassert>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <sstream>
#include <functional>
#include <iomanip>
//#include <windows.h>  //Should be deleted when using AtCoder&POJ
using namespace std;

#define ll long long
#define pq_small priority_queue<int,vector<int>,greater<int> >
#define pii pair<int,int>
/**==Info==
*Program:B
*Problem:
*Date:
*Algorithm:
*Stats:*/
int a[15];
int n;

inline int dfs(int pos,int pro){
	//cout<<pos<<" "<<pro<<endl;
	if(pos==n && pro%2==0) return 1;
	if(pos==n) return 0;
	return dfs(pos+1,pro*(a[pos]-1)%2)+dfs(pos+1,pro*(a[pos]+1)%2)+dfs(pos+1,pro*(a[pos])%2);
}
int main(int argc,char* argv[]){
	
	cin>>n;
	for(int i=0;i<n;i++) cin>>a[i];
	
	cout<<dfs(1,a[0]-1)+dfs(1,a[0]+1)+dfs(1,a[0]);
	return 0;
}


Measured memory_bytes: 256
n,k=gets.split.map(&:to_i)
pt=gets.split.map(&:to_i)
t=gets.chomp #s=>0 ,p=>1 ,r=>2


ans=[0]*n
n.times do |i|
    m=t[i]
    if m=="s"
        m=0
    elsif m=="p"
        m=1
    else
        m=2
    end
    
    
    
    if i>=k && t[i-k]==t[i] && ans[i-k]>0
        #nothing
    else
    ans[i]=pt[m]
    end
end
p ans.inject(&:+)

Measured memory_bytes: 15264
#include <stdio.h>

int main()
{
    int n, m = 0, s = 0, l[11];
    scanf("%d", &n);
 
    for (int i = 0; i < n; i++){    
        scanf("%d", &l[i]);
        s += l[i];
        if(m < l[i]){
            m = l[i];
        }
    }
    printf("%s\n", s - m > m ? "Yes" : "No");
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,s,n) for(ll i = (s); i < (n); i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()



int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(18);
  
  ll n, m, x;
  cin >> n >> m >> x;
  
  vector<ll> c(n);
  ll a[n][m];
  rep(i, 0, n) {
    cin >> c[i];
    rep(j, 0, m) 
      cin >> a[i][j];
  }
  
  bool flag = false;
  ll mini = 10000000000000;
  for(ll bits = 0; bits < (1<<n); bits++) {
    ll sum[m];
    ll cnt = 0;
    rep(j, 0, m) sum[j]=0;
    rep(i, 0, n) {
      ll mask = 1 << i;
      if(bits & mask) {
        cnt += c[i];
        rep(j, 0, m) {
          sum[j] += a[i][j];
        }
      }
    }
    bool flag2 = true;
    rep(j, 0, m) {
      if(sum[j] < x) flag2 = false;
    }
    if(flag2) {
      flag = true;
      mini = min(mini, cnt);
    }
  }
  if(flag)
    cout << mini << "\n";
  else
    cout << -1 << "\n";
}

Measured memory_bytes: 3656
#include<stdio.h>
 int main(){
 	int i=0,x=0,k;
 	int data[10000];
 	while(1){
 	x++;
 	scanf("%d",&data[x]);
 	i=i+1;
 	if(data[x] == 0)break;
  	}
 	for(k=1;k<i;k++){
 	 printf("Case %d: %d\n",k,data[k]);
 	 }
 	 return 0;
  	}

Measured memory_bytes: 1764
// inputに入力データ全体が入る
function Main(input) {
	var line = input.split("\n");
	var X = Number(line[0]);
	var A = Number(line[1]);
	var B = Number(line[2]);
	var ans = (X-A)%B;
	console.log(ans);
}

//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 21064
import sys

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


def resolve():
    n = int(input())
    AB = sorted([list(map(int, input().split())) for _ in range(n)], key=lambda x: x[0],
                reverse=True)
    CD = sorted([list(map(int, input().split())) for _ in range(n)], key=lambda x: x[1])

    res = 0
    for i in range(n):
        a, b = AB[i]
        for j in range(len(CD)):
            c, d = CD[j]
            if a < c and b < d:
                res += 1
                CD.pop(j)
                break

    print(res)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <stdio.h>
#include <list>
#include <numeric>
#include <stack>
#include <queue>
#include <tuple>
#include <bitset>
#include <map>
#include <math.h>
//　ceil(a/b)   (a + (b - 1))/ b
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
typedef long long ll;
typedef pair<int,int> P;
const int inf=1000000007;
const int mod=1000000007;
const double PI=3.14159265358979323846;
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};

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


// ll memo[2020][2020];
// int pascal_triangle(){
//   for(int i = 0; i < 2020; i++){
//     for(int j = 0; j < i+1; j++){
//       if(j == 0 || j == i) memo[i][j] = 1;
//       else{
// 	memo[i][j] = (memo[i-1][j-1]+memo[i-1][j]);
//       }
//     }
//   }
//   return 0;
// }


int factorial(int n){
  if(n == 0) return 1;
  return n*factorial(n-1);
}

int divisor(int a){
  int cnt = 0;
  for(int i=1; i <= a; i++) if(a%i == 0) cnt++;
  return cnt;
}

int comb(int n, int k){
  return factorial(n) / (factorial(n-k)*factorial(k));
}

// int cans(bool f){
//   if(f) cout << "Yes" << endl;
//   else cout << "No" << endl;
//   return 0;
// }






int main(){
  int a,b,x;
  cin >> a >> b >> x;
  if(x >= a && b >= x-a) cout << "YES" << endl;
  else cout << "NO" << endl;
}









Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<vector>

using namespace std;

int main(){

    int N;
    vector<int> A;
    map<long long, long long> numCount;

    cin >> N;
    A.resize(N);
    for (int i = 0; i < N; i++){
        cin >> A[i];
        if(numCount.count(A[i]) == 0){
            numCount[A[i]] = 1;
        }else{
            numCount[A[i]]++;
        }
    }

    long long ans_full = 0;
    for (auto iter = numCount.begin(); iter != numCount.end(); iter++){
        long long n = iter->second;
        long long add = n * (n - 1) / 2;
        ans_full += add;
    }

    for (int i = 0; i < N; i++){
        long long ans = ans_full - numCount[A[i]] + 1;

        cout << ans << endl;
    }
}

Measured memory_bytes: 10240
#include <cstdio>
#include <algorithm>
// C - Walk on Multiplication Table

#define INF 0x3f3f3f3f3f3f3f3f

using namespace std;

int main() {
    long long N,i,ans;

    scanf("%lld",&N);

    ans = INF;
    for (i = 1;i * i <= N;i++) {
        if (N % i == 0)
            ans = min(ans,i + N / i - 2);
    }

    printf("%lld\n",ans);

    return 0;
}

Measured memory_bytes: 128
#include <algorithm>
//#include <cstdio>
//#include <functional>
#include <iostream>
//#include <cfloat>
//#include <climits>
//#include <cstdlib>
//#include <cstring>
#include <cmath>
//#include <map>
//#include <queue>
//#include <set>
//#include <sstream>
//#include <stack>
//#include <string>
//#include <time.h>
#include <vector>
//#include <random>
//#include <unordered_set>
//#include <complex>
//#include <string.h>

#define rt0 return 0
#define rep(i,n) for(int i=0;i<n;i++)
#define LL long long
#define pii pair<int,int>

using namespace std;
const int MOD=2e5+10;

int main()
{
    int n,left,right;
	LL A[MOD],ans=0;
	LL sumx;

	cin>>n;
	
	rep(i,n) {
		cin>>A[i];
	}
	
	right=0;
	sumx=0;
	
	rep(left,n) {
		while(right<n) {
			if(sumx&A[right]) break; //有进位，不符合条件，停止向右搜索。 
			sumx^=A[right];
			right++;			
		}
		ans+=(right-left);
		sumx^=A[left];
	}
	
	cout<<ans;
		
	rt0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb(x) push_back(x)
#define f(i,st,n) for(i=st;i<n;i++)
#define qu queue
#define ps(x) push(x)
#define vec vector
#define ft() front()
#define mst(a,b) memset(a,b,sizeof(a))
#define mod 1000000007
#define sfl(x) scanf("%lld",&x)
#define pfl(x) printf("%lld\n",x)
#define pf(x) printf("%lld",x)
#define mpr make_pair
#define fs first
#define se second
#define inf LLONG_MAX
 
 
 
ll gcd(ll a,ll b){
    if(a==0){
        return b;
    }                     
    return gcd(b%a,a);
}
ll power(ll x,ll y){            
    ll res=1;
    while(y>0){
        if(y%2==1){
            res=(res*x);
        }
        x=(x*x);
        y=y/2;
    }
    return res;
}
 




int main(){
 
 /*#ifndef ONLINE_JUDGE
    
   freopen("input.txt", "r", stdin);
   
   freopen("output.txt", "w", stdout);
   #endif*/
string s;
cin>>s;
ll n=s.length(),l=0,r=n-1;

ll ans=0;

while(l<=r){
   if(s[l]!=s[r])ans++;
   l++;r--;
}
pf(ans);









   return 0;
 }

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(5 * 10**5)
input=sys.stdin.readline

N, K, Q = list(map(int, input().split()))

counts = [0] * N
for i in range(Q):
    counts[int(input()) - 1] += 1

for i in range(N):
    if Q - counts[i] < K:
        print("Yes")
    else:
        print("No")


Measured memory_bytes: 4680
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<string>
#include<cstring>
#include<cstdlib>
#include<utility>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define pi acos(-1)
#define pb push_back
#define all(v) v.begin(),v.end()
using namespace std;
typedef pair<int,int> p;
typedef long long ll;

int main(){
	int n;
	cin>>n;
	int a,b,m=1e9+1;
	rep(i,n){
		cin>>a;
		b=0;
		while(a%2==0){a/=2;b++;}
		m=min(m,b);
	}
	cout<<m<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 998244353;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define zep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(int i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

const long long MAX = 2e5+100;
long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(){
	cin.tie(0); ios::sync_with_stdio(false);
	COMinit();
	
	ll n, m, k; cin >> n >> m >> k;
	
	ll x[n+100];
	x[0] = 1;
	rep(i, 1, n){
		x[i] = x[i-1]*(m-1)%MOD;
	}
	
	ll ans = 0;
	rep(i, 0, k){
		ans += COM(n-1, i)*x[n-1-i]%MOD;
		ans %= MOD;
	}
	print(ans*m%MOD)
	return 0;
}

Measured memory_bytes: 9868
#include <bits/stdc++.h>
#define int long long 
using namespace std;

signed main() {
	int N,A,B;
	cin >> N >> A >> B;
	vector<int> vec(N);
	for(int i = 0;i < N;i++) {
		cin >> vec.at(i);
	}
	int answer = 0;
	for(int i = 0;i < N - 1;i++) {
		answer += min((vec.at(i + 1) - vec.at(i)) * A,B);
	} 
	cout << answer << endl;
}


Measured memory_bytes: 1024
object Main extends App {
  import scala.io.StdIn._

  val Array(n, m) = readLine.trim.split(' ').map(_.toInt)
  val inEdgeCount = Array.tabulate(n){_ ⇒ 0}
  val edges = Array.tabulate(n){_ ⇒ Nil: List[Int]}
  for (_ ← 1 until n + m){
    val Array(a, b) = readLine.trim.split(' ').map(_.toInt - 1)
    inEdgeCount(b) += 1
    edges(a) ::= b
  }
  var current = List(inEdgeCount.indexWhere(_ == 0))
  val prev = Array.tabulate(n){_ ⇒ 0}
  while (current.nonEmpty){
    var next = Nil: List[Int]
    for (c ← current; e ← edges(c)) {
      inEdgeCount(e) -= 1
      if (inEdgeCount(e) == 0) {
        next ::= e
        prev(e) = c + 1
      }
    }
    current = next
  }
  println(prev.mkString("\n"))
}

Measured memory_bytes: 77016
#include<stdio.h>
int main(){
  int r,c,i,j,e;
  int ans[101][101]={};
  scanf("%d%d",&r,&c);
  for(i=0;i<r;i++){
    for(j=0;j<c;j++){
      scanf("%d",&e);
      ans[i][j]=e;
      ans[i][c]+=ans[i][j];
    }
    ans[r][c]+=ans[i][c];
  }
  for(i=0;i<c;i++){
    for(j=0;j<r;j++){
      ans[r][i]+=ans[j][i];
    }
  }
  for(i=0;i<r+1;i++){
    for(j=0;j<c+1;j++){
      printf("%d",ans[i][j]);
      if(j!=c){
	printf(" ");
      }
    }
    
    printf("\n");
  }
  return 0;
}



Measured memory_bytes: 2772
#include<bits/stdc++.h>
using namespace std;
typedef long double ld;
const int N=5005,M=1000000007;
int n,i,m,j,k;
long long f[N][N],a[N],ans;
int main()
{
	scanf("%d %d",&n,&m);
	a[0]=1;
	for(i=1;i<=max(n,m);++i)
		a[i]=a[i-1]*2%M;
	f[n][m]=1;
	for(i=n-1;i>=0;--i)
	{
		for(j=m;j>=1;--j)
			f[i][j]=(f[i+1][j+1]+f[i][j+1]*2)%M;
		for(j=1;j<=m;++j)
			f[i][j]=(f[i][j]*j+f[i+1][j]*(j+1))%M;
		/*{
			f[i][j]=f[i+1][j]*(j+1)%M;
			for(k=j+1;k<=m;++k)
				f[i][j]=(f[i][j]+f[i+1][k]*a[k-j-1]%M*j)%M;
		}*/
	}
	for(i=1;i<=m;++i)
		ans=(ans+f[0][i])%M;
	cout<<(ans%M+M)%M;
}


Measured memory_bytes: 199180
//E
#include <bits/stdc++.h>
#define Inf 0x3f3f3f3f
#define rg register
#define pii pair<int, int>
#define mp(x, y) make_pair(x, y)
using namespace std;
typedef long long ll;
const int Maxn = 1e5 + 5, Mod = 1e9 + 7;
typedef ll arr[Maxn];
ll Add(ll x, ll y) { return (x += y) >= Mod ? x - Mod : (x < 0 ? x + Mod : x); }
ll min(ll x, ll y) { return x < y ? x : y; }
ll max(ll x, ll y) { return x > y ? x : y; }
inline ll read()
{
	rg ll res = 0, sign = 1;
	rg char ch = getchar();
	while (!isdigit(ch))
	{
		if (ch == '-')
			sign = -1;
		ch = getchar();
	}
	do
	{
		res = (res << 3) + (res << 1) + (ch ^ 48);
		ch = getchar();
	} while (isdigit(ch));
	return res * sign;
}
int n, k;
arr fac, inv, invfac;
ll ans;
struct str
{
	int cnt, pos;
	bool operator<(str A) const { return cnt < A.cnt || (cnt == A.cnt && pos < A.pos); }
} a[Maxn];
ll C(int x, int y) { return fac[x] * invfac[y] % Mod * invfac[x - y] % Mod; }
int main()
{
	fac[0] = inv[1] = invfac[0] = 1;
	for (int i = 1; i <= 100000; i++)
	{
		fac[i] = fac[i - 1] * i % Mod;
		if (i > 1)
			inv[i] = (Mod - Mod / i) * inv[Mod % i] % Mod;
		invfac[i] = invfac[i - 1] * inv[i] % Mod;
	}
	cin >> n >> k;
	for (int i = 1; i <= n; i++)
		a[i] = {read(), i};
	sort(a + 1, a + n + 1);
	for (int i = 1; i <= n - k + 1; i++)
		ans = Add(ans, -(a[i].cnt * C(n - i, k - 1) % Mod));
	for (int i = k; i <= n; i++)
		ans = Add(ans, (a[i].cnt * C(i - 1, k - 1) % Mod));
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 3328
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main
{
    static int mod=1000000007;
    static int dp[][];
    public static void main(String[] args) throws IOException {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        int n=Integer.parseInt(br.readLine());
        int arr[][]=new int[n][n];
        dp=new int[(1<<n)+1][n];
        for(int i=0;i<dp.length;i++)
            for(int j=0;j<dp[0].length;j++)
//                for(int k=0;k<dp[0][0].length;k++)
                dp[i][j]=-1;
        for(int i=0;i<n;i++)
        {
            String str[]=br.readLine().split(" ");
            for(int j=0;j<str.length;j++) {
                arr[i][j] = Integer.parseInt(str[j]);
            }
        }
        int man=((1<<n)-1);
        int woman=((1<<n)-1);
//        System.out.println(man);
        System.out.println(calculate(woman,arr,0));
    }

    private static int calculate(int woman, int[][] arr,int index) {
        if( woman==0 && index>=arr.length)
            return 1;
        if(index>=arr.length)
            return 0;
        if(dp[woman][index]!=-1)
            return dp[woman][index];
        int sum=0;
                for (int j = 0; j < arr.length; j++) {
                    if (arr[index][j] == 1 && ((woman >> j) & 1) == 1) {
                        sum = ((sum%mod)+(calculate( woman ^ (1 << j), arr, index + 1)%mod))%mod;
                    }
                }
        return dp[woman][index]=sum;
    }
}

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

int main()
{
	int A = 0, B = 0, C = 0, D = 0, E = 0, ANS = 0;
	cin >> A >> B >> C >> D >> E;

	int  a=0, b=0, c=0, d=0, e=0;
	if (A % 10 != 0) a = 10 - A % 10;
	else a = 0;
	if (B % 10 != 0) b = 10 - B % 10;
	else b = 0;
	if (C % 10 != 0) c = 10 - C % 10;
	else c = 0;
	if (D % 10 != 0) d = 10 - D % 10;
	else d = 0;
	if (E % 10 != 0) e = 10 - E % 10;
	else e = 0;
	
	vector<int> loss{ a,b,c,d,e };
	sort(loss.begin(), loss.end());
	reverse(loss.begin(), loss.end());

	ANS = (A + a) + (B + b) + (C + c) + (D + d) + (E + e) - loss.at(0);
	cout << ANS << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <algorithm>
#include <cstring>
#include <utility>
#include <vector>
#include <map>
#include <set>
#include <cmath>
#include <queue>
#include <bitset>
#include <stack>
#include <deque>
using namespace std;
typedef pair<int, int> pii;
typedef long long LL;

int main() {
    int N;
    scanf("%d", &N);
    int ans = 0;
    scanf("%d", &ans);
    for (int i = 1; i < N; i++) {
        int tmp;
        scanf("%d", &tmp);
        ans = __gcd(ans, tmp);
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 256
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <cmath>
using namespace std;
const int N=100005;
int n,m,fa[N],d[N];
int getf(int k){
	if (fa[k]==k)
		return k;
	int f=fa[k];
	fa[k]=getf(fa[k]);
	d[k]+=d[f];
	return fa[k];
}
int main(){
	scanf("%d%d",&n,&m);
	for (int i=1;i<=n;i++)
		fa[i]=i;
	memset(d,0,sizeof d);
	for (int i=1;i<=m;i++){
		int L,R,D;
		scanf("%d%d%d",&L,&R,&D);
		if (getf(L)==getf(R)){
			if (d[L]-d[R]!=D){
				puts("No");
				return 0;
			}
		}
		else {
			int A=getf(L),B=getf(R);
			fa[B]=A,d[B]=d[L]-D-d[R];
		}
	}
	puts("Yes");
	return 0;
}

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

int main(){
    int n,mark,number;
    string card,out;
    int c[4][13]={0};
    cin >> n;
    for(int i=0;i<n;i++){
        cin>>card>>number;
        if(card =="S") mark=0;
        if(card =="H") mark=1;
        if(card =="C") mark=2;
        if(card =="D") mark=3;
        c[mark][number-1]=1;
    }
    for(int j=0;j<4;j++){
        for(int k=0;k<13;k++){
            if(c[j][k]==0){
                if(j==0) out="S";
                if(j==1) out="H";
                if(j==2) out="C";
                if(j==3) out="D";
                cout << out << " " << k+1 << endl; 
            }
        }
    }
    return 0;
}


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

int main() {
    int n;
    cin >> n;
    vector<ll> dp(n + 1, 0);
    for (int x = 1; x * x <= n; x++){
        for (int y = 1; y * y <= n; y++){
            for (int z = 1; z * z <= n; z++){
                int val = x * x + y * y + z * z;
                val += x * y + x * z + y * z;
                if(val <= n){
                    dp[val]++;
                }
            }
        }
    }
    rep(i,n){
        cout << dp[i + 1] << endl;
    }
}


Measured memory_bytes: 3572
import java.util.*;
 
public class Main{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);

        long N = sc.nextLong();
        sc.close();
        long a = 1;
        List<Integer> list = new ArrayList<>();
        int count = 0;
        if(N == 0)
            System.out.println(0);
        while(N != 0){
            if(N % (2*a) != 0)
                list.add(1);
            else
                list.add(0);
            N -= list.get(count) * Math.pow(-2, count);
            a *= 2;
            count++;
        }

        for(int i = 0; i < list.size(); i++){
            System.out.print(list.get(list.size()-1-i));
        }

    }
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define rep(i, m, n) for (lli i = m; i < (n); i++)
#define repe(i, m, n) for (lli i = m; i <= (n); i++)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((lli)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define _GLIBCXX_DEBUG
const lli INF = 2147483647;
const lli MINF = -2147483648;
const lli LINF = 9223372036854775807;
const lli MOD = 1000000007; //10^9+7
const double PI = acos(-1);
#define SORT(n) sort(n.begin(), n.end())
#define SORTR(n) sort(n.begin(), n.end(), greater<int>())
#define REV(n) reverse(n.begin(), n.end())
#define pb push_back
#define eb emplace_back
#define mp make_pair
#pragma GCC optimize("Ofast")
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vlli = vector<lli>;
using vvli = vector<vlli>;
using vs = vector<string>;
using vvs = vector<vs>;
using vb = vector<bool>;
using vvb = vector<vb>;
using ll = long long;
// vector入力
template <typename T>
istream &operator>>(istream &is, vector<T> &vec)
{
  for (T &x : vec)
    is >> x;
  return is;
}
// vector出力
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec)
{
  // os << '{';
  for (int i = 0; i < vec.size(); i++)
  {
    os << vec[i] << (i + 1 == vec.size() ? "" : "");
  }
  // os << '}';
  return os;
}
// aよりもbが大きいならばaをbで更新する(更新されたならばtrueを返す)
template <typename T>
bool chmax(T &a, const T &b)
{
  if (a < b)
  {
    a = b; // aをbで更新
    return true;
  }
  return false;
}
// aよりもbが小さいならばaをbで更新する(更新されたならばtrueを返す)
template <typename T>
bool chmin(T &a, const T &b)
{
  if (a > b)
  {
    a = b; // aをbで更新
    return true;
  }
  return false;
}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  lli a, b, t, c, h, k, n, v, w, ans = 0, count = 0;
  string s;
  vector<pair<string, pair<lli, lli>>> pr;
  cin >> a >> v;
  cin >> b >> w;
  cin >> t;

  lli a_m = v * t;
  lli b_m = w * t;
  lli dist = abs(a - b);

  // ans = a + a_m;
  // count = b + b_m;
  // lli dis = abs(ans - count);

  ans = (dist + b_m) - a_m;

  if (ans <= 0)
  {
    cout << "YES" << endl;
  }
  else
  {
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 3656
using namespace std;
#include <iostream>/*{{{*/
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

#include <bits/stdc++.h>

#define rep(i, x) for(int i = 0; i < (int)(x); i++)
#define reps(i,x) for(int i = 1; i <= (int)(x); i++)
#define rrep(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define rreps(i,x) for(int i=((int)(x));i>0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define RFOR(i, m, n) for(int i = m;i >= n;i--)
#define foreach(x,a) for(auto& (x) : (a) )
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define fill(x,y) memset(x,y,sizeof(x))
#define pb(a) push_back(a)
// dump macro{{{
// http://www.creativ.xyz/dump-cpp-652
#define DUMPOUT cerr // 変数ダンプ先。coutかcerr
 
#define DEBUG_ // 提出時はコメントアウト
#ifdef DEBUG_
#define DEB
#else
// DEB と打つとデバッグ時以外はコメントアウトになる
#define DEB /##/
#endif
 
// 変数ダンプ用マクロ。デバッグ時以外は消滅する
// 引数はいくつでもどんな型でも可（ストリーム出力演算子があればOK）
#define dump(...) DEB DUMPOUT<<"  "; \
DUMPOUT<<#__VA_ARGS__; \
DUMPOUT<<":=> "; \
dump_func(__VA_ARGS__); DUMPOUT<<"in ["<<__LINE__<<":"<<__FUNCTION__<<"]"<<endl;
 
// デバッグ用変数ダンプ関数
void dump_func() {
}
template <class Head, class... Tail>
void dump_func(Head&& head, Tail&&... tail)
{
    DUMPOUT << head;
    if (sizeof...(Tail) == 0) {
        DUMPOUT << " ";
    }
    else {
        DUMPOUT << ", ";
    }
    dump_func(std::move(tail)...);
}
 
// vector出力
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec) {
    os << "{";
    for (int i = 0; i<vec.size(); i++) {
        os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
    }
    os << "}";
    return os;
}/*}}}*/
#define debug(x)                 cerr << __LINE__ << ": " << #x << " -> " << x << '\n'
#define debug2(x, y)             cerr << __LINE__ << #x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define debug3(x, y, z)          cerr << __LINE__ << #x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define debug4(a, b, c, d)       cerr << __LINE__ << #a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define debug5(a, b, c, d, e)    cerr << __LINE__ << #a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define debug6(a, b, c, d, e, f) cerr << __LINE__ << #a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define db_2d(d,n,m) rep(i,n){rep(j,m){ cerr << (d)[i][j] << (((j)==(m-1))?"\n":" "); }}
#define db_1d(d,n) rep(i,n){cout << d[i] << (((i)==(n-1))?"\n":" ") << __LINE__}
#define INF 999999999
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long long ll;
typedef vector<long long> vll;
typedef vector<vll> vvll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<pii> vii;
typedef vector<vii> vvii;
typedef tuple<int,int,int> iii;
typedef set<int> si;
typedef complex<double> pnt;
typedef vector<pnt> vpnt;
typedef priority_queue<pii,vii,greater<pii> > spq;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};/*}}}*/

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

  cout << max(0, min(b,d)-max(a,c))<< endl;

  return 0;
}


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

int main() {
  int W, a, b;
  cin >> W >> a >> b;
  if (a - b > W)
    cout << a - b - W << endl;
  else if (b - a > W)
    cout << b - a - W << endl;
  else
    cout << 0 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  int L, R;
  L = A + B;
  R = C + D;
  
  if (L > R){
    cout << "Left" << endl;
  }
  if (L < R){
    cout << "Right" << endl;
  }
  if (L == R){
    cout << "Balanced" << endl;
  }
  
    

}


Measured memory_bytes: 3556
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n;
		while ((n = in.nextInt()) != 0) {
			int a = 0, b = 0;
			for (int i = 0; i < n; i++) {
				int pa = in.nextInt();
				int pb = in.nextInt();
				a += pa;
				b += pb;
				if (pa > pb) {
					a += pb;
					b -= pb;
				} else if (pa < pb) {
					a -= pa;
					b += pa;
				}
			}
			System.out.println(a + " " + b);
		}
	}
}

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

using namespace std;
using ll = long long;
using pii = pair<int, int>;

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  vector<int> a(5);
  for (int i = 0; i < 5; i++) {
    cin >> a[i];
  }
  sort(a.rbegin(), a.rend());
  for (int i = 0; i < 5; i++) {
    cout << a[i] << " \n"[i + 1 == 5];
  }

  return 0;
}


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

typedef int integer;
typedef pair<long long,long long> pr;

#define FIN ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define ld long double
#define pb push_back
#define bs binary_search
#define up upper_bound
#define lw lower_bound
#define fst first 
#define snd second 
#define mp make_pair    

#define fore(i,a,b) for(int i = a; i < b; i++)
#define rfore(i, a, b) for(ll i = a - 1; i >= b; i--)
#define forev(a,b) fore(i,0,b)cout<<a[i]<<" "; 
#define mm(a,b) memset(a , b , sizeof a) 
#define ALL(a) a.begin(),a.end() 
#define SZ(n) ((ll) (n).size())

#define infll (long long)1e7
#define INF (long long)1e15
#define inf  (int)2e9
#define int long long
#define endl '\n'

const ld pi = acos(-1);
const ll MOD = 1e9+7;
const ld EPS = 1e-9;
const int MAX_N = 2e5;

ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b,a%b); } 
ll lcm(ll a, ll b) { return a * (b / gcd(a, b)); }
ll fpow(ll b, ll e, ll m = MOD){if(!e)return 1;ll q=fpow(b,e/2,m);q=(q*q)%m;return e&1?(b*q)%m:q;}


integer main(){FIN;
	int n; int k; cin>>n>>k;
	priority_queue<int> pq;
	fore(i,0,n){
		int x; cin>>x;
		pq.push(x);
	}
	int sum=0;
	while(!pq.empty()){
		if(k<=0){
			sum+=pq.top();
		}
		pq.pop();
		k--;
	}
	cout<<sum<<endl;
    return 0; 
}




Measured memory_bytes: 3444
import math
import sys

N = int(input())
GA, SA, BA = list(map(int, input().split()))
GB, SB, BB = list(map(int, input().split()))

def knapsack(n, ga, sa, ba, gb, sb, bb):
    values = []
    weights = []
    if gb / ga > 1:
        values.append(gb - ga)
        weights.append(ga)
    if sb / sa > 1:
        values.append(sb - sa)
        weights.append(sa)
    if bb / ba > 1:
        values.append(bb - ba)
        weights.append(ba)
    if len(values) == 3:
        # dp[i]: 重さ i 以下で選ぶのの価値の最大値
        dp = [0] * (n + 1)
        dp[0] = n
        for i in range(1, n + 1):
            x = dp[i - 1]
            for w, v in zip(weights, values):
                if i - w >= 0:
                    x = max(x, dp[i - w] + v)
            dp[i] = x
        return dp[n]
    if len(values) == 2:
        w1, w2 = weights
        v1, v2 = values
        if (v1 + w1) / w1 < (v2 + w2) / w2:
            v1, v2 = v2, v1
            w1, w2 = w2, w1
        c1 = n // w1
        c2 = (n - w1 * c1) // w2
        ret = n + v1 * c1 + v2 * c2
        while c1 >= 0:
            a = n - w1 * c1 - w2 * c2
            c1 -= max(1, math.ceil((w2 - a) / w1))
            c2 = (n - w1 * c1) // w2
            ret = max(ret, n + v1 * c1 + v2 * c2)
            if w1 * c1 + w2 * c2 == n:
                break
        return ret
    if len(values) == 1:
        return n + n // weights[0] * values[0]
    return n

ans = knapsack(N, GA, SA, BA, GB, SB, BB)
ans = knapsack(ans, GB, SB, BB, GA, SA, BA)
print(int(ans))

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

using namespace std;
#define int long long
const int p=998244353;
const int maxn=400000;
int po(int a,int b)
{
    if(b==0)
    {
        return 1;
    }
    if(b==1)
    {
        return a;
    }
    if(b%2==0)
    {
        int u=po(a,b/2);
        return (u*u)%p;
    }
    if(b%2==1)
    {
        int u=po(a,b-1);
        return (a*u)%p;
    }
}
int inv(int x)
{
    return po(x,p-2);
}
int fact[maxn];
int invf[maxn];
int c(int n,int k)
{
    int ans=fact[n];
    ans*=invf[k];
    ans%=p;
    ans*=invf[n-k];
    ans%=p;
    return ans;
}
int32_t main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int u=1;
    for(int i=0;i<maxn;++i)
    {
        fact[i]=u;
        invf[i]=inv(fact[i]);
        u*=(i+1);
        u%=p;
    }
    int n,m,k;
    cin>>n>>m>>k;
    int sum=0;
    for(int i=0;i<=k;++i)
    {
        int ans=m;
        ans*=po(m-1,n-i-1);
        ans%=p;
        ans*=c(n-1,i);
        ans%=p;
        sum+=ans;
        //cout<<ans<<" ans "<<endl;
        sum%=p;
    }
    cout<<sum;
    return 0;
}


Measured memory_bytes: 9896
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define doublecout(a) cout<<fixed<<setprecision(15)<<a<<endl;
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second
#define P pair<ll,ll> 
#define m_p make_pair
#define V vector<ll> 

ll n,cnt,ans,a[ohara],b[ohara],c[ohara],d[ohara],tmp,tmpp,m,h,w,x,y,sum,pos,k;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};
vector<ll> g[ohara];
ll nannkai[ohara];
P p[ohara];
ll koutiku[ohara];
bool vi[ohara];
ll p_cou;

//-------------------------↓↓↓↓↓↓------------------------

void dfs(ll now,ll depth){
    if(vi[now])return;
    vi[now]=true;
    p[p_cou++]=m_p(depth,now);
    rep(i,Size(g[now])){
        dfs(g[now][i],depth+1);
    }
}

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

    cin>>n;
    rep(i,n-1){
        cin>>a[i]>>b[i];
        a[i]--;b[i]--;
        nannkai[a[i]]++;
        nannkai[b[i]]++;
        g[a[i]].push_back(b[i]);
        g[b[i]].push_back(a[i]);
    }
    rep(i,n)cin>>c[i];
    rep(i,n){
        if(nannkai[i]==1){
            tmp=i;
            break;
        }
    }
    dfs(tmp,0LL);
    sort(p,p+n);
    reverse(p,p+n);
    sort(c,c+n);
    rep(i,n){
        koutiku[p[i].se]=c[i];
    }
    rep(i,n-1){
        ans+=min(koutiku[a[i]],koutiku[b[i]]);
    }
    Cout(ans);
    rep(i,n){
        if(i==n-1)Cout(koutiku[i]);
        else cout<<koutiku[i]<<" ";
    }
    return 0;
}


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

 using namespace std;

 int main() {
   int A, B, K;

   cin >> A >> B >> K;

   vector<int> CD(101);

   int counter = 0;
   for (int i = 1;i <= min(A, B); i++) {
     if (A % i == 0 && B % i == 0) {
       CD.at(counter) = i;
       counter++;
     }
   }

   sort(CD.begin(), CD.end());
   reverse(CD.begin(), CD.end());

   cout << CD.at(K - 1) << endl;
}


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


int main(){
    int N,M;cin>>N>>M;
    vector<string> a(N),b(M);
    rep(i,0,N)cin>>a.at(i);
    rep(i,0,M)cin>>b.at(i);
    int ok=1;
    rep(i,0,N-M+1){
        rep(j,0,N-M+1){
            ok=1;
            rep(k,0,M){
                rep(l,0,M){
                    if(a.at(i+k).at(j+l)!=b.at(k).at(l))ok=0;
                }
            }
            if(ok==1)goto BR;
        }
    }
    BR:
    if(ok)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}






Measured memory_bytes: 256
#include <bits/stdc++.h>
template<class T> inline bool chmin(T&a, T b){if(a > b){a = b; return true;}else{return false;}}
template<class T> inline bool chmax(T&a, T b){if(a < b){a = b; return true;}else{return false;}}
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1.0)
#define P pair<int,int>
#define PiP pair<ll,pair<ll,ll>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

int main(){
    int n, m;
    cin >> n;
    vector<int> t(n);
    rep(i, n)cin >> t[i];
    int sum = accumulate(all(t), 0);
    cin >> m;
    rep(i, m){
        int p, x;
        cin >> p >> x; p--;
        cout << sum - t[p] + x << endl;
    }
}

Measured memory_bytes: 3612