akhauriyash/Code-Regression huggingface dataset:
def main():
    n,k = map(int, input().split())
    mod = 10**9 + 7
    ans = 0

    def nkr(x,y):
        low = (y-1)*y // 2
        high = ( x*(x+1) - (x-y)*(x-y+1) ) // 2
        return max(high - low,0) + 1

    ans = 0
    for i in range(k,n+2):
        ans += nkr(n,i)
    print(ans % mod)

if __name__ == '__main__':
    main()

Measured memory_bytes: 64136
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        char[] abcd = sc.next().toCharArray();
        for (int i = 0; i < 1 << abcd.length - 1; i++) {
            int ii = abcd[0] - 48;
            char[] op = new char[3];
            for (int j = 0; j < abcd.length - 1; j++) {
                int n = abcd[j + 1] - 48;
                if ((1 & i >> j) == 1) {
                    ii += n;
                    op[j] = '+';
                } else {
                    ii -= n;
                    op[j] = '-';
                }
            }
            if (ii == 7) {
                System.out.printf("%c%c%c%c%c%c%c=7\n", abcd[0], op[0], abcd[1], op[1], abcd[2], op[2], abcd[3]);
                return;
            }
        }
    }
}


Measured memory_bytes: 23764
N, L = map(int, input().split())
l = []
for i in range(N):
    l.append(L+i)
ll = min(list(map(abs, l)))

Min = L
Max = L+N-1
if (Min>0 and Max>0):
    l.remove(ll)
    print(sum(l))
elif Min < 0 and Max < 0:
    l.remove(-1*ll)
    print(sum(l))
else:
    print(sum(l))

Measured memory_bytes: 3064
import java.util.*;

public class Main {
    public static void main(String args[]) {
        Scanner scn = new Scanner(System.in);
        int n = scn.nextInt();
        int w = scn.nextInt();
        int[][] wav = new int[n+1][3]; //1 weight 2 value
        for(int i=1;i<=n;i++){
            wav[i][1] = scn.nextInt();
            wav[i][2] = scn.nextInt();
        }
        // System.out.println(1e5+1);
        //jth col ki val using 1...ith elemnets min in how much weight
        long[][] dp = new long[n+1][(int)(1e5+1)];
        for(int i=1;i<=n;i++){
            for(int val=1;val<=(int)Math.pow(10,5);val++){
                if(i==1){
                    dp[i][val] = (wav[1][2]==val?wav[1][1]:(int)1e9+1);
                }else{
                    long o1 = wav[i][2] <= val ? dp[i-1][val-wav[i][2]] + wav[i][1] : (int)1e9;
                    long o2 = dp[i-1][val];
                    dp[i][val] = Math.min(o1,o2);
                }
            }
        }
        
        long ans = 0;
        for(int val=1;val<=(int)1e5;val++){
            if(dp[n][val]<=w){
                ans = Math.max(ans,val);
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 134116
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main() {
	string str;
	int q = 0;
	string command;
	int a = 0, b = 0;
	string p;
	string answer;

	cin >> str;

	cin >> q;
	for (int i = 0; i < q; i++) {
		cin >> command >> a >> b;
		if (command == "print") {
			answer = str.substr(a, b - a + 1);
			cout << answer << endl;
		}
		else if (command == "reverse") {
			reverse(str.begin() + a, str.begin() + b + 1);
		}
		else {
			cin >> p;
			str.replace(a, b - a + 1, p);
		}
	
	}

}


Measured memory_bytes: 3208
#include <stdio.h>
#include<cmath>
using namespace std;
 
int main(){
    double x1,x2,x3,x4,y1,y2,y3,y4;
    int n;
    scanf("%d",&n);
    for(int i=0; i<n; i++){
        scanf("%lf %lf %lf %lf %lf %lf %lf %lf",&x1,&y1,&x2,&y2,&x3,&y3,&x4,&y4);
 
        if(abs((y2 - y1)*(x4 - x3) - (y4 - y3)*(x2 - x1) ) < 0.0000000001){ //I copied yutaka watabe's code here
            printf("YES\n");
        }else{
            printf("NO\n");
        }
 
    }
    return 0;
}




Measured memory_bytes: 2696
#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>

// using namespace __gnu_pbds;
using namespace std;

#define fbo find_by_order
#define ook order_of_key
#define fi first
#define se second
#define long long long
typedef pair<int,int> ii;
typedef pair<int,ii> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
// typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

int main()
{
	// freopen("input.in", "r", stdin);

 	string s, t, u;		
	cin >> s >> t;
	int a, b; cin >> a >> b;
	cin >> u;

	if(u == s) a--;
	if(u == t) b--;
	cout << a << " " << b << "\n";
}

Measured memory_bytes: 256
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations,permutations,accumulate # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#
# my_round_int = lambda x:np.round((x*2 + 1)//2)
# 四捨五入
import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
n = I()
S = input()
ans = 0
for i in range(1000):
    nya = str(i).zfill(3)
    x = S.find(nya[0])
    y = S.find(nya[1], x+1)
    z = S.find(nya[2], y+1)
    if x != -1 and y != -1 and z != -1:
        ans += 1
print(ans)


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

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

  if (S.at(2) == S.at(3) && S.at(4) == S.at(5)) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}


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

using namespace std;

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

	int a[4][13] = {};
	string design;
	int num;
	
	for (int i = 0; i < n; i++) {
		cin >> design >> num;
		if (design == "S")
			a[0][num - 1] = 1;
		else if (design == "H")
			a[1][num - 1] = 1;
		else if (design == "C")
			a[2][num - 1] = 1;
		else if (design == "D")
			a[3][num - 1] = 1;
	}
	
	for (int j = 0; j < 4; j++) {
		for (int k = 0; k < 13; k++) {
			if (a[j][k] == 0) {
				if (j == 0)
					cout << "S " << k + 1 << endl;
				else if (j == 1)
					cout << "H " << k + 1 << endl;
				else if (j == 2)
					cout << "C " << k + 1 << endl;
				else if (j == 3)
					cout << "D " << k + 1 << endl;
			}
		}
	}

	return 0;
}


Measured memory_bytes: 3088
#include <iostream>
using namespace std;
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#define MOD1 1000000007
#define MOD2 998244353
#define LIMIT1 200002
#define LIMIT2 500002
typedef long long ll;
typedef long double ld;
typedef const void cv;
#define rep(i,n) for((i)=0;(i)<(n);(i)++)
#define per(i,n) for((i)=(n)-1;(i)>=0;(i)--)
#define max(a,b) ((a)>(b) ? (a) : (b))
#define min(a,b) ((a)<(b) ? (a) : (b))
#define zt(a,b) (max((a),(b))-min((a),(b)))
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll nPr(int n,int r){ll i,result=1;rep(i,r){result*=(ll)(n-i);}return result;}
ll nCr(int n,int r){ll i,result=1;if(n<r) return 0;rep(i,min(r,n-r)){result*=(ll)(n-i);result/=(ll)(i+1);}return result;}
#define nHr(n,r) nCr((int)((n)+(r)+1),(int)(r))
#define sankaku(x) (((x)*((x)+1))/2)
int dx[8]={1,0,-1,0,1,-1,-1,1},dy[8]={0,1,0,-1,1,1,-1,-1};
int upint(cv *a, cv *b) { return *(int *)a < *(int *)b ? -1 : *(int *)a > *(int *)b ? 1 : 0; }
int downint(cv *a, cv *b) { return *(int *)a < *(int *)b ? 1 : *(int *)a > *(int *)b ? -1 : 0; }
int upchar(cv *left, cv *right) {return strcmp((char *)left,(char *)right);}
int downchar(cv *left, cv *right) {return strcmp((char *)right,(char *)left);}
void tmpInit(int *c,ll m) {ll i;rep(i,m) c[i]=i;}
ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1){
      res *= a; if(mod>=1) res %= mod;
    }
    a *= a; if(mod>=1) a %= mod;
    n >>= 1;
  }
  return res;
}
void initialize(){
  
}
int a[LIMIT2]={0};
ll findData(ll i){
  //findDataが単調減少のときはbinaryの不等号を反転させる
  if(i==-1) return -1;
  return (ll)a[i];
}
ll binaryCeil(ll max, ll min, ll target){
  //targetの数値以上の最小
  ll mid;
  ll count=0;
  while(max>min && count < 100){
    mid = (max+min)/2;
    if(findData(mid) >= target) max = mid;
    else min = mid+1;
    count++;
  }
  return max;
}
int main(void){
  initialize();
  ll n,m,i,j,k,result=0;
  char s[LIMIT1];
  
  cin >> n;
  rep(i,n){
    cin >> a[i];
  }
  qsort(a,n,sizeof(int),upint);
  
  for(i=n-1;i>=2;i--){
    for(j=i-1;j>=1;j--){
      k = binaryCeil((ll)j,-1,(ll)(a[i]-a[j]+1));
      //cout << k << endl;
      result += j-k;
    }
  }
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 3652
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <map>
#include <cmath>
#include <numeric>

#define rep(i,n) for(int i = 0;i < (n);i++)
#define repp(i,j, n) for(int i = (j);i < (n);i++)
#define all(x) (x).begin(),(x).end()
#define pb(x) push_back(x)
#define mp(a,b) make_pair(a,b)
#define INF 1e9

using namespace std;

typedef long long int ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<pair<int, int> > vpi;
typedef vector<pair<ll, ll> > vpl;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n, x;
  cin >> n >> x;
  vl a(n);
  rep(i, n) cin >> a[i];
  ll ans = 0;
  if(a[0] > x){
    ans += a[0]-x;
    a[0] = x;
  }
  rep(i, n-1){
    if(a[i] + a[i+1] > x){
      if(x-a[i] < 0){
        ans += a[i+1] + a[i]-x;
        a[i+1] = 0;
        a[i] = x;
      }else{
        ans += a[i]+a[i+1]-x;
        a[i+1] = x-a[i];
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <tuple>
#include <cassert>
#include <functional>
#include <set>
#include <deque>
using namespace std;
typedef long long ll;
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
const int INF = 1<<29;
#define LNF __LONG_LONG_MAX__
const ll MOD = 1000000007;
const int MAX = 200000;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
// 法mでのaの逆元を計算
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
//最大公約数
int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }
//最小公倍数
int lcm(int x, int y) { return x / gcd(x, y) * y; }
// nが大きく,kが10^7程度の時の二項係数
long long com[200005];
void combination(long long n,long long k){
    com[0] = 1;
    for(int i=1;i<=k;i++){
        com[i] = (com[i-1]*(n-i+1)%MOD)*modinv(i,MOD)%MOD;
    }
}
vector<ll> x(100005,LNF);
int cnt=0;
void rec(ll t,ll c){
    x[cnt++] = t;
    //cerr << t << "\n";//<< " " << a << " " << cnt  << endl;
    if(t*10>3234566667) return;
    if(c>9) return;
    if(t==0) return;
    ll a = t%10;
    if(a==0){
        //x[cnt++] = t*10;
        rec(t*10,c+1);
        //x[cnt++] = t*10+1;
        rec(t*10+1,c+1);
    }else if(a==9){
        //x[cnt++] = t*10+8;
        rec(t*10+8,c+1);
        //x[cnt++] = t*10+9;
        rec(t*10+9,c+1);
    }else{
        for(int i=a-1;i<=a+1;i++){
            //x[cnt++] = t*10+i;
            rec(t*10+i,c+1);
        }
    }
}
int main(){
    ll K; cin >> K;
    for(int i=1;i<=9;i++){
        //x[cnt++] = i;
        rec(i,0);
    }

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

    cout << x[K-1] << endl;
    return 0;
}


Measured memory_bytes: 1024
n = int(input())
a = list(map(int, input().split()))

m = 1000
k = 0

for i in range(n):
    #最終日は全額売る
    if i == n - 1:
        m += k * a[i]
        break

    #翌日上がるなら買う
    if a[i] < a[i + 1]:
        k += m // a[i]
        m = m % a[i]
        continue
    
    #翌日下がるなら売る
    if a[i] > a[i + 1]:
        m += k * a[i]
        k = 0
        continue

print(m)

Measured memory_bytes: 9152
<?php
$n = trim(fgets(STDIN));
$taro_score = 0;
$hana_score = 0;

for($i = 0; $i < $n; $i++){
    $card = explode(" ", trim(fgets(STDIN)));
    $taro_card = substr($card[0],0);
    $hana_card = substr($card[1],0);
    if($taro_card > $hana_card){
        $taro_score += 3;
    }elseif ($taro_card == $hana_card) {
        $taro_score += 1;
        $hana_score += 1;
    }elseif ($taro_card < $hana_card) {
        $hana_score += 3;
    }
}
printf("%d %d",$taro_score,$hana_score).PHP_EOL;
?>

Measured memory_bytes: 15232
size = int(input())
stones = [int(val) for val in input().split()]
memo = [-1] * (size + 5)

def ans(n):
	if memo[n] != -1:
		return memo[n]
	else:
		memo[n] = min(
			ans(n - 1) + abs(stones[n] - stones[n - 1]),
			ans(n - 2) + abs(stones[n] - stones[n - 2])
		)
		return memo[n]


def ans_iterative(n):
	if memo[n] != -1:
		return memo[n]
	else:
		for idx in range(2, n):
			memo[idx] = min(
				memo[idx - 1] + abs(stones[idx] - stones[idx - 1]),
				memo[idx - 2] + abs(stones[idx] - stones[idx - 2])
			)
		return memo[n - 1]


if size == 1:
	print(0)
else:
	memo[0] = 0
	memo[1] = abs(stones[0] - stones[1])
	print(ans_iterative(size))




Measured memory_bytes: 13976
S = input()
s1 = int(S[:2])
s2 = int(S[2:])

m1 = (1 <= s1 <= 12)
m2 = (1 <= s2 <= 12)

if m1 and m2:
    print('AMBIGUOUS')
elif m1 and not m2:
    print('MMYY')
elif m2 and not m1:
    print('YYMM')
else:
    print('NA')



Measured memory_bytes: 2940
#include<iostream>
#include<algorithm>
#include<string.h>
using namespace std;

int main(){
	long long A, B, C, K, sum=0;
	cin >> A >> B >> C >> K;
	if(A >= K) sum = K;
	else if(A < K) {
		sum = A;
		K = K-A;
		if(B < K) {
			K = K-B;
			sum = sum - K;
		} 
	}
	cout << sum;
	
}

Measured memory_bytes: 3156
#include<iostream>
using namespace std;
int main(){
  int a,b,c;
  cin >> a >> b >> c;
  int j = 0;
  if(a == b && a != c){
    j = 1;
  }
  if(a == c && a != b){
    j = 1;
  }
  if(b == c && b != a){
    j = 1;
  }
  if(j){
    cout << "Yes" << endl;
  }else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
using namespace std;
char buf[11];
int ans=700;
int main()
{
	scanf("%s",buf);
	for(int i=0;i<3;i++)if(buf[i]=='o')ans+=100;
	printf("%d",ans);
	return 0;
} 

Measured memory_bytes: 256
a,b,c,x,y = map(int,input().split())
mo=[a,b]
if(a+b>2*c):
    sum=2*min(x,y)*c+max(x-y,y-x)*min(2*c,mo[x<=y])
else:
    sum=a*x+b*y
print(sum)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    int p1, p2, p3;
    int j1, j2;
    cin >> p1 >> p2 >> p3 >> j1 >> j2;
    cout << min(p1, min(p2, p3)) + min(j1, j2) - 50 << "\n";
    return 0;
}


Measured memory_bytes: 3088
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using static System.Console;
using static System.Math;


namespace AtCodeeeer
{
    class AtCOOOOOOOOOOOder
    {
        static void Main(string[] args)
        {
            int N = int.Parse(ReadLine());
            List<int> ls = new List<int>();
            ls.AddRange(ReadLine().Split(' ').Select(int.Parse).ToArray());
            WriteLine(ls.Max() - ls.Min());
        }
    }
}


Measured memory_bytes: 11348
function Scanner(input) {
	var self = this;
	self.itemNo = 0;
	self.orgStr = input;
	self.splitedStrs = (function(target) {
		var result = [];
		var target = target.replace(/[\n \t]+/g, " ");
		var strs = target.split(" ");
		for (var i = 0, len = strs.length; i < len; i++) {
			result.push(strs[i]);
		}
		return result;
	}(input));

	self.next = function() {
		var result = self.splitedStrs[self.itemNo];
		self.itemNo++;
		return (result != null) ? result : null;
	}

	self.nextInt = function() {
		var result = self.splitedStrs[self.itemNo];
		self.itemNo++;
		return (result != null) ? parseInt(result) : null;
	}

	self.nextBigDecimal = function() {
		var result = self.splitedStrs[self.itemNo];
		self.itemNo++;
		return (result != null) ? parseFloat(result) : null;
	}
	
	self.nextByte = function() {
		var result = self.splitedStrs[self.itemNo];
		self.itemNo++;
		return (result != null) ? new Int8Array(result) : null;
	}

}

function Main(sc) {

	var N = sc.next();
	
	var las1 = N.slice(-1);
	var ans = "";
	
	switch (las1) {
	
	case "2":
	case "4":
	case "5":
	case "7":
	case "9":
		ans = "hon";
		break;
	case "0":
	case "1":
	case "6":
	case "8":
		ans = "pon";
		break;
	case "3":
		ans = "bon";
		break;
	}
	
	console.log(ans);
}
Main(new Scanner(require("fs").readFileSync("/dev/stdin", "utf8")));
// Main(new Scanner("10 1 2 5 3 4 6 7 3 2 4 1 2 2 3 3 4 4 5 3 6 6 7 1 8 8 9 9 10"));

// var str1 = sc.next(); // Stringで取得
// var int1 = sc.nextInt(); // intで取得
// var bd1 = sc.nextBigDecimal(); // BigDecimalで取得
// var byte1 = sc.nextByte(); // byteで取得
// for (var i = 0; i < 1000000000; i++) var toDelay = "aaa"; // 1000msくらいの遅延
// console.log(wrtnNos); return;


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

#define int long long

const int MOD = (int)(1e9) + 7;

inline int mod(int a) {
    return a % MOD;
}

vector<vector<int> > I;

vector<vector<int> > matrixmul(vector<vector<int> > &A, vector<vector<int> > &B) {
    int n = A.size(),
        m = A[0].size(),
        p = B[0].size();
    vector<vector<int> > ans(n, vector<int>(p, 0));
    for (int i = 0; i < n; ++i)
    for (int j = 0; j < p; ++j)
    for (int k = 0; k < m; ++k)
        ans[i][j] = mod(ans[i][j] + mod(A[i][k] * B[k][j]));
    return ans;
}

vector<vector<int> > matrixExpo(vector<vector<int> > &base, int expo) {
    auto ans = I;
    while (expo) {
        if (expo & 1) 
            ans = matrixmul(ans, base);
        base = matrixmul(base, base);
        expo >>= 1;
    }
    return ans;
}

signed main()
{
    int n, k;
    cin >> n >> k;
    vector<vector<int> > M(n, vector<int>(n, 0));
    vector<vector<int> > out(n, vector<int>(1, 0));
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            cin >> M[i][j];
            out[i][0] += M[i][j];
        }
    }
    I.resize(n);
    for (int i = 0; i < n; ++i) {
        I[i].resize(n, 0);
        I[i][i] = 1;
    }
    auto temp = matrixExpo(M, k - 1);
    auto ans = matrixmul(temp, out);
    int total = 0;
    for (int i = 0; i < n; ++i)
        total = mod(total + ans[i][0]);
    printf("%lld\n", total);
    return 0;
}

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

int main() {
  int n, m, x;
  cin >> n >> m >> x;
  vector<int> money(n);
  vector<vector<int>> under(n, vector<int>(m, 0));
  rep(i, n){
    cin >> money[i];
    rep(j,m){
      cin >> under[i][j];
    }
  }
  int ans = INF;
  for (int bit = 0; bit < (1 << n); bit++){
    int tmp_money = 0;
    vector<int> under1(m);
    for (int i = 0; i < n; i++){
      if (bit & (1 << i)){
        tmp_money += money[i];
        rep(j,m){
          under1[j] += under[i][j];
        }
      }
    }
    rep(i,m){
      if(under1[i] >= x){
        if(i == m-1){
          ans = min(ans, tmp_money);
        }
      }else {
        break;
      }
    }
  }
  if(ans == INF){
    cout << -1 << endl;
  }else {
    cout << ans << endl;
  }
}

Measured memory_bytes: 3564
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<n; ++i)
#define rep1(i, n) for (int i=1; i<=n; ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
constexpr ll  MOD = (1e9+7);
constexpr int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
constexpr int lcm(int a, int b) { return a / gcd(a, b) * b; }

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
ll factorial(ll n, ll m=2) {
    // calculate n!
    m = max(2LL, m);
    ll rtn = 1;
    for (ll i=m; i<=n; i++) {
        rtn = (rtn * i) % MOD;
    }
    return rtn;
}
ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
ll modpow(ll a, ll n) {
    ll res = 1;
    while (n > 0) {
        if (n & 1)
            res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    string s; cin >> s;
    if (s == "ABC") puts("ARC");
    else puts("ABC");
    return 0;
}

Measured memory_bytes: 3648
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>

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

using namespace std;
int N;
string befo;
int main(){
  cin >> N;
  set<string> se;
  REP(i,N){
    string s;
    cin >> s;
    if((i!=0&&befo[befo.size()-1]!=s[0])||se.count(s)>=1){
      cout << "No" << endl;
      return 0;
    }
    befo = s;
    se.insert(s);
  }
  cout << "Yes" << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define pf push_front
#define pii pair <int, int>
#define all(vv) (vv).begin(), (vv).end()
#define rep(ii, jj, ll, ss) for(int ii = jj; ii < ll; ii += ss)
#define time cerr << '\n' << (double)clock()/CLOCKS_PER_SEC << '\n'; return 0;

string s;
vector <char> v;

int32_t main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	cin >> s;
	v.pb(s[0]);
	rep(i, 1, (int)s.length(), 1) {	
		if (s[i] == '1' && v.size() && v.back() == '0') {
			v.pop_back();
			continue;
		}
		else if (s[i] == '0' && v.size() && v.back() == '1') {
			v.pop_back();
			continue;
		}
		v.pb(s[i]);
	}
	cout << (int)s.length() - (int)v.size();
	time
}

Measured memory_bytes: 3956
# 一辺の長さNとxが互いに素でないならばmcd(N,x)分の1に縮小できる
# で、全然確信を持てないけど、Nとxが互いに素ならば答えは3(N-1)っぽい
# すると答えはm = mcd(N, x)として m * 3 *(N/m - 1)

def mcd(a, b)
	# a>= b は確定とする
	while(1)
		temp = a % b
		if (temp == 0)
			return b
		end
		a = b
		b = temp
	end
end


N, x = gets.chomp.split(" ").map{|v|
	v.to_i
}

m = mcd(N, x)
puts m *3 * (N/m - 1)


Measured memory_bytes: 1788
// https://atcoder.jp/contests/abc058/tasks/arc071_a
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    multiset<char> st;
    REP(i, n) {
        multiset<char> t, u;
        string s;
        cin >> s;
        for (auto &x : s) {
            t.insert(x);
        }
        if (i == 0) {
            st = t;
        } else {
            // aとbの積集合を作る
            set_intersection(ALL(st), ALL(t), inserter(u, u.end()));
            st = u;
        }
    }
    for (auto &x : st) {
        cout << x;
    }
    cout << "\n";

    return 0;
}


Measured memory_bytes: 256
#include <cstdio>

using namespace std;

int main(){
    int n;
    char s[212];
    char t[212];
    scanf("%d\n", &n);
    scanf("%s %s", s, t);
    // printf("%sX%sX\n", s, t);
    for(int i=0; i < n; i++){
        printf("%c%c", s[i], t[i]);
    }
    printf("\n");

}

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


int main(){
    int a,b,c;
    cin >> a >> b >> c;
    if(a!=b && b!=c && a!=c){
        cout << 3 << '\n';
    }else if(a==b && b==c){
        cout << 1 << '\n';
    }else{
        cout << 2 << '\n';
    }

}





Measured memory_bytes: 3172
N, M, X, Y = map(int, input().split())
xlst = list(map(int, input().split()))
ylst = list(map(int, input().split()))

xmax = max(xlst)
ymin = min(ylst)
cand = []
for i in range(xmax+1, ymin+1):
    cand.append(i)
    
warflag = True
for c in cand:
    if X < c <= Y:
        warflag = False
if warflag:
    print('War')
else:
    print('No War')

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <vector>
#include <iomanip>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
using namespace std;

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

    cout << (((N+999)/1000)*1000 - N) << endl;

    return 0;
}

Measured memory_bytes: 3632
N = input().strip()

h, t, o = N[0], N[1], N[2]

if int(h) < int(t):
  print(str(int(h) + 1) * 3)
elif int(h) > int(t):
  print(h * 3)
else:
  if int(t) < int(o):
    print(str(int(h) + 1) * 3)
  elif int(t) >= int(o):
    print(h * 3)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
#define MAXC 100000
int dp[100005],a[100005],n,k=2;
//int max(int a, int b, int c){
//	return (max(a, max(b,c)));
//}
int main()
{
	string a,b;cin>>a>>b;
	int n = a.size();
	int m = b.size();
	int lcs[n+1][m+1];
	for(int i=0;i<=n;i++){
		for(int j=0;j<=m;j++){
			if(i==0 || j==0) lcs[i][j]=0;
			else if(a[i-1]==b[j-1]){
				lcs[i][j] = lcs[i-1][j-1]+1;
			}else lcs[i][j] = max(lcs[i][j-1],lcs[i-1][j]);
		}
	}
	int index = lcs[n][m];
// 	cout<<index<<endl;
	char s[index+1];
	s[index]= '\0';
	int i = n, j=m;
	while(i>=0 && j>=0){
		if(a[i-1]==b[j-1]) {
			s[--index]=a[i-1];i--;j--;
		}
		else if(lcs[i][j-1]>lcs[i-1][j]) j--;
		else i--;
	}
// 	resize(s, s.size()-1);
// 	reverse(s.begin(), s.end());
	cout<<s;
}

Measured memory_bytes: 35456
fun main(args: Array<String>) = println(run {
    val s = readLine()!!

    val a = s[0] == 'A'
    val b = s.substring(2..s.lastIndex-1).count { it == 'C' } == 1
    val c = s.drop(1).filter { it != 'C' }.all { it in 'a'..'z' }
    if(a && b && c) "AC" else "WA"

})


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

using namespace std;

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

int main() {
	int n, d;
	scanf("%d%d", &n, &d);
	vector<vector<int>> x(n, vector<int> (d));
	rep(i, n) {
		rep(j, d) {
			scanf("%d", &x[i][j]);
		}
	}
	int ans = 0;
	rep(i, n) {
		for (int j = i + 1; j < n; j ++) {
			int s = 0;
			rep(k, d) {
				s += (x[i][k] - x[j][k]) * (x[i][k] - x[j][k]);
			}
			cerr << "s = " << s << endl;
			for (int p = 1; p * p <= s; p ++) {
				if (p * p == s) {
					ans ++;
				}
			}
		}
	}
	printf("%d", ans);
	return 0;
}


Measured memory_bytes: 256
/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Code author: Saurabh Singhal
Code copy karne vaale tera muh kaala
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/

#include<bits/stdc++.h>
#define mp(a,b) make_pair(a,b)
#define pb push_back
#define ppb pop_back

using namespace std;
typedef long long int ll;
typedef vector<int> vi_t;
typedef vector<ll> vll_t;
int t=1;
vll_t a,b;
int  main(){
	// #ifndef ONLINE_JUDGE
 //    // for getting input from input.txt
 //    freopen("input.txt", "r", stdin);
 //    // for writing output to output.txt
 //    freopen("output.txt", "w", stdout);
	// #endif
	int n;
	cin>>n;
	int prev=1;
	for(int i=4;i<=n;i++){
		for(int j=2;j<=sqrt(i);j++){
			int po=j;
			while(po<i){
				po=po*j;
				if(po==i){
					prev=i;
					//cout<<prev<<endl;
					break;
				}
			}
		}
	}
	cout<<prev<<endl;
}

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

using namespace std;

#define pb push_back
#define mk make_pair
#define mod 1000000007
#define ff first
#define ss second

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

ll modpow(ll a, ll b){

    ll ans=1;
    while(b){
        if(b&1){
            ans=(ans*a)%mod;
        }
        a=(a*a)%mod;
        b=b/2;
    }
    return ans;
}

vector<int> inp[100010];
int depdiff[100010];
int ht[100010];
int par[100010];

void dfs1(int r, int p, int depth) {
    depdiff[r] = depth;

    for(int i = 0; i < inp[r].size(); i++) {
        if(p != inp[r][i]) {
            dfs1(inp[r][i], r, depth + 1);
        }
    }
}

void dfs2(int r, int p) {
    int height = 0;

    par[r] = p;

    for(int i = 0; i < inp[r].size(); i++) {
        if(p != inp[r][i]) {
            dfs2(inp[r][i], r);
            height = max(height, ht[inp[r][i]] + 1);
        }
    }

    ht[r] = height;
}

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    int n,a,b;
    cin>>n>>a>>b;

    for(int i = 0; i < n - 1 ; i++) {
        int x,y;
        cin>>x>>y;

        inp[x].push_back(y);
        inp[y].push_back(x);
    }


    dfs1(b, -1, 0);

    dfs2(b, -1);

    int till = (depdiff[a] - 1)/2;

    int ans = depdiff[a] + ht[a] - 1;
    int curr = a;

    for(int i = 0; i < till; i++) {
        curr = par[curr];
        //cout<<curr<<endl;
        ans = max(ans, depdiff[curr] + ht[curr] - 1);
    }

    cout<<ans<<endl;




}


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

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'

// n回繰り返し
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++) // 1-indexed昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  // 0-indexed降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   // 1-indexed降順
#define all(x) (x).begin(),(x).end()

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii;  // 2次元配列
typedef vector<ll> vll;
typedef vector<double> vd;
typedef pair<int, int> PII;

template<typename T>
using vec = vector<T>;
template<class T>
using maxheap = std::priority_queue<T>;
template<class T>
using minheap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

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

const ld Pi = std::acos(-1.0L);
const ll infll = (1LL<<62)-1;
const int inf = (1<<30)-1;
const int mod = 1000000007;
// const int mod = 998244353;


/*FUNCs=================================================*/


/*MAIN==================================================*/
signed main(){
    int START_TIME = clock();
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化
    // cout << fixed << setprecision(15);

    string s,t;
    int a,b,c,e,d,n,m,x,y,z;
    cin >> x >> y >>z;
    cout << z <<' '<< x  << ' '<< y;



    // printf("ExecutionTime: %d /ms\n",1000*(int)((clock()-START_TIME)/CLOCKS_PER_SEC));
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author dyominov
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        AProduct solver = new AProduct();
        solver.solve(1, in, out);
        out.close();
    }

    static class AProduct {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int a = in.nextInt();
            int b = in.nextInt();
            out.print(a * b % 2 == 0 ? "Even" : "Odd");
        }

    }

    static class InputReader implements AutoCloseable {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public void close() {
        }

    }
}



Measured memory_bytes: 21332
#include<iostream>
#include<vector>
#include<cstring>
#define endl "\n"
#define eb emplace_back
typedef long long ll;
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string a, b;
    cin >> a >> b;
    ll len = a.size();
    int count = 0;
    for(int i = 0; i < len; i++)
        if(a[i] != b[i])
            count++;
    cout << count << endl;
}

Measured memory_bytes: 3764
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<vector>
#include<iostream>
#include<string>
#include<cstdlib>
using namespace std;
int main(void)
{
	vector<long long int> num(10);
	int r, d, x;
	cin >> r >> d >> x;
	int i;
	for (i = 0; i < 10; i++)
	{
		if (i == 0)
		{
			num[i] = x * r - d;
		}
		else
		{
			num[i] = num[i - 1] * r - d;
		}
	}

	for (i = 0; i < 10; i++)
	{
		cout << num[i] << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#define REP(i,m,n) for(int i = (int)(m); i < (int) (n) ;i++)
#define rep(i,n)  REP(i , 0 , n)
using namespace std;

int n, d, c, p;
double s, q;
int x[12][12];

int k2(int x, int y){
	return (x - y)*(x - y);
}


int main(){
	
	cin >> n >> d;
	rep(i,n){
		rep(j,d){
			cin >> x[i][j];
		}
	}

	rep(i, n){
		rep(j, n){
			if (i != j){
				rep (k,d){
					s += k2(x[i][k], x[j][k]);
				}
				q = sqrt(s);
				p = q;
				if (p == q) c++;
				s = 0;
			}

		}
	}
	cout << c / 2 << endl;






	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class AtCoderA
{
    static void Main()
    {
        var sc = new Scanner();

        long n = sc.NextLong();
        long h = sc.NextLong();
        long w = sc.NextLong();

        long answer = 0;
        for (long i = 0; i < n; i++)
        {
            long a = sc.NextLong();
            long b = sc.NextLong();
            if (a >= h && b >= w)
            {
                answer++;
            }
        }

        Console.WriteLine(answer);
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}


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

using namespace std;

int dir[][2] = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};

int main() {
	int h, w;
	cin >> h >> w;

	vector<vector<char>> mat(h + 2, vector<char>(w + 2, '#'));
	for (int i = 0; i < h; i++) for (int j = 0; j < w; j++) cin >> mat[i + 1][j + 1];

	queue<pair<int, int>> q;
	for (int i = 1; i <= h; i++) for (int j = 1; j <= w; j++) if (mat[i][j] == '#') q.push(make_pair(i, j));

	int ans = -1;
	bool ok = 1;
	while (ok) {
		ans++;
		ok = 0;
		int cnt = q.size();
		for (int i = 0; i < cnt; i++) {
			pair<int, int> u = q.front(); q.pop();
			int ux = u.first; int uy = u.second;
			for (int j = 0; j < 4; j++) {
				if (mat[ux + dir[j][0]][uy + dir[j][1]] == '.') {
					ok = 1;
					mat[ux + dir[j][0]][uy + dir[j][1]] = '#';
					q.push(make_pair(ux + dir[j][0], uy + dir[j][1]));
				}
			}
		}
	}

	cout << ans << endl;
}


Measured memory_bytes: 12168
const input = require('fs').readFileSync('/dev/stdin', 'utf8');

let [a, b]: number[] = input.split("\n")[0].split(" ").map(Number);
let x = 0;
for(let i=0; i<2; i++){
　if(a>=b){ x = x+a; a = a-1; }
  else{ x = x+b; b = b-1; }
}
console.log(x);

Measured memory_bytes: 7372
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;

#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

#[allow(dead_code)]
fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

//20:50

fn main(){
    let mut line: Vec<usize> = read_as_vec();
    line.sort();
    let (mut a, mut b, mut c) = (line[0], line[1], line[2]);

    let mut ans = 0;

    ans += (c -a)/2;
    a += 2 * ((c-a)/2);
    ans += (c-b)/2;
    b += 2 * ((c-b)/2);

    if a < c && b < c{
        println!("{}", ans+1);
    }else if a == c && b == c{
        println!("{}", ans);
    }else{
        println!("{}", ans+2);
    }
}


Measured memory_bytes: 4352
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
int N_MAX = 301;
typedef pair<int,int> P;
typedef pair<P,int> PP;
int main()
{
  int n,m,l,a,b,c,q,s,t,i,j,k;
  vector<P> v[N_MAX]; // to,cost
  P mc[N_MAX][N_MAX]; // 補給回数，-残燃料
  P e,co;
  PP pp;
  priority_queue<PP, vector<PP>, greater<PP>> que;
  cin >> n >> m >> l;
  for(i=1;i<=n;i++)
    fill(mc[i]+1,mc[i]+n+1,P(N_MAX,0));
  for(i=0;i<m;i++){
    cin >> a >> b >> c;
    if(c<=l){
      v[a].push_back(P(b,c));
      v[b].push_back(P(a,c));
    }
  }
  cin >> q;
  for(i=0;i<q;i++){
    cin >> s >> t;
    if(mc[s][s].first==0){
      if(mc[s][t].first==N_MAX)
        cout << "-1" << endl;
      else
        cout << mc[s][t].first << endl;
      continue;
    }
    mc[s][s]=P(0,-l);
    que.push(PP(mc[s][s],s));
    while(!que.empty()){
      pp=que.top(); que.pop();
      j=pp.second;
      if(mc[s][j]<pp.first) continue;
      for(k=0;k<v[j].size();k++){
        e=v[j][k];
        co=P(mc[s][j].first,mc[s][j].second+e.second);
        if(co.second>0){
          co.first++;
          co.second=-l+e.second;
        }
        if(mc[s][e.first]>co){
          mc[s][e.first]=co;
          que.push(PP(mc[s][e.first],e.first));
        }
      }
    }
    if(mc[s][t].first==N_MAX)
      cout << "-1" << endl;
    else
      cout << mc[s][t].first << endl;
  }
  return 0;
}

Measured memory_bytes: 2432
S = set(list(input()))

if 'N' in S and 'S' not in S:
    print('No')
    exit()
if 'W' in S and 'E' not in S:
    print('No')
    exit()
if 'S' in S and 'N' not in S:
    print('No')
    exit()
if 'E' in S and 'W' not in S:
    print('No')
    exit()

print('Yes')


Measured memory_bytes: 3060
import java.io.*
import java.util.*

// solve
// a + b + c = N ~ 2000
// 10000a + 5000b + 1000c = Y ~ 10 ^ 7
// 10a + 5b + c = Y/1000 ~ 10^4
fun solve(N: Long, Y: Long){
    val n = N.toInt()
    val y = (Y/1000L).toInt()
    for (a in 0..2000){
        for (b in 0..2000){
            val c = n - a - b
            if (c < 0) continue
            if (y == 10*a + 5*b + c){
                println("$a $b $c")
                return
            }
        }
    }
    println("-1 -1 -1")
    return
}


fun main(args: Array<String>) {
    fun StringArray(size: Int, init: (Int) -> String = { "\u0000" }): Array<String> {
        return Array<String>(size, init)
    }
    class Scanner(stream: InputStream) {
        private val reader = BufferedInputStream(stream).bufferedReader()
        private var st: StringTokenizer? = null
        fun next(): String {
            while (!(st?.hasMoreTokens() ?: false)) st = StringTokenizer(reader.readLine())
            return st!!.nextToken()
        }
    }
    val sc = Scanner(System.`in`)
    val N = sc.next().toLong()
    val Y = sc.next().toLong()
    solve(N, Y)
}



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

int n,m,a;

int memo[1005][105]={0};

int main(){
  int b,i,j=0,h,p,q;
  while(1){
    cin >> n >> m >> a;
    if(n+m+a==0)break;
    for(b=0;b<m;b++){
      cin >> h >> p >> q;
      memo[h][p]=q;
      memo[h][q]=p;
      if(j<h)j=h;
    }
    for(i=j;i>0;i--){
      //cout <<" "<< i << " "<<memo[i][a] <<" "<<a <<endl;
      if(memo[i][a])a=memo[i][a];
    }
    cout << a << endl;
    for(h=1;h<=j;h++)for(i=1;i<=n;i++)memo[h][i]=0;
  }
  return 0;
}



Measured memory_bytes: 3472
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define endl "\n"
#define pb push_back
#define f(i,n) for(i=0;i<n;i++)
#define F(i,a,b) for(i=a;a<=b;i++)
#define arr(a,n) for( i=0;i<n;i++)cin>>a[i];
#define fi first
#define se second
#define mp make_pair
#define mod 1000000007
#define YES cout<<"YES"<<endl;
#define Yes cout<<"Yes"<<endl;
#define NO cout<<"NO"<<endl;
#define No cout<<"No"<<endl;
#define yes cout<<"yes"<<endl;
#define no cout<<"no"<<endl;
#define vi vector<ll>
#define ed end()
#define bg begin()
#define sz size()
#define ln length()
#define s() sort(a,a+n);
#define sr() sort(a,a+n,greater<ll>());
#define v()  sort(v.begin(),v.end());
#define vr() sort(v.begin(),v.end(),greater<ll>());
#define mod 1000000007
#define fast() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);}
ll power(ll x,ll y,ll p){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
int main() {
    /*#ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif*/
        /* 
        Ofcourse it's Hard.
        It's supposed to be Hard.
        If it's easy everyone would do it.
        HARD IS WHAT MAKES IT GREAT

        YESTERDAY U SAID TOMORROW

        SLOWLY BECOMING THE PERSON I 
        SHOULD HAVE BEEN A LONG TIME AGO

        SAME TASK CAN'T BE FOUND DIFFICULT TWICE

        BTBHWSITW

        SPRH TU KAB P

        CP IS ALL ABOUT THINKING 
        YOU HAVE MUCH MORE POTENTIAL THAN U THINK

        AJIT SHIDDAT 10

        UR DAILY ROUTINE 


        */

fast();
//ll t;cin>>t;while(t--)
{
    string s;
    cin>>s;
    ll n=s.length();
    cout<<s[0]<<n-2<<s[n-1]<<endl;
}
return 0;
}

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

public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		String sent;
		while((sent=scan.nextLine()).length()!=1){
			ArrayList<Integer> bracket = new ArrayList<Integer>();
			boolean endFlag=false;
			int level=-1;
			for(int i=0;i<sent.length();i++){
				switch(sent.charAt(i)){
					case '[':
						bracket.add(1);
						level+=1;
						break;
					case ']':
						if(level>-1 && bracket.get(level)==1){
							bracket.remove(level);
							level-=1;
						}
						else endFlag=true;
						break;
					case '(':
						bracket.add(2);
						level+=1;
						break;
					case ')':
						if(level>-1 && bracket.get(level)==2){
							bracket.remove(level);
							level-=1;
						}else endFlag=true;
						break;
				}
				if(endFlag)break;
			}
			if(endFlag || level!=-1)System.out.println("no");
			else                   System.out.println("yes");
		}
	}
}

Measured memory_bytes: 44896
A,B,M=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
min_price=min(a)+min(b)
for i in range(M):
    tmp_price=10000
    m=list(map(int,input().split()))
    tmp_price=a[m[0]-1]+b[m[1]-1]-m[2]
    if min_price>tmp_price:
        min_price=tmp_price
print(min_price)

Measured memory_bytes: 18736
// Problem : F - Sum Difference
// Contest : AtCoder Beginner Contest 147
// URL : https://atcoder.jp/contests/abc147/tasks/abc147_f
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update

using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
ordered_set;	

#define FOR(i,a,b) for(int i = (a); i <= (b); ++i)
#define FORD(i,a,b) for(int i = (a); i >= (b); --i)
#define RI(i,n) FOR(i,1,(n))
#define REP(i,n) FOR(i,0,(n)-1)
#define mini(a,b) a=min(a,b)
#define maxi(a,b) a=max(a,b)
#define mp make_pair
#define pb push_back
#define st first
#define nd second
#define sz(w) (int) w.size()
typedef vector<int> vi;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<pii, int> para;
const ll inf = 1e18 + 7;
const ll maxN = 1e6 + 5;
const ll MOD = 1e9 + 7;

int main() {
	ios_base::sync_with_stdio(0);
	int a, b, c;
	cin >> a >> b >> c;
	if (a + b + c > 21) cout << "bust";
	else cout <<"win";
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cmath>
#include <climits>
#include <cstdlib>
using namespace std;

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

int F[200][10];
int P[200][20];

int main() {
  int N;
  int ans = INT_MIN;
  cin>>N;
  REP(i,N) {
    REP(j,10) {
      cin>>F[i][j];
    }
  }
  REP(i,N) {
    REP(j,11) {
      cin>>P[i][j];
    }
  }
  for(int mask = 1; mask < 1024; mask++) {
    int work = 0;
    REP(i,N) {
      int same = 0;
      REP(j,10) {
        if(((1<<j) & mask) && F[i][j] == 1) same++;
      }
      int tmp	= 0;
      tmp	+= P[i][same];
      work += tmp;
      //      cout << i << " " << same << " " << tmp << endl;                       
    }
    //    cout << mask << " " << " " << work << endl;                               
    ans = max(ans, work);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std;
int N, M, P[10009], C[509], E[509], dp[509][10009];
int main() {
	cin >> M >> N;
	for (int i = 0; i < M; i++) cin >> P[i + 1];
	for (int i = 0; i < N; i++) cin >> C[i] >> E[i];
	fill(dp[0] + 1, dp[0] + M + 1, 999999999);
	for (int i = 0; i < N; i++) {
		for (int j = 0; j <= M; j++) {
			dp[i + 1][j] = dp[i][j];
			dp[i + 1][j] = min(dp[i + 1][j], dp[i][max(j - C[i], 0)] + E[i]);
		}
	}
	sort(P + 1, P + M + 1, greater<int>());
	for (int i = 1; i <= M; i++) P[i] += P[i - 1];
	int ret = 0;
	for (int i = 0; i <= M; i++) ret = max(ret, P[i] - dp[N][i]);
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 22768