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

int ans[200009];
bool chk[200009];

int main() {
    int N, x; scanf("%d%d",&N,&x);
    if(N == 2) {
        if(x == 2) puts("Yes\n1\n2\n3");
        else puts("No");
        return 0;
    }
    if(x == 1 || x == 2*N-1) return !printf("No");
    if(x+2 <= 2*N-1) {
        ans[N] = x;
        ans[N-1] = x-1;
        ans[N-2] = x+1;
        ans[N+1] = x+2;
        chk[x-1] = chk[x] = chk[x+1] = chk[x+2] = 1;
    }
    else if(x-2 >= 1) {
        ans[N] = x;
        ans[N-1] = x+1;
        ans[N-2] = x-1;
        ans[N+1] = x-2;
        chk[x+1] = chk[x] = chk[x-1] = chk[x-2] = 1;
    }
    for(int i=1, j=1; i<=2*N-1; i++) {
        while(chk[j]) ++j;
        if(ans[i] == 0) ans[i] = j++;
    }
    puts("Yes");
    for(int i=1; i<=2*N-1; i++) printf("%d\n",ans[i]);
    return 0;
}


Measured memory_bytes: 2304
#include <iostream>
#include <vector>
#include <algorithm>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

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

int main(){
  
  int N, count = 0;
  string N_str;

  cin >> N;

  N_str = to_string(N);

  REP(i, N_str.size()){
    if(N_str[i] == '2') count++;
  }

  cout << count << endl;
 

  
}


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

using namespace std;

int main()
{
    int x,a,b;
    scanf("%d %d %d",&x,&a,&b);
    if(fabs(x-a)>fabs(x-b))cout << "B"<< endl;
    else cout << "A" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define rep(i,n) for(ll i = 0; i < (ll)(n); i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF = 1LL << 60;
int main(){
    int a,b;
    cin >> a >>b;
    rep(i,1010){
        if(i*8/100==a && i*10/100==b){
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define VI vector<int>
#define VVI vector<vector<int>>
#define UM unordered_map
#define MP map
#define ST set
#define US unordered_set
#define V vector
#define S string
#define D deque
#define L list
#define Q queue
#define PQ priority_queue
#define DB double
#define LDB long double
#define FOR(i, n) for (int(i) = 0; (i) < (n); ++(i))
#define FFOR(i, n) for (int(i) = 0; (i) <= (n); ++(i))
#define RFOR(i, n) for (int(i) = (n)-1; (i) >= 0; --(i))
#define all(v) (v).begin(), (v).end()

const int dr[] = {0, 1, 0, -1};
const int dc[] = {1, 0, -1, 0};

int nxt()
{
    int n;
    cin >> n;
    return n;
}

LL llnxt()
{
    LL l;
    cin >> l;
    return l;
}

LDB ldbnxt()
{
    LDB n;
    cin >> n;
    return n;
}

DB dbnxt()
{
    DB n;
    cin >> n;
    return n;
}

void bfs(VVI &graph, int start)
{
    int n = graph.size();
    Q<int> q;
    V<bool> visited(n);
    q.push(start);
    visited[start] = true;
    while (not q.empty())
    {
        auto curr = q.front();
        q.pop();
        for (auto i : graph[curr])
        {
            if (not visited[i])
            {
                q.push(i);
                visited[i] = true;
            }
        }
    }
}
auto tmp = bitset<1000010>{}.set();
bitset<1000010> b(move(tmp));
int main()
{
    int n;
    cin >> n;
    MP<int, int> m;
    FOR(i, n) {
        int t;
        cin >> t;
        m[t]++;
    }
    for (auto [i, cnt] : m)
    {
        if (b[i])
        {
            for (int j = i + i; j <= 1000000; j += i)
            {
                b[j] = false;
            }
        }
    }
    int res = 0;
    for (auto [val, cnt] : m)
    {
        if (cnt == 1 and b[val])
        {
            ++res;
        }
    }
    cout << res;
}

Measured memory_bytes: 13328
a, b = map(int, input().split())


def is_neg(num):
    return num < 0


if a == 0 or b == 0:
    print("Zero")
    exit()

if is_neg(a) and not is_neg(b):
    print("Zero")
    exit()


neg_count = 0
if is_neg(a):
    neg_count += abs(a)

if is_neg(b):
    neg_count -= abs(b) - 1

if neg_count % 2:
    print("Negative")
else:
    print("Positive")


Measured memory_bytes: 9060
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<int,int>;

vector<int>bitSearch(int bit,int n){
    vector<int>S;
    rep(i,n)if(bit&(1<<i))S.push_back(i);
    return S;
}


int d[3] = {-1,0,1};
int main(){
   string s,t;cin>>s>>t;
   int i = 0;
   if(s.size()>t.size())cout<<"GREATER";
   if(s.size()<t.size())cout<<"LESS";
   if(s.size()==t.size()){
       rep(i,s.size()){
           if(s[i]>t[i]){cout<<"GREATER";return 0;}
           if(s[i]<t[i]){cout<<"LESS";return 0;}
       }
     cout<<"EQUAL";
   }
   
}



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

using namespace std;

void solve() {
    int N;
    cin >> N;
    
    vector<int> X(N), Y;
    for (int i = 0; i < N; i++)
    {
        cin >> X[i];
    }
    Y = X;
    sort(Y.begin(), Y.end());

    for (int i = 0; i < N; i++)
    {
        if (X[i] <= Y[N/2-1])
        {
            cout << Y[N/2] << endl;
        }
        else
        {
            cout << Y[N/2-1] << endl;
        }
    }
}

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

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

int main() {
  
  int n;
  cin >> n;
  
  vector<int> vec(n);
  for (int i = 0; i < n; i++) {
  	cin >> vec[i];
  } 
	     
  int maxv = -2000000000;
  int minv = vec[0];
  
  for (int i = 1; i < n; i++) {
  	maxv = max(maxv, vec[i] - minv);
  	minv = min(minv, vec[i]);
	}
	cout << maxv << endl;
	return 0;
  }



Measured memory_bytes: 3624
#include<bits/stdc++.h>
#define X first
#define Y second
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
const ll N = 100005, inf = 2e9;

ll n, m, a[N], b[N], inv[N], s;

vector<ll> adj[N];
pll o[N];

ll p[N], v[N];
bool c[N];

ll Find (ll X) {
	if(p[X] == X) return X;
	return p[X] = Find(p[X]);
}

bool can (ll X) {
	for(ll i=1;i<=n;i++) {
		p[i] = i;
		v[i] = b[i];
	}
	for(ll i=1;i<=n;i++) {
		ll I = o[i].Y;
		c[I] = (a[I]-b[I] <= X);
		for(auto &T : adj[I]) {
			if(inv[T] >= i) continue;
			T = Find(T);
			if(T == I) continue;
			if(c[T] && a[I]-b[I] <= v[T]+X) c[I] = true;
			v[I] += v[T];
			p[T] = I;
		}
	}
	return c[Find(1)];
}

int main()
{
	scanf("%lld%lld",&n,&m);
	for(ll i=1;i<=n;i++) {
		scanf("%lld%lld",&a[i],&b[i]);
		o[i] = {a[i]-b[i], i};
		s += b[i];
	}
	sort(o+1, o+1+n);
	for(ll i=1;i<=n;i++) {
		inv[o[i].Y] = i;
	}
	for(ll i=1;i<=m;i++) {
		ll A, B;
		scanf("%lld%lld",&A,&B);
		adj[A].push_back(B);
		adj[B].push_back(A);
	}
	ll S = 0, E = inf;
	while(S<E) {
		ll M = (S+E)/2;
		can(M) ? E = M : S = M+1;
	}
	printf("%lld\n",S+s);
}


Measured memory_bytes: 13312
#include<iostream>
#include<algorithm>
#include<string>
#define LL long long
LL N;
LL ans;
int main() {
	std::cin >> N;
	LL bef = 0;
	for (int i = 1; i <= N; i++) {
		LL tmp;
		std::cin >> tmp;
		if (bef == 1 && tmp > 0) {
			tmp--;
			ans++;
		}
		ans += tmp / 2;
		bef = tmp % 2;
	}
	std::cout << ans << std::endl;
	return 0;
}

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

#define F first
#define S second

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;

const int N = 10, M = 1010;

int n;
int f[N][N];

int main()
{
	cin >> n;
	for (int i = 1; i <= n; i ++ )
	{
		int x = i;
		while (x >= 10) x /= 10;
		f[x][i % 10] ++ ;
	}
	
	LL res = 0;
	for (int i = 1; i <= n; i ++ )
	{
		int x = i;
		while (x >= 10) x /= 10;
		res += f[i % 10][x];
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
struct ii {
    int a, b;
    bool operator < (ii o) const {
        return tie(a, b) < tie(o.a, o.b);
    }
};
struct iii {
    int a, b, c;
    bool operator < (iii o) const {
        return tie(a, b, c) < tie(o.a, o.b, o.c);
    }
};

const int MOD = 1000000007;
const int INF = 1000000000;
const int MAXN = 1000005;

int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    
    string S, T;
    cin >> S >> T;
    int ans = INF;
    for (int i = 0; i+T.length()-1 < S.length(); i++) {
        int cnt = 0;
        for (int j = 0; j < (int)T.length(); j++) {
            if (T[j] != S[i+j]) cnt++;
        }
        ans = min(ans, cnt);
    }
    cout << ans << "\n";
}


Measured memory_bytes: 3632
// -*- coding:utf-8-unix -*-

use proconio::input;
use proconio::marker::Chars;

fn char2num(c: char) -> i32 {
    (c as i32) - 48
}

fn main() {
    input! {
        n: Chars
    }

    let sum_of_digit = (n as Vec<char>).iter().map(|&ci| char2num(ci)).sum::<i32>();
    let res = sum_of_digit % 9 == 0;

    println!("{}", if res { "Yes" } else { "No" });
}


Measured memory_bytes: 3004
#include <bits/stdc++.h>
using namespace std;
#define fst first
#define sec second
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;
const ll INF=LLONG_MAX,MOD=1e9+7;
const int L=17,N=1<<L;

ll n,m;

int main(){
	ios::sync_with_stdio(false);
	cin>>n>>m;
	double ans=(n+m*18)*100*(1<<m);
	cout << ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <algorithm>
#include <iomanip>
#include <random>
#include <ctime>
#include <bitset>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <cmath>
#include <cstring>
#include <queue>
#include <deque>
#include <stack>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#define ld long double
#define ull unsigned long long
#define ll long long
#define pb push_back
#define pii pair<int, int>
#define pll pair<ll, ll>
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fast_io cout.tie(0), cin.tie(0), ios_base::sync_with_stdio(0)
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
using namespace std;
//using namespace __gnu_pbds;
//typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
ld eps = (ld)1 / 1e9;
ll inf = 1e18, mod2 = 998244353, mod1 = 1e9 + 7;
ll sqr(ll a) { return a * a; }
ll qb(ll a) { return a * a * a; }
ll gcd(ll a, ll b) { return !a ? b : gcd(b % a, a); }
ll binpow(ll a, ll b, ll mod) { return b ? (b % 2 ? (a * (sqr(binpow(a, b / 2, mod)) % mod)) % mod : sqr(binpow(a, b / 2, mod)) % mod) : 1; }
ll binmult(ll a, ll b, ll mod) { return b ? (b % 2 ? (2 * binmult(a, b / 2, mod) + a) % mod : (2 * binmult(a, b / 2, mod)) % mod) : 0; }
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

int main()
{
    fast_io;
    string a;
     cin >> a;
    if (a[1] == 'R') cout << "ABC";
    else cout << "ARC";
    return 0;
}

Measured memory_bytes: 3640
//Volume0-0053
import java.util.Scanner;
 
public class Main {
 
	//declare
	private static final int        PRM_MAX   = 104730,
	                                PRM_NUM   =  10001;
	private static       boolean [] prm_table = new boolean[PRM_MAX];
	private static       int     [] prm_sum   = new int    [PRM_NUM];

    public static void main(String[] args) {
    	
    	//initialize
    	init();
    	
    	//input
    	int n;
    	Scanner sc = new Scanner(System.in);
    	while((n = sc.nextInt()) != 0){
    		
    		//output
    		System.out.println(prm_sum[n]);
    	}
    }
    
    private static void init(){
    	
    	//A prime number table is created.
    	prm_table[2] = true;
    	for(int i=3;i<PRM_MAX;i+=2){prm_table[i] = true;}
    	for(int i=3;i<Math.sqrt(PRM_MAX);i+=2){
    		if(prm_table[i]){
    			for(int j=i*2;j<PRM_MAX;j+=i){
    				prm_table[j] = false;
    			}
    		}
    	}
    	
    	//The sum of a prime number table is created.
    	for(int i=2,j=1;i<PRM_MAX;i++){
    		if(prm_table[i]){
    			prm_sum[j] = i + prm_sum[j-1];
    			j++;
    		}
    	}
    }
}

Measured memory_bytes: 19844
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long

using namespace std;


int main()
{
    FAST;
    
    ll n;
    cin>>n;
    
    vector<vector<vector<ll> > > dp(n+1, vector<vector<ll> >(n+1, vector<ll>(n+1,-1)));
    
    ll ans=0;
    for(int i=1; i<=n; i++)
    {
        for(int j=1; j<=n; j++)
        {
            for(int k=1; k<=n; k++)
            {
                vector<int> tv={i,j,k};
                sort(tv.begin(),tv.end());
                
                if(dp[tv[0]][tv[1]][tv[2]]==-1)
                {
                    dp[tv[0]][tv[1]][tv[2]]=__gcd(i,__gcd(j,k));
                }
                
                ans+=dp[tv[0]][tv[1]][tv[2]];
            }
        }
    }
    
    cout<<ans;
    
}

Measured memory_bytes: 68044
n, m = map(int, input().split())
py = []
for _ in range(m):
    p, y = map(int, input().split())
    py.append((p, y))
prefs = [[] for _ in range(n)]
for ind, (p, y) in enumerate(py):
    prefs[p-1].append((y, ind))
ans = [None]*m
for p, i in enumerate(prefs):
    i.sort()
    for j, (_, ind) in enumerate(i):
        ans[ind] = str(p+1).zfill(6)+str(j+1).zfill(6)
for i in ans:
    print(i)

Measured memory_bytes: 46244
S = input()
if S == "SUN":
    print(7)
elif S == "MON":
    print(6)
elif S == "TUE":
    print(5)
elif S == "WED":
    print(4)
elif S == "THU":
    print(3)
elif S == "FRI":
    print(2)
else:
    print(1)

Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
const int maxn=2010;
bitset<2000010> f;
int a[maxn];
int n,sum;
int main(){
	cin >> n;
	for(int i=1;i<=n;i++)
		cin >> a[i],sum+=a[i];
	f[0]=1;
	for(int i=n;i>=1;--i)
		f|=f<<a[i];
	for(int i=(sum+1)>>1;i<=sum;++i)
		if(f[i]){
			cout << i << endl;
			return 0;
        }
    return 0;
}

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

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

  int ans = 0;
  for (int i = a; i <= b; ++i) {
    vector<int> s;
    int n = i;
    while (n) {
      s.push_back(n % 10);
      n /= 10;
    }

    vector<int> t = s;
    reverse(t.begin(), t.end());
    if (s == t) ans++;
  }

  cout << ans << endl;
}


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

#define N 8
#define FREE -1
#define NOT_FREE 1

int row[N], col[N], dpos[2 * N - 1], dneg[2 * N -1];

bool X[N][N];

void initialize() {
  for(int i = 0; i < N; ++i) { row[i] = FREE; col[i] = FREE;}
  for(int i = 0; i < 2 * N - 1; ++i) { dpos[i] = FREE; dneg[i] = FREE;}
}

void printBoard(){
  for(int i = 0; i < N; ++i){
    for(int j = 0; j < N; ++j){
      if (X[i][j]){
        if(row[i] != j) return;
      }
    }
  }
  for(int i = 0; i < N; ++i){
    for(int j = 0; j < N; ++j){
      cout << ( (row[i] == j) ? "Q" : ".");
    }
    cout << endl;
  }
}

void putQueen(int i){
  if(i == N){
    printBoard();
    return;
  }

  for(int j = 0; j < N; ++j){
    if(col[j] == NOT_FREE ||
      dpos[i + j] == NOT_FREE ||
      dneg[i - j + N - 1] == NOT_FREE) continue;

    row[i] = j;
    col[j] = dpos[i + j] = dneg[i - j + N - 1] = NOT_FREE;

    putQueen(i + 1);

    row[i] = col[j] = dpos[i + j] = dneg[i - j + N - 1] = FREE;
  }
}

int main() {
  initialize();

  for(int i = 0; i < N; ++i)
    for(int j = 0; j < N; ++j) X[i][j] = false;

  int k;
  cin >> k;
  for(int i = 0; i < k; ++i){
    int r, c;
    cin >> r >> c;
    X[r][c] = true;
  }

  putQueen(0);

  return 0;
}



Measured memory_bytes: 3116
#!/usr/bin/env python

n = int(input())
a = [int(input()) for _ in range(n)]

d = {}
for i in range(n):
    if a[i] not in d:
        d[a[i]] = 1 
    else:
        d[a[i]] += 1

ans = 0 
for s in d.values():
    if s%2 == 1:
        ans += 1

print(ans)


Measured memory_bytes: 20684
#include<stdio.h>
int sigsig(int);
int main(void){
    int n;
    int i;
    scanf("%d", &n);
    for(i=1;i<=n;i++){
        if(i%3==0 ||sigsig(i)==1){
             printf(" ");
            printf("%d", i);
        }
    }
    printf("\n");
    return 0;
}
int sigsig(int j){
    while(j>0){
        if(j%10==3){
            return 1;
        }
        else{
            j/=10;
        }
    }
    return 2;
}


Measured memory_bytes: 2104
#include<bits/stdc++.h>
using namespace std;
using ll =long long;
ll n,k;
ll ans;
ll dp[1<<17];
const ll mod = 1e9+7;
ll qpow(ll x,ll n)
{
    ll res =1;
    while(n>0)
    {
        if(n&1) res=res*x%mod;
        x=x*x%mod;
        n>>=1;
    }
    return res;
}
int main(){
	cin>>n>>k;
	for(ll i=k;i>0;i--){
		dp[i]=qpow(k/i , n);
		for(ll j=i+i;j<=k;j+=i){
			dp[i]-=dp[j];  //+mod%mod防溢出 
		}
	}
	for(ll i=1;i<=k;i++) ans=(ans+dp[i]*i)%mod;
	cout<<ans%mod<<endl;
	return 0;
}

Measured memory_bytes: 4340
#include<iostream>
#include<cstdio>
#define MAX 252
using namespace std;
int A[MAX];
int n;

void show(int A[]){
    int i=0;
    for(i=1;i<=n;i++){
        printf("node %d: key = %d, ",i,A[i]);
        if(i/2>0) printf("parent key = %d, ",A[i/2]);
        if(i*2<=n){
            printf("left key = %d, ",A[i*2]);
        }if(i*2+1<=n){
            printf("right key = %d, ",A[i*2+1]);
        }
        cout<<endl;
    }
}
int main(){
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>A[i];
    }
    show(A);
    return 0;
}



Measured memory_bytes: 3136
#include<bits/stdc++.h>
    using namespace std;
    typedef long long ll;
    //--<for debugging>
    #define whatis(x) cout << #x << " is " << x<<" ";
    #define whatisl(x) cout << #x << " is " << x<<"\n";
    #define parr(array,end)for(ll loop=0;loop<end;loop++)cout<<array[loop]<<" ";cout<<"\n";
    #define lline cout<<"\n";
    #define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args);cout<<"\n";}
     
    void err(istream_iterator<string> it) {}
    template<typename T, typename... Args>
    void err(istream_iterator<string> it, T a, Args... args) {
    	cout << *it << " = " << a <<" , ";
    	err(++it, args...);
    }
    //--</for debugging> 
    #define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
    #define testcase ll tt; cin >> tt; while(tt--)
    #define boost ios_base::sync_with_stdio(false);cin.tie(NULL);
    #define pb push_back 
    #define vars ll h,i,j,k,d,l,r,x,y,a,b,c,v,var,n,m,z,s,ans,ind1,ind2,flag,limit1,limit2,limit3,mod;
    #define vll vector<ll>
    #define pll pair<ll,ll>
    #define sll set<ll>
    #define pint pair<int,int>
    const ll INF=1e9+7;
    const ll MOD=1e9+7;
    int main()
    {
        boost vars 
        cin>>a>>b;
        k=a/b;
        cout<<min(abs(a-k*b),abs(a-(k+1)*b));
    }

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var n, k int
	fmt.Scan(&n, &k)
	ds := make([]int, k)
	for i := 0; i < k; i++ {
		fmt.Scan(&ds[i])
	}

	canNotUse := make([]bool, 10)
	for i := range ds {
		canNotUse[ds[i]] = true
	}

	check := func(n int) bool {
		for n != 0 {
			m := n % 10
			if canNotUse[m] {
				return false
			}
			n /= 10
		}
		return true
	}
	for i := n; i < 1000000; i++ {
		if check(i) {
			fmt.Println(i)
			return
		}
	}
}


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

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> PII;
typedef pair<ll, int> PILL;
typedef pair<ll, ll> PLL;

const int MAX_N = 2e6+5;
const int M = 1e6;
const ll INF = (ll)(1e18);
const int inf = 1e9;
const ll MOD = 1000000007LL;

void solve() {

}

int n;
multiset<int> st;

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

    cin >> n;
    for (int i=0; i<pow(2, n); i++) {
        int a; cin >> a;
        st.insert(a);
    }
    vector<int> cur;
    auto it = st.end();
    it--;
    cur.push_back(*it);
    st.erase(it);

    while (!st.empty()) {
        int s = cur.size();
        for (int i=0; i<s; i++) {
           it = st.lower_bound(cur[i]);
           if (it == st.begin()) {
                cout << "No";
                return 0;
           }
           --it;
           cur.push_back(*it);
           st.erase(it);
        }
    }

    cout << "Yes";

    return 0;
}


Measured memory_bytes: 13688
N=int(input())
P=[int(input()) for i in range(N)]

arr=[(P[i],i) for i in range(N)]
arr.sort()

i=0
L=0

while(i<N):
    j=i
    while(j<N-1 and arr[j+1][1]>arr[j][1]):
        j+=1
    L=max(L,j-i+1)
    i=j+1
print(N-L)

Measured memory_bytes: 38180
#include <stdio.h>
#include <string.h>

#define MAX 8
char table[MAX][MAX];

void rotate_90()
{
	char tmp[MAX][MAX];
	for ( int i = 0 ; i < MAX ; i++ ) {
		for ( int j = 0 ; j < MAX ; j++ ) {
			tmp[j][(MAX-1)-i] = table[i][j];	
		}
	}

	memcpy( table, tmp, sizeof( table ) );
}

void print_table() 
{
	for ( int i = 0 ; i < MAX ; i++ ) {
		for ( int j = 0 ; j < MAX ; j++ ) {
			printf( "%c", table[i][j] );
		}
		printf( "\n" );
	}
}

int main()
{
	int i = 0;

	for ( i = 0 ; i < MAX ; i++ ) {
		scanf( "%s", table[i] );
	}

	for ( i = 1 ; i < 4 ; i++ ) {
		rotate_90();
		printf( "%d\n", 90 * i );
		print_table();
	}

	return 0;
}



Measured memory_bytes: 1984
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int N=1e6+9;
ll a[N],f[N],c[N],n,s;
void change(ll x,ll v)
{
	for(;x<=n;x+=x&-x)c[x]=min(c[x],v);
}
long long check(ll x)
{
	ll ans=0x3f3f3f3f;
	for(;x;x-=x&-x)ans=min(ans,c[x]);return ans;
}
int main()
{
	int n;cin>>n;cout<<n*n;return 0;
	scanf("%lld%lld",&n,&s);
	long long i,j;
	scanf("%d",&a[1]);
	for(i=2;i<=n;i++)scanf("%lld",&a[i]),a[i]=max(a[i],a[i-1]+1);
	long long L,R,mid;
	memset(c,0x3f,sizeof(c));
	for(i=1;i<=n;i++)
	{
		L=1,R=i;
		while(L<R)
		{
			mid=(L+R>>1);
			if(f[mid]-mid-1<=a[i]-i)L=mid+1;
			else R=mid;
		}f[i]=a[i]-(L-1)+2*s+i-1;
		if(L!=i)f[i]=min(f[i],check(n+1-L)+2*s+2*i);
		change(n+1-i,f[i]-2*i-2);
	}cout<<f[n];
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm>
#include<queue>
#include<map>
#include<set>
using namespace std;
int n;

int main()
{
    int i=0;
    cin>>n;
    n-=1;
    while (n)
    {
        n/=3;
        i+=1;
    }
    cout<<i<<endl;

    return 0;
}




Measured memory_bytes: 3112
#include<bits/stdc++.h>
using namespace std;
#define maxP 100005
#define FOR(a,b,c) for(a=b;a<c;a++)
#define REMOVE_REDUNDANT
#define EPS 1e-9
#define PI acos(-1.0)
typedef struct {
    double x, y;
} Point;
Point P[maxP], CH[maxP],pivot;
int cmp(const void *i, const void *j) {
    Point *a, *b;
    a = (Point *)i, b = (Point *)j;
    if(a->y != b->y)
        return a->y - b->y > 0 ? 1 : -1;
    return a->x - b->x > 0 ? 1 : -1;
}
bool myComparison(const Point &a,const Point &b)
{
	if(a.y!=b.y)
       return a.y<b.y;
    else return a.x<b.x;
}
double cross(Point *o, Point *a, Point *b) {  		// cross product
    return (a->x - o->x)*(b->y - o->y) -
        (a->y - o->y)*(b->x - o->x);
}

double dist(Point p1, Point p2) {                // Euclidean distance
  return hypot(p1.x - p2.x, p1.y - p2.y); }           // return double

bool angleCmp(Point &a, Point &b) {                 // angle-sorting function
  if (fabs(cross(&pivot, &a, &b)) < EPS)                               // special case
    return dist(pivot, a) < dist(pivot, b);    // check which one is closer
  double d1x = a.x - pivot.x, d1y = a.y - pivot.y;
  double d2x = b.x - pivot.x, d2y = b.y - pivot.y;
  return (atan2(d1y, d1x) - atan2(d2y, d2x)) < 0; }   // compare two angles

void convexHull(int n) {
    int P0 = 0;
  for (int i = 1; i < n; i++)
  if (P[i].y < P[P0].y || (P[i].y == P[P0].y && P[i].x < P[P0].x)) //Diurutkan dari y terkecil, jika y sama maka diutamakan x yang paling kecil.
      {P0 = i;}
  Point temp; 
  temp = P[0]; 
  P[0] = P[P0]; 
  P[P0] = temp;  //swap pivot
  pivot=P[0];
  sort(P+1,P+n,angleCmp); // sort berdasarkan angle
  int i, m = 0, t;
    for(i = 0; i < n; i++) {
        while(m >= 2 && cross(&CH[m-2], &CH[m-1], &P[i]) < 0) // mengecek apakah belok ke kanan atau ke kiri. jika collinear tidak dimasukkan, ditambahkan = . Hati-hati dengan redundant karena tanpa =  akan menambahkan redundant
            m--;
        CH[m++] = P[i];
    }
    for(i = n-2, t = m+1; i >= 0; i--) {		
        while(m >= t && cross(&CH[m-2], &CH[m-1], &P[i]) < 0) // mengikuti aturan diatas
            m--;
        CH[m++] = P[i];
    }
    printf("%d\n",m-1);
    for(i = 0; i < m-1; i++) {
       
        printf("%.lf %.lf\n", CH[i].x, CH[i].y);
    }
}int main()
{	
	int t,tc,i,n;
	double x,y;
	int k;
	Point contoh;
	char dummy[5];
	tc=1;
	FOR(t,0,tc)
	{
		scanf("%d",&n);
		k=0;
		FOR(i,0,n)
		{
			scanf("%lf %lf",&contoh.x,&contoh.y);
			
				P[k]=contoh;
				k+=1;
			
		}
		convexHull(k);
	}
}

Measured memory_bytes: 5976
#include <iostream>

using namespace std;

int main() {
	int n, k;
	int i, j;
	bool d[10];
	bool flag;

	cin >> n >> k;
	for(i=0; i<10; i++) d[i]=true;
	for(i=0; i<k; i++) {
		int m;
		cin >> m;
		d[m]=false;
	}

	for(i=n;;i++) {
		flag=true;
		int calc = i;
		while(calc>0) {
			if(!d[calc%10]) flag=false;
			calc /= 10;
		}
		if(flag) break;
	}

	cout << i << endl;

	return 0;
}


Measured memory_bytes: 256
N, M = map(int, input().split())

a = [0 for i in range(N)]
b = [0 for i in range(N)]
c = [0 for i in range(M)]
d = [0 for i in range(M)]

for i in range(N):
    a[i], b[i] = map(int, input().split())
for i in range(M):
    c[i], d[i] = map(int, input().split())
    
for i in range(N):
    closest_ind = -1
    closest_dist = 10000000000
    for j in range(M):
        if closest_dist > abs(a[i] - c[j]) + abs(b[i] - d[j]):
            closest_ind = j
            closest_dist = abs(a[i] - c[j]) + abs(b[i] - d[j])
    print(closest_ind + 1)

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

int main() {
  int N, M;
  int maxCnt;

  // input
  cin >> N;
  string s[N];
  
  for(int i = 0; i < N; i++){
    cin >> s[i];
  }

  cin >> M;
  string t[M];
  
  for(int i = 0; i < M; i++){
    cin >> t[i];
  }
  
  // solve
  for(int i = 0; i < N; i++){
    int tmpCnt = 0;
    string scope = s[i];
    
    for(int j = 0; j < N; j++){
      if(scope == s[j]){
        tmpCnt++;
      }
    }

    for(int j = 0; j < M; j++){
      if(scope == t[j]){
        tmpCnt--;
      }
    }
    
    if( tmpCnt > maxCnt ){
      maxCnt = tmpCnt;
    }
  }
  
  // output
  if(maxCnt < 0){
    cout << 0 << endl;
  }
  else{
    cout << maxCnt << endl;
  }
  
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define lli long long int
#define REP(i,s,l) for(lli i=s;i<l;i++)
#define DEBUG 0
#define INF (1LL<<50)
#define MOD 1000000007

bool check(lli bit){
	return bit&(bit<<1);
}

signed main(){

	lli h,w,k;
	cin>>h>>w>>k;
	k--;

	lli dp[110][10]={0};
	dp[0][0]=1;

	if(w==1){
		cout<<1<<endl;
		return 0;
	}

	for(lli i=1;i<=h;i++){
		for(lli bit=0;bit<(1LL<<w-1);bit++){
			if(check(bit)==true)continue;
			if(DEBUG)cout<<"bit="<<bit<<endl;
			lli tmp[10];
			REP(j,0,w)tmp[j] = dp[i-1][j];
			for(lli j=0;j<w-1;j++){
				if(bit & 1<<j){
					swap(tmp[j],tmp[j+1]);
				}
			}
			REP(j,0,w) dp[i][j] = (dp[i][j] + tmp[j])%MOD;
		}
	}

	
	cout<<dp[h][k]%MOD<<endl;
	return 0;
}

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

using namespace std;
typedef long long ll;

ll N, a[200000];
ll sum[200001] = {};//sum[i] i-1番目までの累積和

ll my_abs(ll a) {
	if (a < 0)return a * -1;
	return a;
}

int main() {
	cin >> N;
	for (int i = 0; i < N; i++){
		cin >> a[i];
		sum[i + 1] = sum[i] + a[i];
	}
	//累積和
	ll res = 1000000000000;
	if (N == 2) {
		cout << my_abs(a[0] - a[1]) << endl;
		return 0;
	}
	for (int i = 1; i < N - 1; i++) {
		res = min(res, my_abs((sum[i] - sum[1]) - (sum[N - 1] - sum[i]) + a[0] - a[N - 1]));
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
typedef int int__;
#define int long long
#define pb push_back
#define pi pair<int,int>
#define vpi vector<pi>
#define vi vector<int>
#define vvi vector<vi>
#define fi first
#define se second
#define forn(i, n)for(int i=0;i<int__(n);i++) 
#define sz(a)int__(a.size())
template <class A, class B> ostream& operator << (ostream& out, const pair<A, B> &a){return out << "(" << a.first << ", " << a.second << ")";}
template<class A>ostream& operator<<(ostream& out,const vector<A>&v){out<<"[";forn(i,sz(v)){if(i)out<<", ";out<<v[i];}return out<<"]";}
const int MAX = 1e5 + 100;
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
int Mod(int x){const int mm=998244353;x%=mm;if(x<0)x+=mm;return x;}
int Pow(int x,int n){if(n==0)return 1;int t=Pow(x,n/2);t=Mod(t*t);if(n&1)t=Mod(t*x);return t;}
#define watch(x) cout << #x << " : " << x << endl;
int gcd(int a,int b){if(b==0)return a;return gcd(b,a%b);}

int__ main()
{	
	int n; cin >> n;
	string a,b; cin >> a >> b;

	for(int i=0;i<2*n;i++){
		if(i%2==0){
			cout<<a[i/2];
		} else cout << b[i/2];
	}
}

Measured memory_bytes: 256
#include <cassert>

#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
//#include <boost/foreach.hpp>
//#include <boost/range/algorithm.hpp>
#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define ll long long
#define Sort(v) sort(all(v))
#define INF 1000000000
#define END return 0
#define pb push_back
#define se second
#define fi first
#define pb push_back
#define all(v) (v).begin() , (v).end()
#define MP make_pair
#define MOD 1000000007LL
using namespace std;
int day[12]={31,28,31,30,31,30,31,31,30,31,30,31};

int main (){
    int n,m;cin>>n>>m;
    vector<vector<int>> v(n,vector<int>(m));
    rep(i,0,n)rep(j,0,m)cin>>v[i][j];
    int ans=INT_MAX;
    rep(i,0,n){ //縦の幹線道路
        rep(j,0,m){ //横の幹線道路  
            int subans=0;
            rep(k,0,n)rep(l,0,m){ //住人を全探索
                subans+=v[k][l]*(min(abs(k-i),abs(l-j)));
            }
            ans=min(ans,subans);
        }
    }
    cout<<ans<<endl;
    
    
}


/*
6
100
90
80
90
100
65
*/



Measured memory_bytes: 3152
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cassert>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
using namespace std;


typedef long long i64;
const int inf = (int)1.05e9;

i64 square_root(i64 x)
{
	i64 lo = 0, hi = 1.05e9;

	while(hi - lo > 1) {
		i64 mid = (hi + lo) / 2;
		if(mid * mid < x) {
			lo = mid;
		} else {
			hi = mid;
		}
	}

	return hi;
}

int main()
{
	i64 s;

	scanf("%lld", &s);
	i64 n = square_root(s);

	i64 diff = n * n - s;
	i64 x1, y1, x2, y2;

	if(diff > n) {
		x1 = n;
		y2 = n - 1;
		x2 = 1;
		y1 = (diff - n);
	} else {
		x1 = n;
		y2 = n;
		x2 = 1;
		y1 = diff;
	}

	printf("%lld %lld %lld %lld %lld %lld\n", 0, 0, x1, y1, x2, y2);

	return 0;
}

/* waffle */


Measured memory_bytes: 128
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

pub fn read_n<T: FromStr>(n: usize) -> Vec<T> {
    read_n_logic::<T>(n, vec![])
}

pub fn read_n_logic<T: FromStr>(n: usize, mut a: Vec<T>) -> Vec<T> {
    match n {
        0 => a,
        _ => {
            a.push(read::<T>());
            read_n_logic(n - 1, a)
        }
    }
}
use std::cmp::{max, min};

fn main() {
    let n: i64 = read();
    let mut ans: i64 = 0;
    for i in 0..n + 1 {
        if i % 3 != 0 && i % 5 != 0 {
            ans += i;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 2156
n,m,c=map(int,input().split())
B=list(map(int,input().split()))
ans=0
for i in range(n):
  A=list(map(int,input().split()))
  cou=0
  for j in range(m):
    cou+=A[j]*B[j]
  if cou+c>0:
    ans+=1
print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int n,m,d[30][30],f[30][30],ans;
char ch;
void dfs(int x,int y,int k)
{
	if(!f[x][y])return;
	if(d[x][y]<=k)return;else d[x][y]=k;
	dfs(x-1,y,k+1);dfs(x+1,y,k+1);
	dfs(x,y-1,k+1);dfs(x,y+1,k+1);
}
int mx()
{
	int mxx=0;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
			if(d[i][j]^d[0][0])mxx=max(mxx,d[i][j]);
	return mxx;
}
int main()
{
	cin>>n>>m;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
			if(cin>>ch,ch=='.')f[i][j]=1;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
		{
			memset(d,0x7f,sizeof(d));
			dfs(i,j,0);
			ans=max(ans,mx());
		}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 3756
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <queue>
#include <cstring>
#include <map>
#define debug(x) std::cerr << #x << " = " << (x) << std::endl
using namespace std;
typedef long long LL;
const int MAXN = 2e5 + 17;
const int MOD = 1e9 + 7;
LL f[MAXN],lst[MAXN],pre[MAXN],a[MAXN];
int main(int argc, char const *argv[])
{
#ifdef noob
    freopen("Input.txt", "r", stdin);
    freopen("Output.txt", "w", stdout);
#endif
	int n;
	cin>>n;
	for (int i = 1; i <= n; ++i) 
	{
		cin>>a[i];
		pre[i] = lst[a[i]];
		lst[a[i]] = i;
	}
	f[0] = 1;
	for (int i = 1; i <= n; ++i) 
	{
		f[i] = f[i-1];
		if(a[i-1]!=a[i]&&pre[i]!=0) f[i] = (f[i]+f[pre[i]])%MOD;
	}
	cout<<(f[n]%MOD)<<endl;
    return 0;
}


Measured memory_bytes: 6528
a, b = map(int, input().split())
b += 1
ret = 0
for k in range(40):
    ar = a % 2 ** (k+2)
    br = b % 2 ** (k+2)
    if ar & (2 ** (k+1)):
        ar = ar - 2**(k+1)
    else:
        ar = 0
    if br & (2 ** (k+1)):
        br = br - 2**(k+1)
    else:
        br = 0
    if (ar - br) % 2:
        ret += 2**(k+1)
def f(x):
    if x == 0:
        return 0
    if x == 1:
        return 0
    if x == 2:
        return 1
    if x == 3:
        return 1
print(ret + ((f(a % 4) + f(b % 4)) % 2))

Measured memory_bytes: 3064
N = int(input())
def su(n):
    s = 0
    for i in range(1,n+1):
        s += i
    return s

if N == 1:
    print(1)

elif N == 2:
    print(2)
    
elif N == 3:
    print(2)
    print(1)

elif N == 4:
    print(3)
    print(1)
    
else:
    for i in range(N):
        if su(i) >= N:
            M = i
            break
    print(M)

    now = N-M
    
    for i in range(1,M-1):
        if now - (M-i) >=(M-i):
            now -= M-i
            print(M-i)

        else:
            print(M-i)
            if now-(M-i) != 0: 
                print(now-(M-i))
            break

Measured memory_bytes: 42224
#include"bits/stdc++.h"
using namespace std;
#define REP(k,m,n) for(int (k)=(m);(k)<(n);(k)++)
#define rep(i,n) REP((i),0,(n))
using ll = long long;
using ull=unsigned long long;
constexpr ll MOD = 1000000007;

ull mpow(ull a, ull b) {
	ll res = 1;
	while (b > 0) {
		if (b & 1)res *= a;
		a = a * a;
		b >>= 1;
	}
	return res;
}

vector<ull> make_hash(const string& s) {
	vector<ull> res(s.size() + 1, 0);
	ll h = 0;
	rep(i, s.size()) {
		h = h * MOD + s[i];
		res[i] = h;
	}
	return res;
}

map<ull, vector<int>> rolling_hash(const vector<ull>& hash, const int diff) {
	map<ull, vector<int>> mp;
	int siz = hash.size() - diff;
	rep(i, siz) {
		auto num = hash[i] - hash[i + diff];
		num *= mpow(MOD, i);
		mp[num].push_back(i);
	}
	return mp;
}

map<ull, vector<int>> hashing(const string s, const int diff) {
	map<ull, vector<int>> mp;
	ull t = 1;
	rep(i, diff)t *= MOD;

	ull h = 0;
	rep(i, diff)h = h * MOD + s[i];
	rep(i, s.size() - diff) {
		mp[h].push_back(i);
		h = h * MOD + s[i + diff] - s[i] * t;
	}
	mp[h].push_back(s.size() - diff);
	return mp;
}

bool judge(map<ull, vector<int>>& mp, int len) {
	int res = 0;
	for (auto itr : mp) {
		if (itr.second.size() < 2)continue;
		int score = *max_element(itr.second.begin(), itr.second.end())
			- *min_element(itr.second.begin(), itr.second.end());
		res = max(res, score);
	}
	return (res >= len);
}

int main()
{
	int N;
	string S;
	cin >> N >> S;
	//auto hash = make_hash(S);

	// safe , out
	int l = 0, r = N;
	while (r - l > 1) {
		int mid = (l + r) / 2;
		auto mp = hashing(S, mid);
		if (judge(mp, mid)) {
			l = mid;
		}
		else {
			r = mid;
		}
	}
	cout << l << endl;
	return 0;
}


Measured memory_bytes: 768
import java.util.*;

public class Main {
    public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();
        String S = sc.next();
        char[]ss = S.toCharArray();

            if(ss[K-1]=='A'){
                ss[K-1]='a';
                System.out.println(String.valueOf(ss)); 
            }else if(ss[K-1]=='B'){
                 ss[K-1]='b';
                System.out.println(String.valueOf(ss)); 
            }else{
                 ss[K-1]='c';
                System.out.println(String.valueOf(ss));            
            }
 	    }
}


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

using ll = long long;
using ull = unsigned long long;

#define MOD 1000000007

int main(void) {
    ll N;
    ll sum = 0;
    vector<ll> A, B;
    cin >> N;
    A.resize(N + 1);
    B.resize(N);
    for(ll i = 0;i < N + 1;i++) cin >> A[i];
    for(ll i = 0;i < N;i++) cin >> B[i];
    for(ll i = 0;i < N;i++) {
        ll c = min(B[i], A[i]);
        sum += c;
        sum += max(0LL, min(B[i] - c, A[i + 1]));
        A[i + 1] -= max(0LL, min(B[i] - c, A[i + 1]));
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 1792
n, m = map(int, input().split())
lst = []
for i in range(m):
    tmplst = list(map(int, input().split()))
    tmplst.append(i)
    lst.append(tmplst)
    
lst.sort()
tmp = 0
for i in range(m):
    if(tmp != lst[i][0]):
        lst[i][1] = 1
        tmp = lst[i][0]
    else:
        lst[i][1] = lst[i-1][1] + 1
        tmp = lst[i][0]
        
lst2 = []
for i in range(m):
    tmplst2 = [str(lst[i][0]).zfill(6)+str(lst[i][1]).zfill(6), lst[i][2]]
    lst2.append(tmplst2)

lst2.sort(key=lambda i: i[1])

for i in range(m):
    print(lst2[i][0])

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

int main () {
    int d[] = {1,5,10,50,100,500};
    int sum = 0;
    for (int i = 0; i < 6; i++) {
        int x;
        cin >> x;
        sum += d[i] * x;
    }
    if (sum >= 1000) cout << 1 << endl;
    else cout << 0 << endl;

    return 0;
}

Measured memory_bytes: 3096
import java.util.*;

class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
	int a = scan.nextInt();
	int b = scan.nextInt();
	int c = scan.nextInt();

	boolean isAB5C7 = (a==5 && b==5 && c==7);
	boolean isBC5A7 = (a==7 && b==5 && c==5);
	boolean isCA5B7 = (a==5 && b==7 && c==5);

	if(isCA5B7||isBC5A7||isAB5C7){
		System.out.println("YES");
	}else{
		System.out.println("NO");
	}
	}
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int n;
  cin >> n;
  int a[n],b[n+1];
  b[0]=0;
  for(int i=0;i<n;i++){
    cin >> a[i];
    b[i+1]=b[i]+a[i];
  }
  sort(b,b+n+1);
  int e=1,f=0;
  for(int i=0;i<n;i++){
    if(b[i]==b[i+1])e++;
    else{
      f+=e*(e-1)/2;
      e=1;
    }
  }
  f+=e*(e-1)/2;
  cout << f;
}


Measured memory_bytes: 3328
package main

import "fmt"

var CYCLE = int64(1000000007)
var n int
var w [100000]int64
var b [100000]int64
var visited [100000]bool

type Edge struct {
	x, y int
}

var edges map[int][]int

func getChildren(i int) []int {
	possibleChildren := edges[i]
	visited[i] = true
	result := make([]int, 0, len(possibleChildren))
	for _, c := range possibleChildren {
		if !visited[c] {
			result = append(result, c)
		}
	}
	return result
}

func solve(i int) {
	w[i], b[i] = int64(1), int64(1)
	children := getChildren(i)
	for _, c := range children {
		solve(c)
		w[i] = (w[i] * (w[c] + b[c])) % CYCLE
		b[i] = (b[i] * w[c]) % CYCLE
	}
}

func main() {
	fmt.Scan(&n)
	edges = make(map[int][]int)

	var x, y int
	for i := 0; i < n-1; i++ {
		fmt.Scan(&x, &y)
		edges[x-1] = append(edges[x-1], y-1)
		edges[y-1] = append(edges[y-1], x-1)
	}

	solve(0)

	fmt.Println((w[0] + b[0]) % CYCLE)
}


Measured memory_bytes: 40064
//Author:- S_Aditya

#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
using namespace std;
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
#define ll long long 
#define scn(n) scanf("%d",&n)
#define lscn(n) scanf("%lld",&n)
#define lpri(n) printf("%lld",n)
#define pri(n) printf("%d",n)
#define pln() printf("\n")
#define priln(n) printf("%d\n",n)
#define lpriln(n) printf("%lld\n",n)
#define rep(i,init,n) for(int i=init;i<n;i++)
#define pb push_back     
#define mp make_pair
#define F first
#define S second
#define gcd __gcd
#define inf INT_MAX
#define ninf INT_MIN
const ll mod=1e9+7;         
const int N=3e2+4;

int main()                  
{
    int n,k;
    
    scn(n); scn(k);
    
    int a[n],mn=inf;
    
    rep(i,0,n)
    scn(a[i]),mn=min(mn,a[i]);
    
    int dp[k+1]; //dp[i] stores 1 if 1st player wins if we start of with a pile of i stones and 2 if second players wins.

    rep(i,0,mn)
    dp[i]=2;

    rep(i,0,k+1)
    {
        dp[i]=2;
        
        rep(j,0,n)
        if(i-a[j]>=0)
        {
            if(dp[i-a[j]]==2)
            dp[i]=1;
        }
    }
    
    if(dp[k]==1)
    printf("First");
    else
    printf("Second");
} 


Measured memory_bytes: 640
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace __gnu_pbds;
using namespace std;
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define PI 3.1415926535897932384626433832795
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
long long MOD = 1e9+7;
pair<int,int> dx[4] = {{1,0},{-1,0},{0,1},{0,-1}};
const int RANDOM = chrono::high_resolution_clock::now().time_since_epoch().count();
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
struct chash {
    int operator()(int x) const { return x ^ RANDOM; }
};
string toString(long long x)
{
stringstream ss;
ss << x;
string str = ss.str();
return str;
}
long long fastpow(long long x,long long k)
{
    if(!k)
        return 1;
    if(k & 1)
        return ((x * fastpow(x,k-1) % MOD) % MOD) % MOD;
    long long ans = fastpow(x,k/2);
    ans %= MOD;
    ans *= ans;
    ans %= MOD;
    return ans;
}
long long sumF(long long x)
{
    int s = 0;
    while(x)
        s += x%10,x /= 10;
    return s;
}
int freq[26];
long long dp[26];
long long solve(int idx)
{
    if(idx == 26)
        return 1;
    if(dp[idx] != -1)
        return dp[idx];
    long long C1 = freq[idx] * solve(idx + 1);
    long long C2 = solve(idx + 1);
    return dp[idx] = ((C1 % MOD) + (C2 % MOD)) % MOD;
}
int main()
{
    memset(dp,-1,sizeof dp);
    IO;
    int n,k;
    cin >> n >> k;
    if((n+1) / 2 >= k)
        cout << "YES";
    else
        cout << "NO";
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
int main()
{
	int i=0,a,num=0,sum[1000]={0};
	char x[1000];
	while(1)
	{
		for(i=0;;i++)
		{
		scanf("%c",&x[i]);
		if(x[i]=='\n')break;
		sum[num]+=x[i]-'0';
		}
		if(x[0]=='0'&&x[1]=='\n')break;
		num++;
	}
	for(i=0;i<num;i++)
	{
		std::cout<<sum[i]<<std::endl;
	}
	return 0;
}

Measured memory_bytes: 1156
#include <iostream>
#include<algorithm>
using namespace std;
#define ll long long int
int main()
{
    ll n;
    cin>>n;
    string ans="";
    while(n>0){
        ll x = n%26;
        char ch;
        if(x==0){
            ch = 'z';
        }
        else{
            ch = 'a'+x-1;
        }
        ans = ch+ans;
        n = (n-1)/26;
    }
    cout<<ans;
}


Measured memory_bytes: 3632
package main

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

func main() {

	sc := bufio.NewScanner(os.Stdin)
	sc.Scan()
	s := sc.Text()
	result := 9999
	for i := 0; i < len(s)-2; i++ {
		j, _ := strconv.Atoi(s[i : i+3])
		diff := 753 - j
		if diff < 0 {
			diff = -diff
		}
		if result > diff {
			result = diff
		}
	}
	fmt.Println(result)
}


Measured memory_bytes: 640
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <cmath>
#include <map>
using namespace std;
#define MOD 1000000007
#define ADD(X,Y) ((X) = ((X) + (Y)%MOD) % MOD)
typedef long long i64; typedef vector<int> ivec; typedef vector<string> svec;

int main()
{
	int N, Li[2020];
	scanf("%d", &N);
	for (int i = 0; i < 2 * N; ++i) scanf("%d", Li + i);
	sort(Li, Li + 2 * N);
	int ans = 0;
	for (int i = 0; i < 2 * N; i += 2) ans += Li[i];
	printf("%d\n", ans);
	return 0;
}


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


int main(){
    ll N,K,a1,a2,a3;
    cin >>N >> K;
    a1 = N%K;
    a2 = -1*(a1-K);
    cout << min(a1,a2) << endl;
}

Measured memory_bytes: 256