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

class Main
{
	public static void main(String args[])
	{
		Scanner sc = new Scanner(System.in);
		while (true)
		{
			int hands[] = new int[5];
			boolean orverall[] = new boolean[3];
			hands[0] = sc.nextInt();
			if (hands[0] == 0) break;
			orverall[hands[0]-1] = true;
			for (int i = 1; i < 5; i++)
			{
				hands[i] = sc.nextInt();
				orverall[hands[i]-1] = true;
			}
			for (int i = 0; i < 5; i++)
			{
				int win = (hands[i] % 3);
				int lose = ((hands[i] + 1) % 3);
				if (orverall[win])
				{
					if (orverall[lose])
					{
						System.out.println(3);
					}
					else
					{
						System.out.println(1);
					}
				}
				else
				{
					if (orverall[lose])
					{
						System.out.println(2);
					}
					else
					{
						System.out.println(3);
					}
				}
			}
		}
	}
}

Measured memory_bytes: 12000
// Twitter@KonoLv1 2020年春からエンジニア見習いデビュー！
 
//  標準入出力を扱うヘッダーファイルの読み込み
#include <stdio.h>
//  "atoi" "atof"などのキャスト、"rand" 疑似乱数を発生させるヘッダーファイルの読み込み
#include <stdlib.h>
//  "strcpy" "strcat"などの文字列操作や"strlen"文字列長さ取得などを行うヘッダーファイルの読み込み
#include <string.h>
//  "sqrtl" "fmax"などの数値操作を行うヘッダーファイルの読み込み
#include <math.h>

void global_box_sort_desc(void);
void global_box_sort_asc(void);

int global_box[256];
 
int main(void){
  //  char text[256];
//    int no[256];
  //  int yuukoudo[500][500];
    char c[256] = {};
    char text[] = "abcdefghijklmnopqrstuvwxyz";
    int x,y,z;
    int i,j;
    int flg = 0;
    scanf("%s",c);
    for (i = 0; i < 26; i++){
        if (c[0] == text[i]){
            if (i == 25){
                i = -1;
            }
            printf("%c",text[i + 1]);
            break;
        }
    }
   
}



void global_box_sort_desc (void){
    int tmp = 0;int i,j;int n;
    
    scanf("%d",&n);
    
    for (i = 0; i < n; i++){
        scanf("%d",&global_box[i]);
    }
    for (i = 0; i < n - 1; i++){
        for (j = i + 1; j < n; j++){
            if (global_box[i] >= global_box[j]){
                tmp = global_box[i];
                global_box[i] = global_box[j];
                global_box[j] = tmp;
            }
        }
    }
    for (i = 0; i < n; i++){
        printf("%d\n",global_box[i]);
    }
}

void global_box_sort_asc (void){
    int tmp = 0;int i,j;int n;
    
    scanf("%d",&n);
    
    for (i = 0; i < n; i++){
        scanf("%d",&global_box[i]);
    }
    for (i = 0; i < n - 1; i++){
        for (j = i + 1; j < n; j++){
            if (global_box[i] <= global_box[j]){
                tmp = global_box[i];
                global_box[i] = global_box[j];
                global_box[j] = tmp;
            }
        }
    }
    for (i = 0; i < n; i++){
        printf("%d\n",global_box[i]);
    }
}
 

Measured memory_bytes: 128
#ifdef _MSC_VER
#include "stdc++.h"
#endif
#ifdef __GNUC__
#include<bits/stdc++.h>
#endif
using namespace std;

using ll = long long;

//constant
const double EPS = 1e-10;

#define REP(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, s, e) for (ll i = s; i < e; i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(), (x).rend()

//debug
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define DEBUG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl;

// vector
//template<typename T> vector<vector<T>> vv(ll H, ll W, T v) { return vector<vector<T>> vec(H, vector<T>(W, v)); }

// view vector
template<typename T> void view(T e) { cout << e << endl; }
template<typename T> void view(const vector<T>& v) { for (const auto& e : v) { cout << e << " "; } cout << endl; }
template<typename T> void view(const vector<vector<T> >& vv) { for (const auto& v : vv) { view(v); } }

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




// ***************************************

ll N, K, C;
vector<ll> calc(string S){
    ll last = - C - 1;

    ll cnt = 0;
    vector<ll> vec(N+1, 0);
    REP(i, N){
        if(i - last > C && S[i] == 'o') cnt++, last = i;
        vec[i + 1] = cnt;
    }

    return vec;
}



int main(){
    cin >> N >> K >> C;
    string S;
    cin >> S;
    string T = S;
    reverse(ALL(T));

    const auto& left = calc(S);
    const auto& right = calc(T);

    bool flag = false;
    REP(i, N){
        if (S[i] == 'x') continue;
        if (left[i] + right[N-i-1] < K) {
            cout << i + 1 << endl;
            flag = true;
        }
    }

    if (!flag) {
        cout << endl;
    }

    return 0;
}


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

struct HashString{
public:
    using hashtype=long long;
    using hashcomptype=std::tuple<hashtype,hashtype,hashtype>;

    std::vector<hashtype> table1;
    std::vector<hashtype> table2;
    std::vector<hashtype> table3;
    std::vector<hashtype> powtable1;
    std::vector<hashtype> powtable2;
    std::vector<hashtype> powtable3;

    hashtype mod=1000000007ll;
    hashtype base1=1919ll;
    hashtype base2=114514ll;
    hashtype base3=334334ll;

    HashString(){}
    HashString(std::string s){
        table1.resize(s.size()+1);
        table2.resize(s.size()+1);
        table3.resize(s.size()+1);
        powtable1.resize(s.size()+1);
        powtable2.resize(s.size()+1);
        powtable3.resize(s.size()+1);

        table1[0]=0ll;
        table2[0]=0ll;
        table3[0]=0ll;
        powtable1[0]=1ll;
        powtable2[0]=1ll;
        powtable3[0]=1ll;

        for(int i=0;i < s.size(); ++i){
            table1[i+1]=table1[i]*base1+s[i];
            table2[i+1]=table2[i]*base2+s[i];
            table3[i+1]=table3[i]*base3+s[i];
            powtable1[i+1]=powtable1[i]*base1;
            powtable2[i+1]=powtable2[i]*base2;
            powtable3[i+1]=powtable3[i]*base3;

            table1[i+1]=table1[i+1]%mod;
            table2[i+1]=table2[i+1]%mod;
            table3[i+1]=table3[i+1]%mod;
            powtable1[i+1]=powtable1[i+1]%mod;
            powtable2[i+1]=powtable2[i+1]%mod;
            powtable3[i+1]=powtable3[i+1]%mod;
        }
    }

    bool operator == (HashString s){
        if(this->table1.size()!=s.table1.size())return false;
        if(this->table1.back()!=s.table1.back())return false;
        if(this->table2.back()!=s.table2.back())return false;
        if(this->table3.back()!=s.table3.back())return false;
        return true;//maybe :)
    }

    hashcomptype get_hash(int l,int r){//[l,r)でのhash
        assert(r-l>0);

        hashtype hash1=table1[r]-(powtable1[r-l]*table1[l]%mod);
        while(hash1<0)hash1+=mod;
        hash1=hash1%mod;

        hashtype hash2=table2[r]-(powtable2[r-l]*table2[l]%mod);
        while(hash2<0)hash2+=mod;
        hash2=hash2%mod;

        hashtype hash3=table3[r]-(powtable3[r-l]*table3[l]%mod);
        while(hash3<0)hash3+=mod;
        hash3=hash3%mod;

        //std::cout<<hash1<<" "<<hash2<<" "<<hash3<<std::endl;
        return std::make_tuple(hash1,hash2,hash3);
    }
};


using namespace std;

int main(){
    int n;
    string s;
    cin>>n>>s;
    HashString hs(s);
    int l=0,r=1;//[l,r)のしゃくとり法
    int maxlen=0;
    while(true){
        auto ts=hs.get_hash(l,r);
        bool f=false;
        for (int i = r; i+(r-l) <= n; ++i) {
            if(ts==hs.get_hash(i,i+(r-l))){
                f=true;
                break;
            }
        }
        if(f){
            maxlen=r-l;
            if(r+(r-l)>=n)break;
            ++r;
        }
        else{
            ++l;++r;//長さが短くなるようなものは探さなくていい
            if(r+(r-l)>=n)break;
        }
    }
    cout<<maxlen<<endl;
    return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()%
#define int long long

const int MOD = 1e9+7;

int binom_max = 2100;
vector<int> fact(binom_max), inv_fact(binom_max), inv(binom_max);

void modbinom_init() {
    fact[0] = fact[1] = 1;
    inv_fact[0] = inv_fact[1] = 1;
    inv[1] = 1;
    for(int i=2; i<binom_max; i++){
        fact[i] = fact[i-1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        inv_fact[i] = inv_fact[i-1] * inv[i] % MOD;
    }
}

int conv(int n, int k){
    if (n<k) return 0;
    if (n<0 || k<0) return 0;
    return fact[n] * (inv_fact[k] * inv_fact[n-k] % MOD) % MOD;
}

signed main(){
    modbinom_init();
    int n, k;
    cin >> n >> k;
    reps(i,1,k){
        cout << (conv(k-1, i-1) * conv(n-k+1, i)) % MOD << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint         = long long;
constexpr lint inf = 1LL << 60;
constexpr lint mod = 1000000007;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    lint n, k;
    cin >> n >> k;
    vector<lint> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    lint ret = 0;

    sort(a.begin(), a.end());
    for (int i = 0; i < k; ++i) {
        ret += a[i];
    }
    cout << ret << "\n";
    return 0;
}

Measured memory_bytes: 3648
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <iomanip>

#define REP(i,n) for(i=0; i < (n); i++)
#define REPONE(i, n) for(i=1; i <= (n); i++)
#define LOOP(n) for(int loopCount=1; loopCount <= (n); loopCount++)
#define ITER(c) __typeof((c).begin())
#define EACH(c,it) for(ITER(c) it =(c).begin(); it!=(c).end(); it++)
#define SZ(c) ((int) (c).size())
#define ALL(c) c.begin(), c.end()
#define SUM(c) accumulate(ALL(c), 0)
#define EXIST(c,v) (find(ALL(c), (v)) != (c).end())
#define PB push_back
#define MP make_pair

using namespace std;
static const double EPS = 1e-9;
static const double PI = 3.141592653589793238462643383279;
typedef long long ll;

int josephus(int n, int k,  int s){
    ll x = k*s;
    while(x>n){
        x = ((x-n)*k-1)/(k-1);
    }
    return (int)x;
}

int main(){
    int n, k, m;
    while(scanf("%d%d%d",&n,&k,&m)){
        if(!(n||k||m)) break;
        int ans = josephus(n,k,n);
        ans = (ans-(k-m))%n;
        ans = (ans+n)%n;
        if(ans==0) ans=n;
        printf("%d\n",ans);
    }
    return 0;
}

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

int main() {
    int k, l = 9;
    cin >> k;
    string s(10, '0');
    for(int i = 0; i < k; i++) {
        for(int j = 10; j--;) {
            s[j]++;
            if(s[j] > '9') {
                if(j == l)
                    l--;
            } else if(j == l || abs(s[j - 1] - s[j]) < 2) {
                for(j++; j < 10; j++)
                    if(abs(s[j - 1] - s[j]) > 1)
                        s[j] = s[j - 1] == '0' ? '0' : s[j - 1] - 1;
                break;
            }
            s[j] = '0';
        }
    }
    cout << stol(s) << endl;
    return 0;
}


Measured memory_bytes: 256
from collections import deque

N = int(input())
h = list(input().split())
flower = deque([int(h[i]) for i in range(N)])
goal = [0 for i in range(N)]
count = 0

flower.append(0)

while flower != deque([]):
    for i in range(len(flower)):
        if flower[0] == 0:
            flower.popleft()
        else:
            break
    
    for i in range(len(flower)-1):
        if flower[i] == 0 and flower[i+1] != 0:
            count += 1
        elif flower[i] == 0:
            continue
        elif i == len(flower) - 1:
            count += 1
            flower[i] -= 1
        else:
            flower[i] -= 1
    count += 1

print(count-1)
        
            

Measured memory_bytes: 3316
N, K = map(int, input().split())
S = input()

now = S[0]
change = 1
for i in range(1, len(S)):
    if now != S[i]:
        change += 1
    now = S[i]

if change == 1 or change == 2 or (change-2) <= K:
    print(N - 1)
else:
    print(min(N - 1, N - change + 2 * K))


Measured memory_bytes: 3316
def main():
    from string import ascii_lowercase

    c = input()
    idx = ascii_lowercase.index(c)
    print(ascii_lowercase[idx + 1])


if __name__ == '__main__':
    main()

# import sys
#
# sys.setrecursionlimit(10 ** 7)
#
# input = sys.stdin.readline
# rstrip()

# int(input())
# map(int, input().split())


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

int main(){
  	int s;
  	cin >> s;
  	map<int, int> a;
  	a[s] = 1;
  	int i=2;
  	int before = s;
  	while(true){
      	int tmp;
    	if(before%2 == 0){
          	tmp = before/2;
        }else{
          	tmp = 3*before+1;
        }
      	if(a[tmp] != 0){
        	break;
        }
      	a[tmp] = i;
      	before = tmp;
      	i++;
    }
  	cout << i << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
typedef long long ll;
const int mod=1e9+7,i2=(mod+1)/2;
int mul(int a,int b){return(ll)a*b%mod;}
void inc(int&a,int b){(a+=b)>=mod?a-=mod:0;}
int a[3010],f[3010][3010];
int main(){
	int n,q,i,j,x,y,s;
	scanf("%d%d",&n,&q);
	for(i=1;i<=n;i++)scanf("%d",a+i);
	for(i=1;i<=n;i++){
		for(j=1;j<=n;j++)f[i][j]=a[i]>a[j];
	}
	for(j=1;j<=q;j++){
		scanf("%d%d",&x,&y);
		f[x][y]=f[y][x]=mul(f[x][y]+f[y][x],i2);
		for(i=1;i<=n;i++){
			if(i!=x&&i!=y){
				f[x][i]=f[y][i]=mul(f[x][i]+f[y][i],i2);
				f[i][x]=f[i][y]=mul(f[i][x]+f[i][y],i2);
			}
		}
	}
	s=0;
	for(i=1;i<n;i++){
		for(j=i+1;j<=n;j++)inc(s,f[i][j]);
	}
	while(q--)s=mul(s,2);
	printf("%d",s);
}

Measured memory_bytes: 35456
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
      
		// 文字列の入力
		String[] s = sc.next().split("");
        boolean hasC = false;
        String ans = "No";
        for (int i = 0; i < s.length; i++) {
          if (s[i].equals("C")) {
            hasC = true;
          } else if (s[i].equals("F") && hasC) {
            ans = "Yes";
            break;
          }
        }
    
		// 出力
		System.out.println(ans);
	}
}

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

// define maximum possible length of string X and Y
#define MAX 3000

// lookup[i][j] stores the length of LCS of substring X[0..i-1], Y[0..j-1]
int lookup[MAX+1][MAX+1];

// Recursive Function to find Longest Common Subsequence of
// string X[0..m-1] and Y[0..n-1]
string LCS(string X, string Y, int m, int n)
{
	// return empty string if we have reached the end of
	// either sequence
	if (m == 0 || n == 0)
		return string("");

	// if last character of X and Y matches
	if (X[m - 1] == Y[n - 1])
	{
		// append current character (X[m-1] or Y[n-1]) to LCS of
		// substring X[0..m-2] and Y[0..n-2]
		return LCS(X, Y, m - 1, n - 1) + X[m - 1];
	}

	// else when the last character of X and Y are different

	// if top cell of current cell has more value than the left
	// cell, then drop current character of string X and find LCS
	// of substring X[0..m-2], Y[0..n-1]

	if (lookup[m - 1][n] > lookup[m][n - 1])
		return LCS(X, Y, m - 1, n);

	else

	// if left cell of current cell has more value than the top
	// cell, then drop current character of string Y and find LCS
	// of substring X[0..m-1], Y[0..n-2]

		return LCS(X, Y, m, n - 1);
}

// Function to fill lookup table by finding the length of LCS
// of substring X[0..m-1] and Y[0..n-1]
void LCSLength(string X, string Y, int m, int n)
{
	// first row and first column of the lookup table
	// are already 0 as lookup[][] is globally declared

	// fill the lookup table in bottom-up manner
	for (int i = 1; i <= m; i++)
	{
		for (int j = 1; j <= n; j++)
		{
			// if current character of X and Y matches
			if (X[i - 1] == Y[j - 1])
				lookup[i][j] = lookup[i - 1][j - 1] + 1;

			// else if current character of X and Y don't match
			else
				lookup[i][j] = max(lookup[i - 1][j], lookup[i][j - 1]);
		}
	}
}

int main()
{
	string X , Y; cin >> X >> Y;
	int m = X.size(), n = Y.size();

	// fill lookup table
	LCSLength(X, Y, m, n);

	// find longest common sequence
	cout << LCS(X, Y, m, n);
    cout << endl;

	return 0;
}

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

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int N = in.nextInt();
		long[] X = new long[N];
		long[] a = new long[N];
		for (int i = 0; i < N; i++) {
			X[i] = in.nextLong();
			a[i] = X[i];
		}
		Arrays.sort(a);
		for (int i = 0; i < N; i++) {
			if (X[i] <= a[N / 2 - 1]) {
				System.out.println(a[N / 2]);
			} else {
				System.out.println(a[N / 2 - 1]);
			}
		}
		in.close();
	}
}

Measured memory_bytes: 94464
n, m = list(map(int, input().split()))
broken = [0] * (n + 1)
for _ in range(m):
    broken[int(input())] = 1
mod = 1000000007
dp = [0] * (n + 2)
dp[n] = 1
for i in range(n - 1, -1, -1):
    if broken[i]:
        dp[i] = 0
    else:
        dp[i] = dp[i + 1] + dp[i + 2]
        dp[i] = dp[i] % mod
print(dp[0])


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

const int MAXN = 2e5 + 5;

int N;
int inv[MAXN];
int dp[MAXN];

int main() {
	scanf("%d", &N);
	for (int i = 1; i <= N; i++) {
		int x;
		scanf("%d", &x);
		inv[x] = i;
	}
	
	int sol = 0;
	for (int i = 1; i <= N; i++) {
		if (inv[i] > inv[i - 1])
			dp[i] = dp[i - 1];
		sol = max(sol, ++dp[i]);
	}
	
	printf("%d\n", N - sol);
	
	return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>

int main(void)
{
	int a1[3][10];
	int b1[3][10];
	int c1[3][10];
	int d1[3][10];
	
	int b, f, r, v;
	int n;
	int suuji;
	int suuj;
	
	for(suuji = 0; suuji < 3; suuji++){
		for(suuj = 0; suuj < 10; suuj++){
			a1[suuji][suuj] = 0;
			b1[suuji][suuj] = 0;
			c1[suuji][suuj] = 0;
			d1[suuji][suuj] = 0;
		}
	}
			
		
	
	scanf("%d", &n);
	
	while(n != 0){
		scanf("%d %d %d %d", &b, &f, &r, &v);
	if(b == 1){
		a1[f - 1][r - 1] += v;
	}
	else if(b == 2){
		b1[f - 1][r - 1] += v;
	}
	else if(b == 3){
		c1[f - 1][r - 1] += v;
	}
	else if(b == 4){
		d1[f - 1][r - 1] += v;
	}
	n--;
	}
    
	for(suuji = 0; suuji < 3 ;suuji++){
		for(suuj = 0; suuj < 10; suuj++){
			printf(" %d", a1[suuji][suuj]);
		}
		printf("\n");
    }
	printf("####################\n");
	
	for(suuji = 0; suuji < 3; suuji++){
		for(suuj = 0; suuj < 10; suuj++){
			printf(" %d", b1[suuji][suuj]);
		}
		printf("\n");
	}
	
	printf("####################\n");
	
	for(suuji = 0; suuji < 3; suuji++){
		for(suuj = 0; suuj < 10; suuj++){
			printf(" %d", c1[suuji][suuj]);
		}
		printf("\n");
	}
	
	printf("####################\n");
	
	for(suuji = 0; suuji < 3; suuji++){
		for(suuj = 0; suuj < 10; suuj++){
			printf(" %d", d1[suuji][suuj]);
		}
		printf("\n");
	}
	
	
	
	
	return (0);
}
			
	
	
	
	
	
	

Measured memory_bytes: 612
#include<bits/stdc++.h>
#include <array>
using namespace std;
using ULL = unsigned long long;
using UL = unsigned;
using LL = long long;
#define rep(i, n) for(UL i = 0; i < (n); i++)

struct Problem {
	void Solve() {
		UL a, b; a = b = 0;
		rep(i, 3) {
			char c; cin >> c;
			if (c == 'A') a++; else b++;
		}
		cout << ((a && b) ? "Yes" : "No") << endl;
	}

	Problem();
};
int main() {
	unique_ptr<Problem> p(new Problem());
	p->Solve();
	return 0;
}
Problem::Problem() {
	cout << fixed << setprecision(10);
}

Measured memory_bytes: 256
while 1:
	N = int(raw_input())
	if N == 0:
		break
	p = []
	for i in range(N):
		line = map(int,raw_input().split())
		p.append(set(line[1:]))
	line = map(int,raw_input().split())
	l = set(line[1:])
	c = -1
	for i in range(N):
		if l.issubset(p[i]):
			if c == -1:
				c = i+1
			else :
				c = -1
				break
	print c

Measured memory_bytes: 4728
#include<bits/stdc++.h>
using namespace std;
std::vector<int> v[200000],uv[200000];
stack<int> s;
int visited[200000],dist[200000];
void topo_sort(int p)
{
	visited[p] = 1;
	for (int i = 0; i < v[p].size(); ++i)
	{
		if(!visited[v[p][i]])
			topo_sort(v[p][i]);
	}
	s.push(p);
}

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

	for (int i = 0; i < m; ++i)
	{
		int a,b;
		cin>>a>>b;
		v[a].push_back(b);
		uv[b].push_back(a);
	}

	for (int i = 1; i <= n; ++i)
	{
		if(visited[i]==0)
			topo_sort(i);
	}
	int ans = 0;
	 while (s.empty() == false) 
    { 
        int x = s.top();
        int m = 0;
        for (int i = 0; i < uv[x].size(); ++i)
        {
        	m = max(m,dist[uv[x][i]]+1);
        }
        dist[x] = m;
        ans = max(m,ans);
        s.pop(); 
    } 
    cout<<ans<<endl;

	
	return 0;
}

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

int main(){
  int L,R; cin >> L >> R;
  int res=100000;
  
  if(L%2019==0||R%2019==0) res=0;
  else if(L/2019<R/2019) res=0;
  else{
    L%=2019; R%=2019;
    for(int i=L; i<=R-1; i++){
      for(int j=L+1; j<=R; j++){
        res=min(res,(i*j)%2019);
      }
    }
  }
  cout << res << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
signed main(){
  char A; cin>>A;
  string ans="consonant";
  if(A=='a'||A=='i'||A=='u'||A=='e'||A=='o')
    ans="vowel";
  cout<<ans<<endl;
  }


Measured memory_bytes: 256
#include<iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cassert>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repd(i, n) for (int i = n; i > 0; i--)
#define mod 1000000007
typedef long long int ll;
typedef vector<ll> v;

ll modpow(ll a, ll p) {
	if (p == 0) {
		return 1;
	}
	if (p % 2 == 0) {
		ll half = modpow(a, (p / 2));
		return (half*half) % mod;
	}
	else {
		return a * modpow(a, p - 1) % mod;
	}
}

ll comb(int x, int y) {
	if (y > x - y) {
		return comb(x, x - y);
	}
	ll mul = 1, div = 1;
	rep(i, y) {
		mul = (mul*(x - i)) % mod;
		div = (div*(i + 1)) % mod;
	}
	ll subans = mul * modpow(div, mod - 2) % mod;
	return subans;
}

int main() {
	int n, m;
	cin >> n >> m;
	int mm = m;
	int p[40000] = { 0 };
	rep(i, sqrt(mm)) {
		while (m % (i + 2) == 0) {
			p[i + 2]++;
			m /= (i + 2);
		}
	}
	if (m != 1) { p[1] = 1; }
	ll ans = 1;
	rep(i, 40000) {
		if (i == 0) {
			i++;
		}
		if (p[i] > 0) { ans *= comb((p[i] + n - 1), p[i]) % mod; }
		ans %= mod;
	}
	cout << ans % mod<<endl;
	return 0;
}



Measured memory_bytes: 384
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define MOD (1000000007)
#define vi vector<int>
#define vvi vector<vi>
#define all(a)  (a).begin(),(a).end()

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

int gcd(int a, int b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}

const ll INF = 1LL << 60;

int main(){
  int n,m; cin >> n >> m;
  int path[n][n] = {};
  rep(i, m){
    int a,b; cin >> a >> b;
    path[a-1][b-1]++;
    path[b-1][a-1]++;
  }

  vi v; rep(i, n) v.push_back(i);
  int ans = 0;
  do{
    //if(v[0] != 0) continue;
    rep(i, n-1){
      if(path[v[i]][v[i+1]] == 0) break;
      if(i == n-2) ans++;
    }
  }while(next_permutation(v.begin()+1,v.end()));

  std::cout << ans << '\n';
}


Measured memory_bytes: 256
import java.util.*;
public class Main
{
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
String k=sc.next();
String a="";
int f=0;
for(int i=0;i<k.length();i++)
{
a=a+"hi";
if(a.equals(k))
{
f=1;
break;
}
}
if(f==0)
System.out.println("No");
else
System.out.println("Yes");
}

}

Measured memory_bytes: 23764
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;

//If select somewhere,num of white_area + 3

struct Data{
	Data(int arg_row,int arg_col){
		row = arg_row;
		col = arg_col;
	}
	int row,col;
};

int N;
int diff_row[4] = {-1,0,0,1},diff_col[4] = {0,-1,1,0};
char table[127][128];

bool rangeCheck(int row,int col){
	if(row >= 0 && row <= N-1 && col >= 0 && col <= N-1)return true;
	else{
		return false;
	}
}

int main(){

	scanf("%d",&N);

	for(int row = 0; row < N; row++)scanf("%s",table[row]);

	int count = 0;
	int adj_row,adj_col;

	queue<Data> Q;

	for(int row = 0; row < N; row++){
		for(int col = 0; col < N; col++){
			if(table[row][col] == 'o'){
				count++;
				table[row][col] = 'x';

				Q.push(Data(row,col));

				while(!Q.empty()){

					for(int i = 0; i < 4; i++){
						adj_row = Q.front().row + diff_row[i];
						adj_col = Q.front().col + diff_col[i];

						if(!rangeCheck(adj_row,adj_col))continue;

						if(table[adj_row][adj_col] == 'o'){
							table[adj_row][adj_col] = 'x';
							Q.push(Data(adj_row,adj_col));
						}
					}
					Q.pop();
				}
			}
		}
	}

	printf("%d\n",(count-1)/3);

	return 0;
}

Measured memory_bytes: 3280
import java.util.*;
import java.util.stream.Collectors;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int q = sc.nextInt();
        sc.nextLine();
        List<Integer> list = new ArrayList<>();
        for (int i=0;i<q;i++) {
            list.add(sc.nextInt());
            sc.nextLine();
        }
        Map<Integer, Long> map = list.stream().collect(Collectors.groupingBy(m -> m, Collectors.counting()));
        for (int i = 1; i<=n; i++) {
            if (q - map.getOrDefault(i, (long) 0) < k) {
                System.out.println("Yes");
            } else {
                System.out.println("No");
            }
        }
    }
}


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

using namespace std;

char func(char ch, int d)
{
  return (char)('a' + (int)(ch-'a'+d)%26);
}

int main()
{
  string str;
  int s[101], t[101], n;

  while(cin>>n && n){
    cin >> str;

    for(int i = n-1; i >= 0; --i){
      cin >> s[i] >> t[i];
      s[i]--; t[i]--;
    }

    for(int i = 0; i < n; i++){
      str[s[i]] = func(str[s[i]], t[i]-s[i]);
      str[t[i]] = func(str[t[i]], t[i]-s[i]);
      swap(str[s[i]], str[t[i]]);
    }

    cout << str << endl;
  }

  return 0;
}

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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REP1(i,n) for(int i=1, i##_len=(n); i<i##_len; ++i)
#define ll long long
static const int MAX = 10000;
static const ll INFTY = 1e12;

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 ll MRINF = 5000000000000000;

int main() {

  ll N; cin >> N;
  vector<ll> A(N), diff(N+1);
  REP(i, N){
    cin >>A[i];
  }
  ll sum = 0;
  diff[0] = A[0];
  sum += abs(diff[0]);
  REP1(i, N){
    diff[i] = A[i] - A[i-1];
    sum += abs(diff[i]);
  }
  diff[N] = 0-A[N-1];
  sum += abs(diff[N]);

  // cout << sum << endl;

  REP(i, N){
    ll  ans = sum - abs(diff[i]) - abs(diff[i+1]) + abs(diff[i]+diff[i+1]);
    cout << ans << endl;
  }

  

}
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         pass System Test!
*/

Measured memory_bytes: 4788
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <string.h>
using namespace std;
typedef long long ll;

int main() {
    int n; cin >> n;
    vector<string> s(n);
    for (int i = 0; i < n; i++) {
        cin >> s[i];
    } 
    sort(s.begin(), s.end());
    int cnt = 1, M = 0; 
    for (int i = 0; i < n - 1; i++) {
        if (s[i] == s[i + 1]) cnt++;
        else {
            M = max(M, cnt);
            cnt = 1;
        }
    }
    M = max(M, cnt);

    cnt = 1;
    for (int i = 0; i < n - 1; i++) {
        if (s[i] == s[i + 1]) cnt++;
        else {
            if (cnt == M) { 
                cout << s[i] << endl;
            }
            cnt = 1;
        }
    }
    if (cnt == M) cout << s[n - 1] << endl;
}

Measured memory_bytes: 14336
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
ll MOD = 1e9+7;
int n;
 map<int, int> m;
vector<bool> used(2*100000+10);
vector<vector<int>> g(2*100000+10);
vector<int> ans(2*100000 + 10);
void dfs(int s, int prev)
{
    used[s] = true;
    for(int i = 0; i < g[s].size(); i++)
    {
        int next = g[s][i];
        if(used[next]) continue;
        ans[next] = prev + m[next];
        dfs(next, ans[next]);
    }
}

int main()
{
    int q;
    cin >> n >> q;
    for(int i = 0; i < n-1; i++)
    {
        int a, b;
        cin >> a >> b;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    for(int i = 0; i <= n; i++)
    {
        ans[i] = 0;
        used[i] = false;
    }
    for(int i = 0; i < q; i++)
    {
        int a, b;
        cin >> a >> b;
        if(m.count(a) == 0) m.insert(P(a,b));
        else m[a] += b;
    }
    ans[1] = m[1];
    dfs(1, ans[1]);
    for(int i = 1; i <= n; i++)
    {
        cout << ans[i] << " ";
    }
}



Measured memory_bytes: 42240
open System
open System.Collections.Generic


let R T = stdin.ReadLine()|> T
let RS T = stdin.ReadLine().Split()|>Array.map T
let Mod = (1e9|>int64)+7L
[<EntryPoint>]
let main argv =
    let K,S=RS int|>fun c -> int c.[0],int c.[1]
    [for i in [0..K] do for j in [0..K] do yield (if (S-i-j)>=0 && (S-i-j)<=K then 1 else 0)]
    |>List.sum
    |>stdout.WriteLine
    0


Measured memory_bytes: 218588
package main

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

func rec(data int) {
	log.Println(data)
	if data == 0 {
		return
	}
	next := Abs(data) % 2
	if data < 0 {
		next = (2 - next) % 2
	}
	rec((data - next) / -2)
	fmt.Print(next)
}

func main() {
	log.SetFlags(log.Lshortfile)
	N := nextInt()
	if N == 0 {
		fmt.Println(0)
	} else {
		rec(N)
		fmt.Println()
	}
}
func Max(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r < a[i] {
			r = a[i]
		}
	}
	return r
}
func Min(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r > a[i] {
			r = a[i]
		}
	}
	return r
}
func Sum(a []int) (r int) {
	for i := range a {
		r += a[i]
	}
	return r
}
func Abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

type Pair struct {
	a, b int
}

type Pairs []Pair

func (p Pairs) Len() int {
	return len(p)
}
func (p Pairs) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}

func (p Pairs) Less(i, j int) bool {
	return p[i].b < p[j].b
}

var nextReader func() string

func init() {
	nextReader = NewScanner()
}

func NewScanner() func() string {
	r := bufio.NewScanner(os.Stdin)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)
	return func() string {
		r.Scan()
		return r.Text()
	}
}
func nextString() string {
	return nextReader()
}
func nextInt64() int64 {
	v, _ := strconv.ParseInt(nextReader(), 10, 64)
	return v
}
func nextInt() int {
	v, _ := strconv.Atoi(nextReader())
	return v
}
func nextInts(n int) []int {
	r := make([]int, n)
	for i := 0; i < n; i++ {
		r[i] = nextInt()
	}
	return r
}
func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(nextReader(), 64)
	return f
}


Measured memory_bytes: 640
import java.io.*;

public class Main {

	final static long MOD = 1000000007;
	public static void main(String[] args) throws Exception {
		// TODO 自動生成されたメソッド・スタブ

		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String W = in.readLine();
		String[] Ws = W.split(" ");
		int A = Integer.parseInt(Ws[0]);
		int B = Integer.parseInt(Ws[1]);
		int C = Integer.parseInt(Ws[2]);

		System.out.println(Math.max(C-(A-B),0));

	}

}


Measured memory_bytes: 21076
def main():
    from collections import defaultdict, deque

    N, K = map(int, input().split())
    a = map(int, input().split())

    def accumulate(a, mod):
        s = 0
        yield s
        for x in a:
            s = (s + x - 1) % mod
            yield s

    acc = accumulate(a, mod=K)

    d = defaultdict(int)
    dq = deque()
    ans = 0
    for x in acc:
        if x in d:  # inで判定してみる
            ans += d[x]
        d[x] += 1
        dq.append(x)
        if len(dq) >= K:
            r = dq.popleft()
            d[r] -= 1
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 45320
def main():
    n = input()
    S = map(int,raw_input().split())
    q = input()
    T = map(int,raw_input().split())
    m = 0
    for i in range(q):
        i0 = 0
        i1 = n-1
        t = T.pop()
        while i0 <= i1:
            im = int((i0+i1)/2)
            if t == S[im]:
                m += 1
                break
            elif t < S[im]:
                i1 = im-1
            elif t > S[im]:
                i0 = im+1
            
    print m


if __name__ == "__main__":
    main()

Measured memory_bytes: 14876
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define pb push_back
typedef long long ll;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;

int main(){
    int a, b;
    cin >> a >> b;

    int min_ans = 10 * b;
    rep(i,10){
        if(25*a <= (min_ans + i) * 2 && (min_ans +i) * 2 < 25*a+25){
            cout << min_ans + i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    
}

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

int main() {
    string s;
    int n, k;
    cin >> n >> k;
    cin >> s;
    int now = 1;
    int cnt = 0;
    vector<int> nums;
    rep(i,n) {
        if(s[i]-'0'==now) cnt++;
        else {
            nums.push_back(cnt);
            now = 1- now;
            cnt = 1;
        }
    }
    if(cnt!=0) nums.push_back(cnt);
    if(s[n-1]=='0') nums.push_back(0);

    vector<int> sums((int)nums.size()+1, 0);
    //累積和
    rep(i,nums.size()){
        sums[i+1] = sums[i] + nums[i];
    }

    int ans = 0;
    for(int l = 0; l < sums.size(); l+=2){
        int r = l + k*2 + 1;
        if(r >= sums.size()) r = sums.size()-1;
        ans = max(ans, sums[r]-sums[l]);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4180
import java.util.*;

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

	public Main(){
		new AOJ2197().doIt();
	}
	
	class AOJ2197{
		
		boolean calc(int index,int n){
			if(index==n)return false;
			int sum = 0;
			for(int i=index;i<=1000;i++){
				sum+=i;
				if(sum==n)return true;
				else if(sum>n)return false;
			}
			return false;
		}
		
		int solve(int n){
			int result = 0;
			for(int i=1;i<n;i++)if(calc(i, n)){
				result++;
			}
			return result;
		}
		
		void doIt(){
			while(in.hasNext()){
				int n = in.nextInt();
				if(n==0)break;
				System.out.println(solve(n));
			}
		}
	}
	
}

Measured memory_bytes: 19956
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include<stdbool.h>
typedef long long ll;
typedef long double ld;
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define rrep(i,l,r)for(ll i=(l);i>=(r);i--)
#define INF (1LL<<60)
#define MOD1 1000000007
#define MOD2 998244353
#define MAX_N (1 << 17)
#define YES printf("Yes\n")
#define NO printf("No\n")
#define PN printf("\n")

void swap(ll *a, ll *b){ll c;c=*b;*b=*a;*a=c;}
ll max2(ll a,ll b){return a>=b?a:b;}
ll min2(ll a,ll b){return a>=b?b:a;}
ll min3(ll a, ll b, ll c){return (a<=b && a<=c) ? a : b<=c ? b : c;}
ll max3(ll a, ll b, ll c){return (a>=b && a>=c) ? a : b>=c ? b : c;}
ll minn(ll n, ll a[n]){ll b=INF;rep(i,0,n) b=min2(b,a[i]);return b;}
ll maxn(ll n, ll a[n]){ll b=-INF;rep(i,0,n) b=max2(b,a[i]);return b;}
ll ABS(ll a){return a>=0?a:(-a);}
ll POW(ll a, ll b){ll c=1;rep(i,0,b) c*=a;return c;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll mod(ll n){return n%=MOD1;}
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}

typedef struct{ ll a , b;}fr;
int cmp1( const void *p, const void *q ) { return ((fr*)p) ->a - ((fr*)q)->a;}
int cmp2( const void *p, const void *q ) { return ((fr*)q) ->a - ((fr*)p)->a;}
void strsortup(fr*a,int n){qsort(a,n,sizeof(fr),cmp1);}
void strsortdown(fr*a,int n){qsort(a,n,sizeof(fr),cmp2);}

ll inv[1000005],finv[1000005];
void makeinv(ll n){
    inv[1]=1;finv[0]=finv[1]=1;
    rep(i,2,n+1){
        inv[i]=MOD1 - inv[MOD1%i] * (MOD1 / i) % MOD1;
        finv[i] = finv[i - 1] * inv[i] % MOD1;
    }
}
ll modfac(ll n, ll mod){
    ll x=1;
    rep(i,2,n+1){x*=i%mod;x%=mod;}
    return x;
}

int main(void){
    // char ;
    ll x,y,ans=0;
    scanf("%lld%lld",&x,&y);
    // ll [n];
    if((x+y)%3!=0 || y>2*x || x>2*y){
        printf("0\n");
        return 0;
    }
    ll r=(x+y)/3,k=0;
    while(y!=2*x){
        x-=2;
        y--;
        k++;
    }
    makeinv(1000000);
    ans=modfac(r,MOD1)* mod( finv[k]*finv[r-k] );
    ans%=MOD1;
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 15744
# vim: fileencoding=utf-8


def main():
    k, s = map(int, input().split())
    c = 0
    for i in range(k + 1):
        for j in range(k + 1):
            z = s - i - j
            if z >= 0 and z <= k:
                c += 1
    print(c)


if __name__ == "__main__":
    main()


Measured memory_bytes: 73340
import java.io.*;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws Exception{
		// TODO Auto-generated method stub
		String[] sabc = {"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[] nabc = new int[sabc.length];
		for(int i=0; i<nabc.length; i++)nabc[i]=0;

		InputStreamReader isr = new InputStreamReader(System.in);
		BufferedReader br = new BufferedReader(isr);
		
		String str=br.readLine();
		while(str !=null){		
		
			String[] strArray = str.split("");
			for (int i = 0; i < strArray.length; i++) {
				strArray[i] = strArray[i].toLowerCase();
				for(int j = 0; j < sabc.length; j++){
					if(strArray[i].equals(sabc[j])){
						nabc[j]++;
					}
				}
			}
		str = br.readLine();
		}
		for(int j=0; j<sabc.length; j++){
			System.out.println(sabc[j] + " : " + nabc[j]);
		}
	}
}

Measured memory_bytes: 25616
#include <iostream>

using namespace std;

int main (){
  long N, T;
  long d = 0;
  long iv = 0;
  long prev = 0;
  cin >> N >> T;
  for (int i=0;i<N;i++){
    long tt;
    cin >> tt;
    iv = tt - prev;
    if (iv < T) {
      d += T - iv;
    }
    prev = tt;
  }
  cout << N*T - d + T << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
using namespace std;
#define ll long long
#define rep(i, s, n) for(int i = s; i < n; i++)
typedef pair<int, int> P;

int main() {
    string s;
    cin >> s;
    string t = "", r = "";
    int n = s.size();
    t = s.substr(0, (n-1)/2);
    r = s.substr((n+3)/2-1, n);
    for(int i = 0; i < s.size()/2; i++) {
        if(s[i] == s[s.size()-i-1]) {

        }
        else {
            cout << "No" << endl;
            return 0;
        }
    }
    for(int i = 0; i < t.size()/2; i++) {
        if(t[i] == t[t.size()-i-1]) {

        }
        else {
            cout << "No" << endl;
            return 0;
        }
    }
    for(int i = 0; i < r.size()/2; i++) {
        if(r[i] == r[r.size()-i-1]) {

        }
        else {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;
#[allow(unused_imports)]
use std::collections::*;

struct Scanner<R: Read> {
    reader: R,
}

#[allow(dead_code)]
impl<R: Read> Scanner<R> {
    fn new(reader: R) -> Scanner<R> {
        Scanner { reader: reader }
    }

    fn safe_read<T: FromStr>(&mut self) -> Option<T> {
        let token = self.reader.by_ref().bytes().map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        if token.is_empty() {
            None
        } else {
            token.parse::<T>().ok()
        }
    }

    fn readu32(&mut self) -> u32 {
        self.reader.by_ref().bytes().map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .fold(0, |acc, x| acc*10 + (x as u8 - b'0') as u32)
    }

    fn read<T: FromStr>(&mut self) -> T {
        if let Some(s) = self.safe_read() {
            s
        } else {
            writeln!(std::io::stderr(), "Terminated with EOF").unwrap();
            std::process::exit(0);
        }
    }

    fn vec<T: FromStr>(&mut self, len: usize) -> Vec<T> {
        (0..len).map(|_| self.read()).collect()
    }

    fn mat<T: FromStr>(&mut self, row: usize, col: usize) -> Vec<Vec<T>> {
        (0..row).map(|_| self.vec(col)).collect()
    }
}

trait Joinable {
    fn join(self, sep: &str) -> String;
}

impl<U: ToString, T: Iterator<Item=U>> Joinable for T {
    fn join(self, sep: &str) -> String {
        self.map(|x| x.to_string()).collect::<Vec<_>>().join(sep)
    }
}

fn main() {
    std::thread::Builder::new()
        .stack_size(104_857_600)
        .spawn(solve)
        .unwrap()
        .join()
        .unwrap();
}

fn insertion_sort(a: &mut Vec<u32>, g: usize) -> usize {
    let mut cnt = 0;
    let n = a.len();
    for i in g..n {
        let v = a[i];
        let mut j = i;
        while j >= g && a[j-g] > v {
            a[j] = a[j-g];
            cnt += 1;
            j -= g;
        }
        a[j] = v;
    }
    cnt
}

fn shell_sort(a: &mut Vec<u32>, g: &[usize]) -> usize {
    let mut cnt = 0;
    for &i in g.iter() {
        cnt += insertion_sort(a, i);
    }
    cnt
}

fn solve() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);
    let n = sc.read();
    let mut a: Vec<_> = (0..n).map(|_| sc.readu32()).collect();

    let g = {
        let mut g = vec![];
        let mut x = 1 as usize;
        while x <= n {
            g.push(x);
            x = x*3 + 1;
        }
        g.reverse();
        g
    };

    let cnt = shell_sort(&mut a, &g[..]);
    let stdout = stdout();
    let stdout = stdout.lock();
    let mut stdout = BufWriter::new(stdout);

    write!(&mut stdout, "{} ", g.len()).unwrap();
    for x in g.iter() {
        write!(&mut stdout, "{} ", x).unwrap();
    }
    write!(&mut stdout, "{} ", cnt).unwrap();
    for x in a.iter() {
        write!(&mut stdout, "{} ", x).unwrap();
    }
}



Measured memory_bytes: 13108
sss = input().split()
a, b = sss[0], sss[1]

aa, bb = "", ""

for i in range(int(b)):
    aa += a

for i in range(int(a)):
    bb += b

if len(aa) <= len(bb):
    length = len(aa)
    ans = aa
else:
    length = len(bb)
    ans = bb

flag = 0
for i in range(length):
    if int(aa[i]) < int(bb[i]):
        flag = 1
        break
    elif int(aa[i]) > int(bb[i]):
        flag = -1
        break

if flag == 1:
    print(aa)
elif flag == -1:
    print(bb)
else:
    print(ans)


Measured memory_bytes: 3064
#include <cctype>
#include <cfloat>
#include <climits>
#include <cmath>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <ios>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <forward_list>
#include <random>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <unordered_map>
#include <unordered_set>
#endif

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define lcm( a, b ) (a)/__gcd((a),(b))*(b)
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair< int, int > P;
typedef pair< LL, LL > LP;
typedef pair< int, P > iP;
typedef pair< P, P > PP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;
static const int SIZE = 100005;

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

vector< int > Div( int n ) {
    vector< int > ret;
    for( int i = 1; i * i <= n; ++i ) {
        if( n % i == 0 ) {
            ret.pb( i );

            if( i * i != n ) ret.pb( n / i );
        }
    }
    sort( all( ret ) );
    return ret;
}

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

    int n, m;
    cin >> n >> m;
    priority_queue< LL > pq;
    for( int i = 0; i < n; ++i ) {
        LL a;
        cin >> a;
        pq.push( a );

    }

    for( int i = 0; i < m && !pq.empty(); ++i ) {
        LL p = pq.top(); pq.pop();
        p /= 2;
        if( p > 0 ) pq.push( p );

    }

    LL res = 0;
    while( !pq.empty() ) {
        res += pq.top(); pq.pop();

    }
    cout << res << endl;
    return 0;
}



Measured memory_bytes: 1400
#!/usr/bin/env python3

while True:
    n = int(input())
    data = [0] * 10
    if n == 0:
        break

    for _ in range(n):
        in_data = int(input())
        data[in_data] += 1

    for d in data:
        if d == 0:
            print("-")
        else:
            print("*" * d)

Measured memory_bytes: 7404
#include <iostream>
#include <cstring>
#include <map>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <queue>
#include <list>
#include <numeric>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <math.h>
#include <stack>
#include <climits>
#include <bitset>

using namespace std;
typedef long long ll;

//最小公倍数
ll gcd(ll x, ll y) {
  ll tmp = 0;
  if (x < y){
    tmp=x;
    x=y;
    y=tmp;
  }
  while (y > 0) {
    ll r = x % y;
    x = y;
    y = r;
  }
  return x;
}

//最大公倍数
ll lcm(ll x,ll y){
  return x/gcd(x,y)*y;
}

//階乗
ll kaijo(ll k){
    ll sum = 1;
    for (ll i = 1; i <= k; ++i)
    {
        sum *= i;
        sum%=1000000000+7;
    }
    return sum;
}

//for(int i = ; i < ; i++){}

int main(){
  int n;
  cin>>n;
  int a[n];
  int b[9];
  for(int i = 0; i < 9; i++) b[i]=0;
  for(int i = 0; i < n; i++){
    cin>>a[i];
    int c = a[i]/400;
    if(c>7){
      b[8]++;
    }
    else{
      b[c]++;
    }
  }
  //最小を考える。カンスト勢が全員既存の一色を選べば良い
  int counter=0;
  for(int i = 0; i < 8; i++){
    if(b[i]>0) counter++;
  }
  cout<<max(counter,1)<<" ";

  //最大を考える。
    cout<<counter+b[8]<<endl;
 
  
  return 0;
}

  



Measured memory_bytes: 256