akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#define REP(i, n) for (int i = 0; i < (n); i++)

using namespace std;

const int MOD = 998244353;

struct mint {
    int n;
    mint(int n_ = 0) : n(n_) {}
};

mint operator+(mint a, mint b) { a.n += b.n; if (a.n >= MOD) a.n -= MOD; return a; }
mint operator-(mint a, mint b) { a.n -= b.n; if (a.n < 0) a.n += MOD; return a; }
mint operator*(mint a, mint b) { return (long long)a.n * b.n % MOD; }
mint &operator+=(mint &a, mint b) { return a = a + b; }
mint &operator-=(mint &a, mint b) { return a = a - b; }
mint &operator*=(mint &a, mint b) { return a = a * b; }

mint dp[301][90400];
mint dp2[301][90400];

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  int s = 0;
  REP(i, N) cin >> A[i];
  dp[0][0] = 1;
  dp2[0][0] = 1;
  REP(i, N) {
    REP(j, s+1) {
      dp[i+1][j+A[i]] += dp[i][j]*2;
      dp[i+1][j] += dp[i][j];
      dp2[i+1][j+A[i]] += dp2[i][j];
      dp2[i+1][j] += dp2[i][j];
    }
    s += A[i];
  }
  mint ans = 1;
  REP(i, N) ans *= 3;
  mint t = 0;
  REP(i, s+1) {
    if (s-i >= i) {
      ans -= 3*dp[N][i];
    }
  }
  if (s%2==0) {
    t += dp2[N][s/2];
    ans += 3*dp2[N][s/2];
  }
  cout << ans.n << endl;
}


Measured memory_bytes: 212864
from math import cos, radians, sqrt

A, B, H, M = map(int, input().split())
ang_H = 30 * H +  0.5 * M
ang_M = 6 * M
ang = abs(ang_H - ang_M)

if abs(ang) > 180:
    ang = 360 - ang

C = A**2 + B**2 - 2*A*B*cos(radians(ang))
print(sqrt(C))

Measured memory_bytes: 9588
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <set>
#include <map>
using namespace std;
const int INF = 0x3f3f3f3f;
const long long INF64 = 5e18;
const unsigned long long HASHBASE=1222827239ull;
/////////////////////////
long long a[100001];
long long n;
long long sum=0;
/////////////////////////
int main()
{
    ios::sync_with_stdio(false); cin.tie(0);
    cin>>n;
    for(long long i=0ll;i<n;++i)
    {
        cin>>a[i];
        sum+=(i%2ll?(-1ll):1ll)*a[i];
    }
    for(long long i=0ll;i<n;++i)
    {
        cout<<sum<<" ";
        sum=(a[i]-sum/2ll)*2ll;
    }
    return 0;
}


Measured memory_bytes: 2176
package main

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

func main() {
	n := getInt()
	sumYen := 0.0
	for i := 0; i < n; i++ {
		x := getFloat()
		u := getString()
		if u == "BTC" {
			sumYen += x * 380000
		} else {
			sumYen += x
		}
	}

	fmt.Println(sumYen)
}

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

var sc = bufio.NewScanner(os.Stdin)

func init() {
	// buf := 200001
	// sc.Buffer(make([]byte, buf), buf)
	sc.Split(bufio.ScanWords)
}

func getInt() int {
	i, err := strconv.Atoi(getString())
	if err != nil {
		panic(err)
	}
	return i
}

func getFloat() float64 {
	f, err := strconv.ParseFloat(getString(), 64)
	if err != nil {
		panic(err)
	}
	return f
}

func getString() string {
	sc.Scan()
	s := sc.Text()
	return s
}


Measured memory_bytes: 640
n = int(input())
l = list(map(int,input().split()))
l.sort()
ans = 0
for i in range(len(l)-2):
    x = l[i]
    for j in range(i+1,len(l)-1):
        y = l[j]
        for k in range(j+1,len(l)):
            z = l[k]
            if x+y>z and y+z>x and z+x>y:
                if x!=y and y!=z:
                    ans += 1
print(ans)

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

int main(){
  int n, k;
  cin >> n >> k;
  vector<int> vec(n);
  for(int i=0; i<n; ++i){
    cin >> vec.at(i);
  }
  sort(vec.begin(), vec.end());
  long long ans=0;
  for(int i=0; i<n-k; ++i){
    ans += vec.at(i);
  }
  cout << ans << endl;
}

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

// why ak I so weak

int n, k;
int a[100055];

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

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

		int pos;

		for (int i = 0; i < n; i++) if (a[i] == 1) {
			pos = i;
		}

		int res = 0;
		int l;

		if (pos < k) {
			res++;
			l = k;
		} else {
			res += 1 + (pos + 1 - k + (k - 1) - 1) / (k - 1);
			l = res * (k - 1);
			l++;
		}

		if (l < n) {
			res += (n - l + k - 2) / (k - 1);
		}
		
		ans = min(ans, res);
	}
	
	reverse(a, a + n);
	
	{

		int pos;

		for (int i = 0; i < n; i++) if (a[i] == 1) {
			pos = i;
		}

		int res = 0;
		int l;

		if (pos < k) {
			res++;
			l = k;
		} else {
			res += 1 + (pos + 1 - k + (k - 1) - 1) / (k - 1);
			l = res * (k - 1);
			l++;
		}

		if (l < n) {
			res += (n - l + k - 2) / (k - 1);
		}
		
		ans = min(ans, res);
	}

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

	return 0;
}


Measured memory_bytes: 640
#include <stdio.h>

int main(){
    int n,i;
     long long int a[100000],c=1;
    scanf("%d", &n);
  
   for(i=0; i<n; i++){
  scanf("%lld",&a[i]);
   
  

        if (a[i] == 0){
            printf("0");
            return 0;
        }
    }


for (i = 0;i < n;i++){
if(a[i]<=1000000000000000000/c){
  c*=a[i];}
  else {printf("-1\n");
            return 0;
    }}
    
    printf("%lld\n",c);
    
    return 0;
}



Measured memory_bytes: 2516
/* E */
#include <bits/stdc++.h>
#define Fail puts("NO"), exit(0);
#define eps 1e-10
#define maxn 100010
#define maxm 4010
#define inf 1000000007
#define mod 1000000007
#define G 3
#define pi acos(-1)
#define mp(x, y) make_pair(x, y)
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef bitset<maxn> bit;
int read() {
    int x = 0, f = 1;
    char ch = getchar();
    while (ch - '0' < 0 || ch - '0' > 9) {
        if (ch == '-')
            f = -1;
        ch = getchar();
    }
    while (ch - '0' >= 0 && ch - '0' <= 9) {
        x = x * 10 + ch - '0';
        ch = getchar();
    }
    return x * f;
}
int primesize, prime[maxn], miu[maxn];
bool notprime[maxn];
void init() {
    notprime[1] = 1;
    miu[1] = 1;
    for (int i = 2; i <= 100000; i++) {
        if (!notprime[i]) {
            prime[++primesize] = i;
            miu[i] = mod - 1;
        }
        for (int j = 1; j <= primesize && i * prime[j] <= 100000; j++) {
            notprime[i * prime[j]] = 1;
            if (i % prime[j] == 0) {
                miu[i * prime[j]] = 0;
                break;
            }
            miu[i * prime[j]] = mod - miu[i];
        }
    }
}
int n, K, ans;
int quick_pow(int x, int p) {
    int an = 1, po = x;
    while (p) {
        if (p & 1)
            an = 1ll * an * po % mod;
        po = 1ll * po * po % mod;
        p >>= 1;
    }
    return an;
}
int main() {
    init();
    n = read();
    K = read();
    for (int i = 1; i <= K; i++) {
        int sum = 0;
        for (int j = 1; j * i <= K; j++) {
            sum = (sum + 1ll * miu[j] * quick_pow(K / (i * j), n)) % mod;
        }
        ans = (ans + 1ll * sum * i) % mod;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4164
def abc138_e():
    s = str(input())
    t = str(input())
    sd = dict()
    for i, c in enumerate(s):
        if sd.get(c) == None: sd[c] = []
        sd[c].append(i)
    from bisect import bisect_left
    k = 0
    p = 0
    for c in t:
        if sd.get(c) == None: return print(-1)
        idx = bisect_left(sd[c], p)
        if idx == len(sd[c]):
            k += 1
            p = 0
            idx = bisect_left(sd[c], p)
        p = sd[c][idx] + 1
    ans = k * len(s) + p
    return print(ans)

if __name__ == '__main__':
    abc138_e()

Measured memory_bytes: 13496
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)

//素数判定
bool isPrime(int num){
  if (num < 2) return false;
  else if (num == 2) return true;
  else if (num % 2 == 0) return false;
  double sqrtNum = sqrt(num);
  for (int i = 3; i <= sqrtNum; i += 2){
    if (num % i == 0) return false;
  }
  return true;
}

int main(){
  string s;
  cin >> s;
  
  int n = s.size();
  int ans = 0;
  rep(i,n-1){
    if(s[i] == s[i+1]){
      ans++;
      if(s[i] == '0') s[i+1] = '1';
      if(s[i] == '1') s[i+1] = '0';
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 3792
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <math.h>

#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define rep+(i, a, b) for(int i = a; i < b; i++)
#define rep-(i, a, b) for(int i = a - 1; i >= b; i--)

using namespace std;

int main()
{
  int a = 0 , b = 0, c = 0, d = 0, e = 0, f = 0, i = 0, j = 0;
  int num = 0, count = 0, ans = 0;
  double d1 = 0, d2 = 0, d3 = 0, d4 = 0, d5 = 0, d6 = 0;
  int a1[256], a2[512], a3[1024];
  //char s1[200000], s2[200000], s3[200000];
  //string s1, s2, s3;
  
  cin >> a >> b;
  
  if(a - b * 2 <= 0){
    cout << 0 << endl;
  }else{
    cout << a - b * 2 << endl;
  }
}
  


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/range/irange.hpp>
#include <boost/range/adaptors.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;
using uint = unsigned int;
using ll = long long int;
using ull = unsigned long long int;

int main() {
    ll N, M;
    cin >> N >> M;
    vector<ll> as(N, 0), bs(N, 0), cs(M, 0), ds(M, 0);
    for (auto &&i: irange(0LL, N)){
        cin >> as.at(i) >> bs.at(i);
    }
    for (auto &&i: irange(0LL, M)){
        cin >> cs.at(i) >> ds.at(i);
    }
    vector<vector<ll>> manhattan(N, vector<ll>(M, 0));
    for (auto &&i: irange(0LL, N)){
        for (auto &&j: irange(0LL, M)){
            manhattan.at(i).at(j) = abs(as.at(i)-cs.at(j)) + abs(bs.at(i)-ds.at(j));
        }
    }
    for (auto &&i: irange(0LL, N)){
        ll min_ind{numeric_limits<ll>::max()};
        ll minimum{numeric_limits<ll>::max()};
        for (auto &&j: irange(0LL, M)){
            if (manhattan.at(i).at(j) < minimum){
                min_ind = j;
                minimum = manhattan.at(i).at(j);
            }
        }
        cout << min_ind + 1 << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define MOD (long long)1000000007
string s;
long long dp[111111][2];
signed main(){
	cin>>s;
	dp[0][1]=(long long)1;
	dp[0][0]=(long long)2;
	for(int i=1;i<s.size();i++){
		dp[i][1]+=dp[i-1][1]*3;
		if(s[i]=='1')dp[i][1]+=dp[i-1][0];
		if(s[i]=='0')dp[i][0]+=dp[i-1][0];
		else dp[i][0]+=dp[i-1][0]*2;
		dp[i][0]%=MOD;
		dp[i][1]%=MOD;
	}
	cout<<(dp[s.size()-1][0]+dp[s.size()-1][1])%MOD<<endl;
	return 0;
}


Measured memory_bytes: 2048
#include <stdio.h>

int main(){
	int N,tmp,cnt;
	int i,p,q;

	scanf("%d", &N);
	
        if(N<0 && N>100) return -1;

        int L[N*2];
	for( i=0; i<N*2; i++ ){
		scanf("%d ",&L[i]);
     if (L[i] < 0 || L[i] > 100 ){
      return -1;
    }
	}

	//降順ソート
	for( p = 0; p <( N*2)-1; p++){
		for(q = p + 1; q < (N*2); q++){
			if(L[p] < L[q]){
				tmp = L[p];
				L[p] = L[q];
				L[q] = tmp;
			}
		}
	}

	//最大数の和を求める
	for( i= 0; i<N*2; i+=2 ){
		cnt += L[i+1];
	}

	printf("%d",cnt);

	return 0;
}




Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main() {
	string str;
	cin >> str;
	for(int i = 0; i < str.length(); i++) {
		if(str[i] == ',') {
			cout << " ";
		} else {
			cout << str[i];
		}
	}
	cout << endl;

	return 0;
}

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

def main():
    N = int(input())
    A = list(map(int, input().split()))

    ret = 1
    state = 0
    for i in range(1,N):
#        print(i,A[i],A[i-1],state,ret)
        if A[i]>A[i-1]:
            if state == -1:
                ret += 1
                state = 0
            else:
                state = 1
        elif A[i]<A[i-1]:
            if state == 1:
                ret += 1
                state = 0
            else:
                state = -1
#        print(i,A[i],A[i-1],state,ret)
    print(ret)

if __name__ == '__main__':
    main()

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

int hamming(int n);

int main(void){
  int m,n;
  int retval;
  int hammingList[1000001];
  for(int i=0;i<=1000000;i++){
    hammingList[i]=hamming(i);
  }

  while(cin>>m>>n){
    retval=0;
    for(int i=m;i<=n;i++){
      retval+=hammingList[i];
    }
    cout<<retval<<endl;
  }
  return 0;
}

int hamming(int n){
  while(n>1){
    if((n/2)*2==n){
      n=n/2;
    }
    else{
      break;
    }
  }
  while(n>1){
    if((n/3)*3==n){
      n=n/3;
    }
    else{
      break;
    }
  }
  while(n>1){
    if((n/5)*5==n){
      n=n/5;
    }
    else{
      break;
    }
  }
  if(n==1) return 1;
  else return 0;
}



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

for h in range(1, 3501):
    for n in range(h, 3501):
        if 4 * h * n - N * n - N * h > 0 and  N * h * n % (4 * h * n - N * n - N * h) == 0:
            print(h, n, N * h * n // (4 * h * n - N * n - N * h))
            exit()


Measured memory_bytes: 2940
#include<iostream>
#include<string>
#include<cstdlib>
#include<algorithm>
#include<vector>

using namespace std;

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

	if((100*a+10*b+c) % 4 == 0)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
	
 	return 0;
}

Measured memory_bytes: 256
//ITP1-11-D: Dice 4
//2019.05.24

#include <stdio.h>

void throwdice(char, int*);

typedef struct dice_ {
  int d[6];
} dice;

int main(void){
  int n;
  int judge;
  scanf("%d\n", &n);
  dice dice[n];

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 6; j++) scanf("%d", &dice[i].d[j]);
  }

  for (int i = 1; i < n; i++) {
    for (int j = 0; j < 6; j++) {
      if (dice[0].d[0] == dice[i].d[j] ) {
        switch (j) {
          case 0:
            break;
          case 1:
            throwdice('N', &dice[i].d[0]);
            break;
          case 2:
            throwdice('W', &dice[i].d[0]);
            break;
          case 3:
            throwdice('E', &dice[i].d[0]);
            break;
          case 4:
            throwdice('S', &dice[i].d[0]);
            break;
          case 5:
            throwdice('N', &dice[i].d[0]);
            throwdice('N', &dice[i].d[0]);
            break;
        }
      }
    }
  }
  for (int i = 1; i < n; i++) {
    for (int j = 0; j < 6; j++) {
      if (dice[0].d[1] == dice[i].d[j] ) {
        switch (j) {
          case 1:
            break;
          case 2:
            throwdice('R', &dice[i].d[0]);
            throwdice('R', &dice[i].d[0]);
            throwdice('R', &dice[i].d[0]);
            break;
          case 3:
            throwdice('R', &dice[i].d[0]);
            break;
          case 4:
            throwdice('R', &dice[i].d[0]);
            throwdice('R', &dice[i].d[0]);
            break;
          case 5:
            break;
        }
      }
    }
  }

  judge = 1;
  int tmp_judge;
  for (int i = 0; i < n-1; i++) {
    for (int j = i+1; j < n; j++) {
      tmp_judge = 0;
      for (int k = 0; k < 6; k++) {
        if (dice[i].d[k] == dice[j].d[k]) tmp_judge++;
        if (tmp_judge == 6) judge = 0;
      }
    }
  }


  if (judge == 1) {
    printf("Yes\n");
  }else if(judge == 0){
    printf("No\n");
  }

  /*d[0] = top
    d[1] = south
    d[2] = east
    d[3] = west
    d[4] = north
    d[5] = bottom */

  return 0;
}

void throwdice(char c, int *d){
  int tmp[6];
  for (int i = 0; i < 6; i++) {
    tmp[i] = d[i];
  }

  if (c == 'N') {
    d[0] = tmp[1]; //top
    d[1] = tmp[5]; //south
    d[2] = tmp[2]; //east
    d[3] = tmp[3]; //west
    d[4] = tmp[0]; //north
    d[5] = tmp[4]; //bottom
  }else if (c == 'E') {
    d[0] = tmp[3]; //top
    d[1] = tmp[1]; //south
    d[2] = tmp[0]; //east
    d[3] = tmp[5]; //west
    d[4] = tmp[4]; //north
    d[5] = tmp[2]; //bottom
  }else if (c == 'W') {
    d[0] = tmp[2]; //top
    d[1] = tmp[1]; //south
    d[2] = tmp[5]; //east
    d[3] = tmp[0]; //west
    d[4] = tmp[4]; //north
    d[5] = tmp[3]; //bottom
  }else if (c == 'S') {
    d[0] = tmp[4]; //top
    d[1] = tmp[0]; //south
    d[2] = tmp[2]; //east
    d[3] = tmp[3]; //west
    d[4] = tmp[5]; //north
    d[5] = tmp[1]; //bottom
  }else if (c == 'R'){
    d[0] = tmp[0]; //top
    d[1] = tmp[3]; //south
    d[2] = tmp[1]; //east
    d[3] = tmp[4]; //west
    d[4] = tmp[2]; //north
    d[5] = tmp[5]; //bottom
  }
}



Measured memory_bytes: 2104
def readinput():
    n=int(input())
    a=list(map(int,input().split()))
    return n,a

def main(n,a):
    #print(a)
    a.sort(reverse=True)
    #print(a)
    sum=a[0]
    j=0
    k=1
    for i in range(2,n):
        sum+=a[k]
        #print(a[k])
        j+=1
        if j==2:
            j=0
            k+=1
    return sum

if __name__=='__main__':
    n,a=readinput()
    ans=main(n,a)
    print(ans)


Measured memory_bytes: 31388
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.Collections;

class Main {
    public static void main(String[] args) throws NumberFormatException, IOException {
        ArrayList<Integer> input = new ArrayList<Integer>();
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        for(int i=0; i<10; i++)  input.add(Integer.parseInt(br.readLine()));
        Collections.sort(input, Collections.reverseOrder());
        for(int i=0; i<3; i++) System.out.println(input.get(i));
    }
}

Measured memory_bytes: 24204
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

const int p = 1000000007;

long long pow3[100100];
long long pow2[100100];

int main(){
    pow3[0] = 1;
    pow2[0] = 1;
    for(int i =0; i < 100050; i++){
        pow3[i + 1] = pow3[i]*3%p;
        pow2[i + 1] = pow2[i]*2%p;
    }
    string s;
    cin >> s;
    reverse(s.begin(),s.end());
    vector<int> ones;
    for(int i = 0; i < s.size(); i++){
        if(s.at(i) == '1') ones.push_back(i);
    }
    long long ans = 0;
    int n = ones.size();
    for(int i = 0; i < n; i++){
        ans += (pow2[n - 1 - i]*pow3[ones[i]])%p;
        ans %= p;
    }
    ans += pow2[n];
    ans %= p;
    cout << ans << endl;
}

Measured memory_bytes: 2556
#include <bits/stdc++.h>
#include <atcoder/all>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(obj)   (obj).begin(),(obj).end()

#define debug(var)  do{std::cout << __LINE__ << "> " << #var << ": ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

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; }

using namespace std;
using namespace atcoder;
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

void Main() {
	int N, M; cin >> N >> M;
	dsu d(N);
	REP(i, M) {
		int a, b; cin >> a >> b;
		--a, --b;
		d.merge(a, b);
	}
	cout << d.groups().size() - 1 << endl;
}

int main() {
    cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
}


Measured memory_bytes: 9004
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;

using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<int> &o) {
    int a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
//const ll mod = 1e10;

typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;

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

    vector<ll> v(n);
    rep(i, n) cin >> v[i];

    vector<ll> sub(n), add(n);
    rep(i, n) sub[i] = v[i] - i;
    rep(i, n) add[i] = v[i] + i;

    map<ll, int> s;
    rep(i, n) s[sub[i]]++;


    ll ans = 0;
    rep(i, n) {
        s[sub[i]]--;
        ll now = s[-add[i]];
        ans += now;
    }

    cout << ans << endl;

}


Measured memory_bytes: 30644
X = int(input())
if (400 <= X <=599):
  print("8")
elif (600 <= X <= 799):
  print("7")
elif (800 <= X <= 999):
  print("6")
elif (1000 <= X <= 1199):
  print("5")
elif (1200 <= X <= 1399):
  print("4")
elif (1400 <= X <= 1599):
  print("3")
elif (1600 <= X <= 1799):
  print("2")
elif (1800 <= X <= 1999):
  print("1")

Measured memory_bytes: 61900
from time import time
from random import randint

from numba import njit
from numpy import int64

@njit('i8(i8[:],i8[:])')
def func(s,x):
    last=[0]*26
    score=0
    for i,v in enumerate(x,1):
        last[v]=i
        c=0
        for j in range(26):
            c+=s[j]*(i-last[j])
        score=score+s[i*26+v]-c
    return score

def main():
    start=time()
    d,*s=map(int,open(0).read().split())
    s=int64(s)
    x=int64(([*range(26)]*15)[:d])
    M=func(s,x)
    while time()-start<1.3:
        y=x.copy()
        if randint(0,1):
            y[randint(0,d-1)]=randint(0,25)
        else:
            i=randint(0,d-16)
            j=randint(i,i+15)
            y[i],y[j]=y[j],y[i]
        t=func(s,y)
        if t>M:
            M=t
            x=y
    print(*x+1,sep='\n')

main()

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

int main()
{
    std::ios::sync_with_stdio(false);
    lld t = 1;
    // cin >> t;
    while(t--) {
        string S, T;
        cin >> S >> T;
        int ans = 0;
        for(int i = 0; i < 3; i++) {
            if(T[i] == S[i]) {
                ans++;
            }
        }
        cout << ans << "\n";
    }
}

Measured memory_bytes: 256
k,x= map(int, input().split())
#-10000, 10000の制約に注意して
#x-k+1から始まってx+k-1で終わる
number = []
number.append(x)
for i in range(1,k):
    number.append(x+i)
    number.append(x-i)
number.sort()
for m in number:
    if m >1000000 or m<-1000000:
        number.pop(m)
for n in number:
    print(n, end=' ')

Measured memory_bytes: 3060
#include<stdio.h>
int main(){
  int a[100][100],b[100][100],n,m,l,i,j,k;
  long c[100][100]={0};
  scanf("%d %d %d",&n, &m,&l);
  for(i=0;i<n;i++){
    for(j=0;j<m;j++){
      scanf("%d",&a[i][j]);
    }
  }
  for(i=0;i<m;i++){
    for(j=0;j<l;j++){
      scanf("%d",&b[i][j]);
    }
  }

  for(i=0;i<n;i++){
    for(j=0;j<l;j++){
	for(k=0;k<m;k++){
	  c[i][j]=c[i][j]+a[i][k]*b[k][j];
	}
      }
  }


  for(i=0;i<n;i++){
    for(j=0;j<l;j++){
      if(j) printf(" ");
      printf("%ld",c[i][j]);
    }
  printf("\n");
  }
  return 0;
}

Measured memory_bytes: 768
#include <iostream>
#include <algorithm>
#include <string>

using namespace std;

long long n, k, res = 0;

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

    sort(arr, arr + n);
    int p = n - k;
    for(int i = 0; i < p; i++){
        res += arr[i];
    }
    cout << res << endl;
}

Measured memory_bytes: 1024
// ABC175DW.cpp
//#include "pch.h"
#include <iostream>
#include <vector>
#include <set>
#include <algorithm> // max
using namespace std;
using ll = long long;
#define rep(i,n) for (ll i = 0; i < (n); ++i)
int main()
{
    ll n, k;
    cin >> n >> k;
    vector<ll>p(n);
    rep(i, n) {
        cin >> p.at(i);
        p.at(i)--;
    }
    vector<ll>c(n);
    rep(i, n) {
        cin >> c.at(i);
    }
    vector<vector<ll>> s(n); // 各マスからスタートする
    vector<ll>sum(n);
    rep(i, n) {
        ll st = i; // 各ループのスタート位置
        ll now = st;
        s.at(i).push_back(st);
        sum.at(i) = c.at(st);
        while (st != p.at(now)) {
            s.at(i).push_back(p.at(now));
            sum.at(i) += c.at(p.at(now)); // 各ループの小計　負なら繰り返さないほうが良い
            now = p.at(now);
        }
    }
    vector<ll> cnt(n,-1);
    vector<ll> period(n);
    vector<ll>mx(n,-1e18);
    ll ans=-1e18;
    rep(i, n) { // 各マスから初めてみる
        period.at(i) = s.at(i).size(); // それぞれの周期の長さ
        ll sums = 0;
        rep(a, period.at(i)) {
            if (a + 1 > k) break;
            sums += c.at(s.at(i).at(a));
            ll rpt_times_sum = 0;
            ll rpt_times = 0;
            if (sum.at(i) > 0) {
                rpt_times = (k - a - 1) / period.at(i); // sumが正の時の繰り返しの回数
                rpt_times_sum = rpt_times * sum.at(i); // 繰り返した部分の合計
            }
            ans = max(ans, sums + rpt_times_sum);
        }
    }
        cout << ans << endl;
        return 0;
    }


Measured memory_bytes: 218664
# 168_b
K = int(input())
S = input()
# str.islower()
# >文字列中の大小文字の区別のある文字全てが小文字で、
# >かつ大小文字の区別のある文字が 1 文字以上あるなら True を、そうでなければ False を返します。

if (1 <= K and K <= 100) and S.islower() and (1 <= len(S) and len(S) <= 100):
    if len(S)<=K:
        print(S)

    elif len(S)>K:
        print("{}...".format(S[0:K]))


Measured memory_bytes: 9168
#include<iostream>
#include<algorithm>
using namespace std;
static const int Max=200000;

int main(){
    int R[Max],n;
    cin>>n;
    for(int i=0;i<n;i++)cin>>R[i];
    int maxv=-2000000000;
    int minv=R[0];
    for(int i=1;i<n;i++){
        maxv=max(maxv,R[i]-minv);
        minv=min(minv,R[i]);
    }
    cout<<maxv<<endl;
    return 0;
}


Measured memory_bytes: 3884
#include <iostream>
#include <string>
#include <cmath>
using namespace std;

#define Rep(i, n) for(int i = 0; i < (int)(n); i++)
#define PrintLn(X) cout << X << endl
int main(void)
{
	int a, b;
	cin >> a >> b;
	if(a + b < 10){
		PrintLn(a + b);
	}else{
		PrintLn("error");
	}
	return 0;
}


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

template<class T>
void chmax(T &a, T b) {if (a < b) a = b;}
ll dp[110][10010];

int main(int argc, char **argv)
{
	ll N, W; cin >> N >> W;
	vector<ll> value(N), weight(N);
	for (ll i = 0; i < N; ++i) cin >> value[i] >> weight[i];
	memset(dp, 0, sizeof dp);

	for (ll i = 0; i < N; ++i)
	{
		for (ll w = 0; w <= W; ++w)
		{
			chmax(dp[i+1][w], dp[i][w]);
			if (w-weight[i]>=0)chmax(dp[i+1][w], dp[i][w-weight[i]]+value[i]);
		}
	}
	std::cout << dp[N][W] << std::endl;
}



Measured memory_bytes: 11704
function Main(input){
var inputs = input.split(" ");
var A = new Number(inputs[0]);
var B = new Number(inputs[1]);
var K = (A+B)/2;
var jud = Number.isInteger(K);
if(jud == true){
  console.log(K);
}else{
  console.log("IMPOSSIBLE")
}
}
Main(require('fs').readFileSync('/dev/stdin','utf8'));

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

using namespace std; 

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	
	int a, b;
	cin >> a >> b;
	for(int i = 1; i <= 10000000; i++) {
		if((i*8)/100 == a and (i*10)/100 == b) {
			cout << i << '\n';
			return 0;
		}
	}
	cout << -1 << '\n';

	return 0;
}


Measured memory_bytes: 256
from operator import mul
from functools import reduce
from math import floor, log
from itertools import combinations, product

S = input()
N = int(S)
K = int(input())

S_len = len(S)
N_first = int(S[0])

def combinations_count(n, r):
  if n < r:
    return 0
  if r == 0:
    return 1
  r = min(r, n - r)
  numer = reduce(mul, range(n, n - r, -1), 1)
  denom = reduce(mul, range(1, r + 1), 1)
  return numer // denom

if K > S_len:
  print(0)
else:
  count = 0
  if K > 1:
    for l in combinations(range(1, S_len), K-1):
      for m in product('123456789', repeat=K-1):
        s = S[0] + '0' * (S_len - 1)
        for i in range(K-1):
          s = s[:l[i]] + m[i] + s[l[i]+1:]
        if int(s) <= N:
          count += 1
  else:
    count += 1
  count += (N_first-1) * combinations_count(S_len-1, K-1) * (9 ** (K-1))
  count += combinations_count(S_len-1, K) * (9 ** K)
  print(count)


Measured memory_bytes: 3572
z[4000],*a=z,*b=z+2000,m,i,j,t,u;main(n){for(;scanf("%d",&n)*n++;m=!printf("%d\n",m))for(i=n;i--;j=a,a=b,b=j)for(j=n;j--;t>m?m=t:0)t=b[j]=n+~i&&getchar()>45?1+fmin(u=a[j],fmin(t,u)):0;}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
int N,M;

int main()
{
	while(true){
		scanf("%d%d",&N,&M);
		if(N==0&&M==0)return 0;
		int cost[200][200];
		int time[200][200];
		int minc[200][200];
		int mint[200][200];
		for(int i=0;i<M;i++){
			for(int j=0;j<M;j++){
				cost[i][j]=1<<25;
				time[i][j]=1<<25;
				minc[i][j]=1<<25;
				mint[i][j]=1<<25;
				if(i==j){
					cost[i][j]=0;
					time[i][j]=0;
					minc[i][j]=0;
					mint[i][j]=0;
				}
			}
		}
		int A,B,co,ti;
		for(int i=0;i<N;i++){
			scanf("%d%d%d%d",&A,&B,&co,&ti);A--;B--;
			cost[A][B]=co;cost[B][A]=co;
			time[A][B]=ti;time[B][A]=ti;
		}
		for(int i=0;i<M;i++){
			for(int j=0;j<M;j++){
				for(int k=0;k<M;k++){
					cost[j][k]=min(cost[j][k],cost[j][i]+cost[i][k]);
					time[j][k]=min(time[j][k],time[j][i]+time[i][k]);
				}
			}
		}
		
		int K;
		scanf("%d",&K);
		for(int i=0;i<K;i++){
			int P,Q,R;
			scanf("%d%d%d",&P,&Q,&R);P--;Q--;
			if(R==0)printf("%d\n",cost[P][Q]);
			else printf("%d\n",time[P][Q]);
		}
	}
}

Measured memory_bytes: 1352
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int day, sumptn = 0;
		int N = sc.nextInt();//予定を組む日数
		int K = sc.nextInt();//ソースが決まっている日数
		int[] plan = new int[N];
		int[][] pattern = new int[N][6];
		for(int i = 0; i < K; i++) {
			day = sc.nextInt();
			plan[day-1] = sc.nextInt();
		}
		if(plan[0] == 0) {pattern[0][0]=1; pattern[0][1]=1; pattern[0][2]=1;}
		else if(plan[0] == 1) pattern[0][0] = 1;
		else if(plan[0] == 2) pattern[0][1] = 1;
		else if(plan[0] == 3) pattern[0][2] = 1;
		
		for(int i= 1; i < N; i++) {
			for(int k = 0; k < 6; k++) sumptn += pattern[i-1][k]%=10000;
			for(int j = 0; j < 6; j++) {
				if(plan[i] == 0) {//予定がない場合
					if(j<3) pattern[i][j] = sumptn-pattern[i-1][j]-pattern[i-1][j+3];
					else pattern[i][j] = pattern[i-1][j-3];
				} else if(plan[i] == 1){//予定がある場合
					pattern[i][0] = sumptn-pattern[i-1][0]-pattern[i-1][3];
					pattern[i][3] = pattern[i-1][0];break;
				} else if(plan[i] == 2) {
					pattern[i][1] = sumptn-pattern[i-1][1]-pattern[i-1][4];
					pattern[i][4] = pattern[i-1][1];break;
				} else if(plan[i] == 3) {
					pattern[i][2] = sumptn-pattern[i-1][2]-pattern[i-1][5];
					pattern[i][5] = pattern[i-1][2];break;
				}
			}
			sumptn = 0;
		}
		 for(int j = 0; j < 6; j++) sumptn += pattern[N-1][j];
		System.out.println(sumptn%10000);
	}
}

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

int main()
{
    ll x;
    cin >> x;
    ll ans = (x/500)*1000 + (x-x/500*500)/5*5;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
int i;
int a;
int mountain[10];
for(i =0;i<10;i++){
scanf("%d",&mountain[i]);
}
int x;
for(i=0;i<10;i++){
for(x=0;x<=2;x++){
if(mountain[x]<mountain[i] && x<i){
a = mountain[x];
mountain[x] = mountain[i];
mountain[i] = a;
}
}
}
printf("%d\n",mountain[0] );
printf("%d\n",mountain[1]);
printf("%d\n",mountain[2]);
return 0;
}   

Measured memory_bytes: 600
//見かけ倒し。簡単に考えれば発想は500点レベル。実装が簡単とは言っていない。
//[A -> B] <-- xor A --> [0 -> A xor B]. 右のパターンを考えて、最後にxor Aすればよい。
//とりあえず、bitCount(A xor B) % 2 == 1は必要
//逆にこれさえ満たせば構成可能。カルノー図の2列verを考えると、くねくね→下→上で構成できる。

#include <iostream>
#include <vector>
using namespace std;

int bitCount(int x) {
	int i, ret = 0;
	for (i = 0; i < 30; i++) {
		if ((x >> i) & 1) {
			ret++;
		}
	}
	return ret;
}

void makeKaruno(int karuno[]) {
	int i, j;
	
	karuno[0] = 0;
	karuno[1] = 1;
	for (i = 2; i < 17; i++) {
		for (j = 0; j < (1 << (i - 1)); j++) {
			karuno[(1 << (i - 1)) + j] = karuno[(1 << (i - 1)) - 1 - j] + (1 << (i - 1));
		}
	}
}

int n, a, b;
int c;
int karuno[1 << 17];

int main() {
	cin >> n >> a >> b;
	c = a ^ b;
	if (bitCount(c) % 2 == 0) { cout << "NO" << endl; return 0; }
	makeKaruno(karuno);
	
	int i, j;
	for (i = 0; i < (1 << (n - 1)); i++) {
		if (c / 2 == karuno[i]) {
			break;
		}
	}
	int gy = i, gx = c % 2;
	
	vector<int> ans;
	for (i = 0; i < gy; i++) {
		if (i % 2 == 0) {
			for (j = 0; j < 2; j++) {
				ans.push_back(karuno[i] * 2 + j);
			}
		}
		else {
			for (j = 1; j >= 0; j--) {
				ans.push_back(karuno[i] * 2 + j);
			}
		}
	}
	
	for (i = gy; i < (1 << (n - 1)); i++) {
		ans.push_back(karuno[i] * 2 + (!gx));
	}
	for (i = (1 << (n - 1)) - 1; i >= gy; i--) {
		ans.push_back(karuno[i] * 2 + gx);
	}
	
	cout << "YES" << endl;
	for (i = 0; i < ans.size(); i++) {
		cout << (ans[i] ^ a);
		if (i + 1 < ans.size()) cout << " ";
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 2040
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <math.h>
#include <bitset>
#include <queue>
#include <set>
#include <iomanip>
#include <math.h>
#include <assert.h>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr long long int infll = 1001001001001001LL;
constexpr int INF = 1000000007;
constexpr int inf = 1000000007;
const int mod = 1000000007;

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

ll gcd(ll a, ll b)
{
    if (a % b == 0)
    {
        return (b);
    }
    else
    {
        return (gcd(b, a % b));
    }
}

ll lcm(ll a, ll b)
{
    return a / gcd(a, b) * b;
}

inline double nCr(const int n, int r)
{
    if (n == 0)
    {
        return 0;
    }
    if (r == 0)
    {
        return 1;
    }
    if (r == 1)
    {
        return n;
    }
    if (n == r)
    {
        return 1;
    }

    if (r > n / 2)
    {
        r = n / 2;
    }

    double result = 1;
    for (double i = 1; i <= r; i++)
    {
        result *= (n - i + 1) / i;
    }

    return (result);
}

template <typename T>
T seinomi(T a)
{
    if (a > 0)
    {
        return a;
    }
    else
    {
        return 0;
    }
}

template <typename T>
map<T, T> soinsuubunkai(T n) //連想配列[素因数f.first][個数f.second]
{
    map<T, T> ret;
    for (T i = 2; i * i <= n; i++)
    {
        while (n % i == 0)
        {
            ret[i]++;
            n /= i;
        }
    }
    if (n != 1)
        ret[n] = 1;
    return ret;
}

template <typename T>
T ketasuu(T num)
{
    return std::to_string(num).length();
}

int kaizyou(int k)
{
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

template <class ForwardIt, class T>
void iota(ForwardIt first, ForwardIt last, T value)
{
    while (first != last)
    {
        *first++ = value;
        ++value;
    }
}

//nの階乗を計算
int factorial(int n)
{
    int answer = 1;
    while (n > 1)
    {
        answer *= n;
        n--;
    }
    return answer;
}
int comb(int n, int r)
{
    return factorial(n) / (factorial(r) * factorial(n - r));
}

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


template <typename T>
T amarinasi(T a,T b){
    if(a%b==0)
{
    return a/b;
}
else if(a%b>0)
{
    return a/b+1;
}
else
{
    return a/b-1;
}
}

//小数点以下10桁テンプレート（main関数内の最初に貼付け）
//std::cout << std::fixed << std::setprecision(10);

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

int main(){
ll a,b,c;
ll k;
cin>>a>>b>>c>>k;
ll tmp[3];
tmp[0]=a;
tmp[1]=b;
tmp[2]=c;
sort(tmp,tmp+3,greater<ll>());
cout<<tmp[0]*pow(2,k)+tmp[1]+tmp[2]<<endl;
}












Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long int def(long long int d)
{
    if(d==1)
    {
        return 1;
    }
    return 1+2*def(d/2);
}
int main()
{
    long long int h;
    cin >> h;
    long long int temp = h;
    long long int ans = def(temp);
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iomanip>
#include <iostream>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;

int main(void) {
  ios::sync_with_stdio(false);
  int X;
  cin >> X;
  if (30 <= X)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}


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

 
int main() {
  // 科目の数Nを受け取る
  int a,b;
  cin >> a >> b;
  
  int Num = (a * b)%2;
  
  if (Num == 0){
      cout << "Even" << endl;
  } else {
      cout << "Odd" << endl;
  }


}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
//#define int long long
#define fo(a,b) for(int a=0;a<b;a++)
#define Sort(a) sort(a.begin(),a.end())
#define rev(a) reverse(a.begin(),a.end())
#define fi first
#define se second
#define co(a) cout<<a<<endl
#define sz size()
#define bgn begin()
#define en end()
#define pb(a) push_back(a)
#define pop pop_back
#define V vector
#define P pair
#define V2(a,b,c) V<V<int>> a(b,V<int>(c))
#define V2a(a,b,c,d) V<V<int>> a(b,V<int>(c,d))
#define incin(a) int a; cin>>a
#define yuko(a) setprecision(a)
//#define min min<int>
//#define max max<int>
template<class T>
 void cou(vector<vector<T>> a){
  int b=a.size();
  int c=a[0].size();
  fo(i,b){
    fo(j,c){
      cout<<a[i][j];
      if(j==c-1)
        cout<<endl;
      else
        cout<<' ';
    }
  }
}
/*template<>
 void cou(vector<vector<char>> a){
  int b=a.size();
  int c=a[0].size();
  fo(i,b){
    fo(j,c){
      cout<<a[i][j];
      if(j==c-1)
        cout<<endl;
      else
        cout<<' ';
    }
  }
}*/
 int wari(int a,int b) {
   if(a%b==0)
     return a/b;
   else
     return a/b+1;
 }
 int keta(int a){
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
 }
 int souwa(int a){
  return a*(a+1)/2;
 }
 int lcm(int a,int b){
  int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return d*e/f;
    }
  int gcm(int a,int b){
      int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return f;
  }
 bool prime(int a){
   if(a<2)
     return false;
   else if(a==2)
     return true;
   else if(a%2==0)
     return false;
   double b=sqrt(a);
    for(int i=3;i<=b;i+=2){
      if(a%i==0){
        return false;
      }
    }
   return true;
 }
struct Union{
  vector<int> par;
  Union(int n){
	par= vector<int>(n, -1);
  }
  int find(int x){
    if(par[x]<0)
      return x;
    else
      return par[x]=find(par[x]);
  }
  bool same(int a,int b){
    return find(a)==find(b);
  }
  int Size(int a){
    return -par[find(a)];
  }
  void unite(int a,int b){
    a=find(a);
    b=find(b);
    if(a==b)
      return;
    if(Size(b)>Size(a))
      swap<int>(a,b);
    par[a]+=par[b];
    par[b]=a;
  }
};
int ketas(int a){
  string b=to_string(a);
  int c=0;
  fo(i,keta(a)){
    c+=b[i]-'0';
  }
  return c;
}
/*struct aa{
	vector<int> gt;
  aa(int n){
	gt= vector<int>(n, 1);
  }
	void c(V<int> d,int b){
	if(d[b]==0){
		gt[d[b]-1]++;
		gt[gt.sz-1]++;
	}
	else{
		gt[d[b]-1]++;
		c(d,d[d[b]]-1);
	}
}
void cok(int a){
	cout<<gt[a-1]<<endl;
	fo(i,a-1)
	cout<<gt[i]<<endl;
}
};
*/
signed main(){
	int a,i=0,c=0;
	cin>>a;
	V<int> b(a);
	fo(i,a)
	cin>>b[i];
	while(1){
		for(int i=0;i<a;i++){
			if(b[i]%2==1){
				c=1;
				break;
			}
			b[i]/=2;
		}
		if(c)
			break;
		i++;
	}
	cout<<i<<endl;
}

Measured memory_bytes: 256
from sys import stdin
import bisect

INF = 10 ** 11

A, B, Q = [int(x) for x in stdin.readline().rstrip().split()]
s_list = [int(stdin.readline().rstrip()) for _ in range(A)]
t_list = [int(stdin.readline().rstrip()) for _ in range(B)]
x_list = [int(stdin.readline().rstrip()) for _ in range(Q)]


def search_lr_distance(target_list, num):
    i = bisect.bisect_left(target_list, num)
    left_index = i - 1
    right_index = i
    
    if left_index < 0:
        left_distance = INF
    else:
        left_distance = num - target_list[left_index]
    
    if right_index > len(target_list)-1:
        right_distance = INF
    else:
        right_distance = target_list[right_index] - num


    return left_distance, right_distance


for x in x_list:
    min_dist = INF
    for s1, s2 in [[t_list, s_list], [s_list, t_list]]:
        move_left, move_right = search_lr_distance(s1, x)
        f_dist1, f_dist2 = search_lr_distance(s2, x+move_right)
        f_dist3, f_dist4 = search_lr_distance(s2, x-move_left)

        min_dist = min(min_dist, f_dist1+move_right, f_dist2+move_right, f_dist3+move_left, f_dist4+move_left)

    print(min_dist)


Measured memory_bytes: 79580
//teja349
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip> 
//setbase - cout << setbase (16); cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 << endl; prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx


using namespace std;
#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >

//std::ios::sync_with_stdio(false); 
vector<vi> adj(123456);
int siz[123456];
vi vec,vec1;
int n;
int getn(int cur,int prev){
	int i;
	//siz[cur]=1;
	vec.pb(cur);
	if(cur==n-1){
		rep(i,vec.size()){
			vec1.pb(vec[i]);
		}
	}
	
	rep(i,adj[cur].size()){
		if(adj[cur][i]!=prev){
			getn(adj[cur][i],cur);
			//siz[cur]+=siz[adj[cur][i]];
		}
	} 
	vec.erase(--vec.end());
	return 0;
}  
int dfs(int cur,int prev){
	int i;
	siz[cur]=1;
	rep(i,adj[cur].size()){
		if(adj[cur][i]!=prev){
			dfs(adj[cur][i],cur);
			siz[cur]+=siz[adj[cur][i]];
		}
	} 
	return 0;
}
int main(){
    std::ios::sync_with_stdio(false);
	//int n;
	int i,u,v;
	cin>>n;
	rep(i,n-1){
		cin>>u>>v;
		u--;
		v--;
		adj[u].pb(v);
		adj[v].pb(u);
	}     
	dfs(0,-1);
	getn(0,-1);
    i=0;
    int j=vec1.size();
    j-=1;
    int flag=1;
    while(i+1<j){
    	if(flag)
    		i++;
    	else
    		j--;
    	flag^=1;
    }
    int val1=siz[vec1[j]];
    int val2=n-val1;
    if(val2>val1){
    	cout<<"Fennec"<<endl;
    }
    else{
    	cout<<"Snuke"<<endl;
    }
    return 0;
}



Measured memory_bytes: 12536
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define INF 1e18
#define PI 3.14159265358979

using namespace std;

int main(void){
  ll n, m;
  cin >> n >> m;
  
  vector<vector<int>> mat(n, vector<int>(n, 0));
  for (int i = 0; i < m; i++){
    ll a, b;
    cin >> a >> b;
    a--; b--;
    mat[a][b] = 1;
    mat[b][a] = 1;
  }
  int c[8] = {0, 1, 2, 3, 4, 5, 6, 7};
  ll res = 0;
  do {
    int ok = 1;
    for (int i = 0; i < n - 1; i++){
      if (mat[c[i]][c[i+1]] == 0)
        ok = 0;
    }
    if (ok)
      res++;
  } while (next_permutation(c + 1, c + n));

  cout << res << endl;

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void){

 int a,b,d,r;

 double f;


 scanf("%d",&a);


 scanf("%d",&b);

 d=a/b;

 r=a-(d*b);

 f=(double)a/b;

 printf("%d %d ",d,r);

 printf("%lf",f);

 return 0;

}

Measured memory_bytes: 636
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double PI=acos(-1);
const double EPS=1e-10;

int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	int n,m,R;
	cin>>n>>m>>R;
	vector<int> r(R),a(R);
	rep(i,R){
		cin>>r[i];
		r[i]--;
		a[i]=i;
	}
	vector<vector<int>> dp(n,vector<int>(n,INF));
	rep(i,n) dp[i][i]=0;
	rep(i,m){
		int a,b,c;
		cin>>a>>b>>c;
		a--,b--;
		dp[a][b]=c;
		dp[b][a]=c;
	}
	rep(k,n)rep(i,n)rep(j,n) chmin(dp[i][j],dp[i][k]+dp[k][j]);
	int ans=INF;
	do{	
		int now=0;
		rep(i,R-1){
			now+=dp[r[a[i]]][r[a[i+1]]];
		}
		chmin(ans,now);
	}while(next_permutation(begin(a),end(a)));
	cout<<ans<<endl;
}

Measured memory_bytes: 384
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
#![macro_use]

use std::cmp::*;
use std::collections::*;
use std::io::prelude::*;
use std::io::*;
use std::mem::*;
use std::num::*;
use std::ops::*;
use std::slice::*;

const MOD: isize = 1000000007;
fn main() {
    let n: usize = input();
    let a: Vec<usize> = (0..n).map(|_| input()).collect();
    let mut b = vec![0usize; n + 1];
    let mut zz = 3;
    let mut kk = 4;
    swap(&mut zz, &mut kk);

    for &i in a.iter() {
        b[i] += 1;
    }

    let mut sm: isize = 0;
    for &i in b.iter() {
        sm += i as isize * (i as isize - 1) / 2;
    }
    for &i in a.iter() {
        println!(
            "{}",
            if (b[i] > 1) {
                sm as usize - (b[i] * (b[i] - 1) / 2) + (b[i] - 1) * (b[i] - 2) / 2
            } else {
                sm as usize
            }
        );
    }
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace() // iter
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn input<T>() -> T
where
    T: std::str::FromStr,
{
    let stdin = std::io::stdin();
    let next: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    next.parse().ok().unwrap()
}


Measured memory_bytes: 10748
#include<cstdio>
#include<cstring>
#include<algorithm>
#define ll long long
using namespace std;
int n,k;
ll ans;
ll cube(ll a){return a*a*a;}
ll sqr(ll a){return a*a;}
int main(){
	scanf("%d%d",&n,&k);
	ans=cube(n/k);
	if(!(k&1)&&k<=(n<<1)){
		ll now=k>>1,tim=(n-now)/k+1;
		ans+=cube(tim);
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 128