akhauriyash/Code-Regression huggingface dataset:
import java.io.*;
import java.util.*;
class Main{
	static final long MOD = 1_000_000_007; // 10^9+7
    static final int MAX = 2_147_483_646; // intMax 
    static final int INF = 1_000_000_000; // 10^9  
    public static void main(String[] args) throws Exception {
		hayami saori = new hayami();
		int n = saori.saori_hayami();
		if(n%2 == 0){
			System.out.println(n);
		} else {
			System.out.println(2*n);
		}
		saori.close();
    }
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}

Measured memory_bytes: 21076
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
using namespace std;
int main() {
	int n;
	while (cin >> n&&n != 0) {
		int a[100];
		for (int i = 0; i < n; i++) cin >> a[i];
		string s, h = "";
		cin >> s;
		int k = 0;
		for (int i = 0; i < s.length(); i++) {
			char e = s[i];
			for (int j = 0; j < a[k]; j++) {
				if (e == 'a') e = 'Z';
				else if (e == 'A') e = 'z';
				else e--;
			}
			h += e;
			k++;
			if (k == n) k = 0;
		}
		cout << h << endl;
		h = "";
	}
}

Measured memory_bytes: 3216
N,Y = (map(int,input().split()))

for i in range(N+1):
    for j in range(N-i+1):
        k = N-j-i
        if i * 1000 + j * 5000 + 10000 * k == Y:
            print(k,j,i)
            exit()

print(-1,-1,-1)

Measured memory_bytes: 3064
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

int64_t a[100'001];
int64_t b[100'000];

int main()
{
    int n;
    cin >> n;
    for (int i = 0; i <= n; i++)
    {
        cin >> a[i];
    }
    for (int i = 0; i < n; i++)
    {
        cin >> b[i];
    }

    int64_t result = 0;
    for (int i = 0; i < n; i++)
    {
        int64_t beaten = min(a[i], b[i]);
        int64_t res = b[i] - beaten;
        int64_t beaten2 = min(a[i + 1], res);
        a[i + 1] -= beaten2;
        result += beaten + beaten2;
    }

    cout << result << endl;
    return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define f(i,a,n) for(int i=a;i<n;i++)
#define ve vector
#define ss second 
#define ff first
#define pf pop_front
#define pob pop_back
#define psf push_front
#define res(x) cout<<x<<'\n'
#define read(t) ll t;cin>>t

int main(){

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	cout.tie(NULL);
    read(n);
    ll a[n];
    ll sum=0;
     f(i,0,n){
         cin>>a[i];
         sum=sum+a[i];
     }
     sum=sum/n;
     ll mean;
     sort(a,a+n);
     if(n%2==0){
         mean=(a[n/2]+a[(n/2)-1])/2;
     }
     else{
         mean=a[n/2];
     }
    ll ans=0;
    ll ans2=0;
     f(i,0,n){
       ans+=pow(sum-a[i],2);
       ans2+=pow(sum+1-a[i],2);
     }


     cout<<min(ans,ans2)<<endl;
     }

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<climits>
#include<vector>
#include <sstream>

using namespace std;

int main(void) {

	int n, sum;
	cin >> n;

	string in;
	vector<int> a(n+1);

	getline(cin, in, ' ');
	a[0] = stoi(in);
	

	for (int i = 1;i < n;++i) {
		getline(cin, in, ' ');
		a[i] = stoi(in);
	}
	a[n]=0;
  	
  	sum = abs(a[0]);
	for (int i = n;i > 0;--i) {
		a[i] -= a[i - 1];
		sum += abs(a[i]);
	}
	cout << sum - abs(a[0]) - abs(a[1]) + abs(a[0] + a[1]) << endl;
	for (int i = 1;i < n;++i) {
		cout << sum - abs(a[i]) - abs(a[i+1]) + abs(a[i] + a[i + 1]) << endl;
	}

	return 0;
}

Measured memory_bytes: 1664
#include <stdio.h>

int main(){

    int a;
    int b;
    int N;

    scanf("%d", &a);
    scanf("%d", &b);
    scanf("%d", &N);

    if(a * b>=N){
        printf("%d", N);
    }
    if(N > a * b){
        printf("%d\n", a*b);
    }

    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
	long long n;
	scanf("%lld",&n);
	map<string,long long>s;
	getchar();
	for(long long j=0;j<n;j++){
		char ss[10];
		for(long long i=0;i<10;i++){
			ss[i]=getchar();
		}
		getchar();
		sort(ss,ss+10);
		string l;
		for(long long i=0;i<10;i++){
			l+=ss[i];
		}
		s[l]++;
	}
	long long sum=0;
	map<string,long long>::iterator it;
	for(it=s.begin();it!=s.end();it++){
		if(it->second>1){
			for(long long i=1;i<it->second;i++){
				sum+=i;
			}
		}
	}
	printf("%lld",sum);
	return 0;
}

Measured memory_bytes: 12800
d,g=map(int,input().split())
p=[0]
c=[0]
p_num=0
for i in range(d):
    P,C=map(int,input().split())
    p_num+=P
    p.append(P)
    c.append(C)
dp=[0]*(p_num+1)
for j in range(1,d+1):
    for k in range(1,p[j]+1):
        if k==1:
            t_dp=dp[:]
            
        if k==p[j]:
            cc=100*j*k+c[j]
        else:
            cc=100*j*k
            
        for l in range(1,p_num+1):
            if l>=k:
                dp[l]=max(dp[l],t_dp[l-k]+cc)                
for i in range(p_num+1):
    if dp[i]>=g:
        print(i)
        break
                        
                
        

Measured memory_bytes: 3064
class SegmentTree:
    def __init__(self, a: list, e: 'default', f: 'function'):
        n = len(a)
        size = 1 << (n - 1).bit_length()  # 元の配列サイズ以上の最小の二冪 == 最下段
        v = [e] * (size * 2 - 1)
        for i in range(n):
            # size-1個の上段の次、size個目からn個が元の配列の代入位置
            v[size - 1 + i] = a[i]
        for i in range(size - 2, -1, -1):
            v[i] = f(v[i * 2 + 1], v[i * 2 + 2])

        self.n = n  # 元の配列の長さ
        self.size = size  # 元の配列サイズ以上の最小の二冪 == 最下段の要素数
        self.v = v  # Segtreeの配列
        self.e = e  # 初期値
        self.f = f  # 比較関数

    def update(self, k: 'index', x: 'val'):
        k += self.size - 1  # 最下段のindexに変更する
        self.v[k] = x  # 値を更新する
        while k > 0:
            k = (k - 1) // 2  # 親のindex
            self.v[k] = self.f(self.v[k * 2 + 1], self.v[k * 2 + 2])

    def get(self, a, b, k=0, l=0, r=-1):
        # [a,b)区間の処理結果を返す
        # 注目区間[l,r)
        if r < 0:
            r = self.size

        if r <= a or b <= l:
            return self.e
        # 区間が重ならない

        if a <= l and r <= b:
            return self.v[k]
        # 完全被覆

        m = (l + r) // 2
        vl = self.get(a, b, k * 2 + 1, l, m)
        vr = self.get(a, b, k * 2 + 2, m, r)
        return self.f(vl, vr)
        # 部分被覆


def solve(n, h, a):
    seg = SegmentTree([0] * (n + 1), 0, max)
    for i in range(n):
        tmp = seg.get(0, h[i])
        seg.update(h[i], tmp + a[i])
        # 1回あたり更新するのは1箇所だから、iを状態にもつ必要はなくて、配列を使い回すことができる
        # 区間maxが高速に計算できればいいから、セグメント木を使えばできる
    return seg.get(0, n + 1)


if __name__ == '__main__':
    n = int(input())
    h = tuple(map(int, input().split()))
    a = tuple(map(int, input().split()))
    print(solve(n, h, a))

# https://kyopro-friends.hatenablog.com/entry/2019/01/12/231035


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

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

  int n;
  string s;
  cin >> n >> s;
  for (int i = 0; i < s.size(); i++) {
    int ord = s[i] - 'A';
    ord += n;
    ord %= 26;
    s[i] = (char)('A' + ord);
  }
  cout << s << '\n';
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,N) for (int i = 0; i < (N); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int inf{int(1e9)};
int main(void){
  int n;
  cin >> n;
  vector <int> v(n);
  rep(i,n) cin >> v[i];

  //一次元配列で実装する
  //値iの回数をa[i]に入れる
  vector <int> a(100100);
  vector <int> b(100100);
  rep(i,n){
    if (i % 2 == 0) a[v[i]] ++;
    else b[v[i]] ++;
  }

  int max_a, max_b;  //最大値のindex
  max_a = max_element(a.begin(), a.end()) - a.begin();
  max_b = max_element(b.begin(), b.end()) - b.begin();

  //aでの最頻値とbでの最頻値が異なる場合
  if (max_a != max_b) cout << n - a[max_a] - b[max_b] << endl;
  //aでの最頻値とbでの最頻値が同じ場合
  //降順にソートする
  else{
  sort(a.rbegin(), a.rend());
  sort(b.rbegin(), b.rend());
  //aの最頻値を残す場合の答え
  int ans_a = n - a[0] - b[1];
  //bの最頻値を残す場合の答え
  int ans_b = n - a[1] - b[0];
  cout << min(ans_a, ans_b) << endl;
  }
  return 0;
}


Measured memory_bytes: 4572
#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]
 
sys.setrecursionlimit(1000000)
mod = 1000000007
 
def solve():
    s = list(input())
    t = list(input())
    x = len(s)
    y = len(t)
    ans = "Yes"
    for i in range(x):
      if (s[i] == t[i]) and (x+1 == y):
        ans = "Yes"
        continue
      else:
        ans = "No"
        break
    print(ans)    
      
    return
 
#Solve
if __name__ == "__main__":
    solve()

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

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
#define x first
#define y second

#ifdef LOCAL
#include "debug.h"
#endif

const int N = 2010;

int n;
ll dp[3 * N][N];
int MOD;

ll DP(int n, int rem) {
	if (dp[n][rem] >= 0) return dp[n][rem];
	if (n == 0) return dp[n][rem] = 1;

	ll ret = 0;
	if (n >= 1) (ret += DP(n - 1, rem)) %= MOD;
	if (rem >= 1) {
		if (n >= 2) (ret += DP(n - 2, rem - 1) * (n - 1)) %= MOD;
		if (n >= 3) (ret += DP(n - 3, rem - 1) * (n - 1) * (n - 2)) %= MOD;
	}
	return dp[n][rem] = ret;
}

int main() {
	#ifdef LOCAL
	freopen("in", "r", stdin);
	freopen("out", "w", stdout);
	#endif

	cin >> n >> MOD;
	memset(dp, -1, sizeof dp);
	cout << DP(3 * n, n) << endl;

	return 0;
}

Measured memory_bytes: 95360
import java.util.*;
import java.math.*;
import java.lang.*;
import java.io.*;

public class Main{
  public static void main(String args[]) throws IOException{
    Scanner s=new Scanner(System.in);
    int n=s.nextInt();
    
    String ss=s.next();
    int c=1;
    for(int i=0;i<n-1;i++)
    {
      if(ss.charAt(i)!=ss.charAt(i+1))
        c++;
    }
   
    System.out.println(c);
  }
}

Measured memory_bytes: 24340
#include "bits/stdc++.h"

using namespace std;
using ll = long long;
using ull = unsigned long long;

typedef pair< long long, long long > P;
typedef pair< long long, P > PP;
typedef pair< P, P > PPP;

const double DINF = 5e14, eps = 1e-10;
const long long MOD = 1e9 + 7, INF = 5e18;
const int di[4] = { 1,0,-1,0 }, dj[4] = { 0,1,0,-1 };

#define fr first
#define sc second
#define pb push_back
#define eb emplace_back
#define ALL(x) (x).begin(),(x).end()

ll n, a[100010], l, r, ans, L, R, sum;
bool fl = 0;

int main() {
	cin >> n;
	for (int i = 0;i < n;i++)cin >> a[i];
	sort(a, a + n);
	if (n == 2) {
		cout << abs(a[1] - a[0]) << endl;
		return 0;
	}
	ans += abs(a[n - 1] - a[0]) + abs(a[n - 2] - a[0]);
	l = min(a[n - 2], a[n - 1]), r = max(a[n - 1], a[n - 2]);
	L = 1, R = n - 3;
	fl = 0;
	while (true) {
		if (L > R)break;
		if (fl) {
			ans += abs(l - a[R]);
			l = a[R], R--;
			if (L > R)break;
			ans += abs(r - a[R]);
			r = a[R], R--;
			if (L > R)break;
			fl = 0;
		}
		else {
			ans += abs(l - a[L]);
			l = a[L], L++;
			if (L > R)break;
			ans += abs(r - a[L]);
			r = a[L], L++;
			if (L > R)break;
			fl = 1;
		}
	}

	sum += abs(a[n - 1] - a[0]) + abs(a[n - 1] - a[1]);
	l = min(a[0], a[1]), r = max(a[0], a[1]);
	L = 2, R = n - 2;
	fl = 1;
	while (true) {
		if (L > R)break;
		if (fl) {
		    sum += abs(l - a[R]);
			l = a[R], R--;
			if (L > R)break;
			sum += abs(r - a[R]);
			r = a[R], R--;
			if (L > R)break;
			fl = 0;
		}
		else {
			sum += abs(l - a[L]);
			l = a[L], L++;
			if (L > R)break;
			sum += abs(r - a[L]);
			r = a[L], L++;
			if (L > R)break;
			fl = 1;
		}
	}
	cout << max(ans,sum) << endl;
	return 0;
}


Measured memory_bytes: 1024
S = list(input())
N = len(S)

marker = [0] * N
for i in range(1, N - 1):
    if S[i] == "R" and S[i + 1] == "L":
        marker[i] = 1
    elif S[i - 1] == "R" and S[i] == "L":
        marker[i] = 2
    else:
        marker[i] = 0
marker[0] = 1 if S[1] == "L" else 0
marker[-1] = 2 if S[-2] == "R" else 0

cp = list(range(N))
p_last = [-1] * N   # ループに入る最初の座標
steps = [0] * N     # p_lastに着くまでのステップ数
dests = [0] * N     # 1: p_lastがR; 2: L
for i in range(N):
    s = 0
    cp = i
    hist = []   # 訪れた座標
    hist_append = hist.append
    while True:
        if p_last[cp] >= 0:
            p_last[i] = p_last[cp]
            steps[i] = s + steps[cp]
            dests[i] = marker[p_last[cp]]
            break
        elif marker[cp] == 0:
            s += 1
            if S[cp] == "R":
                cp += 1
            else:
                cp -= 1
            hist_append(cp)
        else:
            p_last[i] = cp
            steps[i] = s
            dests[i] = marker[cp]
            break

    for j, h in enumerate(hist[::-1], 1):
        p_last[h] = p_last[i]
        steps[h] = steps[i] - j
        dests[h] = dests[i]

count = [0] * N
for i in range(N):
    pl = p_last[i]
    if dests[i] == 1:
        if steps[i] % 2 == 0:
            count[pl] += 1
        else:
            count[pl + 1] += 1
    else:
        if steps[i] % 2 == 0:
            count[pl] += 1
        else:
            count[pl - 1] += 1
print(" ".join(str(c) for c in count))


Measured memory_bytes: 67960
// https://atcoder.jp/contests/jsc2019-qual/tasks/jsc2019_qual_f
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
#ifdef DEBUG
#define display(x) cerr << #x << " = " << x << endl;
#define displaya(a, st, n)\
	{cerr << #a << " = {";\
	for(int qwq = (st); qwq <= (n); ++qwq) {\
		if(qwq == (st)) cerr << a[qwq];\
		else cerr << ", " << a[qwq];\
	} cerr << "}" << endl;}
#define displayv(v) displaya(v, 0, (int)(v).size() - 1)
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define display(x) ;
#define displaya(a, st, n) ;
#define displayv(v) ;
#define eprintf(...) if(0) fprintf(stderr, "...")
#endif
template<typename T> bool chmin(T &a, const T &b) { return a > b ? a = b, true : false; }
template<typename T> bool chmax(T &a, const T &b) { return a < b ? a = b, true : false; }

const LL P = 1000000007;
const int maxN = 2 * 300000 + 5;
LL qpow(LL a, LL b) {
	LL r = 1;
	while(b) {
		if(b & 1) (r *= a) %= P;
		(a *= a) %= P; b >>= 1;
	}
	return r;
}
int m, n;
LL fac[maxN], ifac[maxN];

LL C(int n, int k) {
	if(k < 0 || k > n) return 0;
	return fac[n] * ifac[k] % P * ifac[n - k] % P;
}
LL D(int n, int k) {
	return C(n + k, k);
}

LL cnt(LL A, int n, int m, LL x) { // sum ai <= A, m of them <= x
	if(A < 0) return 0;
	LL ans = 0;
	for(int i = 0; i <= m; ++i) if(A - (x + 1) * i >= 0) {
		LL dans = D(A - (x + 1) * i, n) * C(m, i) % P;
		if(i & 1) ans -= dans; else ans += dans;
	} else {
		break;
	}
//	eprintf("cnt(%lld, %d, %d, %lld) = %lld\n", A, n, m, x, (ans % P + P) % P);
	return (ans % P + P) % P;
}

LL solve(LL A) {
	LL ans = 0;
	for(int x = 0; x <= A; ++x) if((LL)(n - m) * (x + 1) <= A) {
		ans += cnt(A - (LL)(x + 1) * (n - m), n, m, x);
		ans -= cnt(A - (LL)(x + 2) * (n - m), n, m, x);
	}
	return (ans % P + P) % P * C(n, m) % P;
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
#endif
	fac[0] = 1;
	for(int i = 1; i < maxN; ++i) fac[i] = fac[i - 1] * i % P;
	ifac[maxN - 1] = qpow(fac[maxN - 1], P - 2);
	for(int i = maxN - 2; i >= 0; --i) ifac[i] = ifac[i + 1] * (i + 1) % P;
	int L, R;
	cin >> n >> m >> L >> R;
	m = n - m;
	display(D(R, n) - D(L - 1, n));
	display(solve(R) - solve(L - 1));
	cout << ((D(R, n) - D(L - 1, n) - solve(R) + solve(L - 1) + P * 2) % P) << endl;
	return 0;
}


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

#define int long long
#define pb push_back
#define f first
#define s second
#define all(container) container.begin(),container.end()

#define fast ios::sync_with_stdio(0); cin.tie(0)

int32_t main(){
  
    fast;
    string s; cin >> s;

    int t1[s.size()];
    int t2[s.size()];

    for(int i=0;i<s.size();i++){
      t1[i] = s[i]-'0';
      t2[i] = s[i]-'0';
    }

    int c1 = 0 ,c2 = 0;

    if(t1[0]!=0){
      t1[0] = 0;
      c1++;
    }
    if(t2[0]!=1){
      t2[0] = 1;
      c2++;
    }

    for(int i=1;i<s.size();i++){
      if(t1[i]==t1[i-1]){
        c1++;
        t1[i] = !t1[i];
      }
      if(t2[i]==t2[i-1]){
        c2++;
        t2[i] = !t2[i];
      }
    }

    // cout << "c1 " << c1 << " " << c2 << '\n';
    cout << min(c1,c2);

    
    return 0;
} 

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

int main(void){
	int n,m;
	cin>>n>>m;
	int k[m],s[m][m],p[m];
	for(int i=0;i<m;i++){
		cin>>k[i];
		for(int j=0;j<k[i];j++){
			cin>>s[i][j];
		}
	}
	for(int i=0;i<m;i++)cin>>p[i];
	bool t[n];int res =0,tmp=0;;

	for (int i=0; i<2<<(n-1); i++) {
		memset(t,false,sizeof(t));
		for (int j=0; j<n; j++) {
			if ((1&i>>j) == 1){
				t[j]=true;
				//cout<<j;
			}
		}
		//cout<<endl;
		int cnt=0;tmp=0;
		for(int x=0;x<m;x++){
			cnt=0;
			if(p[x]==0){
				for(int y=0;y<k[x];y++){
					int w=s[x][y]-1;
					//cout<<w<<t[w]<<endl;
					if(t[w]==true)cnt++;
				}
				if(cnt%2==0)tmp++;
			}else{
				for(int y=0;y<k[x];y++){
					int w=s[x][y]-1;
					//cout<<w<<t[w]<<endl;
					if(t[w]==true)cnt++;
				}
				if(cnt%2==1)tmp++;
			}
		}
		if(tmp==m){
			//cout<<i<<endl;
			res++;
		}
	}
	cout<<res<<endl;
}


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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

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

using ll=long long;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

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

const pid_t pid = getpid();
// Problem Specific Parameter:

const int limit = 400010;
int n,m;
vector<int> graph[limit];
int ea[limit],eb[limit];
string s;

int visited[limit];

bool ok = false;
set<int> trace;

void dfs(int v){
	visited[v] = true;
	trace.insert(v);
	for(auto &v2:graph[v]){
		if(visited[v2] == true){
			if(trace.find(v2) != end(trace)){
				ok = true;
			}
		} else {
			dfs(v2);
		}
	}
	trace.erase(v);
	return;
}

int main(void){
	cin >> n >> m;
	cin >> s;

	s = s + s;

	rep(i,m){
		cin >> ea[i] >> eb[i];
		ea[i]--,eb[i]--;
		
		if(s[ea[i]] == 'A' and s[eb[i]] == 'A'){
			graph[ea[i] + n].push_back(eb[i]);
			graph[eb[i] + n].push_back(ea[i]);
		}

		if(s[ea[i]] == 'A' and s[eb[i]] == 'B'){
			graph[ea[i]].push_back(eb[i]);
			graph[eb[i] + n].push_back(ea[i] + n);
		}

		if(s[ea[i]] == 'B' and s[eb[i]] == 'A'){
			graph[ea[i] + n].push_back(eb[i] + n);
			graph[eb[i]].push_back(ea[i]);
		}

		if(s[ea[i]] == 'B' and s[eb[i]] == 'B'){
			graph[ea[i]].push_back(eb[i] + n);
			graph[eb[i]].push_back(ea[i] + n);
		}
	}


	rep(a,2*n) visited[a] = -1;
	
	rep(a,2*n){
		if(visited[a] == -1){
			dfs(a);
		}
	}

	cout << (ok?"Yes":"No") << endl;

	return 0;
}

Measured memory_bytes: 37616
function Main(inputData) {
    init(inputData);
    
    var a = inI();
    var b = inI();
    
    
    outln((a*b) - a - b + 1);
}

////////////////////////////////////////////////////////////////////////////////////
var input,inputCnt;

// "実行する"ボタンを押した時に実行される関数 (デバッグ用)
function debug(){
	Main(document.getElementById("input").value);
}

function init(inputData){
    //配列inputに順番に代入
	input = inputData.replace( /\n/g , " " );
	input = input.split(" ");
	inputCnt = 0;
}
//output
const out = (output) => { console.log(output) }
const outln = (output) => { console.log(output+"\n") }

//input
const inS = () => {return input[inputCnt++]};
const inI = () => {return parseInt(inS(), 10)};
const inF = () => {return parseFloat(inS())};

//prototype
Array.prototype.rsort = function(){
  return this.sort(function(a,b){return (a<b ? 1:-1);});
}

Array.prototype.max = function(){
  return Math.max.apply(null, this);
}

Array.prototype.min = function(){
  return Math.min.apply(null, this);
}

//function
function values(array) {
    var values = [];
    if(array)for(var key in array)values.push(array[key]);
    return values;
};

function keys(array) {
    var keys = [];
    if(array)for(var key in array)keys.push(key);
    return keys;
};

//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7372
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
    string s[]={"Sunny","Cloudy", "Rainy"};
    string s1;
    cin>>s1;
    if(s1==s[0])
    cout<<s[1];
    else if(s1==s[1])
    cout<<s[2];
    else
    {
        cout<<s[0];
    }
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long
#define double long double
double pi= 3.141592653589793238462643383279502884L;
const int N= 1e6+10;

double n,t,k,a,b,h,m;
string str;

int32_t main()
{
	IOS;
	cin>>a>>b>>h>>m;
	double a1= ((2*pi)/12)* h + (2*pi)/(12*60) *m;
	double b1= (2*pi)*(m/60);
	double diff= (a1-b1);

	double len= a*a+b*b-(2*a*b*cos(diff));
	cout<<fixed<<setprecision(12)<<sqrt(len)<<endl;
	return 0;
	
	
}

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

vector<int> children[100010];
priority_queue<int> query[100010];
int markedAt[100010];
using ll = long long;

ll pull(int v) {
    ll res = 0;
    for (int c : children[v]) {
        res += pull(c);
        if (query[v].size() < query[c].size()) {
            swap(query[v], query[c]);
        }
        while (query[c].size()) {
            query[v].push(query[c].top());
            query[c].pop();
        }
    }
    while (query[v].size() && query[v].top() > markedAt[v]) {
        res += v + 1;
        query[v].pop();
    }
    return res;
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n, q;
    while (cin >> n >> q && n) {
        fill(children, children + n, vector<int>());
        fill(markedAt, markedAt+n, 1e9);
        for (int i = 1; i < n; ++i) {
            int p;
            cin >> p;
            --p;
            children[p].push_back(i);
        }
        markedAt[0] = -1;
        for (int i = 0; i < q; i++) {
            char c;
            int v;
            cin >> c >> v;
            --v;
            if (c == 'Q') {
                query[v].push(i);
            } else {
                if (markedAt[v] == 1e9) {
                    markedAt[v] = i;
                }
            }
        }
        cout << pull(0) << endl;
    }
}

Measured memory_bytes: 24136
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <array>
#include <tuple>
#include <string>
#include <algorithm>
#include <functional> // greater など
#include <cmath>      // abs など
#include <numeric>    // accumulate など
#include <stdexcept>
#include <cassert> // assert
using namespace std;

// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
// typedef int128_t ll;
// typedef cpp_int ll;

// GCC, 配列のアクセスなど
#define _GLIBCXX_DEBUG
// Clang, 配列のアクセスなど
#define _LIBCPP_DEBUG 0

// #define NDEBUG 1
// debug用出力 https://trap.jp/post/998/
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T)
{
    cerr << H << " ";
    debug_out(T...);
}
#ifdef NDEBUG
#define debug(...)
#else
#define debug(...) debug_out(__VA_ARGS__)
#endif

//////////////// //////////////// //////////////// //////////////// ////////////////
//////////////// //////////////// //////////////// //////////////// ////////////////

// constexpr inline ll MOD = 1'000'000'007;

int main()
{
    // 入出力
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int res = 0;
    string s, t;
    cin >> s >> t;
    REP(i, s.size()) {
        if (s[i] != t[i])
            res++;
    }
    cout << res<<endl;

    return 0;
}


Measured memory_bytes: 3784
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <math.h>
using namespace std;

int A, B;

int main() {
	scanf("%*d%d%d", &A, &B);
	puts((A - B & 1) ? "Borys" : "Alice");
	return 0;
}

Measured memory_bytes: 128
// Facts.cpp
#include <iostream>
#include <vector>
using namespace std;

class Facts
{
public:
    long long mod = 1000000007;
    int n_max = 1;
    vector<long long int>  fact{1, 1};
    vector<long long int>  inv{1, 1};
    vector<long long int>  factinv{1, 1};

    Facts();
    Facts(int64_t mod);
    int64_t cmb(int n, int r);
    int64_t hom(int n, int r);
    void setup_table(int t);
};



Facts::Facts(int64_t m){
  mod = m;
}

int64_t Facts::cmb(int n, int r){
  if(r < 0 || n < r) return 0;
  if(n_max < n) setup_table(n);
  return fact[n] * (factinv[r] * factinv[n-r] % mod) % mod;
}

int64_t Facts::hom(int n, int r){
  return Facts::cmb(n+r-1, r);
}

void Facts::setup_table(int t){
  for(int i=n_max+1; i<=t; i++){
    fact.push_back( fact.back() * i % mod );
    inv.push_back( -inv[mod % i] * (mod / i) % mod );
    factinv.push_back( factinv.back() * inv.back() % mod );
  }
  n_max = t;
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

// a^{-1} mod を計算する
long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}

int main(){

  int64_t mod = 1000000007;

  int64_t n, k;
  cin >> n >> k;

  int64_t ans = 0;
  Facts f = Facts(mod);

  for(int i=0; i<=min(n-1,k); i++){
    ans += f.cmb(n, i) * f.hom(n-i,i) % mod;
    if(ans<0) ans += mod;
  }
  
  cout << ans % mod << "\n";
  return 0;
}

// int main(){

//   int64_t mod = 998244353;

//   int64_t n, m, k;
//   cin >> n >> m >> k;

//   int64_t ans = 0, t;
//   Facts f = Facts(mod);
//   t = m * modpow(m-1, n-1-k, mod) % mod;

//   for(int i=k; i>=0; i--){
//     ans += f.cmb(n-1, i) * t % mod;
//     ans %= mod;
//     t = t * (m-1) % mod;
//   }

//   if(ans < 0) ans += mod;
//   cout << ans << "\n";
//   return 0;
// }


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

constexpr int INF       = 1000000000;/* 1e+9a */
constexpr int MODULO    = 1000000007;

typedef int64_t ll;

int main()
{
	cin.tie(0);
    ios::sync_with_stdio(false);
	ll n;
	cin >> n;
	ll k = n / 50;
	vector<ll> ou(50);
	for (int i = 0; i < 50; i++) {
		ou[i] = i+k;
	}
	k = n % 50;
	for (int i = 0; i < k; i++) {
		ou[i] += 50;
		for (int j = 1; j < 50; j++) {
			ou[(i+j)%50] -= 1;
		}
	}

	cout << "50\n";
	for (auto&& t : ou) {
		cout << t << ' ';
	}
	cout << endl;

}



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

int main( void )
{
    int a, b;
    cin >> a >> b;
    if ( a <= 8 && b <= 8 )
    {
        cout << "Yay!" << endl;
    }
    else
    {
        cout << ":(" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define rep(i, a, b) for(i = a; i < b; i++)
#define per(i, a, b) for(i = a; i >= b; i--)
#define all(x) x.begin(), x.end()
#define trav(x, it) for(auto it = x.begin(); it != x.end(); it++)
#define pr(x) cout << #x << " = " << x << endl
#define fill(x,y) memset(x,y,sizeof(x))
#define endl "\n"
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector< pii > vpii;
typedef vector< pll > vpll;
double eps = 1e-7;
ll mod = 1000000007;
ll N = 998244353;

ll binpow(ll b, ll p){ ll ans = 1; while(p > 0){if(p & 1) ans = (ans * b) % mod; b = (b * b) % mod; p >>= 1;}return ans;}
ll modinv(ll x){return binpow(x, mod - 2);}

void solve()
{
	ll n, i, c, ans = 0;
	cin >> n;
	map <ll, ll> cnt;
	c = 0;
	while(n % 2 == 0)
	{
		n /= 2;
		c++;
	}
	if(c)
		cnt[2] = c;
	for(i = 3; i * i <= n; i += 2)
	{
		c = 0;
		while(n % i == 0)
		{
			n /= i;
			c++;
		}
		if(c)
			cnt[i] = c;
	}
	if(n > 2)
		cnt[n] = 1;

	trav(cnt, it)
	{
		c = (it->ss);
		ans += (sqrt(8 * c + 1) - 1LL) / 2LL;
	}
	cout << ans << endl;
}

signed main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	int t = 1;
	//cin >> t;
	while(t--)
	{
		solve();
	}
	return 0;
}

Measured memory_bytes: 3672
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.numeric;
import std.stdio;
import std.string;

void main()
{
    long n = to!long(readln().chomp());
    long[] a = readln().split().map!(to!long).array;
    for (long i = 0; i < a.length; ++i)
    {
        a[i] -= i + 1;
    }
    // stderr.writeln(a);
    // auto c = a.dup;
    // sort(c);
    // c = c.uniq.array;
    // foreach (b; c)
    // {
    //     stderr.writeln(b, ":", a.map!(e => abs(e - b)).sum);
    //     m = min(m, a.map!(e => abs(e - b)).sum);
    // }
    // int[int] mode;
    // foreach (e; a)
    // {
    //     auto l = e in mode;
    //     if (l)
    //     {
    //         ++mode[e];
    //     }
    //     else
    //     {
    //         mode[e] = 1;
    //     }
    // }
    // auto r = mode.byKeyValue.array.sort!((a, b) => a.value < b.value);
    // auto maxCount = r[0].value;
    // foreach (e; r)
    // {
    //     auto b = e.key;
    //     if (e.value < maxCount)
    //     {
    //         break;
    //     }
    //     stderr.writeln(b, ":", a.map!(e => abs(e - b)).sum);
    //     m = min(m, a.map!(e => abs(e - b)).sum);
    // }
    // sort(a);
    // if (a.length % 2 == 0)
    // {
    //     double median = (a[to!int(floor(a.length / 2.0))] + a[to!int(ceil(a
    //             .length / 2.0))]) / 2.0;
    //     int downer = to!int(floor(median));
    //     int upper = to!int(ceil(median));
    //     int b = downer;
    //     m = min(m, a.map!(e => abs(e - b)).sum);
    //     b = upper;
    //     m = min(m, a.map!(e => abs(e - b)).sum);
    // }
    // else
    // {
    //     int b = a[to!int(floor(a.length / 2.0))];
    //     m = min(m, a.map!(e => abs(e - b)).sum);
    // }
    sort(a);
    long b = a[n / 2];
    writeln(a.map!(e => abs(e - b)).sum);
}


Measured memory_bytes: 11248
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
using namespace std;
#include <math.h>
 
int main() {
 
	int ans,x,y,z;
 
	cin >> x >> y >> z;
 
 
	cout << z << " " << x << " "  << y;
 
	return 0;
 
 
}

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

int main(void)
{
	int n;
	int a;
	int i;
	int max, min;
	long sum;
	
	cin >> n;
	sum = 0;
	max = -1000000;
	min = 1000000;
	
	for (i = 0; i < n; i++){
		cin >> a;
		
		if (max < a){
			max = a;
		}
		if (min > a){
			min = a;
		}
		sum += a;
	}
	
	cout << min << " " << max << " " << sum << endl;
	
	return (0);
}

Measured memory_bytes: 1164
#include<bits/stdc++.h>
using namespace std;
int main(){
  int h,n;
  cin>>h>>n;
  int a=0;
  for(int i=0; i<n; i++){
    int x;
    cin>>x;
    a+=x;
  }
  if(h<=a){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#define INF 50000000000
struct vertex{
	std::vector<int> edge_to;
	std::vector<int> edge_cost;
	bool done;
	long long int mincost;
};
std::vector<vertex> G(100000);
void shortest_path(int v);
int V,E;
int r;
int main(void){
	std::cin>>V>>E>>r;
	for(int i=0;i<E;i++){
		int from,to,cost;
		std::cin>>from>>to>>cost;
		G[from].edge_to.push_back(to);
		G[from].edge_cost.push_back(cost);
//		G[to].edge_to.push_back(from);
//		G[to].edge_cost.push_back(cost);		
	}
	shortest_path(r);
	for(int i=0;i<V;i++){
		if(G[i].mincost!=INF){
			std::cout<<G[i].mincost<<std::endl;
		}else {
			std::cout<<"INF"<<std::endl;
		}	
	}
	return 0;
}
void shortest_path(int v){
	for(int i=0;i<V;i++){
		G[i].mincost=INF;
	}
	G[v].mincost=0;
	while(1){
		bool update=false;
		for(int i=0;i<V;i++){
			for(int j=0;j<G[i].edge_to.size();j++){
				if(G[ G[i].edge_to[j] ].mincost>G[i].mincost+G[i].edge_cost[j]){
					G[ G[i].edge_to[j] ].mincost=G[i].mincost+G[i].edge_cost[j];
					update=true;
				}
			}
		}
		if(!update){
			break;
		}
	}

}

Measured memory_bytes: 17308
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
//ll mod = 998244353;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main() {
    ll n, k;
    cin >> n >> k;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    vector<ll> f(n);
    rep(i, n) cin >> f[i];
    sort(a.begin(), a.end());
    sort(f.rbegin(), f.rend());
    ll l = -1, r = 1e18;
    while(r-l>1) {
        ll m = (r+l)/2LL;
        ll cnt = 0;
        rep(i, n) {
            if (a[i] * f[i] > m) {
                cnt += (a[i] * f[i] - m + f[i] - 1) / f[i];
            }
        }
        if (cnt > k) l = m;
        else         r = m;
    }
    cout << r << endl;
    return 0;
}


Measured memory_bytes: 6428
#include <iostream>
#include <iomanip>
#include <fstream>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <string>
#include <tuple>
#include <vector>
#include <map>
#include <unordered_map>
#include <list>
#include <set>
#include <stack>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <cassert>
using namespace std;
#define LL long long
#define MP(a, b) make_pair(a, b)
#define POWER9 1000000000
#define MOD POWER9+7
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483647
#define INT_MAX 2147483647
#define LL_MIN (LL)-9223372036854775807
#define LL_MAX (LL)9223372036854775807
#define PI 3.14159265359

string S;
bool dp[100000];
bool already[100000] = {};
bool solve(int now){
	if(now == S.size()) return true;
	if(already[now]) return dp[now];
	bool flg = false;
	if(now+5 <= S.size()){
		string tmp = S.substr(now,5);
		if(tmp == "dream") flg = flg | solve(now+5);
		if(tmp == "erase") flg = flg | solve(now+5);
	}
	if(now+6 <= S.size()){
		string tmp = S.substr(now,6);
		if(tmp == "eraser") flg = flg | solve(now+6);
	}
	if(now+7 <= S.size()){
		string tmp = S.substr(now,7);
		if(tmp == "dreamer") flg = flg | solve(now+7);
	}
	already[now] = true;
	return dp[now] = flg;
}
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << setprecision(9);

	cin >> S;
	if(solve(0)) cout << "YES" << endl;
	else cout << "NO" << endl;

	return 0;
}


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

int main(void){
    int a, n;
    cin >> n >> a;
    //n円を１円玉a枚と500円玉無限枚でちょうど支払えるか
    if(n % 500 - a <= 0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}


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

int n, p, sum = 0;

signed main()
{
    cin >> n;

    REP(n)
    {   
        cin >> p;
        sum += p;
    }   

    sum /= n;

    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 1156
#include<bits/stdc++.h>
using namespace std;
#define _CRT_SECURE_NO_DEPRECATE
#define ll               long long
#define nl               '\n'                             // NL - sign of new line

#define upc(str, c)      str[c] = toupper(str[c]);         // make single char uppercase
#define lowerc(str, c)   str[c] = tolower(str[c]);         // make single char lowercase

#define ups(str)       	 transform(str.begin(), str.end(), str.begin(), ::toupper); // make entire string uppercase
#define lowers(str)      transform(str.begin(), str.end(), str.begin(), ::tolower); // make entire string lowercase

#define ps(x,y)          fixed << setprecision(y) << x     // usage: t=1.1234; cout << ps(t,4); // it means it will print 4 decimal places.

#define vi               vector <int>                      //create vector of int numbers
#define vs               vector <string>                      //create vector of int numbers
#define eb               emplace_back
#define rev(v)		     reverse(v.begin(), v.end())       // reverse the vector

#define mii			     std::map <int,int>
#define multimii		 std::multimap <int,int>
#define mss			     map <string, string>

#define w(t)             unsigned int t; cin >> t; while(t--)      //  usage: create quickly number of test
mt19937                  rng(chrono::steady_clock::now().time_since_epoch().count());

void c_p_c()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}
//==================================6


//==================================
int32_t main()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	c_p_c();
	//--------------------------------


	string s;
	cin >> s;

	cout << s[0] << s[1] << s[2];





	return 0;
}

Measured memory_bytes: 3616
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int ans = 1;
      	//数値の入力
		if(a==b || a<b) {
      		ans = a;	
      	}else {
      		ans = a-1;
      	} 	
        System.out.println(ans);
     }
}	

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

int v[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

int main()
{
  int k;
  scanf("%d", &k);
  k--;
  printf("%d\n", v[k]);
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    int a[n + 1], count = 0;
    for ( int i = 1; i <= n; i++)
    {
        cin >> a[i];
        if ( i%2 == 1 && a[i]%2 == 1) count++;
    }
    cout << count;
}


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

using namespace std;
typedef long long ll;
typedef long int li;
typedef long double lb;
#define rep(i,j,n) for (ll i = j; i < (n); i++)
#define repr(i,j,n) for(ll i = j; i >= (n); i--)
#define all(x) (x).begin(),(x).end()
#define CLR(mat,f) memset(mat, f, sizeof(mat))
#define IN(a, b, x) (a<=x&&x<b)
#define out(ans) cout << ans << endl
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; }
typedef pair<ll,ll>P;
const ll mod=1e9+7;
const ll INF = 1LL<<60;


ll w,h;
const ll dx[]={-1,0,1,-1,1,-1,0,1},dy[]={-1,-1,-1,0,0,1,1,1};

// void dfs(ll height,ll width,ll map[height][width],ll check[height][width]){

// }

int main(){

  while(cin>>w>>h){
    if(w==0&&h==0)break;

    ll map[h][w];
    ll check[h][w];
    rep(i,0,h){
      rep(j,0,w){
        cin>>map[i][j];
        check[i][j]=-1;
      }
    }
    ll num=0;
    rep(i,0,h){
      rep(j,0,w){
        if(map[i][j]==1&&check[i][j]==-1){
          num++;
          stack<P>s;
          s.push(P(i,j));

          while(!s.empty()){
            P p=s.top();s.pop();
            ll y=p.first,x=p.second;

            check[y][x]=num;
            rep(i,0,8){
              ll ny=y+dy[i],nx=x+dx[i];
              if(IN(0,h,ny)&&IN(0,w,nx)&&map[ny][nx]==1&&check[ny][nx]==-1){
                s.push(P(ny,nx));
              }
            }
          }
        }
      }
    }

    out(num);

  }


  return 0;
}



Measured memory_bytes: 3264
#include <stdio.h>

void search(long long int *A,int N,long long int *min,long long int *max){ 
  long long int find = A[N]-A[0];
  int bottom=1,top=N-1;

  while(top-bottom-1>0)
    if(find<(A[(top+bottom)/2]-A[0])*2)
      top=(top+bottom)/2;
    else
      bottom=(top+bottom)/2;

  if(2*(A[top]-A[0])-find<find-2*(A[bottom]-A[0])) bottom=top; 
  long long int first=A[bottom]-A[0],second=A[N]-A[bottom];
  
  if(*min>first) *min=first;
  if(*max<first) *max=first;
  if(*min>second) *min=second;
  if(*max<second) *max=second;
  //  printf("\t[%d:%d]=%lld[%d:%d]=%lld :: ",1,bottom,first,bottom+1,N,second);
  // for(int i=0;i<=N;i++)
  // printf("%lld ",A[i]);
  //printf("\n");

}

int main(){
  int N,a;
  long long int A[300000],s;
  long long int min,max,sunuke;

  scanf("%d",&N);

  s=A[0]=0;
  for(int i=1;i<=N;i++){
    scanf("%d",&a);
    s+=a;
    A[i]=s;
  }
  //for(int i=0;i<=N;i++)
    //  printf("%lld ",A[i]);
  //printf("\n");

  sunuke=1000000000000000;
  for(int i=2;i<=N-2;i++){
    // printf("[%d:%d],[%d:%d]\n",1,i,i+1,N);
    min=1000000000000000;
    max=0;
    search(A,i,&min,&max);
    search(A+i,N-i,&min,&max);
    if(sunuke>max-min) sunuke = max-min;
  }
  
  printf("%lld\n",sunuke);
}

Measured memory_bytes: 2432
import java.util.*;
import java.math.*;
import java.io.*;
import java.lang.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] ar = new int[n];
        for (int i = 0; i < n; i++) {
            ar[i] = sc.nextInt();
        }
        int[] ruiseki = new int[n+1];
        for (int i = 0; i <= n; i++) {
            ruiseki[i] = 0;
        }
        int res = Integer.MAX_VALUE;
        for (int i = 1; i <= n; i++) {
            ruiseki[i] = ar[i-1]+ruiseki[i-1];
        }

        for (int i = 1; i <= n; i++) {
            res = Math.min(res, Math.abs(ruiseki[i] - (ruiseki[n] - ruiseki[i])));
        }
        System.out.println(res);

    }
}

class io{
    public static void br(){
        System.out.println("");
    }

    public static void YesNo(boolean f) {
        System.out.println(f?"Yes":"No");
    }
    public static void YESNO(boolean f) {
        System.out.println(f?"YES":"NO");
    }

}

class Algo{
    public static boolean isOdd(int n){
        return n % 2 == 1;
    }
    public static boolean isEven(int n){
        return n % 2 == 0;
    }


}



Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,n) for(int i=1;i<=n;i++)
const ll MOD = 1000000007;
struct edge{
    int to,weight;
    edge(int to,int weight):to(to),weight(weight){}
};
using Graph = vector<vector<int>> ;
using GraphEdge = vector<vector<int>> ;
long long modinv(long long a, long long m=MOD) {long long b = m, u = 1, v = 0;while (b) {    long long t = a / b;    a -= t * b; swap(a, b);    u -= t * v; swap(u, v);}u %= m; if (u < 0) u += m;return u;}
//MODの割り算の際にa/＝b;をa *= modinv(b,MOD);とする。
int gcd(int a, int b){if (a%b == 0){return(b);}else{return(gcd(b, a%b));}}
int lcm(int a, int b){return a * b / gcd(a, b);}
bool ok(int a){
    if((a%100)%10==(a/10)%10 && a/100 == (a/10)%10)return true;

    else return false;
}
int main(){
    int n;
    cin >> n;
    for(int i=n;i<=999;i++){
        if(ok(i)){
            cout << i << endl;
            return 0;
        }
    }
    return 0;
}

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

int main ()
{
	long long h, w;
	
	cin >> h >> w;
	
	long long ans = 0;
	
	if(h == 1 or w == 1) return puts("1"), 0;
	
	if(h % 2 == 0 and w % 2 == 0)
		ans = (h / 2) * w;
	
	if(h % 2 == 1 and w % 2 == 0)
		ans = (w / 2) * h;
	
	if(h % 2 == 0 and w % 2 == 1)
		ans = (h / 2) * w;
	
	if(h % 2 == 1 and w % 2 == 1)
		ans = (h / 2) * ((w + 1) / 2) + (h / 2) * (w / 2) + ((w + 1) / 2);
	
	cout << ans << '\n';

	return 0;
}	

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

using namespace std;

int main()
{
    string s;
    cin >> s;
    int cnt=0;
    for(int i=0; i<s.size(); i++) {
        if(s[i]=='2') {
            cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}


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++)
#define PI 3.141592653589793


   
int main(){
    int a,b,c;
    cin >> a >> b >>c ;
    set<int> d;
    d.insert(a);
    d.insert(b);
    d.insert(c);
    cout << d.size() << endl;
    }

Measured memory_bytes: 3624
import sys
import os

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]


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

    A, B, C = sl()
    print(A[0] + B[0] + C[0])


if __name__ == '__main__':
    main()


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

char s[2010][10100];
int n,K,len[2010],T;
bitset<10100>F[2010];
vector<pair<int,int> >vec[2];

int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin>>n>>K;
	for(int i=1;i<=n;++i)cin>>(s[i]+1),len[i]=strlen(s[i]+1);
	F[n+1][0]=1;
	for(int i=n;i;--i)F[i]=F[i+1]|(F[i+1]<<len[i]);
	for(int i=1;i<=n;++i)
		if(F[i+1][K-len[i]])vec[0].emplace_back(i,1);
	for(int i=1;i<=K;++i){
		char res='z';
		T^=1;vec[T].clear();
		for(auto j:vec[!T])res=min(res,s[j.first][j.second]);
		cout<<res;
		int pre=n;
		for(auto j:vec[!T]){
			if(s[j.first][j.second]!=res)continue;
			if(j.second!=len[j.first])vec[T].emplace_back(j.first,j.second+1);
			else pre=min(pre,j.first);
		}
		for(int j=pre+1;j<=n;++j)
			if(len[j]+i<=K&&F[j+1][K-i-len[j]])vec[T].emplace_back(j,1);
		while(vec[T].size()>=15000)vec[T].pop_back();
	}
	return 0;
}
//orz

Measured memory_bytes: 22016