akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <ctype.h>
#include <ios> 
#include <iomanip>
using namespace std;

#define N_MAX   (100000)
#define LL_MAX_NUM (1LL<<60)
#define INF 1e7

typedef long long ll;
typedef long long int lli;

int main() {
	int A, B;
	cin >> A >> B;
	if (A + B >= 10) {
		cout << "error" << endl;
	}
	else {
		cout << A + B << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<queue>
using namespace std;

queue<int> card,on,tw;
int maisu;
void f(){
}
int main(){
  int a,b;
  scanf("%d",&maisu);
  maisu*=2;
  int cs[maisu];
  for(int i=maisu;i>=1;i--) card.push(i);
  scanf("%d",&a);
  for(int i=0;i<a;i++){
    scanf("%d",&b);
    if(b){
      for(int j=0;j<maisu-b;j++) {
	card.push(card.front()); 
	card.pop();
      }
    }
    else{
      for(int j=0;j<(maisu/2);j++){
	on.push(card.front());
	card.pop();
      }
      for(int j=0;j<(maisu/2);j++){
	tw.push(card.front());
	card.pop();
      }
      for(int j=0;j<maisu/2;j++){
	card.push(on.front());
	on.pop();
	card.push(tw.front());
	tw.pop();
      }
    }
  }
  for(int j=0;j<maisu;j++){
    cs[maisu-j-1]=card.front();
    card.pop();
  }
  for(int j=0;j<maisu;j++)printf("%d\n",cs[j]);
  return 0;
}

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






int main(){

stack<char> point;



while(true){
string n;
getline(cin,n); 
bool flag=0;
if(n=="."){break;}
for(int i=0;i<n.size();i++){
    if(n[i]=='(' or n[i]==')' or n[i]=='[' or n[i]==']'){
        if(point.empty() ){
            point.push(n[i]);
        }


        else if(!point.empty() and point.top()=='(' and n[i]==')'){
             point.pop(); // 末尾要素を削除
        }
        else if(!point.empty() and point.top()=='[' and n[i]==']'){
             point.pop(); // 末尾要素を削除
        }
        else point.push(n[i]);
    }
}

 /* while (!point.empty()) {
    cout << point.top() << " "; // 末尾要素を参照する
    point.pop(); // 末尾要素を削除
  }*/


if(!point.empty()){
    while (!point.empty()) {
    
    point.pop(); 
  }
    cout<<"no"<<endl;
}
else cout<<"yes"<<endl;






}
    return 0;
}


Measured memory_bytes: 3180
# https://atcoder.jp/contests/abc128/tasks/abc128_c


def check_switch_on(S, btn, P):
    for i, s_row in enumerate(S):
        on_cnt = 0
        # print(s_row)
        for s in s_row:
            if btn[s-1]:
                on_cnt += 1
        if P[i] != on_cnt % 2:
            return False
    return True


if __name__ == "__main__":
    N, M = map(int, input().split())

    S = []
    for _ in range(M):
        l = list(map(int, input().split()))
        k = l[0]
        s_row = l[1:]
        S.append(s_row)

    P = list(map(int, input().split()))

    cnt = 0
    for bit in range(1 << N):
        btn = [False] * N
        for i in range(N):
            if bit & (1 << i):
                btn[i] = True
        if check_switch_on(S, btn, P):
            # print(btn)
            cnt += 1

    print(cnt)


Measured memory_bytes: 42604
package main

import (
	"bufio"
	"container/heap"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

type task struct {
	day, price int
}

type theap []task

func (h theap) Len() int           { return len(h) }
func (h theap) Less(i, j int) bool { return h[i].price > h[j].price } // maxにするためにあえて変更
func (h theap) Swap(i, j int)      { h[i], h[j] = h[j], h[i] }

func (h *theap) Push(x interface{}) {
	*h = append(*h, x.(task))
}

func (h *theap) Pop() interface{} {
	old := *h
	n := len(old)
	x := old[n-1]
	*h = old[0 : n-1]

	return x
}

func main() {
	sc.Split(bufio.ScanWords)
	N, M := scanInt(), scanInt()

	jobs := make(map[int][]int)
	for i := 0; i < N; i++ {
		A, B := scanInt(), scanInt()
		jobs[A] = append(jobs[A], B)
	}

	ans := 0
	H := make(theap, N)
	heap.Init(&H)
	for day := 1; day <= M; day++ {
		for _, t := range jobs[day] {
			heap.Push(&H, task{day, t})
		}
		if H.Len() > 0 {
			selected := heap.Pop(&H).(task)
			ans += selected.price
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 17152
#include<bits/stdc++.h>
#define ll long long
#define MAXN 100005
#define mod 998244353
#define INF 0x3f3f3f3f
#define ld long double
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    #define int ll
    int a,b,c;
    cin>>a>>b>>c;
    cout<<c<<' '<<a<<' '<<b<<endl;

    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
struct Data
{
	int a;
	int id;
}A[100005];
int n,a[100005],b[100005];
bool cmp(Data a,Data b)
{
	return a.a<b.a;
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",&a[i]);
	for(int i=1;i<=n;i++)scanf("%d",&b[i]);
	for(int i=1;i<=n;i++)A[i].a=b[i],A[i].id=a[i];
	sort(A+1,A+n+1,cmp);
	for(int i=1;i<=n;i++)b[i]=A[i].a,a[i]=A[i].id;
	for(int i=1;i<=n;i++)A[i].a=a[i],A[i].id=i;
	sort(a+1,a+n+1);
	sort(b+1,b+n+1);
	sort(A+1,A+n+1,cmp);
	for(int i=1;i<=n;i++)
	{
		if(a[i]>b[i])
		{
			printf("No\n");
			return 0;
		}
	}
	for(int i=2;i<=n;i++)
	{
		if(b[i-1]>=a[i])
		{
			printf("Yes\n");
			return 0;
		}
	}
	int now=0;
	for(int i=1;i<=n;i++)
	{
		if(A[i].a!=A[i-1].a)now++;
		a[A[i].id]=now;
	}
	if(now!=n)
	{
		printf("Yes\n");
		return 0;
	}
	int cnt=1;
	int x=a[1];
	while(x!=1)cnt++,x=a[x];
	if(cnt!=n)
	{
		printf("Yes\n");
		return 0;
	}
	printf("No\n");
	return 0;
}


Measured memory_bytes: 1664
#include <stdio.h>

int main(){
  int a, b, c, d;
  scanf("%d %d %d",&a,&b,&c);
  if(a>b){
    d = a;
    a = b;
    b = d;
  }
  if(b>c){
    d = b;
    b = c;
    c = d;
    if(a>b){
      d = a;
      a = b;
      b = d;
    }
  }
  if((a==b)&&(b!=c)) printf("Yes");
  else if((a!=b)&&(b==c)) printf("Yes");
  else printf("No");
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
 
#define ff first
#define ss second
#define mp make_pair
 
using namespace std;
 
typedef long long ll;

const int MOD=1e9+7;
int cnt[100005];

int main() {
	int n,a;
 
	scanf("%d", &n);
	cnt[0] = 3;

	ll ans = 1;
	for(int i = 0; i < n; i++) {
		scanf("%d", &a);
		ans *= cnt[a];
		ans %= MOD;
		cnt[a]--;
		cnt[a+1]++;
	}
 
	printf("%lld\n", ans);

    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i ,n) for(int i = 0 ; i < (n) ; i ++ )
#define all(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;
using vin=vector<int>;
const int inf=1e9+7;
const ll INF=1e18;


int main() {
  int n,T;
  cin>>n>>T;
  vin t(n);
  rep(i,n) cin>>t[i];
  ///
  ll ans=0;
  rep(i,n-1){
    if(t[i+1]-t[i]>T){
      ans+=T;
    }
    else{
     ans+=t[i+1]-t[i]; 
    }
  }
  ans+=T;
  cout<<ans<<endl;
}

Measured memory_bytes: 1024
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		
		String[] s = stdIn.next().split("");
		boolean flag = false;
		
		for(int i = 0; i < s.length-1; i++) {
			if(!s[i].equals(s[i+1])){
				flag = true;
			}
				
			
		}
		if(flag) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
		
		
		
	}

}


Measured memory_bytes: 22228
N = int(input())
A = [-1] + [int(input()) for _ in range(N)]

count = -1
for i in range(N, 0, -1):
    if A[i] - 1 > A[i - 1]:
        print (-1)
        exit()
    elif A[i] - 1 == A[i - 1]:
        count += 1
    else:
        count += A[i]

print (count)

Measured memory_bytes: 12584
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,m;
    int k;
    int a;
    int food[31]={};
    cin>>n>>m;
    int cnt=0;
    for(int i=0;i<n;i++){
        cin>>k;
        for(int j=0;j<k;j++){
            cin>>a;
            food[a]++;
            if(food[a]==n) cnt++;
        }
    }
    
    cout<<cnt<<endl;
    return 0;
}



Measured memory_bytes: 764
using System;
using System.Collections.Generic;
using System.Linq;

namespace arc076_c
{
	class Program
	{
		static int[] x;
		static bool onedge(int a, int b)
		{
			if (a == 0 || a == x[0]) return true;
			if (b == 0 || b == x[1]) return true;
			return false;
		}
		static int howlong(int a, int b)
		{
			if (a == 0) return b;//up
			if (b == x[1]) return x[1] + a;//right
			if (a == x[0]) return x[1] + x[0] + (x[1] - b);//down
			else return x[1] + x[0] + x[1] + (x[0] - a);//left
		}
		static void Main(string[] args)
		{
			x = Console.ReadLine().Split().Select(int.Parse).ToArray();
			List<Tuple<int, int>> list = new List<Tuple<int, int>>();
			for (int i = 0; i < x[2]; i++)
			{
				int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();
				if (onedge(a[0], a[1]) && onedge(a[2], a[3]))
				{
					int n1 = howlong(a[0], a[1]); list.Add(new Tuple<int, int>(n1, i));
					int n2 = howlong(a[2], a[3]); list.Add(new Tuple<int, int>(n2, i));
				}
			}
			Tuple<int, int>[] arr = list.ToArray();
			Array.Sort(arr);
			Stack<int> stack = new Stack<int>();
			foreach (var tup in arr)
			{
				if (stack.Count == 0) stack.Push(tup.Item2);
				else if (stack.Peek() == tup.Item2) stack.Pop();
				else stack.Push(tup.Item2);
			}
			Console.WriteLine(stack.Count == 0 ? "YES" : "NO");
		}
	}
}

Measured memory_bytes: 30436
#include<stdio.h>
int main(){
  int n,i;
  char a[15],c[]={"01235789"};
  while(scanf("%d",&n),n){
    for(i=0;n;n/=8)a[i++]=c[n%8];
    while(i--)printf("%c",a[i]);
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 572
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
using ll = long long;
int main(){
    int n; cin >> n;
    vector<int> p(n);
    rep(i,n) cin>>p.at(i);
    int count = 1;
    int minnum = p.at(0);
    for(int i=1; i<n; i++){
        if(p.at(i)<=minnum){
            count++;
            minnum = p.at(i);
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 1024
from collections import deque

N,K = map(int,input().split())

a = list(map(int,input().split()))

for i in range(N):
    a[i] -= 1

ans = 0

if a[0] != 0:
    ans += 1
    a[0] = 0


dis = [float("-inf")] * N
lnum = [0] * N

for i in range(N):

    lnum[a[i]] += 1

q = deque([])

for i in range(N):

    if lnum[i] == 0:
        q.append(i)
        dis[i] = 0

while len(q) > 0:

    now = q.popleft()
    if a[now] == 0:
        continue
    elif dis[now] == K-1:
        ans += 1
        dis[now] = -1
    
    dis[a[now]] = max(dis[a[now]] , dis[now] + 1)
    lnum[a[now]] -= 1

    if lnum[a[now]] == 0:
        q.append(a[now])

#print (dis)
print (ans)


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

using namespace std;

#define pb push_back
#define fi first
#define se second
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define REP(i, n) FOR(i, 0, n)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define RREP(i, n) FOR(i, n, 0)
#define MFOR(i, m) for(auto i=(m).begin();i!=(m).end();i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((int)(x).size())

typedef long long int ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;

const double eps = 1e-10;
const int MOD = 1000000007;

template<typename T>
void printv(vector<T> const& s) {
  REP(i, s.size()) {
    cout << s[i] << " ";
  }
  cout << endl;
}

int main () {
  cin.tie(0);
  cout << setprecision(10);
  vi ans;

  while(1) {
    int w, h;
    cin >> w >> h;
    if(w == 0 && h == 0) break;
    vector<vector<char>> tiles(h);
    P st;
    REP(i, h) {
      tiles[i].resize(w);
      REP(j, w) {
        cin >> tiles[i][j];
        if(tiles[i][j] == '@') st = make_pair(i, j);
      }
    }
    queue<P> q;
    vector<vector<bool>> sel(h);
    REP(i, h) {
      sel[i].resize(w, false);
    }
    q.push(st);
    sel[st.fi][st.se] = true;
    vi dx = {-1, 1, 0, 0}, dy = {0, 0, -1, 1};
    int res = 0;
    
    while(!q.empty()) {
      P now = q.front(); q.pop();
      res++;
      REP(i, 4) {
        int nextx = now.fi + dx[i], nexty = now.se + dy[i];
          
        if(0 <= nextx && nextx <= h-1 &&
           0 <= nexty && nexty <= w-1 &&
           !sel[nextx][nexty] && tiles[nextx][nexty] == '.') {
          q.push(make_pair(nextx, nexty));
          sel[nextx][nexty] = true;
        }
      }
    }

    ans.pb(res);
  }

  REP(i, ans.size()) {
    cout << ans[i] << endl;
  }
}



Measured memory_bytes: 3160
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		Scanner sc = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();

		while (true) {
			String cards = sc.nextLine();
			if ( cards.equals("-") ) break;
			int m = sc.nextInt();

			for ( int i=0; i < m; i++) {
				int h = sc.nextInt();
				String car = cards.substring(0, h);
				String ds = cards.substring(h);
				cards = ds + car;
			}
			sc.nextLine(); // nextInt()??????????????£?????????\n????¶????????????????

			sb.append(cards + "\n");
		}

		System.out.print(sb);
	}

}

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

int main()
{
    long long n,k;
    cin>>n>>k;
    long long sum=0;
    while(k--)
    {
        long long a;
        cin>>a;
        sum+=a;
    }
    if(sum>=n)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define RFOR(i,n1,n2) for(ll i=((ll)(n1)-1);i>=(ll)(n2);i--)
#define put(a) cout<<a<<"\n"
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){if(a>b){a=b;return 1;}return 0;}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){if(a<b){a=b;return 1;}return 0;}

int main(){
    ll h,w,x,y;
    cin >> w >> h >> x >> y;
    double res = (double)(h*w)/2;
    cout << setprecision(20);
    cout << res << " ";
    if(w==x*2&&h==y*2){
        put(1);
    }else{
        put(0);
    }
    return 0;
}


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


ll func_ascending(ll S)
{
    ll l, r, mid;
    l = 1, r = 1000000000;
    while(l <= r){
        ll tmp1, tmp2;
        mid = (l + r) / 2;
        tmp1 = mid * mid;
        tmp2 = (mid - 1) * (mid - 1);
        if ((S <= tmp1) && (S > tmp2)) {return mid;}
        else if (S > tmp1){ l = mid + 1;}
        else{ r = mid;}
    }
}



int main()
{
    ll S;
    cin >> S;
    ll N, D;
    /* 辺Nの決定 */
    N = func_ascending(S);
    /* 段Dの決定 */
    D = ((S - 1) / N) + 1;
    /* 第三点の決定 */    

    ll x1 = 0;
    ll y1 = 0;
    ll x2 = N;
    ll y2 = 1;
    ll x3 = N - (((S - 1)%N) + 1);
    ll y3 = D;
    cout << x1 << " " << y1 << " " << x2 << " " << y2 << " " << x3 << " " << y3 << endl;
}

Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
	val scan = Scanner(System.`in`)
	val a = scan.nextInt()
	val b = scan.nextInt()
	val c = scan.nextInt()
	println(if (a < b && b < c) {
		"Yes"
	} else {
		"No"
	})
}


Measured memory_bytes: 27440
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
    int n,m;
    cin>>n>>m;
    vector<int> k[m];
    rep(i,m){
        int f;
        cin>>f;
        rep(j,f){
            int x;
            cin>>x;
            x--;
            k[i].push_back(x);
        }
    }
    vector<int> p(m);
    rep(i,m) cin>>p[i];
    int ans = 0;
    rep(i,1<<n){
        bool ok = true;
        rep(j,m){
            int cnt = 0;
            for(auto u : k[j]){
                if((i>>u)&1) cnt++;
            }
            cnt%=2;
            if(cnt!=p[j]) ok = 0;
        }
        if(ok) ans++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	static long[] a;
	static long[] p;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		long X = Long.parseLong(sc.next());

		a = new long [N+1];
		p = new long [N+1];

		a[0] = 1;
		p[0] = 1;

		for(int i=1;i<N;i++) {
			a[i] = a[i-1]*2+3;
			p[i] = p[i-1]*2+1;
		}

		System.out.println(f(N,X));


	}

	static long f(int N, long X) {
		if(N==0) {
			if(X <= 0) {return 0;
			}else { return 1;}
		}else {
			if(X <= 1) {return 0;
			}else if(1 < X && X < 2 + a[N-1]) {return f(N-1, X-1);
			}else if(X == 2 + a[N-1]) { return p[N-1] + 1;
			}else if(2+a[N-1] < X && X < 2*a[N-1]+3) {return p[N-1]+1+f(N-1, X-a[N-1]-2);
			}else {return 2*p[N-1]+1;
			}

		}
	}

}

Measured memory_bytes: 23892
#include <stdio.h>

int main(){
    int n=0, j=0;
    int pt1=0, pt2=0;
    char ch1[100],ch2[100];
    
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%s %s",ch1,ch2);
        for(j=0;ch1[j]!='\0' && ch2[j]!='\0';j++){
            if     (ch1[j]>ch2[j]){pt1+=3; break;}
            else if(ch1[j]<ch2[j]){pt2+=3; break;}
        }
        if(ch1[j]=='\0'&& ch2[j]=='\0'){pt1+=1,pt2+=1;}
        else if(ch1[j]=='\0'|| ch2[j]=='\0'){ch1[j]=='\0' ? pt2+=3 : pt1+=3;}
    }
    printf("%d %d\n",pt1,pt2);
    
    return 0;
}


Measured memory_bytes: 2732
import sys

sys.setrecursionlimit(10 ** 6)
INF = float("inf")
MOD = 10 ** 9 + 7


def input():
    return sys.stdin.readline().strip()


def main():
    N, K = map(int, input().split())
    A = [0] + list(map(int, input().split()))
    cur = 1
    visited = [-1] * (N + 1)
    visited[cur] = 0
    for i in range(1, K + 1):
        next = A[cur]
        if cur == next:
            print(next)
            return
        elif visited[next] != -1:
            mod = i - visited[next]
            start = visited[next]
            break
        else:
            visited[next] = visited[cur] + 1
            cur = next
    else:
        print(next)
        return

    K = (K - start) % mod
    print(visited.index(K + start))


if __name__ == "__main__":
    main()


Measured memory_bytes: 32404
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <utility>
#include <cmath>

#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
const int inf = 1e9;
const ll linf = 1LL << 50;

int main(int argc, char const* argv[])
{
  int n;
  cin >> n;
  set<ll> st;
  vector<ll> vec;
  for(int i = 0; i < n; i++){
    ll a;
    cin >> a;
    if(st.find(a) != st.end()){
      vec.pb(a);
      st.erase(a);
    }else{
      st.insert(a);
    }
  }
  sort(vec.begin(), vec.end(), greater<ll>());
  if(vec.size() < 2){
    cout << 0 << endl;
  }else{
    cout << (ll)vec[0] * vec[1] << endl;
  }
	return 0;
}


Measured memory_bytes: 4992
#include <iostream>
#include <vector>
#include <unordered_map>

#define ll long long
#define ull unsigned long long
#define eps 10e-10
#define MOD 1000000007

using namespace std;

class Conbination
{
public:
	int size;
	vector<ll> fac;
	vector<ll> revfac;
	Conbination(int n);
	~Conbination();
	void setFac();
	ll nCk(ll n, ll k);
	ll pow(ll a, ll e);
};

Conbination::Conbination(int n){
	this->size = n;
	fac.reserve(n+1);
	revfac.reserve(n+1);
	setFac();
}

Conbination::~Conbination(){}

void Conbination::setFac(){
	fac[0] = 1;
	revfac[0] = 1;
	for (int i = 1; i <= size; ++i)
	{
		fac[i] = i * fac[i-1] % MOD;
		revfac[i] = pow(fac[i], MOD - 2) % MOD;
	}
}

ll Conbination::pow(ll a, ll e){
	ll ans = 1;
	while(e > 0){
		if(e & 1){
			ans *= a;
			ans %= MOD;
		}
		a *= a;
		a %= MOD;
		e = e >> 1;
	}
	return ans % MOD;
}

ll Conbination::nCk(ll n, ll k){
	if(n < k) return 0;
	return fac[n] * revfac[k] % MOD * revfac[n - k] % MOD;
}

int main() {
	ll n;
	cin >> n;
	ll a;
	ll b;
	unordered_map<ll, ll> um;
	for (ll i = 0; i < n+1; ++i)
	{
		ll tmp;
		cin >> tmp;
		if(um.find(tmp) == um.end()) {
			um[tmp] = i;
		} else{
			a = um[tmp];
			b = n - i;
		}
	}

 	Conbination c = Conbination(n+1);
 	for (ll i = 1; i <= n+1; ++i)
 	{
 		cout << (c.nCk(n+1, i) + MOD - c.nCk(a + b, i-1) ) % MOD << endl;
 	}
}


Measured memory_bytes: 6948
N = int(input())
T, A = map(int, input().split())
H = list(map(int, input().split()))

diff_list = []
for h in H:
    diff = abs(A - (T - h * 0.006))
    diff_list.append(diff)

print(diff_list.index(min(diff_list)) + 1)

Measured memory_bytes: 9204
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
#include<cstdio>
using namespace std;

class UnionFind{
public:
    //親の番号を格納する。親だった場合は-(その集合のサイズ)
    vector<int> Parent;

    //作る時はParentの値を全て-1にする
    //こうするとずべてバラバラになる
    UnionFind(int N){
      Parent = vector<int>(N,-1);
    }

    //Aがどのグループに属しているのか調べる
    int root(int A){
      if(Parent[A]<0) return A;
      return Parent[A] = root(Parent[A]);
    }

    //自分のいるグループの頂点数を調べる
    int size(int A){
      return -Parent[root(A)];//親を取ってきたい
    }

    //AとBをくっつける
    bool connect(int A,int B){
      //AとBを直すつつなぐのではなく、root(A)にroot(B)をくっつける)
      A = root(A);
      B = root(B);
      if(A==B){
        //すでにくっついているからくっつけない
        return false;
      }
      //大きい方(A)に小さい方(B)をくっつけたい
      //大小が逆だったらひっくり返しちゃう
      if(size(A)<size(B)) swap(A,B);

      //Aのサイズを更新する
      Parent[A] += Parent[B];
      //Bの親をAに変更する
      Parent[B] = A;

      return true;
    }
  };

int main(){
int N,M;cin>>N>>M;
int i,j,k,l;
vector<int> A(M),B(M);
for(i=0;i<M;i++) {
  cin>>A[i]>>B[i];
  A[i]--; B[i]--;
}
vector<long long> ans(M);
ans[M-1] = (long long)N*(N-1)/2;

UnionFind Uni(N);

for(i=M-1;i>=1;i--){
  ans[i-1] = ans[i];
  //繋がってなかったのが繋がった時
  if(Uni.root(A[i]) != Uni.root(B[i])){
    ans[i-1] -= (long long)Uni.size(A[i]) * Uni.size(B[i]);
    Uni.connect(A[i],B[i]);
    }
  }

  for(i=0;i<M;i++) cout<< ans[i]<<endl;
}


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

const int MOD = 1000000007;
const int INF = 1e9;

int main(){
  int n,k;
  const int max_n = 2 * 1e5;
  cin >> n >> k;
  double p[max_n + 1];
  for(int i = 0; i < n; i++) cin >> p[i];

  // 各期待値を計算
  double res[max_n + 1];
  for(int i = 0; i < n; i++){
    res[i] = (1 + p[i]) / 2;
    // for(int j = 1; j <= p[i]; j++){
    //   res[i] += j;
    // }
    // res[i] /= p[i];
  }
  // 累積和計算
  double sum[max_n + 1];
  for(int i = 0; i < n; i++){
    if(i==0) sum[i] = res[i];
    else sum[i] = sum[i-1] + res[i];
  }
  // 最大値計算
  double ans = 0;
  double now = 0;
  for(int i = 0; i <= n - k; i++){
    if(i == 0) now = sum[k - 1];
    else now = sum[i + k - 1] - sum[i - 1];
    ans = max(ans, now);
  }
  cout << fixed << ans << endl;

  return 0;
}

Measured memory_bytes: 8468
#include<iostream>

using namespace std;

int main( )
{
	int n, x;
	
	
	while( true ) {
		cin>>n>>x;
		if( 0 == n && 0 == x ) { break; }
		
		int cnt = 0;
		for( int i=1; i<n-1; i++ ) {
			for( int j=i+1; j<n; j++ ) {
				for( int k=j+1; k<=n; k++ ) {
					if( x == (i+j+k) ) {
						cnt++;
					}
				}
			}
		}
		cout<<cnt<<endl;
	}

	return 0;
}

Measured memory_bytes: 1160
using System;

namespace SwappingTwoNumbers
{
	class MainClass
	{
		public static void Main (string[] args)
		{
			int i = 0;

			while(true)
			{
				//??\??????
				string[] xy = Console.ReadLine().Split(' ');
				int x = int.Parse (xy[0]);
				int y = int.Parse (xy[1]);

				i++;

				//x ??¨ y ?????¨?????? 0 ?????¨?????\???????????????
				if(x==0&&y==0)
					break;

				//x???y????????§???????????°
				if (x > y)
					Console.WriteLine(y + " " + x);
				else
					Console.WriteLine(x + " " + y);
			}



		}
	}
}

Measured memory_bytes: 5828
//#include <bits/stdc++.h>
#include<iostream>
#include<vector>
#include<map>
#include<math.h>

#define irep(i,n) for(int i = 0; i < (int)(n); i++)
#define irep2(i,a,n) for(int i = (int)(a); i <= (int)(n); i++)
#define irrep(i,n) for(int i = (int)(n-1); i > -1; i--)
#define irrep2(i,n,a) for(int i = (int)(n); i >= (int)(a); i--)

#define fi first
#define se second

using namespace std;

using ll = long long;
using v_int = vector<int>;
using v2_int = vector<v_int>;
using v_ll = vector<ll>;
using v2_ll = vector<v_ll>;
using v_string = vector<string>;
using v_bool = vector<bool>;
using v2_bool = vector<v_bool>;
using pii = pair<int, int>;
using mii = map<int, int>;

const double PI = 3.1415926535897932;
const int INF = (int)2e9;
const ll LINF = (ll)2e18;
const ll MOD = 1000000007;
const int dc[8] = {1, -1, 0,  0, 1, -1,  1, -1};
const int dr[8] = {0,  0, 1, -1, 1,  1, -1, -1};

template<typename T, typename U> inline
ostream& operator<<(ostream &o, pair<T,U> &p) {
    return o << "{" << p.first << "," << p.second << "}";
}
template<typename T> inline
istream& operator>>(istream &is, vector<T> &vec) {
    for(auto &v : vec) { is >> v; }
    return is;
}
template<typename T> inline
ostream& operator<<(ostream &os, vector<T> &vec) {
    for(auto &v : vec) { os << v << ",";}
    return os;
}
template<typename T> inline
ostream& operator<<(ostream &os, vector<vector<T> > &mat) {
    for(auto &row : mat) { os << row << endl; }
    return os;
}
template<typename T> inline
void chmin(T &a, T b) { a = min(a, b); }
template<typename T> inline
void chmax(T &a, T b) { a = max(a, b); }

int main(void)
{
    int d, s, t;
    cin >> d >> s >> t;
    if(t * s < d) {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }
    return 0;
} /*atcoder*/


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

int main() {
	int N;
	cin >> N;
	vector<long long> a(N, 0);
	vector<long long> sum(N, 0);
	long long mod = 1000000007;
	for (int i = 0; i < N; i++) {
		cin >> a[i];
		if (i == 0) {
			sum[0] = a[i];
		}
		else {
			sum[i] = (sum[i - 1] + a[i])%mod;
		}
	}
	long long res = 0;
	for (int i = N - 1; i >= 1; i--) {
		long long t = sum[i - 1] * a[i];
		res = (res + (sum[i - 1] * a[i]) % mod)%mod;
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 6332
#include <bits/stdc++.h>
#include <regex>
#define FOR(i, s, e) for (int i = int(s); i < int(e); ++i)
#define REP(i, e) FOR(i, 0, e)
#define INF (INT_MAX / 2)
#define LINF (LLONG_MAX / 2)
#define EPS (1.0e-8)
#define mkpr make_pair
#define EPR(msg) cerr << msg << endl;
#define AST(exp, msg) EPR(msg) assert(exp);
#define TAST(exp, msg) EPR(msg) while(!exp){}
const int MGN = 10;
const int ARY_SZ_MAX = (int)1e7;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>;
using vc = vector<char>; using vvc = vector<vc>;
using vb = vector<bool>; using vvb = vector<vb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>; using psl = pair<string, ll>;


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


  int L; cin>>L;

  double d = L/3.0;
  
  double  ans = d*d*d;
  printf("%.12lf\n", ans);


  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,a[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
int main(){
	scanf("%d",&n);
	printf("%d\n",a[--n]);
	return 0;
}

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

using tiii = tuple<int, int, int>; //year, city, prefecture
using pii = pair<int, int>; //prefecture, rank

int main(){
  int N, M;
  cin >> N >> M;
  
  vector<tiii> memo;
  for (int i = 1; i <= M; i++) {
    int p, y;
    cin >> p >> y;
    memo.push_back(make_tuple(y, i, p));
  }
  
  sort(memo.begin(), memo.end());
  
  pii ansMemo[M+1];
  map<int, int> prefectureRank;
  for (auto t: memo) {
    int year;
    int city;
    int prefecture;
    tie(year, city, prefecture) = t;
    
    ansMemo[city] = {prefecture, ++prefectureRank[prefecture]};
    
  }
  
  for (int i = 1; i <= M; i++) {
    string prefecture = to_string(ansMemo[i].first);
    string rank = to_string(ansMemo[i].second);
    
    cout << string(6-prefecture.size(), '0');
    cout << prefecture;
    cout << string(6-rank.size(), '0');
    cout << rank << endl;
  }
  
  return 0;
}

Measured memory_bytes: 8180
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <cassert>

#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;
typedef long long int ll;
const ll INF = 1000000000000000000;
const double PI = acos(-1);

int main()
{
    string s, t, u;
    int a, b;
    cin >> s >> t >> a >> b >> u;
    if (u == s) {
        cout << a - 1 << " " << b << endl;
    }
    else {
        cout << a << " " << b - 1 << endl;
    }
    return 0;
}

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

int main(){
    int n;
    cin >> n;
    int sum = 0;
    int longest = 0;
    int l;
    for (int i = 0; i < n; i++){
        cin >> l;
        sum += l;
        longest = max(longest,l);
    }

    if (longest < sum - longest){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
function Main(input) {
    input = input.split("\n");
    tmp = input[0].split(/\s/);
    const a = parseInt(tmp[0], 10);
    const b = parseInt(tmp[1], 10);
    if (a * b % 2 == 0) console.log("Even");
    else console.log("Odd");
}

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

Measured memory_bytes: 29420
#include<stdio.h>

void trace(int A[], int N) {
	int i;
	for(i = 0; i < N; i++) {
		if(i > 0) printf(" ");
		printf("%d", A[i]);
	}
	printf("\n");
}

void insertionSort(int A[], int N) {
	int j, i, v;
	for (i = 1; i < N; i++) {
		v = A[i];
		j = i - 1;
		while (j >= 0 && A[j] > v) {
			A[j + 1] = A[j];
			j--;
		}
		A[j + 1] = v;
		trace(A, N);
	}
}

int main() {
	int N, i, j;
	int A[100];
	
	scanf("%d", &N);
	for(i = 0; i < N; i++) scanf("%d", &A[i]);
	
	trace(A, N);
	insertionSort(A, N);
	
	return 0;
}

Measured memory_bytes: 604
#include<bits/stdc++.h>
#define F first
#define S second
#define REP(i, a, b, c) for(int i = a; i <= b; i+=c)
#define pb push_back
#define int long long int
#define MOD 1000000007
using namespace std;

/*class Graph {

  map<int, list<pair<int, int> > > l;

public:
  void addEdge(int x, int y, int cost) {
    l[x].pb(make_pair(y, cost));
    l[y].pb(make_pair(x, cost));
  }

  int dfs_helper(int n, int node, map<int, int> &vis, map<int, int> &count, int &ans) {
    //cout << node << " " ;
    vis[node] = 1;
    count[node] = 1;
    for (auto m : l[node]) {
      if (!vis[m.F]) {
        vis[m.F] = 1;
        count[node] += dfs_helper(m.F, vis, count, ans);
        ans += 2 * min(count[node], n - count[node]) * m.S.S;
      }
    }
    return count[node];
  }

  void dfs() {
    map<int, int> vis;
    map<int, int> count;
    int ans = 0;
    dfs_helper(0, vis, count, ans);
    cout << ans << endl;
  }

};*/

int dp[105][100005];

int solve(int wt[], int v[], int n, int w)
{
  if (n == 0 || w == 0)
    return 0;
  if (dp[n][w] != -1)
    return dp[n][w];
  int op1, op2;
  op1 = op2 = INT_MIN;
  if (w - wt[n] >= 0)
    op1 = v[n] + solve(wt, v, n - 1, w - wt[n]);
  op2 = solve(wt, v, n - 1, w);

  return dp[n][w] = max(op1, op2);
}


int32_t main()
{
  ios :: sync_with_stdio(false); cin.tie(0);
  int t = 1;
  //cin >> t;
  for (int i9 = 1; i9 <= t; i9++)
  {
    /* Graph G;
     int n, x, y, cost;
     cin >> n;
     while (n--) {
       cin >> x >> y >> cost;
       G.addEdge(x, y, cost);
     }
     G.dfs();*/
    //freopen("ouputnew.txt", "w", stdout);
    //flclose(stdout);
    int N, W;
    cin >> N >> W;
    int wt[N + 5];
    int v[N + 5];
    for (int i = 1; i <= N; i++)
      cin >> wt[i] >> v[i];
    memset(dp, -1, sizeof(dp));
    cout << solve(wt, v, N, W);
  }
}



Measured memory_bytes: 85672
#if defined(LOCAL)
#define PROBLEM_NAME "d"
const double _max_double_error = 1e-9;
#include "testutils.h"
#define L(x...) debug(x)
#else
#define L(x...) (x)
#include <bits/stdc++.h>
#endif

using namespace std;
using vi = vector<int>; using vvi = vector<vi>;
using ii = pair<int,int>; using vii = vector<ii>;
using l = long long; using vl = vector<l>; using vvl = vector<vl>;
using ll = pair<l,l>; using vll = vector<ll>; using vvll = vector<vll>;
using lu = unsigned long long;
using vb = vector<bool>; using vvb = vector<vb>;
using vd = vector<double>; using vvd = vector<vd>;
using mll = unordered_map<l, l>;
const l INF = numeric_limits<l>::max();
const double EPS = 1e-10; static constexpr auto PI = acos(-1);
const l e0=1, e3=1000, e5=100000, e6=10*e5, e7=10*e6, e8=10*e7, e9=10*e8;
const char lf = '\n';
#define all(x) begin(x), end(x)
#define F(a,b,c) for (l a = l(b); a < l(c); a++)
#define B(a,b,c) for (l a = l(c) - 1; a >= l(b); a--)

struct Flip {
  l time, low, low_value, delta, high, high_value, d;
};

Flip next_flip(const Flip& f, l t, l m) {
  Flip next;
  next.time = t;
  l d = f.d * (next.time - f.time);
  next.d = -f.d;
  next.low = max(f.low, - d - f.delta);
  next.low_value = min(m, max(l(0), f.low_value + d));
  next.delta = f.delta + d;
  next.high = min(f.high, m - f.delta - d);
  next.high_value = min(m, max(l(0), f.high_value + d));
  return next;
}

void solve(istream& cin, ostream& cout) {
  l m; cin >> m;
  Flip f;
  f.time = 0;
  f.low = 0; f.low_value = 0;
  f.high = m; f.high_value = m;
  f.delta = 0;
  f.d = -1;
  l n; cin >> n;
  vector<Flip> ff(n + 2);
  ff[0] = f;
  F(i, 0, n) {
    l t; cin >> t;
    f = next_flip(f, t, m);
    ff[i + 1] = f;
  }
  ff[n + 1] = next_flip(f, e9 * 2, m);
  F(i, 0, n + 1) {
    // cerr << ff[i].time << " (" << ff[i].low << ' ' << ff[i].low_value << ") ("
         // << ff[i].high << ' ' <<  ff[i].high_value <<  ") " <<  ff[i].delta << endl;
  }
  l k; cin >> k;
  while (k--) {
    l t, a; cin >> t >> a;
    auto p = upper_bound(all(ff), t, [](l y, const Flip& x) {
        return y < x.time;
      });
    p--;
    if (a <= p->low) {
      a = p->low_value;
    } else if (a >= p->high) {
      a = p->high_value;
    } else {
      a += p->delta;
    }
    a += p->d * (t - p->time);
    a = min(m, max(l(0), a));
    cout << a << lf;
  }
}

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);
  cout << fixed << setprecision(15);
#if defined(LOCAL)
  // _generate_random_test = generate_random;
  // _solve_brute = solve_brute;
  // _player_b = player_b;
  // _custom_solution_checker = solution_checker;
  maybe_run_tests(cin, cout);
#else
  solve(cin, cout);
#endif
}


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


int main()
{
    int a,b;
    cin>>a>>b;
    string s;
    cin>>s;
    if( s.length() != a+b+1)
    {
        cout<<"No";
    } else
    {
        if( s[a] != '-' )
        {
            cout<<"No";
            return 0;
        }
        else
        {
            for(int i=0;i<s.length();i++)
            {
                if( i!= a && (s[i] >'9' || s[i] <'0') ) {
                    cout << "No";
                    return 0;
                }
            }
            cout<<"Yes";
        }
    }
}

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

int n,m;
vector<pair<int,int> > is;


int main()
{
	cin>>n>>m;
	for(int i=0;i<m;i++)
	{
	 int x,y;
	 cin>>x>>y;
	 is.push_back(make_pair(x,y));
	 }
	sort(is.begin(),is.end());
	int mine=1e8,st;
	st=is[0].first;
	int ans=1;
	for(int i=0;i<is.size();i++)
	{
	 if(is[i].first>=mine)
	 {
	  ans++;
	  st=is[i].first;
	  mine=1e8;
	  }
	 if(is[i].second<mine) mine=is[i].second;
	 }
	cout<<ans<<endl; 
 return 0;
 }

Measured memory_bytes: 1400
#include <bits/stdc++.h>
#define INF 2000000000000000000
#define ll long long
#define pll pair<ll, ll>
using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  string S;
  cin >> S;
  if (S.at(S.size() - 1) == 's') {
    S += 'e';
    S += 's';
  }
  else {
    S += 's';
  }
  cout << S << "\n";
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define COUT(x) cout<<(x)<<endl
#define dump(x)  cout << #x << " = " << (x) << endl;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
using M = map<int,int>;
using PQ = priority_queue<int>;
using PQG = priority_queue<int, vector<int>, greater<int>>;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int main() {
  int n; cin >> n;
  int t[n+1],x[n+1],y[n+1];
  REP(i,n) cin >> t[i+1] >> x[i+1] >> y[i+1];

  t[0]=0; x[0]=0; y[0]=0;
  int ok = 1;
  for (int i = 1; i <= n; i++) {
    int d = abs(x[i] - x[i-1]) + abs(y[i] - y[i-1]);
    int td = t[i] - t[i-1];
    if (td < d) ok = 0;
    else if(td > d && (td-d)%2) ok = 0;
  }
  COUT(ok ? "Yes" : "No");
  return 0;
}


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

int int_len(int n) {
  int s=0;
  while(n!=0) s++, n/=10;
  return s;
}

int int_sum(int n) {
  int m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(int i=s-1;i>=0;i--) m+=n/((int)pow(10,i))-(n/((int)pow(10,i+1)))*10;
  return m;
}






int ggcd(int a,int b)
{
 
  int r, tmp;
 
  
 
  /* 自然数 a > b を確認・入替 */
  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }
 
  /* ユークリッドの互除法 */
  r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
 
 
 
  return b;
}







int fac(int n){
  int m=1;
  while(n>=1) m*=n,n--;
  return m;
}

int vec_sum(vector<int> v){
  int n=0;
  for(int i=0;i<v.size();i++) n+=v[i];
  return n;
}
///////////////////////////
int main() {
  string s,a="CODEFESTIVAL2016";
  int count=0;
  cin>>s;
  rep(i,s.size()) if(s[i]!=a[i]) count++;
  cout<<count<<endl;
}
///////////////////////////

Measured memory_bytes: 256
import java.io.PrintWriter
import java.lang.Math.*
import java.util.*

val pw = PrintWriter(System.out)
val sc = Scanner(System.`in`)


fun main(args: Array<String>) {
    val n = nextInt()
    val arr = nextListOfLong()
    var sum = 1L
    for(i in 0 until n){
        if(sum > 1000000000000000000L/arr[i]){
            sum = -1L
            break
        }
        sum *= arr[i]
    }
    if(arr.contains(0L)) sum = 0L
    println(sum)
}

fun abc000a() {
}


fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextListOfString() = next().split(" ")
fun nextListOfInt() = nextListOfString().map { it.toInt() }
fun nextListOfLong() = nextListOfString().map { it.toLong() }
fun nextListOfDouble() = nextListOfString().map { it.toDouble() }

Measured memory_bytes: 64936
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int n = Integer.parseInt(br.readLine());
		String[] aline = br.readLine().split(" ");

		int count = 0;

		for (int i = 0; i < n; i++) {
			int a = Integer.parseInt(aline[i]);
			while (a % 2 == 0) {
				count++;
				a /= 2;
			}
		}

		System.out.println(count);

	}

}


Measured memory_bytes: 25684
N = int(input())
A = list(map(int,input().split()))
num = 10000000000000000000000000
ans = 0
cnt = 0
for i in range(N):
    a = abs(A[i])
    num = min(num,a)
    ans += a
    if A[i] != a:
        cnt += 1
if cnt%2  == 1:
    ans -= num*2
print(ans)

Measured memory_bytes: 64880
# coding: UTF-8
import sys
#sys.setrecursionlimit(n)
import heapq
import re
import bisect
import random
import math
import itertools
from collections import defaultdict, deque
from copy import deepcopy
from decimal import *

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

s = sum(e) / n;
v = 0xFFFFFFFF
ans = -1
for i in range(n):
    if (abs(s - e[i]) < v):
        v = abs(s - e[i])
        ans = i
print(ans)

        




Measured memory_bytes: 7752
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
  ll N,count=0,check=0;

cin>>N;

vector<ll> b(N);
vector<ll> tmp;
for(ll i=0;i<N;i++){
cin>>b[i];
}

if(b[0]!=1){
  printf("%d\n",-1);
  return 0;
}

while(1){
for(ll i=b.size()-1;i>-1;i--){
  if(b[i]==i+1){
    tmp.push_back(b[i]);
    b.erase(b.begin()+i);
    break;
  }
  else if(b[0]!= 1){
    printf("%d\n",-1);
    return 0;
  }
}
if(b.size()==1){

  if(b[0]==1){
    break;
  }
  else{
    printf("%d\n",-1);
    return 0;
  }
}
}

tmp.push_back(1);
for(ll i=N-1;i>=0;i--){
  printf("%ld\n",tmp[i]);
}


  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()

int main(void){
    ll n, d, x;
    cin >> n >> d >> x;

    ll a[n];
    rep(i, 0, n){
        cin >> a[i];
    }
    ll sum = 0;
    rep(i, 1, d + 1){
        rep(j, 0, n){
            if((i - 1) % a[j] == 0){
                sum++;
            }
        }
    }

    cout << sum + x << endl;
    return 0;
}


Measured memory_bytes: 256
require 'pp'
# IS_DEBUG = true
IS_DEBUG = false
def dputs str
	if(IS_DEBUG)
		puts str
	end
end
def dpp str
	if(IS_DEBUG)
		pp str
	end
end
def comb(n,a)
	return $fact[n] / $fact[a] / $fact[n-a];
end
def pow(a,n)
	prd = 1;
	exp = a;
	while(n > 0)
		if((n&1)==1)
			prd *= exp;
		end
		exp *= exp;
		n >>= 1;
	end
	return prd;
end
NMAX=1000
$fact = Array.new(NMAX);
$fact[0] = 1;
for i in 1..(NMAX)
	$fact[i] = $fact[i-1] * i
end
N,P=gets.chomp.split(' ').map{|n| n.to_i}
A=gets.chomp.split(' ').map{|n| n.to_i}
odds = A.count{|i| i%2!=0}
evns = A.count{|i| i%2==0}
if(P==1 && odds == 0)
	puts 0
else
	puts pow(2,evns)*pow(2,odds-1)
end


Measured memory_bytes: 2684
#include <stdio.h>

int A[1000000], n;

/* ????????¢?´¢ */
int binarySearch(int key) {
	int left = 0;
	int right = n;
	int mid;
	while(left < right) {
		mid = (left + right) / 2;
		if(key == A[mid]) return 1; /* key ????????? */
		if(key > A[mid]) left = mid + 1; /* ???????????¢?´¢ */
		else if(key < A[mid]) right = mid; /* ???????????¢?´¢ */
	}
	return 0;
}

int main(void) {
	int i, q, k, sum = 0;
	scanf("%d",&n);
	for(i=0; i<n; i++) {
		scanf("%d",&A[i]);
	}
	
	scanf("%d",&q);
	for(i=0;i<q;i++) {
		scanf("%d",&k);
		if(binarySearch(k)) sum++;
	}
	printf("%d\n",sum);
	
	return 0;
}

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

int main() {
	string sa;
	int ca = 0;
	while (cin >> sa) {
		if (ca != 0)cout << endl;
		char so[5][8];
		int a = sa.size();

		for (int i = 0;i < 5;i++) {
			for (int j = 0;j < 8;j++) {
				if (j == 1 || j == 3)so[i][j] = ' ';
				else if (j == 2) { so[i][j] = '='; }
				else so[i][j] = '*';
			}
		}
	 reverse(sa.begin(), sa.end());
	 string s = sa;

		for (int i =4;i>=5-a;i--) {
			if(s[4-i]>='5'){
				so[i][0] = ' ';
				so[i][1] = '*';
			}
			else {
				so[i][0] = '*';
				so[i][1] = ' ';
			}

			if ((s[4-i] - '0') % 5 == 0) {
				so[i][3] = ' ';
				for (int ia = 4;ia <= 7;ia++)so[i][ia] = '*';
			}
			else if ((s[4-i] - '0') % 5 == 1) {
				for (int j = 3;j <= 7;j++) {
					if (j == 4)so[i][j] = ' ';
					else { so[i][j] = '*'; }
				}
			}
			else if ((s[4-i] - '0') % 5 == 2) {

				for (int j = 3;j <= 7;j++) {
					if (j == 5)so[i][j] = ' ';
					else so[i][j] = '*';
				}
			}
			else if ((s[4-i] - '0') % 5 == 3) {
				for (int j = 3;j <= 7;j++) {
					if (j == 6)so[i][j] = ' ';
					else so[i][j] = '*';
				}
			}
			else {
				for (int j = 3;j <= 7;j++) {
					if (j == 7)so[i][j] = ' ';
					else so[i][j] = '*';
				}
			}
		}
		for (int i = 0;i < 8;i++) {
			for (int j = 0;j < 5;j++) {
				cout << so[j][i];
				if (j == 4)cout << endl;
			}
		}
		ca++;
	}
	return 0;
}

Measured memory_bytes: 3236
#include <cstdio>
#include <algorithm>
#include <utility>
typedef long long int64;
static const int MAXN = 2e5 + 4;
static const int INF = 0x3fffffff;
static const int MODULUS = 1e9 + 7;
#define _  %  MODULUS
#define __ %= MODULUS

int n, x, y;
int c[MAXN], w[MAXN];

int col_ct[MAXN] = { 0 }, tot = 0;
bool col_conn[MAXN] = { false };
int col_min[MAXN];
std::pair<int, int> g_min1(INF, -1), g_min2(INF, -1);

int64 fact[MAXN], fact_inv[MAXN];
inline int64 fpow(int64 base, int exp)
{
    int64 ans = 1;
    for (; exp; exp >>= 1) {
        if (exp & 1) (ans *= base)__; (base *= base)__;
    }
    return ans;
}
inline void preprocess_binomials()
{
    fact[0] = fact_inv[0] = 1;
    for (int i = 1; i < MAXN; ++i) {
        fact[i] = fact[i - 1] * i _;
        fact_inv[i] = fpow(fact[i], MODULUS - 2);
    }
}
inline int64 binomial(int n, int m)
{
    if (n < m || m < 0) return 0;
    return fact[n] * fact_inv[n - m]_ * fact_inv[m]_;
}

int main()
{
    scanf("%d%d%d", &n, &x, &y);
    for (int i = 0; i < n; ++i) scanf("%d%d", &c[i], &w[i]), --c[i];

    for (int i = 0; i < n; ++i) col_min[i] = INF;
    for (int i = 0; i < n; ++i) col_min[c[i]] = std::min(col_min[c[i]], w[i]);
    for (int i = 0; i < n; ++i) {
        if (col_min[i] < g_min1.first) {
            g_min2 = g_min1;
            g_min1 = std::make_pair(col_min[i], i);
        } else if (col_min[i] < g_min2.first) {
            g_min2 = std::make_pair(col_min[i], i);
        }
    }
    for (int i = 0; i < n; ++i) {
        bool conn = false;
        if (w[i] + col_min[c[i]] <= x) conn = true;
        else {
            int g_min = (c[i] == g_min1.second ? g_min2.first : g_min1.first);
            if (g_min + col_min[c[i]] <= y && w[i] + g_min <= y) conn = true;
        }
        if (conn) ++col_ct[c[i]];
    }
    int g_winner = g_min1.second;
    col_conn[g_winner] = true; tot += col_ct[g_winner];
    for (int i = 0; i < n; ++i) if (i != g_winner) {
        if (g_min1.first + col_min[i] <= y) {
            col_conn[i] = true; tot += col_ct[i];
        }
    }

    preprocess_binomials();
    int64 ans = 1;
    for (int i = 0; i < n; ++i) if (col_conn[i]) {
        (ans *= binomial(tot, col_ct[i]))__;
        tot -= col_ct[i];
        //printf("%d%c", col_ct[i], i == n - 1 ? '\n' : ' ');
    }
    printf("%lld\n", ans);

    return 0;
}


Measured memory_bytes: 6656