akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const ll mod = 1000000007;
const ll INF = 1001001001;
const ll LINF = 1001001001001001001;

void prvec(vector<bool> vec){
    ll n = vec.size();
    rep(i,n) cout << i << " " << vec.at(i) << "\n";
}

void pr2d(vector<vector<ll>> vvec){
    ll h = vvec.size();
    ll w = vvec.at(0).size();
    rep(i,h){
        rep(j,w){
            cout << vvec.at(i).at(j) << " ";
        }
        cout << "\n";
    }
}

int main(){
    ll n ; cin >> n;
    vector<ll> cnt(100001,0);
    ll sum = 0;
    rep(i,n){
        ll x; cin >> x;
        cnt.at(x)++;
        sum += x;
    }
    //cout << "deb" ;
    ll q; cin >> q;
    rep(i,q){
        ll b,c; cin >> b >> c;
        ll x = cnt.at(b);
        cnt.at(b) = 0;
        cnt.at(c) += x;
        sum -= b*x;
        sum += c*x;
        cout << sum << endl;
        //cout << "deb" ;
    }
    return 0;
}

Measured memory_bytes: 3992
import sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = 10**20
def I(): return int(input())
def F(): return float(input())
def S(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()

def resolve():
    X, N = LI()
    if N == 0:
        print(X)
        return

    p = LI()

    p_max = max(p)
    p_min = min(p)

    if X < p_min or p_max < X:
        print(X)
        return
    else:
        d = [abs(i-X) for i in range(0, 102) if i not in p]
        d_min = min(d)
        for i in range(0, 102):
            if i not in p:
                if abs(i-X)==d_min:
                    print(i)
                    return

if __name__ == '__main__':
    resolve()


Measured memory_bytes: 9248
#import sys
MOD = 10 ** 9 + 7
INFI = 10**10
#input = sys.stdin.readline
import math

import itertools
import heapq
#import bisect

import copy
from functools import lru_cache

def sosuhante(n):
    for k in range(2, int(math.sqrt(n))+1):
        if n% k ==0:
            return False
    return True
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

def kingaku(a,b,n):
    keta=len(str(n))
    return a*n+b*keta

def my_index(l, x, default=False):
    if x in l:
        return l.index(x)
    else:
        return default

#    h,w,a,b = map(int, input().split())
#    c = [[0 for j in range(n)] for i in range(n)]

def ret(a):
    c=[None]*(len(a)-1)
    if len(a)==1:
        return a[0]
    elif len(a)==0:
        return 0
    for i in range(1,len(a)):
        c[i-1]=abs(a[i]-a[i-1])
    return ret(c)


def main():
    n,m=map(int,input().split())
    h=list(map(int,input().split()))
    a=[[h[i]] for i in range(n)]
    for i in range(m):
        x,y=map(int,input().split())
        a[x-1].append(h[y-1])
        a[y-1].append(h[x-1])
    total=0
    for i in range(n):
        if len(a[i])==1:
            total+=1
        elif max(a[i][1:])<a[i][0]:
            total+=1
    print(total)






if __name__ == "__main__":

    main()

Measured memory_bytes: 92920
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            int[] A = Console.ReadLine().Split().Select(p => int.Parse(p)).ToArray();
            int[] B = Console.ReadLine().Split().Select(p => int.Parse(p)).ToArray();

            long ans = 0;
            for (int i = 0; i < N; i++) {
                if (A[i] >= B[i]) {
                    ans += B[i];
                } else {
                    ans += A[i];
                    int x = B[i] - A[i];
                    if (A[i + 1] >= x) {
                        ans += x;
                        A[i + 1] -= x;
                    } else {
                        ans += A[i + 1];
                        A[i + 1] = 0;
                    }
                }
            }
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 34372
import heapq
N, K = map(int, input().split())
S = [[] for _ in range(N)]
E = [0] * N
Q = []
D = []
x = 0
k = 0
h = 0
for i in range(N):
  t, d = map(int, input().split())
  S[i] = [d, t]
S.sort(reverse=True)
for d, t in S:
  if E[t - 1] > 0:
    D.append(d)
  elif k < K:
    E[t - 1] += 1
    heapq.heappush(Q, d)
    x += 1
    k += 1
    h += d
h += x ** 2
for d in D:
  if k < K:
    heapq.heappush(Q, d)
    h += d
    k += 1
    continue
  q = heapq.heappop(Q)
  if d <= q:
    break
  _h = h - q - x ** 2 + d + (x - 1) ** 2
  if _h < h:
    break
  heapq.heappush(Q, d)
  x -= 1
  h = _h
print(h)

Measured memory_bytes: 22260
#include <stdio.h>

int abs(int a) {
  return a < 0 ? -a : a;
}

int main() {
  int a,b,c, d;
  scanf("%d %d %d %d", &a, &b, &c, &d);

  if(abs(a - c) <= d || (abs(a - b) <= d && abs(b - c) <= d)) {
    printf("Yes\n");
  } else {
    printf("No\n");
  }

  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int N,ans=0;
    cin >> N;
    vector<int> vec;
    int count = 0;

    while(N!=0){
        int tmp=N % 10;
        if(tmp>0)
            count++;
        vec.push_back(tmp);
        N = N / 10;
    }
    
    if(count==1&&vec[vec.size()-1]==1){
        ans = 10;
    }else if(count==1){
        ans = vec[vec.size() - 1];
    }else{
        ans = accumulate(vec.begin(), vec.end(),0);
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<string>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<set>
#include<map>
using namespace std;
int main(){
	ios::sync_with_stdio(false);
	int N;
	cin>>N;
	int i,j,m=0;
	for(i=0;i<=N/4;i++)
	{
		for(j=0;j<=N/7;j++){
		if(4*i+7*j==N){
			cout<<"Yes"<<endl;
			m=1;
			break;
		}
	}
	if(m==1)
	break;
	}
	
	if(m==0)
	cout<<"No"<<endl;
	return 0;
}


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

using namespace std;

#define sz(x) (int)(x.size())
#define rep(i,a,b) for(int i=a;i<b;++i)
#define pb push_back
///////////////////////

int const N = 3e5 + 41;
int const M = 25;

int n;
int d[N];
vector<int> e[N];

int dfs(int u, int p){
	int atleastOne = 0;
	int atleastTwo = 0;
	rep(i, 0, sz(e[u])){
		int to = e[u][i];
		if(to == p) continue;
		int res = dfs(to, u);
		atleastTwo|= (atleastOne & res);
		atleastOne |= res;
	}
	int ret;
	rep(i, 0, M){
		if( ((1<<i) > atleastTwo) && !(atleastOne&(1<<i)) ){
			ret = i;
			break;
		}
	}
	
	int result = (1 << ret);
	rep(i, ret, M){
		result |= ((1 << i) & atleastOne);
	}

	return d[u] = result;
}

void solve(){
	cin >> n;
	rep(i, 0, n-1){
		int u, v;
		cin >> u >> v;
		--u;--v;
		e[u].pb(v);
		e[v].pb(u);
	}
	int ansMask = dfs(0, 0);
	int ans = -1;
	while(ansMask){
		++ans;
		ansMask /= 2;
	}
	cout << ans << endl;
}

int main(){
#ifdef _DEBUG
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif

	solve();

	return 0;
}

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

using namespace std;

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

int main(void){
    int n;ll k;
    cin >> n >> k;
    int a[n];
    for(int i = 0; i < n; i++){
        cin >> a[i];
        a[i]--;
    }
    int oks[n];
    for(int i = 0; i < n; i++)oks[i] = -1;
    int now = 0;
    for(int i = 0; i < k; i++){
        if(oks[now] != -1){
            k -= (oks[now]);
            k %= (i - oks[now]);
            i = -1;
            for(int i = 0; i < n; i++)oks[i] = -1;
            // cout << now << " " << k << endl;
            continue;
        }
        oks[now] = i;
        now = a[now];
    }
    cout << now + 1 << endl;
}

Measured memory_bytes: 5196
# https://atcoder.jp/contests/abc129/tasks/abc129_c
# C - Typical Stairs

n, m = list(map(int, input().split()))
a_list = []

for _ in range(m):
    a = int(input().split()[0])
    a_list.append(a)

steps_list = [dict(fx1=True, fx2=True) for _ in range(n + 1)]

for step_index in a_list:
    steps_list[step_index] = dict(fx1=False, fx2=False)

    if step_index < n - 1:
        steps_list[step_index + 1]['fx1'] = False
    if step_index < n - 2:
        steps_list[step_index + 2]['fx2'] = False

steps_list[1]['fx2'] = False
p_count_list = [0] * (n + 1)

# fx段目に登る方法は、（fx-1 + fx-2）方法ある
# ただし、x-1が壊れている場合はfx-2通り
# x-2が壊れている場合はfx-1通り
for i, op in enumerate(steps_list):
    if i == 0:
        p_count_list[i] = 1
        continue

    p_count = 0
    if steps_list[i]['fx1']:
        p_count += p_count_list[i-1]
    if steps_list[i]['fx2']:
        p_count += p_count_list[i-2]

    p_count_list[i] = p_count % 1000000007

# print(p_count_list)
ans = p_count_list[-1]
print(ans)


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

bool match(string &s, string &t){
    for(int i=0; i<(int)min(s.length(), t.length()); i++){
        if(s[i]!=t[i] and s[i]!='?' and t[i]!='?') return false;
    }
    return true;
}

int main(){
    while(1){
        int n,m;
        cin >> n >> m;
        if(n==0 and m==0) break;

        vector<string> rs(n),rd(n);
        vector<bool> ispermit(n);
        for(int i=0; i<n; i++){
            string type;
            cin >> type >> rs[i] >> rd[i];
            ispermit[i] = (type == "permit");
        }
        vector<string> ans;
        for(int i=0; i<m; i++){
            string s,d,message;
            cin >> s >> d >> message;
            bool permit = false;
            for(int j=0; j<n; j++){
                if(match(s, rs[j]) and match(d, rd[j])){
                    permit = ispermit[j];
                }
            }
            if(permit){
                ans.push_back(s+" "+d+" "+message);
            }
        }
        cout << ans.size() << endl;
        for(auto s: ans){
            cout << s << endl;
        }
    }
    return 0;
}


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

typedef pair<int, int> P;

int main() {
	while (true) {
		int n, k;
		cin >> n >> k;
		if (n == 0 && k == 0) return 0;
		int a[k];
		for (int i = 0; i < k; i++) {
			cin >> a[i];
		}
		
		sort(a, a + k);
		P dp[n + 1];
		for (int i = 0; i < n + 1; i++) {
			dp[i].first = 0;
			dp[i].second = 0;
		}
		for (int i = 0; i < k; i++) {
			dp[a[i]].first = 1;
		}
		if (dp[0].first == 1) dp[0].first = -1;
		
		for (int i = 2; i < n + 1; i++) {
			if (dp[i].first > 0) dp[i].first += dp[i - 1].first;
		}

		if (dp[0].first == 0) {
			int ans = dp[1].first;
			for (int i = 2; i < n + 1; i++) {
				ans = max(ans, dp[i].first);
			}
			cout << ans << endl;
			continue;
		}

		for (int i = 0; i < n + 1; i++) {
			dp[i].second = dp[i].first;
		}
		int i = n;
		while (i > 0) {
			int j = i;
			if (dp[j].second == 0) {
				i--;
				continue;
			}
			while (j >= 0 && dp[j].second > 0) {
				j--;
			}
			if (j > 0 && dp[j - 1].second > 0) {
				dp[i].second += dp[j - 1].second + 1;
			}
			i--;
		}

		int ans = dp[1].second;
		for (int i = 2; i < n + 1; i++) {
			ans = max(ans, dp[i].second);
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 4120
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long int
// #define ll long long int
#define ld long double
#define ff first
#define ss second
#define mp make_pair
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define pb push_back
#define eb emplace_back
#define pii pair<int, int>
#define endl '\n'
#define all(x) x.begin(),x.end()
#define f(i,j,l) for(i=j;i<l;i++)
#define smax(a,b) a=max(a,b)
// #if !defined(ONLINE_JUDGE)
// #include "debugging.h"
// #endif
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
// find_by_order(k)  returns iterator to kth element starting from 0;
// order_of_key(k) returns count of elements strictly smaller than k;
// erase,insert same as normal set

// int const mod = 7340033;
// int const mod = 998244353;
long long const mod = 1e9+7;
int power(int a,int b,int m){
    int res = 1;
    while(b){
        if(b&1){
            // res = res*a;
            res = (res*a)%m;
        }
        a=(a*a)%m;
        // a%=m;
        b=b/2;
    }
    return res;
}

int inverse(int x , int m){
    return power(x,m-2,m);
}

int const N = 2e5+5;
int const inf = 2e9;

set<int> adj[N];
int vis[N];
int cnt = 0;

void dfs(int in,int p){
    vis[in] = 1;
    cnt++;
    for(auto x:adj[in]){
        if(x == p) continue;
        if(vis[x] == 1) continue;
        dfs(x,in);
    }
}

void solve(){  
    int i,j;
    int n,m; cin >> n >> m;
    for(i=0;i<m;i++){
        int u,v; cin >> u>>v;
        adj[u].insert(v); adj[v].insert(u);
    }
    int ans = 1;

    for(i=1;i<=n;i++){
        if(vis[i] == 0){
            cnt = 0;
            dfs(i,0);
            ans = max(ans , cnt);
        }
    }

    // for(i=1;i<=n;i++){
    //     ans = max(ans , (int)adj[i].size() + 1);
    // }

    cout<<ans<<endl;
}              

int32_t main(){
    IOS;
    int t;
    t = 1;
    // precompute();
    // cin>>t;  
    for(int tt=1;tt<=t;tt++){
        // cout << "Case #"<<tt<<": ";
        solve();
    }
    return 0;
}


/*  

*/

Measured memory_bytes: 42600
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>

using namespace std;

inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v;}
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str();}

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

#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EACH(t,i,c) for(t::iretator i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

const double EPS = 1e-10;

int main() {
	int n;

	while(cin >> n, n) {
		int w, h;
		cin >> w >> h;

		vvi field(w, vi(h, 0));

		REP(i, n) {
			int x, y;
			cin >> x >> y;

			field[x-1][y-1] = 1;
		}

		int s, t;
		cin >> s >> t;

		int max = 0;

		FOR(a, 0, w-s+1) {
			FOR(b, 0, h-t+1) {
				int num = 0;
				
				REP(x, s) {
					REP(y, t) {
						if(field[a+x][b+y]) {
							num++;
						}
					}
				}

				if(num > max) {
					max = num;
				}
			}
		}

		cout << max << endl;
	}


}

Measured memory_bytes: 0
#include <iostream>
#include <iomanip>
#include <cstring>
#include <algorithm> 
#include <math.h>
#include <queue>
#include <functional>
#include <map>
#include <vector>
#include <string>
#include <set> 
using namespace std;

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

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

const ll INF = 1e15;
const ll MAX = 510000;
const ll MOD = 1000000007;


int main(void) {
	int N, M; cin >> N >> M;
	vector<ll> A(N);
	priority_queue<ll> que;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		que.push(A[i]);
	}
	for (int i = 0; i < M; i++) {
		int a = que.top();
		que.pop();
		que.push(a / 2);
	}

	ll ans = 0;
	for (int i = 0; i < N; i++) {
		ans += que.top();
		que.pop();
	}
	cout << ans << endl;
}


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

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(a) (int)(a.size())
#define ALL(a) a.begin(),a.end()
#define SET(a,b) memset(a,b,sizeof(a))
#define off ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
typedef pair<int,int>   II;
typedef vector< II >      VII;
typedef vector<int>     VI;
typedef vector< VI > 	VVI;
typedef long long int 	LL;
typedef vector<LL> 		VL;
#define si(n) cin>>n
#define dout(n) cout<<n<<"\n"
#define DRT() int t; si(t); while(t--)
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
//# define M_PI           3.14159265358979323846264338327950288
// DSU
void IO(){
	#ifndef ONLINE_JUDGE
    freopen("../input.txt", "r", stdin);
    freopen("../output.txt", "w", stdout);
	#endif
	srand(chrono::steady_clock::now().time_since_epoch().count());
	off;
}
LL n, ones;
string s;
const int maxn = 2e5+1;
int arr1[maxn];
int arr2[maxn];
void f(LL mod){
	arr1[0] = 1 % mod;
	for(int i=1;i<maxn;i++){
		arr1[i] = (2 * arr1[i-1]) % mod;
	}
}
void g(LL mod){
	arr2[0] = 1 % mod;
	for(int i=1;i<maxn;i++){
		arr2[i] = (2 * arr2[i-1]) % mod;
	}
}
int give(LL a){
	int cnt = 0;
	while(a){
		int mod = __builtin_popcount(a);
		a = a % mod;
		cnt++;
	}
	return cnt;
}
int main(){
	IO();
	cin>>n;
	cin>>s;
	ones = 0;
	rep(i,0,n){
		if(s[i] == '1')
			ones++;
	}
	f(ones+1);
	if(ones-1 > 0)
		g(ones-1);
	LL ans1 = 0, ans2 = 0;
	LL mod = ones + 1;
	LL ind = 0;
	for(int i=n-1;i>=0;i--){
		if(s[i] == '1')
			ans1 = (ans1 + arr1[ind]) % mod;
		ind++;
	}
	if(ones-1 > 0){
		ind = 0;
		mod = ones-1;
		for(int i=n-1;i>=0;i--){
			if(s[i] == '1')
				ans2 = (ans2 + arr2[ind]) % mod;
			ind++;
		}
	}
	ind = n-1;
	rep(i,0,n){
		LL temp = -1;
		if(s[i] == '1'){
			if(ones-1 > 0)
				temp = (ans2 - arr2[ind] + ones-1) % (ones-1);
		}
		else{
			temp = (ans1 + arr1[ind]) % (ones+1);
		}
		if(temp == -1){
			dout(0);
		}
		else{
			temp = 1 + give(temp);
			dout(temp);
		}
		ind--;
	}
	return 0;
}

Measured memory_bytes: 5284
#include <iostream>
#include <algorithm>
using namespace std;
struct apples{
	int val;
	char colour;
};
bool comp(const apples & a, const apples & b)
{
	if(a.val > b.val)
		return 1;
	return 0;
}
int main()
{
	int x, y, a, b, c;
	cin >> x >> y >> a >> b >> c;
	
	apples arr[a+b+c];
	for(int i = 0; i < a; i++)
	{
		cin >> arr[i].val;
		arr[i].colour = 'r';
	}
	for(int i = a; i < a+b; i++)
	{
		cin >> arr[i].val;
		arr[i].colour = 'g';
	}
	for(int i = a+b; i < a+b+c; i++)
	{
		cin >> arr[i].val;
		arr[i].colour = 'c';
	}
	
	int n = a+b+c, sum_elem = 0, end = x+y;
	long long sum = 0;
	sort(arr,arr+n,comp);
	
	for(int i = 0; sum_elem < end; i++)
	{
		if( arr[i].colour == 'r' ){
			if( x > 0 )
			{
				x--;
				sum += arr[i].val;
				sum_elem++;
			}
		}else if( arr[i].colour == 'g' ){
			if( y > 0 )
			{
				y--;
				sum += arr[i].val;
				sum_elem++;
			}
		}else if( arr[i].colour == 'c' ){
			if( c > 0 )
			{
				c--;
				sum += arr[i].val;
				sum_elem++;
			}
		}
	}
	cout << sum;
}

Measured memory_bytes: 2560
#include <cstdio>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <iterator>
#define loop(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define debug(x)  cout << #x << " = " << (x) << endl;

using namespace std;
using LL = long long;
using ULL = unsigned long long;
LL gcd(LL m, LL n) {
    if (m < n) return gcd(n, m);
    else if (n == 0) return m;
    else return gcd(n, m % n);
}
int main() {
    int n; cin >> n;
    vector<LL> a(n);
    rep(i, n) cin >> a[i];
    LL g = a[0];
    for (LL e : a) {
        g = gcd(g, e);
    }
    LL ans = 0;
    if (g % 2 == 0) {
        ans = static_cast<LL>(log2(g));
    }
    cout << ans << endl;
}


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

using namespace std;

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

int a[50], b[50], c[50], d[50];
int p[10];
int n, m, q;

int dfs(int x, int l){
  int r = 0;
  if(x == n){
    REP(i, q){
      if(p[b[i] - 1] - p[a[i] - 1] == c[i]) r += d[i];
    }
    return r;
  }
  for(int i = l; i < m; ++i){
    p[x] = i;
    int v = dfs(x + 1, i);
    r = max(r, v);
  }
  return r;
}

int main(){
  cin >> n >> m >> q;
  REP(i, q){
    cin >> a[i] >> b[i] >> c[i] >> d[i];
  }
  cout << dfs(0, 0) << endl;
  return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <queue>

#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;

int main() {
	int N;
	cin >> N;
	vector<int> a(N);
	int largest=0, second=0;
	int l_id=0, sec_id=0;
	rep(i, N) {
		cin >> a[i];
		if(largest<a[i]) {
			largest = a[i];
			l_id = i;
		} else if(second<a[i]) {
			second = a[i];
			sec_id = i;
		}
	}

	rep(i, N) {
		if(i==l_id) {
			cout << second << endl;
		} else {
			cout << largest << endl;
		}
	}
  return 0;
}

Measured memory_bytes: 2432
S = input()
ans = 0
for i in range(2 ** (len(S)-1)):
    bit = format(i, "b").zfill(len(S))[::-1]
    k = ""
    for j, s in enumerate(S):
        k += s
        if bit[j] == "1":
            k += "+"
    ans += eval(k)
print(ans)

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

int main(){
	int A, B;
	cin >> A >> B;
	int coins = 0;
	
	for(int i = 0; i < 2; i++){
		if(A >= B){
			coins += A;
			A -= 1;;
		} else {
			coins += B;
			B -= 1;;
		}
	}
	
	cout << coins << endl;
}

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

int main(){
    string N;
    cin >> N;
    int num=0;
    for(int i=0; i<N.length(); i++){
        num+=(int)(N[i]-'0');
    }
    if(num%9==0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    system("pause");
    return 0;
}

Measured memory_bytes: 3812
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cstring>
#include <cstdlib>
#include <cassert>
using namespace std;
typedef vector<int> vec;
typedef vector<vec> mat;

int N,M;
const int MAX_N = 20010;
const int MAX_M = 110000;

struct pt{
	int x,id;
	pt(){}
	pt(int x_,int id_):x(x_),id(id_){}
	bool operator<(const pt& r)const{
		return x<r.x;
	}
}a[MAX_N];

int pos[MAX_N];
int sz;

mat path,rpath;

bool vsi[MAX_M];
int ID[MAX_M];
vec st;

void add_edge(int x,int y){
	path[x].push_back(y);
	rpath[y].push_back(x);
}

void update(int x){
	x+=sz;
	while(x>1){
		add_edge(x/2,x);
		add_edge(x/2+M,x+M);
		x>>=1;
	}
}

void update(int x,int L,int R){
	x+=sz,L+=sz,R+=sz;
	while(L<R){
		if(L%2==1)add_edge(x,(L++)+M);
		if(R%2==0)add_edge(x,(R--)+M);
		L>>=1,R>>=1;
	}
	if(L==R)add_edge(x,L+M);
}

void init(int len){
	st.clear();
	memset(vsi,0,sizeof(vsi));
	memset(ID,-1,sizeof(ID));
	path.assign(M*2,vec());
	rpath.assign(M*2,vec());

	for(int i=0;i<N;i+=2){
		add_edge(pos[i],pos[i+1]+M);
		add_edge(pos[i]+M,pos[i+1]);
		add_edge(pos[i+1],pos[i]+M);
		add_edge(pos[i+1]+M,pos[i]);
	}
	for(int i=0;i<N;i++){
		update(i);
	}

	int L=0,R=0;
	for(int i=0;i<N;i++){
		while(L<i&&a[i].x-a[L].x>=len)L++;
		while(R<N&&a[R].x-a[i].x<len)R++;
		update(i,L,i-1);
		update(i,i+1,R-1);
	}
}

void dfs(int v){
	vsi[v]=1;
	for(auto& u:path[v]){
		if(vsi[u])continue;
		dfs(u);
	}
	st.push_back(v);
}

void rdfs(int v,int c){
	ID[v]=c;
	for(auto& u:rpath[v]){
		if(ID[u]>=0)continue;
		rdfs(u,c);
	}
}

bool chk(int len){
	init(len);
	vsi[0]=vsi[M]=1;
	for(int i=0;i<M*2;i++){
		if(vsi[i])continue;
		dfs(i);
	}
	int v,c=0;
	while(!st.empty()){
		v=st.back();st.pop_back();
		if(ID[v]>=0)continue;
		rdfs(v,c++);
	}
	for(int i=sz;i<N+sz;i++){
		if(ID[i]==ID[i+M])return 0;
	}
	return 1;
}

int main(){

	scanf("%d",&N);
	N<<=1;
	for(sz=1;sz<N;sz<<=1);
	M=N+sz;

	for(int i=0,x;i<N;i++){
		scanf("%d",&x);
		a[i]=pt(x,i);
	}

	sort(a,a+N);
	for(int i=0;i<N;i++){
		pos[a[i].id]=i+sz;
	}

	int lo=0,hi=1e9,mid;
	while(lo+1<hi){
		mid=(lo+hi)/2;
		if(chk(mid))lo=mid;
		else hi=mid;
	}
	printf("%d\n",lo);

	return 0;
}


Measured memory_bytes: 27640
N,C,K=map(int,input().split())
T=[int(input())for i in range(N)]
T.sort()
ans=0
bus_seat=0
tmp_time=0
for i in range(len(T)):
    if T[i]>tmp_time+K:
        bus_seat=0
    if bus_seat==0:
        ans+=1
        tmp_time=T[i]
    
    bus_seat+=1
    if bus_seat==C:
        bus_seat=0
print(ans)

Measured memory_bytes: 7484
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>

int main(){
  long N = 0, M = 0, A = 0, B = 0, d = 0, tenbo[100005] = { 0 }, H[100005] = { 0 }, ans = 0;
  scanf("%ld", &N);
  scanf("%ld", &M);
  ans = N;
  for (int i = 0; i < N; i++) scanf("%ld", H + i + 1);
  for (int i = 0; i < M; i++) {
    scanf("%ld %ld", &A, &B);
    if (H[A] >= H[B] && tenbo[B] == 0) {
      tenbo[B] = 1;
      ans--;
    }
    if (H[A] <= H[B] && tenbo[A] == 0) {
      tenbo[A] = 1;
      ans--;
    }
  }
  printf("%ld", ans);
  return 0;
}


Measured memory_bytes: 3296
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using db = double;
using pii = pair < int, int >;
using pll = pair < ll, ll >;
const int N = 2e5 + 10;
const ll inf = 1e15 + 42;
#define endl "\n"
const ll mod = 998244353;

ll MOD (ll a) {
    if (a < 0)
        a += mod;
    return (a % mod);
}

int n, s;
ll a[3004];
ll dp[3004][3004][4];

ll go (int i, int sum, int st) {
    if (sum > s)
        return 0;
    if (st == 2) {
       // cout << i << " " << sum << endl;
        if (sum == s)
            return 1;
        return 0;
    }
    if (i == n) {
        return 0;
    }
    if (dp[i][sum][st] != -1)
        return dp[i][sum][st];
    ll ans = 0;
    if (st == 0)
        ans = MOD(MOD(ans + go (i+1, sum, st)) + go (i, sum, 1));
    else if (st == 1)
        ans = MOD(ans + MOD(go(i+1, sum, 1) + MOD(go(i+1, sum+a[i], 1) + MOD(go(i, sum, 2) + go(i, sum+a[i],2)))));
    dp[i][sum][st] = ans;
    return ans;
}

void testCase() {
    cin >> n >> s;
    for (int i=0; i<n; i++)
        cin >> a[i];
    for (int i=0; i<=3001; i++) {
        for (int j=0; j<=3001; j++) {
            for (int k=0; k<4; k++)
                dp[i][j][k] = -1;
        }
    }
    cout << go (0, 0, 0) << endl;     
}
 
int main() {
    ios_base :: sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    testCase();
    return 0;
}

Measured memory_bytes: 282240
#!/usr/bin/env python3

import sys
import collections
import numpy as np
input = sys.stdin.readline
n = int(input())

A =np.array([list(map(int,input().split())) for i in range(n)])
B = np.sort(A, axis=0)

if n %2 ==1:
    print(B[((n+1)//2)-1][1] - B[((n+1)//2)-1][0] +1)
    sys.exit()
else:
    mn = (B[n//2][0] + B[(n-1)//2][0] )/2
    mx = (B[n//2][1] + B[(n-1)//2][1] )/2
    print(int(((mx - mn) *2) +1))
    sys.exit()



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

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  int tk = (c + b - 1) / b;
  int ao = (a + d - 1) / d;
  if (tk <= ao) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

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



int main(void){
    string s;
    cin >> s;
    sort(s.begin(),s.end());
    int sum=1;
    rep(i,s.size()-1){
        if(s[i] !=s[i+1]){
            sum++;
        }
    }
  	
    if(sum==2){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    
    return 0;
}

















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

int main(void){
    int i;
    
    int N;
    cin>>N;
    
    vector<int> X(N);
    for(i=0;i<N;i++){
        cin>>X[i];
    }
    
    vector<int> Y(N);
    Y=X;
    sort(Y.begin(),Y.end());
    int front,back;
    front=Y[N/2-1];
    back=Y[N/2];
    
    for(i=0;i<N;i++){
        if(X[i]<=front){
            cout<<back<<endl;
        }else if(X[i]>=back){
            cout<<front<<endl;
        }
    }
    
    
}


Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const int mod=1e9+7;
int main() {
int n;
cin>>n;
vector<int>a(n);
for(int i=0;i<n;i++)cin>>a.at(i);
sort(a.begin(),a.end());
cout<<a.at(n-1)-a.at(0)<<endl;
}


Measured memory_bytes: 256
import java.util.*;

class Main {
  
  
  public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
    
    long x = sc.nextLong(); //next(文字列), nextDouble, nextLine(1行)とか
    Deque<Long> que = new ArrayDeque<Long>();
    long count = 0;
    for (long i = 1;i<10; i++){
      que.add(i);
    }
    long temp;
    while (true){
      temp = que.pop();
      count++;
      if (count == x){
        System.out.println(temp);
        return;
      }
      if (temp%10 != 0){
        que.add(10*temp+temp%10-1);
      }
      que.add(10*temp+temp%10);
      if (temp%10 != 9){
        que.add(10*temp+temp%10+1);
      }
    }    
  }
}


Measured memory_bytes: 30292
#include <stdio.h>
#define mod 1000000007
typedef long long ll;

ll rev(ll a) {
  ll b = mod - 2, ans = 1;
  while(b) {
    if(b & 1) ans *= a, ans %= mod;
    b >>= 1, a *= a, a %= mod;
  }
  return ans;
}

int main(void) {
  ll i, j, k, r[2], c[2], ans = 0, now;
  scanf("%lld%lld%lld%lld", &r[0], &c[0], &r[1], &c[1]);
  r[0]--, c[0]--;
  ll n = r[1] + c[1], fact[n + 10];
  fact[0] = 1;
  for(i = 1; i <= n + 9; ++i) fact[i] = fact[i - 1] * i, fact[i] %= mod;
  for(i = 0; i < 2; ++i) for(j = 0; j < 2; ++j) {
    now = fact[c[i] + r[j] + 2] * rev(fact[c[i] + 1]);
    now %= mod;
    now *= rev(fact[r[j] + 1]);
    now %= mod;
    ans += now * ((i ^ j) ? -1 : 1) + mod;
    ans %= mod;
  }
  printf("%lld", ans);
  return 0;
}

Measured memory_bytes: 15744
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, A , B;
  cin >> N >> A >> B;
 
  if (N*A<= B) {
    cout << N*A << endl;
    }else if (B < N*A) {
      cout << B<< endl;
    }
  }



Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int main(){
  int x,y,ans;
  cin >> x >> y;
  ans=x+y;
  for(int i=1;i<y;i++){
    // cout << x << "*" << i << "%" << y << "==" << x*i%y << endl;
    if(x*i%y==0){
      ans=ans-1;
    }
  }
  cout << ans <<endl;
  return(0);
}



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

using namespace std;

typedef long long ll;
#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;++i)
#define RFOR(i,a,b) for(ll i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl;
#define OK(ok) cout << (ok ? "Yes" : "No") << endl;

void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail) {
  cin >> head; CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

const int INF = 1e9 + 1;
const int MOD = 1e9 + 7;
const int MAX_N = 1e5 + 1;

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

  SCIN(S);
  LCIN(K);
  int ans = 1;
  REP(si, min(K, (ll)S.size())) {
    if (S[si] != '1') {
      ans = S[si] - '0';
      break;
    }
  }
  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int T = sc.nextInt();
    int[]c = new int[n];
    int[]t = new int[n];
    ArrayList<Integer>ans  = new ArrayList<>();
    
    for(int i=0; i<n; i++){
        c[i] = sc.nextInt();
        t[i] = sc.nextInt();
}
    int cou = 0;
    for(int i=0; i<n; i++){
    	if(t[i] <= T) {
    		ans.add(c[i]);
    			cou++;
    	}else if(cou == 0) {
    		ans.add(1001);
    	}
    	}
    Collections.sort(ans);
    if(cou != 0) {
    	System.out.println(ans.get(0));
    }else {
    	System.out.println("TLE");
    }
}
}

Measured memory_bytes: 36264
/*    
*  Sachin Mittal
*/
#include<bits/stdc++.h>
#define int long long
#define M 998244353
#define mod 1000000007
#define all(v) v.begin(),v.end()
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define F first
#define S second
#define mem0(dp) memset(dp,0,sizeof(dp))
#define mem1(dp) memset(dp,-1,sizeof(dp))
#define pb push_back
#define fr(i,j,n) for(int i=j;i<n;i++)
#define sz(s) (int)(s.size())
using namespace std;
int32_t main(){
ios
int t=1;
//cin>>t;
while(t--)
{
    int x,y,a,b,c;
    cin>>x>>y>>a>>b>>c;
    vector<pair<int,int> >fruits;
    for(int i=0;i<a;i++)
    {
        int val;cin>>val;
        fruits.pb({val,0});
    }
    for(int i=0;i<b;i++)
    {
        int val;cin>>val;
        fruits.pb({val,1});
    }
    for(int i=0;i<c;i++)
    {
        int val;cin>>val;
        fruits.pb({val,2});
    }
    sort(all(fruits));
    reverse(all(fruits));
    int i=0;
    int sm=0;
    int sz1=0,sz2=0,sz3=0;
    while(sz1+sz2+sz3<x+y)
    {
        int type=fruits[i].second;
        int value=fruits[i].first;
        if(type==0 and sz1<x)
        {
            sm+=value;
            sz1++;
        }
        else if(type==1 and sz2<y)
        {
            sm+=value;
            sz2++;
        }
        else if(type==2)
        {
            sm+=value;
            sz3++;
        }
        i++;
    }
    cout<<sm;
}
}

Measured memory_bytes: 10476
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<ctime>
#include<algorithm>
#include<vector>
#include<set>
using namespace std;
typedef long long ll;
const int MAXM = 4e2 + 5;
const int MAXN = 26 + 5;
const ll linf = 0x3f3f3f3f3f3f3f3f;

int n=26, m;
int c[MAXN];
int a[MAXM][MAXN];

int p[MAXM];
set<int> idx[MAXN];
ll ans;

void init(void)
{
	for(int i=1; i<=n; ++i)
	{
		idx[i].clear();
		idx[i].insert(0);
		idx[i].insert(m+1);
	}
	
	for(int k=1; k<=m; ++k)
		idx[ p[k] ].insert(k);
}

ll recalc(int pos, int x)
{
	int old = p[pos];
	if(old == x) return ans;
	
	ll res = ans;
	
	idx[old].erase(pos);
	
	set<int>::iterator it = idx[old].upper_bound(pos);
	int nxt = *it;
	int lst = *(--it);
	
	res -= (pos - lst) * c[old] * (nxt - pos);
	res -= a[pos][old];
	
	it = idx[x].upper_bound(pos);
	nxt = *it;
	lst = *(--it);
	
	res += (pos - lst) * c[x] * (nxt - pos);
	res += a[pos][x];
	
	idx[x].insert(pos);
	
	p[pos] = x;
	return res;
}

int main(void)
{
	srand(time(0));
	
	scanf("%d",&m);
	for(int i=1; i<=n; ++i) scanf("%d",&c[i]);
	for(int i=1; i<=m; ++i)
		for(int j=1; j<=n; ++j)
			scanf("%d",&a[i][j]);
	
	static int lst[MAXN];
	
	ans = 0;
	for(int k=1; k<=m; ++k)
	{
		ll mx = -linf;
		int mxi = -1;
		for(int i=1; i<=n; ++i)
		{
			ll res = a[k][i];
			for(int j=1; j<=n; ++j) if(j!=i)
				res -= c[j] * (k-lst[j]);
			
			if(mxi==-1 || mx < res)
				mxi = i, mx = res;
		}
		lst[mxi] = k;
		
		ans += mx;
		p[k] = mxi;
	}
	
	init();
	
	int T = 1e6;
	while(T--)
	{
		int pos = rand()%m + 1;
		int x = rand()%n + 1;
		
		int old = p[pos];
		ll res = recalc(pos, x);
		if(res < ans) recalc(pos, old);
		else ans = res;
	}
	
	for(int i=1; i<=m; ++i) printf("%d\n",p[i]);
	return 0;
}

Measured memory_bytes: 3324
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include <numeric>
 
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<n;i++)
#define ALL(a) (a).begin(),(a).end()

int main(){
    ll n;
    cin >> n;
    vector<ll> d(n);
    rep(i, n)scanf("%lld", &d[i]);
    sort(ALL(d));
    int mean1 = n/2 -1;
    int mean2 = mean1+1;
    if(d[mean1] != d[mean2]){
        cout<< d[mean2] -  d[mean1];
        return 0;
    }
    int same1 = 0;
    //for(int i = mean1; i >= 0; i--){
    //    if(d[mean1] == d[i])same1++;
    //}
    //int same2 = 0;
    //for(int i = mean2; i < n;i++){
    //    if(d[mean2] == d[i])same2++;
    //}
    //if(same1 == same2 && same1 + same2 < n){
    //    cout << 1;
    //    return 0;
    //}
    cout << 0;


}

Measured memory_bytes: 1024
a = [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]
k = int(input())

print(a[k-1])

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
string s[50];
vector<int> cnt(26,1e9);
int n;
int main()
{
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>s[i];
		vector<int> v(26,0);
		for(int j=0;j<s[i].size();j++)
		v[s[i][j]-'a']++;
		for(int j=0;j<26;j++)
		cnt[j]=min(cnt[j],v[j]);
	}
	for(int i=0;i<26;i++)
	cout<<string(cnt[i],i+'a');
	return 0;
}

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

using namespace std;

int main(void) {

	string nst;

	int n, tmp, s;

	cin >> nst;

	n = stoi(nst);

	for (int i = 0; i < nst.size(); i++)
	{
		tmp = nst[i] - '0';
		s += tmp;
	}

	if (n%s == 0)cout << "Yes\n";
	else cout << "No\n";


	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
import math
import decimal
import itertools
from itertools import product
from functools import reduce


def main():
    N, M = map(int, input().split())
    X = sorted(list(map(int, input().split())))

    if N >= M:
        print(0)
        exit()

    d = []
    for i in range(M - 1):
        d.append(X[i + 1] - X[i])
    d = sorted(d, reverse=True)

    print(sum(d[N - 1:]))


def input():
    return sys.stdin.readline()[:-1]


def gcd(*numbers):
    return reduce(math.gcd, numbers)


def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)


def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)


def sort_zip(a: list, b: list):
    z = zip(a, b)
    z = sorted(z)
    a, b = zip(*z)
    a = list(a)
    b = list(b)
    return a, b


if __name__ == '__main__':
    main()


Measured memory_bytes: 95348
#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;
typedef long long ll;
typedef double db;
typedef vector <ll> vll;
typedef pair <ll, ll> pll;
#define pb push_back
#define mp make_pair
#define MAX 1000000
#define mod 1000000007
#define all(_) _.begin(), _.end()
#define F first
#define S second
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

int main()
{
    ios_base :: sync_with_stdio(false);
    cin.tie(NULL), cout.tie(NULL);
    ll n, i;
    cin >> n;
    ll thresh = 1e9;
    if(n <= thresh)
    {
        cout << "0 0 1 0 0 " << n << endl; 
    }
    else
    {
        ll ul = 1e18;
        if(n == ul)
        {
            cout << "0 0 1000000000 0 0 1000000000\n";
            return 0;
        }
        ll x2 = thresh;
        ll y3 = n / thresh + 1;
        ll x3 = y3 * x2 - n, y2 = 1;
        // cout << (x2 * y3 - x3 * y2) << endl;
        cout << "0 0 " << x2 << " " << y2 << " " << x3 << ' ' << y3 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,s=0;
	long long d,x,y;
	scanf("%d%lld",&n,&d);
	d=d*d;
	for(int i=1;i<=n;i++)
	{
		scanf("%lld%lld",&x,&y);
		if(x*x+y*y<=d)
			s++;
	}
	printf("%d\n",s);
	return 0;
}

Measured memory_bytes: 3804
<?php
    $n;
    $k;
    $a = 0;
    fscanf(STDIN, "%d %d", $n, $k);
    for($i = $k + 1; $i <= $n; $i++){
        if($k == 0){
            $a--;
        }
        $x = floor(($n - $i + 1) / $i);
        $a += ($x + 1) * ($i - $k);
        $x++;
        if($x * $i + $k <= $n){
            $a += $n - $x * $i - $k + 1;
        }
        //echo "$a\n";
    }
    echo "$a\n";
?>


Measured memory_bytes: 3828
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5+5;
int n,q;
string s;
char t[N],d[N];
bool checkL(int x){
    char now=s[x];int id=x;
    for(int i=1;i<=q;i++){
        if(t[i]==now){
            if(d[i]=='L'){
                id--,now=s[id];
            }else{
                id++,now=s[id];
            }
        }
    }
    return id==0;
}
bool checkR(int x){
    char now=s[x];int id=x;
    for(int i=1;i<=q;i++){
        if(t[i]==now){
            if(d[i]=='L'){
                id--,now=s[id];
            }else{
                id++,now=s[id];
            }
        }
    }
    return id==n+1;
}
int main(){
    ios::sync_with_stdio(false);
    cin>>n>>q>>s;
    s="*"+s+"*";
    for(int i=1;i<=q;i++){
        cin>>t[i]>>d[i];
    }
    int l=1,r=n;
    while (l<=r){
        int mid=l+r>>1;
        if(checkL(mid)){
            l=mid+1;
        }else{
            r=mid-1;
        }
    }
    int cx=r;
    l=1,r=n;
    while (l<=r){
        int mid=l+r>>1;
        if(checkR(mid)){
            r=mid-1;
        }else{
            l=mid+1;
        }
    }
    int cy=l;
    //cout<<cx<<' '<<cy<<endl;
    cout<<max(0,cy-cx-1)<<endl;
}


Measured memory_bytes: 976
# -*- coding: utf-8 -*-
# C

import sys
from collections import defaultdict, deque
from heapq import heappush, heappop
import math
import bisect
input = sys.stdin.readline

# 再起回数上限変更
# sys.setrecursionlimit(1000000)

x, k, d = map(int, input().split())
x = abs(x)

if x > k * d:
    print(x - (k*d))
    sys.exit()

n = x // d
x = x - n * d
k -= n

if k % 2 ==0:
    print(x)
else:
    print(abs(x - d))

Measured memory_bytes: 65152
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        int x=sc.nextInt();
        int y=sc.nextInt();
        int count=0;
        if(x>=y){
            count=x;
            x--;
        }
        else{
            count =y;
            y--;
        }
        if(x>=y){
            count+=x;
        }
        else{
            count+=y;
        }
        System.out.println(count);
    }
}


Measured memory_bytes: 35584
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt(),m = scanner.nextInt();
		int[] count = new int[n];
		for(int i=0;i<m;i++){
			int a = scanner.nextInt()-1;
			int b = scanner.nextInt()-1;
			count[a]++;
			count[b]++;
		}
		for(int i=0;i<n;i++){
			System.out.println(count[i]);
		}
	}

}


Measured memory_bytes: 22868
#include<iostream>
using namespace std;
int main(void){
    int A = 0, tmp = 0;

    for(int i = 0; i < 3; i++){
        cin >> tmp;
        A += tmp;
    }

    if(A > 21)  cout << "bust" << endl;
    else    cout << "win"   << endl;

    return 0;
}

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

using namespace std;

int main() {
    int a;
    cin >> a;
    int x;
    int y;
    int z;
    x = floor(a/3600);
    y = floor((a - (x*3600))/60);
    z = (a - (x*3600) - (y*60));
    cout << x << ":" << y << ":" << z << endl;
}


Measured memory_bytes: 3100
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cstring>
#include <climits>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };
 
int MOD = 1000000007;

void call(int n){
  int i = 1;
 CHECK_NUM:
  int x = i;
  if ( x % 3 == 0 ){
    cout << " " << i;
    goto END_CHECK_NUM;
  }
 INCLUDE3:
  if ( x % 10 == 3 ){
    cout << " " << i;
    goto END_CHECK_NUM;
  }
  x /= 10;
  if ( x ) goto INCLUDE3;
 END_CHECK_NUM:
  if ( ++i <= n ) goto CHECK_NUM;

  cout << endl;
}

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

Measured memory_bytes: 1160
#include <iostream>
#include <string>
#include <cstdlib>
#include <cstdio>
#include <queue>
#include <stack>
#include <list>
#include <utility>
#include <vector>
#include <set>
#include <algorithm>
#include <cmath>
#include <climits>
#include <map>
#include <unordered_map>
#include <string.h>
#include<iomanip>
#include <iterator>
#include <locale>

#define all(a) a.begin(),a.end()
#define VV(T) vector<vector< T > >
#define rep(i,N) for(int i = 0; i <N; i++)
#define repsg(i,s,g) for(int i = s; i <g; i++)
#define name(x) #x
using namespace std;


const int INF = 10000000;
const long long INFL = (1LL<<40);
const int MOD = pow(10,9)+7;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

typedef long long ll,LL;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
typedef pair<int,int> pii;
typedef pair<LL, LL> pLL;


// vector入力
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
    for(T& x: vec) is >> x;
    return is;
}
// vector出力
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec){
    for(int i=0; i<vec.size(); i++){
        os << vec[i] << ( i+1 == vec.size() ? "" : " " );
    }
    return os;
}

template< typename T >
struct edge{
    int src, to;T cost;
    edge(int to,T cost) :src(-1),to(to),cost(cost){}
    edge(int src, int to, T cost) :src(src),to(to),cost(cost){}edge
    &operator=(const int &x){
        to =x;
        return *this;
    }
    operator int() const{ return to;}
};

double dist (double a, double b,  double c, double d){
    
    return sqrt((a-c)*(a-c) + (b-d)*(b-d));
    
}

bool check(int x,int y,vector<string> a,vector<string> b ){
    for(auto i = 0; i<b.size();i++){
        for(auto j =0; j<b.size();j++){
            if(a[x+i][y+j]!= b[i][j]) return false;
        }
    }
    return true;
}


int main() {
    int a,b;cin>>a>>b;
    string s;cin>>s;
    rep(i,a){if(s[i]<'0' || s[i]>'9'){cout<<"No"<<endl;return 0;}}
    if(s[a] != '-') {cout<<"No"<<endl;return 0;}
    repsg(i,a+1,a+b+1){if(s[i]<'0' || s[i]>'9'){cout<<"No"<<endl;return 0;}}
    cout<<"Yes"<<endl;
    return 0;
}







Measured memory_bytes: 256
#include <bits/stdc++.h>
#define L long long
#define ff first
#define ss second
using namespace std;
int main() {
int n,k;
cin>>n>>k;
string x;
cin>>x;

    x[k-1]=97+(x[k-1]-'A');
cout<<x<<endl;
return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a[1000];
int main()
{
	int n;
	cin>>n;
	for (int i = 0; i < n; ++i)
	{
		cin>>a[i];
	}
	sort(a,a+n);
	int ans = 0;
	for (int i = 0; i < n; ++i)
	{
		for(int j = i+1; j < n ;j++)
		{
			for(int k = j+1; k < n ;k++)
			{
				if(a[i]!=a[j] && a[j]!=a[k] && a[i]!=a[k])
				{
					if(a[i]+a[j]>a[k])
						ans++;
				}
			}
		}
	}
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
typedef long double ld;

const ld PI = 3.14159265358979323846;

ld min(ld x, ld y)  
{  
    return (x < y)? x: y;  
      
}
ld calcAngle(ld h, ld m)  
{    
     
  
    if (h == 12) h = 0;  
    if (m == 60) m = 0;  
 
    ld hour_angle = 0.5 * (h * 60 + m);  
    ld minute_angle = 6 * m;  
    ld angle = abs(hour_angle - minute_angle);  
	angle = min(360 - angle, angle);  
  	
    return angle;  
}
int main()
{
	ld a,b,h,m;
	cin>>a>>b>>h>>m;
	ld d=calcAngle(h,m);
	ld c= (a*a)+(b*b) - (2*a*b*cos(d* PI /180));
	cout<< fixed <<setprecision(20)<<sqrt(c);
}


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

int main(){
  int N;
  cin>>N;
  vector <int>P(N);
  int count=0;
  for(int i=0;i<N;i++){
    cin>>P[i];
  }
  for(int i=1;i<N-1;i++){
    if(((P[i-1]>P[i])||(P[i+1]>P[i]))&&((P[i-1]<P[i])||(P[i]>P[i+1]))){
      count++;
    }
  }
  cout <<count<<endl;
        
  return 0;
}

    

Measured memory_bytes: 256