akhauriyash/Code-Regression huggingface dataset:
//
/*==========================================================*/
/*    Template ver 2017-0720    |    Created by JollyBee    */
/* DOMINUS pascit me, et nihil mihi deerit (Psalmorum 23:1) */
/*==========================================================*/
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vii;
const double EPS=(double)1e-9;
const double PI=(double)acos(-1.0);
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define FOR(i,n) for(int i=0;i<n;i++)
#define REPP(i,l,r,c) for(int i=l;i<=r;i+=c)
#define REP(i,l,r) REPP(i,l,r,1)
#define FORD(i,n) for(int i=n-1;i>=0;i--)
#define REVV(i,l,r,c) for(int i=l;i>=r;i-=c)
#define REV(i,l,r) REVV(i,l,r,1)
//random
int irand(int lo, int hi){
    return (((double)rand())/(RAND_MAX+1.0)) * (hi-lo+1) + lo;
}
//ll to string
string toString(ll x) {
    stringstream ss;
    ss << x;
    return ss.str();
}
//string to ll
ll toNumber(string S) {
    ll ret;
    sscanf(S.c_str(),"%lld",&ret);
    return ret;
}
// std::fill(start, end, value);
// for(auto it: DS){}

const int INF=(int)2e9;
const ll MOD=(ll)1e9+7;
/*==========================================================*/
/*                     END OF TEMPLATE                      */
/* DOMINUS pascit me, et nihil mihi deerit (Psalmorum 23:1) */
/*==========================================================*/

const int OFFS = 2;

set<pii> dat;
ll res[15];

int main(){
    FOR(i,13) res[i] = (ll)0;
    dat.clear();
    //
    int h,w,n; scanf("%d %d %d", &h, &w, &n);
    res[0] = (ll)(h-2) * (ll)(w-2);
    FOR(xxx,n){
        int subs[5][5];
        int a,b; scanf("%d %d", &a, &b);
        REP(i,a-2,a+2) REP(j,b-2,b+2){
            subs[i-a+OFFS][j-b+OFFS] = (dat.find(mp(i,j)) != dat.end());
        }
        REP(i,a-1,a+1) REP(j,b-1,b+1){
            if(i-1 < 1 || h < i+1) continue;
            if(j-1 < 1 || w < j+1) continue;
            //
            int cnt = 0;
            REP(ix,i-1,i+1) REP(jx,j-1,j+1){
                cnt += subs[ix-a+OFFS][jx-b+OFFS];
            }
            res[cnt  ] -= 1;
            res[cnt+1] += 1;
        }
        dat.insert(mp(a,b));
    }
    FOR(i,10) printf("%lld\n", res[i]);
    return 0;
}


Measured memory_bytes: 5116
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count __gcd reverse etc.
#include <cstdlib>	// require abs exit atof atoi 
#include <cstdio>		// require scanf printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>		// require fabs
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream 
#include <cstring>	// require memset
#include <cctype>		// require tolower, toupper
#include <fstream>	// require freopen
#include <ctime>		// require srand
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()

using namespace std;

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

int icicles[100005];
int n, l;

int dfs (int curr )
{
	int res = max (0, l - icicles[curr] );
	
	// curr のつららが一番大きい
	if (icicles[curr-1] < icicles[curr] && icicles[curr] > icicles[curr+1] ){
		return res;
	}else	// 前のつららが大きく、後ろのつららが小さい
	if (icicles[curr-1] > icicles[curr] && icicles[curr] > icicles[curr+1] ){
		return res + dfs (curr-1);
	}else	// 前のつららが小さく、後ろのつららが大きい
	if (icicles[curr-1] < icicles[curr] && icicles[curr] < icicles[curr+1] ){
		return res + dfs (curr+1);
	}else{	// curr のつららが一番小さい
		return res + max (dfs (curr-1), dfs (curr+1) );
	} // end if
}

int main()
{
//	cut here before submit 
//	freopen ("testcase.icicles4", "r", stdin );
	while (scanf ("%d %d", &n, &l ) != EOF ){
		memset (icicles, 0, sizeof (icicles ) );
		for (int i = 1; i <= n; i++ ){
			scanf ("%d", &icicles[i] );
		} // end rep
		
		int res = 0;
		for (int i = 1; i <= n; i++ ){
			int curr = dfs (i );
			res = max (res, curr );
		} // end for
		printf ("%d\n", res );

	} // end loop
		
	return 0;
}

Measured memory_bytes: 1584
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include<cmath>
#include<stack>
#include<set>
#include<map>
#include<stdio.h>
#include<functional>

using ll = long long;

using namespace std;

ll mod = 1000000007;

ll n_pow(ll a, ll n) {
	if (n == 0)return 1;
	ll t = n_pow(a, n / 2);
	t *= t;
	t %= mod;
	if (n % 2 == 1)t *= a;
	return t % mod;
}


int main() {
	int n;
	cin >> n;
	vector<int>a(n);
	for (int i = 1; i < n; i++) {
		cin >> a[i];
		a[i]--;
	}
	vector<int>ans(n);
	for (int i = 1; i < n; i++) {
		ans[a[i]]++;
	}
	for (int i = 0; i < n; i++) {
		cout << ans[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 4776
from itertools import product
while 1:
    N = int(input())
    if N == 0:
        break
    M = int(input())
    S = [0]*N
    A = [[None]*N for i in range(N)]
    for i in range(M):
        x, y = map(int, input().split()); x -= 1; y -= 1
        S[x] += 1
        A[x][y] = 1; A[y][x] = 0
    B = []
    for i in range(N):
        for j in range(i+1, N):
            if A[i][j] is None:
                B.append((i, j))
    L = len(B)
    memo = [{} for i in range(L)]
    def dfs(k, s):
        if L == k:
            return all(e <= N//2 for e in s)
        key = tuple(s)
        v = memo[k]
        if key in v:
            return v[key]
        res = 0
        i, j = B[k]
        if s[i]+1 <= N//2:
            s[i] += 1
            res += dfs(k+1, s)
            s[i] -= 1
        if s[j]+1 <= N//2:
            s[j] += 1
            res += dfs(k+1, s)
            s[j] -= 1
        v[key] = res
        return res
    print(dfs(0, S))



Measured memory_bytes: 43624
n,w=map(int,input().split())
wv=[tuple(map(int,input().split())) for i in range(n)]
wv.sort(key=lambda x:-x[1])#reverse
wv.sort(key=lambda x:x[0])

w0=wv[0][0]
x=[[0],[0],[0],[0]]
for i in range(n):
    z=wv[i][0]-w0
    k=wv[i][1]+x[z][-1]
    l=len(x[z])
    x[z].append(k)
#print(x)
#print(w0)
ma=0
l3=len(x[3])
l2=len(x[2])
l1=len(x[1])
l0=len(x[0])
for i in range(l3):
    for j in range(l2):
        d=w-i*(w0+3)-j*(w0+2)
        if d>=0:
            for k in range(l1):
                d=w-i*(w0+3)-j*(w0+2)-k*(w0+1)
                if d>=0:
                    ma=max(ma,x[3][i]+x[2][j]+x[1][k]+x[0][min(d//w0,l0-1)])
                else:
                    break
        else:
            break

print(ma)


Measured memory_bytes: 3064
import math

N = int(input())
a = int(math.sqrt(N))

ans = [0]*2
for i in reversed(range(1, a+1)):
  if N % i == 0:
    ans[0] = i
    ans[1] = N // i
    break
res = 0
for e in ans:
  now = len(str(e))
  if now > res:
    res = now
    
print(res)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const long long LINF=8931145141919364364,LMOD=998244353;
// const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};

int main(){
    int n;cin>>n;
    if(n==1) cout<<"Hello World"<<endl;
    else{
        int a,b; cin>>a>>b;
        cout<<a+b<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>


using namespace std;

//conversion
//------------------------------------------
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(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x*x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define loop(n) FOR(i,0,n)
#define rrep(i,a,b) for(int i=(a);i>=(b);--i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

LL H[101][101];

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

	vector<int> x(n);
	vector<int> y(n);
	vector<int> h(n);

	//h!=0でないから高さを計算すれば確定点。
	//cx,cyの組合せだったときの高さを事前計算しておく。
	int indexofnonzero = -1;
	for (int i = 0; i < n; i++) {
		cin >> x[i] >> y[i] >> h[i];

		if (h[i] != 0) {
			indexofnonzero = i;
		}
	}
	
	for (int cy = 0; cy <= 100; cy++) {
		for (int cx = 0; cx <= 100; cx++) {
					H[cy][cx] = h[indexofnonzero] + abs(x[indexofnonzero] - cx) + abs(y[indexofnonzero] - cy);
		
		}
	}
	
	//cx,cyをすべての地点にnまで調べあげて。高さに矛盾がないか調べる。
	//最後までたどりついたら出力して終了。
	for (int cy = 0; cy <= 100; cy++) {
		for (int cx = 0; cx <= 100; cx++) {
			for (int i = 0; i < n; i++) {

				if (h[i] != 0) {
					int bufH = h[i] + abs(x[i] - cx) + abs(y[i] - cy);
					if (H[cy][cx] != bufH) {
						break;
					}
				}
				else {
					int dist= abs(x[i] - cx) + abs(y[i] - cy);
					if (H[cy][cx] > dist) {
						break;
					}
				}
				
				if (i == n - 1) {
					cout << cx << " " << cy << " " << H[cy][cx] << endl;
					return 0;
				}
				

			}
				
		}
	}

	return 0;
}

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

#define int long long
#define pii pair<int,int>
#define INF (int)1e18
#define all(v) v.begin(), v.end()


int32_t main(){
    ios_base::sync_with_stdio(false),cin.tie(),cout.tie();
    // If you hack my code, you are gay
    int n;
    cin>>n;
    int ara[n];
    for(int i=0;i<n;i++){
        char x;
        cin>>x;
        ara[i]=(x=='R')?1:(x=='G')?2:3;
    }
    int suf[4][n+1];
    memset(suf,0,sizeof(suf));
    for(int i=n-1;i>=0;i--){
        suf[ara[i]][i]++;
        for(auto x:{1,2,3}) suf[x][i]+=suf[x][i+1]; 
    }
    int ans=0;
    for(int i=0;i<n-2;i++){
        for(int j=i+1;j<n-1;j++)if(ara[i]!=ara[j]){
            ans+=suf[ara[i]^ara[j]][j+1]-(2*j-i<n && ara[2*j-i]==(ara[i]^ara[j]));
        }
    }
    cout<<ans;
    return 0;
}

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

int main() {
    int n,a=0,w=0,t=0,r=0;
    string s;
    cin >> n;
    rep(i,n){
        cin >> s;
        if(s == "AC"){
            a++;
        }else if(s == "WA"){
            w++;
        }else if(s == "TLE"){
            t++;
        }else{
            r++;
        }
    }
    printf("AC x %d\n",a);
    printf("WA x %d\n",w);
    printf("TLE x %d\n",t);
    printf("RE x %d\n",r);
    return 0;
}

Measured memory_bytes: 3672
import sys

N, A, B = map(int, sys.stdin.readline().split())
S = sys.stdin.readline()

YES = 'Yes'
NO = 'No'
n = 0
b = 0
for s in S:
    if s == 'c':
        print(NO)
    elif s == 'a':
        if n < A + B:
            print(YES)
            n += 1
        else:
            print(NO)
    elif s == 'b':
        if n < A + B and b < B:
            print(YES)
            n += 1
            b += 1
        else:
            print(NO)


Measured memory_bytes: 4040
import java.util.*;
import java.lang.*;

class Mod{
    static final long MOD = 1000_000_007;
    static final long[] fact = makeFactorialArray(1000000);
    static final long[] factInv = makeInversedArray(fact);

    public static long add(long a, long b){
        long tmp = (a+b)%MOD;
        return tmp>=0 ? tmp : tmp+MOD;
    }
    public static long adds(long... ar){
        long ans=0;
        for(long x:ar) ans = Mod.add(ans, x);
        return ans;
    }
    public static long sub(long a, long b){
        return add(a,-b);
    }
    public static long mult(long a, long b){
        long tmp = (a*b)%MOD;
        return tmp>=0 ? tmp : tmp+MOD;
    }
    public static long mults(long... ar){
        long ans=1;
        for(long x:ar) ans = Mod.mult(ans, x);
        return ans;
    }
    public static long power(long a, long x){ //calculate a^x
        if(x<0)return 0;
        if(x==0)return 1;
        if(x%2==0) {
            long half = power(a,x/2);
            return mult(half,half);
        }
        return (a*power(a,x-1)) % MOD;
    }
    public static long inverse(long a){
        return power(a,MOD-2);
    }
    public static long div(long a, long b){
        return mult(a, inverse(b));
    }
    public static long[] makeFactorialArray(int size){
        long[] array = new long[size];
        array[0]=1;
        for(int i=1;i<size;i++){
            array[i]=mult(array[i-1],i);
        }
        return array;
    }
    public static long[] makeInversedArray(long[] original){
        long[] array = new long[original.length];
        for(int i=0;i<original.length;i++){
            array[i] = inverse(original[i]);
        }
        return array;
    }
    public static long combination(int n, int r){
        if(n<0 || r<0 || n<r) return 0;
        return mult(fact[n], mult(factInv[r],factInv[n-r]));
    }
    public static long gcd(long a, long b){
        if(a<b) return gcd(b,a);
        if(b==0) return a;
        if(a%b==0) return b;
        return gcd(b,a%b);
    }
    public static long lcm(long a, long b){
        return (a/gcd(a,b))*b;
    }

}

public class Main {
    static long invNum(long[] array){
        long ans = 0;
        for(int i=0; i<array.length; i++) for(int j=i+1; j<array.length; j++){
            if(array[i] > array[j]) ans++;
        }
        return ans;
    }
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        long K = sc.nextLong();
        long[] A = new long[N];

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

        long ans = invNum(A) * K;

        for(int i=0; i<N; i++) for(int j=0; j<N; j++){
            if(A[i] > A[j]) ans = Mod.add(ans, K*(K-1)/2);
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 45576
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
#define show(obj) {for(auto x:obj)cout<<x<<' ';cout<<endl;}
#define line "----------"
typedef long long ll;
typedef pair<int,int> ip;
typedef pair<ll,ll> lp;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

int main(){
	int K,a,b; cin>>K>>a>>b;
	bool ok = false;
	for(int i = a; i<=b; ++i)if(i%K==0)ok = true;
	cout<<((ok)?"OK":"NG")<<endl;
	return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <numeric>
#include <cstdio>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
using namespace std;
#define MOD 1000000007
#define endl "\n" 
#define rep(i,n) for(int i = 0; i < (n); ++i)
typedef long long ll;


int main(void) {
    cin.tie(0);
    ios::sync_with_stdio(false);
  
    string a, b; cin >> a >> b;
    string ab = a+b;
    int num = stoi(ab);
    for(int i = 1; i*i <= num; ++i) {
        if(i*i == num) {
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_map>
#include<fstream>
#include<list>
#include<typeinfo>
#include<functional>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;



    
int main(){
    ll n,t;
    cin>>n>>t;
    ll mi=E;
    for(int i=0;i<n;i++){
        ll a,b;
        cin>>a>>b;
        if(b<=t){mi=min(mi,a);}
    }
    if(mi==E){cout<<"TLE"<<endl;}
    else{cout<<mi<<endl;}
    
    
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int x = 0;
  int i, N;
  cin >> N;
  
  vector<char> L(N);
  for(i=0; i<N; i++)
  	cin >> L.at(i);
  
  for(i = 0; i<N; i++){
    if(L.at(i) == 'Y') x = 1;
  }
  if(x == 1)
    cout << "Four" << endl;
  else
    cout << "Three" << endl;
}

Measured memory_bytes: 256
R,G,B,N=map(int,input().split())
count=0

for r in range(N+1):
  for g in range(N+1):
    Bb=N-R*r-G*g
    if Bb>=0:
      #print(r,g,Bb)
      if Bb%B==0:
        count+=1
    else:
      break
      
print(count)

Measured memory_bytes: 2940
/*
LANG:C++
PROB:

*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>
#include <iostream>
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)


using namespace __gnu_pbds;
using namespace std;


typedef tree<int, null_type, less<int>, rb_tree_tag,
            tree_order_statistics_node_update>
    ordered_set;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;
typedef unsigned long long ui64;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }
const int mod=1000000007;
  i64 poww(i64 a, i64 b)
  {
    a%=mod;
    i64 res=1;
    while(b)
      {
if(b&1)res=res*a%mod;

      a=a*a%mod;
      b/=2;

      }
      return res;
  }
  i64 inv(i64 a)
  {
    return poww(a,mod-2);
  }


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

    // ifstream fin(".in");
    // ofstream fout(".in");
int a,b,c;
cin>>a>>b>>c;
cout<<c<<" "<<a<<" "<<b;



    return 0;
  }


Measured memory_bytes: 256
#include <math.h>
#define Rep(i,a,n)for(int i=(int)(a);i<(int)(n);i++)
#define rep(i,n)Rep(i,0,n)
#define Ma(x,y)(x>y?x:y)
int main(){
	int n,k,t,all[6]={0},d[10]={0};
	scanf("%d%d",&n,&k);
	rep(i,k){scanf("%d",&t);d[t]++;}
	if(n==1&&d[1]!=1){printf("1");return 0;}
	t++;
	Rep(i,2<n?n:2,1e5){
		rep(j,log10(i)+1){
			all[j]=(i%(int)pow(10,j+1))/(int)pow(10,j); 
			rep(x,10)if(d[all[j]])t=0;
		}
		if(t){printf("%d",i);return 0;}
		t++;
	}
}

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

int main(void){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    if(a+b == c+d)cout << "Balanced" << endl;
    else if(a+b > c+d)cout << "Left" << endl;
    else cout << "Right" << endl;
}

Measured memory_bytes: 256
function Main(input) { // input="2312 312 312"
    tmp = input.split(" "); // [ "2312","312" ,"312"  ]
    //文字列から10進数に変換するときはparseIntを使います
    var A = parseInt(tmp[1]); // tmp[0] == "2312" parseInt(..) == 2312
    var B = parseInt(tmp[2]);
    var N = parseInt(tmp[0]);
    var NA = 0;
    NA = N * A;
    if (NA <= B) {
        console.log(NA)
    } else if (NA >= B) {
        console.log(B)
    };
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

int main(){
  long long int A, B, K;
  cin >> A >> B >> K;
  
  if(A - K > 0){
    A -= K;
  }else{
    K -= A;
    A = 0;
  }
  
  if(A == 0){
    if(B - K > 0) B -= K;
    else B = 0;
  }
    
  cout << A << " " << B;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
long double pi = 2 * acos(0.0);
const ll mod = 1e9 + 7;

void solve() {
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << max({a * d, a * c, b * c, b * d}) << "\n";
}   

int main() {
    ios_base :: sync_with_stdio(false); 
    cin.tie(nullptr);   
    ll t = 1;
    //cin >> t;
    while(t--) {
        solve();
    }
    return 0;
}

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

using namespace std;
using ll = long long;

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

    int n;
    cin >> n;
    int a[21] = {};
    int b[21] = {};
    int c[21] = {};
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    for (int i = 0; i < n; i++)
    {
        cin >> b[i];
    }
    for (int i = 0; i < n; i++)
    {
        cin >> c[i];
    }
    
    int res = 0;
    res += b[a[0]-1];
    int prev = a[0];
    for (int i = 1; i < n; i++)
    {
        res += b[a[i]-1];
        if (prev+1 == a[i]) {
            res += c[prev-1];
        }
        prev = a[i];
    }
    

    cout << res << "\n";
    

}


Measured memory_bytes: 256
import sys
N = int(input())

if N == 2:
    print (1)
    sys.exit()

now = 1
ans = 0

def want(m):

    ns = N
    while ns % m == 0:
        ns = ns // m
    return ns % m

while now ** 2 <= N:

    if N % now == 0:

        n2 = N // now
        #print (now,n2)

        if now != 1:
            rev = want(now)
            if rev == 1:
                ans += 1


        if n2 != now and n2 != 1:

            rev = want(n2)
            if rev == 1:
                ans += 1

    now += 1

now = 1
while now ** 2 <= N-1:

    if (N-1) % now == 0:
        n2 = (N-1) // now

        if now != 1:
            ans += 1
        if now != n2:
            ans += 1
    now += 1
        
print (ans)


Measured memory_bytes: 40812
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < (n+1); i++)
#define OUT(s) cout << s << "\n";
using namespace std;


int K,A,B;
// https://atcoder.jp/contests/abc165
void Main()
{
    bool flg = false;
    FOR(i, A, B) {
        if ((i%K) == 0) {
            flg = true;
            break;
        }
    }
    if (flg) {
        OUT("OK");
    } else {
        OUT("NG");
    }

}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    // cout << fixed << setprecision(15);
    cin >> K >> A >> B;
    Main();
    return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < (int)b; i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    if (a + b + c >= 22) cout << "bust" << endl;
    else cout << "win" << endl;
    return 0;
}


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

#define ld long double
#define ll long long
#define ALL(a)  (a).begin(),(a).end()
#define spa << " " <<
ll MOD = 1e9+7;
void chmin(ll &a, ll b) { if (a > b) a = b; }
void chmax(ll &a, ll b) { if (a < b) a = b; }

int main(){
  ll i, j;
  vector<ll> a(3);
  cin >> a[0] >> a[1] >> a[2];
  sort(ALL(a));
  cout << a[0]  + a[1] + a[2] * 10 << endl;

  return 0;
}

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

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

    string ans[11];
    int cnt = 0;
    for (int i = 0; i < s.length(); ++i) {
        // バックスペースの場合の挙動
        if (s[i] == 'B') {
            cnt = max(0, cnt - 1);
        }
        // 上記以外の場合の挙動
        else {
            ans[cnt] = s[i];
            ++cnt;
        }
    }

    for (int i = 0; i < cnt; ++i) {
        cout << ans[i];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 504
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace D
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var n = int.Parse(Console.ReadLine());
            var ai = Console.ReadLine().Trim().Split(' ').Select(long.Parse).ToArray();
            var sum = 0L;
            var min = (long)Math.Pow(10, 9);
            var minIndex = 0;
            var minusCount = 0;
            for (var i = 0; i < ai.Length; i++)
            {
                if (ai[i] < 0) minusCount++;
                ai[i] = Math.Abs(ai[i]);
                if (ai[i] < min)
                {
                    min = ai[i];
                    minIndex = i;
                }
                sum += ai[i];
            }
            if (minusCount % 2 == 1) sum -= 2 * ai[minIndex];
            Console.WriteLine(sum);
        }
    }
}


Measured memory_bytes: 31196
#include<stdio.h>
#include<algorithm>
#include<string.h>
#include<string>
#include<math.h>
#include<stdlib.h>
#include<time.h>
#include<map>
#include<queue>
#include<set>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)
using namespace std;
int n,m,a[120000];
long long ans,f[120000],te,g[120000];
inline void add(int l,int r,int x){
	//if (l>r) return;//!!!
	//printf("%d %d %d\n",l,r,x);	
	f[l]+=x;
	f[r+1]-=x;
	f[r+1]-=r-l;
	g[l+1]++;
	g[r+1]--;
}
int main(){
	/*add(3,6,2);
	add(6,10,5);
	fo(i,1,10) g[i]+=g[i-1];
	fo(i,1,10) f[i]=f[i]+f[i-1]+g[i];
	fo(i,1,10) printf("%lld ",f[i]);putchar('\n');*/
	
	scanf("%d%d",&m,&n);
	fo(i,1,m) scanf("%d",&a[i]);
	fo(i,2,m){
		if (a[i-1]<=a[i]){
			ans+=a[i]-a[i-1];
			add(a[i-1]+1,a[i],0);//a[i]+1 !!!
		}else{
			ans+=a[i]+n-a[i-1];
			add(a[i-1]+1,n,0);//a[i]+1 !!! 
			add(1,a[i],n-a[i-1]);//n-a[i]!!!
		}
	}
	fo(i,1,n) g[i]+=g[i-1];
	fo(i,1,n) f[i]=f[i]+f[i-1]+g[i];
	te=f[1];
	fo(i,2,n) if (f[i]>te) te=f[i];
	//fo(i,1,n) printf("%lld ",f[i]);putchar('\n');
	printf("%lld\n",ans-te);
	return 0;
}

Measured memory_bytes: 2176
#include <iostream>
#include <vector>
#include <map>
#include <stack>
#include <list>
#include <queue>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <math.h>

#define PREP(i, m, n) for(int i = m; i < n; i++)
#define MREP(i, m, n) for(int i = m - 1; i >= n; i--)

#define rep(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, b) for(int i = a; i < b; i++)
#define all(v) v.begin(), v.end()
#define rev(v) v.rbegin(), v.rend()
#define prime first
#define weight second
#define MP make_pair
#define PB push_back

using namespace std;

int main(){
	map<char, bool> table;

	table['q'] = true;
	table['w'] = true;
	table['e'] = true;
	table['r'] = true;
	table['t'] = true;
	table['a'] = true;
	table['s'] = true;
	table['d'] = true;
	table['f'] = true;
	table['g'] = true;
	table['z'] = true;
	table['x'] = true;
	table['c'] = true;
	table['v'] = true;
	table['b'] = true;
	table['y'] = false;
	table['u'] = false;
	table['i'] = false;
	table['o'] = false;
	table['p'] = false;
	table['h'] = false;
	table['j'] = false;
	table['k'] = false;
	table['l'] = false;
	table['n'] = false;
	table['m'] = false;

	string input;
	while(cin >> input && input != "#"){
		int Switch = 0;
		bool currentState = table[input[0]];
		for(int i = 1; i < input.size(); i++){
			if(table[input[i]] != currentState){
				currentState = table[input[i]];
				Switch++;
			}
		}
		cout << Switch << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1192
import           Control.Applicative
import           Control.Monad
import           Control.Monad.ST
import           Data.Array.MArray
import           Data.Array.ST
import           Data.Array.Unboxed
import           Data.Char
import           Text.Printf         (printf)

createArray :: String -> UArray Char Int
createArray xs = runSTUArray $ do
    a <- newArray ('a', 'z') 0
    forM_ xs $ \x -> do
        n <- readArray a x
        writeArray a x (n + 1)
    return a

main :: IO ()
main = do
    xs <- fmap toLower . filter isAlpha <$> getContents
    let ary = createArray xs
    forM_ (assocs ary) $ \(a, k) -> do
        printf "%c : %d\n" a k



Measured memory_bytes: 4216
from collections import defaultdict
import sys
input = sys.stdin.readline


class Osak:
    def __init__(self, max_number=10 ** 6):
        self.max_number = max_number
        self.table = list(range(max_number + 1))
        self.calc_minimum_prime()

    def calc_minimum_prime(self):
        self.table[1] = 0
        for base in range(2, self.max_number + 1):
            if self.table[base] != base:
                continue
            for num in range(base, self.max_number+1, base):
                self.table[num] = base

    def judge_is_prime(self, num):
        return self.table[num] == num

    def get_factors(self, num):
        factors = set()
        while num > 1:
            prime = self.table[num]
            factors.add(prime)
            num //= prime
        return factors

    def factorize(self, num):
        factors = defaultdict(int)
        while num > 1:
            prime = self.table[num]
            factors[prime] += 1
            num //= prime
        return factors


def main():
    n = int(input())
    A = list(map(int, input().split()))

    osak = Osak(max(A))
    prime_count = defaultdict(int)
    for a in A:
        factors = osak.get_factors(a)
        for factor in factors:
            prime_count[factor] += 1
    
    if not prime_count:
        ans = 1
    else:
        ans = max(prime_count.values())

    if ans == 1:
        print("pairwise coprime")
    elif ans < n:
        print("setwise coprime")
    else:
        print("not coprime")


if __name__ == "__main__":
    main()


Measured memory_bytes: 179608
#include <iostream>
#include <cstring>
using namespace std;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {-1, 0, 1, 0};

void solve(int n) {
	if (n == 1) {
		cout << '#' << endl;
		return;
	}
	char field[n][n + 1];
	memset(field, ' ', sizeof(field));
	for (int i = 0; i < n; i++) {
		field[i][n] = '\0';
	}
	int x = 0, y = n - 1, d = 0;
	while (true) {
		field[y][x] = '#';
		int newX = x + dx[d];
		int newY = y + dy[d];
		if (newX < 0 || n <= newX || newY < 0 || n <= newY
				|| field[newY+ dy[d]][newX+ dx[d]] == '#') {
			d = (d + 1) % 4;
			newX = x + dx[d];
			newY = y + dy[d];
		}
		int count = 0;
		for (int i = 0; i < 4; i++) {
			int cx = newX + dx[i];
			int cy = newY + dy[i];
			if (0 <= cx && cx < n && 0 <= cy && cy < n && field[cy][cx] == '#') count++;
		}
		if (count > 1) break;
		x = newX;
		y = newY;
	}
	for (int i = 0; i < n; i++) {
		cout << field[i] << endl;
	}
}

int main () {
	int d;
	cin >> d;
	for (int i = 0; i < d; i++) {
		int n;
		cin >> n;
		if (i != 0) cout << endl;
		solve(n);
	}
	return 0;
}

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

using namespace std;

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

typedef long long i64;
typedef pair<i64, i64> pii;

constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

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

  int N;
  while (cin >> N, N) {
    int cnt = 0;
    bool isNA = false;
    while (N != 6174) {
      int tmp[20];
      rep(i, 4) {
        tmp[i] = N % 10;
        N /= 10;
      }
      if (tmp[0] == tmp[1] && tmp[1] == tmp[2] && tmp[2] == tmp[3]) {
        isNA = true;
        break;
      }
      else {
        sort(tmp, tmp + 4, greater<int>());
        int L = tmp[0] * 1000 + tmp[1] * 100 + tmp[2] * 10 + tmp[3];
        int S = tmp[3] * 1000 + tmp[2] * 100 + tmp[1] * 10 + tmp[0];
        N = L - S;
        ++cnt;
        if (N == 6174) break;
      }
    }
    if (isNA) cout << "NA" << '\n';
    else cout << cnt << '\n';
  }

  return 0;
}


Measured memory_bytes: 3156
// atcoder/abc168/D/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; for (auto& i: v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { for (auto& i: v) is >> i; return is; }
template<typename T> ostream& operator << (ostream& os, set<T> s) { os << "#{"; for (auto& i: s) os << i << ","; os << "}"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; for (auto& i: m) os << i << ","; os << "}"; return os; }

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

using lli = long long int;
using ull = unsigned long long;
using point = complex<double>;
using str = string;
template<typename T> using vec = vector<T>;

constexpr array<int, 8> di({0, 1, -1, 0, 1, -1, 1, -1});
constexpr array<int, 8> dj({1, 0, 0, -1, 1, -1, -1, 1});
constexpr lli mod = 1e9 + 7;

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.setf(ios_base::fixed);
  cout.precision(15);

  int n, m;
  while (cin >> n >> m) {
    vec<int> g[n];
    for (int i = 0; i < m; ++i) {
      int a, b;
      cin >> a >> b;
      --a;
      --b;
      g[a].push_back(b);
      g[b].push_back(a);
    }

    set<int> vis;
    int prev[n];
    queue<int> q;
    vis.insert(0);
    for (q.push(0); q.size(); q.pop()) {
      int curr = q.front();
      each (next, g[curr]) {
        if (vis.count(next)) continue;
        vis.insert(next);
        q.push(next);
        prev[next] = curr;
      }
    }

    cout << "Yes" << endl;
    for (int i = 1; i < n; ++i) {
      cout << prev[i]+1 << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 15072
n = int(input())
s = input()

r = s.count("R")
g = s.count("G")
b = s.count("B")

ans = r*g*b

for i in range(n):
    for j in range(i+1,n):
        k = j + (j-i)
        if k<n and set([s[i],s[j],s[k]])==set(["R","G","B"]):
            ans -= 1
print(ans)


Measured memory_bytes: 73916
#include <bits/stdc++.h>
#define newl "\n"
using namespace std;
using lli = long long int;
using vvint = vector <vector <int>>;
const int mod = 1e9 + 7;

const int N = 2e5 + 1;
vector <set <int>> adj;
vector <bool> vis;
int maxx, cnt;

void dfs(int s){
	++cnt;
	maxx = max(maxx,cnt);
	vis[s] = 1;
	for(int u : adj[s]){
		if(vis[u]) continue;
		dfs(u);
	}
	return;
}

void solve(){
	int n,m;
	cin >> n >> m;
	adj = vector <set <int>> (n);
	vis = vector <bool> (n,0);
	maxx = 1;
	for(int i = 0;i < m;++i){
		int u,v;
		cin >> u >> v;
		u--;v--;
		adj[u].insert(v);
		adj[v].insert(u);
	}
	for(int i = 0;i < n;++i){
		if(!vis[i]){
			cnt = 0;
			dfs(i);
		}
	}
	cout << maxx << newl;
	return;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout << fixed << setprecision(10);
	#ifdef EXECUTE_LOCALLY
		   freopen("in.txt","r",stdin);
	#endif
	int t = 1;
	//cin >> t;
	while(t--) solve();
	#ifdef EXECUTE_LOCALLY
    	cout << setprecision(3) << "program time: " << (double)clock() / CLOCKS_PER_SEC << newl;
	#endif
	return 0;
}


Measured memory_bytes: 37436
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;
 
int main() {
    string s;
    cin >> s;
    set<ll> st;
    rep(i, 3) {
        st.insert(s[i]);
    }
    if(st.size() == 1) {
        out("No");
    }
    else {
        out("Yes");
    }
    
    re0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1000000007;
const int N = 100005;

namespace Modop {
    ll modAdd(ll a, ll b) {
        return (a + b) % MOD;
    }
    
    ll modSub(ll a, ll b) {
        return (((a - b) % MOD) + MOD) % MOD;
    }
    
    ll modMul(ll a, ll b) {
        return ((a % MOD) * (b % MOD)) % MOD;
    }

    ll modExp(ll base, ll power) {
        if (power == 0) {
            return 1;
        } else {
            ll cur = modExp(base, power / 2); cur = cur * cur; cur = cur % MOD;
            if (power % 2 == 1) cur = cur * base;
            cur = cur % MOD;
            return cur;
        }
    }
    
    ll modInv(ll a) {
        return modExp(a, MOD - 2);
    }
    
    ll modDiv(ll a, ll b) {
        return modMul(a, modInv(b));
    }
}

using namespace Modop;

int n, zc;
ll cc[N], mul[N];

int main() {
    cin.sync_with_stdio(0); cin.tie(0);
    cin >> n;
    vector<int> a(n);
    for (auto& i : a) cin >> i;
    for (int i = 0; i < N; i++) mul[i] = 1;

    for (int i = 0; i < n; i++) {
        if (!a[i]) zc++;
        else {
            mul[a[i]] *= cc[a[i] - 1];
            cc[a[i] - 1]--;
        }
        cc[a[i]]++;
    }

    ll ans = 1;
    for (int i = 1; i < n; i++) {
        ans = modMul(ans, mul[i]);
    }

    if (zc == 1) ans = modMul(ans, 3ll);
    else if (zc == 2 || zc == 3) ans = modMul(ans, 6ll);
    else ans = 0;
    cout << ans;
}


Measured memory_bytes: 2176
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <climits>
#include <cmath>
#include <utility>
#include <string>
#include <cstring>
#include <functional>

using namespace std;

int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
    int l;
    cin >> l;

    double res = (double)l / 3.0;
    res = res * res * res;
    // cout << res << endl;
    printf("%.6lf\n", res);

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
#include<list>
#include<set>
#include<cstring>
using namespace std;
long long int mod = 1e9 + 7;
int inf = 1e9;

long long int func(long long int a, long long int b) {
  if(a > b) swap(a, b);

  if (b%a == 0) return (2 * (b/a)-1) * a;
  else return 2*(b/a)*a + func(a, b%a);
}

int main() {
  long long int n, x; cin >> n >> x;
  long long int ans = n + func(n - x, x);
  cout << ans << endl;

  return 0;
}


//EOF


Measured memory_bytes: 256
A,B=$<.read.split.map(&:to_i)

def g(x)
    (x.even? ? x : 0) ^ ((x+1)/2) & 1
end

puts g(A-1) ^ g(B)

# def g(x,i)
#     n = 1<<i
#     m = 1<<(i-1)
#     r,q = (x+1).divmod(n)
#     r*m + [m - (n-q),0].max
# end

# ret = 0
# 1.upto(40) do |i|
#    b = g(B,i)
#    a = g(A-1,i)
#    if (b-a).odd?
#      ret += 1<<(i-1)
#    end
# end
# p ret

Measured memory_bytes: 14336
from itertools import accumulate

class BIT_RSQ():
    def __init__(self, n):
        self.n = n
        self.data = [0]*(n+1)

    def add(self, i, v):
        while i <= self.n:
            self.data[i-1] += v
            i += i & -i

    def sum(self, i):
        ret = 0
        while(i > 0):
            ret += self.data[i-1]
            i -= i & -i
        return ret

n = int(input())
a = list(map(int, input().split()))

def check(m):
    b = [[-1,1][i>=m] for i in a]
    bit = BIT_RSQ(2*n+1)
    s = [0] + list(accumulate(b))
    res = 0
    for i in range(n):
        bit.add(s[i]+n+1, 1)
        res += bit.sum(s[i+1]+n+1)
    return res >= (n*(n+1)//2+1)//2

left = 0
right = 10**9+1
while right-left > 1:
    mid = (right+left)//2
    if check(mid):
        left = mid
    else:
        right = mid
print(left)

Measured memory_bytes: 121068
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <iterator>
#include <functional>
#include <utility>
#include <algorithm>
#include <numeric>
#include <typeinfo>

using namespace std;

#define dump(n) cout<<"# "<<#n<<"="<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,n) repi(i,0,n)
#define iter(c) __typeof((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();++i)
#define allof(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;

const int INFTY=1<<29;

struct Edge{
	int src,dst,weight;
	Edge(){}
	Edge(int src,int dst,int weight):src(src),dst(dst),weight(weight){}
};

typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

bool DFS(Graph& g,int v,vi& used,vi& match)
{
	used[v]=true;
	rep(i,g[v].size()){
		int u=g[v][i].dst,w=match[u];
		if(w==-1 || !used[w] && DFS(g,w,used,match)){
			match[v]=u;
			match[u]=v;
			return true;
		}
	}
	return false;
}

int BiparateMatching(const Graph& _g,int m)
{
	int n=_g.size()-m;
	Graph g=_g;
	rep(i,_g.size())
		foreach(e,_g[i])
			g[e->dst].push_back(Edge(e->dst,e->src,e->weight));
	
	vi used(m+n);
	vi match(m+n,-1);
	int res=0;
	rep(i,m+n){
		if(match[i]==-1){
			fill(allof(used),0);
			res+=DFS(g,i,used,match);
		}
	}
	
	return res;
}

int main()
{
	for(int m,n;cin>>m>>n,m|n;){
		vi bs(m),rs(n);
		rep(i,m) cin>>bs[i];
		rep(i,n) cin>>rs[i];
		Graph g(m+n);
		rep(i,m) rep(j,n)
			if(__gcd(bs[i],rs[j])>1)
				g[i].push_back(Edge(i,m+j,1));
		cout<<BiparateMatching(g,m)<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 6624
#include <bits/stdc++.h>
#include <ctime>
#include <sstream>
#define weewoo ios::sync_with_stdio(false);cin.tie(0)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define ld long double
#define ll long long
#define se second
#define fi first
#define ctoi(x) (x-'0')
#define pi (acos(-1))
#define llputin(a,n) for(int i=0;i<n;i++){ll x;cin >> x;a.push_back(x);}
#define iputin(a,n) for(int i=0;i<n;i++){int x;cin >> x;a.push_back(x);}

#define MOD ((ll) 1e9 + (ll) 7)
using namespace std;

ll pw(ll x,ll a){
    if(a==0)
        return 1;
    ll t = pw(x,a/2);
    if(a%2==0)
        return (t*t);
    else
        return (t*t*x);
}

bool prime(int x)
{
    if(x < 2) return false;
        for(int i=2; i<= sqrt(x); i++) {
            if ((x%i) == 0) return false;
        }
    return true;
}


int main()
{
    weewoo;
    ll n,x;
    cin >> n >> x;
    if(n*500>=x)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
 
using namespace std;
 
#define rep(i,n) for(int i=0; i<(n); i++)
#define repc(i,s,e) for(int i=(s); i<(e); i++)
#define pb push_back
#define mp make_pair
#define all(r) r.begin(),r.end()
#define fi first
#define se second
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

typedef pair<int, pii> pip;
 
 
 
const int INF = 1000000;
const double EPS = 1e-8;
const int mod = 1e9 + 7;

int n, m, e, d;
vector<string> s;

bool calc(){
	int y = 0, x = m;
	for(; y < d; y++){
		if(s[y][x]=='1'){
			x++;
		}
		else if(s[y][x-1] == '1'){
			x--;
		}
	}
	return x == e;
}

bool calc(int y, int x){
	bool f =false;
	if((x==0||s[y][x-1]=='0')&&(x+1==n-1||s[y][x+1]=='0')){
		s[y][x]='1'; f= true;
	}
	if(calc()) return true;
	if(f) s[y][x]='0';
	return false;
}

int main(){
	while(cin>>n && n){
		cin>>m>>e>>d;
		m--; e--;
		s = vector<string>(d);
		rep(i, d) cin>>s[i];
		if(calc()){
			cout<<"0"<<endl; continue;
		}
		bool f = false;
		rep(i, d){
			rep(j, n-1){
				if(s[i][j]!='1' && calc(i, j)){
					cout<<i+1<<" "<<j+1<<endl;
					f=true;
					break;
				}
			}
			if(f) break;
		}
		if(!f) cout<<"1"<<endl;
	}
	
}

Measured memory_bytes: 1216
#include <iostream>

using namespace std;

int main()
{
 long long int n,m,i,s=0,p,x;
 cin>>n;
 int t[n];
 for (i=0;i<n;i++){
  cin>>t[i];
  s+=t[i];
 }
 cin>>m;
 for (i=0;i<m;i++){
  cin>>p>>x;
  cout<<s+x-t[p-1]<<"\n";
 }
 return 0;
}


Measured memory_bytes: 256
n = int(input())
A = [int(a) for a in input().split()]
A.sort()
while(len(A)!=1):  
    n = A[0]
    A = map(lambda _: _% n, A[1:])
    A = [n] + [a for a in A if a != 0]
    A.sort()
    
print(A[0])

Measured memory_bytes: 14252
n = int(input())
s = input()
for i in range(len(s)):
    asc = ord(s[i])
    if asc <= 90 - n:
        asc += n
        s = s[:i] + chr(asc) + s[i+1:]
    else:
        asc = 65 + (asc + n - 90) - 1    
        s = s[:i] + chr(asc) + s[i+1:]
print(s)

Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
    //cout.precision(10);
    int d, n;
    cin >> d >> n;
    int k = 1;
    for(int i = 1; i <= d; i++){
        k = k * 100;
    }
    if(n == 100){
        n++;
    }
    cout << k * n << endl;
    return 0;
}

Measured memory_bytes: 256