akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n,m;
vector<int>to[100010],ver;
bool ok[100010];

void dfs(int v){
    ok[v]=true;
    for(int u:to[v]){
        if(ok[u])continue;
        dfs(u);
    }
    ver.push_back(v);
    return;
}

void Tsort(){
    rep(i,n)if(!ok[i])dfs(i);
    reverse(ver.begin(),ver.end());
    return;
}

int main(){
    cin>>n>>m;
    rep(i,n-1+m){
        int a,b;
        cin>>a>>b;
        to[a].push_back(b);
    }
    Tsort();
    vector<int>ans(n+1);
    rep(i,ver.size()){
        for(int u:to[ver[i]]){
            ans[u]=ver[i];
        }
    }
    for(int i=1; i<=n; ++i)cout<<ans[i]<<endl;
}

Measured memory_bytes: 12608
s = input()
cnt = len(s)

if s[0] == "9":
    if s[1:] == "9"*(cnt-1):
        print(9*cnt)
    else:
        print(8+9*(cnt-1))
else:
    if s[1:] == "9"*(cnt-1):
        print(int(s[0]) + 9*(cnt-1))
    else:
        print((int(s[0])-1) + 9*(cnt-1))

Measured memory_bytes: 8888
/*******************************
 * written by Koki Riho
 * Rih0z https://github.com/Rih0z
 *******************************/

#include<iostream>
#include<map>
#include<vector>
#include<string>
#include<numeric>
#include<algorithm>

#define DEBUG false

#define FOR(i , a, b) for(size_t i = a ; i < b ; i++ )
#define REP(i,b) FOR(i , 0 , b)
#define RFOR(i,a,b) for(size_t i = a-1 ; i >= b ; i--)
#define RREP(i,a) RFOR(i,a,0)



typedef long long ll;
using namespace std;

int scanInt(void);
string scanString(void);

void scanLlArr(ll *a , int n);
void scanCharArr(char *string);

void printInt(int p);
void printLlArr(ll *a);
void printCharArr(char *string);


void perSum(ll *a , ll *sum ,int n);

/*************Global variable  **************/
int N ;
string S ;
string ans = "AC";
char str[26];
std::map<char,int> M ;
/*******************************/

int main(){
  if (DEBUG){
    std::printf("******debug mode********\n");


    char a = 'a';// a~z 97 ~ 123
    char A = 'A' ;//A~Z  65 ~91
    char c = 'c' ;
    char C = 'C' ;
    printf("a = %d A = %d\n c = %d C = %d\n",a,A,c,C);
  }
  int cn = 1000;
  cin >> S ;
  if(S[0] != 'A')
    ans = "WA";
  for(int i = 2 ; i < S.length()-1 ; i++ )
  {
    if(S[i] == 'C'){
     cn = i ;
     break;
    }
  }
  if (cn == 1000){
    ans = "WA";
  }

  for(int i = 1 ; i < S.length() ; i++){
    if(i != cn && S[i] < 92){
      ans = "WA";
      break;
    } 
  }
  cout << ans << endl;
  if (DEBUG){
    std::printf("******debug********\n");

    std::printf("******debug********\n");
  }
  return 0 ;
}

//各地点までの部分和を計算する
void perSum(ll *a , ll *sum ,int n){
  int i ;
  sum[0] = a[0];
  for(i = 1 ; i < n ; i++){
    sum[i] = a[i] + sum[i-1];
  }

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

using namespace std;

#define rep(i, a, b) for (int i = a; i < b; i++)
#define rrep(i, a, b) for (int i = a; i <= b; i++)
#define revrep(i, s) for (int i = s-1; i > 0; i--)
#define revrrep(i, s) for (int i = s-1; i >= 0; i--)
#define all(a)  begin((a)),end((a))
#define uniq(c) (c).erase(unique(all((c))), end((c)))

int main()
{
    int r; cin >> r;
    cout << 3 * r * r << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
	int n;
	cin>>n;
	int a[100000];
	int b[100000];
	for(int i=0;i<n;i++){
		cin>>a[i];
		b[i]=a[i];
	}
	sort(b,b+n,greater<int>());
	int m=1000010000;
	int ans;
	for(int i=0;i<n;i++){
		int x=abs(b[0]/2-a[i]);
		if(x<m){
			m=x;
			ans=a[i];
		}
	}	
	if(ans==b[0]){
		ans=0;
	}
	cout<<b[0]<<' '<<ans<<endl;
}

Measured memory_bytes: 1024
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

# N = 50で固定して考える
# K = 151のとき、左端で3回、それ以外で2回取れるようにするのを目標にする
# すると、左端には、98回の増加があり
# それ以外には99回の増加があることがわかる
# これを加味して初期の値を決めればよい

import array
from bisect import *
from collections import *
import fractions
import heapq 
from itertools import *
import math
import random
import re
import string
import sys
import numpy as np

def solve_d(k):
    if k == 0:
        return [0] * 50

    if k <= 50:
        arr = []
        for i in range(k):
            arr.append(50 - i)
        for i in range(k, 50):
            arr.append(0)
        return arr
    else:
        arr = list(reversed(range(1, 51)))
        base = (k - 1) // 50
        for i in range(50):
            arr[i] += base - 1
        for i in range(k - base * 50):
            arr[i] += 1
        return arr

K = int(input())
print(50)
print(*solve_d(K))


##################
# 以下、デバッグ用
##################

# 問題Eのコード
def solve_e(As):
    ans = 0
    N = len(As)
    As = As[:]
    while True:
        taken = [0] * N
        for i, a in enumerate(As):
            taken[i] = a // N
            As[i] -= taken[i] * N
        taken_sum = sum(taken)
        if taken_sum == 0:
            break
        ans += taken_sum
        for i in range(N):
            As[i] += (taken_sum - taken[i])
    return ans

# # 検算(E問題の結果を使う)
# for k in range(1000):
#     arr = solve_d(k)
#     arr_copied = arr.copy()
#     res = solve_e(arr_copied)
#     print("====\nk = ", k)
#     print("arr: ", arr)
#     if res != k:
#         print("error! res = ", res)
#         break




Measured memory_bytes: 21764
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <stdlib.h>
#include <ctype.h>
#include <math.h>

int e(int n)
{
	int r = 1;
	int i = 0;
	while (i < n)
	{
		r = r*(i+1);
		i++;
	}
	return(r);
}

long double met(int x1, int x2, int y1, int y2)
{
	int a = (x1-x2)*(x1-x2);
	int b = (y1-y2)*(y1-y2);
	return (sqrtl(a+b));
}
int main(void)
{
	int n;
	scanf("%d",&n);
	int *x, *y;
	x = (int *)calloc(n+1,sizeof(int));
	y = (int *)calloc(n+1,sizeof(int));
	int i = 0;
	int j = 0;
	while (i < n)
	{
		scanf("%d %d",&x[i],&y[i]);
		i++;
	}
	i = 0;
	long double r = 0;
	
	if (n == 2)
	{
		r = met(x[0],x[1],y[0],y[1]);
		printf("%.10Lf\n",r);
		return(0);
	}

	if (n == 3)
	{
		i = 0;
		j = 0;
		while (i < n)
		{
			j = 0;
			while (j < n)
			{
				r = r + met(x[i],x[j],y[i],y[j]);
				j++;
			}
			i++;
		}
		r = r / 3.0;
		printf("%.10Lf\n",r);
		return(0);
	}

	if (n <= 8)
	{
		i = 0;
		j = 0;
		while (i < n)
		{
			j = 0;
			while (j < n)
			{
				r = r + met(x[i],x[j],y[i],y[j]);
				j++;
			}
			i++;
		}
		r = r / (long double)n;
		printf("%.10Lf\n",r);
		return(0);
	}

	return(0);
}


Measured memory_bytes: 128
x1,y1 = map(int, input().split( ))
x2,y2 = map(int, input().split( ))
x3,y3 = map(int, input().split( ))

s2 = abs((x1-x3)*(y2-y3)-(x2-x3)*(y1-y3))

a = (x1-x2)**2+(y1-y2)**2
b = (x1-x3)**2+(y1-y3)**2
c =(x3-x2)**2+(y3-y2)**2

a **=(1/2)
b **=(1/2)
c **=(1/2)
mx = max(a,b,c)
h= s2/mx

h = s2/(a+b+c+2*h)
print(h)

Measured memory_bytes: 38256
n = gets.to_i
t,a = gets.split.map(&:to_i)
h = gets.split.map(&:to_i)
min = h.inject(:+)
j = 1
p = 1
h.each do |i|
  temp = t - i * 0.006
  if min > (a - temp).abs
    min = (a - temp).abs
    p = j
  end
  j += 1
end
puts p

Measured memory_bytes: 1788
/*
#include<stdio.h>
int main(void)
{
	int ct,num[4001],tanka[4001],kosu[4001],many[4001];
	while(scanf("%d",&ct)){
		if(ct==0){
			return 0;
		}
		for(int f1=0;f1<ct;f1++){
			scanf("%d %d %d",&num[f1],&tanka[f1],&kosu[f1]);
			many[f1]=tanka[f1]*kosu[f1];
		}
		for(int f1=0;f1<ct;f1++){
			for(int f2=0;f2<ct;f2++){
				if((num[f1]==num[f2])&&f1!=f2){
					many[f1]=many[f1]+many[f2];
					num[f2]=-1;
				}
			}
		}
		int flg=0;
		for(int f1=0;f1<ct;f1++){
			if(many[f1]>=1000000){
				printf("%d\n",num[f1]);
				flg=1;
			}
		}
		if(flg==0){
			printf("NA\n");
		}
	}
	return 0;
}
*/
#include <iostream>
#include <vector>
#include <cstring>
#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

typedef long long ll;
typedef pair<int, bool> IB;

struct P{
	int id;
	int tanka;
	int kosuu;
};

ll shain[4001];
bool used[4001];
bool more[4001];

int main()
{
	int n;

	while (cin >> n && n ){
		memset (shain, 0LL, sizeof (shain ) );
		memset (used, false, sizeof (used ) );
		memset (more, false, sizeof (more ) );
		vector<P> data (n );

		rep (i, n )
			cin >> data[i].id >> data[i].tanka >> data[i].kosuu;

		rep (i, n ){
			ll total = (ll)data[i].tanka*(ll)data[i].kosuu;
			shain[data[i].id] += total;
		} // end if

		for (int i = 1; i <= 4000; i++ )
			if (shain[i] >= 1000000LL )
				more[i] = true;

		bool found = false;
		rep (i, n ){
			if (more[data[i].id] && !used[data[i].id] ){
				cout << data[i].id << endl;
				used[data[i].id] = true;
				if (!found )
					found = true;
			} // end if
		} // end rep

		if (!found )
			cout << "NA" << endl;
	} // end loop
		
	return 0;
}

Measured memory_bytes: 1252
#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, m, n) for(int i=(m); i<(n); ++i)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define Cout(x) cout << (x) << endl
#define dump(x) cerr << #x << " = " << (x) << endl;
typedef long long LL;
typedef vector<int> VI;
typedef vector<long long> VL;
typedef vector<string> VS;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
const int inf = (int)1e9;
const long long mod = (long long)1e9 + 7;
const double pi = acos(-1.0);

template <class T>void Sort(vector<T> & a) { sort(a.begin(), a.end()); }
template <class T>void ReSort(vector<T>& a) { sort(a.rbegin(), a.rend()); }
template <class T>void Reverse(vector<T>& a) { reverse(a.begin(), a.end()); }
template <class T>void Unique(vector<T>& a) { a.erase(unique(a.begin(), a.end()), a.end()); }
template <class T>T Sum(vector<T> a, T init = 0) { return accumulate(a.begin(), a.end(), init); }

//INPUT//
void CINPUT() {}
template<class H, class ...T> void CINPUT(H&& h, T&& ...t) { cin >> h; CINPUT(forward<T>(t)...); }
#define in(...) int __VA_ARGS__; CINPUT(__VA_ARGS__);
#define In(T,...) T __VA_ARGS__; CINPUT(__VA_ARGS__);
#define Vin(T,name,n) int n; cin>>n; vector<T> name(n); rep(i,n)cin>>name[i];
#define VIn(T,name,n) vector<T> name(n); rep(i,n)cin>>name[i];
#define VIn2(T,name,name2,n) vector<T> name(n),name2(n); rep(i,n)cin>>name[i]>>name2[i];

//OUTPUT//
void print() { cout << endl; }
template <class H> void print(H&& h) { cout << h << endl; }
template <class H, class... T> void print(H&& h, T&& ... t) { cout << h << " "; print(forward<T>(t)...); }
template<class T>void out(T n) { cout << n << endl; }
template<class T>void out(vector<T> a, string sep = " ", string end = "\n") { for (int i = 0; i < (int)a.size(); ++i)cout << a[i] << (i == (int)a.size() - 1 ? end : sep); }
void yes(bool f) { puts(f ? "yes" : "no"); }
void Yes(bool f) { puts(f ? "Yes" : "No"); }
void YES(bool f) { puts(f ? "YES" : "NO"); }
void poss(bool f) { puts(f ? "possible" : "impossible"); }
void Poss(bool f) { puts(f ? "Possible" : "Impossible"); }
void POSS(bool f) { puts(f ? "POSSIBLE" : "IMPOSSIBLE"); }

int main() {
	in(n, h, w);
	VIn2(int, a, b, n);
	int ans = 0;
	rep(i, n) {
		ans += min(a[i] / h, b[i] / w);
	}
	out(ans);
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	Scanner sc = new Scanner(System.in);
	final int MOD = 1000000007;
	final int MAX = Integer.MAX_VALUE;
	final long LMAX = Long.MAX_VALUE;
	int LEN = (int)1e6 + 1;
	void doIt() {
		int N = sc.nextInt();
		int K = sc.nextInt();
		int cnt = 0;
		while(N > 0) {
			N /= K;
			cnt++;
		}
		System.out.println(cnt);
	}

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

}


Measured memory_bytes: 22740
#include<bits/stdc++.h>
#define rep(i, l, r) for(int i = (l), i##end = (r);i <= i##end;++i)
using std::cin; using std::cout;
const int maxn = 300200;
typedef long long ll;
const int mod = 998244353;
inline ll pow(ll a,int b,int ans = 1) {
	for(;b;b >>= 1,a = a * a % mod) if(b & 1)
		ans = ans * a % mod;
	return ans;
}
inline ll inverse(int x){ return pow(x, mod - 2); }
int w, h, n;
int x[maxn], y[maxn];
const int N = 3e5 + 5;
int tree[maxn << 2], tag[maxn << 2];
inline void put(int cur,int v) {
	tree[cur] += v, tag[cur] += v;
}
inline void down(int cur) {
	put(cur << 1, tag[cur]);
	put(cur << 1 | 1, tag[cur]);
	tag[cur] = 0;
}
inline void add(int ql,int qr,int v,int cur = 1,int l = 0,int r = N) {
	if(ql <= l && r <= qr) return put(cur, v);
	int mid = l + r >> 1; down(cur);
	if(ql <= mid) add(ql, qr, v, cur << 1, l, mid);
	if(mid < qr) add(ql, qr, v, cur << 1 | 1, mid + 1, r);
	tree[cur] = std::max(tree[cur << 1], tree[cur << 1 | 1]);
}
inline int qry(int ql,int qr,int cur = 1,int l = 0,int r = N) {
	if(ql <= l && r <= qr) return tree[cur];
	int mid = l + r >> 1, ans = -1e9; down(cur);
	if(ql <= mid) ans = std::max(ans, qry(ql, qr, cur << 1, l, mid));
	if(mid < qr) ans = std::max(ans, qry(ql, qr, cur << 1 | 1, mid + 1, r));
	return ans;
}
std::pair<int, int> a[maxn];
inline void build(int cur = 1,int l = 0,int r = N) {
	tag[cur] = 0;
	if(l == r) return void(tree[cur] = -a[l].first);
	int mid = l + r >> 1;
	build(cur << 1, l, mid);
	build(cur << 1 | 1, mid + 1, r);
	tree[cur] = std::max(tree[cur << 1], tree[cur << 1 | 1]);
}
inline int calc(int * x,int * y,int A) {
	std::vector<std::pair<int, int>> vector;
	rep(i, 1, n) {
		a[i] = std::pair<int, int>(x[i], y[i]);
	}
	std::sort(a + 1,a + n + 1);
	build();
	static int stack0[maxn], stack1[maxn];
	int top0 = 0, top1 = 0, ans = 0;
	const int W = A / 2;
	for(int i = 1;i <= n;++i) {
		if(i > 1) {
			add(stack0[top0], i - 1, A);
			ans = std::max(ans, a[i].first + qry(0, i - 2));
			add(stack0[top0], i - 1, -A);
		}
		if(a[i].second >= W) {
			for(;top0 && a[stack0[top0]].second > a[i].second;--top0) 
				add(stack0[top0 - 1], stack0[top0] - 1, - a[stack0[top0]].second);
			add(stack0[top0], i - 1, a[i].second), stack0[++top0] = i;
		} else {
			for(;top1 && a[stack1[top1]].second < a[i].second;--top1)
				add(stack1[top1 - 1], stack1[top1] - 1, a[stack1[top1]].second);
			add(stack1[top1], i - 1, -a[i].second), stack1[++top1] = i;
		}
		ans = std::max(ans, A + a[i].first - a[i - 1].first);
	}
	return ans << 1;
}
int main() {
	std::ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> w >> h >> n;
	rep(i, 1, n) {
		std::cin >> x[i] >> y[i];
	}
	x[++n] = w, y[++n] = h;
	std::cout << std::max(calc(x, y, h), calc(y, x, w)) << '\n';
}


Measured memory_bytes: 16640
#include<stdio.h>
#include<math.h>
int main(){
int i,n,t,k=0,d=0,l=0;
int A[100000][2];
A[0][0]=1000000000;A[0][1]=0;
scanf("%d%d",&n,&t);
for(i=0;i<n;i++){
  scanf("%d",&t);
  if(A[k][0]>=t){k++;A[k][0]=A[k][1]=t;}
  if(A[k][1]<t)A[k][1]=t;
}
for(i=0;i<k+1;i++){
  if(d<A[i][1]-A[i][0]){d=A[i][1]-A[i][0];l=0;}
  if(d==A[i][1]-A[i][0])l++;
}
printf("%d",l);
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef double dd;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;

const int mx=1e6+11;
const double PI = acos(-1);
#define MOD 1000000007

#define nl '\n'
#define pb push_back
#define F first
#define S second
#define I insert
#define mp make_pair

#define sz(x) x.size()
#define tt int t; cin>>t; while(t--)
#define lo(i,a,b) for(int i=a;i<b;i++)
#define rlo(i,n) for(int i=n-1;i>=0;i--)
#define be(a) (a).begin(),(a).end()
#define rbe(a) (a).rbegin(),(a).rend()
#define mem(a,b) memset(a,b,sizeof(a))
#define pr(a) {for(auto x:a)cout<<x<<" ";cout<<nl;}

#define su ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define frac cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);

#define dbg(args...) do {cerr << #args << " : "; faltu(args); } while(0)
void faltu () {            cerr << endl;}
template < typename T, typename ... hello>void faltu( T arg, const hello &... rest) {cerr << arg << ' ';faltu(rest...);}

void f()
{
  int a[4];
  cin>>a[0]>>a[1]>>a[2];
  sort(a,a+3);
  cout<<a[2]-a[0]<<nl;
}

int main()
{
    su;
    f();
    return 0;
}


Measured memory_bytes: 3656
use proconio::*;
use proconio::marker::*;
use std::cmp::*;

pub trait MoOperator {
    type Value;
    type Query;
    type Answer;
    fn init(&mut self);
    fn insert(&mut self, v: &Self::Value);
    fn delete(&mut self, v: &Self::Value);
    fn answer(&mut self, q: Self::Query) -> Self::Answer;
    fn solve(
        &mut self,
        array: &[Self::Value],
        mut query: Vec<(usize, usize, Self::Query)>,
        answer: &mut [Self::Answer],
    ) {
        let state = self;
        let size = array.len();
        assert!(query.len() <= answer.len());
        assert!(query.iter().all(|p| p.0 < p.1 && p.1 <= size));
        if query.is_empty() {
            return;
        }
        let batch = (size as f64 / (query.len() as f64).sqrt()).ceil() as usize;
        let mut q = vec![];
        std::mem::swap(&mut q, &mut query);
        let mut query = (0..(size / batch + 1)).map(|_| vec![]).collect::<Vec<_>>();
        for (i, (l, r, op)) in q.into_iter().enumerate() {
            query[l / batch].push((r, l, i, op));
        }
        state.init();
        let mut x = 0;
        let mut y = 0;
        for (i, mut query) in query.into_iter().enumerate() {
            query.sort_unstable_by_key(|p| p.0);
            if i & 1 == 1 {
                query.reverse();
            }
            for (r, l, k, op) in query.into_iter() {
                // 変更始まり
                for v in array[min(x, l)..x].iter().rev() {
                    state.insert(v);
                }
                for v in array[min(y, r)..r].iter() {
                    state.insert(v);
                }
                for v in array[min(x, l)..l].iter() {
                    state.delete(v);
                }
                for v in array[min(y, r)..y].iter().rev() {
                    state.delete(v);
                }
                x = l;
                y = r;
                // 変更終わり
                answer[k] = state.answer(op);
            }
        }
    }
}

struct State {
    cnt: Vec<u32>,
    ans: usize,
}

impl MoOperator for State {
    type Value = usize;
    type Query = ();
    type Answer = usize;
    fn init(&mut self) {
        for c in self.cnt.iter_mut() {
            *c = 0;
        }
        self.ans = 0;
    }
    fn insert(&mut self, x: &Self::Value) {
        let c = &mut self.cnt[*x];
        if *c == 0 {
            self.ans += 1;
        }
        *c += 1;
    }
    fn delete(&mut self, x: &Self::Value) {
        let c = &mut self.cnt[*x];
        if *c == 1 {
            self.ans -= 1;
        }
        *c -= 1;
    }
    fn answer(&mut self, _q: Self::Query) -> usize {
        self.ans
    }
}

#[fastout]
fn run() {
    input! {
        n: usize,
        q: usize,
        c: [Usize1; n],
        ask: [(Usize1, usize); q],
    }
    let ask: Vec<_> = ask.into_iter().map(|(l, r)| (l, r, ())).collect();
    let mut ans = vec![0; q];
    State {
        cnt: vec![0; n],
        ans: 0,
    }.solve(&c, ask, &mut ans);
    for a in ans {
        println!("{}", a);
    }
}

fn main() {
    run();
}


Measured memory_bytes: 41648
#include <iostream>
#include <cmath>

using namespace std;

int main() {
	int q = pow(10, 9) + 7;
	int N;
	int ans = 1;
	bool jud = true;
	int count[100000] = {};

	cin >> N;
	int A[N];

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

	for (int i = 1; i < N; i++) {
		if ((i % 2) == ((N + 1) % 2)) {
			if (count[i] == 2) {
				ans = ans * 2 % q;
			} else {
				jud = false;
				break;
			}
		} else if (count[i] != 0) {
			jud = false;
			break;
		}
	}

	if (jud && ((N % 2 == 1 && count[0] == 1) || (N % 2 == 0 && count[0] == 0))) {
		cout << ans << endl;
	} else {
		cout << 0 << endl;
	}

	return 0;
}

Measured memory_bytes: 1024
/**
 *    author:  nasimnoob
**/

#include<bits/stdc++.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<math.h>
using namespace std;

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

typedef long long                       ll;
typedef unsigned long long              ull;
typedef long double                     ld;

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

#define      cube(x)                    (x*x*x)
#define      sqr(x)                     (x*x)
#define      PI                         acos(-1)

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

int main()
{
    //string ;
    ll a;
    cin>>a;
    cout<<3*sqr(a)<<endl;
    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<list>

using namespace std;

int main(){
    int n, x = 0;
    cin >>n;
    string s;
    list<int> li;
    for(int i = 0; i < n; i++){
        cin >>s;
        if(s == "insert"){
            cin >>x;
            li.push_front(x);
        }else if(s == "delete"){
            cin >>x;
            for(auto itr = li.begin();itr != li.end(); itr++){
                if(*itr == x){
                    li.erase(itr);
                    break;
                }
            }
        }else if(s == "deleteFirst"){
            li.pop_front();
        }else if(s == "deleteLast"){
            li.pop_back();
        }
        //for(auto itr = li.begin(); itr != li.end(); itr++){
          //  cout << i + 1 << ":" << *itr << endl;
        //}
    }
    for(auto itr = li.begin(); itr != li.end(); itr++){
        if(itr != li.begin())cout << " ";
        cout << *itr;
    }
    cout << endl;

}



Measured memory_bytes: 34280
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <cstdint>
#include <vector>

using namespace std;
typedef long long ll;


ll ans,mx,mn=1e8,sum,cnt;
ll odd,even;
int main(){
	ll n;
	cin>>n;
	for(ll i=0; i<n; i++){
		ll a;
		cin>>a;
		if(a%2!=0) odd++;
		else even++;
	}
	if(odd%2==0) cout<<"YES";
	else cout<<"NO";
}


Measured memory_bytes: 256
#line 1 "abc159_c.cpp"
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define coutd(n) cout << fixed << setprecision(n)
#define ll long long int
#define vl vector<ll>
#define vi vector<int>
using P = std::pair<int, int>;
const int INF = 2147483647;
const ll MOD = 1000000007;

using namespace std;

int main() {
  long double l;
  cin >> l;
  coutd(10) << (l * l * l / 27) << endl;
}


Measured memory_bytes: 256
def func(n)
  if n.even?
    (n / 2)
  else
    (3 * n + 1)
  end
end

s = gets.chomp.to_i
n = 1_000_000

a = []
a[0] = s

flg = 0
(1..(n - 1)).each do |i|
  a[i] = func(a[i - 1])
  (0..(i - 1)).each do |j|
    if a[i] == a[j]
      puts (i + 1)
      flg = 1
      break
    end
  end
  break if flg == 1
end

Measured memory_bytes: 1788
#define LOCAL
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rrep(i, n) for(int i=(n-1); i>=0; --i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)
#define ALL(v) (v).begin(), (v).end()
#define memr(dp, val) memset(dp, val, sizeof(dp))
using namespace std;
typedef long long ll;
static const int INTINF = (INT_MAX >> 1); // 10^9 + 10^7
static const ll LLINF = (LLONG_MAX >> 1);
static const int MAX = 100001;
static const ll MOD = 1000000007;
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; }
template<class T> inline bool int_ceil(T a, T b) { T res = a / b; if(a % b != 0) res++; return res; }
template<typename T>
using min_priority_queue = priority_queue<T, vector<T>, greater<T> >;
string to_string(string s) { return '"' + s + '"'; }
string to_string(bool b) { return b ? "true" : "false"; }
template <size_t N> string to_string(bitset<N> bs) {
  string res;
  for (size_t i = 0; i < N; ++i) res += '0' + bs[i];
  return res;
}
string to_string(vector<bool> v) {
  string res = "{";
  for (bool e : v) res += to_string(e) + ", ";
  return res += "}";
}
template <class T, class U> string to_string(pair<T, U> p);
template <class C> string to_string(C c) {
  string res = "{";
  for (auto e : c) res += to_string(e) + ", ";
  return res += "}";
}
template <class T, class U> string to_string(pair<T, U> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
void debug() { cerr << '\n'; }
template <class Head, class... Tail> void debug(Head head, Tail... tail) {
  cerr << '\t' << to_string(head), debug(tail...);
}
#ifdef LOCAL
#define print(...) cerr << "[" << #__VA_ARGS__ << "]:", debug(__VA_ARGS__)
#else
#define print(...)
#endif

int main(int argc, const char * argv[]) {
	std::cout << std::fixed << std::setprecision(15);

	int n; cin >> n;
	int ok = 0;
	rep(i, n){
		int idx = i + 1;
		int a; cin >> a;
		if(idx % 2 == 1){
			if(a % 2 == 1){
				ok++;
			}
		}
	}
	cout << ok << endl;

	return 0;
}


Measured memory_bytes: 3592
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>
#include <chrono>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define FIND(s, e) ((s).find(e) != (s).end())
#define EB emplace_back
template<typename T>inline bool chmax(T &a, T b){return (a < b ? a = b, true : false);}
template<typename T>inline bool chmin(T &a, T b){return (a > b ? a = b, true : false);}

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;
const long double EPS = 1e-9;

const int MAX = 50;
int N, M;
LL a[MAX], b[MAX], c[MAX], d[MAX];

int main() {
	scanf("%d%d", &N, &M);
	REP(i, N) {
		scanf("%lld%lld", a + i, b + i);
	}
	REP(i, M) {
		scanf("%lld%lld", c + i, d + i);
	}
	REP(i, N) {
		LL buf = -1, dis = LLINF;
		REP(j, M) {
			if (llabs(a[i] - c[j]) + llabs(b[i] - d[j]) < dis) {
				dis = llabs(a[i] - c[j]) + llabs(b[i] - d[j]);
				buf = j;
			}
		}
		printf("%d\n", buf + 1);
	}
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
int main() {
	int n, m[100000], ma = 0,ma_p, mi;
	bool b = 0;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> m[i];
		if (ma < m[i]) {
			ma = m[i];
			ma_p = i;
		}
	}
	int s = ma / 2;
	for (int i = 0; i < n; i++) {
		if (ma_p == i) {
			continue;
		}
		else if (!b||abs(s - m[i]) < abs(s - mi)) {
			mi = m[i];
			b = true;
		}
	}
	cout << ma <<" "<< mi;
}

Measured memory_bytes: 640
# Dinic's algorithm
from collections import deque
class Dinic:
    def __init__(self, N):
        self.N = N
        self.G = [[] for i in range(N)]

    def add_edge(self, fr, to, cap):
        forward = [to, cap, None]#(行き先、容量、逆辺の参照)
        forward[2] = backward = [fr, 0, forward]
        self.G[fr].append(forward)
        self.G[to].append(backward)

    def add_multi_edge(self, v1, v2, cap1, cap2):
        edge1 = [v2, cap1, None]
        edge1[2] = edge2 = [v1, cap2, edge1]
        self.G[v1].append(edge1)
        self.G[v2].append(edge2)

    def bfs(self, s, t):
        self.level = level = [None]*self.N
        deq = deque([s])
        level[s] = 0
        G = self.G
        while deq:
            v = deq.popleft()
            lv = level[v] + 1
            for w, cap, _ in G[v]:
                if cap and level[w] is None:
                    level[w] = lv
                    deq.append(w)
        return level[t] is not None

    def dfs(self, v, t, f):
        if v == t:
            return f
        level = self.level
        for e in self.it[v]:
            w, cap, rev = e
            if cap and level[v] < level[w]:
                d = self.dfs(w, t, min(f, cap))
                if d:
                    e[1] -= d
                    rev[1] += d
                    return d
        return 0

    def flow(self, s, t):
        flow = 0
        INF = 10**9 + 7
        G = self.G
        while self.bfs(s, t):
            *self.it, = map(iter, self.G)
            f = INF
            while f:
                f = self.dfs(s, t, INF)
                flow += f
        return flow
N = int(input())
D = Dinic(N*2+2)
red = []
blue = []
for _ in range(N):
    a, b = map(int, input().split())
    red.append((a, b))
for _ in range(N):
    c, d = map(int, input().split())
    blue.append((c, d))
for i in range(N):
    D.add_edge(0, i+1, 1)
    D.add_edge(i+1+N, N*2+1, 1)
    for j in range(N):
        a, b = red[i]
        c, d = blue[j]
        if a<c and b<d:
            D.add_edge(i+1, j+1+N, 1)
print(D.flow(0, N*2+1))






Measured memory_bytes: 44652
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(os.Stdout)

	n := getNextInt(scanner)
	k := getNextInt(scanner)
	if k == 10 {
		fmt.Fprintln(writer, 0)

		writer.Flush()
		return
	}
	var disable [10]int
	dd := make([]int, k)

	for i := 0; i < k; i++ {
		dd[i] = getNextInt(scanner)
		disable[dd[i]] = 1
	}

	valid := false
	for ; valid == false; n++ {
		l := 0
		valid = true
		for i := 10000; i > 0; i /= 10 {
			if n/i > 0 {
				l = i
				break
			}
		}
		for i := l; i > 0; i /= 10 {
			if disable[(n%(i*10))/i] == 1 {
				valid = false
				break
			}
		}
	}
	fmt.Fprintln(writer, n-1)

	writer.Flush()
}


Measured memory_bytes: 640
N = int(input())

ac = 0
wa = 0
tle = 0
re = 0
for i in range(N):
  st = str(input())
  if(st == 'AC'):
    ac += 1
  elif(st == 'WA'):
    wa += 1
  elif(st == 'TLE'):
    tle += 1
  else:
    re += 1

print('AC x {}'.format(ac))
print('WA x {}'.format(wa))
print('TLE x {}'.format(tle))
print('RE x {}'.format(re))

Measured memory_bytes: 9212
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
using namespace std;

#define debug(x) cerr<<#x<<'='<<x<<'\n'

int main(void) {
	int n, a;
	cin>>n>>a;
	int now=1;
	while (n--) {
 	    now=min(now+a, now<<1);
 	}
 	cout<<now;
}

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

int main(){
    int N,K;
    int A;
    int snack[110]={0};

    cin >> N >> K;

    int i,j;
    int d;
    for(i=0; i<K; i++){
        cin >> d;
        for(j=0; j<d; j++){
            cin >> A;   
            if(snack[A-1]==0) snack[A-1]=1;
        }
    }

    int count=0;
    for(i=0; i<N; i++){
        if(snack[i]==0) count++;
    }

    cout << count << endl;

    return 0;
}

Measured memory_bytes: 3504
#include <iostream>

using namespace std;

int main()
{
    int n,a,c=0;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>a;
        if(a%2!=0&&i%2!=0)
            c++;

    }
    cout<<c;
    return 0;
}


Measured memory_bytes: 3588
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
using namespace std;


int n, m;

struct edge
{
	int to, cost;
};
const int INF = 1234567890;
using P = pair<int, int>;//first:cost,second:vertice
int dist[123456];
void dijkstra(vector<edge>graph[], int s)
{
	priority_queue<P, vector<P>, greater<P>>que;
	que.push({ 0,s });
	fill(dist, dist + n, INF);
	dist[s] = 0;
	while (!que.empty())
	{
		auto q = que.top();
		que.pop();
		int thd = q.first;
		int thv = q.second;
		if (thd > dist[thv])
		{
			continue;
		}
		for (auto ed : graph[thv])
		{
			if (dist[ed.to] > ed.cost + thd)
			{
				dist[ed.to] = ed.cost + thd;
				que.push({ dist[ed.to],ed.to });
			}
		}
	}
}

vector<edge>graph[123456];

int main(void)
{
	int s;
	scanf("%d %d %d", &n, &m, &s);
	for (int i = 0; i < m; ++i)
	{
		int a, b, c;
		scanf("%d %d %d", &a, &b, &c);
		graph[a].push_back({ b,c });
	}
	dijkstra(graph, s);
	for (int j = 0; j < n; ++j)
	{
		if (dist[j] == INF)printf("INF\n");
		else printf("%d\n", dist[j]);
	}
	return 0;
}

Measured memory_bytes: 13584
// This is the start of the template//
#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
#define ll long long int
#define vll vector<ll>
#define pb push_back
#define pll pair<ll,ll>
#define mp(a,b) make_pair(a,b)
#define ff first
#define ss second
#define tll tuple<ll,ll,ll>
#define mt make_tuple
void input(){
#ifndef ONLINE_JUDGE 
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout); 
#endif
}
#define mod 1000000007
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,a,b) for(ll i=a;i>=b;i--)
#define sortall(a) sort(a.begin(),a.end())
#define cases ll t; cin>>t; while(t--)
#define array(a,n) vll a(n); rep(i,0,n) cin>>a[i];
#define printall(a) rep(i,0,a.size()) cout<<a[i]<<" "; cout<<endl;
//this is the end of my template //
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
	input();
	ll n,curr,ans=1000,i=0,stock=0;
	cin>>n;
	array(a,n);
	while(i<n)
	{
		curr=a[i];
		ll j=i;
		while(j<n-1&&a[j]<=a[j+1])
			j++;
		if(j!=i)
		{
			stock=ans/a[i];
			ans=ans-a[i]*stock;

			ans+=a[j]*stock;
		}
		i=j;
		i++;
	}
	cout<<ans<<endl;
}	




Measured memory_bytes: 3616
import java.util.Scanner;

class Node{
	int Hcover;
	int Lcover; 
	int min;
	Node parent;
	Node left;
	Node right;
	public Node(){
		parent=null;
		left=null;
		right=null;
	}
	
	public Node(int l,int h,int m){
		Hcover=h;
		Lcover=l;
		min=m;
		parent=null;
		left=null;
		right=null;
	}

	public boolean between(int a){
		return (Lcover<=a)&&(a<=Hcover);
	}
}

public class Main {
	static Node table[]=new Node[100001];

	public static Node cousei(Node n,int l,int h,int m){
		Node mob=new Node(l,h,m);
		mob.parent=n;
		if(h>l){
			mob.left=cousei(mob,l, (h+l)/2, m);
			mob.right=cousei(mob,(h+l)/2+1, h, m);
		}
		if(h==l) table[h]=mob;
		return mob;
	}

	public static int find(Node n,int l,int h){
		//System.out.println("f:"+n.Lcover+"to"+n.Hcover+":"+n.min+"::"+l+"to"+h);
		if(n.Lcover==l&&n.Hcover==h)return n.min;

		if(n.left.between(l)&&n.left.between(h)){
			return find(n.left, l, h);
		}else if(n.right.between(l)&&n.right.between(h)){
			return find(n.right, l, h);
		}else{
			return find(n.left, l, n.left.Hcover)+find(n.right, n.right.Lcover,h);
		}
	}

	public static void update(Node n,int p,int x,int bef){
		//int i=0;
		for(Node it=n;it!=null;it=it.parent){
			//i++;
			//System.out.println(i+"??????");
				it.min=it.left.min+it.right.min;
		}
	}

	public static void main(String[] args) {
		Node root=new Node();
		int n;
		int q;
		Scanner stdin=new Scanner(System.in);
		n=stdin.nextInt();
		q=stdin.nextInt();
		root.min=0;
		root.Hcover=n;
		root.Lcover=1;
		root.parent=null;
		root.left=cousei(root,1,(n+1)/2,root.min);
		root.right=cousei(root,(n+1)/2+1,n,root.min);
		for(int XXX=0;XXX<q;XXX++){
			int com=stdin.nextInt();
			int x=stdin.nextInt();
			int y=stdin.nextInt();
			if(com==0){
				// update
				int m=table[x].min;
				table[x].min+=y;
				update(table[x].parent, x, y,m);
				//prin(root);
			}else{
				// find
				System.out.println(find(root, x, y));
			}
		}
		stdin.close();
	}

}

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

using namespace std;

const int MAX = 100005;
int q[MAX] = {0};

int main()
{
	std::ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    for(int i=0;i<n;i++){
    	cin >> q[i];
	}
	for(int i=0;i<n-1;i++){
		if(i!=n-2 && q[i]>=q[i+1]){
			if(i>0&&q[i]-1>=q[i-1]){
				q[i]--;
			}
			if(i==0) q[i]--;
		}
		if(i==n-2 && q[i]>q[i+1]) q[i]--;
	}
	bool f = true;
	for(int i=0;i<n-1;i++){
		if(q[i]>q[i+1]){
			f = false;
			break;
		}
	}
	if(f) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 640
#include <stdio.h>
main(){
	int a,b,c,x;
	int count = 0;

	scanf("%d%d%d",&a,&b,&c);
	for(x = a;x <= b;x++){
		if(c%x == 0){
			count++;
		}
	}


	printf("%d\n",count);
return 0;

}

Measured memory_bytes: 596
#include <bits/stdc++.h>
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ll long long
#define pii pair<int, int>

using namespace std;

int main() {
    //freopen("output.txt", "w", stdout);
    int n; cin >> n;

    if (n>=30) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define SZ(x) ((int)(x).size())
#define rep(i,n) for(int i=0;i<(n);++i)
#define fore(i,a) for(auto &i:a)
#define min(...) min({__VA_ARGS__})
#define max(...) max({__VA_ARGS__})
#define Yes cout << "Yes" << endl;
#define No cout << "No" << endl;
#define answer cout << ans << endl;
signed _main(); signed main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> using v = vector<T>;
template<class T> using vv = vector<v<T>>;
const int MOD=1e9+7;
const long long INF = 1LL << 60;
/*素数判定*/int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}

signed _main(){
  int N,A,B; cin >> N >> A >> B;
  int ans=(N/(A+B))*A;
  ans+=min(N%(A+B),A);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long 
using namespace std;
int n,a,b,ans=0x7000000000000000;
inline int R()
{
	char c;int sign=1,res=0;
	while((c=getchar())>'9'||c<'0') if(c=='-') sign=-1;res+=c-'0';
	while((c=getchar())>='0'&&c<='9') res=res*10+c-'0';
	return res*sign;	
}
signed main()
{
	n=R();a=R();b=R();if(a>b) swap(a,b);
	if((b-a)%2==0) ans=min(ans,(b-a)/2);
	else 
	{
		ans=min(ans,(b-(a)-1)/2+a);
		ans=min(ans,(n-(a+(n-b+1)))/2+n-b+1);
	}
	printf("%lld\n",ans);
}

Measured memory_bytes: 256
use proconio::input;

fn main() {
    input! {
        N: i64,
        A: [i64; N - 1],
    }

    let mut ans = Vec::new();
    ans.resize(N as usize, 0);

    for v in A {
        ans[(v - 1) as usize] += 1;
    }
    for v in ans {
        println!("{}", v);
    }
}


Measured memory_bytes: 5504
#include <iostream>
#include<vector>
#include<algorithm>
using namespace std;
using ll = long long;
int main(){
  int s;
  cin>>s;
 vector<ll> a;
  ll i= 1; 
 while(1){
    if(find(a.begin(),a.end(),s)!=a.end())break;
    a.push_back(s);
    if(s%2==0)s=s/2;
    else s=3*s+1;
    i++;
  }
  cout<<i<<endl;
  return 0;
}

Measured memory_bytes: 256
fun solve(line: String): String {
    var x = line.toLong()
    for (i in x..2*x) {
        if (isPrime(i)) return "$i"
    }
    return "$x"
}

fun isPrime(n: Long): Boolean {
    for (i in 2..n/2) {
        if (n % i == 0L) return false
    }
    return true
}

fun main(args: Array<String>) {
    println(solve(readLine()!!))
}

Measured memory_bytes: 31868
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			char[] s = scanner.next().toCharArray();
			boolean result = true;
			if ('A' != s[0]) {
				// 最初の文字が'A'でない
				result = false;
			} else if (1 != IntStream.rangeClosed(2, s.length - 2).filter(i -> 'C' == s[i]).count()) {
				// 3文字目から最後から2文字まで'C'の数が1でない
				result = false;
			} else if (2 != IntStream.range(0, s.length).filter(i -> ('A' <= s[i]) && (s[i] <= 'Z')).count()) {
				// 最初の'A'と'C'以外はすべて小文字でない
				result = false;
			}
			System.out.println(result ? "AC" : "WA");
		}
	}
}


Measured memory_bytes: 35920
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
using namespace std;

const int IINF = 1 << 30;
const ll INF = 1ll << 60;
const ll MOD = 1e9 + 7;

int main(int argc, char const *argv[])
{
    string s;
    cin >> s;
    if (s == "AAA" || s == "BBB")
    {
        cout << "No" << endl;
    }
    else
    {
        cout << "Yes" << endl;
    }

    return 0;
}


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

using pii = pair<int,int>;
using ll = long long;
#define rep(i, j) for(int i=0; i < (int)(j); i++)
#define repeat(i, j, k) for(int i = (j); i < (int)(k); i++)
#define all(v) v.begin(),v.end()
#define debug(x) cerr << #x << " : " << x << endl

template<class T> bool set_min(T &a, const T &b) { return a > b  ? a = b, true : false; }
template<class T> bool set_max(T &a, const T &b) { return a < b  ? a = b, true : false; }
// vector
template<class T> istream&
operator >> (istream &is , vector<T> &v) { for(T &a : v) is >> a; return is; }
template<class T> ostream&
operator << (ostream &os , const vector<T> &v) { for(const T &t : v) os << "\t" << t; return os << endl; }
// pair
template<class T, class U> ostream&
operator << (ostream &os , const pair<T, U> &v) { return os << "<" << v.first << ", " << v.second << ">"; }

const int INF = 1 << 30;
const ll INFL = 1LL << 60;


ll solve(ll A, ll B) {
    auto foo_a = [&] (ll a) {
        return a >= A ? a + 1 : a;
    };
    auto foo_b = [&] (ll b) {
        return b >= B ? b + 1 : b;
    };
    auto check = [&] (ll m) {
        bool ok = true;
        ll AB = A * B;
        ok &= foo_a(1) * foo_b(m) < AB;
        ok &= foo_a(m) * foo_b(1) < AB;
        for(ll i = max(1ll, m / 2 - 100); i <= min(m / 2 + 100, m); i++) {
            ll a = foo_a(i);
            ll b = foo_b(m - i + 1);
            ok &= a * b < AB;
        }
        return ok;
    };
    
    ll l = 0, r = 2e9; // [l, r)
    
    while(l + 1 < r) {
        ll m = (l + r) / 2;
        (check(m) ? l : r) = m;
    }
    // debug(l);
    return l;
}

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

    ll Q; cin >> Q;

    rep(q, Q) {
        ll A, B; cin >> A >> B;
        ll ans = max(solve(A, B), solve(B, A));
        cout << ans << endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int n = scanner.nextInt();
			int d = scanner.nextInt(), x = scanner.nextInt();
			int[] a = IntStream.range(0, n).map(i -> scanner.nextInt()).toArray();
			System.out.println(x + IntStream.range(0, n).map(i -> (d - 1) / a[i] + 1).sum());
		}
	}
}


Measured memory_bytes: 36584
l = lambda: list(map(int, input().split()))
N,M = l()
K = [l() for _ in range(M)]
P = l()

ans = 0
fmt = "{:0" + str(N) + "b}"
for i in range(2**N):
    valid = True
    d = list(map(int, list(fmt.format(i))))
    for j in range(M):
        if not P[j] == sum([d[k - 1] for k in K[j][1:]]) % 2:
            valid = False
            break
    if valid:
        ans += 1

print(ans)

Measured memory_bytes: 9116
#include <iostream>

using namespace std;

char c;
int a[1000001];
int n(0),cnt(0);

int main()
{
    a[0]=0;
    while(cin >> c)
    {
        n++;
        a[n]=int(c)-48;
    }
    for (int i(n); i>=0; i--)
        if (a[i]==5 && a[i-1]>=5)
        {
            a[i-1]++;
            cnt+=5;
        }
        else
    {
        if (a[i]<=5) cnt+=a[i];
    else
    {
        cnt+=(10-a[i]);
        a[i-1]++;
    }
    }
    cout << cnt;
}


Measured memory_bytes: 4096
#include <bits/stdc++.h>
#include <iostream>
#include<map>
#include <algorithm>
#include <vector>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

int main() {
    int a, b;
    cin >> a >> b;
    if ((a + b) % 2 == 0) cout << (a + b) / 2 << endl;
    else cout << "IMPOSSIBLE" << endl;
}

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

vector<long long> vec;
int main(){
  int n, k;
  cin >> n >> k;

  long long a[1010];

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

  for(int i = 0;i < n;i++){
    long long tmp = 0;
    for(int j = i;j < n;j++){
      tmp += a[j];
      vec.push_back(tmp);
    }
  }

  for(long long i = 62;i >= 0;i--){
    int cnt = 0;
    for(long long j = 0;j < vec.size();j++){
      if(vec[j] & ((long long)1 << i)) cnt++;
    }
    if(cnt < k) continue;

    for(long long j = 0;j < vec.size();j++){
      if((vec[j] & ((long long)1 << i)) == 0) vec[j] = 0;
    }
  }

  long long ans = LLONG_MAX;
  int cnt = 0;
  for(int i = 0;i < vec.size();i++){
    if(vec[i] != 0){
      ans = (ans & vec[i]);
      cnt++;
    }
    if(cnt == k){
      cout << ans << endl;
      return 0;
    }
  }

}

Measured memory_bytes: 6256
#include<bits/stdc++.h>
#define fi first
#define se second
#define inf 999999999
using namespace std;
int h,w;
bool c[40][40],d[40][40];
int dx[]={-1,0,0,1};
int dy[]={0,1,-1,0};
inline int bfs(){
    int res=inf;
    bool past[40][40];
    for(int i=0;i<40;i++)for(int j=0;j<40;j++)past[i][j]=0;
    queue<pair<int,pair<int,int> > > q;
    q.push(pair<int,pair<int,int> >(0,pair<int,int>(0,0)));
    while(!q.empty()){
        int nowy=q.front().fi;
        int nowx=q.front().se.fi;
        int nowcost=q.front().se.se;
        q.pop();
       // cout<<"nowy="<<nowy<<"nowx="<<nowx<<"nowcost="<<nowcost<<endl;
        if(nowx==w-1 && nowy==h-1){
            res=min(nowcost,res);
            continue;
        }
       // cout<<"hi"<<endl;
        if(past[nowy][nowx]==1)continue;
        else past[nowy][nowx]=1;
       // cout<<"hi"<<endl;
        for(int i=0;i<4;i++){
            if(nowx+dx[i]>=0 && nowx+dx[i]<w && nowy+dy[i]>=0 && nowy+dy[i]<h){
                if(i==0 && c[nowy][nowx-1]==0){
                   // cout<<"hi0"<<endl;
                    q.push(pair<int,pair<int,int> >(nowy,pair<int,int>(nowx-1,nowcost+1)));
                }
                if(i==1 && d[nowy][nowx]==0){
                   // cout<<"hi1"<<endl;
                    q.push(pair<int,pair<int,int> >(nowy+1,pair<int,int>(nowx,nowcost+1)));
                }
                if(i==2 && d[nowy-1][nowx]==0){
                  // cout<<"hi2"<<endl;
                   q.push(pair<int,pair<int,int> >(nowy-1,pair<int,int>(nowx,nowcost+1)));
                 }
                if(c[nowy][nowx]==0 && i==3){
                   // cout<<"hi3"<<endl;
                    q.push(pair<int,pair<int,int> >(nowy,pair<int,int>(nowx+1,nowcost+1)));
                }
            }
        }
    }
    return res;
}
int main(){
    while(cin>>w>>h,w){
        for(int i=0;i<40;i++)for(int j=0;j<40;j++)c[i][j]=0,d[i][j]=0;
        int a=w-1;
        int b=w;
        for(int i=0;i<h;i++){
            for(int j=0;j<a;j++){
                cin>>c[i][j];
            }
            if(i!=h-1)for(int j=0;j<b;j++){
                cin>>d[i][j];
            }else continue;
        }
        if(bfs()==inf){
            cout<<0<<endl;
        }else{
            cout<<bfs()+1<<endl;
        }
    }
}

Measured memory_bytes: 3080