akhauriyash/Code-Regression huggingface dataset:
package main

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

func main() {
	scan_init()
	n := scanInt()
	a := make([]int, n)
	for i:= 0; i<n; i++ {
		a[i] = scanInt()
	}
	sum := 0
	for i:= 1; i<n; i++ {
		if a[i-1]>a[i] {
			take := a[i-1] - a[i]
			sum += take
			a[i] += take
		}
	}
	fmt.Println(sum)
}

var sc = bufio.NewScanner(os.Stdin)

func scan_init() {
	sc.Split(bufio.ScanWords)
}
func scanInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}
func scan() string {
	sc.Scan()
	return sc.Text()
}

var rdr = bufio.NewReaderSize(os.Stdin, 200000)

func readLine() string {
	buf := make([]byte, 0, 200000)
	for {
		l, p, e := rdr.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}
func readLineToNumber() int {
	S := readLine()
	number, _ := strconv.Atoi(S)
	return number
}
func readLineToSlice() []string {
	S := readLine()
	list := strings.Split(S, "")
	return list
}
func readLineToNumberSlice(memo map[string]int) []int {
	// err時は-1を代入
	S := readLine()
	intList := make([]int, len(S))
	for i := 0; i < len(S); i++ {
		if val, ok := memo[string(S[i])]; ok {
			intList[i] = val
		} else {
			intList[i] = -1
		}
	}
	return intList
}

Measured memory_bytes: 5928
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <algorithm>
#include <unordered_map>
#include <cmath>

#define rep(i, a, b) for (ll i = a; i < b; i++)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef unordered_map<string, ll> u_map;

// input
void input() {}
template <class Head, class... Tail>
void input(Head &&a, Tail &&... b)
{
    cin >> a;
    input(forward<Tail>(b)...);
}

template <class V>
void input(vector<V> &v)
{
    for_each(v.begin(), v.end(), [](auto &i) { input(i); });
}

// output
template <class V>
void output(vector<V> &v)
{
    for_each(v.begin(), v.end(), [](auto &x) { cout << x << " "; });
    cout << endl;
}

// math functions
ll mpow(ll a, ll n, ll p)
{
    ll x = 1;
    while (n > 0)
    {
        if (n & 1)
        {
            x = a * x % p;
        }
        a = a * a % p;
        n >>= 1;
    }

    return x;
}

ll mfact(ll n, ll p)
{
    ll res = 1;
    for (ll i = 2; i <= n; i++)
    {
        res = res * i % p;
    }
    return res;
}

ll mcomb(ll n, ll r, ll p)
{
    if (n == 0 && r == 0)
    {
        return 1;
    }
    if (n < r || n < 0 || r < 0)
    {
        return 0;
    }

    ll a = mfact(n, p);
    ll b = mfact(n - r, p);
    ll c = mfact(r, p);
    return (((a * mpow(b, p - 2, p)) % p) * mpow(c, p - 2, p)) % p;
}

ll gcd(ll a, ll b)
{
    if (a < b)
    {
        a ^= b;
        b ^= a;
        a ^= b;
    }
    return b ? gcd(b, a % b) : a;
}

ll lcm(ll a, ll b)
{
    return a * b / gcd(a, b);
}

int main()
{
    ll N;
    input(N);

    cout << ceil(N / 2.0) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define reg register
#define int long long
using namespace std;
int a,b,x;
signed main()
{
    scanf("%lld%lld%lld",&a,&b,&x);
    printf("%lld",!(a%x)?b/x-a/x+1:b/x-a/x);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <cmath>
#include <queue>
#include <numeric>
#include <climits>
#include <iterator>
#include <iomanip>
#include <stack>
#include <set>
#include <bitset>
#include <functional>
using namespace std;
const constexpr int INF = 1e9;
//typedef std::pair<std::string,double> P;


#define FOR(i, a, n) for (ll i = (ll)a; i<(ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)

typedef long long ll;
typedef vector<int> VI;
const constexpr ll MOD = 1e9+7;
vector<pair<int, int> > vp;
 
struct Less {
    bool operator()(const pair<int, int>& x, const pair<int, int>& y) const {
        return x.first > y.first;
    }
};

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


//グラフの隣接リスト
VI g[200010];
//頂点の入次数を管理
int h[100010];
int n;
long long f(ll a[]){
    ll ans = 0;
    if(a[0]<=0) {
        ans += abs(a[0])+1;
        a[0]=1;
    }
    
    ll sum=a[0];
    for(int i=1; i<n; ++i){
        if(i%2!=0){ //奇数番目→負
            if(sum+a[i]>=0){
                ans += abs(sum+a[i])+1;
                a[i] = -(sum)-1;
            }
        }
        if(i%2==0){ //偶数番目→正
            if(sum+a[i]<=0){
                ans += abs(sum+a[i])+1;
                a[i] = -(sum)+1;
            }
        }
        sum += a[i];
    }
    //REP(i, n) cout << a[i] << endl;
    return ans;
}

ll ff(ll a[]){
    ll ans=0;
    if(a[0]>=0) {
        ans += abs(a[0])+1;
        a[0]=-1;
    }
    
    ll sum=a[0];
    for(int i=1; i<n; ++i){
        if(i%2!=0){ //奇数番目→正
            if(sum+a[i]<=0){
                ans += abs(sum+a[i])+1;
                a[i] = -(sum)+1;
            }
        }
        if(i%2==0){ //偶数番目→負
            if(sum+a[i]>=0){
                ans += abs(sum+a[i])+1;
                a[i] = -(sum)-1;
            }
        }
        sum += a[i];
    }
    //REP(i, n) cout << a[i] << endl;
    return ans;
}

int main(void) {
    cin >> n;
    ll a[100010]={0};
    ll b[100010]={0};
    REP(i, n) {
        cin >> a[i];
        b[i] = a[i];
    }
    
    ll ans1 = f(a);
    ll ans2=ff(b);
    cout << min(ans1, ans2) << endl;
    return 0;
}

Measured memory_bytes: 6528
/*
digu_J - Digvijay Janartha
NIT Hamirpur - INDIA
*/

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

const long long MOD = 998244353, N = 8e5 + 5;

int t[N], coef[N], p[N], lazy[N];

namespace ModFunctions {
	inline int add(int a, int b) {
		a += b;
		if (a >= MOD) {
			a -= MOD;
		}
        return a;
	}

	inline int sub(int a, int b) {
		a -= b;
		if (a < 0) {
			a += MOD;
		}
        return a;
	}

	inline int mul(int a, int b) {
		return int((1ll * a * b) % MOD);
	}

	inline int power(int a, long long b) {
		int res = 1;
		while (b > 0) {
			if (b & 1) {
				res = mul(res, a);
			}
			a = mul(a, a);
			b >>= 1;
		}
		return res;
	}

	inline int inv(int a) {
		a %= MOD;
		if (a < 0) {
			a += MOD;
		}
		int b = MOD, u = 0, v = 1;
		while (a) {
			int t = b / a;
			b -= t * a;
			swap(a, b);
			u -= t * v;
			swap(u, v);
		}
		assert(b == 1);
		if (u < 0) {
			u += MOD;
		}
		return u;
	}
}

using namespace ModFunctions;

void build(int v, int tl, int tr) {
    if (tl == tr) {
        t[v] = coef[v] = p[tl];
    } else {
        int tm = (tr + tl) / 2, u = 2 * v;
        build(u, tl, tm);
        build(u + 1, tm + 1, tr);
        coef[v] = add(coef[u], coef[u + 1]);
        t[v] = coef[v];
    }
}

void push(int v) {
    if (!lazy[v]) {
        return;
    }
    int u = 2 * v;
    t[u] = mul(coef[u], lazy[v]);
    lazy[u] = lazy[v];
    t[u + 1] = mul(coef[u + 1], lazy[v]);
    lazy[u + 1] = lazy[v];
    lazy[v] = 0;
}

void update(int v, int tl, int tr, int l, int r, int val) {
    if (l > tr or r < tl) {
        return;
    }
    if (l <= tl and r >= tr) {
        t[v] = mul(coef[v], val);
        lazy[v] = val;
        return;
    }
    push(v);
    int mid = ((tl + tr) >> 1);
    update(2 * v, tl, mid, l, r, val);
    update(2 * v + 1, mid + 1, tr, l, r, val);
    t[v] = add(t[2 * v], t[2 * v + 1]);
}

int query(int v, int tl, int tr, int l, int r) {
    if (l > tr or r < tl) {
        return 0;
    }
    if (l <= tl and r >= tr) {
        return t[v];
    }
    push(v);
    int mid = ((tl + tr) >> 1);
    return add(query(2 * v, tl, mid, l, r), query(2 * v + 1, mid + 1, tr, l, r));
}

void test() {
    int n, q;
	cin >> n >> q;
    p[n] = 1;
    for (int i = n - 1; i > 0; --i) {
        p[i] = mul(p[i + 1], 10);
    }
    build(1, 1, n);
	while (q--) {
		int l, r, val;
		cin >> l >> r >> val;
        update(1, 1, n, l, r, val);
        cout << query(1, 1, n, 1, n) << "\n";
	}
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    #ifdef HOME
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    int t = 1;
    // cin >> t;
    for (int i = 0; i < t; ++i) {
        test();
    }
    return 0;
}


Measured memory_bytes: 10564
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

int32_t main()
{
	IOS;
	string a, b;
	cin >> a >> b;
	int ans = 0;
	for(int i = 0; i < a.size(); i++)
		ans += (a[i] == b[i]);
	cout << ans;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using PII = pair<int, int>;

int main() {
	int n;
	scanf("%d", &n);
	while (n--) {
		int x;
		scanf("%d", &x);
		if (x & 1) {
			puts("first");
			return 0;
		}
	}
	puts("second");
	return 0;
}


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

template<class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  
  return 0;
}

template<class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  
  return 0;
}

int main() {
  int N;
  long long W;
  cin >> N >> W;
  
  long long weight[110], value[110];
  for (int i = 0; i < N; ++i) {
    cin >> weight[i] >> value[i];
  }
  
  long long dp[110][110000] = {0};
  for (int i = 0; i < N; ++i) {
    for (int w = 0; w <= W; ++w) {
      if (w - weight[i] >= 0) {
        chmax(dp[i + 1][w], dp[i][w - weight[i]] + value[i]);
      }
      chmax(dp[i + 1][w], dp[i][w]);
    }
  }
  
  cout << dp[N][W] << endl;
}

Measured memory_bytes: 98140
#include <iostream>
#include <vector>
#include<algorithm>
#include <string>
#include<map>

using namespace std;


int main() {

	int d, t, s;
	cin >> d >> t>> s;
	if ((t*s) >= d) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

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

using namespace std;


typedef long long ll;
ll mod=1e9+0LL;
ll MOD=1e18+0LL;
double pi=acos(-1);
ll md=1000000007;
ll gcd(ll a,ll b){
    //if(b>a) swap(a,b);
    return b==0?abs(a):gcd(b,a%b);
}
ll pow(ll a ,ll n)
{
    if(n==0) return 1;
    if(n%2==0)
    {
        ll b=pow(a,n/2);
        return (b*b)%md;
    }
    return (pow(a,n-1)*a)%md;
}
int main()
{
    int cs=1;
    //scanf("%d",&cs);
    while(cs--)
    {
        int n,i,j,k,m,x;
        cin>>n>>m>>x;
        int a[n+1][m+1];
        for(i=0;i<n;i++)
        {
            for(j=0;j<=m;j++)
            {
                scanf("%d",&a[i][j]);
            }
        }
        int limit=1<<n;
        int minCost=12345678;
        for(k=0;k<limit;k++)
        {
            int cost=0;
            int sum[m+1];
            for(j=0;j<=m;j++) sum[j]=0;
            for(i=0;i<n;i++)
            {
                if(k & (1<<i))
                {//cout<<i<<" ";
                    cost+=a[i][0];
                    for(j=1;j<=m;j++)
                    {
                        sum[j]+=a[i][j];
                    }
                }
            }//cout<<endl;
            bool ok=1;
            for(j=1;j<=m;j++)
            {//cout<<sum[j]<<" ";
                if(sum[j]<x)
                {
                    ok=0;
                    break;
                }
            }
            if(ok)
            {//cout<<"             cost :: "<<cost<<endl;
                minCost=min(minCost,cost);
            }//cout<<endl;
        }
        if(minCost==12345678) minCost=-1;
        printf("%d",minCost);
    }
}


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

using namespace std;

long long poww (long long a)
{
	long long int f = 1;
	for (long long int i = 0; i < a; i++)
	{
		f *= 2;
	}
	return f;
}

const int maxn = 1e2 + 20;
long long n, p, a[maxn], o, e;

int main()
{
	cin >> n >> p;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	for (int i = 0; i < n; i++)
	{
		if (a[i] % 2 == 1)
		{
			o += 1;
		}
		else
		{
			e += 1;
		}
	}
	if (o - 1 < 0 && p == 1)
	{
		cout << 0;
		return 0;
	}
	cout << (long long) (poww (o-1)) * (long long) (poww (e));
	return 0;
}

Measured memory_bytes: 256
import sys
import numpy as np
import math
from collections import deque 
from functools import reduce

n, k = map(int, input().split())
p = [list(map(int, input().split()))]
p_n = np.array(p)
p_n.sort()
p_n = p_n.reshape(-1)
print(sum(p_n[:k]))


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

int main(){
    string s;cin>>s;
    int n=s.size()/2;
    for(int i=1;i<n;i++){
        bool flag=true;
        for(int j=0;j<n-i;j++){
            if(s[j]!=s[j+n-i]){
                flag=false;
                break;
            }
        }
        if(flag){
            int ans=s.size()-i*2;
            cout<<ans<<endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
#include<stdio.h>
#define int long long

int memo[100][100]={0};
int w,h;
int f(int x,int y){
    if(x==1&&y==1)return 1;
    if(x<=0||x>w||y<=0||y>h||memo[x][y]==-1)return 0;
    if(memo[x][y]!=0)return memo[x][y];
    return memo[x][y]=f(x-1,y)+f(x,y-1);
}
signed main(void){
    int x,y;
    int n;
    int i, j;
    while(1){
        for(i = 1; i <= 16; i++)
        {
            for(j = 1; j <= 16; j++)
            {
                memo[i][j] = 0;
            }
        }
        scanf("%lld %lld",&w,&h);
        if(h==0&&w==0)break;
        scanf("%lld",&n);
        for(i=0;i<n;i++){
            scanf("%lld %lld",&x,&y);
            memo[x][y]=-1;
        }
        printf("%lld\n",f(w,h));
    }
    return 0;
}

Measured memory_bytes: 616
a1=input()
a2=[i for i in a1.split()]
x,y=float(a2[0]),float(a2[1])
v,v1=x.is_integer(),y.is_integer()
if 1<=x<=20 and 1<=y<=20 and v==v1==True:
    if 1<=x<=9 and 1<=y<=9:
        print(int(x*y))
    else:
        print('-1')

Measured memory_bytes: 8800
def resolve():
    '''
    code here
    '''
    N, H = [int(item) for item in input().split()]
    ab = [[int(item) for item in input().split()] for _ in range(N)]
    ab.sort(reverse=True, key=lambda x:x[1])
    a_max_ab = max(ab, key=lambda x:x[0])

    cnt = 0    
    for a, b in ab:
        if b > a_max_ab[0]:
            H -= b
            cnt += 1
        
        if H <= 0:
            break

    if H > 0:
        cnt += H // a_max_ab[0]
        if H  % a_max_ab[0] != 0:
            cnt += 1

    print(cnt)


if __name__ == "__main__":
    resolve()


Measured memory_bytes: 26652
#include <bits/stdc++.h>
using namespace std;
#define REP(i,N) for(i=0;i<N;i++)
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

int main(void){
  int N,M;cin >> N >> M;
  int l=0,r=1e5;
  int i;REP(i,M){
    int x,y;cin >> x >> y;
    if(x>l) l=x;
    if(y<r) r=y;
  }
  if(r>=l) cout << r-l+1 << endl;
  else cout << 0 << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  int Q;
  cin >> Q;
  while(Q--){
    int c,a,n;
    cin >> c >> a >> n;
    int ans = 0 , mi = min(c,min(a,n));
    c -= mi , a -= mi;
    ans += mi;
    mi = min(c/2,a);
    c -= mi * 2;
    ans += mi + c / 3;
    cout << ans << endl;
  }
}

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

const int MAXN = 305;
double dp[MAXN][MAXN][MAXN];


int n;

double calc(int a, int b, int c)
{
    if (a == 0 && b == 0 && c == 0) return 0;
    double& x = dp[a][b][c];
    if (abs(x - 0) > 1e-9) return x;
    double m = (a + b + c);
    x = n / m;
    if (a) x += a/m * calc(a-1, b, c);
    if (b) x += b/m * calc(a+1, b-1, c);
    if (c) x += c/m * calc(a, b+1, c-1);
    return x;
}

int a[3];
int main()
{
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        int x;
        cin >> x;
        a[x-1]++;
    }

    cout << setprecision(15) << fixed << calc(a[0], a[1], a[2]);
    return 0;
}


Measured memory_bytes: 219392
N = int(input())
A = [int(input()) for _ in range(N)]

left = [-1 for _ in range(N)]
right = [-1 for _ in range(N)]

left[0] = A[0]
for i in range(N-1):
    left[i+1] = max(left[i], A[i+1])

right[-1] = A[-1]
for i in reversed(range(N-1)):
    right[i] = max(right[i+1], A[i])

for i in range(N):
    if i == 0:
        print(right[1])
    elif i == N-1:
        print(left[-2])
    else:
        print(max(left[i-1], right[i+1]))


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

class MyClass
{
    public static void Main(string[] args)
    {
        var N = int.Parse(Console.ReadLine());
        var a = Console.ReadLine().Split().Select(int.Parse).ToArray();

        var count = 0;
        for (int i = 0; i < N; i++)
        {
            var minj = i;
            for (int j = i; j < N; j++)
            {
                if (a[j] < a[minj])
                {
                    minj = j;
                }
            }
            if (i != minj)
            {
                var t = a[i];
                a[i] = a[minj];
                a[minj] = t;
                count++;
            }
        }
        Console.WriteLine(string.Join(" ", a));
        Console.WriteLine(count);
    }
}


Measured memory_bytes: 18264
n,m,q=map(int,input().split())
L=[list(map(int,input().split())) for i in range(q)]

R=0
for a in range(m):
    for b in range(a,m):
        for c in range(b,m):
            for d in range(c,m):
                for e in range(d,m):
                    for f in range(e,m):
                        for g in range(f,m):
                            for h in range(g,m):
                                for i in range(h,m):
                                    for j in range(i,m):
                                        A=[a+1,b+1,c+1,d+1,e+1,f+1,g+1,h+1,i+1,j+1]
                                        r=0
                                        for k in range(q):
                                            if A[L[k][1]-1]-A[L[k][0]-1]==L[k][2]:
                                                r+=L[k][3]
                                        R=max(R,r)
print(R)

Measured memory_bytes: 73112
N,M=map(int,input().split())
MOD=10**9+7

fac=[0]*(1+max(N,M))
fac[1]=1

for i in range(2, len(fac)):
	fac[i] = i * fac[i-1] % MOD

ans = fac[N] * fac[M] % MOD

if abs(N-M) > 1:
	ans = 0
elif N==M:
	ans = ans * 2 % MOD

print(ans)


Measured memory_bytes: 6900
import java.util.*;
import java.io.*;

public class Main {	
	private static void solve(){
		//Implement solution here.
		int N = ni();
		if(N % 10 == 3) {
			System.out.println("bon");
		} else if(N % 10 == 0 || N % 10 == 1 || N % 10 == 6 || N % 10 == 8) {
			System.out.println("pon");
		} else {
			System.out.println("hon");
		}
	}

	//Switch input source (stdin/file)
	private static BufferedReader br;
	public static void main(String[] args){
		br = new BufferedReader(new InputStreamReader(System.in));
		String debugDataPath = System.getenv("DD_PATH");        
		if(debugDataPath != null){
			try{
				br = new BufferedReader(new InputStreamReader(new FileInputStream(new File(debugDataPath))));
			}catch(Exception e){
				throw new RuntimeException(e);
			}
		}
		boolean hasNext = true;
		while(hasNext){
			solve();	
			try{
				br.mark(1);
				if(br.read() > 0){
					br.reset();			
					System.out.println("---");
				} else {
					hasNext = false;
				}
			}catch(Exception e){
				throw new RuntimeException(e);
			} 
		}
	}

	//Input read utility
	private static StringTokenizer tokenizer = null;
	public static String next() {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(br.readLine());
			} catch (Exception e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}
	//Get next single int
	private static int ni() {
		return Integer.parseInt(next());
	}
	//Get next single long
	private static long nl() {
		return Long.parseLong(next());
	}
	//Get next single double
	private static double nd() {
		return Double.parseDouble(next());
	}
	//Get next int array from one line
	private static int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}
	//Get next char array from one line
	private static char[] ns() {
		return next().toCharArray();
	}
	//Get next long array from one line
	private static long[] nal(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nl();
		return a;
	}
}


Measured memory_bytes: 25416
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<string> vs;
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<int, int> pii;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<pii> vpii;
typedef vector<vpii> vvpii;

inline bool valid(int x, int n) {
    return 0 <= x && x < n;
}

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

template <typename T>
inline T pop(queue<T>& q) {
    T front = q.front();
    q.pop();
    return front;
}

template <typename T>
inline T gcd(T a, T b) {
    for (; b; a %= b, swap(a, b));
    return a; 
}

template <typename T>
tuple<T, T, T> xgcd(T a, T b) {
    if (b == 0) return {1, 0, a};
    T x, y, g;
    tie(x, y, g) = xgcd(b, a%b);
    return {y, x-(a/b)*y, g};
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);

    ll a, b, c, k; cin >> a >> b >> c >> k;
    if (k <= a) {
        cout << k;
        return 0;
    }

    if (a+b >= k) {
        cout << a;
        return 0;
    }

    cout << a - (k-a-b);
}


Measured memory_bytes: 3652
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		char[] c = S.toCharArray();
		int N = S.length();
		int cnt = 0;
		for(int i = 0 ; i < N - 1 ; i++) {
			if(c[i] != c[i + 1]) {
				cnt++;
			}
		}
		System.out.println(cnt);
	}
}


Measured memory_bytes: 26148
N = input()
#for i in range(1000,10000):
    #print(i)
    #N = str(i)
if N[0] == N[1] == N[2] == '1':
    print('Yes')
elif N[0] == N[1] == N[2] == '2':
    print('Yes')
elif N[0] == N[1] == N[2] == '3':
    print('Yes')
elif N[0] == N[1] == N[2] == '4':
    print('Yes')
elif N[0] == N[1] == N[2] == '5':
    print('Yes')
elif N[0] == N[1] == N[2] == '6':
    print('Yes')
elif N[0] == N[1] == N[2] == '7':
    print('Yes')
elif N[0] == N[1] == N[2] == '8':
    print('Yes')
elif N[0] == N[1] == N[2] == '9':
    print('Yes')
elif N[1] == N[2] == N[3] == '0':
    print('Yes')
elif N[1] == N[2] == N[3] == '1':
    print('Yes')
elif N[1] == N[2] == N[3] == '2':
    print('Yes')
elif N[1] == N[2] == N[3] == '3':
    print('Yes')
elif N[1] == N[2] == N[3] == '4':
    print('Yes')
elif N[1] == N[2] == N[3] == '5':
    print('Yes')
elif N[1] == N[2] == N[3] == '6':
    print('Yes')
elif N[1] == N[2] == N[3] == '7':
    print('Yes')
elif N[1] == N[2] == N[3] == '8':
    print('Yes')
elif N[1] == N[2] == N[3] == '9':
    print('Yes')
else:
    print('No')




Measured memory_bytes: 3188
/*  ex4_2
    yy8332  */

#include <stdio.h>
#include <math.h>


int main(void){
  double lengthA, lengthB, hour, minute, theta, ans;

  //入力読み取り
  scanf("%lf %lf %lf %lf",&lengthA, &lengthB ,&hour ,&minute);

  //角度計算
  theta = (((hour + minute / 60) * 30 - minute * 6) / 180) * M_PI;

  //長さ計算
  ans = pow(lengthA, 2.0) + pow(lengthB, 2.0) - 2 * lengthA * lengthB * cos(theta);

  ans = sqrt(ans);


  //出力
  printf("%.10f",ans);


  return 0;
}


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

#define lint long long
#define P pair<int, int>
#define LLP pair<long long, long long>
#define REP(i, x, n) for(int i = (x), i##_len = int(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = int(n) ; i < i##_len ; ++i)
#define reps(i, n) for(int i = 1, i##_len = int(n) ; i <= i##_len ; ++i)
#define rrep(i, n) for(int i = int(n) - 1 ; i >= 0 ; --i)
#define rreps(i, n) for(int i = int(n) ; i > 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())

const int IINF = (1 << 30) - 1;
const long long LLINF = 1LL << 61;
const long long MOD = 1000000007LL;
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};
const double EPS = 1e-8;

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

    int p, q, r;
    cin >> p >> q >> r;
    cout << min({p + q, q + r, r + p}) << endl;

    return 0;
}

Measured memory_bytes: 256
//#pragma GCC optimize("Ofast")
#include <set>
#include <map>
#include <cmath>
#include <stack>
#include <queue>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#define endl '\n'
#define fast ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define zy 2333333
#define bql 2147483647
using namespace std;
int n,ans;
int main()
{
	fast;
	cin>>n;
	for (int i=1;i<=n;i++)
	   if (i<=9)
	   {
	   	  ans++;
	   }
	   else if (i>=100 && i<=999)
	   {
	   	   ans++;
	   }
	   else if (i>=10000 && i<=99999)
	   {
	   	   ans++;
	   }
	cout<<ans<<endl;
	return 0;
}

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

//template
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll; typedef pair<ll, ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename A,size_t N,typename T>void Fill(A(&array)[N],const T &val){fill((T*)array, (T*)(array+N), val);}
const int inf = INT_MAX / 2; const ll INF = LLONG_MAX / 2;
const int mod = 998244353; //1e9+7;
struct Mint {
   int val;
   Mint inv() const {
       int tmp, a = val, b = mod, x = 1, y = 0;
       while(b) tmp = a / b, a -= tmp * b, swap(a, b), x -= tmp * y, swap(x, y);
       return Mint(x);
   }
public:
   Mint() :val(0) {}
   Mint(ll x) :val(x >= 0 ? x % mod : x % mod + mod) {}
   int mtoi() { return this->val; }
   Mint pow(ll t) { Mint res = 1; while(t){if(t&1)res *= *this;*this *= *this;t >>= 1;}return res; }
   Mint& operator+=(const Mint& x) { if ((val += x.val) >= mod) val -= mod; return *this; }
   Mint& operator-=(const Mint& x) { if ((val += mod - x.val) >= mod) val -= mod; return *this; }
   Mint& operator*=(const Mint& x) { val = (ll)val * x.val % mod; return *this; }
   Mint& operator/=(const Mint& x) { return *this *= x.inv(); }
   bool operator==(const Mint& x) const { return val == x.val; }
   bool operator!=(const Mint& x) const { return val != x.val; }
   bool operator<(const Mint& x) const { return val < x.val; }
   bool operator<=(const Mint& x) const { return val <= x.val; }
   bool operator>(const Mint& x) const { return val > x.val; }
   bool operator>=(const Mint& x) const { return val >= x.val; }
   Mint operator+(const Mint& x) const { return Mint(*this) += x; }
   Mint operator-(const Mint& x) const { return Mint(*this) -= x; }
   Mint operator*(const Mint& x) const { return Mint(*this) *= x; }
   Mint operator/(const Mint& x) const { return Mint(*this) /= x; }
};
struct factorial {
   vector<Mint> Fact, Finv;
public:
   factorial(int maxx) {
       Fact.resize(maxx+1,Mint(1)),Finv.resize(maxx+1); rep(i,0,maxx)Fact[i+1]=Fact[i]*Mint(i+1);
       Finv[maxx]=Mint(1)/Fact[maxx]; rrep(i,maxx,0)Finv[i-1]=Finv[i]*Mint(i);
   }
   Mint fact(int n,bool inv) { if(inv) return Finv[n]; else return Fact[n]; }
   Mint nPr(int n,int r) { if(n<0||n<r||r<0) return Mint(0); else return Fact[n]*Finv[n-r]; }
   Mint nCr(int n,int r) { if(n<0||n<r||r<0) return Mint(0); else return Fact[n]*Finv[r]*Finv[n-r]; }
};
//template end



int main(){
   int a,b,c; cin>>a>>b>>c;
   printf("%d\n",max(0,b+c-a));
   return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long; 
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
//constexpr long long MOD = 998244353LL;
template<class T, class U> inline bool chmax(T &a, U b) { if (a < b) { a = b; return true;} return false; }
template<class T, class U> inline bool chmin(T &a, U b) { if (a > b) { a = b; return true;} return false; }
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 
int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    
    int H, W; cin >> H >> W;
    char c[H][W];
    rep(i,H){
        rep(j,W){
            cin >> c[i][j];
        }
    }
    
    rep(i,H){
        rep(j,W){
            cout << c[i][j];
        }
        cout << ln;
        rep(j,W){
            cout << c[i][j];
        }
        cout << ln;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  char s[110];
  set<char> t;
  for(int i=0; i<n; i++){
    cin >> s[i];
    t.insert(s[i]);
  }
  if(t.count('Y')){
    cout << "Four" << endl;
  }
  else cout << "Three" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define MOD 1000000007
#define EPS (1e-10)
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

int a[200000];
int main(){
	int n;cin>>n;
	int g;
	rep(i,n){
		scanf("%d",&a[i]);
		if(i==0){
			g=a[i];
		}
		else g=__gcd(g,a[i]);
	}
	cout<<g<<endl;
}

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

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second

template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> pip;

const ll INF = 1ll<<29;
const ll MOD = 1000000007;
const double EPS  = 1e-10;

int main() {
	int n;
	while (cin >> n, n) {
		int msum = -1, mp = -1;
		REP(i, n) {
			int p, d1, d2;
			scanf("%d %d %d", &p, &d1, &d2);
			int sum = d1 + d2;
			if (chmax(msum, sum)) mp = p;
		}
		printf("%d %d\n", mp, msum);
	}
	return 0;
}

Measured memory_bytes: 3200
def get_input():
    while True:
        try:
            yield ''.join(input())
        except EOFError:
            break

table = [[0 for i in range(100)] for j in range(100)]
L = list(get_input())
N = len(L) // 2 + 1

for l in range(N):
    points = [int(i) for i in L[l].split(",")]
    for i in range(len(points)):
        table[len(points)-i-1][i] = points[i]

for l in range(N, 2*N-1):
    #print(l)
    points = [int(i) for i in L[l].split(",")]
    for i in range(len(points)):
        #print(len(points)-i-1+(l-N+1),i+(l-N+1))
        table[len(points)-i-1+(l-N+1)][i+(l-N+1)] = points[i]


for c in range(1,2*N):
    for i in range(c):
        if c-i-2 < 0:
            table[c-i-1][i] += table[c-i-1][i-1]
        elif i-1 < 0:
            table[c-i-1][i] += table[c-i-2][i]
        else:
            table[c-i-1][i] += max(table[c-i-2][i], table[c-i-1][i-1])

#for i in range(N):
#    for j in range(N):
#        print(table[i][j], end=" ")
#    print("")

print(table[N-1][N-1])


Measured memory_bytes: 5700
#include <bits/stdc++.h>
#define int long long
using namespace std;
int32_t main(){
	int n;cin>>n;
	vector<int> mva;
	for(int i=0;i<n+1;i++){
		int t;cin>>t;
		mva.push_back(t);
	}
	vector<int> mvb;
	for(int i=0;i<n;i++){
		int t;cin>>t;
		mvb.push_back(t);
	}
	int sum=0;
	for(int i=0;i<n;i++){
		int b=mva[i];
		int a=mvb[i];
		sum+=a-b>=0?b:a;
		if(a-b>0){
			a=a-b;
			b=mva[i+1];
			sum+=a-b>=0?b:a;
			mva[i+1]=b-a>0?b-a:0;
		}
	}
	cout<<sum<<endl;
	return 0;
}


Measured memory_bytes: 2548
#abc047 b
w,h,n=map(int,input().split())
zahyo=[]
a=[]
for i in range(n):
    x,y,z=map(int,input().split())
    zahyo.append([x,y])
    a.append(z)
l=[0,0]
r=[w,h]

def white(i):
    if a[i]==1:
        if l[0]<zahyo[i][0]:
            l[0]=zahyo[i][0]
    elif a[i]==2:
        if r[0]>zahyo[i][0]:
            r[0]=zahyo[i][0]
    elif a[i]==3:
        if l[1]<zahyo[i][1]:
            l[1]=zahyo[i][1]
    else:
        if r[1]>zahyo[i][1]:
            r[1]=zahyo[i][1]
#塗りつぶされてるときある

for i in range(n):
    white(i)

yoko=r[0]-l[0]
tate=r[1]-l[1]
ans=0
if yoko>=0 and tate>=0:# マイナスxマイナスを含めない
    ans=yoko*tate
print(ans)

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

int main(){
    int n;
    cin >> n;
    vector<int> a(n), b(2020, 0);
    for(int i=0; i<n; i++){
        cin >> a[i];
        b[a[i]] = 1;
    }
    int m;
    cin >> m;
    for(int i=0; i<m; i++){
        int c;
        cin >> c;
        c--;
        if(a[c]!=2019 and b[a[c]+1]==0){
            b[a[c]] = 0;
            a[c]++;
            b[a[c]] = 1;
        }
    }
    for(int i=0; i<n; i++){
        cout << a[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 3108
#include<stdio.h>
int main(){

	int data[3000][2]={},i,last,task;
	for(i=0;i<=3000;i++){
		scanf("%d %d",&data[i][0],&data[i][1]);
		if(data[i][0]==0 && data[i][1]==0){
			last=i-1;
			break;

		}else{
			if(data[i][0] >= data[i][1]){
				task=data[i][0];
				data[i][0]=data[i][1];
				data[i][1]=task;
			}
		}
	}

	for(i=0;i<=last;i++){
		printf("%d %d\n",data[i][0],data[i][1]);
	}
	return 0;
	
}

Measured memory_bytes: 1756
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <bitset>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <queue>

#define mp make_pair
#define pb push_back


typedef long long ll;
typedef long double ld;

using namespace std;

const int MAXN = 220000;
int a[MAXN];
int ttt[MAXN];
int n;

int check(int x) {
	for (int i = 0; i < 2 * n - 1; ++i)
		a[i] = (ttt[i] <= x ? 0 : 1);
	int l = 0;
	int r = 2 * n - 1;
	for (int i = 1; i < n; ++i)
		if (a[i] == a[i - 1])
			l = max(l, i);
	for (int i = 2 * n - 2; i >= n - 1; --i)
		if (a[i] == a[i + 1])
			r = min(r, i);
	if (abs(n - 1 - l) > abs(n - 1 - r))
		return a[r] == 0;
	else
		return a[l] == 0;

}

int main() {
	cin >> n;
	for (int i = 0; i < 2 * n - 1; ++i)
		cin >> ttt[i];
	int lb = 0;
	int rb = 2 * n - 1;
	while (rb - lb > 1) {
		int mid = (lb + rb) >> 1;
		if (check(mid))
			rb = mid;
		else
			lb = mid;
	}
	cout << rb << "\n";
	return 0;
}




Measured memory_bytes: 1920
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#include <math.h>
#include <assert.h>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <iostream>
#include <functional>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <bitset>

using namespace std;
typedef pair<int, int> Pi;
typedef long long ll;
#define pii Pi
#define pll PL
#define Fi first
#define Se second
#define pb(x) push_back(x)
#define sz(x) ((int)(x).size())
#define rep(i, n) for(int i=0;i<n;i++)
#define all(x) (x).begin(), (x).end()
typedef tuple<int, int, int> t3;
typedef pair<ll, ll> PL;
typedef long double ldouble;

int p[30][51];
int n;

void solve(){
	scanf("%d", &n);
	rep(i, n){
		string s; cin >> s;
		for(char e : s)p[e - 'a'][i]++;
	}
	rep(i, 26){
		int t = *min_element(p[i], p[i]+n);
		rep(j, t)printf("%c", i+'a');
	}
	puts("");
}

int main(){
	int Tc = 1; // scanf("%d\n", &Tc);
	for(int tc=1;tc<=Tc;tc++){
		// printf("Case #%d: ", tc);
		solve();
	}
}

Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
#include <sstream>
#include <iomanip>
#include <set>
#include <stack>
#include <cassert>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vvb> vvvb;
typedef vector<vvvb> vvvvb;
typedef vector<string> vs;
typedef vector<vs> vvs;
typedef vector<vvs> vvvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<vvd> vvvd;
typedef pair<ll, ll> PL;
typedef vector<PL> vpl;
typedef vector<vector<PL>> vvpl;
const int INF = 1001001001;
const ll LINF = 1e17;
const double pi = 3.1415926535897932;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define RFOR(i, a, b) for(ll i = (a); i > b; i--)
#define rep(i, n) for(ll i = 0; i < n; i++)
#define rrep(i, n) for(ll i = n-1; i > -1; i--)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)
#define ff first
#define ss second
#define pb push_back
#define epb emplace_back
#define ALL(X) (X).begin(),(X).end()

template <typename T>
T gcd(T a, T b) {
    return (a == 0) ? b : gcd(b%a, a);
}
template <typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

bool p_comp_fs(const PL p1, const PL p2){ return p1.first < p2.first;};
bool p_comp_fg(const PL p1, const PL p2){ return p1.first > p2.first;};
bool p_comp_ss(const PL p1, const PL p2){ return p1.second < p2.second;};
bool p_comp_sg(const PL p1, const PL p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec){
    sort(ALL(vec));
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}

inline ll popcnt(ll x){return __builtin_popcountll((unsigned long long)x);};
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
//friend bool operator<(const stc& lhs, const stc& rhs){
//    return std::tie(lhs.l, lhs.r) < std::tie(rhs.l, rhs.r);
//}



int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    ll M, D; cin >> M >> D;
    
    ll ans = 0;
    FOR(m, 1, M+1) FOR(d, 1, D+1){
        ll d1 = d%10, d10 = d/10;
        if(d1 < 2 || d10 < 2) continue;
        if(d1 * d10 == m) ans++;
    }
    cout << ans << endstr;
    return 0;
}


Measured memory_bytes: 256
//#pragma warning(disable:4996)
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>
#include <complex>
#include <cstdio>
#include <list>
#include <bitset>
//#include <stdio.h>

//< in.txt > out.txt
using namespace std;
//std::ios::sync_with_stdio(false);
//std::cin.tie(0);
const long long MOD = 1e9 + 7;
const long long INF = 1e15;
typedef long long LL;
typedef long double LD;
//typedef boost::multiprecision::cpp_int bigint;
typedef pair<LL, LL> PLL;
typedef pair<int, int> PI;
typedef pair<LD, LL> pdl;
typedef pair<LD, LD> pdd;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef unsigned long long ULL;

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	int N, K;
	cin >> N >> K;
	VI count(200000 + 1, 0);
	for (int n = 0; n < N; n++) {
		int A;
		cin >> A;
		count[A]++;
	}
	VI str;
	for(int n = 0;n < 200000;n++){
		if (count[n] != 0)str.push_back(count[n]);
	}
	sort(str.begin(), str.end(), [](int a, int b) {
		return a > b;
	});
	int ans = 0;
	for (int n = min(K, (int)str.size()); n < str.size(); n++) {
		ans += str[n];
	}
	cout << ans << "\n";
	return 0;
}


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

using namespace std;

typedef long long ll;

const int N=15,M=1010;
int s[N][M];
char str[N][M];
int arr[N];
int main() {
    int n, m, t;
    cin >> n >> m >> t;
    int ans = 1e9;
    for (int i = 1; i <= n; i++) scanf("%s", str[i]);
    for (int i = 1; i <= n; i++) {
        for (int j = 0; j < m; j++) s[i][j + 1] = str[i][j] - '0';
    }
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            s[i][j] += s[i - 1][j] + s[i][j - 1] - s[i - 1][j - 1];
        }
    }
    for (int i = 0; i < (1 << (n - 1)); i++) {
        memset(arr, 0, sizeof(arr));
        vector<int> p;
        int cnt1 = 0;
        int cnt2 = 0;
        p.push_back(0);
        for (int j = 0; j < n - 1; j++) if (i >> j & 1) p.push_back(j + 1), cnt1++;
        p.push_back(n);
        int now[N];
        bool st = true;
        for (int j = 1; j <= m; j++) {
            for (int k = 1; k < p.size(); k++) now[k] = s[p[k]][j] - s[p[k - 1]][j] - s[p[k]][j - 1] + s[p[k - 1]][j - 1];
            bool h = false;
            for (int k = 1; k < p.size(); k++) {
                if (arr[k] + now[k] > t) {
                    h = true;
                    break;
                }
            }
            if (h != 0) {
                cnt2++;
                for (int k = 1; k < p.size(); k++) {
                    arr[k] = now[k];
                    if (now[k] > t) {
                        st = false;
                        break;
                    }
                }
            } else for (int k = 1; k < p.size(); k++) arr[k] += now[k];
        }
        if (st != 0) ans = min(ans, cnt1 + cnt2);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define per(i, n) for(ll i=((ll)(n))-1; i>=0; i--)
#define perf(i, n) for(ll i=((ll)(n)); i>0; i--)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
template<class T>bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    ll n, maxt = 0, cnt = 0; cin >> n;
    rep(i, n){
        ll h; cin >> h;
        if(h>=maxt){
            cnt++;
            maxt = h;
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
long long int n,ans=0;
cin>>n;
long long int a[n+1],b[n];
long long int i;
for(i=0;i<=n;i++)
cin>>a[i];
for(i=0;i<n;i++)
cin>>b[i];
for(i=0;i<n;i++)
{
if(a[i]>0)
{
ans+=min(a[i],b[i]);
b[i]-=min(a[i],b[i]);
}
if(b[i]>0)
{
ans+=min(b[i],a[i+1]);
a[i+1]-=min(a[i+1],b[i]);
}
}
cout<<ans;
return 0;
}

Measured memory_bytes: 1792
#include<cstdio>
unsigned short N,A,B,sum,temp;
int total;
int main(){
	scanf("%hu%hu%hu",&N,&A,&B);
	for(short a=1;a<=N;a++){
		sum=0;
		temp=a;
		while(temp>0){
			sum+=temp%10;
			temp/=10;
		}
		if(sum>B){
			a+=9-a%10;
			continue;
		}
		if(sum<A)continue;
		total+=a;
	}
	printf("%d\n",total);
}

Measured memory_bytes: 128
#include<iostream>
using namespace std;
int main(){
	int n, count[6];
	for(int i=0; i<6; i++) count[i]=0;
	double student;
	cin >> n;
	for(int i=0; i<n; i++){
		cin >> student;
		if(student < 165.0) count[0]++;
		if(student >= 165.0 && student < 170.0) count[1]++;
		if(student >= 170.0 && student < 175.0) count[2]++;
		if(student >= 175.0 && student < 180.0) count[3]++;
		if(student >= 180.0 && student < 185.0) count[4]++;
		if(student >= 185.0) count[5]++;
	}
	for(int i=0; i<6; i++){
		cout << i+1 << ":";
		if(count[i] != 0){
			for(int j=0; j<count[i]; j++)
				cout << "*";
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

vector<vector<ll>>a(100010);
vector<vector<ll>>c(100010);
ll p[100010];
bool ans=true;
void dep(ll now,ll oya,ll co){
	if(p[now]!=INF){
		if(p[now]!=co){
			ans=false;
		}
		return ;
	}
	p[now]=co;
	if(a[now].size()==1&&a[now][0]==oya){
		return;
	}
	for(int i=0;i<a[now].size();i++){
		ll next=a[now][i];
		dep(next,now,co+c[now][i]);
	}
}
int main() {
	ll n,m;
	cin>>n>>m;
	for(int i=0;i<100010;i++){
		p[i]=INF;
	}
	for(int i=0;i<m;i++){
		ll x,y,z;
		cin>>x>>y>>z;
		x--,y--;
		a[x].push_back(y);
		c[x].push_back(z);
		a[y].push_back(x);
		c[y].push_back(-1*z);
	}
	for(int i=0;i<n;i++){
		if(p[i]!=INF){
			continue;
		}
		dep(i,-1,0);
	}
	cout << (ans?"Yes":"No");
	// your code goes here
	return 0;
}

Measured memory_bytes: 20864
n, A, B, C = map(int, input().split())
l = [int(input()) for _ in range(n)]


def bfs(i, a, b, c):
    if i == n:
        if a < 1 or b < 1 or c < 1:
            return 10 ** 18
        return abs(A - a) + abs(B - b) + abs(C - c)
    res = bfs(i + 1, a, b, c)
    res = min([res, bfs(i + 1, a + l[i], b, c) + (10 if a > 0 else 0)])
    res = min([res, bfs(i + 1, a, b + l[i], c) + (10 if b > 0 else 0)])
    res = min([res, bfs(i + 1, a, b, c + l[i]) + (10 if c > 0 else 0)])
    return res


print(bfs(0, 0, 0, 0))


Measured memory_bytes: 3064
import java.io.*;
import java.util.*;
import static java.lang.System.out;

public class Main {
    static MyReader in = new MyReader();

    public static void main(String[] args) {
        int N = in.i();
        int[] sum = new int[N];

        long ans = 0;
        for (int i = 0; i < N; i++) {
            int a = in.i();
            int b = in.i();
            sum[i] = a + b;
            ans += -b;
        }
        Arrays.sort(sum);

        for (int i = N - 1; i >= 0; i -= 2) {
            ans += sum[i];
        }
        
        out.println(ans);
    }
}

class MyReader extends BufferedReader {
    char[] cbuf = new char[1024];
    int head = 0;
    int tail = 0;

    MyReader() {
        super(new InputStreamReader(System.in));
    }

    char next() {
        if (head == tail) {
            try {
                tail = super.read(cbuf, 0, cbuf.length);
            } catch (IOException e) {
                e.printStackTrace();
            }
            head = 0;
        }
        return cbuf[head++];
    }

    void back() {
        head--;
    }

    boolean minus() {
        boolean minus;
        while (true) {
            char c = next();
            if (!isDelimiter(c)) {
                if (!(minus = c == '-')) back();
                return minus;
            }
        }
    }

    void skip() {
        while (isDelimiter(next()));
        back();
    }

    char[] s(int N) {
        char[] cbuf = new char[N];
        read(cbuf, 0, N);
        return cbuf;
    }

    public int read(char[] cbuf, int off, int len) {
        skip();
        int i;
        for (i = 0; i < cbuf.length; i++) {
            char c = next();
            if (isDelimiter(c)) {
                break;
            }
            cbuf[i] = c;
        }
        return i;
    }

    boolean isDelimiter(char c) {
        return c == ' ' || c == '\n' || c == '\r';
    }

    int i() {
        boolean minus = minus();
        int n = 0;
        while (true) {
            int k = next() - '0';
            if (k < 0 || 9 < k) break;
            n = 10 * n + k;
        }
        return minus ? -n : n;
    }

    int[] ii(final int N) {
        int[] a = new int[N];
        for (int j = 0; j < a.length; j++) a[j] = i();
        return a;
    }

    long l() {
        boolean minus = minus();
        long n = 0;
        while (true) {
            int k = next() - '0';
            if (k < 0 || 9 < k) break;
            n = 10 * n + k;
        }
        return minus ? -n : n;
    }
}


Measured memory_bytes: 36760
using System;
using System.Collections.Generic;
using System.Linq;
 
public class B {
    public static void Main(){
        string line = Console.ReadLine();
        string unit = "x";
        string ans = "";
        for (int i=0;i<line.Length;i++)
        {
            ans += unit;
        }
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 11092