akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
typedef long long int ll;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<signed(n);i++)
#define EREP(i,n) for(int i=1;i<=signed(n);i++)
#define ALL(a) (a).begin(),(a).end()
using std::cout;
using std::vector;
using std::endl;
using std::cin;
using std::string;
//#define EVEL 1
#ifdef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
constexpr int MOD = 1000000007;
constexpr ll INF = 50000000000000000;
typedef std::pair<int,int> P;
constexpr ll SIZE= 100010;

    ll K,A,B,C;
    ll ans=0;
int main() {
    std::ios_base::sync_with_stdio(false);
    cin>>A>>B>>C>>K;
    if(A==B)cout<<0;
    else{
        if(K%2==0)cout<<A-B;
        else cout<<B-A;
    }

    return 0;
}


Measured memory_bytes: 256
#include<cstdio>

int n;
int num_of_d[101];

int main(void){
    int d;
    int result = 0;

    scanf("%d\n", &n);
    for(int i = 0; i < n; i++){
        scanf("%d", &d);
        num_of_d[d]++;
    }

    for(int i = 1; i <= 100; i++){
        if(num_of_d[i]){
            result++;
        }
    }

    printf("%d\n", result);
}

Measured memory_bytes: 128
package main

import (
	"fmt"
	"math"
)

var ans int
var S string

func main() {
	fmt.Scan(&S)
	m := make(map[string]int, 0)

	for i := 0; i < len(S); i++ {
		m[string(S[i])]++
	}
	if len(m) == len(S) {
		fmt.Println("yes")
	} else {
		fmt.Println("no")
	}
}

/*  ----------------------------------------  */

func gcd(x, y uint64) uint64 {
	if x%y == 0 {
		return y
	} else {
		r := x % y
		return gcd(y, r)
	}
}

func combination(x, y int) int {
	return permutation(x, y) / permutation(y, y)
}

func permutation(x, y int) int {
	var ans int = 1
	for i := x - y; 0 < i; i-- {
		ans *= i
	}
	return ans
}

func max(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Max(float64(x[i]), float64(res)))
	}
	return res
}

func min(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Min(float64(x[i]), float64(res)))
	}
	return res
}

func pow(x, y int) uint64 { return uint64(math.Pow(float64(x), float64(y))) }
func abs(x int) int       { return int(math.Abs(float64(x))) }
func floor(x int) int     { return int(math.Floor(float64(x))) }

type XY struct {
	x int
	y int
}

type SortBy [][]int

func (a SortBy) Len() int      { return len(a) }
func (a SortBy) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
func (a SortBy) Less(i, j int) bool {
	if a[i][0] == a[j][0] {
		return a[i][1] > a[j][1]
	}
	return a[i][0] > a[j][0]
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <stack>

using namespace std;

struct uft {
    uft (int s) : ps {new int[s]}, ds {new int[s]}, s {s} {
        for(int i = 0; i < s; ++i){
            ps[i] = i;
            ds[i] = 0;
        }
    };
    void unite(int x, int y){
        int px = parent(x);
        int py = parent(y);
        if(ds[px] < ds[py]){
            ps[px] = py;
        } else if(ds[px] > ds[py]){
            ps[py] = px;
        } else {
            ps[px] = py;
            ++ds[py];
        }
    };
    int parent(int p){
        return p == ps[p] ? p : ps[p] = parent(ps[p]);
    };
    bool same(int x, int y){
        return parent(x) == parent(y);
    };
    int* ps;
    int* ds;
    int s;
};

struct user {
    user() {};
    user(int i) : id {i}, fs {}, group {-1} {};
    int id;
    vector<int> fs;
    int group;
};

void add_friends(user *us, int x, int y){
    us[x].fs.push_back(y);
    us[y].fs.push_back(x);
}

void dfs(user* us, int id, int g){
    stack<int> ss {};
    ss.push(id);
    while(ss.size()){
        int p = ss.top();
        ss.pop();
        us[p].group = g;
        vector<int> fs = us[p].fs;
        for(auto x : fs){
            if(us[x].group == g){
                continue;
            }
            ss.push(x);
        }
    }
}

void make_group(user* us, int n){
    int g = 0;
    for(int i = 0; i < n; ++i){
        if(us[i].group < 0){
            dfs(us, i, g);
            ++g;
        }
    }
}

int main(){
    int n, m;
    cin >> n >> m;
    //user us[n];
    auto us = uft(n);
    /*for(int i = 0; i < n; ++i){
        us[i] = user(i);
    }*/
    for(int i = 0; i < m; ++i){
        int a, b;
        cin >> a >> b;
        us.unite(a, b);
    //    add_friends(us, a, b);
    }
    //make_group(us, n);
    int q;
    cin >> q;
    for(int i = 0; i < q; ++ i){
        int a, b;
        cin >> a >> b;
        //if(us[a].group == us[b].group){
        if(us.same(a, b)){
            cout << "yes" << endl;
        } else {
            cout << "no" << endl;
        }
    }
}

Measured memory_bytes: 1956
#include <bits/stdc++.h>
#define REP(i, e) for(int (i) = 0; (i) < (e); ++(i))
#define FOR(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define ALL(c) (c).begin(), (c).end()
#define PRINT(x) cout << (x) << "\n"
using namespace std;
using ll = long long; using pint = pair<int, int>; using pll = pair<ll, ll>;
const long long MOD = 1000000007;

signed main(){
    ll D, T, S;
    cin >> D >> T >> S;
    if(S * T >= D) PRINT("Yes");
    else PRINT("No");
    return 0;
}

Measured memory_bytes: 3632
while True:
    H, W = map(int, input().split())
    if H + W == 0:
        break
    for i in range(H):
        for j in range(W):
            if (i + j) % 2 == 0:
                print('#', end='')
            else:
                print('.', end='')
        print('')
    print('')



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

using namespace std;

using ll=long long;

int main(){
    const ll INF=-1e9;
    ll n;
    cin >> n;
    vector<vector<ll>> a(n,vector<ll>(3));
    for(ll i=0;i<n;i++){
        for(ll j=0;j<3;j++){
            cin >> a[i][j];
        }
    }
    vector<vector<ll>> dp(n+1,vector<ll>(4,INF));
    dp[0][0]=0;
    for(ll i=1;i<n+1;i++){
        for(ll j=0;j<4;j++){
            for(ll k=1;k<4;k++){
                if(j!=k){
                    dp[i][k]=max(dp[i][k],dp[i-1][j]+a[i-1][k-1]);
                }
            }
        }
    }
    ll ans=-1;
    for(ll i=0;i<3;i++){
        ans=max(ans,dp[n][i+1]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 12800
#include<iostream>
using namespace std;
typedef pair<char,int> P;
string str;
int len,size=0,cnt=1,ans=0;
P t[1000000];
int main(){
  cin>>str;
  str.push_back('-');
  len=str.size();
  for(int i=1;i<len;i++){
    if(str[i-1]==str[i]){
      cnt++;
    }else{
      t[size++]=P(str[i-1],cnt);
      cnt=1;
    }
  }

  for(int i=0;i+2<size;i++){
    if(t[i].first!='J')continue;
    if(t[i+1].first!='O')continue;
    if(t[i+2].first!='I')continue;
    if(t[i].second<t[i+1].second)continue;
    if(t[i+1].second>t[i+2].second)continue;
    ans=max(ans,t[i+1].second);
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 9860
#include<bits/stdc++.h>
#define ll long long int 
#define mod 1000000007
#define se second
#define fi first
#define endl "\n"
#define pi 3.1415926535897932384626433832795028841971
#define MAX 9223372036854775807
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
//	cout<<fixed<<setprecision(10);
	ll n;
	cin>>n;
	ll arr[n];
	map<ll,ll> mp;
	for(int a=0;a<n;a++)
	{
		cin>>arr[a];
		mp[arr[a]]++;
	}
	sort(arr,arr+n);
	if(arr[0]==1)
	{
		if(mp[arr[0]]==1)
		cout<<1;
		else
		cout<<0;
		return 0;
	}
	ll ans=0;
	bool brr[arr[n-1]+1]={0};
	for(int a=0;a<n;a++)
	{
		if(brr[arr[a]]==0)
		{
			if(mp[arr[a]]==1)
			ans++;
			for(int b=arr[a];b<=arr[n-1];b+=arr[a])
			brr[b]=1;
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 18612
H, W = list(map(int, input().strip().split()))
S = [['.' for _ in range(W+2)]] + [list('.' + input() + '.') for _ in range(H)] + [['.' for _ in range(W+2)]]

for y in range(1, H+1):
    for x in range(1, W+1):
        if S[y][x] == '.':
            S[y][x] = str(len([1 for i in range(y-1, y+2) for j in range(x-1, x+2) if S[i][j] == '#']))

S = [s[1:-1] for s in S[1:-1]]

[print(''.join(s)) for s in S]

Measured memory_bytes: 3188
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main
{
	public static void main(String[] args) {
		new Thread(null, new Runnable() {
			public void run() {
                solve();
            }
        }, "1", 1 << 26).start();
	}
	static void solve () {
		FastReader fr =new FastReader();	PrintWriter op =new PrintWriter(System.out);
 
 		int n =fr.nextInt() ,k =fr.nextInt() ,a[] =new int[n] ,i ,dm ,l ,r ,mid ,ans =0 ;
 		long j ;

 		r =0 ;	l =1 ;

 		for (i =0 ; i<n ;++i) {
 			a[i] =fr.nextInt() ;	r =Math.max(r , a[i]) ;
 		}

 		while (l <= r) {
 			mid =(l+r)/2 ;	j =0 ;

 			for (i =0 ; i<n ; ++i) {
 				dm =a[i]/mid + (a[i]%mid == 0 ? 0 : 1) ;

 				j += (dm - 1) ;
 			}
 			//System.out.println(j) ;
 			if (j > k)
 				l =mid + 1 ;
 			else {
 				ans =mid ;

 				r =mid-1 ;
 			}
 		}

 		op.println(ans) ;

		op.flush();	op.close(); 
	}
	static class FastReader {
		BufferedReader br;
		StringTokenizer st;

		public FastReader() {
			br =new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st==null || (!st.hasMoreElements())) 
			{
				try
				{
					st =new StringTokenizer(br.readLine());
				}
				catch(IOException e)
				{
					e.printStackTrace();
				}
				
			}
			return st.nextToken();
		}

		String nextLine() {
			String str ="";

			try
			{
				str =br.readLine();
			}
			catch(IOException e)
			{
				e.printStackTrace();
			}

			return str;
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next()) ;
		}
	}
}

Measured memory_bytes: 55872
import sys
input=sys.stdin.readline
sys.setrecursionlimit(10**9)
from collections import deque

class Node:
    def __init__(self,depth):
        self.depth=depth
        self.left=None
        self.right=None

def insert(node,s):
    n=node
    for i in range(len(s)):
        t=s[i]
        if t=='0':
            if n.left is None:
                n.left=Node(i+1)
            n=n.left
        else:
            if n.right is None:
                n.right=Node(i+1)
            n=n.right

class Trie:
    def __init__(self):
        self.root=Node(0)
    def insert(self,s:str):
        insert(self.root,s)

n,l=map(int,input().split())
S=[input().strip() for _ in range(n)]
trie=Trie()
for s in S:
    trie.insert(s)
Data=[]
q=deque([trie.root])

def dfs(node):
    if node.right is None and node.left is None:
        return
    if node.right is None or node.left is None:
        Data.append(l-node.depth)
    if node.right:
        q.append(node.right)
    if node.left:
        q.append(node.left)

while q:
    dfs(q.popleft())
xor=0

def Grundy(n):
    ret=1
    while n%2==0:
        n//=2
        ret*=2
    return ret

for i in Data:
    xor^=Grundy(i)
print('Alice' if xor else 'Bob')

Measured memory_bytes: 56680
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class MainClass
{
	public const long Giri = 1000000007;

	
	public static void Main(string[] args)
	{
		string[] l1  = Input();
		int a = int.Parse(l1[0]);
		int b = int.Parse(l1[1]);
		
		Console.WriteLine(Math.Max(a-b,Math.Max(a+b,a*b)));
	}

	public static long GCD(long a, long b)
	{
		if(b == 1)
			return a;
		long p = b / a;
		return GCD(a, b - a*p);
	}
	
	public static string[] Input()
	{
		return Console.ReadLine().Split(' ');
	}

	
	public static int Clamp(int val, int max, int min = 0)
	{
		return Math.Min(max, Math.Max(min, val));
	}

}



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

using namespace std;

int main() {
	int a, b;
	cin >> a >> b;
	int t = 0;
	for (int i = b - a + 1; i<= b + a - 1; i++) {
		if ( t != 0) cout <<  " " << i;
		else {cout << i;t++;
		}	
		
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
# coding: utf-8

import sys

def digit_check(n):
    i = 10
    digit = 1
    
    while int(n/i) != 0:
        i *= 10
        digit += 1

    return digit
        
def main():
    for line in sys.stdin:
        ls = list(map(int, line.split(' ')))
        print(digit_check(ls[0]+ls[1]))

if __name__ == '__main__':
    main()

Measured memory_bytes: 7692
use std::cmp::{max, min};
use std::io::prelude::*;
use std::io::stdin;
use std::str::FromStr;

fn main() {
    let n: usize = read();
    let s: Vec<usize> = read::<String>().chars().map(|c| c as usize - 97).collect();
    let mut ans = 0;
    for i in 1..n - 1 {
        let (s1, s2) = s.split_at(i);
        let mut s1_count = [0; 26];
        let mut s2_count = [0; 26];

        for c in s1 {
            s1_count[*c] += 1;
        }
        for c in s2 {
            s2_count[*c] += 1;
        }

        ans = max(
            ans,
            s1_count
                .iter()
                .zip(s2_count.iter())
                .map(|(&x, &y)| min(x, y))
                .filter(|&x| x > 0)
                .count(),
        );
    }
    println!("{}", ans);
}

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|b| b.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


Measured memory_bytes: 4352
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		if(A > B){
			Console.WriteLine(0);
			return;
		}
		if(N == 1){
			Console.WriteLine(A == B ? 1 : 0);
			return;
		}
		if(N <= 2){
			Console.WriteLine(1);
			return;
		}
		
		long min = (N-1)*A + B;
		long max = (N-1)*B + A;
		Console.WriteLine(max - min + 1);
		
	}
	long N,A,B;
	public Sol(){
		var d = rla();
		N = d[0]; A = d[1]; B = d[2];
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 11092
#include<stdio.h>
int main(void){

    int n, x;

    while (1)
    {
        scanf("%d %d",&n,&x);
        if ( n==0 && x==0 ){break;}
        // forの三重ループでもいいけどO(n^3)になる？
        int count = 0;
        for (int i = 1; i < n; i++)
        {
            for (int j = i+1; j < n; j++)
            {
                for (int k = j+1; k <= n; k++)
                    {
                        if (i+k+j == x){count++;} 
                    }
            }
        }
        printf("%d\n",count);

        
    }
    return 0;

}


Measured memory_bytes: 2048
#include <bits/stdc++.h>
#define N 300005
using namespace std;
int n,ans=3e5,s1[N],s2[N];
string s;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>n>>s;
    for(int i=1;i<=n;i++){
        s1[i]=s1[i-1]+(s[i-1]=='W');
        s2[i]=s2[i-1]+(s[i-1]=='E');
    }
    for(int i=1;i<=n;i++){
        ans=min(ans,s1[i-1]+s2[n]-s2[i]);
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 2964
S = input()
N = len(S)
i, j = 0, 1
K = 0
sq = ''
while i+j <= N:
  if S[i:i+j] != sq:
    sq = S[i:i+j]
    K += 1
    i += j
    j = 1
  else:
    j += 1
print(K)

Measured memory_bytes: 3500
def q3():
    """ C - Anti-Division """
    from fractions import gcd  # 3.4.3ではmath.gcdは無い
    A,B,C,D = (int(i) for i in input().split())

    def lcm(x, y):
        """ 最小公倍数を求める """
        return (x * y) // gcd(x, y)

    num_C = B // C - (A - 1) // C  # Cで割り切れる個数
    num_D = B // D - (A - 1) // D  # Dで割り切れる個数
    lcm_CD = lcm(C, D)
    num_CD = B // lcm_CD - (A - 1) // lcm_CD  # CとDの最小公倍数で割り切れる個数
    num_all = num_C + num_D - num_CD  # 全ての割り切れる個数
    ans = B - A + 1 - num_all
    print(ans)


if __name__ == '__main__':
    q3()

Measured memory_bytes: 5332
#include <iostream>
#include <vector>
using namespace std;
int main(void){
    int i;
    int n;
    int j = 0;
    int a[202];
    int b[202];
    vector<int> t1(1000010, 0),t2(1000010, 0);
    for(i = 0; i < 200; i++){
        a[i] = (i+1)*(i+2)*(i+3)/6;
        if(a[i] % 2 == 1){
            b[j] = a[i];
            j++;
        }
    }
    /*cout << a[82] << b[20] << endl;
    for(i = 0; i < 200; i++){
        cout << "a[" << i << "] = " << a[i] << endl;
    }
    for(i = 0; i < 200; i++){
        cout << "b[" << i << "] = " << b[i] << endl;
    }*/

        for(i = 0; i <= 1000005; i++){
            t1[i] = i;
        }

        for(i = 0; i <= 179; i++){
            for(j = a[i]; j <= 1000005; j++){
                if(t1[j] > t1[j - a[i]] + 1){
                    t1[j] = t1[j -a[i]] + 1;
                }
            }    
        }        

        for(i = 0; i <= 1000005; i++){
            t2[i] = i;
        }
        
        for(i = 0; i <= 44; i++){
            for(j = b[i]; j <= 1000005; j++){
                if(t2[j] > t2[j - b[i]] + 1){
                    t2[j] = t2[j - b[i]] + 1;
                }
            }
        }
            


    while(1){
        cin >> n;
        if(n == 0){
            break;
        }
        cout << t1[n] << " " << t2[n] << endl;
    }
    return 0;
}

Measured memory_bytes: 10472
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		int n = Integer.parseInt(sc.nextLine());
		
		for(int i = 0; i < n; i++){
			String[] strs = sc.nextLine().split(":");
			int hour = Integer.parseInt(strs[0]);
			int min = Integer.parseInt(strs[1]);
			
			double m_rad = min * 6.0;
			double h_rad = hour * 30.0 + min / 2.0;
			
			double diff = Math.min(Math.abs(h_rad - m_rad) , Math.abs(m_rad - h_rad));
			if(diff >= 180){
				diff = 360 - diff;
			}
			
			if(0 <= diff && diff < 30){
				System.out.println("alert");
			}else if(90 <= diff && diff <= 180){
				System.out.println("safe");
			}else{
				System.out.println("warning");
			}
			
		}
	}
	
}

Measured memory_bytes: 0
N, M = map(int, input().split())

gate = []

l, r = map(int, input().split())


for i in range(M-1):
    tmpl, tmpr = map(int, input().split())
    if l < tmpl:
        l = tmpl
    if tmpr < r:
        r = tmpr


if r - l < 0:
    print(0)
else:
    print(r - l + 1)


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

	public static void main(String[] args) {		

		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt(), C = sc.nextInt();
		int D[][] = new int[C][C];
		int c[][] = new int[N][N];
		
		for(int i=0;i<C;i++) {
			for(int j=0;j<C;j++) {
				D[i][j] = sc.nextInt();
			}
		}
		
		//ワーシャルフロイド
//		for(int k=0;k<C;k++) {
//			for(int i=0;i<C;i++) {
//				for(int j=0;j<C;j++) {
//					D[i][j]=Math.min(D[i][j], D[i][k]+D[k][j]);
//				}
//			}
//		}
		
		for(int i=0;i<N;i++) {
			for(int j=0;j<N;j++) {
				c[i][j] = sc.nextInt()-1;//0index
			}
		}
		sc.close(); 
		
		int costSum0[] = new int[C]; //%3==0
		int costSum1[] = new int[C];
		int costSum2[] = new int[C];
		
		for(int color=0;color<C;color++) {
			for(int i=0;i<N;i++) {
				for(int j=0;j<N;j++) {
					int nowColor = c[i][j];
					if((i+j)%3==0) costSum0[color] += D[nowColor][color];
					if((i+j)%3==1) costSum1[color] += D[nowColor][color];
					if((i+j)%3==2) costSum2[color] += D[nowColor][color];
				}
			}
		}
		
		int ans = Integer.MAX_VALUE/2;
		//余り１のところ全通り
		for(int i=0;i<C;i++) {
			for(int j=0;j<C;j++) {
				for(int k=0;k<C;k++) {
					if(i==j||j==k||k==i)continue;
					int sum = costSum0[i]+costSum1[j]+costSum2[k];
					ans = Math.min(ans,sum);
				}
			}
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 85932
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            var count = int.Parse(Console.ReadLine());
            var str = Console.ReadLine();
            var arr = str.Split(' ');
            count = arr.Count();
            long[] calcTargetArr = new long[count];
            for (int i = 0; i < count; i++)
            {
                calcTargetArr[i] = int.Parse(arr[i]);
            }

            bool flag = true;
            int number = 0;
            while (flag)
            {
                for (int i =0; i < count; i++)
                {
                    var result = calcTargetArr[i] % 2;

                    if (result != 0)
                    {
                        flag = false;
                        break;
                    }
                    else
                    {
                        calcTargetArr[i] = calcTargetArr[i] / 2;
                    }
                }
                if (flag)
                {
                    number++;
                }             
            }
            Console.WriteLine(number);
        }
    }
}


Measured memory_bytes: 11220
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pii;

const int MAXN = 1e5+5;

ll n, a[MAXN], b[MAXN], ans = (1LL<<60), posa[MAXN], posb[MAXN];
pii s[2*MAXN];

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

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

	ll sa = 0, sb = 0;
	for (int i = 0; i < n; ++i) {
		sa += a[i];
		sb += b[i];
	}

	ans = min(ans, sa);
	ans = min(ans, sb);

	for (int i = 0; i < n; ++i) {
		s[i] = pii(a[i], i);
		s[i+n] = pii(b[i], i+n);
	}

	sort(s, s+2*n);
	for (int i = 0; i < 2*n; ++i) {
		if (s[i].second < n)
			posa[s[i].second] = i;
		else
			posb[s[i].second-n] = i;
	}

	ll sum = 0;
	for (int i = 0; i < n; ++i)
		sum += s[i].first;
	for (int i = 0; i < n; ++i) {
		//use both a[i], b[i]
		ll ct = 0, t = 0;
		if (posa[i] < n)
			ct++;
		if (posb[i] < n)
			ct++;
		if (ct == 2)
			t = sum;
		if (ct == 0)
			t = sum + a[i] + b[i] - s[n-1].first - s[n-2].first;
		if (ct == 1) {
			if (posa[i] == n-1 || posb[i] == n-1)
				t = sum + max(a[i], b[i]) - s[n-2].first;
			else
				t = sum + max(a[i], b[i]) - s[n-1].first;
		}

		ans = min(ans, t);
	}

	cout << ans << endl;
}

Measured memory_bytes: 6528
import Data.List(sort)

main = do
  ns <- fmap (fmap (read :: String -> Int) . words) . lines <$> getContents
  putStrLn $ show $ solve $ concat $ tail ns

solve :: [Int] -> Int
solve ls = calc 0 0 sorted
  where
     e = if mod (length ls) 2 == 0 then ls else 0 : ls
     sorted = reverse $ sort e

calc :: Int -> Int -> [Int] -> Int
calc a b [] = subtract b a
calc a b src = calc (head h + a) (last h + b) (drop 2 src)
  where
    h = take 2 src

Measured memory_bytes: 1020
#define fast ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#include <bits/stdc++.h>
using namespace std;
#define sqr 340
#define mid (l+r)/2
#define pb push_back
#define ppb pop_back
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define ins insert
#define era erase
#define C continue
#define mem(dp,i) memset(dp,i,sizeof(dp))
#define mset multiset
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pi> vpi;
typedef vector<pll> vpll;
const ll mod=1000000007;
const ll mod2=998244353;
const ll mod3=10007;
const ll inf=1e18*4;
const ld pai=acos(-1);
int n;
vi v[100009];
ll dp[100009][2];
void dfs(int node,int p){
	dp[node][0]=dp[node][1]=1;
	for(auto u:v[node]){
		if(u==p)C;
		dfs(u,node);
		dp[node][0]=(dp[node][0]*((dp[u][0]+dp[u][1])%mod))%mod;
		dp[node][1]=(dp[node][1]*dp[u][0])%mod;
	}
}
int main(){
	cin>>n;
	for(int i=0;i<n-1;i++){
		int a,b;cin>>a>>b;
		a--,b--;
		v[a].pb(b);
		v[b].pb(a);
	}
	dfs(0,0);
	cout<<(dp[0][0]+dp[0][1])%mod<<endl;
}
/*
 * I THINK YOU REALLY SHOULD SOLVE COCI,USACO,BOI,CEOI,CODEFROCES CONTESTS
 * THERE ARE 22 LGM IN THE WORLD,552 GOLDMEDALISTS IN THE HISTORY,0 GOLDMEDALIST IN THE HISTORY SYRIA
 * THAT MEAN AIMING GOALS IS HARD ONLY FEW PEOPLE CAN DO IT
 * AND NO ONE IS SMARTER OR BETTER THAN YOU
 * IT IS JUST ABOUT TRAINING
 * TRAIN LIKE A FIGHTER AND DONT YOU EVER GIVE UP OR LOSE ANY TIME
 * NOT EVEN A SECOND
 * I CAN & I WILL
 * GOAL NUMBER 1 : SILVER MEDAL NEXT JULY IN SINGAPORE 2020
 * 2020 WILL BE YOUR YEAR!
 * 270 DAYS LEFT!!!!!
*/


Measured memory_bytes: 14208
#include<iostream>

using namespace std;
int main() {
	int A[3][3];
	int n, b[10];

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

	cin >> n;

	int ans[3][3];

	for (int i = 0; i < n; i++) {
		cin >> b[i];
	}
	for (int j = 0; j < 3; j++) {
		for (int k = 0; k < 3; k++) {
			ans[j][k] = 0;
			for (int i = 0; i < n; i++) {
				if (A[j][k] == b[i]) {
					ans[j][k] = 1;
				}
			}
		}
	}
		
	

	int t = 0;
	for (int i = 0; i < 3; i++) {
		if (ans[i][0] && ans[i][1] && ans[i][2]) {
			t = 1;
		}
		if (ans[0][i] && ans[1][i] && ans[2][i]) {
			t = 1;
		}

	}
	if (ans[0][0] && ans[1][1] && ans[2][2]) {
		t = 1;
	}
	if (ans[0][2] && ans[1][1] && ans[2][0]) {
		t = 1;
	}

	if (t)cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

//template<typename T>
#define o_set(T) tree<T, null_type,greater<T>, rb_tree_tag,tree_order_statistics_node_update>
//member functions :
//use it like o_set(ll) x;  --> x.order.....
//-->for pair<ll,ll> : second element as index and for search use INT_MAX...
//1. order_of_key(k) : number of elements strictly lesser than k
//2. find_by_order(k) : k-th element in the set


#define fast ios::sync_with_stdio(false);cin.tie(0);cout<<setprecision(25)
#define pb push_back
#define I insert
#define F first
#define S second
#define digit(x) floor(log10(x))+1
const long long M1=1000000007;
const long long  M2=998244353;
#define L_MAX 1e18
using ll = long long;
using ld = long double;
using ii = pair<ll,ll>;
using matrix = vector<vector<ll>>;
using arr = vector<ll>;
using vs = vector<string>;
using pv = vector<ii>;
#define in1(x) scanf("%lld",&x)
#define in2(x,y) scanf("%lld %lld",&x,&y)
#define all(x) x.begin(),x.end()
#define debug(x) cerr << #x << " is " << x << endl;
template<typename T>
void showArr(T a){
    for(auto i : a) cout<<i<<" ";
    cout<<endl;
}
bool isValid(ll x,ll y,ll n,ll m){
    return (x>=0 and y>=0 and x<n and y<m);
}
ll power(ll a,ll n,ll m){
    ll ans=1;
    while(n>0){
        if(n&1){
            ans=(ans%m * a%m)%m;
        }
        n=n>>1;
        a=(a%m*a%m)%m;
    }
    return ans;
}
ll MMI(ll a,ll m){
    ll m0=m,y=0,x=1;
    if(m==1) return 0;
    while(a>1){
        ll q=a/m,t=m;
        m=a%m,a=t,t=y,y=x-q*y,x=t;
    }
    if(x<0) x+=m0;
    return x;
}

ll dx[]={-1,1,0,0},dy[]={0,0,-1,1};
//ll dx[]={-1,1,-1,1,0,0,-1,1} , dy[]={-1,1,0,0,-1,1,1,-1};
int main(){
    fast;
    ll n;
    cin>>n;
    string s;
    cin>>s;
    ll w=0,r=0;
    for(int i=0;i<(int)s.length();i++){
        if(s[i]=='W')
            w++;
        else{
            r++;
        }
    }
    ll ans=0;
    for(int i=0;i<r;i++){
        if(s[i]=='W')
            ans++;
    }
    cout<<ans<<endl;
    
    return 0;
}

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

class FordFulkerson {
public:
  struct Edge { int to, cap, rev; };

  FordFulkerson(int V, int S, int T): V(V), S(S), T(T), G(V, vector<Edge>(0)), used(V, false) {}

  void addEdge(int from, int to, int cap) {
    G[from].push_back({ to, cap, (int)G[to].size() });
    G[to].push_back({ from, 0, (int)G[from].size()-1 });
  }

  int maxFlow() {
    int flow = 0;
    for (;;) {
      resetUsed();
      int f = dfs(S, INFTY);
      if (f == 0) return flow;
      flow += f;
    }
  }

private:
  const int INFTY = (1 << 21);
  int V, S, T;
  vector<vector<Edge> > G;
  vector<bool> used;

  int dfs(int v, int f) {
    if (v == T) return f;
    used.at(v) = true;
    for (auto &edge: G.at(v)) {
      if (used.at(edge.to)) continue;
      if (edge.cap <= 0) continue;
      int d = dfs(edge.to, min(f, edge.cap));
      if (d <= 0) continue;
      edge.cap -= d;
      G.at(edge.to).at(edge.rev).cap += d;
      return d;
    }

    return 0;
  }

  void resetUsed() {
    fill(used.begin(), used.end(), false);
  }
};

#define MAX_E 10001
int X, Y, E, SS[MAX_E], TS[MAX_E];

void input() {
  cin >> X >> Y >> E;
  for (int e=0;e<E;e++) {
    cin >> SS[e] >> TS[e];
  }
}

void solve() {
  int S = X + Y, T = X + Y + 1, V = T + 1;
  FordFulkerson ff(V, S, T);
  for (int e=0;e<E;e++) ff.addEdge(SS[e], TS[e]+X, 1);
  for (int x=0;x<X;x++) ff.addEdge(S, x, 1);
  for (int y=0;y<Y;y++) ff.addEdge(y+X, T, 1);
  cout << ff.maxFlow() << endl;
}

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




Measured memory_bytes: 3424
import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;

public class Main {
	static final int MAX_NUM = 76543210;

	void run() {
		Scanner scan = new Scanner(System.in);
		char[] ans = new char[MAX_NUM + 1];
		Queue<char[]> que = new LinkedList<char[]>();
		que.add(new char[] { 0, 1, 2, 3, 4, 5, 6, 7 });
		while (!que.isEmpty()) {
			int size = que.size();
			for (int i = 0; i < size; i++) {
				char[] p = que.poll();
				int num = convertArrayToNumber(p);
				int index = getZeroOfIndex(p);
				int[] d = { -4, -1, 1, 4 };
				for (int j = 0; j < d.length; j++) {
					int ni = index + d[j];
					if (ni < 0 || ni >= 8)
						continue;
					if (index == 4 && d[j] == -1)
						continue;
					if (index == 3 && d[j] == 1)
						continue;
					char[] np = p.clone();
					swap(np, ni, index);
					int n = convertArrayToNumber(np);
					if (ans[n] != 0)
						continue;
					if (ans[n] == 0 && n == 1234567) continue;
					ans[n] = (char)(ans[num] + 1);
					que.add(np);
				}
			}
		}
		while (scan.hasNext()) {
			char[] pazzle = new char[8];
			for (int i = 0; i < 8; i++) {
				pazzle[i] = (char)scan.nextInt();
			}
			System.out.println((int)ans[convertArrayToNumber(pazzle)]);
		}
	}

	void swap(char[] array, int a, int b) {
		char tmp = array[a];
		array[a] = array[b];
		array[b] = tmp;
	}

	int convertArrayToNumber(char[] array) {
		int sum = 0;
		for (int i = 1; i <= 8; i++) {
			sum += array[i - 1] * Math.pow(10, 8 - i);
		}
		return sum;
	}

	int getZeroOfIndex(char[] array) {
		for (int i = 0; i < array.length; i++) {
			if (array[i] == 0)
				return i;
		}
		return -1;
	}

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

Measured memory_bytes: 191140
#define D(x) cout << #x " = " << x << endl
#define DD(x, y) cout << "(" #x ", " #y ") = (" << x << ", " << y << ")" << endl
#define DDD(x, y, z) cout << "(" #x ", " #y ", " #z ") = (" << x << ", " << y << ", " << z << ")" << endl
#define DV(v) for (auto __macro_vi : v){ cout << __macro_vi << " ";} cout << endl;
#define DA(a, n) for (int __macro_i = 0; __macro_i < n; ++__macro_i) { cout << a[__macro_i] << " "; } cout << endl;
#define REP(i, n) for (int i = 0; i < n; ++i)
#define ALL(v) (v).begin(), (v).end()
#include<iostream>
#include<vector>
#include<cassert>
#include<cmath>

using namespace std;
int l, r;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> l >> r;
    int ans = 2019;
    for (int i = l; i <= min(l + 2019, r); ++i) {
        for (int j = i + 1; j <= min(l + 2020, r); ++j) {
            ans = min((long long)ans, (long long)i * j % 2019);
        }
    }
    cout << ans << endl;
}


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

int main(){
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int w, d, n;
	cin >> w >> d >> n;
	int ans = 0;
	vector<vector<int> > res(w, vector<int>(d, -1e9));
	vector<vector<int> > known(w, vector<int>(d, 1e9));
	for(int _ = 0; _ < n; _++){
		int x, y, z;
		cin >> x >> y >> z;
		x--; y--;
		for(int i = 0; i < w; i++){
			for(int j = 0; j < d; j++){
				res[i][j] = max(res[i][j], z - abs(i - x) - abs(j - y));
			}
		}
		known[x][y] = z;
	}
	for(int i = 0; i < w; i++){
		for(int j = 0; j < d; j++){
			ans += res[i][j];
			if(res[i][j] > known[i][j]){
				cout << "No" << '\n';
				return 0;
			}
		}
	}
	cout << ans << '\n';
}


Measured memory_bytes: 3216
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>

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

using namespace std;

int n, w;

void solve() {
    vector<int> v(n);
    int mx = 0;
    REP(i, n) {cin >> v[i]; mx = max(mx, v[i]);}
    vector<double> hist((mx + w) / w, 0);
    for (auto vi : v) {
        hist[vi / w] += 1;
    }
    double hmx = 0;
    for (auto hi : hist) hmx = max(hmx, hi);
    REP(i, hist.size()) hist[i] /= hmx;
    double ans = 0;
    int i = 0;
    for (auto hi : hist) {
        ans += hi * (1. - i / (hist.size() - 1.));
        i += 1;
    }
    cout << setprecision(10) << fixed << ans + 0.01 << endl;
}

int main() {
    while(1) {
        cin >> n >> w;
        if (n == 0 && w == 0) break;
        solve();
    }
}


Measured memory_bytes: 3228
import sys
import collections
ns = lambda: sys.stdin.readline().rstrip()
ni = lambda: int(ns())
nm = lambda: map(int, sys.stdin.readline().split())
nl = lambda: list(nm())
nsm = lambda: map(str, sys.stdin.readline().split())
nsl = lambda: list(nsm())

p, q, r = nm()

print(min(p + q, q + r, r + p))

Measured memory_bytes: 3444
import java.util.*;

class Main {

	static Scanner sc = new Scanner(System.in);
	
	public static void main(String[] args) {
		int N=sc.nextInt(),x[]=new int[N],y[]=new int[N];
		double dis=0;
		for(int i=0;i<N;i++) {
			x[i]=sc.nextInt();
			y[i]=sc.nextInt();
		}
		for(int i=0;i<N;i++) {
			for(int j=0;j<N;j++) {
				int dx = (int) Math.pow(x[i]-x[j],2);
				int dy = (int) Math.pow(y[i]-y[j],2);
				dis += Math.pow(dx+dy,0.5);
			}
		}
		System.out.println(dis/N);
	}
}

Measured memory_bytes: 35824
N,M = map(int,input().split())
island = [[] for i in range(N+1)]
for i in range(M):
    a,b = map(int,input().split())
    island[a].append(b)

for i in island[1]:
    if N in island[i]:
        print('POSSIBLE')
        exit(0)
print('IMPOSSIBLE')

Measured memory_bytes: 33524
#include <stdio.h>
#include<bits/stdc++.h>
using namespace std;
#pragma GCC target("avx2")
#pragma GCC optimization("O3")
#pragma GCC optimization("unroll-loops")
#define mx 1000008

#define pii pair<int,int>
#define pi acos(-1.0)
#define pb push_back
#define ss second
#define ff first
typedef long long int ll;
///adjacent move
int fx[4]={0,+1,0,-1};
int fy[4]={+1,0,-1,0};
///knight
ll prime[mx];
void seive()
{
    for(int i=2;i<mx;i+=2) prime[i]=2;
    for(int i=3;i<mx;i+=2) prime[i]=i;
    ll sq=sqrt(mx);
    for(int i=3;i<=sq;i+=2){
        if(prime[i]==i){
            for(int j=i*i;j<mx;j+=i){
                if(prime[j]==j) prime[j]=i;
            }
        }
    }
}
int a[1000004];
ll f[2000004];
ll po[2000004];
int main()
{
    //seive();
    int t=1;
    //cin>>t;


    int c=0;
    vector<ll>vec;
    for(int i=2;i<mx;i++){
        if(prime[i]==i){
            vec.push_back(i);
        }
    }
    while(t--){
        ll n,m;

        cin>>n;

        ll a[n*2+7];
        for(int i=1;i<=2*n;i++) cin>>a[i];
        ll sum=0;
        sort(a+1,a+2*n+1);
        for(int i=1;i<=2*n;i++){
            if(i&1) sum+=a[i];
        }
        cout<<sum<<endl;
    }
}


Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
using ll=double;
int main()
{
    double a,b,h,m;
    cin>>a>>b>>h>>m;

    ll deg1=m*6;
    ll deg2=h*30+(m/2);
    ll deg=abs(deg1-deg2);
    deg=deg/180.0;
    deg=deg*3.1415926535897;
    ll ans=a*a+b*b-2*a*b*cos(deg);
    cout<<fixed<<setprecision(14)<<sqrt(ans)<<endl;

    
    
}

Measured memory_bytes: 4212
# coding: utf-8
# Your code here!
import sys
from operator import itemgetter

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

N = int(input())
a = [list(map(int, input().split())) for _ in range(N)]
s = sorted(a, key=itemgetter(1))
current_t = 0

for i in range(N):
    current_t += s[i][0]
    if current_t > s[i][1]:
        print("No")
        break
else:
    print("Yes")

Measured memory_bytes: 55256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(n) for (ll i = 0; i < n; ++i)
#define rep2(i, n) for (ll i = 0; i < n; ++i)
#define rep3(i, a, b) for (ll i = a; i < b; ++i)
#define rep4(i, a, b, c) for (ll i = a; i < b; i += c)
#define erep(n) for (ll i = 0; i <= n; ++i)
#define erep2(i, n) for (ll i = 0; i <= n; ++i)
#define erep3(i, a, b) for (ll i = a; i <= b; ++i)
#define erep4(i, a, b, c) for (ll i = a; i <= b; i += c)
#define rrep(i, a, b) for (ll i = a; i > b; --i)
#define rrep2(i, a, b, c) for (ll i = a; i > b; i -= c)
#define errep(i, a, b) for (ll i = a; i >= b; --i)
#define errep2(i, a, b, c) for (ll i = a; i >= b; i -= c)
#define print(a) cout << a << endl;
#define printVec(v) printf("{"); for (const auto& i : v) { std::cout << i << ", "; } printf("}\n");
#define cin(x) cin >> x;
const ll MOD = 1000000007;
const double PI = 3.14159265358979323846264338327950;
inline int newline() { putchar('\n'); return 0; }

int main() {
    int n, m;
    cin(n); cin(m);

    struct Edge {
        int from, to;
        ll cost;
    };

    vector<Edge> edges(m);
    rep2(i, m) {
        int from, to;
        ll cost;
        cin(from); cin(to); cin(cost);

        --from; --to;

        edges[i] = { from, to, cost };
    }

    vector<ll> s(n, LLONG_MIN);
    s[0] = 0;

    rep2(i, m) {
        Edge e = edges[i];

        if (s[e.from] != LLONG_MIN) {
            if (s[e.from] + e.cost > s[e.to]) s[e.to] = s[e.from] + e.cost;
        }
    }

    ll first = s[n - 1];

    rep2(i, m) {
        Edge e = edges[i];

        if (s[e.from] != LLONG_MIN) {
            if (s[e.from] + e.cost > s[e.to]) s[e.to] = s[e.from] + e.cost;
        }
    }

    if (first == s[n - 1]) {
        print(first);
    } else {
        print("inf");
    }

    return 0;
}

Measured memory_bytes: 3656
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cstdlib>
#include<queue>
#include<set>
#include<cstdio>

using namespace std;

#define ll long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define P pair<int, int>

typedef vector<int> vec;
typedef vector<vec> mat;

const ll mod = 1000000007;

int main(){
    int n;
    cin >> n;
    double v[n];
    rep(i, n) cin >> v[i];
    sort(v, v + n);
    double ans = v[0];
    rep(i, n-1) ans = (ans + v[i+1]) / 2;
    printf("%.10lf\n", ans);
}

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


int N, A;
int x[51];
ll dp[51][51][3001] = {0};

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

  dp[0][0][0] = 1;
  
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      for (int k = 0; k < 3001; k++) {
        if(dp[i][j][k]) {
		  dp[i + 1][j + 1][k + x[i]] += dp[i][j][k];
          dp[i + 1][j][k] += dp[i][j][k];
        }
      }
    }
  }
  ll ans = 0;
  for (int i = 1; i <= N; i++) {
    ans += dp[N][i][i * A];
  }
  cout << ans << endl;
}


Measured memory_bytes: 58112
// #include <bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<set>
#include<map>
#include<queue>
#define PI 3.14159265358979323846264338327950288
#define rep(i,n) for(int i=0;i<n;i++)
#define exf(x)	 for(auto&& tmp : x) { cout << tmp << endl; }	// 拡張for
#define testP	 cout << "------------------ test ------------------" << endl;	// 動作確認テスト
#define testX(x) cout << "testout : " << x << endl;	// テストアウト
typedef long long ll;
using namespace std;
const int MOD{ int(1e9 + 7) };	// = 1000000007
const int inf{ 2100000000 };	// = 2100000000 (MAX:2147483647)

// ------------------ ベクター表示 ------------------ //
void printVec(vector<int>& vec) {
	cout << "";
	for (auto it = vec.begin(); it != vec.end(); it++) cout << *it << " ";
	cout << endl;
}

// ------------------ ベクター合計 ------------------ //
int sumVec(vector<int> v) {
	int sum = 0;
	for (size_t i = 0; i < v.size(); i++) sum += v[i];
	return sum;
}

// -------------------------------------------------- //
// ------------------ ここから本編 ------------------ //
// -------------------------------------------------- //

int main(void) {

	int a[5];
	int ans = -1;
	rep(i, 5) {
		cin >> a[i];
		if (a[i] == 0)ans = i;
	}
	cout << ans+1 << endl;
	return 0;
}


Measured memory_bytes: 3576
#include<bits/stdc++.h>
#define pi acos(-1)
#define ll long long
#define pii pair<ll,ll>
#define debug(a) cout<<a<<'\n'
#define maxn 200009 /// I wanna be the wind
#define MOD 1000000007
#define F first
#define S second
#define rep(i, a, b) for(ll i = a; i < (b); ++i)
#define per(i, b, a) for(ll i = b-1; i>=a ; i--)
#define trav(a, x) for(auto& a : x)
#define allin(a , x) for(auto a : x)
#define all(x) begin(x), end(x)
#define sz(x) (ll)(x).size()
using namespace std;
const ll INF = 1e17 + 9;
ll mult(ll a,ll b){
    return a*b%MOD;
}
ll fastpow(ll  a, ll b){
    ll calc=1;
    for(;b>=1LL;b/=2LL){
        if((b&1LL))calc=mult(calc,a);
        a=mult(a,a);
    }
    return calc;
}
ll soma(ll a,ll b){
    if(a+b>MOD)return a+b-MOD;
    else return a+b;
}
ll subt(ll a,ll b){
    if(a-b<0)return a-b+MOD;
    else return a-b;
}
struct M {
    vector<vector<int>> t;
    M(ll n,ll m){
        t.resize(n,vector<int>(m));
    }
    M operator * (const M& b) const{
        ll n = t.size();
        ll m = t[0].size();
        ll mm = b.t[0].size();
        M c = M(n,mm);
        rep(i,0,n){
            rep(j,0,mm){
                rep(k,0,m){
                    // cout<<i<<" "<<k<<"   "<<i<<" "<<j<<"   "<<j<<" "<<k<<endl;
                    c.t[i][k] = soma(c.t[i][k],mult(t[i][j],b.t[j][k]));
                }
            }
        }
        return c;
    }
};
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n,k;
    cin>>n>>k;
    vector<vector<int>> can(n,vector<int>(n));
    rep(i,0,n){
        rep(j,0,n){
            cin>>can[i][j];
        }
    }
    M ans = M(n,n);
    M mat = M(n,n);
    mat.t = can;
    rep(i,0,n){
        ans.t[i][i]=1;    
    }
    while(k){
        if(k%2) ans = ans*mat;
        mat = mat*mat;
        k/=2;
    }
    // cout<<"\n";
    ll total = 0;
    rep(i,0,n){
        rep(j,0,n){
            total = soma(total,ans.t[i][j]);
        }
    }
    cout<<total<<"\n";
    return 0;  
}   

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

int main() {
    int n;
    cin >> n;
    vector<P> a(n);
    rep(i,n) {
        int x, y;
        cin >> x >> y;
        a[i] = P(x,y);
    }
    double sum = 0;
    int cnt = 0;
    vector<int> p(n);
    rep(i,n) p[i] = i;
    do {
        cnt++;
        rep(i,n-1) {
            double x = a[p[i]].first - a[p[i+1]].first;
            double y = a[p[i]].second - a[p[i+1]].second;
            double d = sqrt(x*x + y*y);
            sum += d;
        }
    } while (next_permutation(p.begin(), p.end()));
    double ans = sum/cnt;
    printf("%.10f\n", ans);
    return 0;
}

Measured memory_bytes: 3792
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>

using namespace std;

typedef long long ll;

int main(int argc, char *argv[])
{
	int N, M;
	
	cin >> N >> M;

	vector<vector<int>> v(M);

	for (int i = 0; i < N; i++) {
		int A, B;
		cin >> A >> B;
		if (A > M) {
			continue;
		}
		v[M - A].push_back(B);
	}

	ll ans = 0;
	priority_queue<int> q;
	for (int i = M - 1; i >= 0 ; i--) {
		for (int b : v[i]) {
			q.push(b);
		}
		if (!q.empty()) {
			ans += q.top();
			q.pop();
		}
	}

	cout << ans << endl;

	return 0;
}


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

int main() {

	int N,res;
	cin >> N;

	res = N % 10;

	if (res == 3) {
		cout << "bon" << endl;
	}

	else if (res == 0 || res == 1 || res == 6 || res == 8) {
		cout << "pon" << endl;
	}

	else {
		cout << "hon" << endl;
	}
	
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b;
  cin >> a >> b;
  int ans =0;
  while (a <= b) {
    if (a / 10000 % 10 == a % 10 && a / 1000 % 10 == a / 10 % 10) {
      ans++;
    }
    a++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
N,A,B = map(int,input().split())

if A != 0 and N%(A+B) <= A :
  print((N//(A+B))*A + N%(A+B))

elif A != 0 and N%(A+B) > A :
  print((N//(A+B))*A + A)

else :
  print("0")

Measured memory_bytes: 3060
#include <algorithm>
#include <iostream>
#include <iterator>
#include <vector>
using namespace std;

int main() {
	int nm;
	cin >> nm;
	vector<int> a(nm), c;
	for (int& i : a) cin >> i;
	cin >> nm;
	vector<int> b(nm);
	for (int& i : b) cin >> i;
	set_intersection(a.begin(), a.end(), b.begin(), b.end(), inserter(c, c.end()));
	for (int& i : c) cout << i << endl;
}


Measured memory_bytes: 4756
def bb
    h,w = gets.chomp.split(/\s/).map{|x| x.to_i}

    ai = []
    for i in 1..h
        ar = gets.chomp.split(//).map{|x| x=='.'?0:1}
        aq = ar.uniq
        ai.push(ar) unless aq.length == 1 and aq[0] == 0 # 1行全部0の場合、pushしない
    end

    # 列を削除・・
    ak = []
    idx = 0
    ai.transpose.each do |aj|
        al = aj.uniq
        if al.length == 1 and al[0] == 0
            ak.push(idx)
        end
        idx += 1
    end

    ai.each do |a|
        idx = 0
        a.each do |b|
            if ak.include?(idx)
                idx += 1
                next
            end
            print b==0?'.':'#'
            idx += 1
        end
        puts
    end
end

bb


Measured memory_bytes: 2172
using System;

public class Hello
{
    public static void Main()
    {
        while (true)
        {
            var n = int.Parse(Console.ReadLine().Trim());
            if (n == 0) break;
            var wk = new int[n];
            for (int i = 0; i < n; i++) wk[i] =  int.Parse(Console.ReadLine().Trim());
            Array.Sort(wk);
            var a0 = 0L;  var a1 = 0L;
            var ret = 0L;
            for (int i = 0; i < n-1; i++)
            {
                a1 = a0 + wk[i];
                ret += a1;
                a0 = a1;
            }
            Console.WriteLine(ret);
        }
    }
}

Measured memory_bytes: 9372
def solve(N,K,S):
    """
    >>> solve(4,2,3)
    1 2 3 4
    >>> solve(4,2,1000000000)
    1000000000 1000000000 1 1
    """
    if S < 1000000000:
        l = [str(S)] * K
        for i in range(N-K):
            l.append("1000000000")
        s = " ".join(l)
        print(s)
    else:
        l = [str(S)] * K
        for i in range(N-K):
            l.append("1")
        s = " ".join(l)
        print(s)


def main():
    N,K,S = map(int,input().split())
    solve(N,K,S)


def _test():
    import doctest
    doctest.testmod()


if __name__ == "__main__":
    import sys
    argv = sys.argv
    if len(sys.argv) == 1:
        # no option
        main()
    elif sys.argv[1] == "-t":
        _test()
    else:
        input = open(sys.argv[1]).buffer.readline

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

int main() {
  int n, k;
  cin >> n >> k;
  
  long long a = 0, b = 0;
  for (int i = 1; i <= n; ++i) {
    if (i % k == 0) {
      ++a;
    } else 
    if (2 * i % k == 0) {
      ++b;
    }
  }
  cout << a * a * a + b * b * b << endl;
}


Measured memory_bytes: 256
n, m = map(int, input().split())
A = []

for i in range(n):
  a,b = map(int, input().split())
  A.append([a,b])
  
C = []
for i in range(m):
  c,d = map(int, input().split())
  C.append([c,d])
  
ans = [0 for i in range(n)]
infinity = float("infinity")
for i in range(n):
  min_length = infinity
  for j  in range(m):
    if abs(A[i][0] - C[j][0]) + abs(A[i][1] - C[j][1]) < min_length:
      min_length = abs(A[i][0] - C[j][0]) + abs(A[i][1] - C[j][1])
      ans[i] = j+1
      
for i in range(len(ans)):
  print(ans[i])


Measured memory_bytes: 3064