akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

template <typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 310

int memo[SIZE][SIZE];

int query(int a, int b) {
  if (a == b) return 0;
  if (memo[a][b]) return memo[a][b];

  int d;
  cout << "? " << a << " " << b << endl;
  cout.flush();

  cin >> d;
  return memo[a][b] = memo[b][a] = d;
}

int main(){
  int N, s, t;
  int ds[SIZE], dt[SIZE];

  cin >> N >> s >> t;

  int D = query(s, t);

  for (int i=1; i<=N; i++) {
    ds[i] = query(s, i);
    dt[i] = query(t, i);
  }

  vector<pair<int,int>> vec;

  for (int i=1; i<=N; i++) {
    if (ds[i] + dt[i] == D) {
      vec.push_back({ds[i], i});
    }
  }

  sort(vec.begin(), vec.end());

  vector<int> ans = {};
  int now = s;

  for (auto p : vec) {
    int to = p.second;

    if (query(now, to) == ds[to] - ds[now]) {
      now = to;
      ans.push_back(now);
    }
  }

  cout << "!";

  for (auto p : ans) {
    cout << " " << p;
  }
  cout << endl;

  return 0;
}



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

int main()
{
	int r,c;
	cin>>r>>c;
	char a[r][c];
	for(int i=0;i<r;i++)
		for(int j=0;j<c;j++)
			cin>>a[i][j];

	  	long int result[r][c]={0};
		memset(result,0,sizeof(result));
		for(int i=0;i<r;i++)
		{
			if(a[i][0]=='.')
				{result[i][0]=1;}
			if(a[i][0]=='#')
				break;
		}
		for(int i=0;i<c;i++)
		{
			if(a[0][i]=='.')
				{result[0][i]=1; }
			if(a[0][i]=='#')
				break;
		}

			for(int i=1;i<r;i++)
					for(int j=1;j<c;j++)
					{
						if(a[i][j]=='.')
							result[i][j]=(result[i-1][j]+result[i][j-1])%1000000007;
						else
							result[i][j]=0;
					}
					/*for(int i=0;i<r;i++)
		{for(int j=0;j<c;j++)
			cout<<result[i][j];cout<<"\n";}*/
   cout<<result[r-1][c-1];
				return 0;
}

Measured memory_bytes: 9088
#include <stdio.h>
#include <string.h>

int x[10][10];

void generate(char* ssn, int bssn) {
	int i;
	int cur = 0;
	sprintf(ssn, "%04d", bssn);
	for (i = 0; i < 4; i++) {
		cur = x[cur][ssn[i] - '0'];
	}
	ssn[4] = cur + '0';
	ssn[5] = '\0';
}

int check(const char* ssn) {
	int i;
	int cur = 0;
	for (i = 0; i < 5; i++) {
		cur = x[cur][ssn[i] - '0'];
	}
	return cur == 0;
}

int main(void) {
	int i, j;
	int count = 0;
	int bssn;
	for (i = 0; i <10; i++) {
		for (j = 0; j < 10; j++) {
			if (scanf("%d", &x[i][j]) != 1) return 1;
		}
	}
	for (bssn = 0; bssn <= 9999; bssn++) {
		int false_negative = 0;
		char ssn[8];
		char wrong_ssn[8];
		generate(ssn, bssn);
		for (i = 0; i < 5; i++) {
			for (j = 0; j <= 9; j++) {
				if(ssn[i] - '0' == j) continue;
				strcpy(wrong_ssn, ssn);
				wrong_ssn[i] = j + '0';
				if (check(wrong_ssn)) false_negative = 1;
			}
		}
		for (i = 1; i < 5; i++) {
			char temp;
			if (ssn[i - 1] == ssn[i]) continue;
			strcpy(wrong_ssn, ssn);
			temp = wrong_ssn[i - 1];
			wrong_ssn[i - 1] = wrong_ssn[i];
			wrong_ssn[i] = temp;
			if (check(wrong_ssn)) false_negative = 1;
		}
		if (false_negative) count++;
	}
	printf("%d\n", count);
	return 0;
}

Measured memory_bytes: 632
# -*- coding: utf-8 -*-
l = int(input())
al = [int(input()) for _ in range(l)]
INF = 10**15
dp = [INF]*5  # 0,偶数,奇数,偶数,0の状態
dp[0] = 0

def cost(i, k):
    # i番目を状態kにした時に必要な回数
    if k==0 or k==4:
        return al[i]
    elif k==1 or k==3:
        if al[i]>0:
            return al[i]%2
        else:
            return 2
    else:
        if al[i]%2==0:
            return 1
        else:
            return 0

for i in range(l):
    dp2 = [min(dp[:j+1]) for j in range(5)]
    for j in range(5):
        dp[j] = dp2[j] + cost(i,j)

    # for j in range(5):
    #     for k in range(j,5):
    #         dp[i+1][k] = min(
    #             dp[i+1][k],
    #             dp[i][j] + cost(i, k)
    #         )

print(min(dp))


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

using namespace std;

#define _overload3(_1,_2,_3,_4,name,...) name
#define _rep(i,n) _repi(i,0,n)
#define _repi(i,a,b) for(int i=a, i##_len=(b); i<i##_len; ++i)
#define _repis(i,a,b,s) for(int i=a, i##_len(b); i<i##_len; i+=s)
#define REP(...) _overload3(__VA_ARGS__,_repis,_repi,_rep,)(__VA_ARGS__)

#define REPR(i, n) for(int i = n;i >= 0;--i)

#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define yes(n) cout<<((n)?"yes":"no")<<endl
#define poss(n) cout<<((n)?"possible":"impossible")<<endl
#define Poss(n) cout<<((n)?"Possible":"Impossible")<<endl
#define POSS(n) cout<<((n)?"POSSIBLE":"IMPOSSIBLE")<<endl

int main(){
    int x;
    cin>>x;
    cout<<((x<1200)?"ABC":"ARC");
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#define rep(i,n) for(int i=0; i<n; i++)
typedef long long ll;
typedef pair<int,int> P;
const ll MOD = (int)1e9+7;
const ll INF = MOD*MOD;
ll n,m,k,ans;
string s,t;
const ll powll = 1LL<<1;

int main(void){
  int n; cin >> n;
  int a[n]; rep(i,n) cin >> a[i];

  bool frag = true;
  rep(i,n){
    if(a[i] % 2 == 0){
      if(a[i]%3 != 0 && a[i]%5 != 0) frag = false;
    }
  }
  if(frag) cout << "APPROVED\n";
  else cout << "DENIED\n";
}

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

using namespace std;
inline void prep ()
{
  cin.tie (0);
  cin.sync_with_stdio (0);
};
const double pi = acos(-1.);
//printf(%.12lf\n,mid);
// __builtin_popcount(int) count 1's in binary
// get decimal part of number
/*
double intpart;
double thiss = modf((double)(n*m)/(double)k, &intpart);
*/
// round = (int)(num+.5)
int mod = 20437;

long long mymod(long long num){
  if (num< 0 && !(num%mod == 0)){
    if (mod == 1){
      return 0;
    }
    return mod-abs(num)%mod;
  }else{
    return num%mod;
  }
}

/*string sentence = And I feel fine...;
    istringstream iss(sentence);
*/  

double eps = .000000001;


int main ()
{
  prep();
  int n, m;
  cin >> n >> m;
  priority_queue<int> pq;
  for (int i=0; i<n; i++){
      int num;
      cin >> num;
      pq.push(num);
  }
  for (int i=0; i<m; i++){
      int fr = pq.top();
      pq.pop();
      fr /= 2;
      pq.push(fr);
  }
  long long sum = 0;
  while (!pq.empty()){
      sum += pq.top();
      pq.pop();
  }
  cout << sum;
  return 0; 
}
  

Measured memory_bytes: 892
a,b,c=map(int,input().split())
total=a+b+c
m=max(a,b,c)
if total%2==0:
    if m%2==0:
        print((3*m-total)//2)
    else:
        m=m+1
        print((3*m-total)//2)
else:
    if m%2==0:
        m=m+1
        print((3*m-total)//2)
    else:
        print((3*m-total)//2)

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

int main() {
   int x,y;
   cin>>x>>y;
 if(y%2!=0){
	cout<<"No"<<'\n';
 }else if(y<x*2){
    cout<<"No"<<'\n';
 }else if(y>x*4){
 	cout<<"No"<<'\n';
 }else{
 	cout<<"Yes"<<'\n';
 }
}

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

int main() {
 char S[3];
  int x=0,y=0,z=0;
  for(int i=0;i<3;i++){
   cin >> S[i]; 
  
  if(S[i]=='a'){
    x=1;
  }
  else if(S[i]=='b'){
    y=1;
  }
  else if(S[i]=='c'){
    z=1;
  }
}
  if(x==1 && y==1 && z==1){
    cout << "Yes" <<endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
    int n,i,j,val[11][11];
    scanf("%d",&n);
    while(n!=0){
		val[n][n]=0;
		for(i=0; i<n; i++){
			val[i][n]=0;
			val[n][i]=0;
		}
		for(i=0; i<n; i++){
			for(j=0; j<n; j++){
				scanf("%d",&val[i][j]);
				val[n][n]+=val[i][j];
				val[i][n]+=val[i][j];
				val[n][j]+=val[i][j];
			}
		}
		for(i=0; i<=n; i++){
			for(j=0; j<=n; j++){
				printf("%5d",val[i][j]);
			}
			printf("\n");
		}
        scanf("%d",&n);
    }
	return 0;
}

Measured memory_bytes: 616
import java.util.Scanner;

class Main {
	static int mod = 1000000007;
	private static long[] fact;
	private static long[] inv_fact;

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

		int n = sc.nextInt();

		int[] a = new int[20];
		int[][] x = new int[20][20];
		int[][] y = new int[20][20];

		for (int i = 0; i < n; i++) {

			a[i] = sc.nextInt();

			for (int j = 0; j < a[i]; j++) {

				x[i][j] = sc.nextInt();
				y[i][j] = sc.nextInt();

				// System.out.println("j:" + j);
				// System.out.println("x:" + x + " y:" + y);
			}
		}

		int ans = 0;
		for (int bit = 0; bit < (1 << n); bit++) {
			boolean flag = true;

			for (int i = 0; i < n; ++i) {
				if ((bit & (1 << i)) == 0) {
					continue;
				}
				for (int j = 0; j < a[i]; j++) {
					if ((((bit >> (x[i][j] - 1)) & 1) ^ y[i][j]) != 0) {
						flag = false;
					}
				}

			}
			if (flag)
				ans = Math.max(ans, counter(bit));

		}
		System.out.println(ans);

	}

	// 正直者の人数カウンタ
	static int counter(int x) {
		if (x == 0)
			return 0;
		return counter(x >> 1) + (x & 1);
	}

}

Measured memory_bytes: 25556
/*
 * FileName:     D
 * CreatedDate:  2020-05-31 22:04:17 +0900
 * LastModified: 2020-06-28 10:14:18 +0900
 */

#include <stdio.h>

int main(void){
    long long int n;scanf("%lld\n",&n);
    int ans=0;
    for(long long int i=2;i*i<=n;i++){
        if(n%i==0){
            int cnt = 0;
            while(n%i==0){
                n/=i;
                cnt++;
            }
            for(int j=1;j<=cnt;j++){
                cnt -= j;
                ans++;
            }
        }
    }
    if(n!=1)ans++;
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 1708
'use strict'

function main(input) {
    input = input.split(' ').map(v => ~~v)
    let year = 2018
    let cnt = 0

    let monthlast;

    for (let i = 1; i <= input[0]; i++) {

        monthlast = new Date(year, i, 0)

        for (let d = 1; d <= monthlast.getDate(); d++) {

            if (i != input[0]) {
                if (i == d) cnt++
            } else {

                if (d <= input[1] && i == d) cnt++
            }

        }




    }
    console.log(cnt)
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

int main() {
  string s; cin >> s;
  
  int ans = 0;
  
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == 'A' || s[i] == 'T' || s[i] == 'C' || s[i] == 'G') {
      int l = 1;
      for (int j = i + 1; j < s.size(); j++) {
        if (s[j] == 'A' || s[j] == 'T' || s[j] == 'C' || s[j] == 'G') l++;
        else break;
      }
      ans = max(ans, l);
    }
  }
  
  cout << ans << endl;
}

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

int main(void){
	int a,b,c;
	scanf("%d %d %d",&a,&b,&c);
	//aが最大
	if(a>=b && a>=c) printf("%d\n",a*10+b+c);
	else if (b>=a && b>=c) printf("%d\n",b*10+a+c);
	else printf("%d\n",c*10+a+b);
	return 0;
}

Measured memory_bytes: 128
//#define _GLIBCXX_DEBUG
#include "bits/stdc++.h"

using namespace std;

//------------------------------- Type Names -------------------------------//

using i64 = int_fast64_t;

using seika = string;
//{akari : 1D, yukari : 2D, maki : 3D} vector
template <class kizuna>
using akari = vector<kizuna>;
template <class yuzuki>
using yukari = akari<akari<yuzuki>>;
template <class tsurumaki>
using maki = akari<yukari<tsurumaki>>;
//{akane : ascending order, aoi : decending order} priority queue
template <class kotonoha>
using akane = priority_queue<kotonoha, akari<kotonoha>, greater<kotonoha>>;
template <class kotonoha>
using aoi = priority_queue<kotonoha>;

//------------------------------- Libraries ---------------------------------//

//------------------------------- Dubug Functions ---------------------------//

inline void print()
{
    cout << endl;
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest)
{
    cout << first << ' ';
    print(rest...);
}

//------------------------------- Solver ------------------------------------//

void solve()
{
    int m, n;
    cin >> n >> m;
    akari<int> as(n);
    for (int i = 0; i < n; i++)
    {
        cin >> as[i];
    }
    sort(as.rbegin(), as.rend());
    int sum = accumulate(as.begin(), as.end(), 0);
    for (int i = 0; i < m; i++)
    {
        if (as[i] * 4 * m < sum)
        {
            cout << "No" << endl;
            return;
        }
    }
    cout << "Yes" << endl;
}

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


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

using namespace std;

#define INF 1000000007
#define LINF (1LL << 60)

typedef long long i64;
typedef pair<i64,i64> P;

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

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



int n;
bool prime(int a){
	for(int i = 2; i*i <= a; i++){
		if(a % i == 0) return 0;
	}
	return 1;
}
void solve(){
	cin >> n;
	vector<int> v;
	for(int i = 2; i < 55555; i++){
		if(prime(i)){
			if(i % 5 == 1) v.push_back(i);
		}
	}
	
	while(n--){
		cout << v[n] << " ";
	}
	cout << endl;
}

int main(){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,m,n) for(int i=m;i<n;i++)
ll mod=1e9+7;

int main(){
  int a,b,c;
  cin>>a>>b>>c;
  cout<<a*b/2<<endl;
}

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

typedef long long ll;
#define repd(i,a,b) for (ll i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)

ll mod=1e9+7;

using namespace std;


ll inputValue(){
	ll a;
	cin >> a;
	return a;
};

void inputArray(int * p, ll a){
	rep(i, a){
		cin >> p[i];
	}
};

template<typename T>
void inputVector(vector<T>& p, ll a){
	rep(i, a){
		T input;
		cin >> input;
		p.emplace_back(input);
	}
}


template <typename T>
void output(T a) {
	cout << a << "\n";
}

int main(int argc, const char * argv[]) {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
    ll h,w;
    cin >> h >> w;

    if(h==1 || w==1){
        cout << 1 << endl;
        return 0;
    }

    if(h*w % 2){
        cout << h*w/2+1 << endl;
    }else{
        cout << h*w/2 << endl;
    }

	return 0;
}



Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

from fractions import gcd

N,M = map(int,readline().split())
S = readline().rstrip().decode('utf-8')
T = readline().rstrip().decode('utf-8')

G = gcd(N,M)

# G回overlapする

A = ''.join(S[::N//G])
B = ''.join(T[::M//G])

if A == B:
    answer = N * M // G
else:
    answer = -1
print(answer)


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

#if MYDEBUG
#include "lib/cp_debug.hpp"
#else
#define DBG(...) ;
#endif
#if __cplusplus <= 201402L
template <typename T>
T gcd(T a, T b) { return ((a % b == 0) ? b : gcd(b, a % b)); }
template <typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }
#endif
using LL = long long;
constexpr LL LINF = 334ll << 53;
constexpr int INF = 15 << 26;
constexpr LL MOD = 1E9 + 7;

namespace Problem {
using namespace std;

class Solver {
 public:
  int n;
  vector<LL> a;
  vector<int> f;
  Solver(LL n) : n(n), a(n), f(n){};

  void solve() {
    for (int i = 0; i < n; ++i) {
      cin >> a[i];
      if (a[i] >= 0)
        f[i] = 1;
      else
        f[i] = -1;
    }
    if (accumulate(f.begin(), f.end(), 0) == n) {
      int p = distance(a.begin(), min_element(a.begin(), a.end()));
      f[p] = -1;
    }
    if (accumulate(f.begin(), f.end(), 0) == -n) {
      int p = distance(a.begin(), max_element(a.begin(), a.end()));
      f[p] = 1;
    }
    LL sum = 0;
    for (int i = 0; i < n; ++i) {
      sum += a[i] * f[i];
    }
    int P, N;
    for (int i = 0; i < n; ++i) {
      if (f[i] == 1)
        P = i;
      else
        N = i;
    }
    vector<int> ps, ns;
    for (int i = 0; i < n; ++i) {
      if (f[i] == 1 && i != P) ps.push_back(i);
      if (f[i] == -1 && i != N) ns.push_back(i);
    }
    cout << sum << endl;
    vector<pair<LL, LL>> ans;
    DBG(P, N)
    DBG(ps, ns, f)
    for (int i : ps) {
      ans.emplace_back(a[N], a[i]);
      a[N] -= a[i];
      a[i] = 0;
      DBG(a)
    }
    for (int i : ns) {
      ans.emplace_back(a[P], a[i]);
      a[P] -= a[i];
      a[i] = 0;
      DBG(a)
    }
    ans.emplace_back(a[P], a[N]);
    a[P] -= a[N];
    a[N] = 0;
    DBG(a)
    for (int i = 0; i < ans.size(); ++i) {
      cout << ans[i].first << ' ' << ans[i].second << endl;
    }
  }
};

}  // namespace Problem

int main() {
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(false);
  // std::cout << std::fixed << std::setprecision(12);
  long long n = 0;
  std::cin >> n;

  Problem::Solver sol(n);
  sol.solve();
  return 0;
}


Measured memory_bytes: 5360
#include <stdio.h>  

int main(){
    int hi[10];
    int n,count=0;
    while(scanf("%d",&n) != EOF){
	if(n == 0){
	    printf("%d\n",hi[count-1]);
	    hi[count-1]=0;
	    count--;
	}
	else{
	    hi[count]=n;
	    count++;
	}
    }
    return 0;  
}

Measured memory_bytes: 1028
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ii = pair<int, int>;
#ifdef XVENOM
	#define errp(...) fprintf(stderr, __VA_ARGS__)
	#define dbg(...) errp("[%s]: ", #__VA_ARGS__), dbg_str(__VA_ARGS__)
#else
	#define errp(...)
	#define dbg(...)
#endif
template <typename U, typename V> string to_string (pair<U, V>);
string to_string (const string& e_) { return "\"" + e_ + "\""; }
string to_string (char e_) { return "\'" + string(1, e_) + "\'"; }
string to_string (bool e_) { return e_ ? "true" : "false"; }
template <typename T> string to_string (T e_) {
	string s_ = "[ ";
	for (const auto& x_ : e_) s_ += to_string(x_) + " ";
	return s_ + "]";
}
template <typename U, typename V> string to_string (pair<U, V> e_) {
	return "(" + to_string(e_.first) + ", " + to_string(e_.second) + ")";
}
void dbg_str () { errp(" \n"); }
template <typename U, typename... V> void dbg_str (U u, V... v) {
	errp(" %s", to_string(u).c_str()); dbg_str(v...);
}
/* --- */
const int N = 15;
int a[N][N], valid[N];

int main () {
	ios_base::sync_with_stdio(0); cin.tie(0);
	/* --- */
	int n, ans = 0, x, y, k, count = 0, f;

	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> k;
		for(int j = 0; j < k; j++){
			cin >> x >> y;
			if(y) a[i][x-1] = 1;
			else a[i][x-1] = -1;
		}
	}

	for(int i = 0; i < (1<<n); i++){
		memset(valid, 0, sizeof valid);
		count = 0, f = 0;
		for(int j = 0; j < n; j++){
			if(i&(1<<j)){
				if(valid[j] == -1){
					f = 1;
					break;
				}
				valid[j] = 1;
				for(k = 0; k < n; k++){
					if(a[j][k] == 0) continue;
					if(valid[k] == 0) valid[k] = a[j][k];
					else if(valid[k] != a[j][k]){
						f = 1;
						break;
					}
				}
				count++;
			}
		}
		for(int j = 0; j < n; j++){
			if(i&(1<<j)){
				if(valid[j] != 1)
					f = 1;
			}
			else{
				if(valid[j] == 1)
					f = 1;
			}
		}
		if(f == 0) ans = max(ans,count);
	}
	cout << ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=(0);i<(n);i++)

using namespace std;

typedef long long ll;

int N, A, B, C, D;
string S;
vector<bool> iwa;

bool chk1(){
	for(int i = B; i < D; i++){
		if(iwa[i] && iwa[i+1]) {
			// cout << "chk1,B," << i << endl;
			return false;
		}
	}

	iwa[D] = true;

	for(int i = A; i < C; i++){
		if(iwa[i] && iwa[i+1]) {
			// cout << "chk1,A," << i << endl;
			iwa[D] = false;
			return false;
		}
	}

	return true;
}

bool chk2(){
	bool ok = false;
	int pos = -1;
	// for(int i = B; i <= min(C-2, D-1); i++){
	for(int i = B-1; i <= min(C-2, D-1); i++){
		if(!iwa[i] && !iwa[i+1] && !iwa[i+2]){
			// cout << "chk2,B," << i << endl;
			pos = i+1;
			iwa[pos] = true;
			ok = true;
		}
	}

	if(!ok) return false;

	for(int i = A; i < C; i++){
		if(iwa[i] && iwa[i+1]) {
			// cout << "chk2,A," << i << endl;
			iwa[pos] = false;
			return false;
		}
	}

	return true;
}

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

	cin >> N >> A >> B >> C >> D;
	A--, B--, C--, D--;

	cin >> S;

	iwa.resize(N);
	rep(i, N) {
		if(S[i] == '#'){
			iwa[i] = true;
		} else{
			iwa[i] = false;
		}
	}

	// B -> A
	if(chk1()){
		cout << "Yes" << endl;
		return 0;
	}

	// A -> B
	if(chk2()){
		cout << "Yes" << endl;
		return 0;
	}

	cout << "No" << endl;
}


Measured memory_bytes: 592
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll n,a[1005],l[1005],id,ans[1005],tail,tot[2],last[2],maxi=1,t=1;
bool f;
int main(){
	scanf("%lld",&n);
	for(int i=1;i<=n;++i) scanf("%lld",&a[i]);
	if(n==2){
		printf("%lld\n1\n%d\n",a[1]>a[2]?a[1]:a[2],a[1]>a[2]?2:1);
		return 0;
	}
	for(int i=1;i<=n;++i) if(a[i]>0) f=1,tot[i&1]+=a[i],l[i]=last[i&1],last[i&1]=i;
	if(!f){
		for(int i=2;i<=n;++i) if(a[i]>a[maxi]) maxi=i;
		printf("%lld\n%lld\n",a[maxi],n-1);
		for(int i=n;i>maxi;--i) printf("%d\n",i);
		for(int i=1;i<maxi;++i) puts("1");
		return 0;
	}
	if(tot[0]>tot[1]) t=0;
	printf("%lld\n",tot[t]);
	id=last[t];
	for(int i=n;i>id;--i) ans[++tail]=i;
	while(l[id]!=0){
		int mid=(id+l[id])>>1;
		for(int i=mid;i>l[id];--i) ans[++tail]=i;
		id=l[id];
	}
	for(int i=1;i<id;++i) ans[++tail]=1;
	printf("%lld\n",tail);
	for(int i=1;i<=tail;++i) printf("%lld\n",ans[i]);
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>

using namespace std;

#define rep(i, s, n) for(int i = s;i<n;i++)
#define repe(i, s, n) for(int i = s;i<=n;i++)
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<int> vll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
static const ll maxLL = (ll) 1 << 62;
const ll MOD = 1000000007, INF = 1e18;
int dy[] = {-1, 0, 1, 0};
int dx[] = {0, 1, 0, -1};

template<typename T1, typename T2>
bool pairCompare(const pair<T1, T2> &firstElof, const pair<T1, T2> &secondElof) {
    return firstElof.second > secondElof.second;
}

int mapMaxValue(std::map<ll, int> m) {
    int max = 0;
    for (std::map<ll, int>::iterator it = m.begin(); it != m.end(); it++) {
        if (max < it->second) max = it->second;
    }
    return max;
}

int main(void) {
    int n;
    cin >> n;
    vll monster(n + 1), brave(n);

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

    ll ans = 0;
    for (int i = 0; i < n; ++i) {
        ll min_ii = min(monster[i], brave[i]);
        ans += min_ii;
        monster[i] -= min_ii;
        brave[i] -= min_ii;
        ll min_i_plus1 = min(monster[i + 1], brave[i]);
        ans += min_i_plus1;
        monster[i + 1] -= min_i_plus1;
        brave[i] -= min_i_plus1;
    }

    cout << ans << endl;
}

Measured memory_bytes: 1152
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;
 
int main() {
    ll n, k;
    cin >> n >> k;

    vl x(n);
    rep(i, n) {
        cin >> x[i];
    }

    ll ans = INF;
    rep(i, n-k+1) {
        if(x[i+k-1] <= 0) {
            chmin(ans, abs(x[i]));
        }
        else if(0 <= x[i]) {
            chmin(ans, x[i+k-1]);
        }
        else {
            chmin(ans, 2*min(abs(x[i]), abs(x[i+k-1])) + max(abs(x[i]), abs(x[i+k-1])));
        }
    }
    
    out(ans);
    re0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#include<set>
#include<map>
#include<bitset>
#define rep(i,a,b)  for(i=a;i<b;i++)
#define itrep(at)	for(auto it=at.begin();it!=at.end();it++)
#define lli long long int
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define db double
#define M 1000000007
#define INF 1e18
#define pi 3.1415926535897932384626433832795028841971

#define MAX 100005

using namespace std;
lli min(lli a,lli b){return a<b?a:b;}
lli min(lli a,lli b,lli c){a=min(a,b);a=min(a,c);return a;}
lli max(lli a,lli b){return a>b?a:b;}
lli max(lli a,lli b,lli c){a=max(a,b);a=max(a,c);return a;}
lli dsum(lli n){lli ans=0;while(n){ans+=(n%10);n/=10;}return ans;}
lli power(lli a,lli b){lli res=1;while(b){if(b&1) res=res*a;a=a*a;b>>=1;}return res;}

struct pll{
	lli x,y;
};
bool comp(pll a,pll b){
	if(a.x==b.x)	return a.y<b.y;
	else	return a.x<b.x;
}
lli gcd(lli a,lli b,lli c)
{
	lli x=__gcd(a,b);
	x=__gcd(x,c);
	return x;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	char ch;
	db aa,bb,cc;
	string s1,s2,s3;
    lli i,j,k,a,b,c,d,n,m,sum=0,ans=0,temp,t;
    scanf("%lld",&k);
    for(i=1;i<=k;i++){
    	for(j=1;j<=k;j++){
    		for(a=1;a<=k;a++){
    			sum+=gcd(i,j,a);
			}
		}
	}
	printf("%lld",sum);
    
    
    return 0;
}





















/* UJJWAL KESHRI */

Measured memory_bytes: 3812
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 1001001001
#define LINF 1001001001001001001
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define bit(n) (1LL<<(n))
using namespace std;

typedef pair<int, int> P;
typedef pair<long long, long long> LLP;
typedef long long ll;

int main() {

    for (int i = 1; i <= 5; i++) {
        int x;
        cin >> x;
        if (x == 0) {
            cout << i << endl;
            return 0;
        }
    }
    
    return 0;
}

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

#define REP(i,n) for(int i=0; i < (n); ++i)
#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)

using ll = long long;
#define INF 1e9


int main(){
  int N;
  cin >> N;
  vector<int> a(N);
  REP(i, N){
    cin >> a[i];
  }
  ll ans = INF*INF;
  FOR(i, -100, 101){
    ll cost = 0;
    REP(j, N){
      cost += (a[j]-i)*(a[j]-i);
    }
    ans = min(ans , cost);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	unsigned long long a,b,c,d,n,mn;
	cin>>a>>b>>c>>d>>n;
	b=min(b,2*a);
	c=min(c,2*b);
	d=min(d,2*c);
	mn=d*(n/2)+c*(n%2);
	cout<<mn<<endl;
	return 0;}

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

int main() {
  int N, M;
  std::cin >> N >> M;
  std::vector<int> a(N);
  std::vector<int> b(N);
  for (int i = 0; i < N; ++i) {
    std::cin >> a[i] >> b[i];
  }
  std::vector<int> c(M);
  std::vector<int> d(M);
  for (int i = 0; i < M; ++i) {
    std::cin >> c[i] >> d[i];
  }

  for (int i = 0; i < N; ++i) {
    int min = abs(a[i] - c[0]) + abs(b[i] - d[0]);
    int check = 1;
    for (int j = 1; j < M; ++j) {
      int distance = abs(a[i] - c[j]) + abs(b[i] - d[j]);
      if ( distance < min ) {
        min = distance;
        check = j + 1;
      }
    }
    std::cout << check << std::endl;
  }

  return 0;
}


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

using namespace std;

int main(){

  
  int n;
  string at;
  vector<string> a;

  cin >> n;
  for(int i =0; i< n;i++)
    {
      cin >> at;
    a.push_back(at);
    }

  int m;
  string bt;
  vector<string> b;

  cin >> m;
  for(int i =0; i< m;i++)
    {
      cin >> bt;
      b.push_back(bt);
    }

  vector<string> vec = a;
  vec.insert( vec.end(), b.begin(), b.end() );
  std::sort(vec.begin(), vec.end());
  vec.erase(std::unique(vec.begin(), vec.end()), vec.end());

  // for(string h:vec)
  //   cout << h<<endl;

  int max_a=0;

  for(string v : vec){
    int count = 0;
    for(string aa : a){
      if(aa == v){
        count++;
      }
    }
    for(string bb : b){
      if(bb == v){
        count--;
      }
    }
    
    if(max_a < count){
      max_a = count;
    }
  }
  cout << max_a << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>  // include all standard C++ libraries

using namespace std;

// Loops
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define _rrep(i,n) rrepi(i,n,0)
#define rrepi(i,a,b) for(int i=int(a)-1;i>=int(b);--i)

#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(xi, x) for (auto&& xi : x)
// Note: we can use rep(i,N) or rep(i,from,to)


// typedef
using ll = long long;
template <class T> using vec = vector<T>;
using vi   = vector<int>;
using vvi  = vector<vi>;
using vvvi = vector<vvi>;
using pii  = pair<int, int>;


// Constants

// Shorter repr for frequently used terms
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second


// Algorithms
#define all(x) (x).begin(), (x).end()
#define uniq(v) v.erase( unique(all(v)), v.end() )
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))

template<class T> pair<T, size_t> max(vector<T> &x){ auto it = max_element(all(x)); return mp(*it, it-x.begin()); }
template<class T> pair<T, size_t> min(vector<T> &x){ auto it = min_element(all(x)); return mp(*it, it-x.begin()); }

template<class T> inline bool chmax(T &maxval, const T &newval) { if (maxval<newval) { maxval=newval; return 1; } return 0; }
template<class T> inline bool chmin(T &minval, const T &newval) { if (minval>newval) { minval=newval; return 1; } return 0; }

// Utilities
// Grid world utilities
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
#define inside(H,W,y,x) 0<=(x) && (x)<(W) && 0<=(y) && (y)<(H)

inline int in() {int x; cin >> x; return x;} // read int from cin
inline  ll IN() {ll x; cin >> x; return x;}  // read ll from cin



// Debug
#ifdef LOCAL
  #include "dump.hpp"
  #define debug(x) cerr << #x << ": " << x << '\n'
#else
  #define dump(...)
  #define debug(x)
#endif

// Paste snippets here!!
vector<pii> get_hist(vi &v){
  unordered_map<int, int> hist;
  vector<pii> ret;
  rep(i,v.size()) hist[v[i]]++;
  for(auto kv : hist){
    ret.pb({kv.second, kv.first});
  }
  sort(all(ret), greater<pii>());
  return ret;
}
// 

int main(){
  cin.tie(0); ios::sync_with_stdio(false);    // Magic for faster cin
  int n = in();
  vi v1(n/2), v2(n/2);
  rep(i,n) { if(i%2) cin >> v1[i/2]; else cin >> v2[i/2]; }
  auto h1 = get_hist(v1);  // freq : key
  auto h2 = get_hist(v2);  // freq : key

  rep(i,h1.size()){ dump(h1[i].first, h1[i].second, h2[i].first, h2[i].second); }


  //dump(n, n/2-1, h1[n/2-1].second, h2[n/2-1].second);
  if(h1[0].second != h2[0].second){
    // 最頻値が異なる場合
    cout << n - h1[0].first - h2[0].first << endl;
  } else {
    // 最頻値が同じ場合
    if(h1.size()==1 && h2.size()==1){
      // v1, v2 それぞれ一種類しか含まない場合
      cout << n/2 << endl;
    } else {
      if(h1.size()==1)
        cout << n-(h1[0].first+h2[1].first) << endl;
      else if(h2.size()==1)
        cout << n-(h1[1].first+h2[0].first) << endl;
      else
        cout << min(n-(h1[0].first+h2[1].first), n-(h1[1].first+h2[0].first)) << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 4128
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int main() {
  int A,B,K;
  cin>>A>>B>>K;
  int ans[2*K];
  for(int i=0;i<K;i++){
    if(A+i==B) break;
    ans[i]=A+i;
  }
  for(int j=0;j<K;j++){
    ans[K+j]=B-j;
  }
  sort(ans,ans+2*K);
  if(B-A+1<=K){
    for(int i=A;i<=B;i++) cout<<i<<endl;
  }else{
  for(int i=0;i<2*K;i++){
    if(ans[i]==ans[i+1]) continue;
    cout<<ans[i]<<endl;
  }
  }
}



Measured memory_bytes: 256
#include <stdio.h>

int main(void){
  int i,j,k,n,m,l,a[100][100],b[100][100];
  long int s;
  scanf("%d%d%d",&n,&m,&l);

//行列A
  for(i=0;i<n;i++)
    for(j=0;j<m;j++)
      scanf("%d",&a[i][j]);

//行列B
  for(i=0;i<m;i++)
    for(j=0;j<l;j++)
      scanf("%d",&b[i][j]);

//行列C
  for(i=0;i<n;i++)
    for(j=0;j<l;j++){
      s = 0;
      for(k=0;k<m;k++)
        s += a[i][k] * b[k][j] ;
      printf("%ld", s);
      if(j+1 == l)
        printf("\n");
      else
        printf(" ");
    }

  return 0;
}

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

struct Item{
  int id, p, l, c;
};

main(){
  int n;
  int vp, vl, vc, vC;

  Item I[1001];

  while(1){
    cin >> n;
    if ( n == 0 ) break;

    for ( int i = 0; i < n; i++ ){
      cin >> I[i].id >> I[i].p >> I[i].l >> I[i].c;
    }
    cin >> vp >> vl >> vc >> vC;

    int cnt = 0;
    for ( int i = 0; i < n; i++ ){
      if ( I[i].p > vp || I[i].l > vl || I[i].c > vc ) continue;
      if ( I[i].p*4 + I[i].l*9 + I[i].c*4 > vC ) continue;
      cout << I[i].id << endl;
      cnt++;
    }
    if ( cnt == 0 ) cout << "NA" << endl;
  }
  return 0;
}

Measured memory_bytes: 1176
#include<iostream>
#include<cstdio>
using namespace std;
const int CN = 4e3+3;
int n,a[CN];
int tot[CN],sum[CN]; long long ans = 0;
int abs(int x) {return x>0?x:-x;}
int main(){ 
  cin>>n; for(int i=1;i<=n;i++) cin>>a[i],tot[ a[i] ]++,tot[0] = max(tot[0], a[i]);
  for(int t=1;t<=tot[0]*2;t++) sum[t] = sum[t - 1] + tot[t];
  for(int i=1;i<=n;i++)
    for(int j=i+1;j<=n;j++){
      	ans += sum[ a[i] + a[j] - 1 ] - sum[ abs(a[i] - a[j]) ];
      	if(a[i] + a[j] > a[i] && abs(a[i] - a[j]) < a[i]) ans--;
      	if(a[i] + a[j] > a[j] && abs(a[i] - a[j]) < a[j]) ans--;
	  }
  cout<<ans/3; 
}

Measured memory_bytes: 256
def convert(arr):
    H = []
    for value in arr:
        H.append(int(value))
    return H


def tellTop(i, arr):
    for index in range(i):
        if arr[index] > arr[i]:
            return False
    return True


def count(arr):
    count = 0

    for i in range(0,len(arr)):
        if tellTop(i, arr):
            count = count + 1

    return count


N = input()
arrH = input().split(' ')
N = int(N)
H = convert(arrH)

print(count(H))


Measured memory_bytes: 3064
#include <stdio.h>

typedef struct{
    int top,front,right,left,back,bottom;
}Dice;

void roll(char c,Dice* d){
    int tmp;
    switch(c){
        case 'N':
        tmp=d->top;
        d->top=d->front;
        d->front=d->bottom;
        d->bottom=d->back;
        d->back=tmp;
        break;
        case 'S':
        tmp=d->top;
        d->top=d->back;
        d->back=d->bottom;
        d->bottom=d->front;
        d->front=tmp;
        break;
        case 'E':
        tmp=d->top;
        d->top=d->left;
        d->left=d->bottom;
        d->bottom=d->right;
        d->right=tmp;
        break;
        case 'W':
        tmp=d->top;
        d->top=d->right;
        d->right=d->bottom;
        d->bottom=d->left;
        d->left=tmp;
        break;
    }
    return;
}

int main(void){
    Dice d[100];
    int i,j,n;

    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d%d%d%d%d%d",
        &d[i].top,&d[i].front,&d[i].right,
        &d[i].left,&d[i].back,&d[i].bottom);
    }

    for(i=1;i<n;i++){
        if(d[0].front==d[i].top){
            roll('S',&d[i]);
        }
        else if(d[0].front==d[i].bottom){
            roll('N',&d[i]);
        }
        else if(d[0].front==d[i].right){
            roll('W',&d[i]);
            roll('S',&d[i]);
        }
        else if(d[0].front==d[i].left){
            roll('E',&d[i]);
            roll('S',&d[i]);
        }
        else if(d[0].front==d[i].back){
            roll('S',&d[i]);
            roll('S',&d[i]);
        }
    }

    for(i=0;i<4;i++){
        for(j=1;j<n;j++){
            if(d[0].top==d[j].top&&
            d[0].bottom==d[j].bottom&&
            d[0].right==d[j].right&&
            d[0].left==d[j].left&&
            d[0].back==d[j].back){
                printf("No\n");
                return 0;
            }
            roll('E',&d[j]);
        }
    }

    printf("Yes\n");
    
    return 0;
}

Measured memory_bytes: 584
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i ++)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> PL;
typedef pair<int,int> P;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const double eps = 1e-6;
int N,L;
vector<int> S,T,U;

bool ok(double x){
    int t = 0;
    double tank = (double)L;
    rep(i,N){
        tank = min((double)L,tank + (S[i] - t)*x);
        t = S[i];
        tank = min((double)L,tank + (T[i] - t)*(x - U[i]));
        if (tank < 0) return false;
        t = T[i];
    }
    tank = min((double)L,tank + (86400 - t)*x);
    double one_day_tank = tank;
    t = 0;
    rep(i,N){
        tank = min((double)L,tank + (S[i] - t)*x);
        t = S[i];
        tank = min((double)L,tank + (T[i] - t)*(x - U[i]));
        if (tank < 0) return false;
        t = T[i];
    }
    tank = min((double)L,tank + (86400 - t)*x);
    return abs(one_day_tank - tank) < 1e-8;
}

void solve(){
    S.resize(N),T.resize(N),U.resize(N);
    rep(i,N) scanf("%d %d %d",&S[i],&T[i],&U[i]);
    double l = 0.0,r = 1e10;
    rep(_,150){
        double m = (r + l)/2;
        if (ok(m)) r = m;
        else l = m;
    }
    printf("%.10f\n",r);
}

int main() {
    while (1){
        scanf("%d %d",&N,&L);
        if (N == 0) return 0;
        solve();
    }
}


Measured memory_bytes: 3904
#include <iostream>
#include <cmath>
using namespace std;
typedef long long ll;

ll n,s;

ll digit_sum(ll b,ll m){
	if(m<b) return m;
	else return digit_sum(b,m/b) + m%b;
}

int main(){
	cin >> n >> s;
	bool judge = false;
	ll ans = -1;
	ll t;
	for(ll i=2;i*i<=n;i++){
		if(s==digit_sum(i,n)){
			ans = i;
			judge = true;
			break;
		}else if((i+1)*(i+1)>n){
			t = (i+1)*(i+1);
		}
	}
	if(!judge && n-s>0){
		for(ll q=1;q*q<=n;q++){
			if((n-s)%q==0){
				ll b = (n-s)/q+1;
				if(s==digit_sum(b,n)){
					ans = b;
				}
			}
		}
	}
	if(!judge && n==s) ans = n+1;
	cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static int two(int a) {
		int tmp = a;
		int cnt = 0;
		while(tmp % 2 == 0) {
			tmp /= 2;
			++cnt;
		}
		return cnt;
	}
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int a[] = new int[n];
		int min = 30;
		for(int i = 0; i < n; ++i) {
			a[i] = sc.nextInt();
			int tmp = two(a[i]);
			min = Math.min(min,  tmp);
		}
		sc.close();
		System.out.println(min);
	}

}


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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<double> vd;
typedef vector<string> vs;
typedef pair<int, int> P;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

void YN(bool flg){if(flg) cout << "YES" << endl; else cout << "NO" << endl;}
void Yn(bool flg){if(flg) cout << "Yes" << endl; else cout << "No" << endl;}
void yn(bool flg){if(flg) cout << "yes" << endl; else cout << "no" << endl;}

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

int MAX = 1000010;

int main()
{   
    int n;
    cin >> n;
    vi a(n);
    rep(i, n) cin >> a[i];

    vi cnt(MAX);
    for(auto x : a) {
        if(cnt[x] > 1) continue; 
        for(int j = x; j < MAX; j+=x) {
            cnt[j]++;
        }
    }

    int ans = 0;
    rep(i, n) if(cnt[a[i]]-1 == 0) ans++;

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 7952
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int vis[105],prime[105],cnt=0;
void init(){
    for(int i=2;i<=100;i++){
        if(vis[i])
            continue;
        prime[cnt++] = i;
        for(int j=2*i;j<=100;j+=i){
            vis[j]=1;
        }
    }
}
map<int,int> m;
map<int,int>::iterator it;
void slo(int n){
    for(int i=0;i<cnt;i++){
        while (n%prime[i]==0){
            m[prime[i]]++;
            n/=prime[i];
        }
    }
}
ll cn3(ll x){
    return max(0ll,(x-1)*x*(x-2)/6);
}
ll cn2(ll x){
    return max(0ll,(x-1)*x/2);
}
int n;
vector<int> v;
int main(){
    ios::sync_with_stdio(false);
    init();
    cin>>n;
    for(int i=1;i<=n;i++){
        slo(i);
    }
    ll n2=0,n4=0,n14=0,n24=0,n74=0;
    for(it=m.begin();it!=m.end();it++){
        if(it->second>=74)
            n74++;
        if(it->second>=24)
            n24++;
        if(it->second>=14)
            n14++;
        if(it->second>=4)
            n4++;
        if(it->second>=2)
            n2++;
    }
    ll ans = 0;
    ans+=n74;
    ans+=3*cn3(n4)+(n2-n4)*cn2(n4);
    ans+=2*cn2(n24)+n24*(n2-n24);
    ans+=2*cn2(n14)+(n14)*(n4-n14);
    cout<<ans<<endl;
}

Measured memory_bytes: 256
import std.stdio, std.string, std.array, std.conv, std.typecons, std.algorithm;

T diff(T)(const ref T a, const ref T b) { return a > b ? a - b : b - a; }

void main() {
    immutable n = readln.chomp.to!(ulong);

    auto vs = new Tuple!(ulong, "n", string, "s", ulong, "p")[n];
    for (ulong i = 0; i < n; i++) {
        immutable ip = readln.split;
        vs[i].n = i+1;
        vs[i].s = ip[0];
        vs[i].p = ip[1].to!(ulong);
    }

    vs.sort!((a, b) {
            if (a.s == b.s) return a.p > b.p;
            return a.s < b.s;
            });

    foreach(v ; vs) {
        writeln(v.n);
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int arr[25];
int cnt;
int main()
{
  int n;
  scanf("%d", &n);
  for(int i=0; i<n; i++)
    scanf("%d", arr+i);
  for(int i=1; i<n-1; i++)
  {
    if((arr[i]>arr[i+1] && arr[i]<arr[i-1])||(arr[i]<arr[i+1] && arr[i]>arr[i-1]))
      cnt++;
  }
  printf("%d\n", cnt);
  return 0;
}

Measured memory_bytes: 256
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <utility>
#include <iterator>
#include <set>
#include <map>
#include <limits>
#include <list>
#include <cstring>
#include <numeric>
#include <functional>
#include <sstream>
#include <deque>
#include <bitset>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <ctime>
 
using namespace std;
 
#define ll long long
#define ld long double
#define pb push_back
 
int main()
{
	ios_base::sync_with_stdio(false);
	int w, h, n, x, y, a, xs, xe, ys, ye, area;
	cin >> w >> h >> n;
	xs = ys = 0;
	xe = w;
	ye = h;
	area = w*h;
	while (n--)
	{
		cin >> x >> y >> a;
		if (a == 1)
		{
			if ((x - xs) <= 0)
				continue;
			area -= (min(x, xe) - xs)*(ye - ys);
			xs = x;
		}
		else if (a == 2)
		{
			if ((xe - x) <= 0)
				continue;
			area -= (xe - max(x, xs))*(ye - ys);
			xe = x;
		}
		else if (a == 3)
		{
			if ((y - ys) <= 0)
				continue;
			area -= (xe - xs)*(min(y, ye) - ys);
			ys = y;
		}
		else if (a == 4)
		{
			if ((ye - y) <= 0)
				continue;
			area -= (xe - xs)*(ye - max(y, ys))
				; ye = y;
		}
	}
	cout << max(area, 0);
	return 0;
}

Measured memory_bytes: 256
x=int(input())

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

        divisors.sort()
        return divisors
    yakusu=make_divisors(x)
    f=0
    for i in yakusu:
        a=0
        b=a-i
        while(1):
            if (a**5-b**5)==x:
                f=1
                break
            elif (a**5-b**5)>x and b>0:
                break
            else:
                a+=1
                b+=1
        if f==1:
            print(a, b)
            break

Measured memory_bytes: 9420
N = int(input())
A = list(map(int,input().split()))
A.sort()

from collections import deque
q = deque(A)
mn = q.popleft()
mx = q.pop()

arr = []
for a in q:
    if a >= 0:
        arr.append((mn, a))
        mn -= a
    else:
        arr.append((mx, a))
        mx -= a
arr.append((mx, mn))
print(mx - mn)
for a,b in arr:
    print(a,b)

Measured memory_bytes: 24596
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(a) (a).begin(), (a).end()
typedef vector<int> vi;
const int INF = 1LL << 58;
// const int INF = 1 << 29;
const int MOD = 1000000007;
const int MAX_N = 200100;

int dp[(1 << 19)][51];

signed main()
{
    //  以降 cin の入力元が 'input.txt' になる
    //std::ifstream in("input.txt");
    //std::cin.rdbuf(in.rdbuf());
    int N;
    cin >> N;

    int AB[18][2];
    REP(i, N)
    cin >> AB[i][0];
    REP(i, N)
    cin >> AB[i][1];

    REP(i, (1 << N))
    {
        REP(j, 51)
        {
            dp[i][j] = INF;
        }
    }

    dp[0][0] = 0;

    REP(bit, (1 << N))
    {
        int cnt = 0;
        REP(s, N)
        {
            if (bit & (1 << s))
            {
                cnt++;
            }
        }
        REP(s, 51)
        {
            if (dp[bit][s] >= INF)
                continue;
            int cntt = cnt;
            REP(t, N)
            {
                if (!(bit & (1 << t)))
                {
                    int tmp;
                    if (abs(cnt - t) % 2 == 0)
                        tmp = AB[t][0];
                    else
                        tmp = AB[t][1];
                    if (tmp >= s)
                        dp[bit | (1 << t)][tmp] = min(dp[bit | (1 << t)][tmp], dp[bit][s] + abs(cnt - cntt));
                    cntt++;
                }
            }
        }
    }
    int ans = INF;
    REP(i, 51)
    {
        ans = min(ans, dp[(1 << N) - 1][i]);
    }
    if (ans == INF)
    {
        cout << -1 << endl;
    }
    else
        cout << ans << endl;

    return 0;
}

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

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

    int ans = 0;
    for (int i = 0; i <= a; i++) {
        for (int j = 0; j <= b; j++) {
            for (int k = 0; k <= c; k++) {
                if (500 * i + 100 * j + 50 * k == x) {
                    ans++;
                }
            }
        }
    }
    cout << ans << endl;

    return 0;
}

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

typedef long long lint;
typedef unsigned long long ulint;
const int MOD=1000000007;

int main(){
    int N;
    cin >> N;
    bool d=(N>=1000);
    string s=d?"ABD":"ABC";
    cout << s << endl;

    return 0;
}

Measured memory_bytes: 256
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce
import pprint
sys.setrecursionlimit(10 ** 9)


INF = 10 ** 20
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007


n, c = LI()
A = LI()
B = LI()

pre_compute = [[0] * 401 for _ in range(401)]
for ii in range(401):
    for jj in range(401):
        pre_compute[ii][jj] = pre_compute[ii - 1][jj]
        pre_compute[ii][jj] += pow(ii, jj, mod)
        pre_compute[ii][jj] %= mod


dp = [[0] * (c + 1) for _ in range(n + 1)]
dp[0][0] = 1
for i in range(n):
    for j in range(c + 1):
        for k in range(j + 1):
            dp[i+1][j] += dp[i][k] * (pre_compute[B[i]][j - k] - pre_compute[A[i] - 1][j - k]) % mod
            # print((pre_compute[j - k][B[i]] - pre_compute[j - k][A[i] - 1]))
            dp[i+1][j] %= mod



print(dp[n][c])






Measured memory_bytes: 86132