akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define INF 0x3f3f3f3f
using namespace std;
const int N = 5e5 + 7, M = 1e6 + 7;

int cnt = 1, S, T, b[N], dis[N], cur[N];//b初值-1
struct node{
	int v, c, nex;
}e[M];
void addedge(int u, int v, int c){ //注意建反向边
	e[++cnt].v = v; e[cnt].c = c; e[cnt].nex = b[u]; b[u] = cnt;
	e[++cnt].v = u; e[cnt].c = 0; e[cnt].nex = b[v]; b[v] = cnt;
}
bool bfs(){
	memset(dis, INF, sizeof(dis));
	memcpy(cur, b, sizeof(b));
	queue<int > Q;
	Q.push(S); dis[S] = 0;
	while (!Q.empty()){
		int now = Q.front(); Q.pop();
		for (int i = b[now]; i != -1; i = e[i].nex){
			if (e[i].c > 0 && dis[e[i].v] == INF){
				dis[e[i].v] = dis[now] + 1;
				Q.push(e[i].v);
			}
		}
	}
	return dis[T] < INF;
}

int dfs(int now, int w){
	if (now == T) return w;
	int used = 0;
	for (int i = cur[now]; i != -1 && w; i = e[i].nex){
		cur[now] = i;
		if (e[i].c > 0 && dis[e[i].v] == dis[now] + 1){
			int flow = dfs(e[i].v, min(e[i].c, w));
			if (flow){
				used += flow;
				w -= flow;
				e[i].c -= flow;
				e[i ^ 1].c += flow;
			}
		}
	}
	return used;
}
int maxflow = 0;
int Dinic(){
	while (bfs()) maxflow += dfs(S, INF);
	return maxflow;
}

int a[N], c[N], ida[N], idb[N];
bool vis[N];

int main(){
	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; i++) scanf("%d", &a[i]);
	for (int i = 0; i < n; i++) scanf("%d", &c[i]);
	memset(vis, 0, sizeof(vis));
	int cnta = 0;
	for (int i = 0; i < n; i++){
		if (!vis[i]){
			int j = i; ++cnta;
			while (!vis[j]){
				vis[j] = true; ida[j] = cnta; j = a[j];
			}
		}
	}
	memset(vis, 0, sizeof(vis));
	int cntb = 0;
	for (int i = 0; i < n; i++){
		if (!vis[i]){
			int j = i; ++cntb;
			while (!vis[j]){
				vis[j] = true; idb[j] = cntb; j = c[j];
			}
		}
	}
	S = 0; T = cnta + cntb + 1; memset(b, -1, sizeof(b));
	for (int i = 0; i < n; i++){
		if (a[i] == c[i] && a[i] == i) {addedge(S, T, 1); continue;}
		if (a[i] == i) {addedge(S, idb[i] + cnta, 1); continue;}
		if (c[i] == i) {addedge(ida[i], T, 1); continue;}
		if (a[i] != c[i]) {addedge(ida[i], idb[i] + cnta, 1); continue; }
		addedge(ida[i], idb[i] + cnta, 1);
		addedge(idb[i] + cnta, ida[i], 1);
	}
	printf("%d", n - Dinic());
	return 0;
}

Measured memory_bytes: 23040
IDENTIFICATION DIVISION.
      PROGRAM-ID. 052B.
      DATA DIVISION.
      WORKING-STORAGE SECTION.
      01 INP PIC X(100).
      01 A	 PIC 9(5).
      01 B	 PIC 9(5).
      01 C	 PIC 9(5).
      01 D	 PIC 9(5).
      01 ANS1 PIC 9(10). 
      01 ANS2 PIC 9(10).
      01 OUT PIC ZZZZZZZZZ9.
      
      PROCEDURE DIVISION.
      ACCEPT INP.
      UNSTRING INP DELIMITED BY " "
      INTO A B C D.
      COMPUTE ANS1 = A * B.
      COMPUTE ANS2 = C * D.
      IF ANS1 = ANS2
      	MOVE ANS1 TO OUT
      ELSE 
      	IF ANS1 < ANS2
      		MOVE ANS2 TO OUT
      	ELSE
      		MOVE ANS1 TO OUT
      	END-IF
      END-IF.
      
      DISPLAY FUNCTION TRIM(OUT).
      
      STOP RUN.
  

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 305;

int N, M, ps[3*MAXN][3*MAXN], ps2[3*MAXN][3*MAXN];
char arr[MAXN][MAXN];
vector<pair<int, int>> utama[2*MAXN], lain[2*MAXN];

int main() {
	ios::sync_with_stdio(0); cin.tie(0);
	
	cin >> N >> M;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M; j++) {
			cin >> arr[i][j];
			if (arr[i][j] == '#') {
				utama[i+j].push_back({i, j});
				lain[i-j+MAXN].push_back({i, j});
			}
		}
	}
	
	for (int i = -N; i < 2*N; i++) {
		for (int j = -M; j < 2*M; j++) {
			ps[i+MAXN][j+MAXN] = ps[i-1+MAXN][j+1+MAXN];
			ps2[i+MAXN][j+MAXN] = ps2[i-1+MAXN][j-1+MAXN];
			if (0 <= i && i < N && 0 <= j && j < M && arr[i][j] == '#') {
				ps[i+MAXN][j+MAXN]++;
				ps2[i+MAXN][j+MAXN]++;
			}
			//~ cerr << ps[i+MAXN][j+MAXN] << " ";
		}
		//~ cerr << "\n";
	}
	
	int ans = 0;
	for (int miring = 0; miring < N+M; miring++) {
		for (int i = 0; i < (int)utama[miring].size(); i++) {
			for (int j = i+1; j < (int)utama[miring].size(); j++) {
				auto p = utama[miring][i], q = utama[miring][j];
				int x = p.second-q.second + q.first-p.first;
				assert(x > 0);
				//~ cerr << ps[miring+x-p.second+MAXN][p.second+MAXN] << " " << ps[q.first-1+MAXN][miring+x-(q.first-1)+MAXN] << "ex\n";
				ans += ps[p.first+MAXN][miring-x-p.first+MAXN] - ps[miring-x-(q.second+1)+MAXN][q.second+1+MAXN];
				ans += ps[miring+x-p.second+MAXN][p.second+MAXN] - ps[q.first-1+MAXN][miring+x-(q.first-1)+MAXN];
			}
		}
	}
	
	for (int miring = -M; miring < N; miring++) {
		for (int i = 0; i < (int)lain[miring+MAXN].size(); i++) {
			for (int j = i+1; j < (int)lain[miring+MAXN].size(); j++) {
				auto p = lain[miring+MAXN][i], q = lain[miring+MAXN][j];
				int x = q.first-p.first + q.second-p.second;
				//~ if (x <= 0) cerr << x << " ex\n";
				assert(x > 0);
				//~ cout << ps2[p.first-1+MAXN][-miring+x-(p.first-1)+MAXN] << "\n";
				ans += ps2[miring+x+p.second-1+MAXN][p.second-1+MAXN] - ps2[q.first+MAXN][-miring-x+q.first+MAXN];
				//~ cerr << ans << " ans\n";
				ans += ps2[p.first-1+MAXN][-miring+x+(p.first-1)+MAXN] - ps2[miring-x+q.second+MAXN][q.second+MAXN];
			}
		}
	}
	
	//~ int ans2 = 0;
	//~ for (int i = 0; i < N*M; i++) {
		//~ for (int j = i+1; j < N*M; j++) {
			//~ for (int k = j+1; k < N*M; k++) {
				//~ if (arr[i/M][i%M] == '#' && arr[j/M][j%M] == '#' && arr[k/M][k%M] == '#'
					//~ && abs(i/M-j/M) + abs(i%M - j%M) == abs(i/M-k/M) + abs(i%M - k%M)
					//~ && abs(i/M-k/M) + abs(i%M - k%M) == abs(j/M - k/M) + abs(j%M - k%M)) ans2++;
			//~ }
		//~ }
	//~ }
	//~ cout << ans2 << "\n";
	//~ assert(ans2 == ans);
	
	cout << ans << "\n";
	
	return 0;
}


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

//#define DEBUG
#define REP(i,n) for(int i=1;i<=n;i++)
int n,m;
vector<int> g[5002];
int d[5002];

void mk(int i){
  REP(k,g[i].size()){
    int j=g[i][k-1];
    if(d[i]+1>d[j]){
      d[j]=d[i]+1;
      mk(j);
    }
  }
}

int main(){
  cin>>n>>m;
  int a,b;
  REP(i,m){
    cin>>a>>b;
    g[a].push_back(b);
  }
  REP(i,n)g[0].push_back(i);
  mk(0);
  bool f=0;
  REP(r,n){
    int c=0;
    REP(i,n){
      if(d[i]==r){
        c++;
        cout<<i<<endl;
      }
    }
    if(c>1)f=1;
  }
  cout<<f<<endl;
  #ifdef DEBUG
  REP(i,n){
    REP(j,n)cout<<g[i][j]<<" ";
    cout<<endl;
  }
  REP(i,n)cout<<d[i]<<" ";
  #endif
  return 0;
}

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

int main(){
  int N=8779;
  string M;
  cin >> N;
  M=to_string(N);
  M=M[M.length()-1];
  if(M=="3"){
    cout << "bon";
  }
   if(M=="0"||M=="1"||M=="6"||M=="8"){
    cout << "pon";
  }
   if(M=="2"||M=="4"||M=="5"||M=="7"||M=="9"){
    cout << "hon";
  }
	return 0;
}

Measured memory_bytes: 3672
/******************************************
* AUTHOR : HRITIK AGGARWAL *
******************************************/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define N 100005
#define MOD 1000000007
#define dd double
#define vi vector<int>
#define vll vector<ll>
#define forr(i, n) for(int i = 0; i < n; i++)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep1(i,b) for(int i=1;i<=b;i++)
#define pb push_back
#define mp make_pair
#define clr(x) x.clear()
#define sz(x) ((int)(x).size())
#define ms(s, n) memset(s, n, sizeof(s))
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define int ll
ll po(ll a, ll x, ll m) { if (x == 0) {return 1;} ll ans = 1; ll k = 1;  while (k <= x) {if (x & k) {ans = ((ans * a) % m);} k <<= 1; a *= a; a %= m; } return ans; }
// DEKHIYE JI  WALID JO THE ABBA HAMARE WO YEH function CHHOD KR GYE THE
int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    int n;
    cin >> n;
    int arr[10001] = {0};
    for (int i = 1; i <= 500; i++) {
        for (int j = 1; j <= 500; j++) {
            for (int k = 1; k <= 500; k++) {
                int tmp  = i * i + j * j + k * k + i * j + j * k + k * i;
                if (tmp < 10001) {
                    arr[tmp]++;
                }
            }
        }
    }
    forr(i, n) {
        cout << arr[i + 1] << "\n";
    }
    return 0;
}

Measured memory_bytes: 3612
package main

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

type Answer map[string](int)

func main() {
	scanner := Scanner()
	n := ReadInt(scanner)

	ans := Answer{}
	ans["AC"] = 0
	ans["WA"] = 0
	ans["TLE"] = 0
	ans["RE"] = 0
	for i := 0; i < n; i++ {
		s := ReadString(scanner)
		if _, ok := ans[s]; !ok {
			ans[s] = 1
		} else {
			ans[s]++
		}
	}

	// fmt.Printf("%v", ans)

	fmt.Printf("%v x %v\n", "AC", ans["AC"])
	fmt.Printf("%v x %v\n", "WA", ans["WA"])
	fmt.Printf("%v x %v\n", "TLE", ans["TLE"])
	fmt.Printf("%v x %v\n", "RE", ans["RE"])
}

func Scanner() *bufio.Scanner {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	return scanner
}

func ReadInt(scanner *bufio.Scanner) int {
	var t string

	if scanner.Scan() {
		t = scanner.Text()
	}

	n, err := strconv.Atoi(t)
	if err != nil {
		log.Fatal(err)
	}

	return n
}

func ReadString(scanner *bufio.Scanner) string {
	var t string

	if scanner.Scan() {
		t = scanner.Text()
	}

	return t
}

// func (ans Answer) String() string {
// 	var ret string
// 	for s, v := range ans {
// 		ret += fmt.Sprintf("%v x %v\n", s, v)
// 	}
// 	return ret
// }


Measured memory_bytes: 2176
#include <stdio.h>
#define N 100

int main(){
  int array_size, numbers[N], key, i, j, k;
  
  scanf("%d",&array_size);

  for(i = 0; i < array_size; i++){
    scanf("%d",&numbers[i]);
  }
  for(j = 0; j < array_size - 1; j++){
    printf("%-d ",numbers[j]);
  }
  
  printf("%-d\n",numbers[array_size - 1]);

  for(i = 1; i < array_size; i++){
    key = numbers[i];
    j = i - 1;
    while((j >= 0) && (numbers[j] > key)){
      numbers[j + 1] = numbers[j];
      j--;
      numbers[j + 1] = key;
    }
    for(k = 0; k < array_size - 1; k++){
      printf("%-d ",numbers[k]);
    }
    printf("%-d\n",numbers[array_size - 1]);
  }
  
  return 0;
}



Measured memory_bytes: 2144
import java.util.*;

public class Main{
	
	private void doit(){
		Scanner sc = new Scanner(System.in);
		boolean first = true;
		while(sc.hasNext()){
			
			String s = sc.next();
			
			if(first){
				first = false;
			}
			else{
				System.out.println();
			}
			int len = s.length();
			for(int i = 0; i < (5 - len); i++){
				s = "0" + s;
			}
			len = 5;
			char [][] disp = new char[8][5];
			for(int i = 0; i < 8; i++){
				if(i == 2){
					Arrays.fill(disp[i], '=');
				}
				else{
					Arrays.fill(disp[i], '*');
				}
			}
			
			for(int i = 0; i < len; i++){
				int num = s.charAt(i) - '0';
				int ind1 = (num / 5) ^ 1;
				disp[ind1][i] = ' ';
				int ind2 = (num % 5);
				disp[ind2 + 3][i] = ' ';
			}
			
			for(int i = 0; i < 8; i++){
				System.out.println(new String(disp[i]));
			}
			
		}
	}
	private void debug(Object... o) { System.out.println("debug = " + Arrays.deepToString(o)); }

	public static void main(String[] args) {
		new Main().doit();
	}
}

Measured memory_bytes: 12000
n=int(input())
a=list(map(int,input().split()))
ans=[]
if n%2==1:
    i=n
    while i>=1:
        ans.append(str(a[i-1]))
        i-=2
    i=2
    while i<=n:
        ans.append(str(a[i-1]))
        i+=2
    print(" ".join(ans))
else:
    i = n
    while i >= 1:
        ans.append(str(a[i - 1]))
        i -= 2
    i = 1
    while i <= n:
        ans.append(str(a[i - 1]))
        i += 2
    print(" ".join(ans))

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

int p(int n){
    if(n%2 == 0){
        return 1;
    }
    else{
        return -1;
    }
}

int main(){
    int N, M;
    cin >> N >> M;
    long long x[N], y[N], z[N];
    rep(i, N){
        cin >> x[i] >> y[i] >> z[i];
    }
    long long s[8][N];
    priority_queue<long long> que[8];
    long long sum[8];
    fill_n(sum, 8, 0);
    rep(i, 8){
        int k = i % 2;
        int l = (i/2) % 2;
        int m = (i/4) % 2;
        rep(j, N){
            s[i][j] = x[j] * p(k) + y[j] * p(l) + z[j] * p(m);
            que[i].push(s[i][j]);
        }
        rep(a, M){
            sum[i] += que[i].top();
            que[i].pop();
        }
    }
    sort(sum, sum+8, greater<long long>());
    cout << sum[0] << endl;
}

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

#define lli long long int
#define ld long double
#define DEFO(n) lli n = 0;
#define MAX_L lli max = 9000000000000000000;
#define MIN_L lli min = 9000000000000000000;
#define MAX_D ld max = 4500;
#define MIN_D ld min = -4500;
#define LLI(n) \
  lli n;       \
  cin >> n;
#define LD(n) \
  ld n;       \
  cin > n;
#define LLIV(a, n)            \
  vector<lli> a(n);           \
  for (lli i = 0; i < n; i++) \
  {                           \
    cin >> a.at(i);           \
  };
#define LLIV2(a, b, n)         \
  vector<lli> a(n), b(n);      \
  for (lli i = 0; i < n; i++)  \
  {                            \
    cin >> a.at(i) >> b.at(i); \
  };
#define LDV(a, n)             \
  vector<ld> a(n);            \
  for (lli i = 0; i < n; i++) \
  {                           \
    cin >> a.at(i);           \
  };
#define STR(n) \
  string n;    \
  cin >> n;
#define SUM(n) accumulate(n.begin(), n.end(), 0);
#define SORT(n) sort(n.begin(), n.end());
#define REVE(n) reverse(n.begin(), n.end());
#define yes              \
  cout << "Yes" << endl; \
  return 0;
#define no              \
  cout << "No" << endl; \
  return 0;
#define C45(n) (n + 1) / 2
#define OUT(n) cout << n << endl;
#define SRC(n, c)                    \
  for (lli i = 0; i < s.size(); i++) \
  {                                  \
    if (s.at(i) == c)                \
    {                                \
      n++;                           \
    }                                \
  };
//こぴー
/*#define ZISYO(s, S)                  \
  for (lli i = 0; i < s.size(); i++) \
  {                                  \
    S.at(i) = s.at(i);               \
  }                                  \
  Sort(S) Reve(S) for (lli i = 0; i < s.size(); i++) { s.at(i) = S.at(i); };
*/

//素数
bool IsPrime(lli num)
{
  if (num < 2)
    return false;
  else if (num == 2)
    return true;
  else if (num % 2 == 0)
    return false;
  long double sqrtNum = sqrt(num);
  for (lli i = 3; i <= sqrtNum; i += 2)
  {
    if (num % i == 0)
      return false;
  }
  return true;
}
//各桁の和
lli KSum(lli n)
{
  lli sum = 0;
  if (n < 0)
    return 0;
  while (n > 0)
  {
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

//数値反転
bool KReve(lli n)
{
  int reverse = 0;
  int remaind;
  int tmp = n;
  while (tmp != 0)
  {
    remaind = tmp % 10;
    reverse = reverse * 10 + remaind;
    tmp /= 10;
  }
  if (reverse == n)
    return true;
  else
    return false;
}

int main(void)
{
  ios::sync_with_stdio(false);
  LLI(n) LLIV(d, n) SORT(d) DEFO(flag)
  flag++;
  for(lli i = 0;i < n;i++) {
    if(i != 0) {
      if(d[i - 1] < d[i]) {
        flag++;
      }
    }
  }
  OUT(flag)
}


Measured memory_bytes: 256
from collections import Counter

N = int(input())
A = list(map(int, input().split()))
Wa = []
Sa = []
for i, j in enumerate(A):
    Wa.append(j + i + 1)
    Sa.append(i + 1 - j)
CWa = Counter(Wa)
CSa = Counter(Sa)
ans = 0

for i in CWa.keys():
    ans += CWa[i] * CSa[i]
print(ans)

Measured memory_bytes: 63412
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <iomanip>
#include <bitset>
#include <cassert>
using namespace std;

typedef long long ll;

int main() {
	int n, k; cin >> n >> k;
	vector<ll> x(n), s(n + 1);
	for (int i = 0; i < n; i++) cin >> x[i];
	ll ans = 2e18;
	for (int i = 0; i + k <= n; i++) {
		ll a = -min(0LL, x[i]);
		ll b = max(0LL, x[i + k - 1]);
		ans = min(ans, a + b + min(a, b));
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1792
/* Bismillahir Rahmanir Rahim */

#include <bits/stdc++.h>

#define rep(i, n)	for(int i=0;i<n;i++)
#define repn(i, n)	for(int i=1;i<=n;i++)
#define set(i, n)	memset(i, n, sizeof(i))

#define pb	push_back
#define oo	1e9 

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;

int main(){
	string str;
	cin >> str;
	rep(i, str.size()){
		if(str[i] == ',') cout << " ";
		else cout << str[i];
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 384
d, g = gets.chomp.split.map(&:to_i)
p = []
c = []

d.times do |i|
  p[i], c[i] = gets.chomp.split.map(&:to_i)
end

ans = 10**10

[0, 1].repeated_permutation(d) do |bits|
  # 得点
  tmp = 0

  # 選んだ問題数
  num = 0

  # 全完には選ばれなかったが一番大きい数字のインデックス
  max_i = -1

  d.times do |i|
    if bits[i] == 1
      # 全完したときの得点を足す
      tmp += 100 *(i+1) * p[i] + c[i]
      num += p[i]

      # ここで選んだ時点でgを超えてたら答えを更新しておく
      ans = [ans, num].min if tmp >= g
    else
      max_i = [max_i, i].max
    end
  end

  # 指定したやつ全問といて届かなかったときはここで足していく
  # どれも全完しない場合については、最初の[0,0,..,0]で対応しているので問題なし

  rest = g-tmp
  next if rest <= 0

  # あとは全完しなかったやつの中から一番大きいやつをたす

  rest_cnt = ( rest.to_f / ( 100 * ( max_i+1 ) ) ).ceil
  
  next if rest_cnt > p[max_i] - 1

  ans = [ans, num + rest_cnt].min
end

p ans


Measured memory_bytes: 1788
(let* ((d-read (read))
    (c (make-array 27))
    (s (make-array (list (+ d-read 1) 27)))
    (td 0)
    (ans 0)
    (last (make-array '(27) :initial-element 0)))

    (loop for i from 1 to 26 do
        (setf (aref c i) (read))
    )
    (loop for i from 1 to d-read do
        (loop for j from 1 to 26 do
            (setf (aref s i j) (read))
        )
    )
    (loop for d from 1 to d-read do
        (progn
            (setq td (read))
            (setf (aref last td) d)
            (incf ans (aref s d td))
            (loop for j from 1 to 26 do
                (decf ans (* (aref c j) (- d (aref last j))))
            )
            (format t "~D~%" ans)
        )
    )
)

Measured memory_bytes: 29668
#include<iostream>

using namespace std;

static const long long P = 1000000007;
typedef long long ll; 

int main(){
    ll n,k;
    cin >> n >> k;
    ll ans = 0;
    for (int i = k; i <= n + 1; i++)
    {
        ans += (i * (n - i + 1) + 1) % P;
        ans = ans % P;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3604
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <cstring>
#include <iomanip>
#include <utility>
 
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n) for(int i=1;i<=(n);i++)
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
using namespace std;

int keta(int n){
  int sum=0;
  sum+=n%10;
  sum+=n/10%10;
  sum+=n/100%10;
  sum+=n/1000%10;
  sum+=n/10000%10;
  sum+=n/100000%10;
  sum+=n/1000000%10;
  sum+=n/10000000%10;

  return sum;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin>>n;
  int sum=keta(n);

  if(n%sum==0){
    cout<<"Yes"<<'\n';
  }
  else{
    cout<<"No"<<'\n';
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <utility>
#include <cmath>
#include <map>
#include <set>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <random>
#include <deque>

#define INF_LL 1e18
#define INF 1e9

typedef long long ll;

using namespace std;

int main()
{
  int x, y;
  cin >> x >> y;
  cout << x * y << endl;
  return 0;
}


Measured memory_bytes: 3644
N = int(input())
S = list(input())
c = 0
a = 0
cw = [0] * N
cb = [0] * N
tw = 0
tb = 0
for i in range(N):
    if S[i] == '.':
        tw += 1
        cw[i] = tw
        cb[i] = tb
    else:
        tb += 1
        cb[i] = tb
        cw[i] = tw
A = cw[N - 1]
for i in range(N):
    A = min(A, cb[i] + cw[N - 1] - cw[i])
print(A)


Measured memory_bytes: 14116
S = input()
if S[0] != 'A':
  print('WA')
  exit()
count = 0
if len(S) < 4:
  print('WA')
  exit()
for i in range(len(S) - 3):
  if S[i+2] == 'C':
    count += 1
  elif S[i+2].islower():
    continue
  else:
    print('WA')
    exit()
if S[1].isupper() or S[-1].isupper():
  print('WA')
  exit()
if count == 1:
  print('AC')
  exit()
print('WA')
    

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<bool> vb;
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define INT(str) stoi((str), 0)
#define INTB(str) stoi((str), 0, 2) // 2進数の文字列を int に
 
int main() {
  ll N, A, B;
  cin >> N >> A >> B;
  cout << N / (A + B) * A + min(A, N % (A + B)) << endl;
}

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

typedef struct Node
{
  int key;
  struct Node *next,*prev;
}Node;

Node *nl;

Node* listSearch(int key)
{
  Node *cu=nl->next;
  while(cu!=nl && cu->key !=key)
    {
      cu=cu->next;
    }
  return cu;
}

void init()
{
  nl=(Node *)malloc(sizeof(Node));
  nl->next=nl;
  nl->prev=nl;
}

void printlist()
{
  Node*cu=nl->next;
  int f=0;
  while(1)
    {
      if(cu==nl) break;
      if(f++>0)printf(" ");
      printf("%d",cu->key);
      cu=cu->next;
    }
  printf("\n");
}

void deleteNode(Node *r)
{
  if(r==nl)return;
  r->prev->next=r->next;
  r->next->prev=r->prev;
  free(r);
}

void deletefirst()
{
  deleteNode(nl->next);
}

void deletelast()
{
  deleteNode(nl->prev);
}

void deletekey(int key)
{
  deleteNode(listSearch(key));
}

void insert(int key)
{
  Node *a=(Node *)malloc(sizeof(Node));
  a->key=key;
  a->next=nl->next;
  nl->next->prev=a;
  nl->next=a;
  a->prev=nl;
}

int main()
{
  int key,i,n;
  int cnt=0;
  char order[20];
  int p=0,d=0;
  scanf("%d",&n);
  init();
  for(i=0;i<n;i++)
    {
      scanf("%s%d",order,&key);
      if(order[0]=='i')
	{
	  insert(key);
	  p++;
	  cnt++;
	}
      else if(order[0]=='d')
	{
	  if(strlen(order)>6)
	    {
	      if(order[6]=='F') deletefirst();
	      else if(order[6]=='L')deletelast();
	    }
	  else
	    {
	    deletekey(key);
	    d++;
	    }
	  cnt--;
	}
    }
  printlist();
  return 0;
}

Measured memory_bytes: 31788
#include <iostream>
#include<algorithm>
#include<sstream>
#include<cmath>
#include<vector>
#include<iomanip>
#include<map>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i = 0; i < n;i++)
int main(void) {
    string s, t;cin >> s;int sum = 1111111;
    rep(i, s.size() - 2) {
        t = "";
        t += s[i]; t += s[i + 1];t += s[i + 2];
        int num = stoi(t);
        sum = min(abs(num - 753), sum);
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int n, m, q, d[500005] = {}, a[500005] = {};
    cin >> n >> a[0];
    d[n + 1] = 1;
    for (int i = 1; i <= n; i++) cin >> a[i];
    for (int i = n; i; i--) {
        if (a[i] >= d[i + 1] + d[i + 1]) d[i] = d[i + 1];
        else d[i] = d[i + 1] + a[i];
    }
    for (int i = 1; i <= n; i++) a[i] = min(a[i - 1], abs(a[i - 1] - a[i]));
    cin >> q;
    while (q--) {
        cin >> m;
        if (a[m - 1] >= d[m + 1]) cout << "YES\n";
        else cout << "NO\n";
    }
    //for (int i = 1; i <= n; i++) cout << d[i] << ' ' << a[i] << '\n';
}


Measured memory_bytes: 5888
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

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

	vector<int> arr,arr2;
	vector<int> left,right;
	for(int i = 0; i < n; i++) {
		int a;
		cin >> a;
		arr.push_back(a);
		if(i%2==0) left.push_back(a);
		else right.push_back(a);
	}

	sort(arr.begin(),arr.end());
	sort(left.begin(),left.end());
	sort(right.begin(),right.end());
	for(int i = 0; i < n; i++) {
		if(i%2==0) arr2.push_back(left[i/2]);
		else arr2.push_back(right[i/2]);
	}
/*
	for(int i = 0; i < n; i++) {
		cout << arr[i] << " : " << arr2[i] << endl;
	}
*/
	int ans = 0;

	for(int i = 0; i < n; i++) {
		int pos = lower_bound(arr.begin(),arr.end(),arr2[i]) - arr.begin();
//		cout << pos << endl;
		if(pos>i) ans += ((pos-i)%2!=0)?1:0;
	}

	cout << ans << endl;

	return 0;
}


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

int main() {
  uint32_t N = 0;
  std::cin >> N;
  int64_t prod = 1;
  for (uint32_t i = 0; i < N; i++) {
    int64_t A = 0;
    std::cin >> A;

    if (prod == -1) {
      if (A == 0) prod = 0;
    } else if (prod != 0) {
      if ((1'000'000'000'000'000'000 + prod - 1) / prod < A) {
        prod = -1;
      } else {
        prod *= A;
        if (prod > 1'000'000'000'000'000'000) prod = -1;
      }
    }
  }

  std::cout << prod << std::endl;

  return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define erep(i, a, b) for (int i = a; i <= (int)(b); ++i)
#define per(i, a, b) for (int i = (b); i > (a); --i)
#define eper(i, a, b) for (int i = ((int)(a)); i >= b; --i)
#define pb push_back
#define mp make_pair
#define INF 2000000000
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
int dy[] = {0, 0, 1, -1};
int dx[] = {1, -1, 0, 0};
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

bool isPrime(int x)
{
    if (x < 2)
        return false;
    else if (x == 2)
        return true;
    else if (x % 2 == 0)
        return false;

    double sq = sqrt(x);
    for (int i = 3; i <= sq; i += 2)
    {
        if (x % i == 0)
        {
            return false;
        }
    }
    return true;
};

const int N_MAX = 100005;
int q, sum[N_MAX];
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    rep(i, 3, N_MAX) {
        if (isPrime(i) && isPrime((i+2)/2)) {
            sum[i]++;
        }
    }
    int cnt = 0;
    rep(i, 3, N_MAX) {
        sum[i] += sum[i-1];
    }
    cin >> q;
    rep(i, 0, q) {
        int l, r, ans = 0;
        cin >> l >> r;
        ans = sum[r] - sum[l-1];
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 1024
N = int(input())
H = input().split(" ")
count = 0
for i in range(N):
  if i == 0:
    nowTop = H[0]
    count += 1
  else:
    if int(H[i]) >= int(nowTop):
      nowTop = H[i]
      count += 1
      
print(count)

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

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP0(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REP1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)

typedef long long LL;
typedef pair<int, int> pii;

const int INTINF = int(1e9) + 1;
const LL LLINF = LL(1e18) + 1;
long double eps = 1.0E-14;
#define pow10(n) int(1e##n + n)

void solve()
{
    int A, B;
    cin >> A >> B;
    cout << (A - 1) * (B - 1) << endl;
}

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(10);
    solve();
    return 0;
}


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

int main() {
  int k, s;
  cin >> k >> s;
  int c = 0;
  for (int x = 0; x <= k; x++) {
    for (int y = 0; y <= k; y++) {
      int z = s - x - y;
      if (0 <= z && z <= k) c++;
    }
  }
  cout << c << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int n;
  int i, j, sum = 0;
  int min = INT_MAX;
  
  cin >> n;
  vector<int> p(n);

  for(i = 0; i < n; i++){
    cin >> p.at(i);
  }
  
  for(i = 0; i < n; i++){
    if (min >= p.at(i)){
      min = p.at(i);
      sum++;
    }
  }
  
  cout << sum << endl;
}

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

#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define LL long long
#define pii pair <int,int>
#define fi first
#define se second
#define pb push_back
#define mpr make_pair

using namespace std;

const LL MOD=998244353;

LL a,b,c,d,dp[3010][3010];

int main()
{
	cin>>a>>b>>c>>d;
	dp[a][b]=1;
	for(int i=a+1;i<=c;i++) dp[i][b]=dp[i-1][b]*b%MOD;
	for(int i=b+1;i<=d;i++) dp[a][i]=dp[a][i-1]*a%MOD;
	for(int i=a+1;i<=c;i++) for(int j=b+1;j<=d;j++)
	dp[i][j]=(dp[i-1][j]*j+dp[i][j-1]*i-dp[i-1][j-1]*(i-1)*(j-1)%MOD+MOD)%MOD;
	cout<<dp[c][d]<<endl;
	return 0;
}

Measured memory_bytes: 74068
#include <iostream>
//#include <fstream>
#include <vector>

using namespace std;

int main(int argc, const char * argv[]) {
//    ifstream in("input.txt");
//    cin.rdbuf(in.rdbuf());
    
    int W, H, x, y;
    cin >> W >> H >> x >> y;
    
    int a = 0;
    if (x*2 == W && y*2 == H)a=1;
    
    cout << (double(W) * double(H)) / 2 << " " << a << endl;
    
//    cout <<static_cast<float>(12.35) / 2.0f << endl;
    
    return 0;
}

Measured memory_bytes: 256
#![allow(unused_mut)]
#![allow(non_snake_case)]
#![allow(unused_macros)]
#![allow(unused_variables)]
#![allow(unused_imports)]
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

macro_rules! max {
    ($x: expr) => ($x);
    ($x: expr, $($y: expr),+) => {
        ::std::cmp::max($x, max!($($y),+))
    };
}

macro_rules! min {
    ($x: expr) => ($x);
    ($x: expr, $($y: expr),+) => {
        ::std::cmp::min($x, max!($($y),+))
    };
}

use std::cmp;
use std::collections::{HashSet, BinaryHeap};
use std::io::{Write, BufWriter, stdout};
fn main() {
    input! {
        N: usize,
        C: usize,
        tv_pro: [(usize, usize, usize1); N],
    }
    tv_pro.sort_by_key(|p| p.0);
    let mut recorders: Vec<(usize, usize)> = Vec::new();
    let mut new_ind;
    for &(start, end, channel) in tv_pro.iter() {
        new_ind = None;
        for (ind, r) in recorders.iter().enumerate() {
            if r.0 < start {
                new_ind = Some(ind); 
            } else if r.0 == start && r.1 == channel {
                new_ind = Some(ind);
                break;
            }
        }
        if let Some(ind) = new_ind {
            recorders[ind].0 = end;
            recorders[ind].1 = channel;
        } else {
            recorders.push((end, channel));
        }
    }
    println!("{}", recorders.len());
}


Measured memory_bytes: 8444
#include<bits/stdc++.h>
typedef long long ll;
const int maxn=1e6+9;
const int mod=1e9+7;
using namespace std;
int main()
{
	ll n,base=100,cnt=0;
	scanf("%lld",&n);
	while(1)
	{
		cnt++;
		base=base+base/100;
		if(base>=n)
		{
			printf("%lld\n",cnt);break;
		}
	}
}

Measured memory_bytes: 3736
class Tree
  class Node
    attr_accessor :value, :parent, :left, :right

    def initialize(value, parent=nil)
      @value = value
      @parent = parent
      @left = nil
      @right = nil
    end

    def ==(other)
      @value == other.value
    end

    def insert(value)
      if value < @value
        if @left
          @left.insert(value)
        else
          @left = Node.new(value, self)
        end
      else
        if @right
          @right.insert(value)
        else
          @right = Node.new(value, self)
        end
      end
    end

    def find(value)
      return self if value == @value

      if value < @value
        return @left && @left.find(value)
      else
        return @right && @right.find(value)
      end
    end

    def visit_inorder(&block)
      @left.visit_inorder(&block) if @left
      block.call(self) if block
      @right.visit_inorder(&block) if @right
    end

    def visit_preorder(&block)
      block.call(self) if block
      @left.visit_preorder(&block) if @left
      @right.visit_preorder(&block) if @right
    end
  end

  def initialize
    @root = nil
  end

  def insert(value)
    if @root
      @root.insert(value)
    else
      @root = Node.new(value)
    end
  end

  def include?(value)
    return false unless @root

    !!@root.find(value)
  end

  def delete(value)
    return false unless @root

    target = @root.find(value)
    return false unless target

    if target.left && target.right
      min_node = target.right
      while min_node.left
        min_node = min_node.left
      end

      parent = min_node.parent

      if parent == target
        right = min_node.right
        parent.right = right
        right.parent = parent if right
        min_node.parent = min_node.right = nil
      else
        right = min_node.right
        parent.left = right
        right.parent = parent if right
        min_node.parent = min_node.right = nil
      end

      target.value = min_node.value
    else
      parent = target.parent
      child = target.left || target.right

      if parent
        child.parent = parent if child

        if parent.left == target
          parent.left = child
        else
          parent.right = child
        end
      else
        @root = child
      end

      target.parent = target.left = target.right = nil
    end

    true
  end

  def visit_inorder(&block)
    @root.visit_inorder(&block) if @root
  end

  def visit_preorder(&block)
    @root.visit_preorder(&block) if @root
  end
end

if $PROGRAM_NAME == __FILE__
  n = gets.to_i

  tree = Tree.new

  n.times do
    command, value = gets.chomp.split

    value = value.to_i if value

    case command
    when 'insert'
      tree.insert(value)
    when 'find'
      puts tree.include?(value) ? 'yes' : 'no'
    when 'delete'
      tree.delete(value)
    when 'print'
      tree.visit_inorder do |node|
        print " #{node.value}"
      end
      puts

      tree.visit_preorder do |node|
        print " #{node.value}"
      end
      puts
    else
      raise "unknown command: #{command}"
    end
  end
end

Measured memory_bytes: 66308
flag = 1
a, b = {},{}
def loop():
    global flag
    while True:
        try:
            c, d = map(int, input().split(','))
        except:
            flag = 0
            break
        if flag:
            a[c] = 1 if c not in a else a[c]+1
        else:
            b[c] = 1 if c not in b else b[c]+1

loop()
loop()
for k in sorted(a.keys()):
    if b.get(k, 0):
        tmp = a[k]+b[k]
        if tmp > 1:
            print(k, tmp)

Measured memory_bytes: 7412
/*⠄⢰⣧⣼⣯⠄⣸⣠⣶⣶⣦⣾⠄⠄⠄⠄⡀⠄⢀⣿⣿⠄⠄⠄⢸⡇⠄⠄
⠄⠄⠄⣾⣿⠿⠿⠶⠿⢿⣿⣿⣿⣿⣦⣤⣄⢀⡅⢠⣾⣛⡉⠄⠄⠄⠸⢀⣿⠄
⠄⠄⢀⡋⣡⣴⣶⣶⡀⠄⠄⠙⢿⣿⣿⣿⣿⣿⣴⣿⣿⣿⢃⣤⣄⣀⣥⣿⣿⠄
⠄⠄⢸⣇⠻⣿⣿⣿⣧⣀⢀⣠⡌⢻⣿⣿⣿⣿⣿⣿⣿⣿⣿⠿⠿⠿⣿⣿⣿⠄
⠄⢀⢸⣿⣷⣤⣤⣤⣬⣙⣛⢿⣿⣿⣿⣿⣿⣿⡿⣿⣿⡍⠄⠄⢀⣤⣄⠉⠋⣰
⠄⣼⣖⣿⣿⣿⣿⣿⣿⣿⣿⣿⢿⣿⣿⣿⣿⣿⢇⣿⣿⡷⠶⠶⢿⣿⣿⠇⢀⣤
⠘⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣽⣿⣿⣿⡇⣿⣿⣿⣿⣿⣿⣷⣶⣥⣴⣿⡗
⢀⠈⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡟⠄
⢸⣿⣦⣌⣛⣻⣿⣿⣧⠙⠛⠛⡭⠅⠒⠦⠭⣭⡻⣿⣿⣿⣿⣿⣿⣿⣿⡿⠃⠄
⠘⣿⣿⣿⣿⣿⣿⣿⣿⡆⠄⠄⠄⠄⠄⠄⠄⠄⠹⠈⢋⣽⣿⣿⣿⣿⣵⣾⠃⠄
⠄⠘⣿⣿⣿⣿⣿⣿⣿⣿⠄⣴⣿⣶⣄⠄⣴⣶⠄⢀⣾⣿⣿⣿⣿⣿⣿⠃⠄⠄
⠄⠄⠈⠻⣿⣿⣿⣿⣿⣿⡄⢻⣿⣿⣿⠄⣿⣿⡀⣾⣿⣿⣿⣿⣛⠛⠁⠄⠄⠄
⠄⠄⠄⠄⠈⠛⢿⣿⣿⣿⠁⠞⢿⣿⣿⡄⢿⣿⡇⣸⣿⣿⠿⠛⠁⠄⠄⠄⠄⠄
⠄⠄⠄⠄⠄⠄⠄⠉⠻⣿⣿⣾⣦⡙⠻⣷⣾⣿⠃⠿⠋⠁⠄⠄⠄⠄⠄⢀⣠⣴
⣿⣿⣿⣶⣶⣮⣥⣒⠲⢮⣝⡿⣿⣿⡆⣿⡿⠃⠄⠄⠄⠄⠄⠄⠄⣠⣴⣿*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;
#define ll long long
#define ii pair<ll,ll>
#define iii pair<ii,ll>
#define fi first
#define se second
#define endl '\n'
#define debug(x) cout << #x << " is " << x << endl;

#define rep(x,start,end) for(auto x=(start)-((start)>(end));x!=(end)-((start)>(end));((start)<(end)?x++:x--))
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()

ll MAX(ll a){return a;}
ll MIN(ll a){return a;}
template<typename... Args>
ll MAX(ll a,Args... args){return max(a,MAX(args...));}
template<typename... Args>
ll MIN(ll a,Args... args){return min(a,MIN(args...));}

#define indexed_set tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>

mt19937 rng(chrono::system_clock::now().time_since_epoch().count());


int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	ll n;
	cin>>n;
	
	string ans;
	
	while (n){
		if (n%26) ans+=(char)('a'+(n-1)%26);
		else ans+='z',n-=26;
		n/=26;	
	}
	
	reverse(all(ans));
	cout<<ans<<endl;
}


Measured memory_bytes: 3616
while True:
    n=int(input())
    if n==0:
        break
    for i in range(n):
        s,e,k=map(int,input().split())
        if k==100 or s==100 or e==100:
            print("A")
        elif (s+e)/2 >=90:
            print("A")
        elif (s+k+e)/3 >=80:
            print("A")
        elif (s+k+e)/3 >=70:
            print("B")
        elif (s+k+e)/3 >=50 and s>=80:
            print("B")
        elif (s+k+e)/3 >=50 and e>=80:
            print("B")
        else:
            print("C")
            


Measured memory_bytes: 5612
fn main() {
    let n = read::<usize>();

    let mut v: Vec<usize> = vec![0; n];
    for i in 0..n {
        let mut x = i + 1;
        let mut cnt = 0;

        while x % 2 == 0 {
            cnt += 1;
            x /= 2;
        }

        v[i] = cnt;
    }

    let mut max = 0;
    let mut ret = 0;
    for i in 0..n {
        if max <= v[i] {
            max = v[i];
            ret = i + 1;
        }
    }
    println!("{}", ret);
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().parse().ok().unwrap()
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector < long long > vll;
typedef pair < long long, long long > pll;
typedef pair < int, int > pii;
typedef vector < int > vi;
typedef vector<vector<int>> vvi;
#define deb(x) cout << #x << " : " << x << endl
#define deb2(x , y) cout << #x << " : " << x << " , "<< #y << " : " << y << endl
#define debv(x) for(auto i=x.begin();i!=x.end();i++) cout<<*i<<' ';cout<<endl
#define debp(x) for(auto i=x.begin();i!=x.end();i++) cout<<i->first<<':'<<i->second<<' ';cout<<endl
#define debvv(x) for(auto j=x.begin();j!=x.end();j++) { for(auto i=(*j).begin();i!=(*j).end();i++) cout<<*i<<' ';cout<<endl;}cout<<endl
#define rsz(x,n) x.clear(); x.resize(n)
#define rrsz(x,a,n) x.clear(); x.resize(n,a)
#define rep(i,n) for(int i = 0; i < n; i++)
#define reps(i,a,n) for(int i = a; i < n; i++)
#define wt while(true)
#define all(x) x.begin(),x.end()
#define pb push_back
#define csl ios_base::sync_with_stdio(false); cin.tie(NULL)
#define INF (1e9 + 7)
#define endl '\n'
int mod=1e9+7;

void solve() {
	int n;
	cin>>n;
	vector<double> prob(n);
	vector<vector<double>> chance(n+1,vector<double>(n+1,0));
	rep(i,n){
		cin>>prob[i];
	}
	chance[0][0]=1;
	reps(i,1,n+1){
		rep(j,n+1){
			if(j==0){
				chance[i][j]=(1-prob[i-1])*chance[i-1][j];
			}
			else{
				chance[i][j]=chance[i-1][j]*(1-prob[i-1]);
				chance[i][j]+=chance[i-1][j-1]*prob[i-1];
			}
		}
	}
  	//debvv(chance);
	double ans=0;
	reps(i,n/2+1,n+1){
		ans+=chance[n][i];
	}
	cout<<ans<<endl;
}

int main() {
	csl;
	int testcase=1;
  	cout.precision(10);
//	cin >> testcase;
	for (int i = 0; i < testcase; i++) {
		solve();
	}
	return 0;
}



Measured memory_bytes: 73672
import sys

read = sys.stdin.read
readline = sys.stdin.readline
n, m = map(int, readline().split())
ab = map(int, read().split())
ab = sorted(zip(ab, ab))

ans = 0
for a, b in ab:
    drink = min(b, m)
    ans += a * drink
    m -= drink
    if m <= 0:
        break
print(ans)


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

int main(){
    int N;cin>>N;
    vector<long long >A(N);
    for(int i=0;i<N;i++)cin>>A[i],A[i]*=2;
    long long offset=0;
    for(int i=0;i<N;i++)offset=A[i]-offset;
    long long x=offset/2;

    long long cur=x;
    for(int i=0;i<N;i++){
        cout<<cur<<" ";
        cur=A[i]-cur;
    }
    cout<<endl;
}

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

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<bool> VB;
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<char> VC;
typedef vector<VC> VVC;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a)*(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define LB lower_bound
#define UB upper_bound

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL INF = 1e9;
const LL MOD = 1e9+7;

//other
//-------------------------------------------
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define FI first
#define SE second

//memo
// setprecision()

LL Gcd(LL a, LL b) {
  if (a < b) {
    return Gcd(b,a);
  }
  if (b == 0) {
    return a;
  }
  else {
    return Gcd(b,a%b);
  }
}

LL Lcm(LL a, LL b) {
  LL abd = Gcd(a,b);
  LL x = a / abd, y = b / abd;
  
  return x*y*abd;
}


LL RepSqu(LL N, LL P, LL M) {
  if(P == 0) {
    return 1;
  }
  if(P%2 == 0) {
    LL t = RepSqu(N, P/2, M);
    return t*t % M;
  }
  return (N * RepSqu(N, P-1, M)) % M;
}


int main() {
  
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int N;
  cin >> N;
  N++;
  VI A(N,0);
  
  REP(i,N-1){
    cin >> A.at(i+1);
  }
  
  SORT(A);
  
  REP(i,N){
    if(i%2){
      continue;
    }
    A.at(i) = 24 - A.at(i);
  }
  
  SORT(A);
  
  int del =A.at(N-1) - A.at(0);
  chmin(del,24-del);
  
  REP(i,N-1){
    chmin(del, A.at(i+1)-A.at(i));
  }
  
  cout << del << endl;
  
  return 0;
}

Measured memory_bytes: 256
# 5
# 5 3 2 4 1

# j = 0
# 

n = int(input())
arr = [ int(i) for i in input().split(" ")]

ans = 0

for i in range(len(arr) - 1):
  j = len(arr)-1
  for _ in range(len(arr)-i-1):
    if arr[j-1] > arr[j]:
      b = max(arr[j], arr[j-1])
      s = min(arr[j], arr[j-1])
      arr[j] = b
      arr[j-1] = s
      ans += 1
    j = j - 1
    
print(" ".join([str(i) for i in arr]))
print(ans)




Measured memory_bytes: 5608
#include<stdio.h>

int main(){
    int W,H,x,y,r;
    scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
    if(x-r>=0&&x+r<=W&&y-r>=0&&y+r<=H) printf("Yes\n");
    else printf("No\n");
    return 0;
}


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


int main(void) {
    int a, b, ans = 0;
    cin >> a >> b;
    for (int i = a; i <= b; i++) {
        if (i/10000 == i%10 && i/1000%10 == i/10%10) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(2147483647)
INF = 1 << 60
MOD = 10**9 + 7 # 998244353
input = lambda:sys.stdin.readline().rstrip()
def resolve():
    m, n, x = map(int, input().split())
    CA = [list(map(int, input().split())) for _ in range(m)]

    res = INF
    for U in range(1 << m): # 使う参考書を全探索
        cost = 0
        total = [0] * n
        for i in range(m):
            if (U >> i) & 1 == 0:
                continue
            c, *A = CA[i]
            cost += c
            for j, a in enumerate(A):
                total[j] += a
        if min(total) >= x:
            res = min(res, cost)

    if res == INF:
        res = -1
    print(res)
resolve()

Measured memory_bytes: 69096
import sys,collections,math;sys.setrecursionlimit(10**7)
from operator import itemgetter;
def Is(): return [int(x) for x in sys.stdin.readline().split()]
def Ss(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

N,M = Is()
lis = []
for i in range(M):
    lis.append([i]+Is())
t = sorted(lis,key=itemgetter(1,2))
x,p = 0,1
for i in range(M):
    if p == t[i][1]:
        x += 1
        t[i] += [p,x]
    else:
        p = t[i][1]
        x = 1
        t[i] += [p,x]
t = sorted(t,key=itemgetter(0))
for e in t:
    print( (6-len(str(e[3])))*"0" + str(e[3]) + (6-len(str(e[4])))*"0" + str(e[4]))

Measured memory_bytes: 39544
def val(num):
    print(num, flush=True)
    sex = input()
    if sex == "Vacant":
        exit(0)
    return 1 if sex == "Male" else 0


n = int(input())

l_sex = val(0)
r_sex = val(n - 1)

left = 0
right = n - 1

while left < right:
    mid = (left + right) // 2
    sex = val(mid)
    if (mid - left) % 2 == 0 and sex != l_sex:
        right = mid
        r_sex = sex
    elif (mid - left) % 2 == 1 and sex == l_sex:
        right = mid
        r_sex = sex
    else:
        left = mid
        l_sex = sex

print(left, flush=True)
exit(0)


Measured memory_bytes: 62180
#include <iostream>
#include <cstdio>
#include <cmath>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <vector>
#include <memory.h>
#include <algorithm>
#define case        printf("Case %d: ",++tc);
#define read        freopen("tst.txt","r",stdin)
#define write       freopen("out.txt","w",stdout)
typedef long long ll;
using namespace std;
#define pi acos(-1)
#define mx 100001
ll dp[101][mx],val[102],wt[102],n,w;


main(){
ll t,tc = 0;

scanf("%lld%lld",&n,&w);
for(ll i = 0; i<n; i++)    scanf("%lld%lld",wt+i,val+i);
for(ll i = 0; i<=n; i++){
    for(ll j = 0; j<=w; j++){
        if(i==0 || j==0)    dp[i][j] = 0;
        else if(wt[i-1]<=j) dp[i][j] = max(val[i-1]+dp[i-1][j-wt[i-1]],dp[i-1][j]);
        else dp[i][j] = dp[i-1][j];
    }
}
printf("%lld\n",dp[n][w]);

return 0;
}



Measured memory_bytes: 79104
using System;

namespace ABC051
{
    class Program
    {
        static void Main(string[] args)
        {
            solve();
        }
        static void solve()
        {
            string[] input = Console.ReadLine().Split(' ');
            int sx = int.Parse(input[0]);
            int sy = int.Parse(input[1]);
            int tx = int.Parse(input[2]);
            int ty = int.Parse(input[3]);

            int w, h;
            w = tx - sx;
            h = ty - sy;
            string ans = "";
            ans += new string('R', w);
            ans += new string('U', h);
            ans += new string('L', w);
            ans += new string('D', h);

            ans += new string('D', 1);
            ans += new string('R', w + 1);
            ans += new string('U', h + 1);
            ans += new string('L', 1);
            ans += new string('U', 1);
            ans += new string('L', w + 1);
            ans += new string('D', h + 1);
            ans += new string('R', 1);

            Console.WriteLine(ans);


        }




    }


}


Measured memory_bytes: 2904
using System;
class Program{
	static void Main(){
		long[] s=Array.ConvertAll(Console.ReadLine().Split(),long.Parse);
		long m=(long)(Math.Sqrt(s[1])+1);
		long ans=1;
		for(long i=m;i>0;i--){
			if(s[1]%i==0){
				if(s[0]<=s[1]/i){ans=Math.Max(ans,i);}
				if(s[0]<=i){ans=Math.Max(ans,s[1]/i);}
			}
		}
		Console.WriteLine(ans);
	}
}

Measured memory_bytes: 13268