akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            var a = Console.ReadLine().Split().Select(int.Parse).ToArray();

            var s = a[0];
            var w = a[1];




            if ( s > w ) Console.WriteLine("safe");
            else Console.WriteLine("unsafe");


        }
    }
}


Measured memory_bytes: 18868
import java.util.Scanner;

public class Main {
  static public void main(String[] args) {
    Scanner s = new Scanner(System.in);
    int t;
    while ((t = s.nextInt()) != 0) {
      int[] sum = new int[2];
      for (int i = 0; i < t; i++) {
        int m = s.nextInt();
        int n = s.nextInt();
        if (m > n) {
          sum[0] += m + n;
        }
        if (m < n) {
          sum[1] += m + n;
        }
        if (m == n) {
          sum[0] += m;
          sum[1] += n;
        }
      }
      System.out.printf("%d %d\n", sum[0], sum[1]);
    }
  }
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define sz(x) (int)(x.size())

signed main() {
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int a[n];
    for(int i = 0; i < n; i++) {
        cin >> a[i];
    }
    sort(a, a + n);
    int mn = a[0], mx = a[n - 1];
    int ans = INT64_MAX;
    for(int x = mn; x <= mx; x++) {
        int cost = 0;
        for(int i = 0; i < n; i++) {
            cost += (x - a[i]) * (x - a[i]);
        }
        ans = min(ans, cost);
    }
    cout << ans << "\n";
}

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

const int N = 16, inf = 2e9;

int n, m;
int f[N][1 << N], g[N][1 << N], a[1 << N];
int G[N][N], ans;

int main()
{
	scanf("%d %d", &n, &m);
	for(int i = 1; i <= m; i++)
	{
		int x, y, t;
		scanf("%d %d %d", &x, &y, &t);
		G[x][y] = G[y][x] = t;
		ans += t;
	}

	for(int s = 0; s < (1 << n); s++)
		for(int i = 1; i <= n; i++)
			if(s & (1 << i - 1))
				for(int j = i + 1; j <= n; j++)
					if(s & (1 << j - 1)) a[s] += G[i][j];

	for(int s = 0; s < (1 << n); s++)
		for(int i = 1; i <= n; i++) g[i][s] = f[i][s] = -inf;

	for(int s = 1; s < (1 << n); s++)
		if(s & 1) f[1][s] = a[s];
			
	for(int s = 1; s < (1 << n); s++)
	{
		if(!(s & 1)) continue;
		for(int i = 2; i <= n; i++)
			if(s & (1 << i - 1))
				for(int t = s; t; t = (t - 1) & s)
					if((t & (1 << i - 1)) && !(t & 1))
						f[i][s] = max(f[i][s], g[i][s ^ t] + a[t]);
		for(int i = 1; i <= n; i++)
			if(!(s & (1 << i - 1)))
				for(int j = 1; j <= n; j++)
					if(s & (1 << j - 1))
						if(G[i][j]) g[i][s] = max(g[i][s], f[j][s] + G[i][j]);
	}

	printf("%d", ans - f[n][(1 << n) - 1]);
	return 0;
}

Measured memory_bytes: 7424
#include <iostream>
#include <vector>
using namespace std;
typedef std::vector<double> vd;
int main(){
	int n;
  	cin>>n;
  	vector<int> arr(n);
  	int c1 = 0, c2 = 0, c3 = 0;
  	for(int i = 0;i<n;i++){
    	cin>>arr[i];
      	if(arr[i]==1) c1++;
      	else if(arr[i]==2) c2++;
      	else c3++;
    }
    vector<vector<vd>> probs(n+1, vector<vd>(n+1, vd(n+1)));
   	vector<vector<vd>> exp(n+1, vector<vd>(n+1, vd(n+1)));
  	probs[c1][c2][c3] = 1.0;
  	exp[c1][c2][c3] = 0.0;
  	int m = c1 + 2*c2 + 3*c3;
	for(int k = c3 ;k>=0;k--){
  		for(int j = n-k;j>=0;j--){
      		for(int i=n-j-k;i>=0;i--){
			  if(i+2*j+3*k>m || i+j+k >n ) continue;

              if(i==0 && j==0 && k==0) continue;
              	double p = double(n-i-j-k)/n;
              	double psofar = probs[i][j][k];
              	double expsofar = exp[i][j][k];
              	double exphere = p/(1-p);
				if(i>0){
                  	double ps =  i/(n*(1-p));
                	probs[i-1][j][k] +=  psofar * ps;
                  	exp[i-1][j][k] += ps * (expsofar+psofar*exphere);
                }

              	if(j>0){
                  	double ps = double(j)/(n*(1-p));
                	probs[i+1][j-1][k] += psofar *  ps;
                  	exp[i+1][j-1][k] += ps * (expsofar+ psofar*exphere);
                }

            	if(k>0){
                  	double ps = double(k)/(n*(1-p));
                	probs[i][j+1][k-1] +=  psofar * ps;
                  	exp[i][j+1][k-1] +=  ps * (expsofar+psofar*exphere);
                }
            
            }
        }
	}
  printf("%.13f", m + exp[0][0][0]);
}

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

using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;

#define REP(i, n, m) for(ll i=n; i<(ll)m; ++i)
#define IREP(i, n, m) for(ll i=n-1; i>=m; --i)
#define rep(i, n) REP(i, 0, n)
#define irep(i, n) IREP(i, n, 0)
#define all(v) v.begin(), v.end()
#define vprint(v) for(auto e:v){cout<<e<<" ";};cout<<endl;
#define vvprint(vv) for(auto v:vv){vprint(v)};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(20);

    ll N, K;
    cin >> N >> K;

    if(K>(N-1)*(N-2)/2) cout << -1 << endl;
    else{
        vvll edges = {};
        REP(i, 2, N+1) edges.push_back({1, i});
        ll r = (N-1)*(N-2)/2 - K;
        REP(i, 2, N){
            if(r==0) break;
            REP(j, i+1, N+1){
                if(r==0) break;
                edges.push_back({i, j});
                --r;
            }
        }
        cout << edges.size() << endl;
        for(auto e : edges) cout << e[0] << " " << e[1] << endl;
    }
}


Measured memory_bytes: 3848
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import random

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)


def main():
    n,m = LI()
    aa = [set(LI_()[1:]) for _ in range(m)]
    p = LI()
    r = 0
    for i in range(2**n):
        t = [0] * m
        for j in range(n):
            if 2**j & i:
                for k in range(m):
                    if j in aa[k]:
                        t[k] ^= 1
        if p == t:
            r += 1

    return r


print(main())



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

#define LL long long
#define ULL unsigned long long
LL INF=10000000000001LL;

typedef pair<int,int> pii;
typedef pair<LL,LL> pll;
typedef vector<int> vi;
typedef vector<LL> vl;
typedef vector<pii> vii;
typedef vector<pll> vll;

#define READ 		freopen("in.txt","r",stdin)
#define WRITE  		freopen("out.txt","w",stdout)
#define BOOST		ios_base::sync_with_stdio(false)
#define sf 			scanf
#define pf 			printf
#define F  			first
#define S  			second
#define pb 			push_back
#define NL			pf("\n")
#define ALL(v)		v.begin(),v.end()
#define si(x)		sf("%d",&x);
#define sii(x,y)	sf("%d%d",&x,&y);
#define siii(x,y,z)	sf("%d%d%d",&x,&y,&z);
#define sl(x)		sf("%lld",&x);
#define sll(x,y)	sf("%lld%lld",&x,&y);
#define slll(x,y,z)	sf("%lld%lld%lld",&x,&y,&z);
#define clr(x,y) 	memset(x,y,sizeof (x) )
#define ch 			printf("Came Here!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n")
#define SV(v)		sort(v.begin(),v.end())
#define SVR(v,cmp)	sort(v.begin(),v.end(),cmp)
#define FOR(i,n)	for(int i=0;i<n;i++)
#define cnd			tree[idx]
#define lc			tree[idx*2]
#define rc			tree[idx*2+1]
#define lnd 		(2*idx),(b),((b+e)/2)
#define rnd 		((2*idx)+1),(((b+e)/2)+1),(e)
// graph direction array [4]
//LL X[4]={0,0,1,-1};
//LL Y[4]={1,-1,0,0};
// graph direction array [8]
//int X[8]={0,0,1,-1,-1,1,1,-1};
//int Y[8]={1,-1,0,0,-1,-1,1,1};
// Bishop direction array [8]
//int X[8]={0,0,1,-1,-1,1,1,-1};
//int Y[8]={1,-1,0,0,-1,-1,1,1};
// Knight Direction Array
//int KX[8] = {1,1,2,2,-1,-1,-2,-2};
//int KY[8] = {2,-2,1,-1,2,-2,1,-1};

bool Check(int N,int pos){return (bool)(N & (1<<pos));} // check bit
int Set(int N,int pos){	return N=N | (1<<pos);}// set bit

LL mod=1000000007;
LL modMul(LL a, LL b){

	return (a%mod * b%mod)%mod;
//    LL ans = 0;
//    a = a % mod;
//    while (b > 0){
//        if ( b % 2 )ans = (ans%mod+ a%mod) % mod;
//        a = (a%mod * 2%mod) % mod;
//        b /= 2;
//    }
//    return ans % mod;
}

LL powerMod(LL a,LL b){
	if(b==0)return 1%mod;
	LL x=powerMod(a,b/2);
	x = (x%mod*x%mod)%mod;
//	x = modMul( x,x )%mod;
	if(b%2==1){
		x = (x%mod*a%mod)%mod;
//		x = modMul(x,a)%mod;
	}
	return x%mod;
}

LL lcm( LL a,LL b ){
	LL g = __gcd(a,b);
	return (a*b)/g;
}

const int mx = 10009;
// ----------------------------------------------
// ----------------------------------------------

LL arr[1009];
int main(){
//  READ;
//  WRITE;
//  BOOST;
    LL t,n,m,k,c,a,u,v;
	cin>>n>>t>>a;
	t*=1000;
	a*=1000;
	FOR(i,n){
		cin>>arr[i];
	}

	LL d = INF;
	int ind=0;
    FOR(i,n){
		LL cd = t - arr[i]*6;
		cd = abs( cd-a );
		if( cd<d ){
			d = cd;
			ind = i+1;
		}
	}


	cout<<ind<<endl;
    return 0;
}




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

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

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String str;
		try {
			while ((str = br.readLine()) != null) {
				String[] num = str.split(" ");
				int a = Integer.parseInt(num[0]);
				int b = Integer.parseInt(num[1]);
				if (0 <= a && a <= 1000000 && 0 <= b && b <= 1000000) {
					System.out.println(Integer.toString(a + b).length());
				}
			}
		} catch (IOException e) {
			e.printStackTrace();
		}

	}
}

Measured memory_bytes: 24256
import java.io.*;

public class Main {
	public static void main(String[] args) {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		try {
			String line;
			while(true){
				/* input */
				line = br.readLine();

				int n = Integer.parseInt(line.split(" ")[0]), k = Integer.parseInt(line.split(" ")[1]);
				
				if(n==0&&k==0) break;
				
				int[] s = new int[k];
				int[][] b = new int[n][k];
				
				line = br.readLine();
				String[] str = line.split(" ");
				for(int i=0;i<k;i++){
					s[i] = Integer.parseInt(str[i]);
				}
				
				for(int i=0;i<n;i++){
					line = br.readLine();
					str = line.split(" "); 
					for(int j=0;j<k;j++){
						b[i][j] = Integer.parseInt(str[j]);
					}
				}

				/* processing */
				boolean f = true;
				for(int i=0;i<k;i++){
					int sum = 0;
					for(int j=0;j<n;j++){
						sum += b[j][i];
					}
					if(sum>s[i]){
						f = false;
						break;
					}
					if(!f) break;
				}
				
				/* output */
				if(f){
					System.out.println("Yes");
				} else {
					System.out.println("No");
				}
			}
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}

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

int main() {
  int a, b;
  cin >> a >> b;
  if (a <= 0 and 0 <= b) {
    cout << "Zero" << endl;
  }
  else if (b < 0 and (b-a+1)%2 == 1) {
    cout << "Negative" << endl;
  }
  else {
    cout << "Positive" << endl;
  }
}

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

// varibable settings
#define infile "../test/sample-1.in"
#define int long long //{{{
const int INF=1e18;
const int MOD=1e9+7; //}}}

// define basic macro {{{
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)((b)-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(i,a) for (auto&& i : a)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define mt(a, b, c) make_pair(a, b, c)
#define ceil(a,b) ((a)+(b)-1)/(b)
#define is_in(x, a, b) ((a)<=(x) && (x)<(b))
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define ub upper_bound
#define lb lower_bound
#define posl(A, x) (lower_bound(all(A), x)-A.begin())
#define posu(A, x) (upper_bound(all(A),x)-A.begin())
template<class T> inline void chmax(T &a, const T &b) { if((a) < (b)) (a) = (b); }
template<class T> inline void chmin(T &a, const T &b) { if((a) > (b)) (a) = (b); }

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;

template<typename T> using PQ = priority_queue<T, vector<T>, greater<T>>;
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;

#if defined(PCM) || defined(LOCAL)
  #include "lib/dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42
  #define dump_2d(...) 42
#endif
//}}}

const int MAX = 1000000;
// Calculate COM(MAX, k) for k<=MAX by O(1) after COMinit() by O(MAX)
// {{{
ll 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;
  }
}

// 二項係数計算
ll 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 solve(){
  int x,y;cin>>x>>y;

  if ((x+y)%3!=0){
    cout << 0 << endl;
    return 0;
  }

  int n = (x+y)/3;

  int tx = x-n;
  dump(n, tx);

  COMinit();
  int ans = COM(n, tx);
  cout << ans << endl;

  return 0;
}

signed main() { //{{{
#ifdef INPUT_FROM_FILE
  std::ifstream in(infile);
  std::cin.rdbuf(in.rdbuf());
#endif
  solve();
  return 0;
} //}}}


Measured memory_bytes: 23680
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
using namespace std;

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

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
/*----------------------------------------*/
const int MOD = 1000000007;

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int n, m; cin >> n >> m;
  if (abs(n-m) > 1) {
    cout << 0 << '\n';
    return 0;
  }
  if (n < m) swap(n, m);
  vector<long long> fact(100001, 0);
  fact[0] = fact[1] = 1;
  FOR(i, 2, 100001) fact[i] = (fact[i-1] * i) % MOD;
  if (n == m) cout << fact[n] * fact[m] % MOD * 2 % MOD << '\n';
  else cout << fact[n] * fact[m] % MOD << '\n';
  return 0;
}


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

int main(void){
   int N;
   cin>>N;
   vector<char> S(N);
   for(int i=0;i<N;i++){
      cin>>S[i];
   }
   int ans=0;
   int x=0;
   for(int i=0;i<N;i++){
      if(S[i]=='D') x=x-1;
      if(S[i]=='I') x=x+1;
      ans=max(x,ans);
   }
   cout<<ans<<endl;
   return 0;
}



Measured memory_bytes: 256
main :: IO ()
main = do
    [a, b, _, k] <- map read . words <$> getLine
    putStrLn $ maybe "Unfair" show $ solve a b k

solve :: Int -> Int -> Int -> Maybe Int
solve a b k
    | abs (a - b) > 10 ^ 18 = Nothing
    | otherwise   = Just $ (-1) ^ k * (a - b)


Measured memory_bytes: 508
#include<iostream>
#include<string>
#include<typeinfo>
using namespace std;
int main()
{
/*	string s;
	cin >> s;
	int sum=0;
	for(int i=0; i<3; i++){
		if(s[i]=="1"){
			sum++;
		}
	}
*/
	int a;
	cin >> a;
	int sum = a%10 + (a/10)%10 + (a/100)%10;
	cout << sum << endl;
	return 0;
}

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

int main() {
	
	int n;
	cin >> n;
	vector<int> a(n);
	rep(i, n) cin >> a[i];
	
	vector<int> r(n+1);
	
	rep(i, n){
		if(i%2 == 0) r[0] += a[i];
		else r[0] -= a[i];
	}
	
	r[n] = r[0];
	for(int i=n-1; i>=0; i--){
		r[i] = 2 * a[i] - r[i+1];
	}
	
	rep(i, n){
		cout << r[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 2048
#include <bits/stdc++.h>
#define one_peace ios::sync_with_stdio(0),ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
using namespace std;

int main()
{
    one_peace;
    int a,b;
    long long ss=0;
    cin>>a>>b;
    if(a==1 &&b==1)
    {
        cout<<1000000;
        return 0;
    }
    if(a==1)
    {
        ss+=300000;
    }
    if(a==2)
    {
        ss+=200000;
    }
    if(a==3)
    {
        ss+=100000;
    }
    if(b==1)
    {
        ss+=300000;
    }
    if(b==2)
    {
        ss+=200000;
    }
    if(b==3)
    {
        ss+=100000;
    }
    cout<<ss;
    return 0;
}


Measured memory_bytes: 256
def i1():
 return int(input())
def i2():
 return [int(i) for i in input().split()]
n=i1()
t=[0]
x=[0]
y=[0]
ss="Yes"
for i in range(n):
 s=i2()
 t.append(s[0])
 x.append(s[1])
 y.append(s[2])
for i in range(n):
 tx=abs(x[i+1]-x[i])
 ty=abs(y[i+1]-y[i])
 if not(t[i+1]-t[i]>=tx+ty and (t[i+1]-t[i])%2==(tx+ty)%2):
   ss="No"
   break
print(ss)

Measured memory_bytes: 65496
#include<iostream>
using namespace std;
int main(){
	int a,b,c;
	while(cin>>a>>b>>c){
		int ans=0;
		for(int i=a;i<=b;i++){
			if(c%i==0)
				ans++;
		}
		cout<<ans<<endl;
	}
	return 0;
}


Measured memory_bytes: 3104
//Written by Zhu Zeqi
//Come on,baby
//Hack,please
#include<bits/stdc++.h>
#define MAX 1000000000000000000
#define MOD 1000000007
#define PI 3.141592653589793238462
#define INF 0x3F3F3F3F

typedef long long ll;
//orz yht
using namespace std;
string i_s(int x){
	if(x==0)
	return "0";
	if(x==0)
	return "0";
	string ret="";
	while(x){
		ret=ret+(char)(x%10+'0');
		x/=10;
	}
	reverse(ret.begin(),ret.end());
	return ret;
}
string add(string a,string b){
	if(a=="")
	a="0";
	if(b=="")
	b="0";
	if(a.length()<b.length())
	swap(a,b);
	while(b.length()<a.length()){
		b='0'+b;
	}
	for(int i=0;i<a.length();i++){
		a[i]=a[i]+(b[i]-'0');
	}
	bool big=false;
	for(int i=a.length()-1;i>=0;i--){
		if(big){
			a[i]++;
		}
		big=false;
		if(a[i]>'9'){
			a[i]=a[i]-10;
			big=true;
		}
	}
	if(big)
	a='1'+a;
	return a;
}
string mul(string a,string b){
	vector<int> va,vb;
	if(a=="0" || b=="0")
	return "0";
	string ans;
	for(int i=0;i<a.length();i++){
		va.push_back(a[i]-'0');
	}
	for(int i=0;i<b.length();i++){
		vb.push_back(b[i]-'0');
	}
	reverse(va.begin(),va.end());
	reverse(vb.begin(),vb.end());
	vector<int> res;
	res.clear();
	res.resize(1005);
	for(int i=0;i<a.length();i++){
		for(int j=0;j<b.length();j++){
			res[i+j]+=(va[i]*vb[j]);
		}
	}
	for(int i=0;i<1005;i++){
		if(res[i]>9){
			res[i+1]+=(res[i]/10);
			res[i]%=10;
		}
	}
	for(int i=0;i<1005;i++){
		ans+=(res[i]+'0');
	}
	reverse(ans.begin(),ans.end());
	int k=0;
	while(ans[k]=='0'){
		k++;
	}
	ans=ans.substr(k);
	return ans;
}
bool is_prime(int n){
	if(n<2)
    return false;
    for(int i=2;i*i<=n;i++)
    if(n%i==0)
    return false;
    return true;
}
int n,m;
int main(){
	//freopen("input.in","r",stdin);
	//freopen("output.out","w",stdout);
	cin>>n>>m;
	cout<<n-m+1;
	//system("pause");
	return 0;
}


Measured memory_bytes: 768
#include<cstdio>
#include<iostream>
#include<string>
#include<set>
#include<map>
#include<vector>
#include<deque>
#include<tuple>
#include<algorithm>
#include<numeric>
#include<limits>
#include<boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision;
using namespace std;
#define BEGIN ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define END return EXIT_SUCCESS
#define rep(I,N) for(auto I=0;I<(N);++I)
#define up(I,A,B) for(auto I=(A);I<=(B);++I)
#define dw(I,A,B) for(auto I=(A);I>=(B);--I)
#define all(C) (C).begin(),(C).end()
#define rall(C) (C).rbegin(),(C).rend()
#define ft first
#define sd second
#define mp make_pair
#define mt make_tuple
#define pf push_front
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define rs resize
typedef long long ll;
typedef unsigned long long ull;
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>inline void                                      in(T &p){cin>>p;}
template<class T1,class T2>inline void                            in(T1 &p1,T2 &p2){cin>>p1>>p2;}
template<class T1,class T2,class T3>inline void                   in(T1 &p1,T2 &p2,T3 &p3){cin>>p1>>p2>>p3;}
template<class T1,class T2,class T3,class T4>inline void          in(T1 &p1,T2 &p2,T3 &p3,T4 &p4){cin>>p1>>p2>>p3>>p4;}
template<class T1,class T2,class T3,class T4,class T5>inline void in(T1 &p1,T2 &p2,T3 &p3,T4 &p4,T5 &p5){cin>>p1>>p2>>p3>>p4>>p5;}
template<class T>inline void                                      ins(T &p){for_each(all(p),in<decltype(p[0])>);}
template<class T>inline void                             out(T p){cout<<p<<endl;}
template<class T1,class T2>inline void                   out(T1 p1,T2 p2){cout<<p1<<" "<<p2<<endl;}
template<class T1,class T2,class T3>inline void          out(T1 p1,T2 p2,T3 p3){cout<<p1<<" "<<p2<<" "<<p3<<endl;}
template<class T1,class T2,class T3,class T4>inline void out(T1 p1,T2 p2,T3 p3,T4 p4){cout<<p1<<" "<<p2<<" "<<p3<<" "<<p4<<endl;}
inline                                              void out(double p){printf("%.10f\n",p);}
template<class T>inline                             void outs(T p){for_each(all(p),out<decltype(p[0])>);}
template<class T>inline void outs(vector<T> V){int n=V.size();rep(i,n)cout<<V[i]<<" \n"[i==n-1];}
inline void solve(void){
  int N;in(N);
  vector<int>X(N);ins(X);
  double ave=0;
  rep(i,N)ave+=X[i];
  ave/=N;
  int x1=(int)ave;
  int x2=x1+1;
  int ans1=0,ans2=0;
  rep(i,N)ans1+=(x1-X[i])*(x1-X[i]);
  rep(i,N)ans2+=(x2-X[i])*(x2-X[i]);
  out(min(ans1,ans2));
}
int main(int argc,char**argv){
  BEGIN;
  solve();
  END;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"log"
	"math"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Split(bufio.ScanWords)
	log.SetFlags(log.Lshortfile)
	h := nextInt()
	n := nextInt()
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = nextInt()
	}
	if h <= sum(a) {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

func nextString() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

var dy = []int{0, 1, 0, -1}
var dx = []int{1, 0, -1, 0}
var MAX = math.MaxInt32

func pow(a, b int) int {
	return int(math.Pow(float64(a), float64(b)))
}

func lcm(a, b int) int {
	return a * b / gcd(a, b)
}
func gcd(a, b int) int {
	if a < b {
		a, b = b, a
	}
	for b != 0 {
		a, b = b, a%b
	}
	return a
}
func max(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r < a[i] {
			r = a[i]
		}
	}
	return r
}
func min(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r > a[i] {
			r = a[i]
		}
	}
	return r
}
func sum(a []int) (r int) {
	for i := range a {
		r += a[i]
	}
	return r
}
func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

type pair struct {
	a, b int
}

type pairs []pair

func (p pairs) Len() int {
	return len(p)
}
func (p pairs) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}

func (p pairs) Less(i, j int) bool {
	if p[i].a == p[j].a {
		return p[i].b < p[j].b
	}
	return p[i].a < p[j].a
}


Measured memory_bytes: 1920
import java.io.InputStream;
import java.io.PrintStream;
import java.util.*;

public class Main {

  public static void main(String[] args) {
    solve(System.in, System.out);
  }

  static void solve(InputStream is, PrintStream os) {
    Scanner sc = new Scanner(is);

    /* read */
    int n = sc.nextInt();
    int[] h = new int[n];

    for (int i = 0; i < n; i++) {
      h[i] = sc.nextInt();
    }

    int i = 0;
    int count = 0;
    int max = 0;
    while (i < n) {
      while (i + 1 < n && h[i] >= h[i + 1]) {
        count++;
        i++;
      }
      max = Math.max(max, count);
      count = 0;
      i++;
    }
    os.println(max);
  }

}

Measured memory_bytes: 50400
#include<iostream>

using namespace std;

const int MAX = 1e5+9;
int n,m,b[MAX],ans,c[MAX];

int main(){
	cin >> n >> m;
	b[0] = 1;
	for(int i=0;i<n;i++) c[i] = 1;
	for(int j=0,v,u;j<m;j++){
		cin>>v>>u,v--,u--;
		c[v]--,c[u]++;
		if(b[v]) b[u] = 1;
		if(c[v] == 0)b[v] = 0;
	}
	for(int k = 0;k<n;k++) ans+=b[k] ;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
#define MAX 100000
#define NIL -1
typedef struct{
  int p;
  int l;
  int r;
}Node;

Node T[MAX];
int n,D[MAX];//深さを代入

void print(int node_num){
    int i,c,flag=1;
    printf("node %d: ",node_num);//引数の番号
    printf("parent = %d, ",T[node_num].p);//引数ノードの親
    printf("depth = %d, ",D[node_num]);//引数ノードからrootまでの深さ
    if(T[node_num].p==(-1)) printf("root, ");
    else if(T[node_num].l==NIL) printf("leaf, ");//lに子の一番左のノードを入れる
    else printf("internal node, ");
    printf("[");
    for(c=T[node_num].l;c!=NIL;flag++){
        printf("%d",c);
        c=T[c].r;
        if(c!=NIL){
          printf(", ");
        }
      }
      printf("]");
      printf("\n");
}
//深さ探索(再起)
int rec(int node_num,int p){
  D[node_num]=p;//初期pは0値を逐一更新
  //初期化時全てのノードのp,r,lはNILになってる
  if(T[node_num].r!=NIL)rec(T[node_num].r,p);//最深部を探すため兄弟のノードからも子がないか調べる.
  if(T[node_num].l!=NIL)rec(T[node_num].l,p+1);//子のノードがあればpをカウントしてnode_numを子に変更
}

int main(){
  int i,j,depth,left,right,child,d,node_num;//dは次数
  scanf("%d",&n);
    for(i=0;i<n;i++){
      T[i].l=T[i].r=T[i].p=NIL;
    }
    for(i=0;i<n;i++){//ノードの個数
      scanf("%d",&node_num);
      scanf("%d",&d);//次数＝子の数
      for(j=0;j<d;j++){  //子入力
        scanf("%d",&child);
        if(j==0) T[node_num].l=child;//一回めに左端の子を代入
        else T[left].r=child;//以降の子は兄弟なのでrに代入
        left=child;//leftにchildのノードを入れておく
        T[child].p=node_num;//入れたノードの親を設定
   //ここまで子の入力
  }
}
    for(i=0;i<n;i++){
      if(T[i].p==NIL)right=i;
    }
    rec(right,0);
for(i=0;i<n;i++) print(i);
return 0;
}



Measured memory_bytes: 6360
import qualified Data.Text as T
import qualified Data.Text.IO as T
import qualified Data.Text.Read as T

main :: IO ()
main = do
  let
    m = 10 ^ 18 :: Integer
  n <- unsafeTextToInt <$> T.getLine :: IO Int
  as <- map unsafeTextToInteger . T.words <$> T.getLine :: IO [Integer]
  let
    p = foldl step (Just 1) as :: Maybe Integer
      where
        step :: Maybe Integer -> Integer -> Maybe Integer
        step Nothing 0 = Just 0
        step Nothing _ = Nothing
        step (Just x) y | z <= m    = Just z
                        | otherwise = Nothing
          where
            z = x * y :: Integer
  print . maybe (-1) id $ p

unsafeTextToInt :: T.Text -> Int
unsafeTextToInt s = case T.signed T.decimal s of
  Right (n, _) -> n
{-# INLINE unsafeTextToInt #-}

unsafeTextToInteger :: T.Text -> Integer
unsafeTextToInteger s = case T.signed T.decimal s of
  Right (n, _) -> n
{-# INLINE unsafeTextToInteger #-}


Measured memory_bytes: 16116
open Batteries;;

let rec check la lb count =
  match la, lb with
  | hda :: [] , hdb :: [] -> count + hda + hdb
  | [], _ -> List.fold_left (+) count lb
  | hda :: resta, hdb :: restb ->
     max (check [] lb (count+hda)) (check resta restb (count+hda))
    in
    let n = read_int () in
let lista = read_line () |> String.split_on_char ' ' |> List.map int_of_string in
let listb = read_line () |> String.split_on_char ' ' |> List.map int_of_string in
let ans = check lista listb 0 in
print_int ans
;;

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Rep(i, k, n) for (int i = k; i < (int)(n); i++)
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}
const long long INF = 1LL << 60;
long long dp[100010];
long long h[100010];
const int MOD = 1000000007;

int a[12][12];

int main()
{
    int n, m, x;
    cin >> n >> m >> x;
    vector<int> c(n);
    rep(i, n)
    {
        cin >> c[i];
        rep(j, m) cin >> a[i][j];
    }

    int ans = 1001001001;
    rep(s, 1 << n)
    {
        int cost = 0;
        vector<int> d(m);
        rep(i, n)
        {
            if (s >> i & 1)
            {
                cost += c[i];
                rep(j, m) d[j] += a[i][j];
            }
        }
        bool ok = true;
        rep(j, m) if (d[j] < x) ok = false;
        if (ok) ans = min(ans, cost);
    }
    if (ans == 1001001001) cout << -1 << endl;
    else cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3632
#include<iostream>
#include<stdio.h>
#include<vector>
#include<cmath>
#include<queue>
#include<string.h>
#include<map>
#include<algorithm>
#define ll long long
#define rep(i,a,b) for(int i = a;i < b;i++)
#define N 100004

using namespace std;

ll n,ar[N],x;

int main()
{
    ios_base::sync_with_stdio(false);

    cin >> n >> x;

    rep(i,0,n)
    {
        cin >> ar[i];
    }

    sort(ar,ar+n);

    ll cur = 0;

    while(cur < n && x >= ar[cur])
    {
        x -= ar[cur];
        cur++;
    }

    if(x != 0 && cur == n)
        cur--;

    cout << cur << endl;

    return 0;
}



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

#define sws ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define INFINITO 1000000000
#define ll long long
#define vi vector<int>
#define pb push_back
#define pii pair<int, int>
#define mp make_pair
#define ff first
#define ss second
#define vvi vector<vi>
#define all(x) x.begin(), x.end()
#define fo(i, n) for( int i = 0; i < n; i++ )


int main() {

    int a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;

    int ans = c * 2 * max(x, y);
    ans = min(ans, a * x + b * y);
    
    if ( x > y ) ans = min(ans, c * 2 * y + a * (x - y));
    else ans = min(ans, c * 2 * x + b * (y - x));

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
	int A, B,TUP=1,tup=0;
	cin >> A;
	cin >> B;
	while (1)
	{
		if (TUP >= B)
			break;
		TUP += A - 1;
		tup++;
			

	}
	cout << tup;
}

Measured memory_bytes: 256
from itertools import count, takewhile
from math import floor, sqrt
 
n = int(input())
xys = [map(int, input().split()) for _ in range(n)]
 
def mysqrt(n):
    x = floor(sqrt(n))
    for y in takewhile(lambda y: y**2 <= n, count(max(0, x-2))):
        x = y
    return x
 
for x, y in xys:
    xy = x*y
    root = mysqrt(xy-1)
    ans = root*2 - (root**2 + root >= xy) - 1 + (x == y)
    print(ans)

Measured memory_bytes: 3064
#line 2 "header.hpp"

//%snippet.set('header')%
//%snippet.fold()%
#ifndef HEADER_H
#define HEADER_H

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

// varibable settings
const long long INF = 1e18;
template <class T> constexpr T inf = numeric_limits<T>::max() / 2.1;

#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define _rrep(i, n) rrepi(i, 0, n)
#define rrepi(i, a, b) for (ll i = (ll)((b)-1); i >= (ll)(a); --i)
#define r_rep(...) _overload3(__VA_ARGS__, rrepi, _rrep, )(__VA_ARGS__)
#define each(i, a) for (auto &&i : a)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define mt(...) make_tuple(__VA_ARGS__)
#define ub upper_bound
#define lb lower_bound
#define lpos(A, x) (lower_bound(all(A), x) - A.begin())
#define upos(A, x) (upper_bound(all(A), x) - A.begin())
template <class T> inline void chmax(T &a, const T &b) { if ((a) < (b)) (a) = (b); }
template <class T> inline void chmin(T &a, const T &b) { if ((a) > (b)) (a) = (b); }
template <typename X, typename T> auto make_table(X x, T a) { return vector<T>(x, a); }
template <typename X, typename Y, typename Z, typename... Zs> auto make_table(X x, Y y, Z z, Zs... zs) { auto cont = make_table(y, z, zs...); return vector<decltype(cont)>(x, cont); }

#define cdiv(a, b) (((a) + (b)-1) / (b))
#define is_in(x, a, b) ((a) <= (x) && (x) < (b))
#define uni(x) sort(all(x)); x.erase(unique(all(x)), x.end())
#define slice(l, r) substr(l, r - l)

typedef long long ll;
typedef long double ld;
using vl = vector<ll>;
using vvl = vector<vl>;
using pll = pair<ll, ll>;

template <typename T>
using PQ = priority_queue<T, vector<T>, greater<T>>;
void check_input() { assert(cin.eof() == 0); int tmp; cin >> tmp; assert(cin.eof() == 1); }

#if defined(PCM) || defined(LOCAL)
#else
#define dump(...) ;
#define dump_1d(...) ;
#define dump_2d(...) ;
#define cerrendl ;
#endif

#endif /* HEADER_H */
//%snippet.end()%
#line 2 "solve.cpp"
template<class T=ll> using vec = vector<T>;
struct Fast { Fast() { std::cin.tie(0); ios::sync_with_stdio(false); } } fast;


int solve() {
    ll n;cin>>n;
    vector<ll> a(n);
    rep(i, n) {
        cin>>a[i];
    }
    dump(a);

    ll h = a[0];
    ll ans = 0;
    rep(i, 1, n){
        if (h > a[i]) {
            ans += h-a[i];
        }
        else{
            h = a[i];
        }
    }
    cout << ans << endl;

    return 0; 
}


int main(){/*{{{*/
    solve();
    check_input();
    return 0;
}/*}}}*/


Measured memory_bytes: 4780
n = gets.to_i
a = n.times.map{gets.split.map(&:to_s)}

list = []

a.each do |c|
  if c[0] == 'delete'
    for i in 0..list.count-1
      if c[1].to_i == list[i]
        list.delete_at(i)
        break
      end
    end
  elsif c[0] == 'deleteFirst'
    list.shift
  elsif c[0] == 'deleteLast'
    list.pop
  else
    list.unshift(c[1].to_i)
  end
end
puts list.join(' ')


Measured memory_bytes: 325568
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin>>N;
  int Na;
  Na=N;
  int A=0;
  for (int i=8; i>-1; i--) {
    int Ni;
    int B;
    B=std::pow(10,i);
    if (i==0) {
      Ni=Na%10;
    } else {
      Ni=Na/B;
      Na=Na-Ni*B;
    }
    A+=Ni;
  }
  
  if (N%A==0) {
    cout<<"Yes"<<endl;
  } 
  else {
    cout<<"No"<<endl;
  }
}

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

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) cin >> A.at(i);
  sort(A.begin(), A.end());
  cout << A.at(N-1) - A.at(0) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
const int MOD=(int)1e9+7;
using namespace std;
int main(){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    cout<<min(a,b)+min(c,d)<<endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ABC49
{
    class Program
    {
        static void Main(string[] args)
        {
            var c = Console.Read();
            switch (c)
            {
                case 'a':
                case 'i':
                case 'u':
                case 'e':
                case 'o':
                    Console.WriteLine("vowel");
                    break;
                default:
                    Console.WriteLine("consonant");
                    break;
            }
        }
    }
}


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

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

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

int main() {
    int64_t r, c, k;
    cin >> r >> c >> k;

    vector items(r + 1, vector(c + 1, 0L));
    for (auto i : irange(0L, k)) {
        int64_t rr, cc, v;
        cin >> rr >> cc >> v;
        items[rr][cc] = v;
    }

    vector dp(r + 1, vector(c + 1, array<int64_t, 4>{}));
    for (auto i : irange(1L, r + 1)) {
        for (auto j : irange(1L, c + 1)) {
            for (auto t : irange(0L, 4L)) {
                dp[i][j][t] =
                        max({dp[i][j - 1][t], dp[i - 1][j][0], dp[i - 1][j][1],
                             dp[i - 1][j][2], dp[i - 1][j][3]});
            }
            for (auto t : irange(1L, 4L) | reversed) {
                dp[i][j][t] = max(dp[i][j][t], dp[i][j][t - 1] + items[i][j]);
            }
        }
    }

    cout << max({dp[r][c][0], dp[r][c][1], dp[r][c][2], dp[r][c][3]}) << endl;
}

Measured memory_bytes: 355264
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;cin>>N;vector<long long>V(N);
  long long U=0;long long O=1000000007;vector<long long>R(N);
  for(int X=0;X<N;X++){
    cin>>V[X];
  }
  int P=0;
  for(int X=N-1;X>=0;X--){
    R[X]=U;U+=V[X];U%=O;P++;
  }
  long long K=0;
  for(int X=0;X<N;X++){
    K+=V[X]*R[X]%O;
  }
  K%=O;
  cout<<K<<endl;
}

Measured memory_bytes: 6356
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}

int main(){
  int n,k,q;
  cin >> n >> k >> q;
  map<int,int> mp;
  vector<int> p(n,k-q);
  
  rep(i,q){
    int tmp;
    cin >> tmp;
    tmp--;
    mp[tmp]++;
  }
  
  for(auto m:mp){
    //printf("player=%d,answer=%d\n",m.first,m.second);
    p[m.first] += m.second;
  }
  
  for(auto p1:p){
    if(p1 <= 0) cout << "No" << endl;
    else cout << "Yes" << endl;
  }
  return 0;
}

Measured memory_bytes: 3968
#include <bits/stdc++.h>
#define re return
#define ll long long
#define pb push_back
using namespace std;

string s;

int main()
{
    cin>>s;
    for (int i=0;i<s.size();++i){
        if (!(i%2))cout<<s[i];
    }
    return 0;
}


Measured memory_bytes: 512
n = int(input())
xyh = [list(map(int,input().split())) for _ in range(n)]
for i in range(n):
    if(xyh[i][2]!= 0):
        x = xyh[i][0]
        h = xyh[i][2]
        y = xyh[i][1]
        break
for i in range(101):
    for j in range(101):
        H = h+ abs(x - i)+abs(y - j)
        ok = True
        for k in range(n):
            nowx = xyh[k][0]
            nowy = xyh[k][1]
            nowh = xyh[k][2]
            if nowh != max(H - abs(nowx - i) - abs(nowy - j),0):
                ok = False
                break
        if ok :
            print(i,j,H)
            break

                

Measured memory_bytes: 43888
import math
n,k = map(int,input().split())
l = list(map(int,input().split()))
def cnt_check(longest):
    if longest == 0:
        return False
    cnt = 0
    for log in l:
        cnt += math.ceil(log/longest)-1
    if cnt <= k:
        return True
    else:
        return False
left = 0
right = max(l)
while right - left > 1:
    middle = (left + right)//2
    if cnt_check(middle):
        right = middle
    else:
        left = middle
print(right)

Measured memory_bytes: 104632
#include <cstdio>
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <cmath>
#include <string>

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

using namespace std;

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

void trace(int A[], int N) {
    for (int i = 0; i < N; ++i) {
        if (i > 0) cout << " ";
        cout << A[i];
    }
    cout << endl;
}

using ll = long long;
using P = pair<int, int>;

const unsigned long long INF = 1LL << 60;

////////////////////////////////////////////////////////////

int H, W;

int main() {
    while (true) {
        cin >> H >> W;
        if (H == 0 && W == 0) break;

        for (int i = 0; i < H; i++) {
            for (int j = 0; j < W; j++) {
                if (i == 0 || i == H - 1 || j == 0 || j == W - 1) {
                    cout << '#';
                } else {
                    cout << '.';
                }
            }
            cout << endl;
        }
        cout << endl;
    }
}



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

int main() {
	int N, K;
	cin >> N >> K;
	vector<int> A(N);
	for (int i = 0; i < N; i++) cin >> A[i];
	for (int i = K; i < N; i++) {
		cout << (A[i] > A[i - K] ? "Yes" : "No") << endl;
	}
}

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

#define FASTIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using ll = long long;

const int MAXN = 3005;
const int MOD = 998244353;

int A, B, C, D;
ll dp[MAXN][MAXN];

ll color(int a, int b) {
    if(a < A || b < B) return dp[a][b] = 0;
    if(a == A && b == B) return dp[a][b] = 1;
    if(dp[a][b] != -1) return dp[a][b];
    
    dp[a][b] = b*(color(a-1,b)%MOD) + a*(color(a,b-1)%MOD) - (a-1)*(b-1)*color(a-1,b-1)%MOD;
    dp[a][b] %= MOD;
    return dp[a][b];
}

int main() {
    FASTIO
    
    memset(dp,-1,sizeof(dp));
    cin >> A >> B >> C >> D;
    cout << color(C,D) << "\n";
    
    return 0;
}

Measured memory_bytes: 74556
#include<stdio.h>
#define WHITE 0
#define GRAY 1
#define BLACK 2

int M[100][100];
int f[100], d[100], tt, n, color[100];

void df_d(int u) {
  int v;
  color[u]=GRAY;
  d[u]=++tt;
  for (v=0; v<n; v++) {
    if (M[u][v]==0) continue;
    if (color[v]==WHITE) {
      df_d(v);
    }
  }
  color[u]=BLACK;
  f[u]=++tt;
}

void df_f() {
  int u;
  for(u=0; u<n; u++)
    color[u]=WHITE;
  tt=0;

  for (u=0; u<n; u++) {
    if (color[u]==WHITE) df_d(u);
  }
  for (u=0; u<n; u++) {
    printf("%d %d %d\n",u+1, d[u], f[u]);
  }
}

int main() {

  int  u, k, i, j, v;

  scanf("%d", &n);

  for (i=0; i<n; i++)
    for (j=0; j<n; j++)
      M[i][j]=0;

  for (i=0; i<n; i++) {
    scanf("%d %d", &u, &k);
    u=u-1;
    for (j=0; j<k; j++) {
      scanf("%d", &v);
      v=v-1;
      M[u][v]=1;
    }
  }

  df_f();

  return 0;

}

Measured memory_bytes: 636
#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=(a);i<=(b);i++)
#define END(x) do{cout<<(x)<<endl;exit(0);}while(0)
#define debug(x)  do{cerr<<#x<<": "<<x<<"\n";}while(0)
#define debugv(x) do{cerr<<#x<<": ";for(auto&e: (x))cerr<<e<<" ";cerr<<"\n";}while(0)
#define exp2(x)  (1LL<<(x))
#define cond(a,b,c) ((a)?(b):(c))
using ll=long long;
using namespace std;

const ll MOD = 1e9+7;
vector<int> adj[100*1000+100];
ll ans = 1, K=-1;

void dfs(int u, int f, int c) {
    ans = (ans * c )% MOD;
    int cc = cond(f==-1,-1,0);
    for(auto v : adj[u]) if (f != v) dfs(v, u, max(0LL,K-2-cc++));
}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(nullptr);
    int N; cin >> N >> K;
    rep(i, 0,N-2) {
        int u, v; cin >> u >> v; u--;v--;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    dfs(0, -1, K);
    END(ans);
}


Measured memory_bytes: 10368
<?php
fscanf(STDIN, "%d", $n);
$an = explode(' ', trim(fgets(STDIN)));
fscanf(STDIN, "%d", $q);

$cnt = array_fill(1, 100001, 0);
foreach ($an as $a) {
  ++$cnt[$a];
}
$tot = array_sum($an);

for ($i=0; $i < $q; $i++) {
  fscanf(STDIN, "%d %d", $b, $c);
  $tot += $c*$cnt[$b] - $b*$cnt[$b];
  $cnt[$c] += $cnt[$b];
  $cnt[$b] = 0;
  echo $tot.PHP_EOL;
}


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

namespace ConsoleApp2
{
	class Program
	{
		static void Main(string[] args)
		{
			var input1 = Console.ReadLine().Split(' ');
			int n = int.Parse(input1[0]);
			int d = int.Parse(input1[1]);

			var dict = new Dictionary<int, List<int>>();
			for (int i = 0; i < n; i++)
			{
				var str = Console.ReadLine().Split(' ');
				var q = from a in str
						select int.Parse(a);
				dict.Add(i, new List<int>(q));
			}

			
			int count = 0;
			for (int i = 0; i < n - 1; i++)
			{
				for (int j = i + 1; j < n; j++)
				{
					int r = 0;
					for (int k = 0; k < d; k++)
					{
						r += (int)Math.Pow(dict[i][k] - dict[j][k], 2);
					}
					var z = Math.Sqrt(r);
					if (z == (double)((int)z))
					{
						count++;
					}
				}
			}

			Console.WriteLine(count);
		}
	}
}


Measured memory_bytes: 13280
#include<stdio.h>
int main(void)
{
    int N,r;
    scanf("%d",&N);
    r=N%10;
    if(r==2 || r==5 || r==7 || r==9 || r==4)
        printf("hon\n");
    if(r==0 || r==1 || r==6 || r==8)
        printf("pon\n");
    if(r==3)
        printf("bon\n");
    return 0;
}


Measured memory_bytes: 1644
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<map>
#include<iomanip>
#define rip(i,n) for(int i=0;i<n;i++)
#define ll long long
#define ld long double
#define set setprecision　//小数点以下何位まで知りたいか
#define mod 1000000007
#define pi 3.14159265
#include<numeric>
using namespace std;
int gcd(int a, int b)//最大公約数
{
	if (a % b == 0)	return(b);
	else return(gcd(b, a % b));
}
int lcm(int a, int b)//最小公倍数
{
	return a * b / gcd(a, b);
}
ll pow(ll a, ll b) {
	ll k = b % 30000, h = b / 30000, s = 1;
	rip(i, 30000)s = (s * a) % 2019; ll j = 1;
	if (h != 0)rip(i, h)j = j * s % 2019;
	if (k != 0)rip(i, k)j = j * a % 2019;
	return(j);
}
int main() {
	int n, k;
	cin >> n >> k;
	int i = 0;
	vector<int>d(k);
	vector<vector<int>> a(k, vector<int>(100));
	while (i < k) {
		cin >> d[i];
		rip(j, d[i])cin >> a[i][j];
		i++;
	}
	vector<int>s(n, 0);
	rip(i, k) {
		rip(j, d[i]) {
			s[a[i][j]-1]++;
		}
	}
	int count = 0;
	rip(i, n)if (s[i] == 0)count ++ ;
	cout << count << endl;
}

Measured memory_bytes: 3640
n, w = map(int, input().split())
wv = [list(map(int, input().split())) for _ in range(n)]

dp = [[0]* (w+1) for _ in range(n+1)]

for i in range(1, n+1):
    w_temp, v_temp = wv[i-1]
    for j in range(1,w+1):
        if(j >= w_temp):
            dp[i][j] = max(dp[i-1][j],
                            dp[i-1][j-w_temp] + v_temp)
        else:
            dp[i][j] = dp[i-1][j]

print(dp[n][w])

Measured memory_bytes: 119916
from collections import Counter
 
N = int(input())
A = list(map(int, input().split()))
count = Counter(A)
S = sum(A)
 
for _ in range(int(input())):
    b, c = map(int, input().split())
    k = count[b]
    count[b] = 0
    count[c] += k
    S += (c - b) * k
    print(S)

Measured memory_bytes: 24192
# include <iostream>
# include <algorithm>
#include <array>
# include <cassert>
#include <cctype>
#include <climits>
#include <numeric>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <tuple>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <chrono>
# include <random>
# include <limits.h>
# include <unordered_map>
# include <unordered_set>
# include <deque>
# include <cstdio>
# include <cstring>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr long long MOD = 1000000000 + 7;
constexpr long long INF = 1e17 - 10;
const double PI = acos(-1);
#define fir first
#define sec second
typedef pair<LL, LL> Pll;
typedef pair<LL, pair<LL, LL>> Ppll;
typedef pair<LL, pair<LL, bitset<100001>>> Pbll;
typedef pair<LL, pair<LL, vector<LL>>> Pvll;
typedef pair<LL, LL> Vec2;
struct Tll { LL first, second, third; };
typedef pair<LL, Tll> Ptll;
#define rep(i,rept) for(LL i=0;i<rept;i++)
#define Mfor(i,mf) for(LL i=mf-1;i>=0;i--)
LL h, w, n, m, s, t, q, ans, sum,a[100000][2],
dp[1000][10001], last;
struct Edge { LL to,cost; };
string str, ss;
pair<char,int> c[1000];
vector<char>v;
bool f[100];
void YN(bool f) {
	if (f)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}
void yn(bool f) {
	if (f)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}
int main() {
	cin >> n >> m;
	rep(i,n) {
		cin >> a[i][0] >> a[i][1];
	}
	rep(i, n) {
		rep(j, m+1) {
			if (j - a[i][1] >= 0)
				dp[i][j] = max(dp[i][j - a[i][1]] + a[i][0], dp[i][j]);
			dp[i + 1][j] = dp[i][j];
		}
	}
	cout << dp[n][m] << endl;
	return 0;
}



Measured memory_bytes: 11080