akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#define max(A,B) ((A) > (B) ? (A) : (B))

int M0, D0, h0, m0; /* int型の時刻の基準 */

void setOriginTime(int M, int D, int h, int m) {
	M0 = M; D0 = D; h0 = h; m0 = m;
}

/* 時刻を計算用の整数値に変換する */
int timeToInt(int M, int D, int h, int m) {
	int t;
	t = M - M0;
	t = t * 30 + D - D0;
	t = t * 24 + h - h0;
	t = t * 60 + m - m0;
	return t;
}

int main(void) {
	int n; /* 日誌の行数 */

	/* データセット毎の処理 */
	while (scanf("%d", &n) == 1 && n > 0 && n <= 1000) {
		int io[1000] = {}; /* 現在祭壇にいるか */
		int ti[1000] = {}; /* 最後に祭壇に入った時刻 */
		int total[1000] = {}; /* 女神のいる間に祭壇にいた合計時間 */
		int M, D, h, m, p, i, t;
		char e;

		/* 行毎の処理 */
		for (i = 0; i < n; i++) {
			scanf("%d/%d %d:%d %c %d", &M, &D, &h, &m, &e, &p); /* 一行入力 */
			if (i == 0) setOriginTime(M, D, h, m); /* 最初のログを時刻の基準とする */

			t = timeToInt(M, D, h, m); /* 整数値に変換する */

			if (e == 'I') {
				/* 入室 */
				io[p] = 1;
				ti[p] = t;
			} else if (e == 'O') {
				/* 退室 */
				io[p] = 0;
				if (p == 0) {
					/* 女神 */
					int j;
					/* 女神退室時点での全てのプログラマーの滞在時間を計算する */
					for (j = 1; j < 1000; j++) {
						if (io[j]) total[j] += t - max(ti[j], ti[0]);
					}
				} else {
					/* プログラマー */
					if (io[0]) total[p] += t - max(ti[p], ti[0]); /* 両者が祭壇にいた時間を加える */
				}
			}
		}

		/* 合計時間の最大値を探す */
		int tmax = total[1];
		for (i = 2; i < 1000; i++) {
			if (total[i] > tmax) tmax = total[i];
		}

		printf("%d\n", tmax);
	}

	return 0;
}

Measured memory_bytes: 612
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
       
        Scanner sc = new Scanner(System.in);
        long a = sc.nextLong();
        ArrayList<Long> list = new ArrayList<>();
        long ans1 = 0;
        long ans2 = 0;
        for(long i = 1; i * i <= a; i++){
            if(a % i == 0){
                list.add(i);
                list.add(a/i);
            }
        }
        ans1 = list.get(list.size() - 2) - 1;
        ans2 = list.get(list.size() - 1) - 1;
        System.out.println(ans1 + ans2);
    }
}

Measured memory_bytes: 23764
fun main(args: Array<String>) {
    val (h, w, n) = readLine()!!.split(' ').map(String::toLong)
    val hwList = mutableListOf<Pair<Long, Long>>()
    for (i in 1..n) {
        val (ht, wt) = readLine()!!.split(' ').map(String::toLong)
        if (wt <= ht) hwList.add(Pair(ht, wt))
    }
    hwList.sortBy { it.second }
    hwList.sortBy { it.first }
    var diff = 1L
    var min = Long.MAX_VALUE
    for (i in 0 until hwList.size) {
        val h = hwList[i].first
        val w = hwList[i].second
        if (w + diff <= h) {
            min = Math.min(h - 1, min)
        } else if (h - w == diff - 1) {
            diff++
        }
    }
    print(Math.min(h, min))
}


Measured memory_bytes: 133848
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
    
#define all(a) a.begin(), a.end()
#define F first
#define S second
#define $ ios::sync_with_stdio(0);
//#define int long long int
    
using namespace std;
using namespace __gnu_pbds;
using ll = long long int;
using ii = pair<int, int>;
using vi = vector<int>;
using graph = vector<vi>;
using ordered_mset = tree<ii, null_type, less<ii>, rb_tree_tag, tree_order_statistics_node_update>;
using ordered_set = tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>;
    
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    
const ll mod = 1000000007;
const int INF = 0x3f3f3f3f;
//const ll INFLL = (ll)1e17;
const int MAXN = 3123;
const double pi = 3.14159265359;
const double eps = 0.00000001;
 
double p[MAXN];
double dp[MAXN];
 
int main() {
    $
    int n;
    cin >> n;
    for (int i = 1; i <= n; ++i) {
        cin >> p[i];
    }
    dp[0] = 1;
    double save, keep;
    for (int i = 1; i <= n; ++i) {
        save = dp[0];
        dp[0] *= (1 - p[i]);
        for (int j = 1; j <= i; ++j) {
            keep = dp[j];
            dp[j] = save * p[i] + dp[j] * (1 - p[i]);
            save = keep;
            //dp[i][j] = dp[i - 1][j - 1] * p[i] + dp[i - 1][j] * (1 - p[i]);
        }
    }
    double ans = 0;
    for (int i = n/2+1; i <= n; ++i) {
        ans += dp[i];
    }
    cout << fixed;
    cout.precision(10);
    cout << ans << '\n';
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long  ll;
typedef vector<int> VI;
typedef vector<ll> VLL;

int main(){
    string s="Christmas", a = " Eve";
    int d;
    cin >> d;
    if(d==25){cout << s << endl; return 0;}
    if(d==24){cout << s + a << endl; return 0;}
    if(d==23){cout << s + a + a << endl; return 0;}
    if(d==22){cout << s + a + a +a << endl; return 0;}

}

Measured memory_bytes: 256
import java.util.*
import java.math.*

fun main(args: Array<String>) {

//    var (A,B,C,D) = readLine()!!.split(" ").map { it.toLong() }
    var N = readLine()!!.toInt()
//    val D = readLine()!!.split(" ").map { it.toLong() }
    val D = readLine()!!.split(" ").map { it.toInt() }.toIntArray()
    D.sort()
    println(D[N/2] - D[N/2-1])

//    println("%.9f".format(ans))
}


Measured memory_bytes: 51496
//参考：https://qiita.com/DaikiSuyama/items/9dba963ba74396b9b7fd
//インクルード(アルファベット順)
#include <algorithm>     //sort,二分探索,など
#include <bitset>        //固定長bit集合
#include <cmath>         //pow,logなど
#include <complex>       //複素数
#include <deque>         //両端アクセスのキュー
#include <functional>    //sortのgreater
#include <iomanip>       //setprecision(浮動小数点の出力の誤差)
#include <iostream>      //入出力
#include <iterator>      //集合演算(積集合,和集合,差集合など)
#include <map>           //map(辞書)
#include <numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include <queue>         //キュー
#include <set>           //集合
#include <stack>         //スタック
#include <string>        //文字列
#include <unordered_map> //イテレータあるけど順序保持しないmap
#include <unordered_set> //イテレータあるけど順序保持しないset
#include <utility>       //pair
#include <vector>        //可変長配列

using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= (ll)(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= (ll)(b); i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(), (x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())      //sizeをsize_tからllに直しておく
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007    //10^9+7:合同式の法
#define MAXR 100000       //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define FIR first    //pairの一つ目の要素
#define SEC second   //pairの二つ目の要素

signed main()
{
    //入力の高速化用のコード
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int N;
    cin >> N;
    vector<ll> A(10000000);

    FOR(x, 1, 100)
    FOR(y, 1, 100)
    FOR(z, 1, 100)
    {
        ll C = x * x + y * y + z * z + x * y + y * z + z * x;
        A[C]++;
    }

    FOR(i, 1, N)
    cout << A[i] << "\n";

    return 0;
}


Measured memory_bytes: 80968
from itertools import combinations
n = int(input())
march = [0 for _ in range(5)]
for i in range(n):
    s = input()

    if s[0] == 'M':
        march[0] += 1
    elif s[0] == 'A':
        march[1] += 1
    elif s[0] == 'R':
        march[2] += 1
    elif s[0] == 'C':
        march[3] += 1
    elif s[0] == 'H':
        march[4] += 1
ans = 0
for i in combinations(range(5), 3):
    ans += march[i[0]] * march[i[1]] * march[i[2]]
print(ans)


Measured memory_bytes: 9148
#include <iostream> 
#include<vector>
#include<algorithm>
#include<map>
#include<iomanip>
#include<set>
#include<queue>
#include<deque>
#include<iomanip>
#include<sstream>
#include<cmath>
#include<bitset>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define req(i,n) for(int i = 1;i <=  n; i++)
#define rrep(i,n) for(int i = n -1;i >= 0;i--)
#define ALL(obj) begin(obj), end(obj)
#define RALL(obj) rbegin(obj),rend(obj)
typedef long long int ll;
typedef long double ld;
const ll INF = (1 << 30);
ld h, m,a,b, sum; string s, t;
const ll MOD= 1000000007;
const ld PI = acos(-1);
int main() {
    cin >> a >> b >> h >> m;
    ld ang = abs(30 * h + 0.5 * m - 6 * m);
    ang = ang / 180 * PI;
    sum = a * a + b * b - 2 * a * b * cos(ang);
    cout << fixed << setprecision(10) << sqrt(sum )  << endl;
}

Measured memory_bytes: 4168
#include <bits/stdc++.h>
using namespace std;
int main() {
  int H, W;
  cin >> H >> W;
  vector<string> mat(H);
  for (int i = 0; i < H; ++i) {
    cin >> mat[i];
  }
  int dp[H][W];
  for (int i = 0; i < H; ++i) {
    for (int j = 0; j < W; ++j) {
      if (i + j == 0) {
        dp[0][0] = (mat[0][0] == '#');
      } else {
        dp[i][j] = 1e9;
        if (i > 0) {
          dp[i][j] = min(dp[i][j], dp[i - 1][j] + (mat[i - 1][j] == '.' && mat[i][j] == '#'));
        }
        if (j > 0) {
          dp[i][j] = min(dp[i][j], dp[i][j - 1] + (mat[i][j - 1] == '.' && mat[i][j] == '#'));
        }
      }
    }
  }
  cout << dp[H - 1][W - 1] << endl;
  return 0;
}
  

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <functional>
#include <queue>
#include <stack>
#include <string.h>
#include <list>
using namespace std;
typedef long long ll;
#define all(a)  (a).begin(), (a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define rep(i,n) for(int i = 0; i < n; i++)
#define repR(i,n) for(int i = n-1; i >= 0; i--)
#define FOR(i,m,n) for(int i = m; i < n; i++)
#define PB push_back
#define MP make_pair
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))


int main() {
    ll n,a,ans = 0;
    cin >> n;
    rep(i,n){
        cin >> a;
        ans += a;
    }
    cout << ans - n << endl;
    return 0;
}

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int N, Q;
  cin >> N >> Q;

  vector<char> A(N);
  for (int i = 0; i < N; i++) {
    char C;
    cin >> C;
    A.at(i) = C;
  }

  vector<int> B(N);
  for (int i = 1; i < N; i++) {
    if (A.at(i - 1) == 'A' && A.at(i) == 'C') B.at(i)++;
    B.at(i) += B.at(i - 1);
  }

  for (int i = 0; i < Q; i++) {
    int L, R;
    cin >> L >> R;
    cout << B.at(R - 1) - B.at(L - 1) << endl;
  }
}

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

#define dump(x) cout << (x) << '\n'
#define Int int64_t
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
 
Int INF = 1e18;
int inf = 1e9;
Int mod = 1e9+7;

int main() {
    Int d, n;
    cin >> d >> n;
    Int x = 1;
    while (d > 0) {
        x *= 100;
        d--;
    }
    if (n == 100) {
        n++;
    }
    dump(x * n);
    return 0;
}

Measured memory_bytes: 256
from sys import stdin
import sys

S = stdin.readline().rstrip()
T = ''

data = ['dream', 'erase', 'dreamer', 'eraser']

if len(S) < len('dream'):
    print('NO')
    sys.exit()

pos = 0
flag_dream = False
flag_erase = False

while pos < len(S):
    if S[pos:pos+len(data[0])] == data[0]:
        pos = pos + len(data[0])
        flag_dream = True
        flag_erase = False
    elif S[pos:pos+len(data[1])] == data[1]:
        pos = pos + len(data[1])
        flag_erase = True
        flag_dream = False
    elif S[pos:pos+len(data[2])] == data[2]:
        pos = pos + len(data[2])
        flag_dream = False
        flag_erase = False
    elif S[pos:pos+len(data[3])] == data[3]:
        pos = pos + len(data[3])
        flag_dream = False
        flag_erase = False
    elif flag_dream and S[pos:pos+len('er')] == 'er':
        pos = pos + len('er')
        flag_dream = False
        flag_erase = False
    elif flag_erase and S[pos:pos+len('r')] == 'r':
        pos = pos + len('r')
        flag_dream = False
        flag_erase = False
    else:
        print('NO')
        sys.exit()


print('YES')



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

using namespace std;


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

    bool fg = true;
    while (a > 0 || c > 0) {
        if (fg) {
            c -= b;
            if (c <= 0) {
                cout << "Yes" << endl;
                return 0;
            }
            fg = false;
        } else {
            a -= d;
            if (a <= 0) {
                cout << "No" << endl;
                return 0;
            }
            fg = true;
        }
    }
}


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

const ll MAXN = 200000;
const ll INF = 1001001001;

ll N, C, ans=0, tmp=0;
vector<ll> A, X, S1, S2, SR1, SR2;

signed main(){
    cin >> N >> C;
    X.resize(N);
    A.resize(N);
    S1.resize(N+1,0);
    S2.resize(N+1,0);
    SR1.resize(N+1,0);
    SR2.resize(N+1,0);
    for(int i=0;i<N;i++) {
        cin >> X[i] >> A[i];
    }
    for(int i=0;i<N;i++) {
        S1[i+1] = S1[i] + A[i];
        S2[i+1] = S2[i] + A[i];
        SR1[N-i-1] = SR1[N-i] + A[N-i-1];    
        SR2[N-i-1] = SR2[N-i] + A[N-i-1];    
    }
    for(int i=0;i<N;i++) {
        S1[i+1] -= X[i];
        S2[i+1] -= 2*X[i];
        SR1[N-i-1] -= C-X[N-i-1];    
        SR2[N-i-1] -= 2*(C-X[N-i-1]);
    }
    for(int i=0;i<=N;i++) {
        //cout << S1[i] << " " << S2[i] << " " << SR1[N-i] << " " << SR2[N-i] << endl;
    }
    for(int i=0;i<N;i++) {
        S1[i+1] = max(S1[i+1],S1[i]);
        S2[i+1] = max(S2[i+1],S2[i]);
        SR1[N-i-1] = max(SR1[N-i-1],SR1[N-i]);
        SR2[N-i-1] = max(SR2[N-i-1],SR2[N-i]);;    
    }
    for(int i=0;i<=N;i++) {
        ans = max(ans, S1[i]+SR2[i]);
        ans = max(ans, S2[i]+SR1[i]);
    }
    cout << ans << endl;
    return 0;
}


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

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int[] a = new int[3];
		int[] b = new int[3];
		for (int i=0;i<3;i++) {
			a[i]=sc.nextInt();
			b[i]=sc.nextInt();
		}

		int[] c = new int[4];
		for (int i=0;i<3;i++) {
			switch (a[i]) {
			case 1:c[0]++;
			break;
			case 2:c[1]++;
			break;
			case 3:c[2]++;
			break;
			case 4:c[3]++;
			break;
			}
		}
		for (int i=0;i<3;i++) {
			switch (b[i]) {
			case 1:c[0]++;
			break;
			case 2:c[1]++;
			break;
			case 3:c[2]++;
			break;
			case 4:c[3]++;
			break;
			}
		}
		int cnt = 0;
		for(int i=0;i<4;i++) {
			if (c[i]%2==0) {
				cnt++;
			}
		}
		if (cnt==2) {
			System.out.println("YES");
		}else {
			System.out.println("NO");
		}
	}
}

Measured memory_bytes: 22740
#include<stdio.h>
int main(void){
    setvbuf(stdout,NULL,_IONBF,0);
 
    int r,c,i,j;
    scanf("%d %d",&r,&c);
    int num[r + 1][c + 1];
    for(i = 0;i <= r;i++){
        for(j = 0;j <= c;j++){
            num[i][j] = 0;
        }
    }
    for(i = 0;i < r;i++){
        for(j = 0;j < c;j++){
            scanf("%d",&num[i][j]);
        }
    }
    for(i = 0;i < r;i++){
        for(j = 0;j < c;j++){
            num[i][c] += num[i][j];
        }
    }
    for(i = 0;i <= c;i++){
        for(j = 0;j < r;j++){
            num[r][i] += num[j][i];
        }
    }
    for(i = 0;i <= r;i++){
        for(j = 0;j < c;j++){
            printf("%d ",num[i][j]);
        }
        printf("%d\n",num[i][j]);
    }
 
    return 0;
}

Measured memory_bytes: 644
#include <stdio.h>
#include <math.h>

int main(void){
    long N, D, a[2];
    int cnt = 0, i;

    scanf("%ld %ld", &N, &D);

    for(i = 0; i < N; i++){
        scanf("%ld %ld", &a[0], &a[1]);
        if(D >= sqrt(a[0] * a[0] + a[1] * a[1]))
            cnt++;
    }

    printf("%d\n", cnt);

    return 0;
}

Measured memory_bytes: 2132
using System;

namespace MyApp
{
    class Contest
    {
        public static int Main()
        {
            string[] args = Console.ReadLine().Split(' ');
            int a = int.Parse(args[0]);
            int b = int.Parse(args[1]);
            int ab = a + b;

            int c = ab % 2 > 0 ? ab / 2 + 1 : ab / 2;
          
            Console.WriteLine(c);
            return 0;
        }
    }
}

Measured memory_bytes: 11092
// AOJ 1522: Planarian Regeneration
// 2019.2.25 bal4u

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int c[42][42];
long double a[42][42], s[42][42];

long double calc(int m, int n, int x)
{
	int i, j;
	long double ans;

	memset(c, 0, sizeof(c)), memset(a, 0, sizeof(a)), memset(s, 0, sizeof(s));
	c[0][0] = 1, s[0][0] = 1.0;
	for (i = 0; i < 42; i++) a[0][i] = 1.0;
	for (i = 1; i <= x; i++) {
		for (j = 0; j < i; j++) {
			c[i][j]   += c[i-1][j];
			c[i][j+1] += c[i-1][j];
		}
		for (j = 0; j <= x; j++) {
			if (j < i) a[i][j] = a[i-1][j] * (long double)m/(m+n);
			else       a[i][j] = a[i-1][j] * (long double)n/(m+n);
		}
		for (j = 0; j < i; j++) {
			s[i][j] += s[i-1][j];
			s[i][j+1] += s[i-1][j] - a[i][j] * (long double)c[i-1][j];
		}
	}
	ans = 0; for (i = 0; i <= x; i++) ans += s[x][i]*a[x][i];
	return ans;
}

int main()
{
	int m, n, x, k, l, y;
	scanf("%d%d%d%d%d%d", &m, &n, &x, &k, &l, &y);
	printf("%.12Lf\n", calc(m, n, x)*calc(k, l, y));
	return 0;
}


Measured memory_bytes: 2064
(unless (member :child-sbcl *features*)
  (quit
   :unix-status
   (process-exit-code
    (run-program *runtime-pathname*
                 `("--control-stack-size" "128MB"
                   "--noinform" "--disable-ldb" "--lose-on-corruption" "--end-runtime-options"
                   "--eval" "(push :child-sbcl *features*)"
                   "--script" ,(namestring *load-pathname*))
                 :output t :error t :input t))))

(defun read-fixnum (i n)
  (if (<= n i)
    nil
    (cons (read) (read-fixnum (1+ i) n)))
  )


(setq *n* (read))
(setq *k* (read))

(setq *hi* (read-fixnum 0 *n*))

(defun ans (hi)
  (length (remove-if (lambda (h) (< h *k*)) hi)))

(format t "~a~%" (ans *hi*))


Measured memory_bytes: 64572
from itertools import tee


def pairwise(iterable):
    a, b = tee(iterable)
    next(b, None)
    return zip(a, b)


N = int(input())
H = list(map(int, input().split()))

longest_stroke = 0
current_stroke = 0
for p, n in pairwise(H):
    if p >= n:
        current_stroke += 1
        if longest_stroke < current_stroke:
            longest_stroke = current_stroke
    else:
        current_stroke = 0
print(longest_stroke)


Measured memory_bytes: 14528
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bits/stdc++.h>
#include<cmath>
#include<bitset>
#include<queue>
#define ll long long
#define itn int
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define INF ((1LL<<62)-(1LL<<31))
#define MOD 1000000007
using namespace std;

ll N,M,K,A,B,C,ans=0,cnt=0;
string S,T;
vector<ll> P,Q,R;
vector<pair<int,int>> PP,QQ;
bool CAN=true;


int main(){
  cin>>N;
  REP(i,N){
    ll a;
    cin>>a;
    P.push_back(i);
    PP.push_back(make_pair(a,i));
  }
  
  SORT(P);
  SORT(PP);
  
  REP(i,N){
    QQ.push_back(make_pair(P.at(i),i));
  }
  
  REP(i,N){
    if(abs(QQ[i].second-PP[i].second)%2==1) ans++;
  }
  
  cout<<ans/2<<endl;
}

Measured memory_bytes: 3308
import std.stdio, std.conv, std.string, std.bigint;
import std.math, std.random, std.datetime;
import std.array, std.range, std.algorithm, std.container, std.format;
string read(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }


void main(){

 int n = read.to!int;
 long[] as;
 foreach(i; 0 .. n + 1) as ~= read.to!long;

 long[long] pos;
 long i0, i1;
 foreach(i, a; as){
  if(a !in pos) pos[a] = i;
  else i0 = pos[a], i1 = i;
 }

 foreach(k; 1 .. n + 2){
  long q = pascal(k, n + 1 - k);
  q += mod - pascal(k - 1, i0 + (n - i1) - (k - 1)), q %= mod;

  q.writeln;

 }

}
/*
// 仮実装
long pascal(long a, long b){
  static long[long[2]] memo;
  if(a == 0) return 1;
  if(b == 0) return 1;
  if(a < 0) return 0;
  if(b < 0) return 0;
  if([a, b] !in memo){
    memo[[a, b]] = (pascal(a, b - 1) + pascal(a - 1, b)) % mod;
  }
  return memo[[a, b]];
}
*/
// mod p における乗法逆元
long inv(long x){
	assert(x > 0);
	assert(x < mod);
	static long[] _inv = [0, 1];
	while(x >= _inv.length){
		_inv ~= _inv[mod % $] * (mod - mod / _inv.length) % mod;
	}
	return _inv[x];
}

// mod p における階乗
long perm(long x){
	assert(x >= 0);
	assert(x < mod);
	static long[] _perm = [1];
	while(x >= _perm.length){
		_perm ~= _perm[$ - 1] * _perm.length % mod;
	}
	return _perm[x];
}

// mod p における階乗の逆元
long invperm(long x){
	assert(x >= 0);
	assert(x < mod);
	static long[] _invperm = [1];
	while(x >= _invperm.length){
		_invperm ~= _invperm[$ - 1] * inv(_invperm.length) % mod;
	}
	return _invperm[x];
}

// mod p における二項係数（定義に注意：(a + b)! / a! / b! ）
long pascal(long a, long b){
    if(a < 0 || b < 0) return 0;
	assert(a >= 0 && b >= 0);
	assert(a < mod && b < mod);
	long res = perm((a + b) % mod);
	res *= invperm(a), res %= mod;
	res *= invperm(b), res %= mod;
	return res;
}
const long mod = 1_000_000_007;



Measured memory_bytes: 16444
#include "bits/stdc++.h"
#define rep(i, j) for (int i = 0; i < j; i++)
using namespace std;
using ll = long long;
using ull = unsigned long long;

int gcd(int x, int y);

const int INF = 1001001001;

/*struct mint {
    ll x; // typedef long long ll;
    mint(ll x = 0) :x((x% mod + mod) % mod) {}
    mint operator-() const { return mint(-x); }
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; }
    mint operator+(const mint a) const { return mint(*this) += a; }
    mint operator-(const mint a) const { return mint(*this) -= a; }
    mint operator*(const mint a) const { return mint(*this) *= a; }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod - 2); }
    mint& operator/=(const mint a) { return *this *= a.inv(); }
    mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream & is, const mint & a) { return is >> a.x; }
ostream& operator<<(ostream & os, const mint & a) { return os << a.x; }*/

int main() {
    int n;
    cin >> n;
    vector<string> s(n);
    rep(i, n) cin >> s[i];
    sort(s.begin(), s.end());
    int m;
    cin >> m;
    vector<string> t(m);
    rep(i, m) cin >> t[i];
    sort(t.begin(), t.end());
    int ans = 0;
    rep(k, n) {
        int num = 0;
        rep(i, n) {
            if (s[k] == s[i])
                num++;
        }
        rep(j, m) {
            if (s[k] == t[j])
                num--;
        }
        ans = max(num, ans);
    }

    cout << ans << endl;
    return 0;
}
/*���C�u�����ő����*/
//���[�O���b�h�̌ݏ��@
int gcd(int x, int y) {
    int num[3];
    num[0] = (x > y) ? x : y;
    num[1] = (x <= y) ? x : y;
    num[2] = num[0] % num[1];

    while (num[2]) {
        num[0] = num[1];
        num[1] = num[2];
        num[2] = num[0] % num[1];
    }

    return num[1];
}

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

int check(int dis) {
	for (int i = 1; i < dis+1; i++) {
		if (dis == i*i) return 1;
	}
	return 0;
}

int main() {
	int n, d;
	scanf("%d %d", &n, &d);
	int x[n][d];
	int sum = 0;
	int time = 0;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < d; j++) {
			scanf("%d", &x[i][j]);
		}
	}
	for (int i = 0; i < n-1; i++) {
		for (int j = i+1; j < n; j++) {
			int dis = 0;
			for (int k = 0; k < d; k++) {
				dis += (x[i][k]-x[j][k])*(x[i][k]-x[j][k]);
			}
			if (check(dis) == 1) sum++;
			time++;
		}
	}
	printf("%d", sum);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()

vector<int> factors[200001];

int main() {
    int N, a[200001] = {}, A[200001] = {};
    bool ans[200001] = {};
    cin >> N;
    REP(i, N) cin >> a[i + 1];
    FOR(i, 1, N + 1) {
        int n = i;
        while (n <= N) {
            factors[n].push_back(i);
            n += i;
        }
    }

    RFOR(i, N, 0) {
        if (a[i] != A[i]) {
            for (int f : factors[i]) {
                A[f] = (A[f] + 1) % 2;
            }
            ans[i] = true;
        }
    }

    int cnt = 0;
    REP(i, N + 1) if (ans[i]) cnt++;
    cout << cnt << endl;
    REP(i, N + 1) if (ans[i]) cout << i << " ";
    cout << endl;
    return 0;
}

Measured memory_bytes: 24064
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<vector>
#include<utility>
using namespace std;
int BIG=999999999;

int n,m;
int dis[1010],ond[1010];
int dp[1010][1010];//day,now

int sol(int day,int now){
	if(dp[day][now]!=-1)return dp[day][now];
	if(now==n)return dp[day][now]=0;
	if(day==m)return dp[day][now]=BIG;
	dp[day][now]=min(sol(day+1,now),sol(day+1,now+1)+(ond[day]*dis[now]));
	return dp[day][now];
}

int main(){
	cin >> n >> m;
	for(int i=0; i<n; i++)cin >> dis[i];
	for(int i=0; i<m; i++)cin >> ond[i];
	for(int i=0; i<=m; i++){
		for(int j=0; j<=n; j++)dp[i][j]=-1;
	}
	cout << sol(0,0) << endl;
	return 0;
}



Measured memory_bytes: 7036
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
const int INF = 100010;

int main(){
    ll a,b; cin >> a >> b;
    if(a==b){
        cout << a << endl;
        return 0;
    }
    ll ans=0;
    if(a%2==0){
        if(b%2==0){
            if((b-a)/2 % 2 == 1) ans^=1;
            ans^=b;
        }
        else{
            if((b-a+1)/2 % 2 == 1) ans^=1;
        }
    }
    else{
        if(b%2==0){
            if((b-a-1)/2 % 2 == 1) ans^=1;
            ans^=a; ans^=b;
        }
        else{
            if((b-a)/2 % 2 == 1) ans^=1;
            ans^=a;
        }
    }
    cout << ans << endl;
}



Measured memory_bytes: 256
n, m = map(int, input().split())
#生徒とチェックポイントの定義
student = [[0 for i in range(3)] for j in range(n)]
check_point = [[0 for i in range(2)] for j in range(m)]
#入力
for i in range(n):
  student[i][0], student[i][1] = map(int, input().split())
for i in range(m):
  check_point[i][0], check_point[i][1] = map(int, input().split())
#動作
for i in range(n):
  minlen = 400000001  #今までで一番近い距離
  for j in range(m):
    length = abs(student[i][0] - check_point[j][0]) + abs(student[i][1] - check_point[j][1])
    if length < minlen:
      minlen = length
      student[i][2] = j + 1
  #出力
  print(student[i][2])


Measured memory_bytes: 3064
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

def sousa(n, k):
    while n >= k:
        if n % k == 0:
            n = n // k
        else:
            n = n % k
    return n

N = int(input())
cnt = 0

if N == 2:
    print(1)
    exit()

divisors = make_divisors(N)
for i in divisors:
    if i == 1: continue
    if sousa(N, i) == 1:
        cnt += 1

lst = factorization(N-1)
tuika = 1
for i in range(len(lst)):
    tuika *= lst[i][1]+1
# cnt += len(make_divisors(N-1))-1
cnt += tuika-1
print(cnt)

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

const int nxx=1e5+5;
int arr[nxx],dp[nxx];
int n;

int main(){
	cin>>n;
	int k;
	cin>>k;
	for(int i=1;i<=n;i++){
		cin>>arr[i];
	}
	memset(dp,-1,sizeof(dp));
	int min1=1e6+5;
	dp[1]=0;
	dp[2]=abs(arr[2]-arr[1]);
	int c=0;
	for(int i=3;i<=n;i++){
	    if(i<=k){
	        min1=1e10+5;
	        for(int j=1;j<i;j++){
	            min1=min(dp[i-j]+abs(arr[i-j]-arr[i]),min1);   
	        }
	        dp[i]=min1;
	    }
	    else{
	        min1=1e10+5;
	        for(int j=1;j<=k&&i-j>=1;j++){
	            min1=min(dp[i-j]+abs(arr[i-j]-arr[i]),min1);
	        }
	        dp[i]=min1;
	    }
	    
	}
    
	cout<<dp[n];
	return 0;
}

Measured memory_bytes: 4360
a, b = map(int, input().split())

if a > 0 and b > 0:
    print("Positive")

elif (a >= 0 and b <= 0) or (a <= 0 and b >= 0):
    print("Zero")

else:
    abs_ab = abs(a-b)
    
    if abs_ab % 2 == 0:
        print("Negative")
    else:
        print("Positive")

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;
bool cmp(int a,int b)
{
	return a>b;
}
int main()
{
	long long n,h;
	cin>>n>>h;
	long long maxv=-1,x;
	long long a[n+5];
	memset(a,0,sizeof(a));
	for(int i=1;i<=n;i++)
	{
		cin>>x>>a[i];
		if(x>maxv)
		maxv=x;
	}
	sort(a+1,a+n+1,cmp);
	int times=0;
	int j=0;
	while(1)
	{
		j++;
		if(a[j]>maxv&&h>0&&j<=n)
		{
			h-=a[j];
			times++;
		}
		else
			break;
	}
	while(h>0)
	{
		h-=maxv;
		times++;
	}
	cout<<times<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include <functional>
#include<time.h>
#include <stack>
#include<iomanip>
using namespace std;
#define rep(i,a,n) for(int i=(a);i<(n);i++)
#define ll long long
#define llint long long int
#define reverse(v)  reverse(v.begin(), v.end());
#define Yes(ans) if(ans)cout<<"Yes"<<endl; else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl; else cout<<"NO"<<endl;
#define hei(a) vector<a>
#define whei(a) vector<vector<a>>
#define UF  UnionFind
#define rt (a); return (a); 
#define Pint pair<int,int>
#define keta(a)  fixed << setprecision(a)
constexpr auto INF = 1000000000;
constexpr auto mod = 1000000007;
//辞書順はnext_permutation( begin( v ), end( v ) );やで！
llint gcd(llint a, llint b) {
	if (b > a)swap(a, b);
	if (a % b == 0)return b;
	return gcd(b, a % b);
}
llint Tow(int n) {//2のn乗
	if (n == 0)return 1;
	llint x = Tow(n / 2);
	x %= mod;
	x *= x;
	x %= mod;
	if (n % 2 == 1)x *= 10;
	x %= mod;
	return x;
}

int main(){
	int n;
	string s;
	cin >> n >> s;
	int r = 0, b = 0;
	rep(i, 0, n) {
		if (s[i] == 'R')r++;
		else b++;
	}
	Yes(r>b)
	return 0;
}

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

int main() {
  int n, m;
  cin >> n >> m;
 vector <int> b(n+1);
  for(int i=0;i<m;i++){
    int a;
    cin >> a;
    b[a] = 1;
  }
  vector<int> dp(n+2);
  
  const int mod = 1000000007;
  dp[n] = 1;
  for (int i = n-1; i >= 0; i--) {
    if (b[i]) {
      dp[i] = 0;
      continue;
    }
    dp[i] = (dp[i+1] + dp[i+2]) % mod;
  }
  
  cout << dp[0] << endl;
  return 0;
}    


Measured memory_bytes: 1024
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <iostream>
#include <vector>
#include <queue>
#include <unordered_map>
#include <random>
#include <stack>
#include <set>
#include <unordered_set>

#define bug(x) cout<<"zdongdebug1: "<<x<<endl;
#define bug2(x, y) cout<<"zdongdebug2: "<<x<<" "<<y<<endl;
#define bug3(x, y, z) cout<<"zdongdebug3: "<<x<<" "<<y<<" "<<z<<endl;
using namespace std;
typedef long long ll;
const int maxn = 200005;
const int mod = 1000000007;

int n;
int a[maxn];
vector<int>v;
vector<int>e[maxn];
stack<int>mx[maxn];
struct ST{
  int l,r,val;
}st[maxn*4];
void build(int id, int l, int r){
  st[id].l=l,st[id].r = r, st[id].val = 0;
  if(l==r)return;
  int m = (l+r)>>1;
  build(id<<1,l,m);
  build(id<<1|1,m+1,r);
}
void pd(int id){
  st[id].val = max(st[id<<1].val,st[id<<1|1].val);
}
void upd(int id, int pos, int val){
  if(st[id].l==st[id].r){
    st[id].val = val;
    return;
  }
  int m=(st[id].l+st[id].r)>>1;
  if(pos<=m)upd(id<<1,pos,val);
  else upd(id<<1|1,pos,val);
  pd(id);
}

int query(int id, int l, int r){
  if(st[id].l==l&&st[id].r==r){
    return st[id].val;
  }
  int m = (st[id].l+st[id].r)>>1;
  if(r<=m)return query(id<<1,l,r);
  else if(l>m)return query(id<<1|1,l,r);
  return max(query(id<<1,l,m),query(id<<1|1,m+1,r));
}

int f[maxn];

void dfs(int x, int fa){
  if(a[x]==1)f[x] = 1;
  else f[x] = query(1, 1, a[x]-1) + 1;
  int tt = mx[a[x]].size() ? max(mx[a[x]].top(), f[x]): f[x];
  mx[a[x]].push(tt);
  upd(1,a[x],tt);
  f[x] = query(1, 1, v.size());
  for(int i=0;i<e[x].size();i++){
    int vv = e[x][i];
    if(vv==fa)continue;
    dfs(vv, x);
  }
  mx[a[x]].pop();
  tt = mx[a[x]].size() ? mx[a[x]].top() : 0;
  upd(1, a[x], tt);
}

int main() {
#ifdef suiyuan2009
  freopen("/Users/suiyuan2009/CLionProjects/icpc/input.txt", "r", stdin);
  //freopen("/Users/suiyuan2009/CLionProjects/icpc/output.txt", "w", stdout);
#endif
  cin>>n;
  for(int i=1;i<=n;i++){
    cin>>a[i];
    v.push_back(a[i]);
  }
  sort(v.begin(),v.end());
  v.erase(unique(v.begin(),v.end()),v.end());
  for(int i=1;i<=n;i++){
    a[i] = lower_bound(v.begin(),v.end(),a[i])-v.begin()+1;
  }
  int m = v.size();
  for(int i=1;i<n;i++){
    int x,y;
    cin>>x>>y;
    e[x].push_back(y);
    e[y].push_back(x);
  }
  build(1,1,m);
  dfs(1,0);
  for(int i=1;i<=n;i++)cout<<f[i]<<endl;
  return 0;
}

Measured memory_bytes: 166428
H,N=map(int,input().split())
a=[]
max_x=-10**10
for i in range(N):
  x,y=map(int,input().split())
  if x>max_x:
    max_x=x
  a.append([x,y])
  
dp = [0] * (H+max_x)
for i in range(0,H+max_x):
    if i==0:
        dp[i]=0
    else:
        dp[i]=min(dp[i-l[0]]+l[1] for l in a )
print(dp[H])



Measured memory_bytes: 3572
#include <cstdio>
#include <iostream>
#include <cmath>
#include <set>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
using namespace std;
typedef long long ll;
const int N=400000+10;
int dp[N][2],n,k,c;
string s;
int main()
{
    //freopen("a.in","r",stdin);
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>n>>k>>c;
    c++;
    cin>>s;
    s=" "+s;
    int last=-c;
    for(int i=1;i<=n;i++){
    	if(s[i]=='o'){
    		if(i>=last+c){
    			dp[i][0]=dp[i-1][0]+1;
    			last=i;
    		}
    		else dp[i][0]=dp[i-1][0];
    	}
    	else dp[i][0]=dp[i-1][0];
    }
    last=n+c;
    for(int i=n;i>=1;i--){
    	if(s[i]=='o'){
    		if(i<=last-c){
    			dp[i][1]=dp[i+1][1]+1;
    			last=i;
    		}
    		else dp[i][1]=dp[i+1][1];
    	}
    	else dp[i][1]=dp[i+1][1];
    }
    vector<int> ans;
    for(int i=1;i<=n;i++){
    	if(dp[i-1][0]+dp[i+1][1]<k&&s[i]=='o')ans.push_back(i);
    	//cout<<dp[i][0]<<" "<<dp[i][1]<<"\n";
    }
    for(int i=0;i<ans.size();i++)cout<<ans[i]<<"\n";
    return 0;
}


Measured memory_bytes: 4556
#include <iostream>
#include <string>
using namespace std;
int main()
{
    string S;
    int N, K;
    cin >> N >> S >> K;
    for (int i = 0; i < N; i++)
    {
        if (S[i] == S[K - 1])
        {
            cout << S[i];
        }
        else
        {
            cout << "*";
        }
    }
}

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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
ll mm=1000000000;ll MM=mm+7;
#define rep(i, n) for(int i=0;i<n;i++)

int main(){
 ll a,b,n;
  cin >> a >> b >> n;
  ll ans;
  if(n>=b){
    ans=a*(b-1)/b;
  }
  else ans=a*n/b;
  cout << ans << endl;
}
 

Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
#define     ll              long long
#define     MAX             100000
#define     FI              freopen("input.txt","r",stdin)
#define     FO              freopen("output.txt","w",stdout)
#define     fast            ios_base::sync_with_stdio(false);cin.tie();cout.tie();
#define     sc(a)           scanf("%d",&a)
#define     sc2(a,b)        scanf("%d %d",&a,&b)


int main()
{
    string s;
    cin>>s;
    int in = s.size()-1;
    if(s[in]=='2' || s[in]=='4' || s[in]=='5' || s[in]=='7' || s[in]=='9')
        cout<<"hon\n";
    else if(s[in]=='0' || s[in]=='1' || s[in]=='6' || s[in]=='8')
        cout<<"pon\n";
    else if(s[in]=='3')
        cout<<"bon\n";
    return 0;
}



Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define SORT(i) sort((i).begin(),(i).end())
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 2000000000;
constexpr ll mod = 1000000007;

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

int main() {

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

	int N; cin >> N;
	vector<int>a(N);
	rep(i, N)cin >> a[i];
	int cnt = 1, ans = 0;
	rep(i, N) {
		if (a[i] != cnt) {
			++ans;
		}
		else {
			++cnt;
		}
	}
	if (ans == N) {
		cout << -1 << "\n";
	}
	else cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 1024
#import pysnooper
#import numpy
#import os,re,sys,operator
#from collections import Counter,deque
#from operator import itemgetter,mul
#from itertools import accumulate#,combinations,groupby,combinations_with_replacement,permutations
from sys import stdin,setrecursionlimit
#from bisect import bisect_left,bisect_right
#from copy import deepcopy
#import heapq
#import math
#import string
#from time import time
#from functools import lru_cache,reduce
#from math import factorial
#import sys

setrecursionlimit(10**6)
input=stdin.readline

s=input().rstrip()
l,r=0,len(s)-1
ans=0
while l<r:
    if s[l]!=s[r]: ans+=1
    l+=1
    r-=1
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <cstring>

using namespace std;

int arr[4][13], rank[9], card[5], cnt[13];
string str[5];

int getMark(char ch){
  if(ch == 'S'){
    return 0;
  }else if(ch == 'C'){
    return 1;
  }else if(ch == 'H'){
    return 2;
  }
  return 3;
}

int getNum(char ch){
  if('2' <= ch && ch <= '9'){
    return (ch-'0')-1;
  }else if(ch == 'A'){
    return 0;
  }else if(ch == 'T'){
    return 9;
  }else if(ch == 'J'){
    return 10;
  }else if(ch == 'Q'){
    return 11;
  }
  return 12;
}

int judge(){
  bool same_mark = true;
  char ch = str[0][1];
  for(int i = 1 ; i < 5 ; i++){
    if(ch != str[i][1]){
      same_mark = false;
      break;
    }
  }

  if(same_mark){
    if(card[0] == 1 && card[1] == 10 && card[2] == 11 &&
       card[3] == 12 && card[4] == 13){
      return rank[8];
    }else{
      bool check = true;
      for(int i = 1 ; i < 5 ; i++){
        if(card[i] - card[i-1] != 1){
          check = false;
          break;
        }
      }
      if(check){
        return rank[7];
      }else{
        return rank[4];
      }
    }
  }

  sort(cnt, cnt+13, greater<int>());
  if(cnt[0] == 4){
    return rank[6];
  }else if(cnt[0] == 3){
    if(cnt[1] == 2){
      return rank[5];
    }else{
      return rank[2];
    }
  }else if(cnt[0] == 2){
    if(cnt[1] == 2){
      return rank[1];
    }else{
      return rank[0];
    } 
  }else{
    bool check = true;
    for(int i = 1 ; i < 5 ; i++){
      if(card[i] - card[i-1] != 1){
        check = false;
        break;
      }
    }
    if(check){
      return rank[3];
    }
    if(card[0] == 1 && card[1] == 10 && card[2] == 11 &&
       card[3] == 12 && card[4] == 13){
      return rank[3];
    }
  }

  return 0;
}

int main(){
  int N;
  bool space = false;

  while(cin >> N){
    if(space){
      cout << endl;
    }else{
      space = true;
    }

    for(int i = 0 ; i < 4 ; i++){
      for(int j = 0 ; j < 13 ; j++){
        cin >> arr[i][j];
      }
    }
    for(int i = 0 ; i < 9 ; i++){
      cin >> rank[i];
    }

    while(N--){
      int point = 0, m,n;
      memset(cnt, 0, sizeof(cnt));
      for(int i = 0 ; i < 5 ; i++){
        cin >> str[i];
        m = getMark(str[i][1]);
        n = getNum(str[i][0]);
        point += arr[m][n];
        card[i] = n+1;
        cnt[n]++;
      }
      sort(card, card+5);
      cout << point*judge() << endl;
    }
  }

  return 0;
}

Measured memory_bytes: 1220
#include <algorithm>  
#include <iostream>  
#include <sstream>  
#include <string>  
#include <cstring>
#include <vector>  
#include <queue>  
#include <set>  
#include <map>  
#include <cstdio>  
#include <cstdlib>  
#include <cctype>  
#include <cmath>  
#include <list>  
#include <cassert>
#include <ctime>
#include <climits>
using namespace std;  

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }

const int MAXLEN=100000;

char s[MAXLEN+1]; int n,K;

void run() {
	scanf("%s%d",s,&K); n=strlen(s);
	int rem=K;
	REP(i,n) {
		int need=s[i]=='a'?0:'z'-s[i]+1;
		if(rem>=need) { s[i]='a'; rem-=need; }
		if(i==n-1) s[i]=(s[i]-'a'+rem)%26+'a';
	}
	printf("%s\n",s);
}

int main() {
	run();
	return 0;
}


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

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
                int a=sc.nextInt();
                int b=sc.nextInt();
                int c=sc.nextInt();
                int d=sc.nextInt();
                int e=sc.nextInt();
                int f=sc.nextInt();
                int g=sc.nextInt();
                int h=sc.nextInt();
                int ten=a+b+c+d;
                int tenten=e+f+g+h;
                if (ten<tenten){
                    System.out.println(tenten);
                }else if (ten>tenten){
                    System.out.println(ten);
                }if (ten==tenten){
                    System.out.println(ten);
                }
            }

        }

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

int f(int c, int N) {
  int t = N - c;
  int a = 1;
  int num = 0;
  while (a*a <= t) {
    if (t % a == 0) {
      int b = int(t / a);
      if (a == b) {
        num += 1;
      } else {
        num += 2;
      }
    }
    a += 1;
  }
  return num;
}

int main() {
  int N;
  cin >> N;
  int ans = 0;
  for (int c = 1; c <= N; c++) {
    ans += f(c, N);
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3628
# DDCC C
si = lambda: input()
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))
h,w,k = nm()
C = []
itigo = []
itigo_sum = []
is_copy = []
ans = [[] for i in range(h)]
for i in range(h):
    C.append(si())
s = 0
for c in C:
    ii = c.count('#')
    s += ii
    itigo.append(ii)
    itigo_sum.append(s)

itigo_cnt = 0
cnt = 1

for i in range(h):
    itigo_cnt = 1
    if i>=1:
        itigo_cnt += itigo_sum[i-1]
    if itigo[i]==0:
        continue
    else:
        cnt = itigo_cnt
        for j in range(w):
            ans[i].append(cnt)
            if C[i][j:j+1]=='#':
                if itigo_sum[i]>cnt:
                    cnt += 1
idx = 0
for i,aa in enumerate(ans):
    if aa:
        idx = i
        if is_copy:
            for j in range(len(is_copy)):
                t = is_copy.pop()
                for k in range(w):
                    ans[t].append(ans[i][k])
    else:
        is_copy.append(i)
    
    if i==len(ans)-1:
        for j in range(len(is_copy)):
            t = is_copy.pop()
            for k in range(w):
                ans[t].append(ans[idx][k])

for aa in ans:
    print(*aa)



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

int main (void){
    string n;
    cin >> n;
    if (n[0] == '7' || n[1] == '7' || n[2] == '7') {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3608
#include <cstdio>
#include <cstring>
#include <cctype>
#include <algorithm>
using namespace std;
#define N 2010
#define mod 1000000007
#define foru(i,l,r) for (int i=l; i<=r; i++)
#define ford(i,r,l) for (int i=r; i>=l; i--)
#define read(x) ((x)=getint())
#define inc(a,b) (((a)+=(b))%=mod)
#define mul(a,b) (LL(a)*(b)%mod)
typedef long long LL;

int n,k,fac[N*N],inv[N*N],f[N][N];

int getint()
{
	int x,f=1; char ch;
	while (!isdigit(ch=getchar())) f=ch=='-'?-1:1;
	x=ch-'0';
	while (isdigit(ch=getchar())) x=x*10+ch-'0';
	return f*x;
}
int C(int n, int m)
{
	if (n<0||n<m) return 0;
	return mul(mul(fac[n],inv[m]),inv[n-m]);
}
int main()
{
	read(n), read(k);
	if (k==1) return puts("1"), 0;
	fac[0]=inv[0]=fac[1]=inv[1]=1;
	foru(i,2,n*k) fac[i]=mul(fac[i-1],i);
	foru(i,2,n*k) inv[i]=mul(mod-mod/i,inv[mod%i]);
	foru(i,2,n*k) inv[i]=mul(inv[i],inv[i-1]);
	f[0][0]=1;
	foru(i,1,n)
		ford(j,i,0)
		{
			inc(f[i][j],f[i][j+1]);
			if (j) inc(f[i][j],mul(C(i*k-j-1,k-2),f[i-1][j-1]));
		}
	printf("%lld\n",mul(f[n][0],fac[n]));
	return 0;
}

Measured memory_bytes: 46464
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define Rep(i,s,n) for(int i=s;i<n;i++)
#define fi first
#define se second
#define all(c) c.begin(),c.end()
typedef long long int ll;
typedef pair<int, int> P;
typedef long double ld;
void Ans(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}

const ll INF=1001001001;
const ll mod=1000000007;

int main(){
  string s;
  cin>>s;
  if(s=="SUN") cout<<7<<endl;
  if(s=="MON") cout<<6<<endl;
  if(s=="TUE") cout<<5<<endl;
  if(s=="WED") cout<<4<<endl;
  if(s=="THU") cout<<3<<endl;
  if(s=="FRI") cout<<2<<endl;
  if(s=="SAT") cout<<1<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <string>
#include<limits>
#include<cstdlib>
#include<functional>
#include<cassert>
using namespace std;

	int main()
	{
		int A,B,C;
		int sum = 0;
		

		cin >> A >>B >>C;

		for (int i = 0; i <= C - 1; i++) {
			B -= A;
			if (B < 0) { break; }
			sum++;
		}

		cout << sum << endl;

		return 0;
	}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define N 100000
#define inf 1e9
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
int n;
vvi iv(N,vi(3,0));

int calculation(int e){
    vvi mark(N,vi(3,0));
    vvi table(N,vi(3,0));
    table[e][0] = iv[e][0]; table[e][1] = iv[e][1]; table[e][2] = iv[e][2];
    mark[e][0] = -1; mark[e][1] = -1; mark[e][2] = -1;
    for (int i = e-1; i >= 0; i--){
        for (int s = 0; s < 3; s ++){
            int a = (s+1)%3;
            int b = (s+2)%3;
            table[i][s] = (iv[i][s] + table[i+1][a] > iv[i][s] + table[i+1][b])? iv[i][s] + table[i+1][a] : iv[i][s] + table[i+1][b];
            mark[i][s] = (iv[i][s] + table[i+1][a] > iv[i][s] + table[i+1][b])? a : b;
        }
    }
    return max(table[0][0],max(table[0][1],table[0][2]));
}

int main(){
    cin >> n;
    for (int i = 0; i < n; i ++){
        cin >> iv[i][0] >> iv[i][1] >> iv[i][2];
    }
    cout << calculation(n-1);
}


Measured memory_bytes: 16640
#include<iostream>
#include<algorithm>

using namespace std;

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

int main(){
	int a, b;
	cin >> a >> b;
	int mul, sm, dif;
	mul = a * b;
	sm = a + b;
	dif = a - b;
	int ans;
	ans = max(mul, max(sm, dif));
	cout << ans << endl;
}

Measured memory_bytes: 256
use std::collections::HashSet;
use whiteread::parse_line;

fn main() {
    let mut s: i32 = parse_line().unwrap();
    let mut a: HashSet<i32> = HashSet::new();

    a.insert(s);
    loop {
        if s % 2 == 0 {
            s /= 2;
        } else {
            s = s * 3 + 1;
        }
        if !a.insert(s) {
            break;
        }
    }
    println!("{}", a.len() + 1);
}


Measured memory_bytes: 2204