akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstring>
#include<algorithm>
#include<vector>
#include<cmath>
#include<limits>
#include<map>
#define ll long long
#define ALL(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define int_INF 2147483647
#define ll_INF 	9223372036854775807
#define vi vector<int>
#define vll vector<long long>
#define pii pair<int,int>
using namespace std;

inline int c_to_i(char c) {
	if ('a' <= c && c <= 'z') {
		return c - 'a';
	}
	else {
		return -1;
	}
}

inline int isExchangeable(char s, char t, vi v) {
	if (v[c_to_i(s)] == 0 && v[c_to_i(t)] == 0) {
		return 1;
	}
	else {
		return 0;
	}
}

void replace_all(const char s, const char t, string& T) {
	//Tに含まれるsとtを交換する
	for (int i = 0; i < T.size(); i++) {
		if (T[i] == t) {
			T[i] = s;
		}
		else if(T[i] == s) {
			T[i] = t;
		}
		//cout << T << endl;
	}

}
int main() {
	string s, t;
	cin >> t >> s;
	vi stack(26, 0);
	//下から直してくスタックが切れたら終わり
	bool flag = true;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] != t[i]) {
			if (isExchangeable(s[i], t[i], stack)) {

				stack[c_to_i(s[i])] = 1;
				replace_all(s[i], t[i], t);
			}
			else {
				flag = false;
				break;
			}
		}
		else {
			stack[c_to_i(s[i])] = 1;
		}
		//cout << t << endl;
	}

	if (flag) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}


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


using namespace std;
using LL = long long;
const int N = 1e5 + 5;
int a[N], b[N << 1];

int main(){
    int n, x;
    cin >> n;
    int cur = 0;
    a[cur++] = 0;
    for(int i = 0; i < n; i++){
        cin >> x;
        a[cur++] = x;
    }
    a[cur++] = 0;
    LL sum = 0;
    for(int i = 1; i < cur; i++){
        sum += abs(a[i] - a[i - 1]);
    }

    for(int i = 1; i < cur - 1; i++){
        LL tmp = abs(a[i-1] - a[i]) + abs(a[i+1] - a[i]);
        LL dis = abs(a[i - 1] - a[i + 1]);
        cout << sum - tmp + dis << endl;
    }
}


Measured memory_bytes: 1664
#include <stdio.h>
  
int main()
{
  int i, n, minv, maxv;
  int r;
  
  scanf("%d", &n);
  
  for(i=0; i<n; i++) {
	scanf( "%d", &r );
	if( i == 0 ){
		maxv = -1000-r;
		minv = r;
	}else{
		if(maxv < r-minv) maxv = r-minv;
		if(minv > r) minv = r;
	}
  }
  printf("%d\n", maxv);
  return 0;
}

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

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


Measured memory_bytes: 256
# -*- coding: utf-8 -*-

import sys
from collections import Counter

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N = INT()
A = LIST()
C = Counter(A)

# dp[i][j][k] := 3個残りがi個、2個残りがj個、1個残りがk個である状態にするまでの操作回数の期待値
dp = list3d(N+1, N+1, N+1, INF)
# 全て残0なら残り回数は0
dp[0][0][0] = 0.0
for i in range(N+1):
    for j in range(N+1):
        # 枝刈り
        if i+j > N:
            break
        for k in range(N+1):
            # 枝刈り
            if i+j+k > N:
                break
            if i == j == k == 0:
                continue
            # 今現在残っている皿を取る確率
            tmp = (i + j + k) / N
            # そのために必要な回数
            res = 1 / tmp
            # それ以降に必要な回数
            if i and j < N: 
                res += (i/N) / tmp * dp[i-1][j+1][k]
            if j and k < N: 
                res += (j/N) / tmp * dp[i][j-1][k+1]
            if k: 
                res += (k/N) / tmp * dp[i][j][k-1]
            dp[i][j][k] = res
print(dp[C[3]][C[2]][C[1]])


Measured memory_bytes: 256648
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1'000'000'007;

ll p2(ll e) {
    if (e == 0) return 1;
    if (e == 1) return 2;
    if (e & 1) return 2 * p2(e - 1) % mod;
    ll r = p2(e >> 1);
    return r * r % mod;
}

ll solve(vector<ll>& hs) {
    if (hs.empty()) return 1;
    set<ll> vset(hs.begin(), hs.end());
    vector<ll> vs(vset.begin(), vset.end());
    map<ll,int> vi;
    for (int i = 0; i < vs.size(); i++) vi[vs[i]] = i;
    vector<ll> ans(vs.size(), 1LL);
    ll total = 1;
    ll ph = 0;
    for (ll h: hs) {
        if (ph == 0) {
            for (int i = 0; i <= vi[h]; i++) {
                ans[i] = p2(h - vs[i]);
            }
            total = p2(h);
        } else if (ph <= h) {
            vector<ll> pans(ans.begin(), ans.end());
            for (int i = 0; i <= vi[h]; i++) {
                ans[i] = (pans[min(i, vi[ph])] + pans[vi[ph]]) * p2(h - max(vs[i], ph));
                ans[i] %= mod;
            }
            total = (total + 2 * pans[vi[ph]]) * p2(h - ph);
            total %= mod;
        } else {
            vector<ll> pans(ans.begin(), ans.end());
            for (int i = 0; i <= vi[h]; i++) {
                ans[i] = pans[i] + pans[vi[h]];
                ans[i] %= mod;
            }
            total = (total + 2 * pans[vi[h]]);
            total %= mod;
        }
        ph = h;
        // printf("after h = %lld: total = %lld\n", h, total);
        // for (int i = 0; i < vs.size(); i++) {
        //     printf("%lld: %lld\n", vs[i], ans[i]);
        // }
        // printf("\n");
    }
    return total;
}

int main() {
    int n;
    scanf("%d", &n);
    vector<ll> h;
    ll ans = 1;
    for (int i = 0; i < n; i++) {
        ll v;
        scanf("%lld", &v);
        if (v == 1) {
            ans *= 2;
            ans %= mod;
            ans *= solve(h);
            ans %= mod;
            h.clear();
        } else {
            h.push_back(v);
        }
    }
    ans *= solve(h);
    ans %= mod;
    printf("%lld\n", (ans % mod + mod) % mod);
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<set>
#include<map>
using namespace std;

static const int INF=1e9;
typedef long long ll;
typedef pair<int,int> P;

int main(){
   int N,K;
   cin >> N >> K;
   if(N%K==0) cout << 0 << endl;
   else cout << N-K << endl;
}


Measured memory_bytes: 256
fn get_input() -> String {
    let mut word = String::new();
    std::io::stdin().read_line(&mut word).unwrap();
    word.trim().to_owned()
}

fn main() {
    let n:usize = get_input().parse().unwrap();
    let mut a:Vec<i64> = Vec::new();
    let mut b:Vec<i64> = Vec::new();
    let mut c:Vec<i64> = Vec::new();

    for _ in 0..n {
        let line = get_input();
        let mut split = line.split_whitespace();
        a.push(split.next().unwrap().parse().unwrap());
        b.push(split.next().unwrap().parse().unwrap());
        c.push(split.next().unwrap().parse().unwrap());
    }

    let mut dp = [[0; 3]; 100010];

    for i in 0..n {
        for j in 0..3 {
            for l in 0..3 {
                if j == l { continue; }
                let s = dp[i][l] + if l == 0 { a[i] } else if l == 1 { b[i] } else { c[i] };
                dp[i + 1][j] = std::cmp::max(s, dp[i + 1][j]);
            }
        }
    }

    println!("{}", dp[n].iter().max().unwrap());
}


Measured memory_bytes: 10748
using System;

public class Hello
{
    public static void Main()
    {
        var s = Console.ReadLine().Trim();
        Console.WriteLine(getAns(s));
    }
    static int getAns(string s)
    {
        var week = new string[] { "SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT" };
        for (int i = 0; i < 7; i++)
            if (week[i] == s) return 7 - i;
        return 0;
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using Bint = boost::multiprecision::cpp_int;
using namespace std;
typedef long long ll;
typedef pair<int, ll> Pil;

int N;
const int MAX_N = 1.0e5 + 10;
Bint A[MAX_N];

int main() {
    cin >> N;
    for (int i = 0; i < N; i++) cin >> A[i];

    bool is_over = false;
    Bint mul_A = 1;
    for (int i = 0; i < N; i++) {
        if (A[i] == 0) {
            is_over = false;
            mul_A = 0;
            break;
        }
    }

    if (mul_A != 0) {
        for (int i = 0; i < N; i++) {
            mul_A *= A[i];
            if (mul_A > (Bint)1.0e18) {
                is_over = true;
                break;
            }
        }
    }

    cout << (is_over ? -1 : mul_A) << endl;

    
    return 0; 
}

Measured memory_bytes: 6884
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#define IO(i, o) freopen(i, "r", stdin), freopen(o, "w", stdout)

using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count());

long long x, y;

int main(){
	//IO("input.txt", "output.txt");
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> x >> y;
	long long cur = x;
	int cnt = 0;
	while(cur <= y){
		cnt++;
		cur *= 2;
	}
	cout << cnt << "\n";
	return 0;
}

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

int main() {
    double W, H, x, y;
    cin >> W >> H >> x >> y;
    double ans = W * H / 2;
    if (x * 2 == W && y * 2 == H) cout << ans << " " << 1 << endl;
    else cout << ans << " " << 0 << endl;
}

Measured memory_bytes: 256
import itertools

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

abcd_list = []
for i in range(Q):
    abcd_list.append(list(map(int,input().split())))

A_list = itertools.combinations_with_replacement(range(1,M+1),N)
ans = 0
for A in A_list:
    sum_d = 0
    for a,b,c,d in abcd_list:
        if A[b-1] - A[a-1] == c:
            sum_d+=d
    ans = max(ans,sum_d)
print(ans)

Measured memory_bytes: 9084
import bisect
import os
from collections import Counter, deque
from fractions import gcd
from functools import lru_cache
from functools import reduce
import functools
import heapq
import itertools
import math
import numpy as np
import re
import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")

N, M, X = list(map(int, sys.stdin.readline().split()))
A = np.array(list(map(int, sys.stdin.readline().split())))

print(min(len(A[A > X]), len(A[A<X])))


Measured memory_bytes: 13768
#include <bits/stdc++.h>
using namespace std;
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(false), cout << fixed << setprecision(20);
#define int long long
#define gcd __gcd
#define all(x) (x).begin(), (x).end()
template<class T>
bool chmax(T& a, T b){return (a = max(a, b)) == b;}
template<class T>
bool chmin(T& a, T b){return (a = min(a, b)) == b;}
#define _overload(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(...) _overload(__VA_ARGS__, repi, _rep)(__VA_ARGS__)
#define _rev(i, n) revi(i, n, 0)
#define revi(i, a, b) for(int i = (int)(a - 1); i >= (int)(b); i--)
#define rev(...) _overload(__VA_ARGS__, revi, _rev)(__VA_ARGS__)
#define each(i, n) for(auto&& i: n)
const int INF = 1e18, MOD = 1e9 + 7;
struct UnionFind {
    vector<int> t;
    UnionFind(int size): t(size, -1) {}
    int root(int x) {return t[x] < 0 ? x : t[x] = root(t[x]);}
    int size(int x) {return -t[root(x)];}
    bool isSame(int x, int y) {return root(x) == root(y);}
    bool unite(int x, int y) {
        x = root(x), y = root(y);
        if(x != y) {
            if(t[y] < t[x]) swap(x, y);
            t[x] += t[y], t[y] = x;
        }
        return x != y;
    }
};
signed main() {
    INCANT;
    int n, m, a, b, c;
    cin>>n>>m;
    UnionFind uf(n);
    rep(i, m) {
        cin>>a>>b>>c;
        a--, b--;
        uf.unite(a, b);
    }
    set<int> s;
    rep(i, n) {
        s.insert(uf.root(i));
    }
    cout<<s.size()<<endl;
}


Measured memory_bytes: 5760
import java.util.*;

public class Main{
	public static void main(String[]args){

		Scanner sc=new Scanner(System.in);

		int n=sc.nextInt();
		int p[]=new int[n];
		for(int i=0;i<n;i++){
			p[i]=sc.nextInt();
		}

		int total=0;
		Arrays.sort(p);
		for(int i=0;i<n-1;i++){
			total+=p[i];
		}
		System.out.println(total+p[n-1]/2);

	}
}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
long min1(long long a,long long b,long long c){
	return min(min(a*b,a*c),b*c);
}
int main() {
	long long a,b,c;
	cin>>a>>b>>c;
	if(!(a%2)||!(b%2)||!(c%2)) {
		cout<<0;
		return 0;
	}
	cout<<min1(a,b,c);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
  int n;
  cin>>n;
  int number=0;
  int temp=n;
  int answer=0;
  int multiplier=9;
  while(temp/10>0)
  {
    number++;
    temp=temp/10;
    if(number%2!=0)
      answer+=multiplier;
  	multiplier=multiplier*10;
  	
  }
  if(temp!=0&&number%2==0)
    answer+=(n-multiplier/9+1);
   cout<<answer;
  
  return 0;
}

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



struct cards{
	char suit;
	int num;
};

bool isStable( cards arr[], cards arr_stable[], size_t arr_s )
{
	for( size_t i=0; i<arr_s; i++ ){
		if( arr[i].suit != arr_stable[i].suit ){
			return false;
		}
	}
	return true;
}

void show( cards arr[], size_t size )
{
	for( size_t i=0; i<size; i++ ){
		cout<<arr[i].suit<<' '<<arr[i].num<<endl;
	}
}

void swap( cards &a, cards &b )
{
	cards t=a;
	a=b;
	b=t;
}

size_t partition(cards arr[], size_t arr_s, size_t left, size_t right)
{
	if( right >= arr_s ){
		cout<<"Error"<<endl;
		return -1;
	}


	size_t below=left-1;

	for( size_t above=left; above<right; above++ ){
		if( arr[above].num <= arr[right].num ){
			++below;
			swap( arr[above], arr[below] );
		}
	}
	swap( arr[right], arr[below+1] ); 
	return below+1; 
}

void merge( cards arr[], size_t arr_s, size_t lft, size_t md, size_t rgt )
{
	size_t left_s=md-lft+1, right_s=rgt-md+1;
	cards *left=new cards[left_s], *right=new cards[right_s];

	for( size_t i=0; i<left_s-1; i++ ){
		left[i]=arr[lft+i];
	}
	left[left_s-1].num=INT_MAX;
	for( size_t i=0; i<right_s-1; i++ ){
		right[i]=arr[md+i];
	}
	right[right_s-1].num=INT_MAX; 

	for( size_t i=0, left_i=0, right_i=0; i<left_s+right_s-2; i++ ){
		if( left[left_i].num <= right[right_i].num ){
			arr[lft +i]=left[left_i];
			++left_i;
		}else{
			arr[lft +i]=right[right_i];
			++right_i;
		}
	}

	delete[] right;delete[] left;
}

void mergeSort( cards arr[],  size_t arr_s,  size_t lft,  size_t rgt ) 
{
	size_t md=(lft + rgt)/2;
	if( rgt - lft >=2 ){ 

		mergeSort(arr, arr_s, lft, md);  
		mergeSort(arr, arr_s, md, rgt);
		merge(arr, arr_s, lft, md, rgt); 
	
	}
}




void quickSort( cards arr[], size_t arr_s, size_t left, size_t right )
{
	if( left < right ){
		size_t pivot_i=partition( arr, arr_s, left, right );
		quickSort( arr, arr_s, left, pivot_i-1 );
		quickSort( arr, arr_s, pivot_i+1, right );
	}
}
		



int main()
{
	size_t arr_s;
	cin>>arr_s;
	cards *arr=new cards[arr_s], *arr_stable=new cards[arr_s];
	for( size_t i=0; i<arr_s; i++ ){
		cin>>arr[i].suit;
		cin>>arr[i].num;
		arr_stable[i].suit=arr[i].suit;
		arr_stable[i].num=arr[i].num;
	}

	quickSort(arr, arr_s, 0, arr_s-1);
	mergeSort(arr_stable, arr_s, 0, arr_s);
	cout<<( isStable(arr, arr_stable, arr_s) ? "Stable":"Not stable" )<<endl;
	show(arr, arr_s);
}

Measured memory_bytes: 3364
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <queue>

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

using namespace std;

int main(){
    int r,d,x; cin >> r >> d >> x;
    rep(i, 10) {
        x = r*x - d;
        cout << x << endl;
    }
}





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

int main() {
int a, b;
cin >> a >> b;
if(a >= 13){
    cout << b << endl;
} else if(a >= 6 && a <= 12){
    cout << b/2 << endl;
} else if(a <= 5){
    cout << 0 << endl;
}
}


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

int main(){
    ll n,m;
    cin>>n>>m;
    vector<pair<ll,ll>>v;
    for(int i=0;i<n;i++){
        ll mon,can;
        cin>>mon>>can;
        v.push_back(make_pair(mon,can));
    }
    sort(v.begin(),v.end());
    ll sum=0;
    for(int i=0;i<n;i++){
        if(m!=0){
            if(m>=v[i].second){
                sum+=v[i].second*v[i].first;
                m-=v[i].second;
            }else {
                sum+=v[i].first*m;
                m-=m;
            }    
        }
        if(m==0)break;
    }
    cout<<sum;
}


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

#define rep(i,m,n) for(int i = m;i < n;++i)
using namespace std;
using ll = long long;
using R = double;
const ll inf = 1LL << 50;
const ll MOD = 1e9 + 7;



class UnionFind {
public:
	vector<int> r, p;

	UnionFind() {}
	UnionFind(int size) {
		r.resize(size, 0);
		p.resize(size, 0);
		rep(i, 0, size)makeSet(i);
	}

	void makeSet(int x) {
		p[x] = x;
		r[x] = 0;
	}

	bool same(int x, int y) {
		return findSet(x) == findSet(y);
	}

	void unite(int x, int y) {
		link(findSet(x), findSet(y));
	}

	void link(int x, int y) {
		if (r[x] > r[y]) {
			p[y] = x;
		}
		else {
			p[x] = y;
			if (x == y) {
				r[y]++;
			}
		}
	}


	int findSet(int x) {
		if (x == p[x]) {
			return x;
		}
		else {
			return p[x] = findSet(p[x]);
		}
	}
};


int main() {
	int n, m;
	cin >> n >> m;
	UnionFind un = UnionFind(n+1);


	vector<int>p(n);
	rep(i, 0, n) {
		cin >> p[i];
	}

	rep(i, 0, m) {
		int x, y;
		cin >> x >> y;
		un.unite(x,y);
	}

	int ans = 0;
	rep(i, 0, n) {
		if (un.same(i+1,p[i])) {
			ans++;
		}
	}

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

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

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

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

int main() {
	string s;

	while (getline(cin, s)) {
		string sa;
		sa = ctof(s[0]);
		for (int i = 1;i < s.size();i++) {
			sa += ctof(s[i]);
		}
		int z = sa.size();
		if (z % 5 != 0) {
			for (int i = z % 5;i <= 5;i++)sa.push_back('0');
		}
		string sb;
		for (int i = 0;i < z;i += 5) {
			string c = sa.substr(i, 5);
			sb.push_back(ftoc(c));
		}
		cout << sb << endl;
	}
	getchar();
	return 0;
}

Measured memory_bytes: 3108
#include<stdio.h>

int main(void)
{
  char str1[101],str2[101],temp;
  int i=0,j=0,frag=1,len;
  scanf("%s %s",str1,str2);
  while(frag == 1)
    {
      i=0; frag=0;
      while(str1[i+1] != '\0')
	{
	  if(str1[i] > str1[i+1])
	    {
	      temp = str1[i];
	      str1[i] = str1[i+1];
	      str1[i+1] = temp;
	      frag = 1;
	    }
	  i++;
	}
    }
  frag = 1;
  while(frag == 1)
    {
      j=0; frag = 0;
      while(str2[j+1] != '\0')
	{
	  if(str2[j] < str2[j+1])
	    {
	      temp = str2[j];
	      str2[j] = str2[j+1];
	      str2[j+1] = temp;
	      frag = 1;
	    }
	  j++;
	}
    }
  if(i < j)
    {
      len = i;
      frag = 0;
    }
  else
    {
      len = j;
      frag = 1;
    }
  i=0;
  while(len >= i)
    {
      if(str1[i] < str2[i])
	{
	  printf("Yes\n");
	  return 0;
	}
      else if(str1[i] > str2[i])
	{
	  printf("No\n");
	  return 0;
	}
      i++;
    }
  if(frag == 0)
    {
      printf("Yes\n");
      return 0;
    }
  else
    {
      printf("No\n");
      return 0;
    }
}


Measured memory_bytes: 128
package main

import (
	"fmt"
	"strings"
)

func main() {
	var n int
	var taroScore, hanakoScore int
	fmt.Scan(&n)
	for i := 0; i < n; i++ {
		var taro, hanako string
		fmt.Scan(&taro, &hanako)
		switch strings.Compare(taro, hanako) {
		case 1: taroScore += 3
		case 0: taroScore, hanakoScore = taroScore+1, hanakoScore+1
		case -1: hanakoScore += 3
		}
	}
	fmt.Printf("%d %d\n", taroScore, hanakoScore)
}


Measured memory_bytes: 1176
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
const int N=200005;
int n,i,j,k,head[N],adj[N*2],nxt[N*2],sg[N];
bool v[N];
void dfs(int x,int dad)
{
	for(int y=head[x];y;y=nxt[y])
		if(adj[y]!=dad)
		{
			dfs(adj[y],x);
			sg[x]^=sg[adj[y]]+1;
		}
}
int main()
{
	scanf("%d",&n);
	for(i=1;i<n;++i)
	{
		scanf("%d%d",&j,&k);
		adj[i*2-1]=k;
		nxt[i*2-1]=head[j];
		head[j]=i*2-1;
		adj[i*2]=j;
		nxt[i*2]=head[k];
		head[k]=i*2;
	}
	dfs(1,-1);
	if(sg[1])
		printf("Alice");
	else
		printf("Bob");
	return 0;
}


Measured memory_bytes: 8448
n = int(input())

a = []
b = []

for i in range(n):
	at, bt = map(int,raw_input().split())

	a.append(at)
	b.append(bt)

ans = 0
for i in range(n-1,-1,-1):
	if (a[i] + ans) % b[i] == 0:
		next

	else :
		ans += (((a[i] + ans) / b[i]) + 1) * b[i] - (a[i] + ans)

print ans

Measured memory_bytes: 12196
#include<bits/stdc++.h>
using namespace std;
bool ispal(string a)
{
    long long int n=a.length();
    if(n==1)
        return true;
    else{
    int i=0,j;
    j=n-1;
    while(1)
    {
        if(a[i]!=a[j])
        {
            cout<<i<<" "<<j;
           return false;
        }
        i++,j--;
        if(i==j)
         {
        //     cout<<i<<" ";
             break;
        }
    }
    return true;
}}
int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
long long int n;
cin>>n;
unordered_map<long long int ,int>m;
long long int a[n],s=0;
for(int i=0;i<n;i++)
{
    cin>>a[i];
    m[a[i]]++;
    s+=a[i];
}
long long int q;
cin>>q;
while(q--)
{
    long long int a,b;
    cin>>a>>b;
    if(m[a]>0)
    {
        m[b]+=m[a];
        s+= m[a]*(b-a);
        m[a]=0;
    }
  cout<<s<<endl;
}
}


Measured memory_bytes: 7732
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}
int gcd(int a, int b){//ユークリッドの互除法
  if (a < b) gcd(b,a); //aの方がbよりでかいのが前提
  if (b == 0) return a; //aをbで割り切れたらreturn
  else gcd(b, a % b);
}

int main(){
  int a,b,c; cin >> a >> b >> c;
  cout << min(b/a,c) << endl;
  
  return 0;
}

Measured memory_bytes: 256
package main

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

var sc *bufio.Scanner

const BufferSize = 1024

func nextInt() int {
	if !sc.Scan() {
		panic(nil)
	}
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func answer(reader io.Reader, writer io.Writer) {
	sc = bufio.NewScanner(reader)
	buf := make([]byte, BufferSize)
	sc.Buffer(buf, 1e+6)
	sc.Split(bufio.ScanWords)
	n := nextInt()
	k := nextInt()
	if k > 1 {
		_, _ = fmt.Fprintf(writer, "%d", n-k)
	} else {
		_, _ = fmt.Fprintf(writer, "0")
	}
}

func main() {
	answer(os.Stdin, os.Stdout)
}


Measured memory_bytes: 640
n=int(input())
v=sorted(list(map(int,input().split())))
if n==2:
    print((v[0]+v[1])/2)
else:
    x=(v[0]+v[1])/2
    for i in range(n-2):
        x=(x+v[i+2])/2
    print(x)

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

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(), (v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x,n) bitset<n>(x)

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

struct edge {
	int to,cost;
	edge(int t,ll c):to(t),cost(c) {}
};

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

ll mypow(ll x,ll n,ll m) {
	if(n==0) return 1;
	if(n%2==0) return mypow(x*x%m,n/2,m);
	else return x*mypow(x,n-1,m)%m;
}

//-----------------------------------------------------------------------------

int n;

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

	cin>>n;
	ll i=1;
	while (i*i<=n) i++;
	i--;
	cout<<i*i<<endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/*
void showqueue(queue<int> q) {
	cout << "queue: " ;
	while (!q.empty()) {
		cout << q.front() << " " ;
		q.pop();
	}
	cout << endl;
	return;
}
*/

int main() {
	//input
	int N, M;
	cin >> N >> M;

	vector<queue<int>> road(N);
	vector<int> output(N, -1);

	for (int i = 0; i < M; i++) {
		int temp_A, temp_B;
		cin >> temp_A >> temp_B;
		temp_A--;
		temp_B--;
		road[temp_A].push(temp_B);
		road[temp_B].push(temp_A);
	}

	queue<int> room_queue;
	room_queue.push(0);

	while (!room_queue.empty()) {
		int temp_room = room_queue.front();
		queue<int> temp_room_queue = road[temp_room];
		while (!temp_room_queue.empty()) {
			int temp_room_new = temp_room_queue.front();
			if (output[temp_room_new] == -1) {
				output[temp_room_new] = temp_room;
				room_queue.push(temp_room_new);
				//cout << temp_room_new << " " << num << endl;
			}
			temp_room_queue.pop();
		}
		room_queue.pop();
	}


	//output
	//cout << endl;

	cout << "Yes" << endl;
	for (int i = 1; i < N; i++) {
		cout << output[i] + 1 << endl;
	}


	return 0;
}


Measured memory_bytes: 71560
/* Dsingh_24 */

#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define	endl		'\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define ios	    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;

#define N  100005

int main()
{
	ios
	string s;
	cin>>s;
	ll i,j,n=s.size();
	ll r[n+1]={0},l[n+1];
	for(i=1;i<n;i++){
		if(s[i]=='R')r[i]=i;
		else r[i]=r[i-1];
	}
	map<ll,ll>m;
	l[n-1]=n-1;
	for(i=n-2;i>=0;i--){
		if(s[i]=='L')l[i]=i;
		else l[i]=l[i+1];
	}
	for(i=0;i<n;i++){
		if(s[i]=='R'){
			ll step=l[i]-i;
			if(step%2)m[l[i]-1]++;else m[l[i]]++;
		}else{
			ll step=i-r[i];
			if(step%2)m[r[i]+1]++;else m[r[i]]++;
		}
	}
	for(i=0;i<n;i++)
		cout<<m[i]<<" ";
	return 0;
}

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


int main() {
  int N;
  cin>>N;
  vector<int>time(N+1);
  vector<int>x(N+1);
  vector<int>y(N+1);
  time[0]=0;
  x[0]=0;
  y[0]=0;
  rep(i,N) cin>>time[i+1]>>x[i+1]>>y[i+1];
  rep(i,N){
       int a =abs(x[i+1]-x[i]+y[i+1]-y[i]);
    int t=time[i+1]-time[i];
    if((t-a)%2 != 0 || t<a){
      cout<<"No"<<endl;
      return 0;
  }
  }
   cout<<"Yes"<<endl;
}


Measured memory_bytes: 1408
import std.stdio;
import std.string;
import std.conv;
import std.array;

void main()
{
    ulong N = readln.split[0].to!ulong;
    string S = readln.chomp;

    S = "." ~ S ~ "#";

    int switch_i = 0;
    while (S[switch_i] == '.') switch_i++;
    int cnt = 0;
    foreach (i; switch_i..(N + 2)) if (S[i] == '.') cnt++;

    int ans = cnt;
    int cnt0 = 0;
    int cnt1 = 0;
    foreach (i; switch_i..(N + 1)){
        if (S[i] == '.') cnt0++;
        else cnt1++;

        if (S[i] == '.' && S[i + 1] == '#'){
            cnt = cnt + cnt1 - cnt0;
            if (cnt < ans) ans = cnt;

            cnt0 = 0;
            cnt1 = 0;
        }
    }

    writeln(ans);
}



Measured memory_bytes: 2812
n=int(input())
a=[s for s in input().split()]
a=[int(s) for s in a]
a=sorted(a)
ans=0
def nini(e,f,g):
    b=[e,f,g]
    b=sorted(b)
    h=b[1]
    return h
for i in range(n):
    for j in range(n):
        for k in range(n):
            if a[i]!=a[j] and a[j]!=a[k] and a[k]!=a[i]:
                if max(a[i],a[j],a[k])<min(a[i],a[j],a[k])+nini(a[i],a[j],a[k]):
                    ans+=1
print(int(ans/6))


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

int r,c,n;

class P {
public:
  int x,y;
  bool onEdge() {
    return y == 0 || y == c || x == 0 || x == r;
  }
  int d() {
    if(y == 0) {
      return x;
    } else if(x == r) {
      return r+y;
    } else if(y == c) {
      return 2*r + c - x;
    } else if(x == 0) {
      return 2*r + 2*c - y;
    }
  }
};

int main () {
  priority_queue<pair<int, int>> q;

  scanf("%d %d %d", &r, &c, &n);
  rep(i,n) {
    P p1, p2;
    scanf("%d %d %d %d", &p1.x, &p1.y, &p2.x, &p2.y);
    if(p1.onEdge() && p2.onEdge()) {
      q.push(make_pair(p1.d(), i));
      q.push(make_pair(p2.d(), i));
    }
  }

  stack<int> s;
  while(!q.empty()) {
    int i = q.top().second; q.pop();
    if(s.empty()) {
      s.push(i);
    } else if(s.top() == i) {
      s.pop();
    } else {
      s.push(i);
    }
  }

  if(s.empty()){
    printf("YES\n");
  } else {
    printf("NO\n");
  }
  return 0;
}


Measured memory_bytes: 2420
//Union-Find木
//Extended so that the number of elements of the set and the number of sets are counted
//reference Programming Contest ChaTenge Book Second Edition
// verify https://onlinejudge.u-aizu.ac.jp/courses/library/3/DSL/1/DSL_1_A

#include<iostream>
#include<vector>

using namespace std;

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

template <typename T>
struct Union_Find {

  vector<T> par;//親の番号
  vector<T> urank;//集合のランク
  vector<T> usize;//集合の要素数
  T num;//集合の数

  Union_Find() {
    init(100000);
  }

  Union_Find(T n) {
    init(n);
  }

  void init(T n) {//0〜n-1までの要素を初期化 最初はバラバラ
    par.clear();urank.clear();usize.clear();
    par.resize(n);urank.resize(n);usize.resize(n);
    num = n;
    rep(i,n) {
      par[i] = i;
      urank[i] = (T)0;
      usize[i] = (T)1;
    }
  }

  T find(T x) {//xが属する集合の親を見つける
    if(par[x] == x) {
      return x;
    } else {
      return par[x] = find(par[x]);
    }
  }

  T get_usize(T x) {//xが属する集合の要素数を返す。
    return usize[find(x)];
  }

  void unite(T x,T y) {//xが属する集合とyが属する集合を併合する。
    x = find(x);
    y = find(y);
    if(x == y) return;

    T s = usize[x] + usize[y];
    num--;
    if(urank[x] < urank[y]) {
      par[x] = y;
      usize[y] = s;
    } else {
      par[y] = x;
      usize[x] = s;
      if(urank[x] == urank[y]) urank[x]++;
    }
  }

  bool same(T x,T y) {//同じ集合に属するかを判定する
    return find(x) == find(y);
  }

  T num_set() {//集合の数(木の数)を返す。
    return num;
  }
};

using ll = long long;

ll n,q;

int main() {
    cin >> n >> q;
    Union_Find<ll> uf(n);

    rep(i,q) {
        ll com,x,y;
        cin >> com >> x >> y;
        if(com) {
            cout << uf.same(x,y) << endl;
        }else {
            uf.unite(x,y);
        }
    }
    return 0;
}



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

int main()
{
  int a[3],b[3] ;
  for(int i=0;i<3;i++) cin>>a[i]>>b[i] ;
  
  int c[6]={a[0],a[1],a[2],b[0],b[1],b[2]} ;
  int count[4]={0} ;
  for(int i=0;i<6;i++){
    switch(c[i]){
      case 1: count[0]++ ;
              break ;
      case 2: count[1]++ ;
              break ;
      case 3: count[2]++ ;
              break  ;
      case 4: count[3]++ ;
              break ;
    }
  }
  
  if(count[0]*count[1]*count[2]*count[3]==4&&
        count[0]+count[1]+count[2]+count[3]==6){
    cout<<"YES"<<endl ;
  }else cout<<"NO"<<endl ;
       
  
  return 0 ;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define flash ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define lb lower_bound
#define ub upper_bound
#define endl '\n'
#define rep(n) for(ll j=1;j<=n;j++)
#define loope(i,a,b) for(ll i=a;i<=b;i++)
#define loopne(i,a,b) for(ll i=a;i<b;i++)

ll mod=1e9+7;
ll dp[101][100005];
int main()
{
    ll n;
    cin>>n;
    ll k;
    cin>>k;
    ll candy[n];
    rep(n)
    cin>>candy[j];
    for(ll i=1;i<=k;i++)
    {
        dp[0][i]=0;
    }
    dp[0][0]=1;
    for(ll i=1;i<=n;i++)
    {
        ll sum[k+1];
        sum[0]=dp[i-1][0];
        for(ll j=1;j<=k;j++)
        {
            sum[j]=((dp[i-1][j])%mod+sum[j-1]%mod+mod)%mod;
        }
        for(ll j=0;j<=k;j++)
        { 
            ll ans=sum[j];
            ll x=j-candy[i];
            if(x>=1)
            {
               ans=(ans-sum[x-1]+mod)%mod;
            }
            dp[i][j]=ans%mod;
        }
    }
    cout<<dp[n][k];
    return 0;
    
}

Measured memory_bytes: 79872
import java.util.*

fun main(args: Array<String>) {

    val sc = Scanner(System.`in`)
    val N = sc.nextInt()
    var ans = 0.0
    for (i in 0 until N) {
        val x = sc.nextDouble()
        val u = sc.next()
        if (u == "JPY") ans += x
        if (u == "BTC") ans += x*380000
    }

    println(ans)
}

Measured memory_bytes: 31268
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;
using ll = long long;

#define REP(i, a) for (int i = 0; i < (a); ++i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORR(i, a, b) for (int i = (a)-1; i >= (b); --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define SIZE(obj) (int)(obj).sizeT()
#define YESNO(cond, yes, no) \
    { cout << ((cond) ? (yes) : (no)) << endl; }
#define SORT(list) sort(ALL((list)));
#define RSORT(list) sort((list).rbegin(), (list).rend())
#define ASSERT(cond, mes) assert(cond&& mes)

constexpr int MOD = 1'000'000'007;
constexpr int INF = 1'050'000'000;

template <typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

template <typename T1, typename T2>
istream& operator>>(istream& is, pair<T1, T2>& p) {
    is >> p.first >> p.second;
    return is;
}

template <typename T1, typename T2>
ostream& operator<<(ostream& os, pair<T1, T2>& p) {
    os << p.first << p.second;
    return os;
}

template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
    REP(i, (int)v.size())
    is >> v[i];
    return is;
}

template <typename T>
T clamp(T& n, T a, T b) {
    if (n < a) n = a;
    if (n > b) n = b;
    return n;
}

template <typename T>
static T GCD(T u, T v) {
    T r;
    while (v != 0) {
        r = u % v;
        u = v;
        v = r;
    }
    return u;
}

template <typename T>
static T LCM(T u, T v) {
    return u / GCD(u, v) * v;
}

std::vector<int> enum_div(int n) {
    std::vector<int> ret;
    for (int i = 1; i * i <= n; ++i) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i != 1 && i * i != n) { ret.push_back(n / i); }
        }
    }
    return ret;
}

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

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

struct ToUpper {
    char operator()(char c) {
        return toupper(c);
    }
};

struct ToLower {
    char operator()(char c) {
        return tolower(c);
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    ll N, A, B;
    cin >> N >> A >> B;

    auto solve = [&]() {
        if (A % 2 == B % 2) { return abs(B - A) / 2; }
        if (A > B) { swap(A, B); }
        ll t1 = A + (B - A) / 2;
        ll t2 = (2 * N - A - B + 1) / 2;
        return min(t1, t2);
    };

    cout << solve() << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define vl vector
#define inf LONG_MAX
#define gets getline
#define pb push_back
#define pf push_front
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define makestring(x) to_string(x)
#define endl "\n"
#define ss second
#define ff first
#define fast  ios_base::sync_with_stdio(false)
using namespace std;
vl<ll> divisor(ll n)
{
    vl<ll> v;
    for(int i=2;i<=sqrt(n);i++)
    {
        if(n%i==0) 
        {
            if(n/i==i) v.pb(i);
            else
            {
                v.pb(i);
                v.pb(n/i);
            }
        }
    }
    return v;
}

bool isprime(int n)
{
    int i;
    for(i=2;i*i<=n;i++) if(n%i==0) return 0;
    return 1;
}

vl<ll> sieve()
{
    vl<ll> v(1000001);
    int i,j;
    for(i=0;i<1000001;i++) v[i]=1;
    for(i=2;i<=sqrt(1000001);i++) if(v[i]==1) for(j=i*i;j<=1000000;j+=i) v[j]=0;
    v[1]=0;
    return v;
}

string dectobi(ll n)
{
    string s;
    while(n>0)
    {
        if(n&1) s.pb('1');
        else s.pb('0');
        n>>=1;
    }
    reverse(all(s));
    return s;
}

ll power(ll a, ll b, ll m)
{
    ll res=1;
    while(b>0)
    {
        if(b%2) res=(res*a)%m;
        a=(a*a)%m;
        b/=2;
    }
    return res%m;
}

int main()
{
    fast;
    ll a,b=31,c,d,e,sum=0,flag=0,j=0,i=1,count=0;
    ll x,y,o;
    set<ll> se;
    ll n,m,t,k,l,r;
    string s;
    cin>>n;
    if(n>=30) cout<<"Yes";
    else cout<<"No";
}

Measured memory_bytes: 3636
#include <stdio.h>
#include <stdlib.h>

int main(){
	int max;
	int count=0;
	char c[1025];
	int i,j;
	char key[10][5]={
		{0},
		{'.',',','!','?',' '},
		{'a','b','c'},
		{'d','e','f'},
		{'g','h','i'},
		{'j','k','l'},
		{'m','n','o'},
		{'p','q','r','s'},
		{'t','u','v'},
		{'w','x','y','z'},
	};
	int counter=0;
	char d[77];
	char kiroku=0;
	
	scanf("%d\n",&max);
	
	while(counter<max){
		gets(c);
		i=0;
		j=0;
		count=0;
		while(c[i]){
			if(c[i]!='0'){
				if(kiroku==c[i]){
					count++;
				}else{
					kiroku=c[i];
					count=0;
				}
			}else if(kiroku!=0){
				int test=3;
				switch(kiroku-'0'){
					case 1:test++;
					case 7:
					case 9:test++;break;
				}
				count=count%test;
				d[j]=key[kiroku-'0'][count];
				j++;
				kiroku=0;
			}
			i++;
		}
		d[j]=0;
		printf("%s\n",d);
		counter++;
	}
	return 0;
}

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

int N;
int h[110]={};

bool allh(){
  for(int i=0; i<N; i++){
    if(h[i]>0) return true;
  }
  return false;
}

int searchfirst(){
  int temp=0;
  while(1){
    if(h[temp]>0){
      return temp;
    }else{
      temp++;
    }
  }
}

int searchlast(int x){
  while(1){
    if(h[x]==0){
      return x-1;
    }else{
      x++;
    }
  }
} 

int main(){
  cin >> N;
  for(int i=0; i<N; i++) cin >> h[i];
  int res=0;
  while(allh()){
    int first=searchfirst();
    int last=searchlast(first);
    for(int i=first; i<=last; i++){
      h[i]--;
    }
    res++;
  }
  cout << res << endl;
}

Measured memory_bytes: 256
import itertools
n=int(input())
li_a =  list(map(int,input().split()))
li_b =  list(map(int,input().split()))
li_f = list()
for i in range(n):
    li_f.append(i+1)
li_j = list(itertools.permutations(li_f, n))
print(abs(li_j.index(tuple(li_a))-li_j.index(tuple(li_b))))

Measured memory_bytes: 44656
import java.util.Scanner;
import java.util.Arrays;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while (true){
			int sousuu = sc.nextInt(), sum = 0;
			if(0==sousuu) break;
			int[] ten = new int[sousuu];
			double ave = 0.0;
			for(int i=0;i<sousuu;i++) ten[i] = sc.nextInt();
			Arrays.sort(ten);
			for(int i=1;i<sousuu-1;i++) sum += ten[i];
			System.out.println(sum/(sousuu-2));
		}
	}
}


Measured memory_bytes: 28656
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {n: usize, k: usize, p:[usize; n], c: [i128;n]};
    let p: Vec<usize> = p;
    let c: Vec<i128> = c;

    let p: Vec<usize> = p.iter().map(|x| x - 1).collect();

    let mut ans = -(10i128.pow(18));

    // 全ての開始位置を試す
    for si in 0..n {
        let mut x = si;

        // 循環してる周期の得点を入れる
        let mut s: Vec<i128> = Vec::new();
        let mut total: i128 = 0;
        while true {
            x = p[x];
            s.push(c[x]);
            total += c[x];
            if x == si {
                break;
            }
        }

        let l = s.len();

        let mut t = 0;

        for i in 0..l {
            t += s[i];
            let mut now = t;
            if i + 1 > k {
                break;
            }
            if (total > 0) {
                let e = (k - (i + 1)) / l;
                now += total * e as i128
            }

            ans = std::cmp::max(ans, now);
        }
    }

    println!("{}", ans);
}


Measured memory_bytes: 2508
#include <iostream>
#include <algorithm>
#include <queue>

#define X first
#define Y second

using namespace std;

typedef pair<int, int> PII;

const int MAX_HW = 8 + 2;
const int MAX_C  = 6;
int dy[] = { -1, 0, 1, 0 };
int dx[] = { 0, -1, 0, 1 };

int H, W, C;
int fd[MAX_HW][MAX_HW];
int tp[MAX_HW][MAX_HW];
bool used[MAX_HW][MAX_HW];

void dfs ( int x, int y, int dest, int src, int m[MAX_HW][MAX_HW] )
{
	if (dest == src || m[y][x] == -1 || m[y][x] != dest) { return; }
	m[y][x] = src;
	for (int d = 0; d < 4; ++d) {
		dfs(x+dx[d], y+dy[d], dest, src, m);
	}
}

int bfs ( int x, int y, int color, int m[MAX_HW][MAX_HW] )
{
	int count = 0;
	for (int i = 0; i < MAX_HW; ++i) {
		fill(used[i], used[i]+MAX_HW, false);
	}
	queue<PII> que;
	que.push(PII(x, y));
	while(!que.empty()) {
		PII p = que.front(); que.pop();
		if (!used[p.Y][p.X]) { ++count; }
		used[p.Y][p.X] = true;
		for (int d = 0; d < 4; ++d) {
			int mx = p.X + dx[d], my = p.Y + dy[d];
			if (!used[my][mx] && m[my][mx] == color) {
				que.push(PII(mx, my));
			}
		}
	}
	return count;
}

void copy2dArray ( int h, int w, int d[MAX_HW][MAX_HW], int s[MAX_HW][MAX_HW] )
{
	for (int y = 0; y < h; ++y) {
		for (int x = 0; x < w; ++x) {
			d[y][x] = s[y][x];
		}
	}
}

int main ( void )
{
	while (cin >> H >> W >> C, H|W|C) {
		for (int i = 0; i < MAX_HW; ++i) {
			fill(fd[i], fd[i]+MAX_HW, -1);
			fill(tp[i], tp[i]+MAX_HW, -1);
		}
		for (int y = 1; y <= H; ++y) {
			for (int x = 1; x <= W; ++x) {
				cin >> fd[y][x];
			}
		}
		int ans = 0;
		for (int a = 1; a <= MAX_C; ++a) {
			for (int b = 1; b <= MAX_C; ++b) {
				if (b == a) { continue; }
				for (int c = 1; c <= MAX_C; ++c) {
					if (b == c) { continue; }
					for (int d = 1; d <= MAX_C; ++d) {
						if (c == d) { continue; }
						copy2dArray(MAX_HW, MAX_HW, tp, fd);
						int &color = tp[1][1];
						dfs(1, 1, color, a, tp);
						dfs(1, 1, color, b, tp);
						dfs(1, 1, color, c, tp);
						dfs(1, 1, color, d, tp);
						dfs(1, 1, color, C, tp);
						ans = max(ans, bfs(1, 1, C, tp));
					}
				}
			}
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1252
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
				Scanner scanner=new Scanner(System.in);
				int R=scanner.nextInt();
				if((0<=R)&&(R<1200)) {
					System.out.println("ABC");
				}else if((R>=1200)&&(R<2800)) {
					System.out.println("ARC");
				}else {
					System.out.println("AGC");
				}

			}

		
	}

Measured memory_bytes: 22996
#include <bits/stdc++.h>
typedef long long LL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

using namespace std;

int main(void)
{
  int n;
  cin >> n;
  vector<LL> value(1<<18), weight(1<<18);
  FOR(i,1,n+1) cin >> value[i] >> weight[i];
  vector<vector<pair<LL, LL>>> hanzen(1<<12); // weight, value
  hanzen[0].emplace_back(0,0);
  FOR(bits,1,1<<12) {
    for(pair<LL,LL> p:hanzen[bits/2]) {
      pair<LL,LL> added = make_pair(p.first+weight[bits], p.second+value[bits]);
      hanzen[bits].push_back(p);
      hanzen[bits].push_back(added);
    }
    vector<pair<LL,LL>> tmp(hanzen[bits].begin(),hanzen[bits].end());
    sort(tmp.begin(),tmp.end());
    hanzen[bits].clear();
    hanzen[bits].emplace_back(0,0);
    for(pair<LL,LL> p:tmp) {
      if(hanzen[bits].back().second < p.second) hanzen[bits].push_back(p);
    }
  }
  int q;
  cin >> q;
  while(q--) {
    LL v, l;
    cin >> v >> l;
    vector<pair<LL,LL>> comb;
    comb.emplace_back(0,0);
    while(v>=(1<<12)) {
      vector<pair<LL,LL>> tmp(comb.begin(), comb.end());
      for(pair<LL,LL> p:tmp) {
        pair<LL,LL> added = make_pair(p.first+weight[v], p.second+value[v]);
        comb.push_back(added);
      }
      v/=2;
    }
    LL answer = 0;
    for(pair<LL,LL> p: comb) {
      LL cw,cv;
      tie(cw,cv) = p;
      if(cw>l) continue;
      auto ite = lower_bound(hanzen[v].begin(),hanzen[v].end(), make_pair(l-cw+1,0ll));
      --ite;
      answer=max(answer, cv+ite->second);
    }
    cout << answer << endl;
  }

  return 0;
}


Measured memory_bytes: 177204
///==================================================///
///                HELLO WORLD !!                    ///
///                  IT'S ME                         ///
///               BISHAL GAUTAM                      ///
///         [ bsal.gautam16@gmail.com ]              ///
///==================================================///
#include<bits/stdc++.h>
#define PI acos(-1.0)
#define nl puts("")
#define SZ(x) x.size()
#define pb(x) push_back(x)
#define X first
#define Y second
#define pii pair<int,int>
#define mpr(a,b) make_pair(a,b)
#define S(a) scanf("%d",&a)
#define P(a) printf("%d",a)
#define SL(a) scanf("%lld",&a)
#define S2(a,b) scanf("%d%d",&a,&b)
#define all(v) v.begin(),v.end()
#define clr(a) memset(a,0,sizeof(a))
#define SET(a) memset(a,-1,sizeof(a))
#define fr(i,a,n) for(i=a;i<=n;i++)
#define rf(i,a,n) for(i=n;i>=a;i--)

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
///==========CONSTANTS=============///
///  Digit     0123456789012345678 ///
#define MX     200001
#define inf    1000000000
#define MD     1717171769LL
#define eps    1e-9
///===============================///

int main()
{

    string s;
    cin>>s;
    string r=s;
    reverse(all(s));

    if(s==r)cout<< "Yes\n";
    else cout<< "No\n";
}


Measured memory_bytes: 256
n, m = gets.split.map(&:to_i)
x = gets.split.map(&:to_i)
if n >= m
  puts 0
  exit
elsif n == 1
  puts x.max - x.min
  exit
end
x.sort!{|a, b| a<=>b}
sum = x.max - x.min
y = []
0.upto(m-2) do |i|
  y[i] = x[i + 1] - x[i]
end
y.sort!{|a, b| b<=>a}
0.upto(n-2) do |i|
  sum -= y[i]
end
puts sum

Measured memory_bytes: 9848
#include<iostream>
#include<bits/stdc++.h>
#define pq priority_queue
#define Pi acos(-1.0)
using namespace std;
#define MOD 1000000007
char s[105];
int main()
{
    int ans=0,now=0,n;
    cin>>n;
    scanf("%s",s);
    for(int i=0;i<n;i++)
    {
        if(s[i]=='I')
            now++;
        else
            now--;
        ans=max(ans,now);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256