akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int t = sc.nextInt();
		int a = sc.nextInt();
		double[] h = new double[n];

		for(int i=0; i<n; i++){
			int b = sc.nextInt();
			h[i] = t - b*0.006;
		}

		double min = 1000000000;
		int ans=-1;
		for(int i=0; i<n; i++){
			double x;
			if(h[i] >= a){
				x = h[i]-a;
			}else{
				x = a - h[i];
			}
			if(x <= min){
				ans = i;
				min = x;
			}
		}
		System.out.println(ans+1);



	}
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
#define pb push_back
#define F first
#define S second
#define ALL(a) (a).begin(),(a).end()
#define MAX 105
#define int long long int
using namespace std;
int dp[102][100005];



int32_t main()
{
    int N,W;
    cin >> N >> W;
    int wt[N],val[N];
    for(int i = 0 ; i < N ; i++)
        cin >> wt[i] >> val[i];
    int sum = 0;
    for(auto it: val)
        sum += it;
    //int dp[N+1][sum+1];
    memset(dp,0,sizeof(dp));
    for(int i = 0 ; i <= sum ; i++)
        dp[0][i] = INT_MAX;
    for(int i = 0 ; i <= N ; i++)
        dp[i][0] = 0;
    
    for(int i = 1 ; i <= N ; i++)
    {
        for(int j = 1 ; j <= sum ; j++)
        {
            if(val[i-1] <= j)
                dp[i][j] = min(dp[i-1][j-val[i-1]]+wt[i-1], dp[i-1][j]);
            else dp[i][j] = dp[i-1][j];
        }
    }
    int ans=0;
    for(int i = 0 ; i <= sum ; i++)
    {
        //cout << dp[N][i] << " ";
        if(dp[N][i] <= W)
        {
            ans = i;
        }
    }
    cout << ans;
    
    return 0;
}


Measured memory_bytes: 83276
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;
using ll = long long;
using P = pair<int, int>;
#define rep(i,n) for(int i = 0; i < n; i++)
const double INF = 1001001001;

int main() {
	int n, t, a;
	cin >> n >> t >> a;
	vector<int> h(n);
	double minDif = INF;
	int ans = 0;
	rep(i, n) {
		int h;
		cin >> h;
		double temp = t - h * 0.006;
		double dif = max(a - temp, temp - a);
		if (dif <= minDif) {
			minDif = dif;
			ans = i + 1;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    int a, b, n;
    while(cin >> a >> b >> n) {
        int sum = 0;
        a %= b;
        for(int i = 0; i < n; ++i) {
            a *= 10;
            sum += a / b;
            a %= b;
        }
        cout << sum << endl;
    }
    return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    string s;
    cin>>n>>s;
    ll q,k;
    cin>>q;
    vector<ll> v;
    while(q--){
    	cin>>k;
    	ll numd=0,numm=0,ans=0,num=0;
    	for(int i=0;i<n;i++){
    		if(i>=k){
    			if(s[i-k]=='D'){
    				num-=numm;
    				numd--;
    			}else if(s[i-k]=='M')numm--;
    		}
    		if(s[i]=='D')numd++;
    		else if(s[i]=='M'){
    			num+=numd;
    			numm++;
    		}else if(s[i]=='C') ans+=num;
    	}
    	v.pb(ans);
    }
    for(auto& i:v)cout << i<<endl;
    return 0;
}


Measured memory_bytes: 1948
N, M = map(int, input().split())
A = list(map(int, input().split()))
A.sort()

dif = []
for i in range(M-1):
    dif.append(A[i+1] - A[i])

dif.sort(reverse=True)
dif = dif[N-1:]

print(sum(dif))

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

int main() {
  int N;
  cin >> N;
  //cout << M << endl;*/

  //int N = 3;
  vector<int> vec(N);
  for (int i = 0; i < N; i++) {
    cin >> vec.at(i);
  }

  std::sort(vec.begin(), vec.end());
  //sort(vec.begin(), vec.end());
  //vec.erase(std::unique(vec.begin(), vec.end()), vec.end());

  /*for (int i = 0; i < vec.size()-1; i ++){
    cout << vec.at(i) << " ";
  }
  cout << vec.at(vec.size() - 1) << endl;*/

  int ans=0;

  /*for(int i = 0; i < vec.size()-2; i++){
    for(int j = i+1; j < vec.size()-1; j++){
      for(int k = j+1; k < vec.size(); k++){
        if(vec.at(i) != vec.at(j) && vec.at(j) != vec.at(k) && vec.at(i) + vec.at(j) > vec.at(k)){
            //cout << vec.at(i) << " " << vec.at(j) << " " << vec.at(k) << endl;
            ans++;
        }
      }
    }
  }*/

  for(int i = 0; i < vec.size(); i++){
    for(int j = 0; j < i; j++){
      for(int k = 0; k < j; k++){
        if(vec.at(i) != vec.at(j) && vec.at(j) != vec.at(k) && vec.at(k) + vec.at(j) > vec.at(i)){
            //cout << vec.at(i) << " " << vec.at(j) << " " << vec.at(k) << endl;
            ans++;
        }
      }
    }
  }

  cout << ans << endl;

  //vector<int> vec(N);
  /*for (int i = 0; i < vec.size(); i ++){
    cout << vec.at(i) << endl;
  }*/


  /*for (int i = 0; i < vec.size()-1; i ++){
    cout << vec.at(i) << " ";
  }
  cout << vec.at(vec.size() - 1) << endl;*/
}


Measured memory_bytes: 3632
#include<iostream>
#include<algorithm>
int main(void){
  int N;
  std::cin >> N;
  int mochi[N];
  for (int i=0;i<N;i++){
    std::cin >> mochi[i];
  }
  std::sort(mochi, mochi+N);
  std::reverse(mochi, mochi+N);

  int count = 1;
  for (int i=0;i<N-1;i++){
    if (mochi[i] > mochi[i+1]) count++;
  }
  std::cout << count << std::endl;

  return 0;
}

Measured memory_bytes: 3632
import heapq
import math
import sys
input = sys.stdin.readline


def main():
    N, H = map(int, input().split())
    a_max = 0
    B = []
    for _ in range(N):
        a, b = map(int, input().split())
        a_max = max(a, a_max)
        B.append(-b)
    heapq.heapify(B)

    cnt = 0
    while H>0:
        if len(B)==0 or a_max >= B[0]*(-1):
            cnt += math.ceil(H/a_max)
            break
        else:
            cnt += 1
            H += heapq.heappop(B)
    
    print(cnt)

if __name__ == '__main__':
    main()

Measured memory_bytes: 60508
n, k = map(int, input().split())
p = list(map(int, input().split()))

meanList = []

for a in p:
    meanList.append((a + 1) / 2)

sums = [0]

for a in meanList:
    sums.append(sums[-1] + a)

ans = 0

for i in range(n - k + 1):
    ans = max(ans, sums[k+i] - sums[i])

print(ans)


Measured memory_bytes: 24700
#include <stdio.h>

inline static int read_int() {
    int x = 0, k;
    while ((k = getchar_unlocked() - '0') >= 0) {
        x = x * 10 + k;
    }
    return x;
}

inline static void put_int(int x) {
    int s = 0;
    char f[4];
    while (x) {
        f[s++] = x % 10;
        x /= 10;
    }

    while (s--) putchar_unlocked(f[s] + '0');
    putchar_unlocked('\n');
}

short highest[2000], streak[2000];

#pragma GCC optimize ("O3")
int main() {
    int h = read_int(), w = read_int(), max = 0, height, width, lastWall, i, res;
    short len;

    for (height = 0; height < h; height++) {
        lastWall = -1;

        for (width = 0; width < w; width++) {
            if (getchar_unlocked() != '.') {
                if (lastWall != width - 1) {
                    len = width - lastWall - 1;
                    for (i = lastWall + 1; i < width; i++) if (len > highest[i]) highest[i] = len;
                }

                res = highest[width] + streak[width];
                if (res > max) max = res;

                highest[width] = streak[width] = 0;
                lastWall = width;
            } else streak[width]++;
        }

        getchar_unlocked();

        if (lastWall != width - 1) {
            len = width - lastWall - 1;
            for (i = lastWall + 1; i < width; i++) if (len > highest[i]) highest[i] = len;
        }
    }

    for (width = 0; width < w; width++) {
        if (streak[width] != 0) {
            res = highest[width] + streak[width];
            if (res > max) max = res;
        }
    }

    put_int(max - 1);
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n;
    cin>>n;
    int d1,d2,count=0;
    for(int i=0;i<n;i++){
        cin>>d1>>d2;
        if(d1==d2){
            count++;
        }else{
            count=0;
        }
        if(count==3){
            cout<<"Yes"<<endl;
            break;
        }
        if(n-1==i){
            cout<<"No"<<endl;
            break;
        }
    }
}


Measured memory_bytes: 3632
import java.util.Scanner;

class Main
{
    public static void main(String[] args)
    {
        Scanner scan = new Scanner(System.in);
        
        int W = scan.nextInt();
        
        int H = scan.nextInt();
        
        int x = scan.nextInt();
        
        int y = scan.nextInt();
        
        int r = scan.nextInt();
        
        if(x + r <= W && y + r <= H && x - r >= 0 && y - r >= 0){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    } 
}
            


Measured memory_bytes: 26284
instring = input()
head_str = ""
foot_str = ""
ans_str = ""
ref = "keyence"
ref_rev = ref[::-1]
flag = False

# 頭からあっているかチェックしていく
start_index = 0
end_index = len(ref)-1
# 前から数えていく
for i in range(len(instring)):
    head_str += instring[i]
    now_ref = ref[:(i+1)]
    # 前から並べたときに一致しているかチェック
    if(head_str != now_ref):
        # どこで一致しなくなったかメモ
        start_index = i
        flag = True
        break

# normal
if(flag):
    ans_str += head_str[:start_index]
else:
    ans_str = head_str

end_flag = False
# 既に一致していたらこれ以上やらない
if(ans_str == ref):
    print("YES")
    end_flag = True

ans_len = len(ans_str)    

# 後ろから数えていく
for i in range(len(ref)-ans_len):        
    foot_str += instring[-(i+1)]
    now_ref = ref_rev[:(i+1)]
    if (foot_str != now_ref):
        end_index = i
        break

# 反転させる
foot_str = foot_str[:end_index][::-1] 
ans_str += foot_str

if(end_flag != True):
    if(ans_str == ref):
        print("YES")
    else:
        print("NO")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
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; }
const int INF=1001001001;
vector<pair<int64_t,int64_t>>prime_factorize(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p; 
}

int main() {
  string s;
  cin>>s;
  for(int i=0;i<s.size();i++){
    cout<<'x';
  }
  
  return 0;
}

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

int main() {
  int l;
  cin >> l;
  double x = ((double)l) / 3;
  printf("%.6f\n", x * x * x);
  return 0;
}

Measured memory_bytes: 256
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())
        
n, m, k = map(int, input().split())
ans = [-1 for _ in range(n)]
UF = UnionFind(n)
for _ in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    UF.union(a, b)
    ans[a] -= 1
    ans[b] -= 1
    
for i in range(n):
    ans[i] += UF.size(i)

for _ in range(k):
    c, d = map(int, input().split())
    c -= 1
    d -= 1
    if UF.same(c, d):
        ans[c] -= 1
        ans[d] -= 1
print(*ans)

Measured memory_bytes: 17840
import sys
import itertools
import bisect
import math

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

n = ni()
a = na()
b = na()

ans = 0

for i in range(n):
    if a[i] >= b[i]:
        ans += b[i]
        a[i] -= b[i]
    else:
        ans += a[i]
        b[i] -= a[i]
        a[i] = 0
        if a[i+1] >= b[i]:
            ans += b[i]
            a[i+1] -= b[i]
            b[i] = 0
        else:
            ans += a[i+1]
            a[i+1] = 0
print(ans)

Measured memory_bytes: 18624
import java.util.Scanner;

public class Main {

	@SuppressWarnings("resource")
	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		String s=scanner.next();
		if(s.length()==2) {
			System.out.println(s);
		}else {
			for(int i=0;i<3;i++) {
				System.out.print(s.charAt(2-i));
			}
			System.out.println();
		}

	}
}


Measured memory_bytes: 23124
n = int(input())
a = list(input().split())
m = int(input())
b = list(input().split())
# for i in range(max(len(a),len(b))):
#     if a[i] == b[i]:
#         if i+1 >= len(a) and len(b) > i+1 :
#             print('1')
#             break
#         elif i+1 >= len(b):
#             print('0')
#             break
#         pass    
#     elif a[i] < b[i]:
#         print('1')
#         break
#     else:
#         print('0')
#         break
print(+(a < b))


Measured memory_bytes: 5624
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define Aint(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef vector<int> v;
typedef vector<ll> vll;
typedef pair<int, int> P;
using Graph = vector<vector<int>>;
const int INF = 1001001001;
const int mINF = -1001001001;
const int mod = 1000000007;
// << fixed << setprecision(0) <<
// sort(ALL(),greater<int>());


int main() {
  int n,m;
  cin >> n >> m;
  v isOK(n+1,0);
  REP(i,m) {
    int a;
    cin >> a;
    isOK[a]=1;
  }
  int ans[n+1]={0};
  ans[0]=1;
  for(int i=1;i<=n;i++){
    if(isOK[i]==1) {
      ans[i]=0;
    } else if(isOK[i]==0) {
      if(i==1) {
        ans[i]=ans[i-1];
      } else {
        ans[i]=ans[i-1]+ans[i-2];
      }
    }
    ans[i]%=mod;
  }
  cout << ans[n] << endl;
  return 0;
}


Measured memory_bytes: 1024
# region header
import sys
import math
from bisect import bisect_left, bisect_right, insort_left, insort_right
from collections import defaultdict, deque, Counter
from copy import deepcopy
from fractions import gcd
from functools import lru_cache, reduce
from heapq import heappop, heappush
from itertools import accumulate, groupby, product, permutations, combinations, combinations_with_replacement
from math import ceil, floor, factorial, log, sqrt, sin, cos
from operator import itemgetter
from string import ascii_lowercase, ascii_uppercase, digits
sys.setrecursionlimit(10**7)
rs = lambda: sys.stdin.readline().rstrip()
ri = lambda: int(rs())
rf = lambda: float(rs())
rs_ = lambda: [_ for _ in rs().split()]
ri_ = lambda: [int(_) for _ in rs().split()]
rf_ = lambda: [float(_) for _ in rs().split()]
INF = float('inf')
MOD = 10 ** 9 + 7
PI = math.pi
# endregion
A, B, C, D = ri_()
print('Balanced' if A + B == C + D else 'Left' if A + B > C + D else 'Right')

Measured memory_bytes: 63212
N = int(input())

ans = 0

for i in range(1,N+1):
  if i % 2 == 0:
    continue
  count = 0
  for j in range(1,i+1):
    if i % j == 0:
      count += 1
  
  if count == 8:
    ans += 1


print(ans)

Measured memory_bytes: 2940
N,A,B,C = map(int,input().split(" "))

l = []


for i in range(0,N):
  inp = int(input())
  l.append(inp)


def select_bamboo(choice,mp,ID,a,b,c,aa,bb,cc):
  if ID > N-1 and aa>= 1 and bb >= 1 and cc >= 1:
    return mp + abs(A-a) + abs(B-b) + abs(C-c)
  elif ID > N-1:
    return 10**12
  
  if choice == "a":
    a += l[ID]
    if aa>=1:
      mp += 10
    aa += 1
    reta = min(select_bamboo("a",mp,ID+1,a,b,c,aa,bb,cc), select_bamboo("b",mp,ID+1,a,b,c,aa,bb,cc), select_bamboo("c",mp,ID+1,a,b,c,aa,bb,cc), select_bamboo("x",mp,ID+1,a,b,c,aa,bb,cc))
    return reta
  if choice == "b":
    b += l[ID]
    if bb>=1:
      mp += 10
    bb += 1
    retb = min(select_bamboo("a",mp,ID+1,a,b,c,aa,bb,cc),select_bamboo("b",mp,ID+1,a,b,c,aa,bb,cc),select_bamboo("c",mp,ID+1,a,b,c,aa,bb,cc),select_bamboo("x",mp,ID+1,a,b,c,aa,bb,cc))
    return retb
  if choice == "c":
    c += l[ID]
    if cc>=1:
      mp += 10
    cc += 1
    retc = min(select_bamboo("a",mp,ID+1,a,b,c,aa,bb,cc),select_bamboo("b",mp,ID+1,a,b,c,aa,bb,cc),select_bamboo("c",mp,ID+1,a,b,c,aa,bb,cc),select_bamboo("x",mp,ID+1,a,b,c,aa,bb,cc))
    return retc
  if choice == "x":
    retx = min(select_bamboo("a",mp,ID+1,a,b,c,aa,bb,cc),select_bamboo("b",mp,ID+1,a,b,c,aa,bb,cc),select_bamboo("c",mp,ID+1,a,b,c,aa,bb,cc),select_bamboo("x",mp,ID+1,a,b,c,aa,bb,cc))
    return retx
  

print(min(select_bamboo("a",0,0,0,0,0,0,0,0),select_bamboo("b",0,0,0,0,0,0,0,0),select_bamboo("c",0,0,0,0,0,0,0,0),select_bamboo("x",0,0,0,0,0,0,0,0)))


Measured memory_bytes: 3192
#include <cstdio>

int sum[1000][1000][3];

int main() {
    int i;
    int m, n;
    int k;

    scanf("%d %d", &m, &n);
    scanf("%d", &k);

    for (i=0;i<m;i++) {
        int j;
        for (j=0;j<n;j++) {
            sum[i][j][0] = 0;
            sum[i][j][1] = 0;
            sum[i][j][2] = 0;
        }
    }

    for (i=0;i<m;i++) {
        int j;
        for (j=0;j<n;j++) {
            char c;
            scanf(" %c", &c);

            if (i > 0) {
                sum[i][j][0] += sum[i-1][j][0];
                sum[i][j][1] += sum[i-1][j][1];
                sum[i][j][2] += sum[i-1][j][2];
            }

            if (j > 0) {
                sum[i][j][0] += sum[i][j-1][0];
                sum[i][j][1] += sum[i][j-1][1];
                sum[i][j][2] += sum[i][j-1][2];
            }

            if (i > 0 && j > 0) {
                sum[i][j][0] -= sum[i-1][j-1][0];
                sum[i][j][1] -= sum[i-1][j-1][1];
                sum[i][j][2] -= sum[i-1][j-1][2];
            }

            if (c == 'J') {
                sum[i][j][0] += 1;
            } else if (c == 'O') {
                sum[i][j][1] += 1;
            } else {
                sum[i][j][2] += 1;
            }
        }
    }

    for (i=0;i<k;i++) {
        int j;
        int x1, x2;
        int y1, y2;
        int calc[3];

        scanf("%d %d %d %d", &y1, &x1, &y2, &x2);
        x1--;
        y1--;
        x2--;
        y2--;

        for (j=0;j<3;j++) {
            calc[j] = sum[y2][x2][j];

            if (x1 > 0) {
                calc[j] -= sum[y2][x1-1][j];
            }

            if (y1 > 0) {
                calc[j] -= sum[y1-1][x2][j];
            }

            if (x1 > 0 && y1 > 0) {
                calc[j] += sum[y1-1][x1-1][j];
            }
        }

        printf("%d %d %d\n", calc[0], calc[1], calc[2]);
    }
}

Measured memory_bytes: 12624
import std.stdio,std.string,std.conv;

int main()
{
	string[char] ID;
	ID[' '] = "101";
	ID['\''] = "000000";
	ID[','] = "000011";
	ID['-'] = "10010001";
	ID['.'] = "010001";
	ID['?'] = "000001";
	ID['A'] = "100101";
	ID['B'] = "10011010";
	ID['C'] = "0101";
	ID['D'] = "0001";
	ID['E'] = "110";
	ID['F'] = "01001";
	ID['G'] = "10011011";
	ID['H'] = "010000";
	ID['I'] = "0111";
	ID['J'] = "10011000";
	ID['K'] = "0110";
	ID['L'] = "00100";
	ID['M'] = "10011001";
	ID['N'] = "10011110";
	ID['O'] = "00101";
	ID['P'] = "111";
	ID['Q'] = "10011111";
	ID['R'] = "1000";
	ID['S'] = "00110";
	ID['T'] = "00111";
	ID['U'] = "10011100";
	ID['V'] = "10011101";
	ID['W'] = "000010";
	ID['X'] = "10010010";
	ID['Y'] = "10010011";
	ID['Z'] = "10010000";

	string[string] Id;
	Id["00000"] = "A";
	Id["00001"] = "B";
	Id["00010"] = "C";
	Id["00011"] = "D";
	Id["00100"] = "E";
	Id["00101"] = "F";
	Id["00110"] = "G";
	Id["00111"] = "H";
	Id["01000"] = "I";
	Id["01001"] = "J";
	Id["01010"] = "K";
	Id["01011"] = "L";
	Id["01100"] = "M";
	Id["01101"] = "N";
	Id["01110"] = "O";
	Id["01111"] = "P";
	Id["10000"] = "Q";
	Id["10001"] = "R";
	Id["10010"] = "S";
	Id["10011"] = "T";
	Id["10100"] = "U";
	Id["10101"] = "V";
	Id["10110"] = "W";
	Id["10111"] = "X";
	Id["11000"] = "Y";
	Id["11001"] = "Z";
	Id["11010"] = " ";
	Id["11011"] = ".";
	Id["11100"] = ",";
	Id["11101"] = "-";
	Id["11110"] = "'";
	Id["11111"] = "?";

	string s;
	string str = "";
	while((s = readln.chomp).length != 0)
	{
		foreach(i;0..s.length)
		{
			str ~= ID[s[i]];
		}

		while(str.length % 5 != 0)
		{
			str ~= "0";
		}

		string ans = "";
		while(str.length != 0)
		{
			string temp = str[0..5];
			ans ~= Id[temp];
			str = str[5..$];
		}
		ans.writeln;
	}
	return 0;
}

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

#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define abs(a) max((a),-(a))
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repe(i,n) rep(i,(n)+1)
#define per(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define pere(i,n) rep(i,(n)+1)
#define all(x) (x).begin(),(x).end()
#define SP <<" "<<
#define RET return 0
#define MOD 1000000007
#define INF 1000000000000000000

typedef long long LL;
typedef long double LD;

int main(){
  int n,ww;
  cin >> n >> ww;
  vector<int> w(n),v(n);
  vector<LL> dp(1000*n+1,INF);
  dp[0]=0;
  for(int i=0;i<n;i++){
    cin >> w[i] >> v[i];
    for(int j=1000*(i+1)+1;j>=v[i];j--){
      dp[j]=min(dp[j],dp[j-v[i]]+w[i]);
    }
  }
  LL ans=0;
  for(int i=0;i<=1000*n;i++){
    if(dp[i]<=ww){
      ans=i;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <bits//stdc++.h>
using namespace std;
int main(void){
    int n,m,c,d,i,j,k;
    cin>>n>>m>>c;
    int minimum[n][n];
    vector<int> visit;
    for(i=0;i<c;i++){
        cin>>d;
        visit.push_back(d);
    }
    for(i=0;i<n;i++){
        for(j=0;j<n;j++){
            minimum[i][j]=INT_MAX/2;
        }
    }
    for(i=0;i<m;i++){
        int a,b;
        cin>>a>>b>>d;
        minimum[a-1][b-1]=d;
        minimum[b-1][a-1]=d;
    }
    for(k=0;k<n;k++){
        for(j=0;j<n;j++){
            for(i=0;i<n;i++){
                minimum[i][j]=min(minimum[i][j],minimum[i][k]+minimum[k][j]);
            }
        }
    }
    sort(visit.begin(),visit.end());
    int answer=INT_MAX;
    int tmp;
    do{
        tmp=0;
        for(i=0;i<c-1;i++){
           tmp=tmp+minimum[visit[i]-1][visit[i+1]-1];
        }
        answer=min(tmp,answer);
    }while(next_permutation(visit.begin(),visit.end()));
    cout<<answer<<endl;
    
    
}




Measured memory_bytes: 384
N,M = map(int,input().split())
a = list(map(int,input().split()))
for i in range(len(a)):
    a[i] = a[i]*(-1)
import heapq
heapq.heapify(a)
for _ in range(M):
    x = (-1)*heapq.heappop(a)
    y = x//2
    heapq.heappush(a,-y)
print((-1)*sum(a))

Measured memory_bytes: 14224
#include<iostream>
#include<queue>
#include<string.h>
using namespace std;
long long  cheese[1001][1001];
long long  check[1001][1001];
char num[11]={'0','1','2','3','4','5','6','7','8','9'};
int q[4]={0,1,0,-1};
int p[4]={1,0,-1,0};
struct ST {
	int a;
	int b;
	int c;
	int d;
};
int main(){
	memset(cheese,0,sizeof(cheese));
	memset(check,0,sizeof(check));
	int h,w,n;
	int i,j,m;
	int ys,xs;
	char data;
	queue <ST> Q;
	ST x;
	ST y;
	cin>>h>>w>>n;//??¢??????????????°
	for(i=1;i<=h;i++){
		for(j=1;j<=w;j++){
			cin>>data;
			if(data=='S'){//????????????
				ys=i;//??????????????§?¨?
				xs=j;
			}
			else if(data=='X'){//?????????
				cheese[i][j]=-1;
			}
			else if(data!='.'){
				for(m=1;m<=9;m++){
					if(num[m]==data){
						cheese[i][j]=m;
					}
				}
			}
		}
	}
	x.a=ys;
	x.b=xs;
	x.c=0;
	x.d=1;
	Q.push(x);
	while(!Q.empty()){
		y=Q.front();
		Q.pop();
		if(check[y.a][y.b]==1)continue;
		check[y.a][y.b]=1;
		if(y.d==cheese[y.a][y.b]){
			if(n==y.d) break;
			memset(check,0,sizeof(check));
			while(!Q.empty()){
				Q.pop();
			}
			y.d+=1;
			x.a=y.a;
			x.b=y.b;
			x.c=y.c;
			x.d=y.d;
			Q.push(x);
			continue;
		}
		for(i=0;i<4;i++){
			if(y.a+q[i]>0&&y.a+q[i]<=h&&y.b+p[i]>0&&y.b+p[i]<=w&&check[y.a+q[i]][y.b+p[i]]!=1&&cheese[y.a][y.b]!=-1){
				x.a=y.a+q[i];
				x.b=y.b+p[i];
				x.c=y.c+1;
				x.d=y.d;
				Q.push(x);
			}
		}
	}
	cout<<y.c<<endl;
	return 0;
}

Measured memory_bytes: 18732
import heapq
n,k = map(int,input().split())
hlist = list(map(lambda x: int(x)*(-1),input().split()))

heapq.heapify(hlist)
if k < n:
  for i in range(k):
    heapq.heappop(hlist)
  print(-sum(hlist))
else:
  print(0)


Measured memory_bytes: 106452
#include <bits/stdc++.h>
#define all(X) (X).begin(),(X).end()
#define P 1000000007
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)

using namespace std;
using ll = long long;
typedef pair<int, int> ii;
typedef vector<ii> vii; 
typedef vector<int> vi;

void solve() {
	int h, n, a[100010];
	cin >> h >> n;
	for(int i = 0; i < n; i++) cin >> a[i];
	
	int sum = 0;
	for(int i = 0; i < n; i++) sum += a[i];
	if(sum >= h) cout << "Yes" << endl;
	else cout << "No" << endl;
}

int main(){
#define MULTITEST 0
#if MULTITEST   
 
    CASET {
        solve();
    }
    
#else

    solve();
    
#endif

    return 0;
}

Measured memory_bytes: 3896
#include<iostream>
#include<string>
using namespace std;
 
int main() {
  int n, ptt = 0, pth = 0, length;
  string wt, wh;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> wt;
    cin >> wh;
    length = (wt.size() > wh.size()) ? wh.size() : wt.size();
    int j = 0; 
    while (j < length) {
      if (wt[j] > wh[j]) { ptt += 3; break; }
      else if (wt[j] < wh[j]) { pth += 3; break; }
      j++;
    }
    if (j == length) {
      if (wt.size() < wh.size()) pth += 3;
      else if (wt.size() > wh.size()) ptt += 3;
      else { ptt++; pth++; }
    }
  }
  cout << ptt << " " << pth << endl;
  return 0;
}


Measured memory_bytes: 3160
S = int(input())
l = int(S/100)
r = int(S%100)

if 1 <= r <= 12:
  if 1 <= l <= 12:
    print('AMBIGUOUS')
  else:
    print('YYMM')
else:
  if 1 <= l <= 12:
    print('MMYY')
  else:
    print('NA')

Measured memory_bytes: 2940
#include <stdint.h>
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <tuple>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-12;
static const double PI = acos(-1.0);
static const ll MOD = 1000000007;

#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(a) (a).begin(), (a).end()
#define DEBUG(x) cout << #x << ": " << x << endl

void solve(long long D, std::vector<long long> c, std::vector<std::vector<long long>> s, std::vector<long long> t) {
  vector<ll> last(26, 0);
  ll score = 0;
  REP(d, D) {
    ll i = t[d] - 1;
    score += s[d][i];
    last[i] = d + 1;
    REP(j, 26) {
      score -= c[j] * (d + 1 - last[j]);
    }
    cout << score << endl;
  }
}

int main() {
  long long D;
  scanf("%lld", &D);
  std::vector<long long> c(26);
  for (int i = 0; i < 26; i++) {
    scanf("%lld", &c[i]);
  }
  std::vector<std::vector<long long>> s(D, std::vector<long long>(26));
  for (int i = 0; i < D; i++) {
    for (int j = 0; j < 26; j++) {
      scanf("%lld", &s[i][j]);
    }
  }
  std::vector<long long> t(D);
  for (int i = 0; i < D; i++) {
    scanf("%lld", &t[i]);
  }
  solve(D, std::move(c), std::move(s), std::move(t));
  return 0;
}


Measured memory_bytes: 3716
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const ll mod=1e9+7;


ll power(ll a,ll b)
{
 ll res=1;
    while(b)
    {
     if(b&1)res=res*a;
        a=a*a;
        b/=2;
    }
    return res;
}

void solve()
{
  string s;
    cin>>s;
    int n=s.size();
    if(s[n-1]=='s')
    {
     s+="es";
    }
    else s+="s";
    cout<<s<<endl;
}


int main()
{
 ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    int t=1;
   // cin>>t;
    while(t--)
        solve();
}

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

#define rep(X,N) for(ll X = 0LL; X < (N); X++)
#define ALL(V) (V).begin(),(V).end()
#define endl "\n"

using namespace std;
typedef long long ll;

const double PI = 3.1415926535897932384626;
const ll MODN = 1000000007;
const ll MODN2 = 998244353;
const double EPS = 1e-10;

int main(){

    int n;
    ll x;
    cin >> n >> x;

    vector<ll> patty(51);
    patty[0] = 1;

    vector<ll> burger(51);
    burger[0] = 1;

    for(int i = 1; i <= 50; i++){
        patty[i] = patty[i - 1] * 2 + 1;
        burger[i] = burger[i - 1] * 2 + 3;
    }

    function<ll(int, ll)> f = [&](int ni, ll xi) -> ll{
        if(ni == 0 && xi >= 1){
            return 1;
        }

        if(xi <= 1){
            return 0;
        }else if(xi <= burger[ni - 1] + 1){
            return f(ni - 1, xi - 1);
        }else if(xi == burger[ni - 1] + 2){
            return patty[ni - 1] + 1;
        }else{
            return patty[ni - 1] + 1 + f(ni - 1, xi - 2 - burger[ni - 1]);
        }
    };

    cout << f(n, x) << endl;
    return 0;
}


Measured memory_bytes: 3608
#include <cctype>
#include <cstdio>
#include <cstring>
#include <algorithm>
#define rep(i,x,y) for (int i=x; i<=y; ++i)
#define repd(i,x,y) for (int i=x; i>=y; --i)
 
int get()
{
    char c;
    while (!isdigit(c=getchar()));
    int k=c-'0';
    for (; isdigit(c=getchar()); k=k*10+c-'0');
    return k;
}
 
using namespace std;
const int N=1e5+10,mod=1e9+7;
char s[N];
int n,m,ans,fac[N],ifac[N],l[N],r[N],lb[N],rb[N],f[2][N],a[N];

int inv(int x)
{
    return x>1? 1ll*(mod-mod/x)*inv(mod%x)%mod:1;
}

int c(int n,int m)
{
    return 1ll*fac[n]*ifac[m]%mod*ifac[n-m]%mod;
}
 
int main()
{
    n=get(),m=get();
    fac[0]=1;
    rep(i,1,n)
        fac[i]=1ll*fac[i-1]*i%mod;
    ifac[n]=inv(fac[n]);
    repd(i,n,1)
        ifac[i-1]=1ll*ifac[i]*i%mod;
    scanf("%s",s+1);
    rep(i,1,n)
        a[i]=a[i-1]+s[i]-48;
    int t=0;
    rep(i,1,m)
    {
        int x=get(),y=get();
        if (x==l[t])
            r[t]=max(r[t],y);
        else if (y>r[t])
            ++t,l[t]=x,r[t]=y;
    }
    m=t,l[m+1]=n+1,f[0][0]=1;
    rep(i,1,m)
    {
        static int *f=::f[0],*g=::f[1];
        swap(f,g);
        int w=a[r[i]]-a[max(l[i]-1,r[i-1])];
        int s=min(r[i],l[i+1]-1)-l[i]+1;
        int mx=r[i]-l[i]+1-s;
        lb[i]=max(0,lb[i-1]+w-s),rb[i]=min(mx,rb[i-1]+w);
        rep(j,lb[i],rb[i])
            rep(k,lb[i-1],rb[i-1])
                f[j]=(f[j]+1ll*g[k]*c(s,k+w-j))%mod;
        memset(g+lb[i-1],0,sizeof(int)*(rb[i-1]-lb[i-1]+1));
    }
    rep(i,0,n)
        ans=(ans+f[m&1][i])%mod;
    printf("%d",ans);
    return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <complex>
#include <algorithm>
#include <vector>
#include <stack>
#include <string>
#include <queue>
#include <cmath>
#include <math.h>
#include <numeric>
#include <list>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <climits>
#include <set>
#include <memory.h>
#include <memory>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cassert>
#include <map>
#include <cassert>
#include <time.h>

using namespace std;

typedef complex<double> xy_t;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<int , P> PP;
typedef pair<int, string> Ps;
typedef vector<int> vec;
typedef vector<vec> mat;
const int INF= 1 << 30;
const double EPS = 1e-9;
const double PI = 3.1415926535897932384626433832795;

#define rep(i, n) for(int i = 0; i < n; i++)
double r[12];
double dp[12][1 << 12];

int main(){
	int n;
	double b;
	int num;
	string s;
	while(cin >> b){
		n = 0;
		fill(&dp[0][0], &dp[11][(1 << 12) - 1] + 1, (double)INF);
		getline(cin , s);
		istringstream in(s);
		while(in >> num) {
			r[n++] = num;
		}
		rep(i, n) dp[i][1 << i] = r[i] * 2;
		rep(i, 1 << n){
			rep(j, n){
				if(i & (1 << j)){
					rep(k, n){
						if(!(i & (1 << k))){
							dp[k][i | (1 << k)] = min(dp[k][i | (1 << k)],
								dp[j][i] + r[k] - r[j] + sqrt((r[k] + r[j]) * (r[k] + r[j]) - 
								(r[k] - r[j]) * (r[k] - r[j])));
						}
					}
				}
			}
		}
		double res = 1e10;
		rep(i, n) res = min(dp[i][(1 << n) - 1], res);
		//cout << n << " " << res  << endl;
		if(res < b + EPS) cout << "OK" << endl;
		else cout << "NA" << endl;
	}
	return 0;
}

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

int a[12][12];
const int INF= pow(10,5)*20+9;

int main() {
  int n,m,x;
  cin >> n >> m >> x;
  vector <int> c(n);
  
  rep(i,n) {
    cin>> c[i];
    rep(j,m) cin >>a[i][j];
  }
  
  int ans =INF;
  rep(s,1<<n){
    int cost=0;
    vector<int> d(m);
    
    rep(i,n){
      if(s>>i&1){
        cost += c[i];
        rep(j,m) d[j]+= a[i][j];
      }
    }
    bool ok=true;
    rep(j,m) if (d[j]<x) ok=false;
    if(ok) ans= min(ans,cost);
  }
  if (ans==INF) cout <<-1<<endl;
  else cout <<ans<<endl;
  
  return 0;
}

Measured memory_bytes: 3620
def resolve():
	n = int(input())
	c = []
	for _ in range(n):
		c.append(list(map(int, input().split())))
	dp = [[0, 0, 0] for _ in range(n)]
	dp[0] = c[0]
	for i in range(n-1):
		for j in range(3):
			for k in range(3):
				if j == k:
					continue
				else:
					dp[i+1][j] = max(dp[i+1][j], dp[i][k] + c[i+1][j])
	print(max(dp[-1]))
resolve()

Measured memory_bytes: 47352
package main

import "fmt"

func main() {
	a := make([]int, 5)
	for i := 0; i < 5; i++ {
		fmt.Scan(&a[i])
	}

	var k int
	fmt.Scan(&k)

	for i := 0; i < 4; i++ {
		for j := i + 1; j < 5; j++ {
			if v := a[j] - a[i]; v > k {
				fmt.Println(":(")
				return
			}
		}
	}
	fmt.Println("Yay!")
}


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

#define fast ios_base::sync_with_stdio(false),cin.tie(NULL)
#define ldb long double 
#define db double
#define int long long

#define fr first
#define se second
#define lb lower_bound 
#define ub upper_bound 
#define pb push_back
#define mpr make_pair

#define pi pair<int,int>
#define pdb pair<db,db>
#define pldb pair<ldb,ldb>

#define vi vector<int>
#define vdb vector<db>
#define vldb vector<ldb>
#define vpi vector< pi >

#define mi map<int,int>
#define mdb map<db,db>
#define mldb map<ldb,ldb>


#define forr(a,b) for (int i = (a); i < (b); ++i)
#define rrof(a,b) for (int i = (b)-1; i >= (a); --i)

#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)

const int md = 1e9+7;
const int MX = 2e5+5;
const int INF = 1e18; 
const ldb PI = 4*atan((ldb)1);

int power_md(int a,int n)
{
 int res=1;
 while(n)
{
 if(n%2)
  res=(res%md*a%md)%md;
  a=(a%md*a%md)%md;
  n/=2;
}
res%=md;
return res;
}

int power(int a,int n)
{
 int res=1;
 while(n)
{
 if(n%2)
  res*=a;
  a=a*a;
  n/=2;
}
return res;
}

int abst(int a)
{
 return ((a<0)?(-1*a):(a));
}

class cmp_set{
public:
	bool operator() (int a, int b){
		return a > b;
	}
};

vector<string> vec_splitter(string s) {
	s += ',';
	vector<string> res;
	while(!s.empty()) {
		res.push_back(s.substr(0, s.find(',')));
		s = s.substr(s.find(',') + 1);
	}
	return res;
}
void debug_out(
vector<string> __attribute__ ((unused)) args,
__attribute__ ((unused)) int idx, 
__attribute__ ((unused)) int LINE_NUM) { cerr << endl; } 
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
	if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
	stringstream ss; ss << H;
	cerr << args[idx] << " = " << ss.str();
	debug_out(args, idx + 1, LINE_NUM, T...);
}
#ifdef XOX
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define debug(...) 42
#endif

/*int ter_search(int l,int r)
{
    while((r-l)>0)
    {
        int m1=l+(r-l)/3;
        int m2=r-(r-l)/3;
        int f1=f(m1);
        int f2=f(m2);
        if(f1>f2)
         l=m1+1;
         else
          r=m2-1;
    }
    return f(l);
}*/

int32_t main()
{
   fast;
   int s;
   cin>>s;
   if(s<3)
   {
       cout<<0<<"\n";
       return 0;
   }
   int dp[(s+5)];
   for(int i=0;i<(s+5);i++)
    dp[i]=0;
    dp[3]=1;
    dp[0]=1;
   for(int i=4;i<=s;i++)
   {
       for(int j=3;j<=i;j++)
       {
        if((i-j)>0&&(i-j)<3)
         continue;
        dp[i]=(dp[i]%md+(dp[i-j]%md))%md;
       }
   }
   cout<<dp[s]<<"\n";
   return 0;
}

Measured memory_bytes: 3636
def input_from_console():
    s = input().rstrip()
    return s


def solve(s):
    if s == "ARC":
        return "ABC"
    return "ARC"

def main():
    s = input_from_console()
    print(solve(s))


if __name__ == "__main__":
    import sys

    if sys.gettrace():  # Check if the python interpreter is in debug mode or not.
        check_cases()
    else:
        main()

Measured memory_bytes: 8984
(defun _sw (n m lst p-lst)
     (let ((sw-status (make-array n :initial-element 0)))
       (labels ((sw-k (sw-lst p)
                      (let ((sw-sum
                              (reduce #'(lambda (a b)
                                          (+ a (aref sw-status (- b 1))))
                                      sw-lst
                                      ::initial-value 0)))
                        (= p (mod sw-sum 2))))
                (check-sw (_lst p-lst)
                          (if (null _lst) t
                            (let ((sw-lst (cdar _lst))
                                  (p (car p-lst)))
                              (if (not (sw-k sw-lst p)) nil
                                (check-sw (cdr _lst) (cdr p-lst))))))
                (set-array (_v _i)
                           (if (= _v 0) t
                             (multiple-value-bind (next_v mod_v) (floor _v 2)
                               (setf (aref sw-status _i) mod_v)
                               (set-array next_v (+ _i 1)))))

                (walk-array (i max-n rv)
                            (if (= i max-n) rv
                              (let ((next-i (+ i 1)))
                                  (set-array i 0)
                                  (walk-array next-i max-n (if (check-sw lst p-lst) (+ rv 1) rv))))))
         (walk-array 0 (expt 2 n) 0))))

(defun sw (n m lst p-lst)
  (print
    (_sw n m lst p-lst)))

#|
(sw 2 2 '((2 1 2) (1 2)) '(0 1))
(sw 2 3 '((2 1 2) (1 1) (1 2)) '(0 0 1))
(sw 5 2 '((3 1 2 5) (2 2 3)) '(1 0))
|#

(let* ((n (read))
       (m (read))
       (lst (labels ((read-n (my-n rv)
                             (if (= my-n 0) (cons 0 (nreverse rv))
                               (let ((a (read)))
                                 (read-n (- my-n 1) (cons a rv)))))

                     (read-m (my-m rv)
                               (if (= my-m 0) (nreverse rv)
                                 (let* ((dn (read))
                                        (_lst (read-n dn nil)))
                                   (read-m (- my-m 1) (cons _lst rv))))))
              (read-m m nil)))

       (p-lst (labels ((read-p (my-m rv)
                               (if (= my-m 0) (nreverse rv)
                                 (let ((p (read)))
                                   (read-p (- my-m 1) (cons p rv))))))
                (read-p m nil))))
  (sw n m lst p-lst))


Measured memory_bytes: 17252
#include  <iostream>
#include  <stdio.h>
#include <algorithm>
using namespace std;
#include <vector>
#define rep(i,n) for (int i = 0; i < (n) ; i++)
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define ll long long
#define ull unsigned long long
#define vint vector<int>
#define vll vector<ll>

//#include <stack>
//#include <queue>

/*
#include <math.h>
int standerd = int(pow(10.0,9.0)) + 7;
*/
string ans_Yes = "Yes"; 
string ans_No = "No"; 
string ans_yes = "yes"; 
string ans_no = "no"; 

ll ABC[4];
ll N;
ll A;
ll B;
ll C;

int main(){

    
    cin >> N;
    cin >> A;
    cin >> B;
    cin >> C;
    ABC[0]=A;
    ABC[1]=B;
    ABC[2]=C;
    string VAL[4];
    VAL[0]="A";
    VAL[1]="B";
    VAL[2]="C";

    string flag="Yes";
    vector<string> ans;
    vector<string> ss;
    string sentaku;
    int index1;
    int index2;
    if(A==0&&B==0&&C==0){
        cout << "No" << endl;
    }else{
        rep(ni,N){
            cin >> sentaku;
            ss.push_back(sentaku);
        }
        rep(ni,N){
            sentaku=ss[ni];
            if(sentaku=="AB"){
                index1=0;
                index2=1;
            } else if(sentaku=="BC"){
                index1=1;
                index2=2;
            } else{
                index1=0;
                index2=2;
            }

            if(ABC[index1]==0&&ABC[index2]==0){
                flag="No";
                break;
            }else if(ABC[index1]==1&&ABC[index2]==1&&ni+1<N){
                if(ss[ni+1].substr(0,1)==VAL[index1]){
                    if(ss[ni+1].substr(1,1)==VAL[index2]){
                        ABC[index1]--;
                        ABC[index2]++;
                        ans.push_back(VAL[index2]);
                    }else{
                        ABC[index2]--;
                        ABC[index1]++;
                        ans.push_back(VAL[index1]);

                    }
                }else if(ss[ni+1].substr(1,1)==VAL[index1]){
                    ABC[index2]--;
                    ABC[index1]++;
                    ans.push_back(VAL[index1]);
                }else{
                    ABC[index1]--;
                    ABC[index2]++;
                    ans.push_back(VAL[index2]);
                }
            }else{
                if(ABC[index1]>=ABC[index2]){
                    ABC[index1]--;
                    ABC[index2]++;
                    ans.push_back(VAL[index2]);
                }else{
                    ABC[index2]--;
                    ABC[index1]++;
                    ans.push_back(VAL[index1]);
                }
            }

        }
        cout << flag << endl;
        if(flag=="Yes"){
            rep(ni,ans.size()){
                cout << ans[ni] << endl;
            }
        }
    }
}

Measured memory_bytes: 12452
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>

using namespace std;

typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;

const int iinf = 1 << 29;
const int imax = ~(1 << 31);
const long long linf = 1ll << 61;
const long long lmax = ~(1ll << 63);

#define dump(x) cerr << #x << " : " << x << '\n'
#define MOD(x, y) (((y) + (x) % (y)) % (y))

string s;
int N, K;
string t[5 * 5000];

int main(int argc, char* argv[])
{
    cin >> s;
    cin >> K;
    N = s.length();

    int k = 0;
    for (int i = 0; i < N; i++) {
        for (int j = 1; j <= K; j++) {
            if (i + j - 1 >= N) continue;
            t[k] = s.substr(i, j);
            k++;
        }
    }
    sort(t, t + k);
    int i;
    for (i = 0; i < k; i++) {
        if (t[i] != t[i + 1]) K--;
        if (K == 0) break;
    }
    cout << t[i] << endl;

	return 0;
}


Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
int n,a,i;
main(){
    string s;
    cin>>s;
    n=s.size();
    s+="#";
    while(i<n){
        int mp[1000]={};
        for (auto c:"JOI"){
            while(s[i]==c){
                mp[c]++;
                i++;
            }
        }
        if (mp['J'] >= mp['O'] && mp['O'] <= mp['I']) {
            a=max(a, mp['O']);
        }
    }
    cout << a << endl;

}

Measured memory_bytes: 3968
const input=require('fs').readFileSync('/dev/stdin', 'utf8').split(/[\s]/);const nin=()=>{const r = input[0];input.shift();return Number(r)};const nrin=(n)=>{const a:number[]=[];rep(n,()=>a.push(nin()));return a};const sin=()=>{const r = input[0];input.shift();return String(r)};const out=(...a)=>{console.log(...a)};const floor=(a)=>{return Math.floor(a)};const abs=(a)=>{return Math.abs(a)};const min=(...a)=>{return Math.min(...a)};const max=(...a)=>{return Math.max(...a)};const rep=(n, callback)=>{for(let i = 0;i < n; i++){callback()}};const strrep=(s, i, v)=>{return s.slice(0, i)+v+s.slice(i+1);};const permutation=({result=[],pre=[],post,n=post.length})=>{if(n>0){post.forEach((_,i)=>{const rest=[...post];const elem=rest.splice(i, 1);permutation({result, pre: [...pre,...elem],post:rest,n:n-1})})}else{result.push(pre)}return result};const sw=(s,a:any[],op:'=='|'>='|'>'|'<='|'<'='==')=>{for(let i=0;i<a.length;i+=2){if(op==='=='){if(s==a[i])return a[i+1]}else if(op==='>='){if(s>=a[i])return a[i+1]}else if(op==='<='){if(s<=a[i])return a[i+1]}else if(op==='>'){if(s>a[i])return a[i+1]}else if(op==='<'){if(s<a[i])return a[i+1]}}return a[a.length-1];};const or=(a,...b)=>{for(let i=0;i<b.length;i++)if(a==b[i])return true;return false};const maxindex=(...a)=>{return a.indexOf(Math.max.apply(null,a))};const asc=(ar:number[])=>{return ar.sort((a,b)=>{return a-b})};const desc=(ar:number[])=>{return ar.sort((a,b)=>{return b-a})};const ceil=a=>{return Math.ceil(a)};const srin=s=>{const a:string[]=[];rep(s,()=>a.push(sin()));return a};let ssinteger=-1;const ssin=()=>{ssinteger++;return input[0][ssinteger]};
const main = ()=>{
  out(sin()==sin()?'H':'D')
}
main()

Measured memory_bytes: 7372
#pragma warning(disable:4996)
#include<stdio.h>
void bubbleSort(int A[],int N) {
	int k = 0;
	for (int i = 0; i < N; i++) {
		for (int j = N - 1; j> i; j--) {//从数组末尾至i出遍历
			if (A[j] < A[j - 1]) {//若逆序，交换之
				int temp = A[j];
				A[j] = A[j - 1];
				A[j - 1] = temp;
				k++;
			}
		}
	}
	for (int i = 0; i < N; i++) {
		if (i != 0) {
			printf(" ");
		}
		printf("%d", A[i]);
		
	}
	printf("\n%d\n", k);
}
int main() {
	int N,A[100];
	scanf("%d", &N);
	for (int i = 0; i < N; i++) {
		scanf("%d", &A[i]);
	}
	bubbleSort(A, N);
	
	return 0;
}


Measured memory_bytes: 2756
import itertools
import functools
import math
from collections import Counter
from itertools import combinations

N,M=map(int,input().split())

ans = 0
if N >= 2:
    ans += len(list(itertools.combinations(range(N), 2)))
if M >= 2:
    ans += len(list(itertools.combinations(range(M), 2)))

print(ans)


Measured memory_bytes: 9632
import sys
k, x= map(int, input().split())
if x-k+1 < -1000000:
	s = -1000000
else:
	s = x-k+1
if x+k-1 >1000000:
	f = 1000000
else:
	f = x+k-1
for i in range(s,f):
	sys.stdout.write(str(i))
	sys.stdout.write(" ")
sys.stdout.write(str(f))

Measured memory_bytes: 3060
#include<iostream>
using namespace std;
int main()
{
    int a,b;
	cin>>a>>b;
	if(a<b){
		for(int at=1;at<=b;at++)
		{
			cout<<a;
		}
	}else if(b<a){
		for(int bt=1;bt<=a;bt++)
		{
			cout<<b;
		}	
	}else{
		for(int t=1;t<=b;t++)
		{
			cout<<a;
		}	
	}
    return 0;
}

Measured memory_bytes: 256