akhauriyash/Code-Regression huggingface dataset:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd, log
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7 
#mod = 998244353
from decimal import *
#import numpy as np
#decimal.getcontext().prec = 10

N = INT()
A = LIST()
c = Counter(A)

a = list(c.keys())
n = len(a)

if n == 1 and c[0] == N:
	print("Yes")
elif N%3 == 0:
	if n == 3 and len(set(c.values())) == 1 and a[0]^a[1] == a[2]:
		print("Yes")
	elif n == 2 and c[0] == N//3:
		print("Yes")
	else:
		print("No")
else:
	print("No")


Measured memory_bytes: 21820
#include <bitset>
#include <cmath>
#include <cstdint>
#include <iostream>
#include <map>
#include <string>
#include <vector>

using std::cin;
using std::cout;
using std::endl;
using std::string;

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

  int len = N.length();
  int ways = std::pow(2, len - 1);

  int64_t ans = std::stol(N);
  for (int i = 1; i < ways; i++) {
    int64_t sum(0);
    int idx(0);
    std::bitset<10> bit(i);

    // std::cout << "bit: " << bit << endl;
    bit[len - 1] = 1;
    for (int j = 0; j < len; j++) {
      if (bit[j] == 1) {
        auto sub = N.substr(idx, j - idx + 1);
        sum += std::stol(sub);
        // cout << "added: " << sub << endl;
        idx = j + 1;
      }
    }

    ans += sum;
    // cout << "sum: " << sum << endl;
  }
  cout << ans << endl;
}


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

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

    for(int bit = 0; bit < 1 << (s.size() - 1); ++bit)
    {
        int sum = s[0] - '0';
        string res;
        res += s[0];
        for(int i = 1; i < s.size(); ++i)
        {
            if(bit & (1 << (i-1)))
            {
                sum += s[i] - '0';
                res += '+';
            } else
            {
                sum -= s[i] - '0';
                res += '-';
            }
            res += s[i];
        }
        
        if(sum == 7)
        {
            cout << res + "=7" << "\n";
            break;
        }
    }

    return 0;
}

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

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

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

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vi v(n);
	REP(i, n)cin >> v[i];
	sort(ALL(v));
	int sum = 0;
	REP(i, n - 1)sum += v[i];
	sum -= v.back();
	if (sum > 0)cout << "Yes" << endl;
	else cout << "No" << endl;
}

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

template <class T>
inline void read(T &x) {
    x = 0;
    int f = 0;
    char ch = getchar();
    while (!isdigit(ch))    { f |= ch == '-'; ch = getchar(); }
    while (isdigit(ch))     { x = (x << 1) + (x << 3) + (ch ^ 48); ch = getchar(); }
    x = f ? -x : x;
    return;
}

typedef long long LL;

const LL mod = 1e9 + 7;

LL n, a, b;

LL qPow(LL a, LL b) {
    LL s = 1;
    while (b) {
        if (b & 1)  s *= a, s %= mod;
        a *= a, a %= mod;
        b >>= 1;
    }
    return s % mod;
}

LL inv(LL a) { return qPow(a, mod - 2); }

LL C(LL n, LL m) {
    LL s = 1;
    for (int i = n; i >= n - m + 1; --i)    s *= i, s %= mod;
    for (int i = m; i >= 1; --i)    s = s * inv(i) % mod;
    return (s % mod + mod) % mod;
}

int main() {
    read(n), read(a), read(b);
    printf("%lld\n", ((qPow(2, n) - 1 - C(n, a) - C(n, b)) % mod + mod) % mod);
    return 0;
}

Measured memory_bytes: 256
/*  
    tanuj_johal :: gla_clg_sync_with_CSE(true);
    bonding.tie(true);
    hardwork.tie(true);
    
    ::::::::--------------------::::::::
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define ll          long long
#define fio         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb          push_back
#define vi          vector<ll>
#define pp          push_pop
#define pll         pair<ll,ll>
#define in          insert
#define ff          first
#define ss          second
#define inf         10000000000000000
#define all(p)      p.begin(), p.end()
#define que_max     priority_queue <int>
#define que_min     priority_queue <int, vi, greater<int>>
#define print(a)    for(auto i:a){cout<<i<<" ";}
#define print1(a)   for(auto i:a){cout<<i.ff<<" "<<i.ss<<endl;}

typedef tree<pll, null_type, less<pll>, rb_tree_tag, tree_order_statistics_node_update> Set;


const ll mod = 1e9+7;

ll power(ll x,ll y,ll p){ll r=1;x=x%p;while(y>0){if(y&1)r=(r*x)%p;y=y>>1;x=(x*x)%p;}return r;}
bool imp = false;

void solve()
{
    unordered_map<ll,ll> mp;        set<ll> st;
    multiset<ll> ms;
    
    ll n;cin>>n;
    
    ll x = 100;
    ll ans = 0;
    while(x<n){
        ans++;
        double d = ((double)x/100);
        d = floor(d);
        x += (ll)d;
    }
    cout<<ans<<endl;
    
    
}

int main()
{
    fio
    int t=1;
    if(imp) cin>>t;
    while(t--)
    {
        // cout<<"Case #"<<tc<<": ";
        solve();
        // tc++;
    }
    
}


Measured memory_bytes: 3660
#include <stdio.h>

bool isprime(int n)	{
	if (n == 1)	return false;
	for (int i = 2; i*i <= n; i++)	{
		if (n % i == 0)	return false;
	}
	return true;
}

int main(void)	{
	
	int a, d, n, tousa, cnt;
	
	while (true)	{
		
		scanf("%d %d %d", &a, &d, &n);
		if (a == 0)	break;
		
		cnt = 0;
		
		for (int i = 0; ; i++)	{
			tousa = a + i*d;
			
			if (isprime(tousa))	cnt++;
			
			if (cnt >= n)	{
				printf("%d\n", tousa);
				break;
			}
		}
	}
	
	return 0;
}


Measured memory_bytes: 2588
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
    using namespace std;
 
    int main(){
      int n;
      cin >> n;
      int a[n];
      rep(i,n)cin >> a[i];
      int count=0;
      rep(i,n){
       if(a[i]%2==1)count++; 
      }
      if(count%2==1)cout << "NO" << endl;
      else cout << "YES" << endl;
      return 0;}

Measured memory_bytes: 640
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

    public static void main(String[] args) throws Exception {
        try (BufferedReader reader = new BufferedReader(new InputStreamReader(System.in))) {
            int N = readInt(reader);
            int[] A = readIntArray(reader);
            int[] B = readIntArray(reader);
            int[] C = readIntArray(reader);

            int manzoku = 0;
            for (int i = 0; i < N; i++) {
                manzoku += B[A[i] - 1];

                if (i >= 1 && A[i] == A[i - 1] + 1) {
                    manzoku += C[A[i - 1] - 1];
                }
            }

            System.out.println(manzoku);
        }
    }

    public static int readInt(BufferedReader reader) throws Exception {
        return Integer.parseInt(reader.readLine());
    }

    public static int[] readIntArray(BufferedReader reader) throws Exception {
        String[] str = reader.readLine().split(" ");
        int[] array = new int[str.length];
        for (int i = 0; i < str.length; i++) {
            array[i] = Integer.parseInt(str[i]);
        }
        return array;
    }

}


Measured memory_bytes: 21204
#include <vector>
#include <map>
#include <set>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <queue>

typedef char                SINT8;
typedef unsigned char       UINT8;
typedef short               SINT16;
typedef unsigned short      UINT16;
typedef int                 SINT32;
typedef unsigned int        UINT32;
typedef long long           SINT64;
typedef unsigned long long  UINT64;
typedef double              DOUBLE;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))
#define rep(i,a,b) for(int (i)=int(a);(i)<int(b);(i)++)

#define INF 1000000001
#define MOD 1000000007
#define INF64 1000000000000000001

#define F first
#define S second

#define Pii pair<SINT32,SINT32>
#define Pll pair<SINT64,SINT64>


using namespace std;

int main() {

	SINT32 N = 0;
	SINT32 M = 0;
	SINT32 ans = 0;

	cin >> N;
	cin >> M;

	vector<vector<SINT32>> dist(10,vector<SINT32>(10));
	
	rep(i,0,10) {
		rep(j,0,10) {
			cin >> dist[i][j];
		}
	}
	rep(k,0,10) {
		rep(i,0,10) {
			rep(j,0,10) {
				dist[i][j] = MIN(dist[i][j], dist[i][k]+dist[k][j]);
			}
		}
	}
	rep(i,0,N) {
		rep(j,0,M) {
			SINT32 buf;
			cin >> buf;
			if (buf != -1) {
				ans += dist[buf][1];
			}
		}
	}

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

//	sort(DATA.begin(),DATA.end());
//	sort(DATA.begin(),DATA.end(),std::greater<SINT32>());
//	__gcd(ANS,DATA[i]);

//	// DATA.emplace_back(BUF);	//後ろに追加

//  DATA.erase(std::unique(DATA.begin(), DATA.end()), DATA.end());	//ソート後に使用

//	DATA.insert(DATA.begin() + X, 0);	//X番目の要素に0を挿入


//	vector<vector<SINT32>> DP(N,vector<SINT32>(3));	//2次元配列

/*
	SINT32 M = 3;
	vector<pair<SINT32,SINT32>> DATA2(M);
	for (SINT32 i = 0; i < M; i++) {
		cin >> DATA2[i].first;
		cin >> DATA2[i].second;
	}
	sort(DATA2.begin(),DATA2.end());
	cout << DATA2[0].first << endl;
	cout << DATA2[0].second << endl;
*/

// 	vector<pair<int,pair<int,int>>> DATA(M);
//	cin >> DATA[i].first;
//	cin >> DATA[i].second.first;
//	cin >> DATA[i].second.second;


//		APOSI = lower_bound(ADATA.begin(),ADATA.end(),QDATA[i]) - ADATA.begin();	//key以上を探す
//		BPOSI = lower_bound(BDATA.begin(),BDATA.end(),QDATA[i]) - BDATA.begin();


/* 文字列回転
	string N;
	cin >> N;
	N = N[N.length()-1] + N.substr(0,N.length()-1);
*/
/* 文字列合成
	string N,M;
	cin >> N >> M;
	SINT64 ans = 0;
	ans = stoi(N+M);
*/



/* SET コンテナ
	set<SINT32> DATA;
	for (SINT32 i = 0; i < N; i++) {
		SINT32 buf;
		cin >> buf;
		DATA.insert(buf);
	}

	//全表示
    set<string>::iterator it; //  イテレータを用意
    for(it = DATA.begin(); it != DATA.end(); it++) {
        cout << *it << endl;
    }

	//N番目を一部表示
	set<string>::iterator it; //  イテレータを用意
	it = DATA.begin();
	rep (i,0,N) {
		it++;
	}
	cout << *it << endl;
*/

/* map
	map<string,SINT32> mp;
	SINT32 N = 0;
	SINT32 mx = 0;

	cin >> N;
	for (SINT32 i = 0; i < N; i++) {
		string s;
		cin >> s;
		mp[s]++;
	}
	for(auto it=mp.begin();it!=mp.end();it++) {
		mx=max(mx,it->second);
	}

*/

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int i, K, A, B, c=0;
  scanf("%d",&K);
  scanf("%d%d",&A,&B);
  for(i=A; i<=B; i++){
    if (i%K==0){
      c=1;
      break;
    }
    else
      continue;
  }
  if (c==0)
  printf("NG");
  else
  printf("OK");
}

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

public class Solution
{
    public static void Main()
    {
        var s = Console.ReadLine();

        string result = "Good";
        if(s[0] == s[1] || s[1] == s[2] || s[2] == s[3])
        {
            result = "Bad";
        }

        Console.WriteLine(result);
    }
}

Measured memory_bytes: 11092
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, st, n) for (int i = st; i < n; ++i)
using pii = pair<int, int>;
#define ceil(a, b) a / b + !!(a % b)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)

void outs(stack<pii> s) {while (!s.empty()) {cout << s.top().first << " " << s.top().second << endl; s.pop();}}
int main() {
    int n;
    while (cin >> n && n) {
        vector<string> v;
        stack<pii> s;
        rep(i, n) {string s; cin >> s; v.push_back(s);}
        for (int i = n - 1; i >= 0; --i) {
            int c = 0;
            while (v[i][c] == '.') c++;
            char last = v[i][v[i].size() - 1];
            if (0 <= last - '0' && last - '0' <= 9) {
                s.push({c, last - '0'});
            } else {
                int ret = 0;
                if (last == '*') ret = 1;
                while (!s.empty()) {
                    int dot = s.top().first, num = s.top().second;
                    s.pop();
                    //cout << dot << " " << num << endl;
                    if (dot != c + 1) {
                        s.push({dot, num});
                        break;
                    }
                    if (last == '*') ret *= num;
                    else ret += num;
                }
                s.push({c, ret});
            }
        }
        cout << s.top().second << endl;
    }
}



Measured memory_bytes: 3216
#include<bits/stdc++.h>
#define ll long long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
static const ll MAX = 1000000000000000;
static const int NIL = -1;
using namespace std;
const long double EPS = 0.0000000001;
const long double PI = (acos(-1));
const int MOD = 1000000007;

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")




int main() {


    ll k,t,a; cin >> k >> t;
    ll ans = 0;
    ll sum = 0;
    vector<ll> x(t);
    ll l = -1;
    priority_queue<pair<ll,ll>> q;

    rep(i,t){
        cin >> x[i];
        sum += x[i];
        //q.push(make_pair(a,i));
    }

    sort(x.begin(),x.end());

    if(x[x.size()-1] <= sum-x[x.size()-1]) cout << 0;
    else cout << x[x.size()-1] - (sum-x[x.size()-1]) -1;

    /*
    while(!q.empty()){

        pair<ll,ll> tmp = q.top();
        q.pop();
        if(l != tmp.second){
            tmp.first --;
            l = tmp.second;
        }else{
            if(q.size() == 1) break;
            pair<ll,ll> tmp2 = q.top();
            tmp2.first --;
            l = tmp2.second;
            if(tmp2.first != 0) q.push(tmp2);
        }
        if(tmp.first != 0) q.push(tmp);
    }

    if(!q.empty()) ans += q.top().first;
*/
    //cout << ans;


    return 0;
}


Measured memory_bytes: 3612
#include <algorithm>
#include <climits>
#include <complex>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

// using
using namespace std;

// typedef
typedef long long ll;

// define
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REVERSE(c) reverse(ALL(c))
#define UNIQ(c) unique(ALL(c))
#define FOR(i, a, b, c) for (int i = (int)(a); i < (int)(b); i += (int)(c))
#define REP(i, n) FOR(i, 0, n, 1)
#define RFOR(i, a, b, c) for (int i = (int)(a); i >= (int)(b); i -= (int)(c))
#define RREP(i, n) RFOR(i, n, 0, 1)

// functions
template <class T>
T ceil(T a, T b) {
    return (a + b - 1) / b;
}
template <class T>
T round(T a, T b) {
    return (a + b / 2) / b;
}
template <class T>
T gcd(T a, T b) {
    return b ? gcd(b, a % b) : a;
}
template <class T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}
template <class T>
bool amax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
bool amin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

// main
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S;
    cin >> S;
    int m = atoi(S.substr(5, 2).c_str());
    if (m <= 4) {
        cout << "Heisei" << endl;
    } else {
        cout << "TBD" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
    using namespace std;
    int main(){
    	int a,b,c;
    	cin>>a>>b>>c;
    	if(a+b==c||a+c==b||b+c==a){
			cout<<"Yes"<<endl;
		}else cout<<"No"<<endl;
		    return 0;
    }


Measured memory_bytes: 256
// Standard I/O
#include <iostream>
#include <sstream>
#include <cstdio>
// Standard Library
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
// Template Class
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
// Container Control
#include <algorithm>

using namespace std;

#define rep( i, n ) for( int i = 0; i < n; ++i )
#define irep( i, n ) for( int i = n-1; i >= 0; --i )
#define reep( i, s, n ) for ( int i = s; i < n; ++i )
#define ireep( i, n, s ) for ( int i = n-1; i >= s; --i )
#define foreach(itr, x) for( typeof(x.begin()) itr = x.begin(); itr != x.end(); ++itr)

#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define all( v ) v.begin(), v.end()
#define fs first
#define sc second
#define vc vector

// for visualizer.html
double SCALE = 1.0;
double OFFSET_X = 0.0;
double OFFSET_Y = 0.0;
#define LINE(x,y,a,b) cerr << "line(" << SCALE*(x) + OFFSET_X << ","	\
	<< SCALE*(y) + OFFSET_Y << ","										\
	<< SCALE*(a) + OFFSET_X << ","										\
	<< SCALE*(b) + OFFSET_Y << ")" << endl;
#define CIRCLE(x,y,r) cerr << "circle(" << SCALE*(x) + OFFSET_X << ","	\
	<< SCALE*(y) + OFFSET_Y << ","										\
	<< SCALE*(r) << ")" << endl;

typedef long long ll;
typedef complex<double> Point;

typedef pair<int, int> pii;
typedef pair<int, pii> ipii;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector< vector<int> > vii;
typedef vector< vector<double> > vdd;

typedef vector<int>::iterator vi_itr;

const int IINF = 1 << 28;
const int MOD = 1e9+7;
const double INF = 1e30;
const double EPS = 1e-10;
const double PI = acos(-1.0);

// Direction : L U R D
const int dx[] = { -1, 0, 1, 0};
const int dy[] = { 0, -1, 0, 1 };

int h, w;
char field[50][50];

int main()
{
    cin >> h >> w;
    rep(i, h) rep(j, w) cin >> field[i][j];

    bool ans = true;
    [&]() {
        rep(i, h) rep(j, w) {
            if ( field[i][j] == '.' ) continue;
        
            bool flag = false;
        
            rep(k, 4) {
                int nx = j + dx[k];
                int ny = i + dy[k];

                if ( nx < 0 || nx >= w || ny < 0 || ny >= h ) continue;

                if ( field[ny][nx] == '#' ) flag = true;
            }

            if( flag == false ) {
                ans = false;
                return;
            }
        }
    }();

    cout << (ans ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<queue>
#include<vector>
#include<string.h>
#include<string>


using namespace std;

char T[26],S[10001];
int N,i,j,k,len;

string U;



int main()
{
  
  cin >>N>> S;
  
  T[0]='A';
  T[1]='B';  
  T[2]='C';  
  T[3]='D';  
  T[4]='E';  
  T[5]='F';  
  T[6]='G';  
  T[7]='H';  
  T[8]='I';  
  T[9]='J';  
  T[10]='K';  
  T[11]='L';  
  T[12]='M';  
  T[13]='N';  
  T[14]='O';  
  T[15]='P';  
  T[16]='Q';  
  T[17]='R';  
  T[18]='S';  
  T[19]='T';  
  T[20]='U';  
  T[21]='V';  
  T[22]='W';  
  T[23]='X';  
  T[24]='Y';  
  T[25]='Z';  
  
  i=0;
  k=1;
  while(k==1)
  {
    k=0;
    for(j=0;j<26;j++)
    {
      if(S[i]==T[j])
      {
        k=1;
        break;
      }
    }
    j=(j+N)%26;
    
    if(k==1)
    {
      cout <<T[j];
    }
    i++;
  }
  

  return 0; 
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<string.h>
#include<algorithm>
#include<queue>
#include<stack>
#include<math.h>
#include<map>
typedef long long int ll;
using namespace std;
#define maxn 0x3f3f3f3f
const int mm=1e6;
ll d[mm];
int main()
{
	ll n,m,i,j,a,b,c,k,kk;
	cin>>n>>m; 
	k=n%m;
	kk=abs(k-m);
	printf("%lld\n",min(k,kk));
}

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

using namespace std;

#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(a)  (a).begin(),(a).end()
using ll = long long;
using Pair = pair<int, int>;
const ll mod = 1e9 + 7;

template<typename T>
struct BIT {
  int n;
  vector<T> d;
  // 1-index
  BIT(int n=0): n(n), d(n+1) {}
  void add(int i, T x=1) {
    for (++i; i<=n; i+=i&(-i)) {
      d[i] += x;
    }
  }
  T sum(int i) {
    T x = 0;
    for (++i; i; i-=i&(-i)) {
      x += d[i];
    }
    return x;
  }
};

int main(int argc, char const* argv[])
{
  ll n, d, a;
  cin >> n >> d >> a;
  vector<pair<ll, ll>> p;
  vector<ll> xs;
  for (ll i = 0; i < n; i++) {
    ll x, h;
    cin >> x >> h;
    p.emplace_back(x, h);
    xs.push_back(x);
  }
  sort(ALL(p));
  sort(ALL(xs));

  BIT<ll> bit(n+1);
  ll ans = 0;
  REP(i, n) {
    ll x = p[i].first;
    ll h = p[i].second;

    h -= bit.sum(i);
    if (h > 0) {
      // 残った体力分新たな爆弾でダメージを与える
      ll count = (h+a-1)/a;
      ans += count;
      ll damage = a * count;
      bit.add(i, damage);
      ll limit = upper_bound(xs.begin(), xs.end(), x+2*d) - xs.begin();
      bit.add(limit, -damage);
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 8176
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
using P = pair<int, int>;
const int INF = 1e9;
const long long LINF = 1e18;
const long long MOD = 1e9 + 7;

signed main(){
    int n;
    cin >> n;
    string s;
    cin >> s;
    string t = s;
    reverse(ALL(t));
    map<pair<string, string>, int> mp;
    for(int bit = 0; bit < 1 << n; bit++){
        string r,b;
        for(int i = 0; i < n; i++){
            if(bit & 1 << i){
                r.push_back(s[i]);
            }else{
                b.push_back(s[i]);
            }
        }
        mp[pair<string, string>(r, b)]++;
    }
    ll ans = 0;
    for(int bit = 0; bit < 1 << n; bit++){
        string r,b;
        for(int i = 0; i < n; i++){
            if(bit & 1 << i){
                r.push_back(t[i]);
            }else{
                b.push_back(t[i]);
            }
        }
        ans += mp[pair<string, string>(r, b)];
    }
    cout << ans << endl;
    return 0;
}   

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

#define fast_cin() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define MAX 1000000
#define ll long long
#define db double
#define str string
#define pb push_back
#define For(i,s,e) for (ll i=(s); i<(e); i++)
#define Debug_array(a,n) for (ll i=(0); i<(n); i++) cout<<a[i]<<" "
#define Foreq(i,s,e) for (ll i=(s); i<=(e); i++)
#define Forrev(i,s,e) for (ll i=(s); i>=(e); i--)
#define all(v) v.begin(),v.end()
#define vll vector<ll>
#define vs vector<string>

#define mapll map<ll,ll>
#define mapss map<string,string>
#define mapsl map<string,ll>
#define mapls map<ll,string>

#define pll pair<ll,ll>
#define pss pair<string,string>
#define psl pair<ll,string>
#define pls pair<string,ll>

#define minheap priority_queue<ll>
#define maxheap priority_queue<ll,vector<ll> ,greater<ll>>

#define ff first
#define ss second
#define endl "\n"
#define mp make_pair
#define big_prime 15486277
#define bigger_prime 179424697
#define biggest_prime 32416188691
const ll mod=1e9 + 7;


ll takemod(ll a) {
    return ((a%mod)+mod)%mod;
}

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

ll fast_exp(ll base, ll expo) {
    ll res=1;
    while(expo>0) {
        if(expo&1) res=(res*base)%mod;
        base=(base*base)%mod;
        expo>>=1;}
    return res;
}

ll modinv(ll a) {
    return takemod(fast_exp(takemod(a), mod-2));
}

ll dp[100005];
ll n,k;
ll dpfunc(ll val)
{
    //cout<<val<<endl;
    if(val>=k)
        return 0;
    else
    {
        //cout<<dp[val]<<endl;
        if(dp[val]==0)
        {
            //cout<<1<<endl;
            dp[val]=1+dpfunc(val*2);
        }
        return dp[val];
    }
}
signed main() 
{
    fast_cin();
    memset(dp,0,sizeof(dp));
    cin>>n>>k;
    double ans=0;
    For(i,1,min(n+1,k))
    {
        db val=pow(2,dpfunc(i))*n;
        ans+=(1/val);
        //cout<<ans<<endl;
    }
    if(n>=k)
    {
        ans+=(n-k+1)/double(n);
    }
    cout<< fixed <<setprecision(9)<<ans<<endl;
    //cout<<dp[1]<<endl;
    
    return 0;    
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define MOD (1000000007)
#define INF (1e9)
#define INFL (1e18)
 
typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
template<class T>using arr=vector<vector<T>>;
template<class T>void pr(T x){cout << x << endl;}
template<class T>void prvec(vector<T>& a){rep(i, a.size()-1){cout << a[i] << " ";} cout << a[a.size()-1] << endl;}
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; }
 
int main()
{
    int a, b;
    while(cin >> a >> b){
        int c = a + b;
        int ans = 0;
        while(c>0){
            ans++;
            c /= 10;
        }
        pr(ans);
    }
    return 0;}


Measured memory_bytes: 2992
// Package main provides
//
// File:  b.go
// Author: ymiyamoto
//
// Created on Mon Dec 10 23:55:28 2018
//
package main

import (
	"fmt"
	"sort"
)

func main() {
	var N int

	fmt.Scan(&N)

	arr := make([]int, N)
	for i := range arr {
		fmt.Scan(&arr[i])
	}

	sort.Ints(arr)
	fmt.Println(arr[len(arr)-1] - arr[0])
}


Measured memory_bytes: 512
/** Which of the favors of your Lord will you deny ? **/

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

#define LL long long
#define PII pair<int,int>
#define PLL pair<LL,LL>
#define MP make_pair
#define F first
#define S second

#define ALL(x) (x).begin(), (x).end()
#define DBG(x) cerr << __LINE__ << " says: " << #x << " = " << (x) << endl
#define READ        freopen("alu.txt", "r", stdin)
#define WRITE       freopen("vorta.txt", "w", stdout)

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

template<class TIn>using indexed_set = tree<TIn, null_type, less<TIn>,rb_tree_tag, tree_order_statistics_node_update>;

/**

PBDS
-------------------------------------------------
1) insert(value)
2) erase(value)
3) order_of_key(value) // 0 based indexing
4) *find_by_order(position) // 0 based indexing

**/

template<class T1, class T2>
ostream &operator <<(ostream &os, pair<T1,T2>&p);
template <class T>
ostream &operator <<(ostream &os, vector<T>&v);
template <class T>
ostream &operator <<(ostream &os, set<T>&v);

inline void optimizeIO()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

const int nmax = 2e5+7;
const LL LINF = 1e17;

template <class T>
string to_str(T x)
{
    stringstream ss;
    ss<<x;
    return ss.str();
}

//bool cmp(const PII &A,const PII &B)
//{
//
//}
vector<int>cnt(1e5+7,0);
int main()
{
    optimizeIO();

    int n;
    cin>>n;

    vector<LL>v(n);

    LL s = 0;
    for(int i=0;i<n;i++)
        cin>>v[i] , cnt[v[i]]++ , s+=v[i];

    int q;
    cin>>q;

    while(q--)
    {
        LL b,c;
        cin>>b>>c;

        LL v1 = b*cnt[b];
        s -= v1;
        LL v2 = c*cnt[b];
        s += v2;

        cnt[c] += cnt[b];
//        DBG(cnt[b]);
        cnt[b] = 0;
        cout<<s<<endl;
    }

    return 0;
}

/**

**/

template<class T1, class T2>
ostream &operator <<(ostream &os, pair<T1,T2>&p)
{
    os<<"{"<<p.first<<", "<<p.second<<"} ";
    return os;
}
template <class T>
ostream &operator <<(ostream &os, vector<T>&v)
{
    os<<"[ ";
    for(int i=0; i<v.size(); i++)
    {
        os<<v[i]<<" " ;
    }
    os<<" ]";
    return os;
}

template <class T>
ostream &operator <<(ostream &os, set<T>&v)
{
    os<<"[ ";
    for(T i:v)
    {
        os<<i<<" ";
    }
    os<<" ]";
    return os;
}




Measured memory_bytes: 4512
n = gets.to_i
hp = gets.split.map(&:to_i)
hp.sort!
ans = hp[0]
for i in 1..n-1
  k = ans
  l = hp[i]
  while k % l != 0 && l % k != 0
    if k > l
      k = k % l
    else
      l = l % k
    end
  end
  ans = [k,l].min
end
puts ans


Measured memory_bytes: 11128
#include <stdio.h>

int main(void){
	while(1){
		int n, k, i, j, flag=0;
		long s[100];
		int b[100][100];
	
		scanf("%d %d", &n, &k);
		if(n==0 && k==0) break;
		
		for(i=0; i<k; i++)
			scanf(" %ld", &s[i]);
		
		for(i=0; i<n; i++){
			for(j=0; j<k; j++){
				scanf(" %d", &b[i][j]);
				s[j] -= b[i][j];
			}
		}
			
		for(i=0; i<k; i++){
			if(s[i] < 0) flag=1;
		}
		
		if(flag==1) printf("No\n");
		else printf("Yes\n");
	
	}

	return 0;
}

Measured memory_bytes: 624
N = int(input())
A = [tuple(map(int, input().split())) for _ in range(N)]
ans = []
for i in range(len(A)-1):
    for k in range(i+1,len(A)):
        ans.append((((A[i][0]-A[k][0])**2)+(A[i][1]-A[k][1])**2)**0.5)
print(sum(ans)*2/N)

Measured memory_bytes: 9444
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
    while (true) {
        int n;
        cin >> n;
        if (n == 0)break;

        long long len = 0;
        for (int i = 0; i < n; i++) {
            int p;
            cin >> p;
            len += p;
        }
        vector<int> joint(n - 1);
        for (int i = 0; i < n - 1; i++) {
            cin >> joint[i];
            len += joint[i];
        }

        sort(joint.begin(), joint.end());
        long long ret = 0;
        for (int i = 0; i < n - 1; i++) {
            ret = max(ret, len * (i + 1));
            len -= joint[i];
        }

        cout << max(ret, len * n) << endl;
    }
    return 0;
}


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

int main() {
	
	int n, i;
	cin >> n >> i;
	cout << n - i + 1 << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cctype>
#include <algorithm>
#include <vector>
#include <cstring>
#include <cassert>
using namespace std;
using ll = long long;

namespace io {
#define File(s) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)
  const int SIZE = (1 << 21) + 1;
  char ibuf[SIZE], *iS, *iT, obuf[SIZE], *oS = obuf, *oT = oS + SIZE - 1;
  inline char getc () {return (iS == iT ? (iT = (iS = ibuf) + fread (ibuf, 1, SIZE, stdin), (iS == iT ? EOF : *iS ++)) : *iS ++);}
  inline void flush () {fwrite (obuf, 1, oS - obuf, stdout); oS = obuf;}
  inline void putc (char x) {*oS ++ = x; if (oS == oT) flush ();}
  template<class T>
  inline void read(T &x) {
    char ch; int f = 1;
    x = 0;
    while(isspace(ch = getc()));
    if(ch == '-') ch = getc(), f = -1;
    do x = x * 10 + ch - '0'; while(isdigit(ch = getc()));
    x *= f;
  }
  template<class T, class ...Args>
  inline void read(T &x, Args&... args) {read(x); read(args...);}
  template<class T>
  inline void write(T x) {
    static char stk[128];
    int top = 0;
    if(x == 0) {putc('0'); return;}
    if(x < 0) putc('-'), x = -x;
    while(x) stk[top++] = x % 10, x /= 10;
    while(top) putc(stk[--top] + '0');
  }
  template<class T, class ...Args>
  inline void write(T x, Args... args) {write(x); putc(' '); write(args...);}
  inline void space() {putc(' ');}
  inline void endl() {putc('\n');}
  struct _flush {~_flush() {flush();}} __flush;
};
using io::read; using io::write; using io::flush; using io::space; using io::endl; using io::getc; using io::putc;

const int N = 200005;

struct segtree {
  int mn[N * 4];
  segtree() {
    memset(mn, 0x3f, sizeof mn);
  }
  void mdy(int x, int l, int r, int ql, int qr, int v) {
    if (ql <= l && r <= qr) {
      mn[x] = min(mn[x], v);
      return;
    }
    int mid = (l + r) >> 1;
    if (ql <= mid) mdy(x << 1, l, mid, ql, qr, v);
    if (qr > mid) mdy(x << 1 | 1, mid + 1, r, ql, qr, v);
  }
  int query(int x, int l, int r, int p) {
    if (l == r) return mn[x];
    int mid = (l + r) >> 1;
    return min(p <= mid ? query(x << 1, l, mid, p) : query(x << 1 | 1, mid + 1, r, p), mn[x]);
  }
}t[2];

int main() {
  int n, q;
  ll s;
  read(n, q);
  s = 1LL * (n - 2) * (n - 2);
  for (int i = 1; i <= q; ++i) {
    int op, x;
    read(op, x);
    --op; --x;
    int p = t[op].query(1, 1, n - 2, x);
    p = min(p, n - 2);
    if (p == 0) continue;
    s -= p;
    t[op ^ 1].mdy(1, 1, n - 2, 1, p, x - 1);
  }
  printf("%lld\n", s);
  return 0;
}

Measured memory_bytes: 11088
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(int i = 0; i < x; i++)
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
const ll MOD = 1e9+7;
const int n_max = 1e5+10;

int main(){
    string s;cin >> s;
    int n = s.size();
    string judge[2];
    judge[0].push_back('0');judge[1].push_back('1');
    rep(i,n){
        if(!i)continue;
        rep(j,2){
            if(judge[j][i-1] == '0')judge[j].push_back('1');
            else judge[j].push_back('0');
        }
    }
    int ans = n+10;
    rep(i,2){
        int temp = 0;
        rep(j,n){
            if(s[j] != judge[i][j])temp++;
        }
        ans = min(ans, temp);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 768
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <utility>
using namespace std;

typedef long long ll;
ll MOD = 1e9+7;

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

int main()
{
	ll n,m;
	vector<pair<ll,ll>> sosu;//mの素因数分解の結果
	ll ans=1;
	cin>>n>>m;
	ll g=gcd(n,m);
	if(n/g==1)
		ans=m/g;
	else{
		ans=m/n;
		while(m%ans!=0)
			ans--;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <chrono>
#include <cmath>
#include <string.h>
#include <iomanip>
#include <algorithm>
#include <unordered_set>
#include <vector>
#include <queue>
#include <math.h>
#include <unordered_map>
#include <fstream>
#include <functional>
#include <map>
#include <deque>
#include <string.h>

#define MAX(a, b) (a > b ? a : b)
#define MIN(a, b) (a < b ? a : b)
#define ABS(a) (a < 0 ? -a : a)
#define YesNo(flag) (flag ? "Yes\n" : "No\n")
#define YESNO(flag) (flag ? "YES\n" : "NO\n")

constexpr auto NMAX = (int)1e2 + 20;
constexpr auto INF_ULL = 18446744073709551615;
constexpr auto INF_INT = 2147483647;
constexpr auto PI = 3.14159265359;
using namespace std;

typedef unsigned long long ull;

bool isPrime(ull n){
	if (n < 2) {
		return false;
	}
	if (n == 2) {
		return true;
	}
	if (n % 2 == 0) {
		return false;
	}
	for (ull i = 3; i * i <= n; i++) {
		if (n % i == 0) {
			return false;
		}
	}
	return true;
}

ull n;
int k;
int sum;

int findN(int k) {
	int n = 0;
	while (n * (n + 1) / 2 < k) {
		n++;
	}
	if (n * (n + 1) / 2 > k) {
		return n - 1;
	}
	return n;
}

int main()
{
	cin >> n;

	if (isPrime(n)) {
		cout << 1 << '\n';
		exit(0);
	}

	while (n % 2 == 0) {
		n >>= 1;
		k++;
	}
	sum += findN(k);
	k = 0;
	for (ull i = 3; i * i <= n; i += 2) {
		while (n % i == 0) {
			k++;
			n /= i;
		}
		sum += findN(k);
		k = 0;
	}
	if (n != 1) {
		sum++;
	}
	cout << sum << '\n';
	return 0;
}

Measured memory_bytes: 3604
#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
#define MOD 1000000007LL
ll now,n,k;
ll ans;

vector<vector<pair<int, int>>> g;
const int N = 1e5;
int used[N];
//ll col[N];

ll dfs(int i,int deep) {
    if (used[i]!=0){
        return 0LL;
    }
    used[i] = deep;
    //col[i] = c;
    ll j=0;
    for(auto to : g[i]) {
        j+=dfs(to.first,deep+1);
        //cout<<j<<" "<<deep<<endl;
    }
    REP(ii,j){
        ans=ans*(k-2+(deep==1)-ii)%MOD;
    }
    
    return 1LL;
}


int main() {
    cin >>n>>k;
    
    if (n==1LL){
        cout<<k<<endl;
        return 0;
    }

    g.resize(n*2+1);
    
    for(int i = 0; i < n-1; i++) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        g[a].emplace_back(b, 0);
        g[b].emplace_back(a, 0);
    }
    ans=k;
    ll bans=dfs(0,1);

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

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

#define int long long

int a, b;

int32_t main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> a >> b;
	if (a >= 13)
		cout << b;
	else if (a > 5)
		cout << b / 2;
	else
		cout << 0;
}

Measured memory_bytes: 256
//In The Name Of Allah
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define sz(x) (int)(x.size())
#define double long double 
#define fi first
#define se second
#define pii pair<int, int>


signed main() {
	ios::sync_with_stdio(false); cin.tie(nullptr);
  int n, m;
  cin >> n >> m;
  int cnt[n + 1];
  for (int i = 1; i <= n; i++) {
    cnt[i] = 1;
  }
  set<int> st = {1};
  for (int i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y;
    if (st.find(x) != st.end()) {
      st.insert(y);
    }
    if (cnt[x] == 1) {
      st.erase(x);
    }
    cnt[x]--, cnt[y]++;
  }
  cout << sz(st) << "\n";
}

Measured memory_bytes: 5760
#include <bits/stdc++.h>
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
using i64 = int64_t;
using f80 = __float80;
static const int dy[4] = {0,1,0,-1}, dx[4] = {1,0,-1,0};
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
#define _overload3(_1,_2,_3,name,...) name
#define repi(i,start,end) for(i64 i=(start);i<(end);++i)
#define _rep(i,n) repi(i,0,n)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,start,end) for(i64 i=(start);i>end;--i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define v(T) vector<T>
#define vv(T) v(v(T))
typedef v(i64) vi;
typedef v(vi) vvi;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream &operator<<(ostream &os, const vector< T > &v){
  rep(i,v.size()) os << v[i] << (i + 1 != v.size() ? " " : "");
  return os;
}
template<typename T> istream &operator>>(istream &is, vector< T > &v){
  for(T &in : v) is >> in;
  return is;
}

bool countone(i64 X, i64 r){
  if(r==0){
    X %= 4;
    if(X==0 or X==3) return 0;
    else return 1;
  }
  if(r>0){
    X %= (1LL << (r+1));
    if(X<(1LL << r)) return 0;
    X -= (1LL << r) - 1;
    return X % 2;
  }
}

void Main()
{
  i64 A, B;
  cin >> A >> B;

  i64 ans = 0;

  if(A == 0){
    for(i64 i=0; (1LL<<i)<=B;i++){
      ans += (1LL << i) * (countone(B,i));
    }
    cout << ans << "\n";
    return;
  }

  for(i64 i=0;(1LL<<i)<=B;i++){
    ans += (1LL << i) * (countone(A-1,i)^countone(B,i));
  }
  cout << ans << "\n";
}

int main()
{
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Main();
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
int main(int argc, char const *argv[]) {
    int n, a, b;
    cin >> n >> a >> b;
    int MIN = min(a, b);
    int MAX;
    if (n > a+b) MAX = 0;
    else MAX = (a+b)-n;
    cout << MIN << " " << MAX << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
using namespace std;

template<class T>
void in(vector<T>& V) {
	for (auto itr = V.begin(); itr != V.end(); itr++)cin >> *itr;
	return;
}

template<class T>
void out(vector<T>& V) {
	for (T& itr : V)cout << itr << endl;
	return;
}

int N;
vector<int> mark;   //-1:未 0:vacant 1:male 2:female

int main() {
	string input;
	cin >> N;
	mark.resize(N,-1);
	cout << 0 << endl;
	cout << flush;
	cin >> input;
	if (input == string("Vacant"))return 0;
	else if (input == string("Male"))mark[0] = 1;
	else mark[0] = 2;
	int s = 0, e = N - 1;
	while (e - s > 1) {
		int m = (s + e) / 2;
		cout << m << endl;
		cout << flush;
		cin >> input;
		if (input == string("Vacant"))return 0;
		else if (input == string("Male"))mark[m] = 1;
		else mark[m] = 2;
		if (s % 2 == m % 2) {
			if (mark[s] == mark[m]) s = m;
			else e = m;
		}
		else {
			if (mark[s] == 3 - mark[m])s = m;
			else e = m;
		}
	}
	cout << s << endl;
	cout << flush;
	cin >> input;
	if (input == string("Vacant"))return 0;
	cout << e << endl;
	cout << flush;
	cin >> input;
	if (input == string("Vacant"))return 0;
	return 0;
}

Measured memory_bytes: 1236
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main (){
    int N, M, K;
    cin >> N >> M >> K;
    for (int i = 0; i <= N; i++)
    {
        for (int j = 0; j <= M; j++)
        {
            int sum = N * j + M * i - 2 * i * j;
            if (sum == K)
            {
                cout << "Yes" << endl;
                return 0;
            }
        }
        
    }
    cout << "No" << endl;
 
    return 0;
    
}


Measured memory_bytes: 256
from sys import stdin

n = int(stdin.readline().rstrip())
nNum = [int(stdin.readline().rstrip()) for i in range(n)]

def isPrime(n):
    if n == 2:
        return True
    elif n < 2 or n%2 == 0:
        return False

    for i in range(3, n, 2):
        if i*i > n:
            break
        elif n%i == 0:
            return False

    return True

print(len([True for x in nNum if isPrime(x)]))


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

using namespace std;

int main() {
	int n, m;
	cin >> n >> m;
	vector <int> h(n);
	for (int i = 0; i < n; i++) {
		cin >> h[i];
	}
	vector <bool> ok(n, true);
	for (int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		a--;
		b--;
		if (h[a] <= h[b]) ok[a] = false;
		if (h[a] >= h[b]) ok[b] = false;
	}
	int cnt = 0;
	for (int i = 0; i < n; i++) {
		cnt += ok[i];
	}
	cout << cnt;
	return 0;
}



Measured memory_bytes: 3788
#include <bits/stdc++.h>
 
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for (ll i = (ll)(n) - 1; i >= 0; i--)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1e18)

#define PI (acos(-1))
#define print(x) cout << x << endl
 
ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
typedef pair <ll,ll> P;

bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.first != b.first){
        return a.first < b.first;
    }else{
        return a.second > b.second;
    }
}

template <typename T> 
ostream& operator<<(ostream& os, const vector<T>& v) 
{ 
    for (int i = 0; i < (int)v.size(); ++i) { 
        os << v[i]; 
        if (i != (int)v.size() - 1) 
            os << " "; 
    } 
    return os; 
} 

int main()
{
    ll N, M, R;
    cin >> N >> M >> R;
    vector<ll> r(R);
    rep(i, R) {
        cin >> r[i];
        r[i]-=1;
    }
    vector<vector<ll>> G(N, vector<ll>(N, INF));
    rep(i, N) {
        G[i][i] = 0;
    }
    rep(i, M) {
        ll A, B, C;
        cin >> A >> B >> C;
        A--; B--;
        G[A][B] = min(G[A][B], C);
        G[B][A] = min(G[A][B], C);
    }
    rep(i, N) {
        rep(j, N) {
            rep(k, N) {
                G[j][k] = min(G[j][k], G[j][i] + G[i][k]);
            }
        }
    }
    sort(all(r));
    ll mi = INF;
    do {
        ll sum = 0;
        rep(i, R-1) {
            sum += G[r[i]][r[i+1]];
        }
        mi = min(mi, sum);
    } while (std::next_permutation(r.begin(), r.end()));
    print(mi);
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <climits>
#include <cstring>
#include <string>
#include <set>
#include <bitset>
#include <map>
#include <queue>
#include <stack>
#include <vector>
#define rep(i,m,n) for(i=m;i<=n;i++)
#define mod 1000000007
#define inf 0x3f3f3f3f
#define vi vector<int>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define ll long long
#define pi acos(-1.0)
#define pii pair<int,int>
#define sys system("pause")
const int maxn=2e5+10;
const int N=1e3+10;
using namespace std;
ll gcd(ll p,ll q){return q==0?p:gcd(q,p%q);}
ll qpow(ll p,ll q){ll f=1;while(q){if(q&1)f=f*p%mod;p=p*p%mod;q>>=1;}return f;}
int n,m,k,t,h,w,a,b;
ll fac[maxn],inv[maxn];
void init()
{
    fac[0]=1;
    for(int i=1;i<=maxn-10;i++)fac[i]=fac[i-1]*i%mod;
    inv[maxn-10]=qpow(fac[maxn-10],mod-2);
    for(int i=maxn-11;i>=0;i--)inv[i]=inv[i+1]*(i+1)%mod;
}
ll C(int x,int y)
{
    return fac[x]*inv[y]%mod*inv[x-y]%mod;
}
int main()
{
    int i,j;
    init();
    scanf("%d%d%d%d",&h,&w,&a,&b);
    ll ret=C(h+w-2,h-1);
    for(i=0;i<=b-1;i++)ret=(ret-C(i+h-a-1,h-a-1)*C(w-i+a-2,a-1)%mod+mod)%mod;
    printf("%lld\n",ret);
    return 0;
}


Measured memory_bytes: 3456
def main():
    N = int(input())
    A = list(map(int, input().split(' ')))
    ans = list()
    # to same signs
    max_A, min_A = max(A), min(A)
    all_positive = (min(A) > 0)
    if max_A >= 0 >= min_A:
        if max_A > abs(min_A):
            max_index = A.index(max_A)
            for i in range(N):
                if i == max_index:
                    continue
                ans.append('{} {}'.format(max_index + 1, i + 1))
            all_positive = True
        else:
            min_index = A.index(min_A)
            for i in range(N):
                if i == min_index:
                    continue
                ans.append('{} {}'.format(min_index + 1, i + 1))
            all_positive = False
    # cumulative sum
    if all_positive:
        for i in range(N - 1):
            ans.append('{} {}'.format(i + 1, i + 2))
    else:
        for i in range(N - 1):
            ans.append('{} {}'.format(N - i, N - i - 1))
    print(len(ans))
    for a in ans:
        print(a)


if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
//MEMOIZATION

/******************************************
* AUTHOR : DHRUV GUPTA *
* NICK : COSMOGOD *
* INSTITUTION : LNMIIT *
******************************************/


#include<bits/stdc++.h>
using namespace std;
double dp[301][301][301];

double solve(int one, int two, int three, int& n)
{
    if(one < 0 || two < 0 || three < 0)
        return 0;
    if(three == 0 && two == 0 && one == 0)
        return 0;
 
    if(dp[one][two][three] > 0)
        return dp[one][two][three];
 
    int remaining = one + two + three;
    double exp_val = n+one*solve(one-1,two,three,n) + two*solve(one+1,two-1,three,n) +
                    three*solve(one,two+1,three-1,n);
 
    return dp[one][two][three] = exp_val/remaining;
}

int main(){
	int n,x,c1=0,c2=0,c3=0;
	cin >> n;
	for(int i=0;i<n;i++){
		cin >> x;
		if(x==1)
			c1++;
		else if(x==2)
			c2++;
		else
			c3++;
	}
	memset(dp,-1,sizeof(dp));	
	//dp[0][0][0] = 0;
	cout << fixed << setprecision(9) << solve(c1,c2,c3,n);
	return 0;
}

Measured memory_bytes: 213376