akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define vb __int128
#define ll long long
#define ld long double
#define full(a) a.begin(),a.end()
#define fr(i,a,b) for(int i = a ; i < b ; i++)
#define stoink stack<ll>
#define quu queue<ll>
#define quee queue<pair<ll,ll>>
#define vec vector <ll>
#define vg vector<vector<ll> >
#define eg vector<pair<ll,ll>>
#define vgw vector<vector<pair<ll,ll> > >
#define pa pair<ll,ll>
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define pre 0.00000000000000000001
#define inf 100000000000000000
#define mod 998244353
int main()
{	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ll n,m,k;
	cin >> n >> m >> k;
	ll x1,y1,x2,y2;
	cin >> x1 >> y1 >> x2 >> y2;
	x1--;
	y1--;
	x2--;
	y2--;
	vector<string> arr(n);
	fr(i,0,n) cin >> arr[i];
	queue<pair<ll,pa>> pq;
	vg dist(n,vec(m,inf));
	dist[x1][y1] = 0;
	pq.push({0,{x1,y1}});
	while(!pq.empty()) {
		pair<ll,pa> ver = pq.front();
		pq.pop();
		ll x = ver.ss.ff;
		ll y = ver.ss.ss;
		ll weight = ver.ff;
		ll i;
		for(i = 1 ; i <= k ; i++) {
			ll xx = x + i;
			ll yy = y;
			if(xx < n && xx >= 0 && yy < m && yy >= 0) {
				if(arr[xx][yy] == '@' || dist[xx][yy] <= dist[x][y])
					break;
				if(dist[xx][yy] == inf) {
					dist[xx][yy] = weight + 1;
					pq.push({weight + 1,{xx,yy}});
				}
			}
			else
				break;
		}
		for(i = 1 ; i <= k ; i++) {
			ll xx = x;
			ll yy = y - i;
			if(xx < n && xx >= 0 && yy < m && yy >= 0) {
				if(arr[xx][yy] == '@' || dist[xx][yy] <= dist[x][y])
					break;
				if(dist[xx][yy] == inf) {
					dist[xx][yy] = weight + 1;
					pq.push({weight + 1,{xx,yy}});
				}

			}
			else
				break;
		}
		for(i = 1 ; i <= k ; i++) {
			ll xx = x;
			ll yy = y + i;
			if(xx < n && xx >= 0 && yy < m && yy >= 0) {
				if(arr[xx][yy] == '@' || dist[xx][yy] <= dist[x][y])
					break;
				if(dist[xx][yy] == inf) {
					dist[xx][yy] = weight + 1;
					pq.push({weight + 1,{xx,yy}});
				}
			}
			else
				break;
		}
		for(i = 1 ; i <= k ; i++) {
			ll xx = x - i;
			ll yy = y;
			if(xx < n && xx >= 0 && yy < m && yy >= 0) {
				if(arr[xx][yy] == '@' || dist[xx][yy] <= dist[x][y])
					break;
				if(dist[xx][yy] == inf) {
					dist[xx][yy] = weight + 1;
					pq.push({weight + 1,{xx,yy}});
				}
			}
			else
				break;
		}
	}
	if(dist[x2][y2] == inf)
		cout << -1;
	else
		cout << dist[x2][y2];
	return 0;
}


Measured memory_bytes: 19796
{-# LANGUAGE BangPatterns #-}

import Control.Monad
import Data.List
import Data.Bits
import Debug.Trace
import Data.Maybe
import qualified Data.ByteString.Char8 as C

main :: IO ()
main = do
  [n, l] <- readInts
  print $ solve n l

solve n l = if l >= 0
  then applePie - l
  else if -l >= (n - 1)
    then applePie - (l + n - 1)
    else applePie
  where
    applePie = (n * (n - 1)) `div` 2 + (l * n)
-- 以下ライブラリ

readInts :: IO [Int]
readInts = map (fst . fromJust . C.readInt) . C.words <$> C.getLine

readNInts :: Int -> IO [[Int]]
readNInts = flip replicateM readInts

readIntegers :: IO [Integer]
readIntegers = map (fst . fromJust . C.readInteger) . C.words <$> C.getLine

readNIntegers :: Int -> IO [[Integer]]
readNIntegers = flip replicateM readIntegers

getNLns :: Int -> IO [String]
getNLns = flip replicateM getLine

Measured memory_bytes: 380
s = input()

even = []
odd = []
for i, elem in enumerate(s):
  if i % 2 == 0:
    odd.append(elem)
  else:
    even.append(elem)

if all(elem in ['D', 'U', 'L'] for elem in list(set(even))) and all(elem in ['U', 'R', 'D'] for elem in list(set(odd))):
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3060
import math

def main():

    N = int(input())
    p = []
    for _ in range(N):
        x, y = map(int, input().split())
        p.append([x, y])

    f = 1
    for i in range(1, N+1): f *= i
    dist = [[0 for _ in range(N)] for _ in range(N)]
    d = 0
    for i in range(N):
        for j in range(N):
            dist[i][j] = math.sqrt(pow(p[i][0]-p[j][0], 2) + pow(p[i][1]-p[j][1], 2))
            d += dist[i][j]
    return d / N

if __name__ == '__main__':
    print(main())

Measured memory_bytes: 3064
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
result = 0
result += sum(B)
for i in range(N - 1):
    if A[i] < A[i + 1] and A[i+1] == A[i] + 1:
        aim = A[i] - 1 
        result +=C[aim]
        
print(result)

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

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

Measured memory_bytes: 3856
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
// #include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

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

int main()
{
  int ab, bc, ca;cin>>ab>>bc>>ca;

  cout << ab * bc / 2 << endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int[] x = new int[n];
        int[] y = new int[n];

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

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

        double D1 = 0;
        double D2 = 0;
        double D3 = 0;
        double D4 = 0;

        for (int i = 0; i < n; i++) {
            D1 += Math.abs(x[i] - y[i]);
            D2 += Math.pow(Math.abs(x[i] - y[i]), 2);
            D3 += Math.pow(Math.abs(x[i] - y[i]), 3);
            if (D4 < Math.abs(x[i] - y[i])) {
                D4 = Math.abs(x[i] - y[i]);
            }
        }

        System.out.printf("%8f\n%8f\n%8f\n%8f\n", D1, Math.sqrt(D2),
                Math.cbrt(D3), D4);
    }
}

Measured memory_bytes: 26548
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef int Int;
typedef pair<Int, Int> pii;
typedef pair<Int, double> pid;
typedef pair<double, double> pdd;
typedef pair<Int, pii> pip;
typedef pair<pii, Int> ppi;
typedef pair<double, Int> pdp;
typedef vector<Int> veci;
typedef vector<double> vecd;
typedef vector<int> veci;
typedef vector<ll> vecll;
typedef vector<double> vecd;
typedef vector<pii> vecpii;
typedef vector<ppi> vecppi;
typedef vector<veci> mati;
typedef vector<vecll> matll;
typedef vector<vecd> matd;
#define PB(x) push_back(x)
#define EB(x) emplace_back(x)
#define ALL(x) x.begin(),x.end()
#define SZ(x) (x).size()
#define CLR(x) memset(x,0,sizeof x)
#define pdebug() printf("%d\n",__LINE__)
#define REP(i, a, b) for(int i = (a);i <= (b);i++)
#define FORO(i, n) REP(i,0,(int)n-1)
#define FORI(i, n) REP(i,1,(int)n)
#define FORIT(i, t) for(auto i = t.begin();i != t.end();i++)
#define eps 1e-6
#define sqr(x) ((x)*(x))
#define dist(_a, _b) sqrt(sqr(_a.A-_b.A)+sqr(_a.B-_b.B))
#define norm(_a) sqrt(sqr(_a.A)+sqr(_a.B))
#define DEBUG 1
#if DEBUG
#define DUMP(a) do { std::cout << #a " = " << (a) << ", "; } while(false)
#define DUMPLN(a) do { std::cout << #a " = " << (a) << std::endl; } while(false)
#else
#define DUMP(a)
#define DUMPLN(a)
#endif
template<typename T, typename U>
inline void getMin(T &a, U b) { if (a > b) a = b; }
template<typename T, typename U>
inline void getMax(T &a, U b) { if (a < b) a = b; }
template<typename T>
vector<T> getVector(const int n) { return vector<T>(n); }
template<typename T>
vector<T> getVector(const int n, const T a) { return vector<T>(n, a); }
template<typename T>
vector<T> getEmptyVector() { return vector<T>(); }
template<typename T>
void appendAll(vector<T> &a, vector<T> b) { a.insert(a.end(), b.begin(), b.end()); }
template <class T1, class T2> ostream &operator<<(ostream &os, const pair<T1, T2> &a) { return os << "(" << a.first << ", " << a.second << ")"; };
// #define X first
// #define Y second
const int dx[4] = {1, -1, 0, 0};
const int dy[4] = {0, 0, 1, -1};
const ll MOD = 1000000007;
const int MAXN = 1 << 17;
const int inf = 1 << 27;
const ll llinf = 1LL << 50;
const int NIL = -inf;
int popcount(int x) { return __builtin_popcount(x); }

void solve() {
    string S;
    cin >> S;
    if(S.back() == 's') S += "es";
    else S += "s";
    cout << S << endl;
}

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

    int tc = 1;
    // cin >> tc;
    while(tc--) {
        solve();
    }

    return 0;
}


Measured memory_bytes: 3664
N, M = map(int, input().split())
adj_matrix = [[0]* N for _ in range(N)]

for i in range(M):
    a, b = map(int, input().split())
    adj_matrix[a-1][b-1] = 1
    adj_matrix[b-1][a-1] = 1

def dfs(v, used):
    #usedにFalseの値が入っていなかったら関数終了
    if not False in used:
        return 1
    
    ans = 0
    
    #adj_matrixがTrueじゃなかったら
    for i in range(N):
        #0だったら→枝がなかったら
        if not adj_matrix[v][i]:
            continue
        #usedに値があったら
        if used[i]:
            continue
        
        #used_iにTrueを代入
        used[i] = True
        #再帰
        ans += dfs(i, used)
        used[i] = False
    
    return ans
#main処理
#usedを全てFalseが詰まったリストにする
used = [False] * N
#used_0=1はTrue
used[0] = True

print(dfs(0, used))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

int main() {
  string s;
  cin >> s;
  int n = sz(s);
  cout<<s[0]+to_string(n-2)+s[n-1]<<endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {    
    public static void main(String[] args){        
        Scanner sc = new Scanner(System.in);                
        
        String ans = "";
        
        String Q = sc.next();
        String E = sc.next();
        
        for(int i = 0;i < Q.length();i++){
            ans += Q.charAt(i);
            if(i == Q.length() -1 && Q.length() != E.length()){
                 break;
            }
            ans += E.charAt(i);                        
        }        
        
        System.out.println(ans);
                
    }            
}

        

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

int main() {
    int n, m, a, b;
    cin >> n >> m;
    int capital[n];
    for (int i = 1; i <= n; i++) capital[i] = 0;

    for (int i = 1; i <= m; i++) {
        a = 0, b = 0;
        cin >> a >> b;
        capital[a] += 1;
        capital[b] += 1;
        }
    

    for (int i = 1; i <= n; i++) cout << capital[i] << endl;

    return 0;
}

Measured memory_bytes: 256
s = input()

if len(s) % 2 != 0:
	print("No")
	exit()

for i in range(len(s)):
    if (i % 2 == 0) and (s[i] != "h"):
        print("No")
        exit()
    if (i % 2 != 0) and (s[i] != "i"):
        print("No")
        exit()
		
print("Yes")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <cstdlib>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
int main() {
    int a, b;
    cin >> a >> b;
    for (int i = 1; i <= 1100; i++) {
        int foo_a = floor(i * 0.08);
        int bar_b = floor(i * 0.10);
        if (foo_a == a && bar_b == b) {
            cout << i << endl;
            return 0;
        }

    }
    cout << "-1" << endl;

    return 0;
}



Measured memory_bytes: 892
#include <iostream>

using namespace std;

struct P{
	double x;
	double y;
};

int ccw(P p0, P p1, P p2)
{
	double dx1 = p1.x-p0.x;
	double dy1 = p1.y-p0.y;
	double dx2 = p2.x-p0.x;
	double dy2 = p2.y-p0.y;
	
	if(dx1*dy2 > dy1*dx2){
		return 1;
	} 
	if(dx1*dy2 < dy1*dx2){
		return -1;
	}
	if((dx1*dx2 < 0) || (dy1*dy2 < 0)){
		return -1;
	}
	if((dx1*dx1+dy1*dy1)<(dx2*dx2+dy2*dy2)){
		return 1;
	}
	
	return 0;
}

int intersect(P p1, P p2, P p3, P p4)
{
	return (((ccw(p1, p2, p3)*ccw(p1, p2, p4)) <= 0)
				 &&((ccw(p3, p4, p1)*ccw(p3, p4, p2)) <= 0));
}

int main()
{
	int n, c;
	bool f;
	P pr[3], s, t;
	
	while(cin>>n && n){
		while(n--){
			c = 0;
			cin >> pr[0].x >> pr[0].y >> pr[1].x >> pr[1].y >> pr[2].x >> pr[2].y >> s.x >> s.y >> t.x >> t.y;
			if(intersect(pr[0], pr[1], s, t) == 1){
				c++;
			}
			if(intersect(pr[0], pr[2], s, t) == 1){
				c++;
			}
			if(intersect(pr[1], pr[2], s, t) == 1){
				c++;
			}
			if(c == 1){
				cout << "OK" << endl;
			} else {
				cout << "NG" << endl;
			}
		}
	}
	
	return 0;
}

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

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

    int A[N], B[N], C[N-1];
    for(int i = 0; i < N; i++){
        cin >> A[i];
        A[i]--;
    }
    for(int i = 0; i < N; i++) cin >> B[i];
    for(int i = 0; i < N-1; i++) cin >> C[i];
    
    int ans = 0, pre = A[0];
    ans += B[pre];
    
    for(int i = 1; i < N; i++){
        ans += B[A[i]];
        if(pre == A[i]-1) ans += C[pre];
        pre = A[i];
    }
    cout << ans << "\n";
    return 0;
}


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


Measured memory_bytes: 2044
#include <cstdio>
#include <string>
#include <cstring>
using namespace std;

struct Node {
	Node * l;
	Node * r;
	Node () {l = r = NULL;}
};

Node * build(char s[], int l, int r) {
	if (r < l) return NULL;
	Node * p = new Node();
	int cnt = 0;
	for (int i = l + 1; i < r; ++i) {
		if (s[i] == '(') {cnt ++; continue;}
		if (s[i] == ')') {cnt --; continue;}
		if (s[i] == ',' && cnt == 0) {
			p->l = build(s, l + 1, i - 1);
			p->r = build(s, i + 1, r - 1);
			break;
		}
	}
	return p;
}

Node * getInter(Node * a, Node * b) {
	Node * p = new Node();
	if (a->l != NULL && b->l != NULL) {
		p->l = getInter(a->l, b->l);
	}
	//else p->l = NULL;
	if (a->r != NULL && b->r != NULL) {
		p->r = getInter(a->r, b->r);
	}
	//else p->r = NULL;
	return p;
}

Node * getUnion(Node * a, Node * b) {
	Node * p = new Node();
	if (a != NULL && b != NULL) {
		if (a->l != NULL || b->l != NULL) {
			p->l = getUnion(a->l, b->l);
		}
		else p->l = NULL;
		if (a->r != NULL || b->r != NULL) {
			p->r = getUnion(a->r, b->r);
		}
		else p->r = NULL;
	} else if (a == NULL) {
		if (b->l != NULL) p->l = getUnion(NULL, b->l);
		else p->l = NULL;
		if (b->r != NULL) p->r = getUnion(NULL, b->r);
		else p->r = NULL;
	} else {
		if (a->l != NULL) p->l = getUnion(a->l, NULL);
		else p->l = NULL;
		if (a->r != NULL) p->r = getUnion(a->r, NULL);
		else p->r = NULL;
	}
	return p;
}
void DFS2(Node *root,Node* root1)
{
    if(root1->l!=NULL)
    {
        if(root->l==NULL){
        Node *node = new Node;
        root ->l = node;}
        DFS2(root->l,root1->l);
    }
    if(root1->r!=NULL)
    {
        if(root->r==NULL){
        Node *node = new Node;
        root->r = node;}
        DFS2(root->r,root1->r);
    }
}
string getStr(Node * p) {
	if (p == NULL) {
		return "";
	}
	else return "(" + getStr(p->l) + "," + getStr(p->r) + ")";
}

char a[3000], b[3000];

int main() {
	char op;
	while (scanf("%c %s %s", &op, a, b) != EOF) {
		getchar();
		int la = strlen(a), lb = strlen(b);
		Node * ra = build(a, 0, la - 1);
		Node * rb = build(b, 0, lb - 1);
		Node * root = new Node;
		if (op == 'i') root = getInter(ra, rb);
		else {
		DFS2(root,ra);DFS2(root,rb);
		}
		string res = getStr(root);
		printf("%s\n", res.c_str());
	}
	return 0;
}

Measured memory_bytes: 0
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

k = int(readline())
runrun = [i + 1 for i in range(9)]
ans = runrun
for n in range(11):
    check = runrun
    runrun = []
    for x in check:
        if x > 3234566667:
            break
        y = x % 10
        if y > 0:
            runrun.append(x * 10 + y - 1)
        runrun.append(x * 10 + y)
        if y < 9:
            runrun.append(x * 10 + y + 1)
    ans += runrun
print(ans[k - 1])


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

typedef long long ll;

int main(){
    int n;
    ll x;
    cin >> n >> x;
    ll ans = 0;
    ll a[100010];
    for(int i = 0; i < n; i++)
    {
        cin >> a[i];
    }

    for(int i = 0; i < n-1; i++)
    {
        if(i==0 && a[i]>x){
            ans += a[i]-x;
            a[i] = x;
        }
        if(a[i]+a[i+1]>x){
            ans += a[i+1]+a[i]-x;
            a[i+1] = x-a[i];
        }
    }

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

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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))
#define sz(v) ((int) v.size())

using namespace std;

using i64 = long long;
using f80 = long double;
using vi32 = vector<int>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

void yes() { cout << "Yes" << endl; exit(0); }
void no() { cout << "No" << endl; exit(0); }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> void amax(T &x, T y) { x = max(x, y); }
template <typename T> void amin(T &x, T y) { x = min(x, y); }
template <typename T> T exp(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { for (auto &x : v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }

const i64 INF = 1001001001001001001;
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};

i64 dp[61][2][2];

void solve() {
  int n;
  cin >> n;
  vi64 a(n);
  cin >> a;
  i64 x = 0;
  repi(i, 2, n) x ^= a[i];
  i64 y = a[0] + a[1];
  repc(i, 60) rep(j, 2) rep(k, 2) {
    dp[i][j][k] = -1;
  }
  dp[60][0][0] = 0;
  rrep(i, 60) rep(j, 2) rep(k, 2) rep(l, 2) rep(m, 2) rep(nj, 2) {
    if (dp[i+1][j][k] == -1) continue;
    int ni = i;
    int nk = 1;
    if (k == 0 && (a[0] >> i & 1) < l) continue;
    if (k == 0 && (a[0] >> i & 1) == l) nk = 0;
    int xbit = x >> i & 1;
    int ybit = y >> i & 1;
    if (j == 0) {
      if (xbit == 0) {
        if (ybit == 0) {
          if (l != 0 || m != 0 || nj != 0) continue;
        } else {
          if (l != 0 || m != 0 || nj != 1) continue;
        }
      } else {
        if (ybit == 0) {
          continue;
        } else {
          if (l == m || nj != 0) continue;
        }
      }
    } else {
      if (xbit == 0) {
        if (ybit == 0) {
          if (l != 1 || m != 1 || nj != 0) continue;
        } else {
          if (l != 1 || m != 1 || nj != 1) continue;
        }
      } else {
        if (ybit == 0) {
          if (l == m || nj != 1) continue;
        } else {
          continue;
        }
      }
    }
    amax(dp[ni][nj][nk], dp[i+1][j][k] | (l == 1 ? bit64(i) : 0));
  }
  i64 ans = max(dp[0][0][0], dp[0][0][1]);
  if (ans <= 0) {
    cout << -1 << endl;
  } else {
    cout << a[0] - ans << endl;
  }
}


Measured memory_bytes: 3668
#include<iostream>

using namespace std;

int main(){
  int a, b ,c, d, e;
  int Atotal = 0, Btotal = 0;
  cin >> a >> b >> c >> d >> e;
  Atotal = a * e;
  Btotal = b;
  if(e > c) Btotal += d * (e - c);
  if(Atotal > Btotal) cout << Btotal << endl;
  else cout << Atotal << endl;
  return 0;
}

Measured memory_bytes: 3076
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<functional>
#include<map>
#include<cstring>
#include<unordered_map>
#include<set>
#define P pair<int,int>//cost to
using namespace std;

bool X[20];
vector<P>rinsetu[20];
bool S[20];
int MAX;
int saiki(int a, int b) {
	MAX = max(MAX, b);
	S[a] = true;
	for (P i : rinsetu[a]) {
		if (S[i.second] == false&&X[i.second]) {
			saiki(i.second, b + i.first);
		}
	}
	S[a] = false;
}
signed main() {
	int a;
	while (cin >> a, a) {
		memset(X, true, sizeof(X));
		int sum = 0;
		for (int b = 0; b < a; b++) { rinsetu[b].clear();}
		for (int b = 1; b < a; b++) {
			int c, d, e; cin >> c >> d >> e; c--; d--;
			rinsetu[c].push_back(P(e, d));
			rinsetu[d].push_back(P(e, c));
			sum += e * 2;
		}
		for (int i = 1; i < a; i++) {
			if (rinsetu[i].size() == 1) {
				sum -= rinsetu[i][0].first * 2;
				X[i] = false;
			}
		}
		memset(S, false, sizeof(S));
		MAX = 0;
		saiki(0, 0);
		cout << sum-MAX << endl;
	}
}

Measured memory_bytes: 3096
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <set>
#include <iomanip>
#include <stdio.h>
#include <sstream>
#include <string>
using namespace std;
int main(void){
  int x,y;
  cin>>x>>y;
  if(x==2||y==2){
    cout<<"No"<<endl;
  }else if((x==1||x==3||x==5||x==7||x==8||x==10||x==12)&&(y==1||y==3||y==5||y==7||y==8||y==10||y==12)){
      cout<<"Yes"<<endl;
    }else if((x==4||x==6||x==9||x==11)&&(y==4||y==6||y==9||y==11)){
      cout<<"Yes"<<endl;
    }else{
      cout<<"No"<<endl;
    }
}

Measured memory_bytes: 256
#dt = {} for i in x: dt[i] = dt.get(i,0)+1
import sys;input = sys.stdin.readline
inp,ip = lambda :int(input()),lambda :[int(w) for w in input().split()]

M = 10**9+7
h,w = ip()
grid = [input().strip() for i in range(h)]
dp = [[0]*w for i in range(h)]
dp[0][0] = 1
for i in range(h):
    for j in range(w):
        if i-1 >= 0 and grid[i-1][j] == '.':
            dp[i][j] += dp[i-1][j]
        if j-1 >= 0 and grid[i][j-1] == '.':
            dp[i][j] += dp[i][j-1]
print(dp[-1][-1]%M)

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

class Main {
	public static void main(String[] args) {
		try {
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			String x;
			while ((x = br.readLine()) != null) {
				int input = Integer.parseInt(x);
				int output = input * input * input;
				System.out.println(output);
			}
		} catch (Exception ex) {
			System.exit(-1);
		}
	}
}

Measured memory_bytes: 16864
#include<bits/stdc++.h>
using namespace std;
static const int64_t mod=1000000007;
int64_t f(int64_t x,int64_t y){
if(y==0)
  return 1;
  else if(y%2==0)
    return (f(x,y/2)*f(x,y/2))%mod;
  else
    return (x*((f(x,y/2)*f(x,y/2))%mod))%mod;
}
int main(){
 int N;cin>>N;
  int k=(N+999)/1000;
  cout<<1000*k-N<<endl;
  return 0;
  
}

Measured memory_bytes: 3648
//#include "pch.h"
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>

#include <vector>
#include <set>
#include <map>
#include <iostream>
#include <utility>
#include <queue>
#include <algorithm>
#include <functional>
#include <string>

#define ll long long
#define fri(n) for(i=0;i<(n);i++)
#define frj(n) for(j=0;j<(n);i++)
#define min(p,q) ((p)<(q)?(p):(q))
#define max(p,q) ((p)>(q)?(p):(q))
#define swap(p,q) r=(p);(p)=(q);(q)=r
#define INF 1000000000000000000//10^18
#define INFINT 2000000001//2*10^9+1
#define MOD 1000000007
#define MODANOTHER 998244353
#define PI acos(-1)

using namespace std;

int len;

ll doubling(int x){
	int i;
	ll int ret=1;
	for(i=0;i<x;i++){
		ret=ret*2;
	}
	return ret;
}

ll search(ll x){
	ll int i;
	ll int temp;
	ll int ret=0;

	if(x<=0) return 0;

	len=0;
	temp=x;
	while(temp!=0){
		len++;
		temp=temp/2;
	}

	temp=0;
	for(i=1;i<=len;i++){
		if(i==1){
			temp=((x+1)/2)%2;
			ret=ret+temp*doubling(i-1);
		}else if(((x+1)/doubling(i-1))%2==1&&x%2==0){
			temp=1;
			ret=ret+temp*doubling(i-1);
		}
	}

	return ret;
}


int main(void)
{
	//変数の宣言
	ll int a,b;

	//よく使う変数
	int i,j,k,l;
	int flag=0;
	int ans=0;
	int count=0;
	ll int temp,temp1,temp2;
	int max,min;
//	int len;
	int sum=0;
	int ok,ng;



	//データの読み込み


	scanf("%lld %lld",&a,&b);
//	scanf_s("%lld %lld",&a,&b);

/*	for(i=0;i<m;i++){
//		scanf("%d",&b[i]);
		scanf_s("%d",&b[i]);
	}*/


	//	printf("nは%dです\n", n);
	//	printf("データの読み込み終了\n");
	//実際の処理

	temp1=search(b);
	temp2=search(a-1);


	//	printf("計算部分終了\n");

	//出力


	printf("%lld",temp1^temp2);


	//	printf("結果の出力終了\n");


	return 0;
}



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

using namespace std;
#define _USE_MATH_DEFINES_
#define ll long long
#define ld long double
#define Accepted 0
#define pb push_back
#define mp make_pair
#define sz(x) (int)(x.size())
#define every(x) x.begin(),x.end()
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define For(i,x,y)  for (ll i = x; i <= y; i ++) 
#define FOr(i,x,y)  for (ll i = x; i >= y; i --)
#define SpeedForce ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
// ROAD to...                                                                                                                                                                                                                Red

inline void Input_Output () {
	//freopen(".in", "r", stdin);
   //freopen(".out", "w", stdout);
}

const double eps = 0.000001;
const ld pi = acos(-1);
const int maxn = 1e7 + 9;
const int mod = 1e9 + 7;
const ll MOD = 1e18 + 9;
const ll INF = 1e18 + 123;
const int inf = 2e9 + 11;
const int mxn = 1e6 + 9;
const int N = 6e5 + 123;                                          
const int M = 22;
const int pri = 997;
const int Magic = 2101;

const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
 
int n, m, k;
int a[N];
ll f[N];
map < int, int > cnt;

int main () {
   SpeedForce;
	cin >> n >> k;
	cnt[0] = 1;

	ll res = 0;
	for (int i = 1;i <= n; i ++) {
		if (i >= k) {
			cnt[f[i - k]]--;
		}
		cin >> a[i];
		a[i]--;
		a[i] %= k;
		f[i] = f[i - 1] + a[i];
		f[i] %= k;

		//cout << cnt[f[i]] << ' ';
		res += cnt[f[i]]++;
	}

	cout << res;
   return Accepted;
}

// B...a

Measured memory_bytes: 13312
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
const ll INF = 1LL<<60;
const ll MOD = 1e9+7;


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a,b;cin>>a>>b;
    string num = "0123456789";
    if(a<b)cout<<string(b,num[a]);
    else cout<<string(a,num[b]);
    return 0;
}

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

public class Main {

	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String num = br.readLine();
		String[] str =num.split("");
		for(int i=0;i<str.length-8;i++) {
			System.out.print(str[i]);
		}
	}
}

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

int main() {
  char C;
  cin >> C;
  if (C == 'a' || C == 'i' || C == 'u' || C == 'e' || C == 'o') {
    cout << "vowel" << endl;
  }
  else {
    cout << "consonant" << endl;
  }
}

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

int main(int argc, char const *argv[])
{
    int sx,sy,tx,ty;cin>>sx>>sy>>tx>>ty;
    string s;
    // first loop
    for(int i=0;i<tx-sx;++i)s+='R';
    for(int i=0;i<ty-sy;++i)s+='U';
    for(int i=0;i<tx-sx;++i)s+='L';
    for(int i=0;i<ty-sy;++i)s+='D';
    // second loop
    s+='D';
    for(int i=0;i<tx-sx+1;++i)s+='R';
    for(int i=0;i<ty-sy+1;++i)s+='U';
    s+="LU";
    for(int i=0;i<tx-sx+1;++i)s+='L';
    for(int i=0;i<ty-sy+1;++i)s+='D';
    s+='R';
    cout <<s<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int n;
    int age;
    int person[7];
    int i;

    while (1){
        scanf("%d", &n);
        if (n == 0){
            break;
        }

        for (i = 0; i < 7; i++){
            person[i] = 0;
        }

        for (i = 0; i < n; i++){
            scanf("%d", &age);
            if (age >= 70){
                person[6]++;
            }
            else {
                person[age / 10]++;
            }
        }

        for (i = 0; i < 7; i++){
            printf("%d\n", person[i]);
        }
    }

    return (0);
}

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

int n,l,sum;
int f[205];

int compare(int x, int y)
{
    return abs(x) < abs(y);
}

int main()
{
    scanf("%d %d",&n,&l);
    for(int i = 0; i < n; i++)
    {
        f[i] = i+l;
    }
    sort(f,f+n,compare);
    sum = 0;
    for(int i = 1; i < n; i++)
        sum += f[i];
    printf("%d\n",sum);
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

typedef long long ll;
typedef uint64_t ull;
typedef pair<int, int> P;
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

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

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

    int n;
    cin >> n;
    vector<ll> S(n + 1);
    S[0] = 0;
    for(int i = 0; i < n; ++i){
        cin >> S[i + 1];
        S[i + 1] += S[i];
    }
    ll ans = 0;
    map<ll, int> mp;
    for(int i = 0; i <= n; ++i){
        ans += mp[S[i]];
        ++mp[S[i]];
    }
    cout << ans << endl;
}

Measured memory_bytes: 14336
from itertools import combinations_with_replacement
n,m,q = map(int, input().split())
data = []
ans = 0
for i in range(q):
    data.append(list(map(int, input().split())))
for array in combinations_with_replacement(range(1,m+1),n):
    count = 0
    array = list(array)
    array.sort()
    for i in range(q):
        if array[data[i][1]-1] - array[data[i][0]-1] == data[i][2]:
            count += data[i][3]
    ans = max(ans, count)
print(ans)




Measured memory_bytes: 68248
#include <iostream>
#include <utility>
#include <vector>
#include <algorithm>
#include <string>

int main()
{
    int N;
    std::cin >> N;
    std::vector<std::pair<long long, long long> > BA;
    BA.resize(N);
    for(int i=0; i<N; i++) scanf(" %lld %lld", &(BA[i].second), &(BA[i].first));

    std::sort(BA.begin(), BA.end());
    bool flag = true;
    long long sum = 0;
    for(int i=0; i<N; i++){
        sum += BA[i].second;
        if(BA[i].first < sum){
            flag = false;
            break;
        }
    }
    std::string ans = (flag == true) ? "Yes" : "No";
    std::cout << ans << std::endl;
}

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

int main(){
  int k,s,ans=0;
  cin >> k >> s;
  for(int i=0;i<=k;i++){
    for(int j=0;j<=k;j++){
      if(s-i-j<=k&&s-i-j>=0){
        ans++;
      }
    }
  }

  cout << ans << endl;
}


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

using namespace std;

#define REP(i, a, b) for (int i = (a), i##_end_ = (b); i < i##_end_; ++i)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define mp make_pair
#define x first
#define y second
#define pb push_back
#define SZ(x) (int((x).size()))
#define ALL(x) (x).begin(), (x).end()

template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }

typedef long long LL;

const int oo = 0x3f3f3f3f;

const int maxn = 100100;

struct data
{
	int x, y, z;

	data() { }
	data(int _x, int _y, int _z): x(_x), y(_y), z(_z) { }

	friend bool operator<(const data &x, const data &y)
	{
		return x.y - x.x > y.y - y.x;
	}

};

int n, nx, ny, nz;
data a[maxn + 5];

LL sum;

struct Set
{
	LL sum_big;
	multiset<int> big;
	multiset<int> small;

	Set(): sum_big(0) { }

	void add(int x)
	{
		if (small.empty() || x >= *(--small.end())) big.insert(x), sum_big += x;
		else small.insert(x);
	}

	LL query(int x)
	{
		while (SZ(big) > x)
		{
			auto it = big.begin();
			small.insert(*it);
			sum_big -= *it;
			big.erase(it);
		}
		while (SZ(big) < x)
		{
			auto it = --small.end();
			big.insert(*it);
			sum_big += *it;
			small.erase(it);
		}
		return sum_big;
	}

	void del(int x)
	{
		if (big.count(x)) big.erase(big.find(x)), sum_big -= x;
		else small.erase(small.find(x));
	}

};

int main()
{
#ifdef matthew99
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	scanf("%d%d%d", &nx, &ny, &nz);
	sum = 0;
	REP(i, 0, nx + ny + nz) scanf("%d%d%d", &a[i].x, &a[i].y, &a[i].z), sum += a[i].x;
	n = nx + ny + nz;
	sort(a, a + n);
	Set left, right;
	REP(i, 0, n) right.add(a[i].z - a[i].x);
	LL ans = -1;
	REP(i, 0, n + 1)
	{
		if (i >= ny && n - i >= nx)
		{
			int le = i - ny;
			int ri = n - i - nx;
			if (le <= i && ri <= n - i) chkmax(ans, sum + left.query(le) + right.query(ri));
		}
		if (i < n) 
		{
			left.add(a[i].z - a[i].y);
			right.del(a[i].z - a[i].x);
			sum -= a[i].x;
			sum += a[i].y;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 6144
n,T=map(int,input().split())
c_l=[]
t_l=[]
for i in range(n):
	c,t=map(int,input().split())
	if t>T:
		c=1001
	c_l.append(c)
	t_l.append(t)
print("TLE" if min(c_l) == 1001 else min(c_l))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
using P = pair<int,int>;

//2で割れる回数を求める関数
int div2(int x){
  int cnt = 0;
  while(x>1){
    x/=2;
    cnt++;
  }
  return cnt;
}

int main()
{
  int N, K;
  cin >> N >> K;
  int x;
  if(K==pow(2,div2(K))){
    x = K;
  }else{
    x = pow(2,div2(K)+1);
  }
  int sum = 0;
  FOR(i,1,N+1){
    int cnt=0;
    int j = i;
    while(j<K){
      j*=2;
      cnt++;
    }
    sum+=pow(2,div2(x)-cnt);
  }
  double y = N*x;
  double z = sum;
  double a = z/y;
  cout << fixed << setprecision(10) << a << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main () {
    long long N;
    cin >> N;
    if (N & 1) {
        puts("0");
        return 0;
    }
    N/=2;
    long long ans = 0;
    while (N) {
        ans += (N = N/5);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include <algorithm>
#include <utility>
using namespace std;

int main()
{
    int N;
    int A[100];
    bool flag = 1;
    int count = 0;
    cin >> N;
    //int a = N-1;
    
    for(int i = 0; i < N; i++){
        cin >> A[i];
        }
        
    while(flag){
        flag = 0;
        for(int j = N-1; j > 0; j--){
            if(A[j] < A[j-1]){
                 swap(A[j],A[j-1]);
                 flag = 1;
                 count++;
            }
        }
    }
    
    for(int i; i < N; i++){
        if(i == N-1){
            printf("%d\n",A[i]);
            }else{
            printf("%d ",A[i]);
            }
    }
    printf("%d\n",count);
    //cout << count << endl;
}


Measured memory_bytes: 3232
#include <iostream>
using namespace std;
#include <cmath>
#include <cstdio>

int main(){
    double x1,x2,y1,y2;
    cin >> x1 >> y1 >> x2 >> y2;
    double T = (x1-x2);
    double W = (y1-y2);
    double d = sqrt(T*T + W*W);
    
    printf("%f\n",d);
    return 0;
}


Measured memory_bytes: 3296
import java.io.*;
import java.util.*;
import static java.lang.Math.*;

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

    public void solve(String[] args) {
        MyScanner scanner = new MyScanner();
        int N = scanner.nextInt();
        int X = scanner.nextInt();
        int[] m = new int[N];
        int ans = 0;
        int min = Integer.MAX_VALUE;
        for (int i = 0; i < N; i++) {
            m[i] = scanner.nextInt();
            min = Math.min(min, m[i]);
            ans++;
            X -= m[i];
        }
        ans = ans + (X/min);
        System.out.println(ans);
    }

    private class MyScanner {
        String[] s;int i;BufferedReader br;String reg = " ";
        MyScanner () {
            s = new String[0];i = 0;br = new BufferedReader(new InputStreamReader(System.in));
        }
        public String next() {
            try {
                if (i < s.length) return s[i++];
                String line = br.readLine();
                while (line.equals("")) {line = br.readLine();}
                s = line.split(reg, 0);
                i = 0;return s[i++];
            } catch (Exception e) {e.printStackTrace();}
            return null;
        }
        public int nextInt() {
            try {return Integer.parseInt(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
        public double nextDouble() {
            try {return Double.parseDouble(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
        public long nextLong()  {
            try {return Long.parseLong(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
    }
}


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

vector<int> ns;

int partition(int p, int r)
{
  auto x = ns[r];
  int i = p-1;
  for (int j=p; j<r; ++j) {
    if (ns[j] <= x) {
      ++i;
      swap(ns[i], ns[j]);
    }
  }
  swap(ns[i+1], ns[r]);
  return i+1;
}

int main()
{
  int n; cin >> n; // number of iterations
  ns = vector<int> {istream_iterator<int>{cin}, istream_iterator<int>{}};
  int split = partition(0, n-1);
  for(int i=0; i<n; ++i) {
    if(i) cout << ' ';
    if(i==split) cout << '[';
    cout << ns[i];
    if(i==split) cout << ']';
  }
  cout << endl;
}


Measured memory_bytes: 3364
input = require('fs').readFileSync(process.stdin.fd, 'utf8')
lines = input.split('\n')
line = lines.shift().split(' ')
A = line[0]
B = line[1]
C = line[2]

if (A - B >= C) {
  console.log(0)
} else {
  console.log(C - (A - B))
}

Measured memory_bytes: 11468
(function main() {
  const lines = require('fs').readFileSync('/dev/stdin', 'utf8').trim().split('\n');
  const n1 = Number(lines.shift());
  const arr1 = lines.shift().split(' ').map(Number);
  const n2 = Number(lines.shift());
  const arr2 = lines.shift().split(' ').map(Number);

  const solve = memoization(function(i, m) {
    if (m == 0) return true;
    if (i >= n1) return false;
    return solve(i + 1, m) || solve(i + 1, m - arr1[i]);
  });
  arr2.map(m => solve(0, m) ? 'yes' : 'no').forEach(res => console.log(res));
})();

function memoization(f) {
  const cache = {};
  return (...param) => {
    const c = cache[param];
    return typeof c === 'undefined' ? cache[param] = f(...param) : c;
  };
}



Measured memory_bytes: 24404
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define MOD 1000000007

string s;
ll d, dp[100001][101][3];

ll cal(string s){
    int len = s.size();
    for (int x = 1; x <= 9; x++){
        if (x < s[0] - '0') dp[1][x%d][0]++;
        else if (x > s[0] - '0') dp[1][x%d][2]++;
        else dp[1][x%d][1]++;
    }
    for (int i = 1; i < len; i++){
        for (int b = 0; b < d; b++){
            for (int sta = 0; sta < 3; sta++){
                if (dp[i][b][sta] == 0) continue;
                ll cur = dp[i][b][sta];
                for (int x = 0; x <= 9; x++){
                    if (sta == 0 || sta == 2) 
                        (dp[i + 1][(b + x)%d][sta] += cur) %= MOD;
                    else{
                        if (x < s[i] - '0')
                            (dp[i + 1][(b + x)%d][0] += cur) %= MOD;
                        else if (x > s[i] - '0') 
                            (dp[i + 1][(b + x)%d][2] += cur) %= MOD;
                        else (dp[i + 1][(b + x)%d][1] += cur) %= MOD;
                    }
                }
                
            }
        }
    }
    ll ans = 0;
    for (int i = 1; i <= len; i++){
        for (int sta = 0; sta < (i == len ? 2 : 3); sta++){
            ans = (ans + dp[i][0][sta]) % MOD;
        }
    }
    return ans;
}

int main(){
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    
    cin >> s >> d;
    
    cout << cal(s);
    
    return 0;
}


Measured memory_bytes: 24832
ans_s = []
while True:
    s = input()
    if s == "-":
        break
    else:
        n = int(input())
        for i in range(n):
            h = int(input())
            s = s[h:] + s[0:h]
        ans_s.append(s)
    
for s_ in ans_s:
    print(s_)
        


Measured memory_bytes: 5600
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <queue>
using namespace std;

#define INF 1e9
#define MAXN 100000
#define ll long long
#define vi vector<int>
#define vll vector<long long>
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define pii pair<int, int>

int N, M, P, Y;

priority_queue<pii, vector<pii>, greater<pii> > prefs[MAXN+5];
set<int> ids;
string ans[MAXN+5];

string make_str(int pref_id, int i){
  string res(12,'0');

  string pref_id_str = to_string(pref_id);
  res.replace(6-pref_id_str.size(), pref_id_str.size(), pref_id_str);

  string i_str = to_string(i);
  res.replace(12-i_str.size(), i_str.size(), i_str);

  return res;
}

void encode(){
  for(auto pref_id : ids) {
    rep(i,prefs[pref_id].size()){
      pii tmp = prefs[pref_id].top();
      prefs[pref_id].pop();
      int city_id = tmp.second;
      // printf("(%d, %d)\n", city_id, tmp.first);
      ans[city_id] = make_str(pref_id, i+1);
    }
  }
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);//高速化、endlは使わない

  cin >> N >> M;

  rep(city_id,M){
    cin >> P >> Y;
    ids.insert(P);
    prefs[P].push(make_pair(Y,city_id));
  }

  encode();

  rep(city_id,M){
    cout << ans[city_id] << endl;
  }
}

Measured memory_bytes: 17920
#include <bits/stdc++.h>
#include <bitset>
#include <cassert>
#include <cstring>
#include <functional>
#include <iomanip>
#include <list>
#include <math.h>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <vector>
// #include <boost/multiprecision/cpp_dec_float.hpp>
// #include <boost/multiprecision/cpp_int.hpp>
using namespace std;
#define REP(i, n) for (int64_t i = 0; i < (int64_t)n; i++)
#define REP_FOR(i, a, b) for (int64_t i = (int64_t)a; i < (int64_t)b; i++)
#define REP_REV(i, a, b) for (int64_t i = (int64_t)a; i > (int64_t)b; i--)
#define FORALL(v) (v).begin(), (v).end()
#define mp(a, b) make_pair(a, b)
#define eb(x) emplace_back(x)
#define F first
#define S second
typedef long long ll;
typedef long double ld;
typedef pair<int64_t, int64_t> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<int64_t> vii;
typedef vector<vii> vvii;
const ll mod = 1e9 + 7;
const int64_t infi = 1147483600;
const ll infl = 4e18 + 5;
const char EOL = '\n';
//cout << fixed << setprecision(17) << res << endl;
const ll MOD = 998244353;

bool my_compare(const int64_t& a, const int64_t& b) {
    return a > b;
};

int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << std::fixed << setprecision(15);
    int64_t n, m;
    cin >> n >> m;

    multiset<int64_t, greater<int64_t>> a;

    for (int64_t i = 0; i < n; ++i) {
        int64_t b;
        cin >> b;
        a.insert(b);
    }

    for (int64_t i = 0; i < m; ++i) {
        auto iter = a.begin();
        a.erase(iter);
        auto v = (*iter) >> 1;
        a.insert(v);
    }

    int64_t sum = 0;
    for (auto iter = a.begin(); iter != a.end(); ++iter) {
        sum += *iter;
    }

    cout << sum << endl;
}


Measured memory_bytes: 4992
#include<iostream>
#include<vector>
#include<string>
#include<set>
#include<map>
#include<algorithm>
#include<queue>
#include<list>
#include<stack>
#include<cstdio>
#include<fstream>
#include<numeric>
#include<functional>
#include<utility>
#include<memory>
#include <cstring>
#include<bits/stdc++.h> 
#define mp make_pair
typedef long long ll;
using namespace std;
int a,b,k;
string str[105];
int main(){
	cin>>a>>b;
	b--;
	a--;
	for (int i=0;i<99;i++){
		str[0]+='#';
	}
	k=2;
	while (a>0){
		for (int i=0;i<33;i++){
			str[k]+="###";
			if (a>0){
				a--;
				str[k-1]+="#.#";
			}else{
				str[k-1]+="###";
			}
		}
		k+=2;
	}
	k--;
	for (int i=0;i<99;i++){
		str[k]+='.';
	}
	k+=2;
	while (b>0){
		for (int i=0;i<33;i++){
			str[k]+="...";
			if (b>0){
				b--;
				str[k-1]+=".#.";
			}else{
				str[k-1]+="...";
			}
		}
		k+=2;
	}
	cout<<k-1<<' '<<99<<endl;
	for (int i=0;i<k-1;i++){
		cout<<str[i]<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
n = gets.to_i

while n / 10 != 0
  n %= 10
end

hon = [2,4,5,7,9]
pon = [0,1,6,8]

if hon.include?(n)
  puts "hon"
elsif pon.include?(n)
  puts "pon"
else
  puts "bon"
end


Measured memory_bytes: 14288