akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<ll,ll> ii;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define RST(i,n) memset(i,n,sizeof i)
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(),a.end()
#define X first
#define Y second
#define mkp make_pair
#define pb push_back
#define eb emplace_back
#define pob pop_back
#ifdef cold66
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<", ";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // cold66
//}
template<class T> inline bool chkmax(T &a, const T &b) { return b > a ? a = b, true : false; }
template<class T> inline bool chkmin(T &a, const T &b) { return b < a ? a = b, true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;

const ll MAXn=1e5+5,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=0x3f3f3f3f;

ll fpow(ll x,ll a){
    ll ret = 1;
    ll base = x;
    while (a) {
        if (a&1) ret *= base;
        base *= base;
        a >>= 1;
    }
    return ret;
}
vector<ii> tmp;
int main(){
    IOS();
    ll n,p;
    cin >> n >> p;
    ll x = (ll)sqrt(p);
    for (ll i=2;i<=x;i++) {
        ll cnt = 0;
        while (p%i == 0) {
            cnt++;
            p /= i;
        }
        if (cnt) tmp.eb(i,cnt);
    }
    if (p != 1) tmp.eb(p,1);
    ll ans = 1;
    REP (i,SZ(tmp)) ans *= fpow(tmp[i].X,tmp[i].Y/n);
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define GET_MACRO(_1, _2, _3, NAME, ...) NAME
#define _repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define _rep(i,n) _repl(i,0,n)
#define rep(...) GET_MACRO(__VA_ARGS__, _repl, _rep)(__VA_ARGS__)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cout<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cout<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream &o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream &o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

#define INF 1120000000

int main(){
  int x,t;
  cin>>x>>t;

  cout << max(0,x-t) << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define vi vector<int>
#define ff first
#define ss second
#define file_se_input  freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define pp long long int
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define pb push_back
#define mp make_pair
#define pi 3.141592653589793238
#define eb emplace_back
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define zip(i,a,b) for(int i=a;i<b;i++)
#define rzip(i,a,b) for(int i=a;i>=b;i--)
#define ll unsigned long long int
#define test int t;cin>>t; while(t--)
#define um unordered_map
#define en '\n'
#define us unordered_set
typedef pair<int, int>     pii;
typedef pair<char, int>    pci;
typedef pair<char, char>   pcc;
typedef vector<pii>       vii;
typedef long double ld;
#define all(v) v.begin(), v.end()
#define INF (1e18+5)
#define inf (1e9+5)
#define mod 1000000007


bool check_prime(long long n)
{
	int flag = 0;
	for (long long i = 2; i * i <= n; i++)
	{
		if (n % i == 0)
		{
			flag = 1;
			break;
		}
	}
	if (n == 1)
		return false;
	else if (flag == 0 || n == 2 || n == 3)
	{
		return true;
	}
	else
	{
		return false;
	}

}

int BE(int x, int n, int m) //function to calculate x raise to power n modulo m
{
	int result = 1;
	while (n > 0)
	{
		if (n % 2 == 1)
			result = result * x % m;
		x = x * x % m;
		n = n / 2;
	}
	return result;
}

int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(0);
#ifndef ONLINE_JUDGE
	if (fopen("input.txt", "r"))
	{
		freopen ("input.txt" , "r" , stdin);
		freopen ("output.txt" , "w" , stdout);
	}
#endif
	//_______________________________-code starts-_______________________________________________

	int n, m;
	cin >> n >> m;
	if (n <= 2 || m <= 2)
	{
		if (n > m)
			swap(n, m);
		if (n == 1)
		{
			cout << abs(m - 2) << en;
		}
		else if (n == 2)
		{
			cout << 0 << en;
		}
	}
	else
		cout << (abs(n - 2) * (m - 2)) << en;


	return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public int n = 3;

	void run() {
		Scanner sc = new Scanner(System.in);

		int[] in = new int[n];

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

		int cnt5 = 0;
		int cnt7 = 0;

		for (int i = 0; i < n; i++) {
			if (in[i] == 5) {
				cnt5++;
			} else if (in[i] == 7) {
				cnt7++;
			}
		}

		if (cnt5 == 2 && cnt7 == 1) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}

	}

	public static void main(String[] args) {
		new Main().run();
	}

}


Measured memory_bytes: 9428
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
const int MOD = (int)1e9 + 7;

int main() {
    int n, m; cin >> n >> m;
    vector<int> is_ok(n + 1, true);
    while (m--) {
        int a; cin >> a;
        is_ok[a] = false;
    }
    vector<int> dp(n + 1);
    dp[0] = 1;
    if (is_ok[1]) dp[1] = 1;
    for (int i = 2; i <= n; i++) {
        if (is_ok[i - 1]) (dp[i] += dp[i - 1]) %= MOD;
        if (is_ok[i - 2]) (dp[i] += dp[i - 2]) %= MOD;
    }
    cout << dp[n] << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define MOD 1000000007
#define M(x) ((x+MOD)%MOD)
#define MAX 2010

int n, d;
int x[11][11];

int test(int a, int b)
{
	int m = 0;
	for (int i = 1;i <= d;++i)
		m += (x[a][i] - x[b][i])*(x[a][i] - x[b][i]);
	int k = sqrt(m);
	if (k*k == m)return 1;
	else return 0;
}

int main()
{
	cin >> n >> d;
	for (int i = 1;i <= n;++i)
		for (int j = 1;j <= d;++j)
			cin >> x[i][j];
	int ans = 0;
	for (int i = 1;i <= n;++i)
		for (int j = i + 1;j <= n;++j)
			if (test(i, j))
				ans++;
	cout << ans << endl;
	//system("pause");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <iomanip>
#include <cmath>

using namespace std;

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

	vector<int> x(n, 0), y(n, 0);

	for (int i = 0; i < n; ++i)
		cin >> x[i];

	for (int i = 0; i < n; ++i)
		cin >> y[i];

	// ???????????????????????¢(p = 1)
	double md = 0.0;
	double p = 1.0;
	for (int i = 0; i < n; ++i)
		md += pow(abs(x[i] - y[i]), p);
	md = pow(md, 1 / p);

	// ???????????????????????¢(p = 2)
	double ed = 0.0;
	p = 2.0;
	for (int i = 0; i < n; ++i)
		ed += pow(abs(x[i] - y[i]), p);
	ed = pow(ed, 1 / p);

	// p = 3?????¨???
	double td = 0.0;
	p = 3.0;
	for (int i = 0; i < n; ++i)
		td += pow(abs(x[i] - y[i]), p);
	td = pow(td, 1 / p);

	// ?????§????????§????????¢(p = ???)
	double cd = 0.0;
	for (int i = 0; i < n; ++i)
		if (abs(x[i] - y[i]) > cd)
			cd = abs(x[i] - y[i]);

	cout << setprecision(16) << md << endl;
	cout << ed << endl;
	cout << td << endl;
	cout << cd << endl;

	return 0;
}

Measured memory_bytes: 1332
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <bitset>
#include <complex>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef long long int llint;
typedef pair<ll, ll> pl;
#define pi pair<int,int>
#define MM 1000000000
#define MOD MM+7
#define initial_value -1
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define INF (1 << 29) //536870912
const long double PI = acos(-1);
const ll DEP = 1e18;
int dx[8] = {-1,0,1,0,1,-1,1,-1};
int dy[8] = {0,-1,0,1,1,1,-1,-1};
struct edge{ll to,cost;};
ll N,a,b,c,Q,K,x,y;
vector<edge> tree[100010];
ll depth[100010];

void dfs(int v, int p, ll d){
    depth[v] = d;
    for(auto&& e: tree[v]){
        if(e.to == p) continue;
        dfs(e.to,v,d+e.cost);
    }
}

int main(){
    cin >> N;
    for(int i = 0; i < N-1; i++){
        cin >> a >> b >> c;
        a--; b--;
        tree[a].push_back({b,c});
        tree[b].push_back({a,c});
    }
    cin >> Q >> K;
    K--;
    dfs(K,-1,0);
    for(int i = 0; i < Q; i++){
        cin >> x >> y;
        x--; y--;
        cout << depth[x]+depth[y] << endl;
    }
    return 0;
}

Measured memory_bytes: 14336
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    for(;;){
        int n;
        cin >> n;
        if(n == 0)
            return 0;

        vector<int> color(n);
        for(int i=0; i<n; ++i)
            cin >> color[i];

        int ret = n;
        for(int i=0; i<2*n; ++i){
            int tmp = color[i/2];
            int j = i/2;
            int k = i/2;
            if(i % 2 == 0){
                if(i/2+1 >= n)
                    continue;
                color[i/2] = color[i/2+1];
                ++ k;
            }else{
                if(i/2-1 < 0)
                    continue;
                color[i/2] = color[i/2-1];
                -- j;
            }
            while(j >= 0 && k < n){
                if(color[j] != color[k])
                    break;
                int j1 = j;
                while(j1 >= 0 && color[j1] == color[j])
                    -- j1;
                int k1 = k;
                while(k1 < n && color[k1] == color[k])
                    ++ k1;
                int num = j - j1 + k1 - k;
                if(num < 4)
                    break;
                j = j1;
                k = k1;
                ret = min(ret, j+1 + n-k);
            }
            color[i/2] = tmp;
        }

        cout << ret << endl;
    }
}

Measured memory_bytes: 0
N = gets.chomp.to_i
C = Array.new(N-1)
S = Array.new(N-1)
F = Array.new(N-1)

(N-1).times do |n|
	C[n],S[n],F[n] = gets.chomp.split.map(&:to_i)
end

(N-1).times do |n|
	sum = 0
	n.upto(N-2) do |m|
		if sum < S[m]
			sum = S[m]
		elsif sum % F[m] != 0
			sum += F[m] - (sum % F[m])
		end
		sum += C[m]
	end
	p sum
end
p 0

Measured memory_bytes: 3964
import sys
readline = sys.stdin.readline

INF = 10**9+7
def calc(n, k):
    if k == 1:
        return n
    if n > 20:
        return INF
    return min(INF, (pow(k, n)-1)//(k-1))
    

K, N = map(int, readline().split())

if K%2 == 0:
    ans = [K//2] + [K]*(N-1)
    print(*ans)
else:    
    ans = []
    cnt = 0
    half = True
    for l in range(N, 0, -1):
        clk = calc(l, K)
        if half:
            c = 1+K//2
            if l%2 == 0:
                cnt += 1
            if clk//2 == cnt:
                ans.append(c)
                break
            if clk//2 < cnt:
                c -= 1
                half = False
                cnt -= clk//2 + 1
                
                while cnt >= clk:
                    cnt -= clk
                    c -= 1
                if cnt == clk-1:
                    ans.append(c)
                    break
        else:
            c = K
            while cnt >= clk:
                    cnt -= clk
                    c -= 1
            if cnt == clk-1:
                ans.append(c)
                break
        ans.append(c)
    print(*ans)
            

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

using namespace std;

const int mxn = 1e5;
unsigned long long a[mxn + 11];
const long long mm = 1e18;

int main(){
	long long a;
	double b;
	scanf("%lld %lf", &a, &b);
	int c = b * 100.0 + 0.5;
	long long ans = a * c;
	ans = ans / 100;
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 3776
#include<iostream>
#include<string>
using namespace std;
int main(){
	double x,t[]={128,64,32,16,8,4,2,1,0.5,0.25,0.125,0.0625};
	while(cin>>x,x>0){
		string s="";
		for(int i=0;i<12;i++){
			if(x-t[i]>=0){
				s+="1";
				x-=t[i];
			}
			else
			s+="0";
			if(i==7)
			s+=".";
		}
		if(x==0.0)
		cout<<s<<endl;
		else
		cout<<"NA"<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
# Dijkstra修正したので、確認のため使用した。

# ダイクストラ法：単一始点最短路。各距離は非負。
# 時間計算量はO(ElogV)
# s:始点, path[from]:[(to,cost)...] 隣接リスト
# 後述の改善前に比べ、heapqの中身をtupleにしたら速度が改善した
import heapq
def dijkstra(s,path):
    # 距離をinfで初期化
    d = [float('inf')]*len(path)
    d[s] = 0

    # sへの距離は0
    q = [(0,s)]
    heapq.heapify(q)

    # 距離が最小の頂点から更新していけば良い
    while q:
        c,p = heapq.heappop(q)

        # 頂点pまでの距離がheap内のpまでの距離より小さい場合、continue
        if d[p]<c:
            continue

        # 頂点pから伸びる、全ての辺の距離を確認
        for to,cost in path[p]:
            # 頂点pから行ける頂点の距離がpまでの距離とpからの距離の和より小さい場合 -> 距離を更新し、heapに追加
            if d[to] > d[p] + cost:
                d[to] = d[p] + cost
                heapq.heappush(q,(d[to], to))
    return d



n,m,s,t = map(int, input().split())
s-=1
t-=1

snuke_path = [[] for i in range(n)]
yen_path = [[] for i in range(n)]

for i in range(m):
    u,v,a,b = map(int, input().split())
    u-=1
    v-=1
    yen_path[u].append([v,a])
    yen_path[v].append([u,a])
    snuke_path[u].append([v,b])
    snuke_path[v].append([u,b])

yen_from_s = dijkstra(s,yen_path)
snuke_to_t = dijkstra(t,snuke_path)

total = [yen_from_s[i]+snuke_to_t[i] for i in range(n)]
ans = [0]*n
ans [-1] = total[-1]
for i in range(n-1):
    ans[-2-i] = min(ans[-1-i],total[-2-i])
ans = [10**15-ans[i] for i in range(n)]

print('\n'.join(map(str,ans)))



Measured memory_bytes: 145588
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;

int main() {
    ll n; cin >> n;
    ll h[n][3];
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < 3; j++) cin >> h[i][j];
    }
    
    ll dp[n + 1][3] = {};
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < 3; j++) {
            for (int k = 0; k < 3; k++) {
                if (j != k) dp[i + 1][j] = max(dp[i + 1][j], dp[i][k] + h[i][j]);
            }
        }
    }
    ll ans = max({dp[n][0], dp[n][1], dp[n][2]});
    cout << ans << endl;
}

Measured memory_bytes: 4992
#include<stdio.h>

#define X 20
#define Y 20
#define L 3
#define M 2
#define S 1

void large(int x, int y, int ppr[X][Y]);
void middle(int x, int y, int ppr[X][Y]);
void small(int x, int y, int ppr[X][Y]);

int main(void)
{
        int ppr[X][Y];/*紙*/
        int x = 0, y = 0;
        int i = 0, j = 0;
        int size = 0;
        int count = 0;
        int max = 0;
        for(i = 0; i < X; i++)
        {
                for(j = 0;j < Y; j++)
                {
                        ppr[i][j] = 0;
                }
        }

        while(scanf("%d,%d,%d", &x, &y, &size) != EOF)
        {
                if(size == L)
                {
                        large(x+4, y+4, ppr);
                }
                if(size == M)
                {
                        middle(x+4, y+4, ppr);
                }
                if(size == S)
                {
                        small(x+4, y+4, ppr);
                }
        }
        for(i = 4; i < X-6; i++)
        {
                for(j = 4;j < Y-6; j++)
                {
                        if( ppr[i][j] == 0 )
                        {
                                count++;
                        }
                        if(max < ppr[i][j])
                        {
                                max = ppr[i][j];
                        }
                }
        }
        printf("%d\n",count);
        printf("%d\n",max);
        return 0;
}

void large(int x, int y, int ppr[X][Y])
{
        ppr[x - 2][y]     += 1;
        ppr[x + 2][y]     += 1;
        ppr[x]    [y - 2] += 1;
        ppr[x]    [y + 2] += 1;
        ppr[x - 1][y - 1] += 1;
        ppr[x - 1][y]     += 1;
        ppr[x - 1][y + 1] += 1;
        ppr[x]    [y - 1] += 1;
        ppr[x]    [y]     += 1;
        ppr[x]    [y + 1] += 1;
        ppr[x + 1][y + 1] += 1;
        ppr[x + 1][y]     += 1;
        ppr[x + 1][y - 1] += 1;
}

void middle(int x, int y, int ppr[X][Y])
{
        ppr[x - 1][y-1]   += 1;
        ppr[x - 1][y]     += 1;
        ppr[x - 1][y+1]   += 1;
        ppr[x]    [y-1]   += 1;
        ppr[x]    [y]     += 1;
        ppr[x]    [y+1]   += 1;
        ppr[x + 1][y + 1] += 1;
        ppr[x + 1][y]     += 1;
        ppr[x + 1][y - 1] += 1;
}
void small(int x, int y, int ppr[X][Y])
{
        ppr[x + 1][y]     += 1;
        ppr[x]    [y]     += 1;
        ppr[x - 1][y]     += 1;
        ppr[x]    [y + 1] += 1;
        ppr[x]    [y - 1] += 1;
}

Measured memory_bytes: 600
#![allow(unused_imports)]
 
use proconio::{input, fastout};
use proconio::marker::*;
use std::collections::HashMap;

fn helper(
  vals: &Vec<usize>,
  mut index: usize
) -> Vec<(usize, usize)> {
  let mut map: HashMap<usize, usize> = HashMap::new();
  while index < vals.len() {
    let entry = map.entry(vals[index]).or_insert(0);
    *entry += 1;
    index += 2;
  }
  
  let mut result: Vec<(usize, usize)> = map.into_iter().collect();
  result.sort_by(|a, b| a.1.cmp(&b.1));
  result.reverse();
  result
}

#[fastout]
fn main() {
  input! {
    n: usize,
    vals: [usize;n],
  }
  let mut result = 0;
  let mut last = vals[0];
  let mut success = true;
  for i in 1..n {
    if last != vals[i] {
      success = false;
      break
    }
  }

  if success {
    println!("{}", n / 2);
    return
  }
  
  let mut firsts = helper(&vals, 0);
  let mut seconds = helper(&vals, 1);
  if firsts.len() == 1 {
    firsts.push((10_000_000, 0));
  }
  if seconds.len() == 1 {
    seconds.push((10_000_000, 0));
  }
  
  if firsts[0].0 == seconds[0].0 {
    let result = std::cmp::min(
      n - firsts[0].1 - seconds[1].1,
      n - firsts[1].1 - seconds[0].1,
    );
    println!("{}", result);
  } else {
    println!("{}", n - firsts[0].1 - seconds[0].1);
  }
}

Measured memory_bytes: 6256
N, X, Y = map(int, input().split())

ans = [0]*(N-1)
for i in range(1, N):
    for j in range(i+1, N+1):
        num = min(j-i, abs(i-X)+abs(j-Y)+1)
        ans[num-1] += 1

for i in ans:
    print(i)

Measured memory_bytes: 3444
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>

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

    if (a <= c && b >= c || a >= c && b <= c)
        std::cout << "Yes" << std::endl;
    else
        std::cout << "No" << std::endl;

    return 0;
}

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

int main(){

	int N; cin >> N;
	array<double, 200000> A = {0}; 
	double dummy;
	
	for(int i=0; i<N; ++i){
		cin >> A[i];
	}
	sort(A.begin(), A.begin()+N);
	for(int j=0; j<N-1; ++j){
		//cout << A[j+1] << ' ' << A[j] << endl;
		if (A[j+1] - A[j] == 0){
			cout << "NO" << endl;
			return 0;
		}
	}

	cout << "YES" << endl;

	return 0;
}


Measured memory_bytes: 1792
require 'prime'
require 'set'
require 'tsort'
include Math
ALP = ('a'..'z').to_a
INF = 0xffffffffffffffff
def max(a,b);              a > b ? a : b                              end
def min(a,b);              a < b ?  a : b                             end
def swap(a,b);             a, b = b, a                                end
def gif;                   gets.to_i                                  end
def gff;                   gets.to_f                                  end
def gsf;                   gets.chomp                                 end
def gi;                    gets.split.map(&:to_i)                     end
def gf;                    gets.split.map(&:to_f)                     end
def gs;                    gets.chomp.split.map(&:to_s)               end
def gc;                    gets.chomp.split('')                       end
def pr(num);               num.prime_division                         end
def pr?(num);              Prime.prime?(num)                          end
def digit(num);            num.to_s.length                            end
def array(s,ini=nil);      Array.new(s){ini}                          end
def darray(s1,s2,ini=nil); Array.new(s1){Array.new(s2){ini}}          end
def rep(num);              num.times{|i|yield(i)}                     end
def repl(st,en,n=1);       st.step(en,n){|i|yield(i)}                 end


a,b = gi
puts max(max(a+b,a-b),a*b)


Measured memory_bytes: 4348
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

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

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

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

type pair struct {
	x, y int
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer([]byte{}, 1000000)
	H, W, D := getInt(), getInt(), getInt()
	a := make([]pair, H*W)
	for i := 0; i < H; i++ {
		for j := 0; j < W; j++ {
			x := getInt() - 1
			a[x] = pair{i, j}
		}
	}

	N := H * W
	t := make([]int, N)
	for i := 0; i < D; i++ {
		for j := i + D; j < N; j += D {
			d := abs(a[j].x-a[j-D].x) + abs(a[j].y-a[j-D].y)
			t[j] = d + t[j-D]
		}
	}
	// out(t)

	Q := getInt()
	w := bufio.NewWriter(os.Stdout)
	defer w.Flush()
	for i := 0; i < Q; i++ {
		l, r := getInt()-1, getInt()-1
		fmt.Fprintln(w, t[r]-t[l])
	}
}


Measured memory_bytes: 5760
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int k;
    cin >> k;
    cout << a[k-1] << endl;
    return 0;
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author YahiaAshraf74
 */

#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <stack>
#include <complex>
#include <string>
#include <bitset>
#include <stdio.h>
#include <string.h>
#include <fstream>
#include <iomanip>
#include <assert.h>

using namespace std;
#define el  '\n'
#define ll long long
#define clr(a, b)memset(a,b,sizeof(a))
#define sz(a) (int)(a).size()
const long long N = (int) 2e5 + 74, OO = 0x3f3f3f3f, MOD = (int) 1e9 + 7;

int n;
int a[N][3];
int mem[N][3];
int dp[N][3];

class CVacation {
public:
    void init() {
        clr(mem, -1);
        clr(dp, 0);
    }

    int solve(int i, int last) {
        if (i == n)
            return 0;
        if (last != -1 && mem[i][last] != -1)
            return mem[i][last];
        mem[i][last] = 0;
        for (int j = 0; j < 3; j++) {
            if (last != j)
                mem[i][last] = max(mem[i][last], solve(i + 1, j) + a[i][j]);
        }
        return mem[i][last];
    }

    void solve(istream &cin, ostream &cout) {
        init();
        cin >> n;
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < 3; j++)
                cin >> a[i][j];
        }
        dp[0][0] = max(a[0][1], a[0][2]);
        dp[0][1] = max(a[0][0], a[0][2]);
        dp[0][2] = max(a[0][0], a[0][1]);
        for (int i = 1; i < n; i++) {
            for (int k = 0; k < 3; k++) {
                for (int j = 0; j < 3; j++) {
                    if (k != j)
                        dp[i][j] = max(dp[i][j], dp[i - 1][k] + a[i][j]);
                }
            }
        }
//        cout << solve(0, -1);
        cout << max({dp[n - 1][0], dp[n - 1][1], dp[n - 1][2]});
    }
};
int main() {
	ios::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr);
	CVacation solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 6400
h, w = map(int, (input().split()))
s = [['.'] * (w + 2)] + \
    [list('.' + input() + '.') for i in range(h)] + \
    [['.'] * (w + 2)]

for i in range(1, h + 1):
    for j in range(1, w + 1):
        if s[i][j] == '.':
            s[i][j] = (s[i - 1][j - 1:j + 2] +
                       s[i][j - 1:j + 2] +
                       s[i + 1][j - 1:j + 2]).count('#')

for i in range(1, h + 1):
    print(*s[i][1:w + 1], sep='')

Measured memory_bytes: 3444
a, b, c = map(int, raw_input().split())

it = 0
while True:
    if a % 2 == 1 or b % 2 == 1 or c % 2 == 1:
        print it
        exit(0)
    if a == b and b == c and c == a:
        print -1
        exit(0)

    a, b, c = (a + b) // 2, (b + c) // 2, (a + c) // 2
    it += 1
print -1


Measured memory_bytes: 2568
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define mod 1000000007
const ll maxi =20000;
#define ip pair<ll,ll>
#define mp make_pair
int main()
{ 
 ios_base::sync_with_stdio(false);
 cin.tie(NULL);


int x,n;
cin>>x>>n;
bool a[1000];

for(int i=1;i<=1000;i++)
a[i]=false;

for(int i=0;i<n;i++){
  int a1;
  cin>>a1;
  a[a1]=true;
}
int mindif=INT_MAX;
int ans=x;
for(int i=-1000;i<=1000;i++)
{
if(abs(x-i)<mindif&&i>0&&a[i]==false){ans=i;mindif=abs(x-i);}
else if(i<=0&&abs(x-i)<mindif){ans=i;mindif=abs(x-i);}
}
cout<<ans<<endl;


}

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

#define ll long long
const int MAX = 1'000'000;
int n;
ll a[MAX], m[MAX];
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

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

	for(int i=0;i<n;i++){
		if(i%2 == 0)
			m[0] += a[i%n];
		else
			m[0] -= a[i%n];
	}
	for(int i=1;i<n;i++){
		m[i] = 2*a[i-1] - m[i-1];
	}
	for(int i=0;i<n;i++){
		cout<<m[i]<<' ';
	}


 	return 0;
}

Measured memory_bytes: 6272
import java.util.Map.Entry;
import java.io.*;
import java.util.*;

public class Main {
	
	public static void main(String[] args) throws IOException {
		FastScanner sc = new FastScanner(System.in);
		
		String s = sc.next();
		char[] p = "abcdefghijklmnopqrstuvwxyz".toCharArray();
		int ans = 101;
		for(int i = 0; i < p.length; i++){
			char c = p[i];
			char[] prev = s.toCharArray();
			int count = 0;
			
			boolean tf = true;
			for(int j = 0; j < prev.length; j++)
				if(prev[j] != c){
					tf = false;
					break;
				}
			if(tf){
				System.out.println(0);
				return;
			}
			
			while(true){
				count++;
				char[] next = new char[prev.length-1];
				boolean isAll = true;
				for(int j = 0; j < next.length; j++){
					if(prev[j] == c || prev[j+1] == c) next[j] = c;
					else{
						next[j] = prev[j];
						isAll = false;
					}
				}
				
				if(isAll) break;
				prev = next;
			}
			
			ans = Math.min(ans, count);
		}
		System.out.println(ans);
	}
}

class FastScanner {
    private InputStream in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    public FastScanner(InputStream in) {
		this.in = in;
	}
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() {
    	if (hasNextByte()) return buffer[ptr++];
    	else return -1;
    }
    private static boolean isPrintableChar(int c){
    	return 33 <= c && c <= 126;
    }
    public boolean hasNext() {
    	while(hasNextByte() && !isPrintableChar(buffer[ptr]))
    		ptr++; return hasNextByte();
    }
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() {
    	return Double.parseDouble(next());
    }
}


Measured memory_bytes: 22868
import java.util.*;

public class Main{

    int n;
    int[][] T, H;
    public Main(){
	Scanner sc = new Scanner(System.in);


	while(true){
	    n = sc.nextInt();
	    if ( n == 0 ) break;
	    T = new int[n][n];
	    H = new int[n][n];
	    for ( int i = 0; i < n; i++ ){
		for ( int j = 0; j < n; j++ ){
		    T[i][j] = sc.nextInt();
		    H[i][j] = 0;
		}
	    }
	    for ( int a = 0; a < n; a++ ){
		int minv = getMin(a);
		int maxv = getMax(a);
		for ( int b = 0; b < n; b++ ){
		    if ( T[a][b]  == minv ) H[a][b]++;
		    if ( T[b][a] == maxv ) H[b][a]++;
		}
	    }

	    int ans = 0;
	    for ( int i = 0; i < n; i++ ){
		for ( int j = 0; j < n; j++ ){
		    if ( H[i][j] == 2 ) ans = T[i][j];
		}
	    }
	    System.out.println(ans);
	}
    }

    int getMax(int j){
	int maxv = 0;
	for ( int i = 0; i < n; i++ ){
	    if ( maxv < T[i][j] ) {
		maxv = T[i][j];
	    }
	}
	return maxv;
    }
    
    int getMin(int i){
	int minv = Integer.MAX_VALUE;
	for ( int j = 0; j < n; j++ ){
	    if ( minv > T[i][j] ) {
		minv = T[i][j];
	    }
	}
	return minv;
    }

    public static void main(String[] args){
	new Main();
    }
}

Measured memory_bytes: 12000
#include <cstdio>
#include <cstring>
using namespace std;
#define swap(a,b)	if(a!=b){ a^=b;	b^=a;	a^=b; }
#define INFINITY 1e9+1
int n;

void cswap(char* a,char* b){
	char tem=*a;	*a=*b;	*b=tem;
}

void quicksort(int a[],char s[],int p,int r){
	if(p<r){
		//partition(a,p,r)
		int x=a[r];
		int i=p;
		for(int j=p;j<r;j++){
			if(a[j]<=x){
				swap(a[i],a[j]);
				cswap(&s[i],&s[j]);
				i++;
			}
		}
		swap(a[i],a[r]);
		cswap(&s[i],&s[r]);
		//q=i(return);
		if(i-p>=2)	quicksort(a,s,p,i-1);
		if(r-i>=2)	quicksort(a,s,i+1,r);
	}
}

void mergesort(int a[],char s[],int left,int right){
	if(left+1>=right)	return;
	int mid=(left+right)/2;
	mergesort(a,s,left,mid);	mergesort(a,s,mid,right);
	int ln=mid-left,rn=right-mid;
	int ll[ln+1],rr[rn+1];
	char lc[ln+1],rc[rn+1];
	for(int i=0;i<ln;i++){
		ll[i]=a[left+i];	lc[i]=s[left+i];
	}
	for(int i=0;i<rn;i++){
		rr[i]=a[mid+i];	rc[i]=s[mid+i];
	}
	ll[ln]=INFINITY;	rr[rn]=INFINITY;	lc[ln]='\0';	rc[rn]='\0';
	
	int lco=0,rco=0;
	for(int i=left;i<right;i++){
		if(ll[lco]<=rr[rco]){
			a[i]=ll[lco];	s[i]=lc[lco++];
		}
		else{
			a[i]=rr[rco];	s[i]=rc[rco++];
		}
	}
}
			
	
	
int main(){
	scanf("%d",&n);
	int num[n];	char suit[n];
	int num2[n];	char suit2[n];
	for(int i=0;i<n;i++){
		scanf(" %c %d",&suit[i],&num[i]);
		num2[i]=num[i];	suit2[i]=suit[i];
	}
	quicksort(num,suit,0,n-1);
	mergesort(num2,suit2,0,n);
	suit[n]='\0';	suit2[n]='\0';
	if(strcmp(suit,suit2)==0)	printf("Stable\n");
	else 	printf("Not stable\n");
	for(int i=0;i<n;i++)	printf("%c %d\n",suit[i],num[i]);
	return 0;
}

Measured memory_bytes: 2504
#include<stdio.h>
#include<stdlib.h>
#include<stdint.h>
#include<inttypes.h>

typedef int32_t i32;
typedef int64_t i64;

#define MIN(a,b) ((a) < (b) ? (a) : (b))

void run (void) {
  i64 n;
  scanf ("%" SCNi64, &n);
  i64 min = 1000000000000000LL;
  for (i32 i = 0; i < 5; ++i) {
    i64 a;
    scanf ("%" SCNi64, &a);
    min = MIN(min, a);
  }
  printf ("%" PRIi64 "\n", (n + min - 1) / min + 4);
}

int main (void) {
  run ();
  return 0;
}

Measured memory_bytes: 128
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    var a = readLine()!!.split(" ").map { it.toInt() }

    var r = a.filter { it % 2 == 0 }
    if(r.all { it % 3 == 0 || it % 5 == 0 }){
        println("APPROVED")
    }else{
        println("DENIED")
    }
}

Measured memory_bytes: 37952
#include <iostream>

using namespace std;

int max(int a, int b)
{
	return a > b ? a : b;
}

int min(int a, int b)
{
	return a < b ? a : b;
}

int GCD(int a, int b)
{
	if (a == b)
	{
		return a;
	}
	else
	{
		return GCD(max(a, b) - min(a, b), min(a, b));
	}
}

int LCM(int a, int b)
{
	return a / GCD(a, b) * b;
}

int main()
{
	int a, b;

	while (cin >> a >> b)
	{
		cout << GCD(a, b) << ' ' << LCM(a, b) << endl;
	}

	return 0;
}

Measured memory_bytes: 1160
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF (1<<30)
#define LINF (1LL<<60)
#define endl "\n"
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
typedef unsigned long long int ull;
typedef long long lint;
 
 int main(void){
     lint N;
     cin >> N;
     lint A[N];
     rep(i,N) cin >> A[i];
     sort(A,A+N);
     priority_queue<lint> edge;
     rep(i,N-1){
         if(A[i]==A[i+1]) edge.push(A[i]),i++;
     }
     if(edge.size()<2) cout << "0" << endl;
     else{
         lint ans=1;
         rep(i,2){
             ans*=edge.top();
             edge.pop();
         }
         cout << ans << endl;
     }
 }

Measured memory_bytes: 1660
#include <iostream>

using namespace std;
typedef pair<int,int> PII;
typedef long long ll;
const int N=1010;
ll f[N][N];
ll ans=0;
ll qmi(ll a,ll b)
{
    ll ans=1;
    while(b){
        if(b&1)ans=ans*a;
        a=a*a;
        b>>=1;
    }
    return ans;
}
void dfs(int i,int j,int k,ll now)
{
    if(i<1){
        ans=now;
        return ;
    }
    // cout<<i<<' '<<j<<' '<<k<<' '<<now<<endl;
    int a1=f[i-1][j-1];
    int a2=f[i-1][j-1]+f[i-1][j];
    // cout<<a1<<' '<<a2<<' '<<k<<endl;
    // dfs(i-1,j+1,k-a2,now+(j+1)*(qmi(10,i-1)));
    if(k<=a1){
        dfs(i-1,j-1,k,now+(j-1)*(qmi(10,i-1)));
    }else if(k<=a2){
        dfs(i-1,j,k-a1,now+j*qmi(10,i-1));
    }else{
        dfs(i-1,j+1,k-a2,now+(j+1)*(qmi(10,i-1)));
    }
}
int main()
{
    int n;
    cin>>n;
    for(int i=0;i<=9;i++)f[0][i]=1;
    for(int i=1;i<=20;i++)
    {
        for(int j=0;j<=9;j++)
        {
            if(j==9){
                f[i][j]=f[i-1][j-1]+f[i-1][j];
            }else{
                f[i][j]=f[i-1][j-1]+f[i-1][j]+f[i-1][j+1];
            }
            if(j==1){
                // f[i][j]++;
            }
        }
    }
    // cout<<f[1][0]<<endl;
    // for(int i=1;i<=20;i++)
    // {
    //     for(int j=1;j<=9;j++)cout<<f[i][j]<<' ';
    //     cout<<endl;
    // }
    ll sum=0;
    PII t;
    // dfs(n);
    for(int i=0;i<=20;i++)
    {
        for(int j=1;j<=9;j++)
        {
            if(sum+f[i][j]<n){
                sum+=f[i][j];
            }else{
                t={i,j};
                break;
            }
        }
        if(t.first)break;
    }
    if(n<10){
        cout<<n<<endl;
        return 0;
    }
    // cout<<f[t.first][t.second]<<endl;
    // cout<<sum<<endl;
    // cout<<t.first<<' '<<t.second<<endl;
    // cout<<(n-sum)<<endl;
    // cout<<(t.second*qmi(10,t.first))<<endl;
    dfs(t.first,t.second,n-sum,t.second*(qmi(10,t.first)));
    cout<<ans<<endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
  int n; cin >> n;
  vector <int> a(n);
  vector <int> b(n);
  vector <int> c(n-1);
  int res = 0;
  for (auto &m: a) {
    cin >> m;
  }
  for (auto &m: b) {
    cin >> m;
    res += m;
  }
  for (auto &m: c) {
    cin >> m;
  }
  for (int i = 0; i < a.size()-1; i++ ) {
    if (a[i] + 1 == a[i+1]) {
      res += c[a[i]-1];
    }
  }
  cout << res;
}

Measured memory_bytes: 3536
while line = gets do
    ->(l){
        a = l[0]
        b = l[1]
        c = l[2]
        d = l[3]
        e = l[4]
        f = l[5]
        delta = 1.0 / ( a * e - b * d );
        x = ( e * c - b * f ) * delta
        y = ( a * f - d * c ) * delta
        printf "%.3f %.3f\n", x+1e-9, y+1e-9
    }.call line.split(' ').map(&:to_f)
end

Measured memory_bytes: 6140
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long int ll;
typedef vector<pair<ll,ll> > Q;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
const ll inf=1e9+7;
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; }

int main(){
  double n,d;
  cin>>n>>d;

  double ans=n/(2*d+1);
  cout<<ceil(ans)<<endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef pair<ll, ll> PP;
#define rep(i,n) for(ll i = 0; i < ll(n); i++)
#define all(v) v.begin() , v.end()
#define inputv(v,n) rep(i,n){\
    ll x;\
    cin>>x;\
    v.push_back(x);\
    }
const ll INF = 999999999999999;
const ll MOD = 1000000007;
ll a, b, c, d, e, f, p, t, x, y, z, q, m, n, r, h, k, ans = 0, w, l;
struct edge { ll to, w, p; };
vector<edge>X[110];
int N, M, used[110];
ll dfs(ll s, ll t, ll r) {
	if (s == t)return r; used[s] = 1;
	for (int i = 0; i < ll(X[s].size()); i++) {
		edge& u = X[s][i];
		if (used[u.to] == 0 && u.w > 0) {
			ll F = dfs(u.to, t, min(r, u.w));
			if (F > 0) { u.w -= F; X[u.to][u.p].w += F; return F; }
		}
	}
	return 0;
}
void input() {
	cin >> N >> M;
	for (int i = 0; i < M; i++) {
		cin >> a >> b >> c;
		edge p = { b,c,ll(X[b].size()) }; X[a].push_back(p);
		edge q = { a,0,ll(X[a].size() - 1) }; X[b].push_back(q);
	}
	ll res = 0;
	while (true) {
		for (int i = 0; i < 110; i++)used[i] = 0;
		ll P = dfs(0, N - 1, 1 << 30);
		if (P == 0)break; res += P;
	}
	cout << res << endl;
}
void solve() {
	
}

int main() {
	input();
	solve();
}


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

ll mod_pow(ll x, ll n, ll md)
{
  ll ret = 1;
  while( n > 0 ){
    if( n & 1 ){
      ret *= x;
      ret = ret % md;
    }
    x *= x;
    x = x % md;
    n >>= 1;
  }
  return ret;
}

ll modinv(ll a, ll m)
{
  
  ll x = 0, y = 1, gcd = m;
  ll px = 1, py = 0, pgcd = a;
  ll temp = 0;
  while (gcd > 0){
    ll quotient = pgcd / gcd;
    temp = x;
    x = px - quotient * temp;
    px = temp;
    temp = y;
    y = py - quotient * temp;
    py = temp;
    temp = gcd;
    gcd = pgcd - quotient * temp;
    pgcd = temp;
  }
  while(px<0){ px += m; }
  return px;
}

int main()
{
  const int md = 1000000007;
  int n,a,b;
  cin >> n;
  cin >> a;
  cin >> b;
  
  ll tot = mod_pow(2,n,md);
  tot = ( tot - 1 + md ) % md;
  
  ll t1 = 1;
  for(ll nn = n; nn >= n - a + 1; nn--){
    t1 *= nn;
    t1 = t1 % md;
  }
  for(ll nn = 1; nn <= a; nn ++){
    t1 *= modinv(nn,md);
    t1 = t1 % md;
  }
  tot = ( tot - t1 + md ) % md;
  
  t1 = 1;
  for(ll nn = n; nn >= n - b + 1; nn--){
    t1 *= nn;
    t1 = t1 % md;
  }
  for(ll nn = 1; nn <= b; nn ++){
    t1 *= modinv(nn,md);
    t1 = t1 % md;
  }
  tot = ( tot - t1 + md ) % md;
  
  cout << tot << endl;
  
  return 0;
}




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

#ifdef ONLINE_JUDGE
#define endl "\n"
#endif
using namespace std;
typedef unsigned long long int lu;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> v;
typedef vector<v> vv;
typedef vector<ld> vld;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
#define yes cout << "YES\n";
#define no cout << "NO\n";
#define yesno(f) \
    if (f)       \
        yes else no;
#define amin(x, y) \
    if (y < x)     \
        x = y;
#define sz(x) (ll) x.size()
template<typename T = ll>
vector<T> ga(ll n, bool oneIndexed = false) {
    vector<T> a = vector<T>(n + oneIndexed);

    for (ll i = 0; i < n; i++) {
        T p;
        cin >> p;
        a[i + oneIndexed] = p;
    }

    return move(a);
}

ll h, w, k;

vs grid;

ll checker(ll p, ll q, ll startcol) {
    ll sum = 0, farthest = -1;
    while (startcol < w) {
        for (ll row = p; row <= q; row++) {
            sum += grid[row][startcol] == '1';
        }
        if (sum <= k) {
            farthest = startcol;
            startcol++;
        } else return farthest;
    }
    return farthest;
}

ll check(ll bitmask) {
    ll total = 0;
    vpll parts;
    ll prev = 0;

    for (ll i = 0; i < h - 1; i++) {
        if (bitmask & (1ll << i)) {
            total++;
            parts.push_back({prev, i});
            prev = i + 1;
        }
    }
    parts.push_back({prev, h - 1});

    ll col = 0;
    while (col < w) {
        ll res = w;
        for (auto part : parts) {
            ll ret = checker(part.first, part.second, col);
            if (ret == -1)return 1e15;
            amin(res, ret);
        }
        if (res >= w - 1)break;

        total++;
        col = res + 1;
    }
    return total;
}

void solve() {
    cin >> h >> w >> k;
    grid = ga<string>(h);

    ll cuts = 1e15;
    for (ll i = 0, lim = 1 << (h - 1); i < lim; i++) {
        amin(cuts, check(i));
    }
    cout << cuts << endl;
}

int main(void) {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    // ll t;cin >> t;while(t--)
    solve();
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
  int a,b, i;
  scanf("%d", &a);
  scanf("%d", &b);
  for(i =0; ;i++){
    if(i*(a-1)+1>= b){
        printf("%d\n", i);
      break;
    }
  }
  return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <iomanip>

using namespace std;
vector<long long> ans;

void add(long long keta, long long cur){
   if(keta == 1){
      //cout << cur << endl;
      ans.emplace_back(cur);
      return;
   }
   int d = cur%10;
   for(int i = 0; i < 10; i++){
      if(abs(i-d)<=1) add(keta-1, cur*10+i);
   }
   return;
}

int main(){
   int K;
   cin >> K;
   for(int j = 1;j<=10 ;j ++){
      for(int i = 1 ; i <10 ; i++){
         add(j,i);
      }
   }
   sort(ans.begin(),ans.end());
   cout << ans[K-1] << endl;
   return 0;
}


Measured memory_bytes: 2420
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sat Jun 15 16:58:00 2019

@author: YudNK
"""
import bisect as bs

N, Q = map(int, input().split())
E = []
for i in range(N):
    s, t, x = map(int, input().split())
    a = [s - x, t - x, x] #イベント
    E.append(a)
E.sort(key = lambda x: x[2])
D = []
for i in range(Q):
    D.append(int(input()))

ans = [-1]*Q
check = [-1]*Q

for e in E:
    l = bs.bisect_left(D, e[0])
    r = bs.bisect_left(D, e[1])
    while l < r:
        if check[l] == -1:  
            ans[l] = e[2]
            check[l] = r
            l += 1
        else:
            l = check[l]
        
[print(i) for i in ans]

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

int main(){
  int c[3][3];
  rep(i,3) rep(j,3) cin >> c[i][j];
  vector<int> a(3,0), b(3,0);
  rep(i,3) {
    a[i] = c[i][0];
    b[i] = c[0][i] - a[0];
  }
  rep(i,3) {
    rep(j,3) {
      if (c[i][j] != a[i] + b[j]) {
        puts("No");
        return 0;
      }
    }
  }
  puts("Yes");
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int a,b,x;
    cin >> a >> b >> x;
    if(x < a){
        cout << "NO";
    }else if(x == a){
      	cout << "YES";
    }else if( x < (a + b)/2){
        cout <<  "NO";
    }else if( x > a + b){
        cout << "NO";
    }else{
        cout << "YES";
    }
    return 0;
}

Measured memory_bytes: 256
import bisect

N,M,K=map(int,input().split())
arr1=list(map(int,input().split()))
arr2=list(map(int,input().split()))

A=[0]
for i in range(N):
  A.append(arr1[i]+A[-1])
B=[0]
for i in range(M):
  B.append(arr2[i]+B[-1])

ans=0
for i in range(N+1):
  if A[i]>K:
    break
  j=bisect.bisect_right(B,K-A[i])-1
  ans=max(ans,i+j)
print(ans)

Measured memory_bytes: 47396