akhauriyash/Code-Regression huggingface dataset:
// C++ code to find number of distinct numbers 
// in a subarray 
#include<bits/stdc++.h> 
using namespace std; 
  #define ld long double
#define ll long long
const int MAX = 1000001; 
int a[5*MAX+7]; 
struct Query 
{ 
    int l, r, idx; 
}; 

bool cmp(Query x, Query y) 
{ 
    return x.r < y.r; 
} 
  
void update(int idx, int val, int bit[], int n) 
{ 
    for (; idx <= n; idx += idx&-idx) 
        bit[idx] += val; 
} 
int query(int idx, int bit[], int n) 
{ 
    int sum = 0; 
    for (; idx>0; idx-=idx&-idx) 
        sum += bit[idx]; 
    return sum; 
} 
  
void answeringQueries(int arr[], int n, Query queries[], int q) 
{ 
    int bit[n+1]; 
    memset(bit, 0, sizeof(bit)); 
    int last_visit[MAX]; 
    memset(last_visit, -1, sizeof(last_visit)); 
    int ans[q]; 
    int query_counter = 0; 
    for (int i=0; i<n; i++) 
    { 
       
        if (last_visit[arr[i]] !=-1) 
            update (last_visit[arr[i]] + 1, -1, bit, n); 
        last_visit[arr[i]] = i; 
        update(i + 1, 1, bit, n); 
        while (query_counter < q && queries[query_counter].r == i) 
        { 
            ans[queries[query_counter].idx] = 
                     query(queries[query_counter].r + 1, bit, n)- 
                     query(queries[query_counter].l, bit, n); 
            query_counter++; 
        } 
    } 
    for (int i=0; i<q; i++) 
        cout << ans[i] << endl; 
}  
int main() 
{  
    int n,q; cin>>n>>q; 
    for(int i=0;i<=n-1;i++) cin>>a[i]; 
    Query queries[q]; int t=0; int p=q; 
    while(q--)  
    {   
        int s,e; cin>>s>>e; s--; e--; 
        queries[t].l=s; queries[t].r=e; 
        queries[t].idx=t; t++; 
    } 
    sort(queries, queries+p, cmp); 
    answeringQueries(a, n, queries, p); 
    return 0; 
}

Measured memory_bytes: 19308
#include <cstdio>
#include <set>

int main() {
  size_t N, M;
  scanf("%zu %zu", &N, &M);

  std::set<size_t> one, en;
  for (size_t i = 0; i < M; ++i) {
    size_t a, b;
    scanf("%zu %zu", &a, &b);

    if (a == 1) one.insert(b);
    if (b == N) en.insert(a);
  }

  for (auto b: one)
    if (en.count(b))
      return puts("POSSIBLE"), 0;

  puts("IMPOSSIBLE");
}


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

int main()
{
    char a[3];
    int b=700;

    std::cin>>a;

    for(int i=0;i<3;i++){
    if(a[i]=='o')
        b+=100;
    }
    std::cout<<b<<'\n';
    
    return 0; 
}


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

int arr[10000];

int find(int x)
{
	while (arr[x] != x)x = arr[x];
	return x;
}

void unite(int a, int b)
{
	arr[find(a)] = arr[find(b)];
}

int main()
{
	int n, q, ch, a, b;
	scanf("%d%d", &n, &q);
	for (int i = 0; i < n; ++i)arr[i] = i;
	while (q--){
		scanf("%d%d%d", &ch, &a, &b);
		if (ch){
			if (find(a) == find(b))printf("1\n");
			else printf("0\n");
		}
		else {
			unite(a, b);
		}
	}
	return 0;
}


Measured memory_bytes: 3196
/* ex 2_3 nknm */
 
#include <stdio.h>
 
int main(void){
    //引数を定義
    int N,A;
  
    //数字を入力
    scanf("%d%d", &N, &A);
    //数字を出力
    printf("%d\n", N * N - A);
  
    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<string.h>
using namespace std;
int main(){
	string a,b;
	int i=0;
	cin>>a>>b;
	if(a.length()!=b.length()){
		cout<<"No"<<endl;
		return 0;
	}else{
		for(i=0;i<a.length();i++){
			if(a[i]==b[0]){
				break;
			}
		}
		for(int j=0;j<a.length();j++){
			if(i<=a.length()){
				if(a[i]==b[j]){
					i++;
					if(i>=a.length()){
						i=i-a.length();
					} 
					
				}else{
					cout<<"No"<<endl;
					return 0;
				}
			}
		}
	}
	cout<<"Yes"<<endl;
	return 0;
}

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

int main(){
    int n;
    cin>>n;
    for(int k=0;k<n;k++){
        string order,msg;
        cin>>order>>msg;
        reverse(order.begin(),order.end());
        for(int i=0;i<order.size();i++){
            if(order[i]=='C'){
                string tmp=msg;
                for(int j=0;j<msg.size();j++)
                    tmp[j]=msg[(j+1)%msg.size()];
                    msg=tmp;
            }
            if(order[i]=='J'){
                string tmp=msg;
                for(int j=0;j<msg.size();j++)
                    tmp[j]=msg[(j-1+int(msg.size()))%msg.size()];
                msg=tmp;


            }
            if(order[i]=='E'){
                string tmp=msg;
                if(!(msg.size()%2))
                    for(int j=0;j<msg.size()/2;j++){
                        tmp[j]=msg[msg.size()/2+j];
                        tmp[msg.size()/2+j]=msg[j];
                    }
                else
                    for(int j=0;j<msg.size()/2;j++){
                        tmp[j]=msg[msg.size()/2+1+j];
                        tmp[msg.size()/2+1+j]=msg[j];

                    }
                msg=tmp;
            }
            if(order[i]=='A')
                reverse(msg.begin(),msg.end());
            if(order[i]=='M'){
                for(int j=0;j<msg.size();j++)
                    if('0'<=msg[j] && msg[j]<='9')
                        msg[j]=(msg[j]-'0'+1)%10+'0';

            }
            if(order[i]=='P'){
                for(int j=0;j<msg.size();j++)
                    if('0'<=msg[j] && msg[j]<='9')
                        msg[j]=(msg[j]+10-'0'-1)%10+'0';


            }
      }

        cout<<msg<<endl;
    }


    return 0;
}
                  
                                                   

Measured memory_bytes: 3048
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>
#include <stack>



#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = (int)(n-1); i >= 0; i--)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(x) (x).begin(),(x).end()

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

typedef long long ll;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n;cin>>n;
  ll res=1e18;
  repi(i,1,(int)sqrt(n)+1){
    if(n%i==0){
      chmin(res,(n/i+i-2));
    }
  }
  cout<<res<<endl;
  return 0;

}


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

int main() {
  int N;
  cin >> N;
  vector<ll> T(N), A(N);
  for (int i = 0; i < N; i++) cin >> T[i] >> A[i];

  for (int i = 1; i < N; i++) {
    ll x = max((T[i - 1] + T[i] - 1) / T[i], (A[i - 1] + A[i] - 1) / A[i]);
    T[i] *= x, A[i] *= x;
  }
  cout << T[N - 1] + A[N - 1] << endl;
}


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

int main(){
  long long int A, B, C, K;
  cin >> A >> B >> C >> K;
  if(abs(A - B) > (long long int)(1e18)) cout << "Unfair" << endl;
  else if(K%2) cout << B - A << endl;
  else cout << A - B << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<cmath>
#include<iomanip>

int main(void){
    double a, b, x;
    std::cin >> a >> b >> x;
    // if(b - sta::tan())
    double tan = 2 / std::pow(a, 3) * (std::pow(a, 2) * b - x);
    // std::cout << a * std::tan(ans) << std::endl;
    if(tan <= b / a) {
        std::cout << std::fixed << std::setprecision(15) << std::atan2(tan, 1) * 180 / M_PI << std::endl;
    }else{
        tan = std::pow(b, 2) / (2 * x ) * a;
        std::cout << std::fixed << std::setprecision(15) << std::atan2(tan, 1) * 180 / M_PI << std::endl;
    }
    // std::cout << ans * 180 / M_PI << std::endl;
    // std::cout << std::tan(ans) << std::endl;
    return 0;
}


Measured memory_bytes: 4308
#include<bits/stdc++.h>
using namespace std ;
int main()
{
	string s , t ;
	cin >> s >> t ;
	sort ( s.begin() , s.end() ) ;
	sort ( t.begin() , t.end() ) ;
	reverse ( t.begin() , t.end() ) ;
	if ( s < t ) 
		cout << "Yes" ;
	else
		cout << "No" ;


}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

const int mod = 1e9 + 7, MX = 210000;
int n, cnt[MX];
vector<vi> e;

deque<vi> *rec(int c, int p, int d = 0){
	cnt[d]++;
	vector<deque<vi>*> v;
	for(int i : e[c]) if(i != p) v.pb(rec(i, c, d + 1));
	if(!v.size()){
		deque<vi> *res = new deque<vi>();
		res->pb({1, 1, 0});
		return res;
	}
	sort(all(v), [](deque<vi> *a, deque<vi> *b){
		return a->size() < b->size();
	});
	rep(i, v.size() - 1){
		deque<vi> &l = *v[i], &r = *v[i + 1];
		
		rep(j, l.size()){
			vi next(3);
			rep(x, 3) rep(y, 2){
				(next[min(x + y, 2)] += (ll)l[j][x] * r[j][y] % mod) %= mod;
			}
			r[j] = next;
		}
	}
	if(v.size() > 1) rep(i, v[v.size() - 2]->size()){
		((*v.back())[i][0] += (*v.back())[i][2]) %= mod;
		(*v.back())[i][2] = 0;
	}
	v.back()->push_front({1, 1, 0});
	return v.back();
}

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	cin >> n; n++;
	e.resize(n);
	for(int i = 1; i < n; i++){
		int p; cin >> p;
		e[p].pb(i);
		e[i].pb(p);
	}
	
	deque<vi> &dp = *rec(0, 0);
	ll pw[MX], ans = 0;
	pw[0] = 1;
	rep(i, MX - 1) pw[i + 1] = pw[i] * 2 % mod;
	rep(i, dp.size()) ans += pw[n - cnt[i]] * dp[i][1] % mod;
	cout << ans % mod << endl;
	
	return 0;
}

Measured memory_bytes: 154224
n = int(input())
init = []
tosort = []
final = []

for i in range(n):
    s, p = (str(_) for _ in input().split())
    init.append([s,int(p)])
cities = sorted(init)

prev = cities[0][0]

for city in cities:
    if city[0] == prev:
        tosort.append(city)
    else:
        tosort.sort(key=lambda x: x[1], reverse = True)
        final += tosort
        tosort = []
        tosort.append(city)
    prev = city[0]
tosort.sort(key=lambda x: x[1], reverse = True)
final += tosort

for f in final:
    print(init.index(f)+1)

Measured memory_bytes: 3064
#![allow(unused_imports, unused_macros, dead_code)]

macro_rules! min {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| min!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = min!($($ys),*);
        if $x < t { $x } else { t }
    }}
}
macro_rules! max {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| max!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = max!($($ys),*);
        if $x > t { $x } else { t }
    }}
}
macro_rules! ewriteln {
    ($($args:expr),*) => { let _ = writeln!(&mut std::io::stderr(), $($args),*); };
}
macro_rules! trace {
    ($x:expr) => { ewriteln!(">>> {} = {:?}", stringify!($x), $x) };
    ($($xs:expr),*) => { trace!(($($xs),*)) }
}
macro_rules! put {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        if let Some(x) = it.next() { print!("{}", x); }
        for x in it { print!(" {}", x); }
        println!("");
    }};
    ($x:expr) => { println!("{}", $x) };
    ($x:expr, $($xs:expr),*) => { print!("{} ", $x); put!($($xs),*) }
}

const M: i64 = 1_000_000_007;

fn main() {
    let mut sc = Scanner::new();
    let n: usize = sc.cin();
    let x: usize = sc.cin();
    let t: usize = sc.cin();
    put!((n + x - 1) / x * t);
}

use std::collections::VecDeque;
use std::io::{self, Write};
use std::str::FromStr;

struct Scanner {
    stdin: io::Stdin,
    buffer: VecDeque<String>,
}
impl Scanner {
    fn new() -> Self {
        Scanner {
            stdin: io::stdin(),
            buffer: VecDeque::new(),
        }
    }
    fn cin<T: FromStr>(&mut self) -> T {
        while self.buffer.len() == 0 {
            let mut line = String::new();
            let _ = self.stdin.read_line(&mut line);
            for w in line.split_whitespace() {
                self.buffer.push_back(String::from(w));
            }
        }
        self.buffer.pop_front().unwrap().parse::<T>().ok().unwrap()
    }
    fn chars(&mut self) -> Vec<char> {
        self.cin::<String>().chars().collect()
    }
    fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.cin()).collect()
    }
}


Measured memory_bytes: 2072
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// ここにコードを挿入
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int x = sc.nextInt();
		int t = 0, s = 0, k = 1;
		for (int i = 1; i <= n; i++) {
			t = sc.nextInt();
			s += t;
			if (s <= x) {
				k++;
			}

		}
		System.out.println(k);
	}

}

Measured memory_bytes: 21844
N,K=tuple(map(int,input().split()))
S=input()
if S[K-1]=="A":
    print(S[0:K-1]+"a"+S[K:N])
elif S[K-1]=="B":
    print(S[0:K-1]+"b"+S[K:N])
elif S[K-1]=="C":
    print(S[0:K-1]+"c"+S[K:N])

Measured memory_bytes: 3064
package main

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

func max(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton max() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Max(float64(res), float64(nums[i])))
	}
	return res
}
func main() {
	sc := NewBufScanner(os.Stdin)
	n, m, k := sc.Int(), sc.Int(), sc.Int()


	a := make([]int, n+1)
	for i := 1; i <= n; i++ {
		tmp := sc.Int()
		a[i] = a[i-1] + tmp
	}

	b := make([]int ,m+1)
	for i := 1; i <= m; i++ {
		tmp := sc.Int()
		b[i] = b[i-1] + tmp
	}



	ans := 0

	j := m
	for i :=0; i <=n; i++ {
		if a[i] > k {
			continue
		}
		for b[j] > k - a[i] {
			j--
		}
		ans = max(ans, i + j)
	}

	fmt.Println(ans)
}


type BufScanner struct {
	*bufio.Scanner
}

func NewBufScanner(r io.Reader) *BufScanner {
	s := bufio.NewScanner(r)
	s.Split(bufio.ScanWords)
	// s.Split(scanWords)
	return &BufScanner{s}
}

func scanWords(data []byte, atEOF bool) (advance int, token []byte, err error) {
	start := 0
	for isSpace(data[start]) {
		start++
	}
	for i := start; i < len(data); i++ {
		if isSpace(data[i]) {
			return i+1, data[start:i], nil
		}
	}
	if atEOF && len(data) > start {
		return len(data), data[start:], nil
	}
	return start, nil, nil
}
func isSpace(b byte) bool {
	return b == ' ' || b == '\n' || b == '\r' || b == '\t'
}

func (s *BufScanner) String() string {
	s.Scan()
	return s.Text()
}

func (s *BufScanner) Int() int {
	return int(s.UInt())
}

func (s *BufScanner) UInt() uint64 {
	s.Scan()
	i, e := strconv.ParseUint(s.Text(), 10, 64)
	if e != nil {
		panic(e)
	}
	return i
}


Measured memory_bytes: 7828
#include<iostream>
#include<algorithm>
using lint=long long;
using namespace std;
 
int main()
{
	lint N,W;
	lint w[110]={},v[110]={};
	lint dp[110][100010]={};
	
	cin >> N >> W;
	for(int i=1;i<=N;i++)
		cin >> w[i] >> v[i];
	
	for(int i=0;i<110;i++)
		for(int j=0;j<100010;j++)
			dp[i][j]=1e9+7;
	for(int i=0;i<=N;i++)
		dp[i][0]=0;
	
	for(int i=1;i<=N;i++)
	{
		for(int j=0;j<=100000;j++)
		{
			dp[i][j]=dp[i-1][j];
			if(j-v[i]>=0)
				dp[i][j]=min(dp[i][j],dp[i-1][j-v[i]]+w[i]);
		}
	}
	
	for(int i=100000;i>=0;i--)
	{
		if(dp[N][i]<=W)
		{
			cout << i << endl; 
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 86144
import math
n=int(input())
a=list(map(int,input().split()))
soin = [0]*(10**6+1)
if a.count(1)==n:
    print("pairwise coprime")
    exit()

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n ** 0.5 // 1)) + 1):
        if temp % i == 0:
            while temp % i == 0:
                temp //= i
            arr.append(i)

    if temp != 1:
        arr.append(temp)

    if arr == []:
        arr.append(n)

    return arr


if len(a)>80000:
    ans=a[0]
    for i in a:
        ans=math.gcd(ans,i)
    if ans==1:
        print("setwise coprime")
    else:
        print("not coprime")
else:
    for i in a:
        if i ==1:continue
        for num in factorization(i):
            soin[num]+=1
    if max(soin)==1:
        print("pairwise coprime")
    elif max(soin)==n and 1 not in a:
        print("not coprime")
    else:print("setwise coprime")


Measured memory_bytes: 189228
from math import *

def main():
    N, M = map(int, input().split())
    special_value = M//N
    divisor_set = set(i for i in range(1, (int(sqrt(M)) + 1)) if (M % i == 0))
    divisor_set = divisor_set.union(M//j for j in divisor_set)
    print(int(max(divisor_set, key=lambda x: x if special_value >= x else -1)))

    return

main()


Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<numeric>
using namespace std;
typedef long long ll;
ll MOD = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)
int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    int sum = accumulate(a.begin(), a.end(), (int)0);
    int frame_num = 0;
    int frame_min_dif = 1e8;
    rep(i, n) {
        int tmp_num = a[i] * n;
        int dif = abs(tmp_num - sum);
        if ( dif < frame_min_dif ) {
            frame_num = i;
            frame_min_dif = dif;
        }
    }
    cout << frame_num << endl;
    return 0;
}


Measured memory_bytes: 384
from itertools import accumulate

def time_to_seconds(time):
    h, m, s = time.split(':')
    return int(h) * 3600 + int(m) * 60 + int(s)

ans = []
while(1):
    N = int(input())
    if N==0:
        break
    A = []
    for n in range(N):
        begin, end = input().split()
        begin = time_to_seconds(begin)
        end = time_to_seconds(end)
        A.append((begin,1))
        A.append((end,-1))
    A.sort()
    mx = 0
    cumsum = 0
    for _, x in A:
        cumsum += x
        mx = max(mx, cumsum)
    ans.append(mx)

for a in ans:
    print(a)


Measured memory_bytes: 7784
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pint;

int main(){
    string s;
    cin>>s;
    int c=s.size()-1;
    ll ans=0;
    rep(i,1<<c){
        ll t=s[0]-'0';
        FOR(j,1,c+1){
            if(1<<(j-1)&i){
                ans+=t;
                t=s[j]-'0';
            }
            else{
                t*=10;
                t+=s[j]-'0';
            } 
        }
        ans+=t;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) 42
#endif

#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define repp(i, m, n) for(int i = m, i##_len = (n); i < i##_len; ++i)
#define reprev(i, n) for(int i = (n-1LL); i >= 0; --i)
#define all(x) (x).begin(), (x).end()
template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;

template< typename T >
struct edge {
  int src, to;
  T cost;

  edge(int to, T cost) : src(-1), to(to), cost(cost) {}

  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}

  edge &operator=(const int &x) {
    to = x;
    return *this;
  }

  operator int() const { return to; }
};

template< typename T >
using Edges = vector< edge< T > >;
template< typename T >
using WeightedGraph = vector< Edges< T > >;
using UnWeightedGraph = vector< vector< int > >;
template< typename T >
using Matrix = vector< vector< T > >;

template< typename T >
void warshall_floyd(Matrix< T > &g, T INF) {
  for(int k = 0; k < g.size(); k++) {
    for(int i = 0; i < g.size(); i++) {
      for(int j = 0; j < g.size(); j++) {
        if(g[i][k] == INF || g[k][j] == INF) continue;
        g[i][j] = min(g[i][j], g[i][k] + g[k][j]);
      }
    }
  }
}

int h, w;
int f(int i, int j) {
    return i * w + j;
}

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> h >> w;
    vector<string> s(h);
    rep (i, h) cin >> s[i];
    Matrix<int> mat(h * w, vector<int>(h * w, INT16_MAX));
    rep (i, h) rep (j, w) mat[f(i,j)][f(i,j)] = 0;
    rep (i, h) {
        rep (j, w - 1) {
            if (s[i][j] == '.' && s[i][j + 1] == '.') {
                mat[f(i,j)][f(i,j+1)] = 1;
                mat[f(i,j+1)][f(i,j)] = 1;
            }
        }
    }
    rep (i, h - 1) {
        rep (j, w) {
            if (s[i][j] == '.' && s[i + 1][j] == '.') {
                mat[f(i,j)][f(i+1,j)] = 1;
                mat[f(i+1,j)][f(i,j)] = 1;
            }
        }
    }
    warshall_floyd(mat, INT16_MAX);
    int ans = 0;
    rep (x, h * w - 1) {
        repp (y, x + 1, h * w) {
            int i = x / w, j = x % w, ii = y / w, jj = y % w;
            if (s[i][j] == '.' && s[ii][jj] == '.') chmax(ans, mat[x][y]);
        }
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 896
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<queue>
using namespace std;
int x[300][50];
int y[300][50];
double ijk[300];
int v[300];
int size[300];
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1);
int sig(double r){return (r<-EPS)?-1:(r>+EPS)?+1:0;}
double Abs(double a){return max(a,-a);}
struct Pt{
	double x,y;
	Pt(){}
	Pt(double x,double y):x(x),y(y){}
	Pt operator+(const Pt &a)const{return Pt(x+a.x,y+a.y);}
	Pt operator-(const Pt &a)const{return Pt(x-a.x,y-a.y);}
	Pt operator*(const Pt &a)const{return Pt(x*a.x-y*a.y,x*a.y+y*a.x);}
	Pt operator-()const{return Pt(-x,-y);}
	Pt operator*(const double &k)const{return Pt(x*k,y*k);}
	Pt operator/(const double &k)const{return Pt(x/k,y/k);}
	double Abs()const{return sqrt(x*x+y*y);}
	double Abs2()const{return x*x+y*y;}
	double arg()const{return atan2(y,x);}
	double dot(const Pt &a)const{return x*a.x+y*a.y;}
	double det(const Pt &a)const{return x*a.y-y*a.x;}
};
Pt point[300][50];
double tri(const Pt&a,const Pt&b,const Pt&c){return (b-a).det(c-a);}
int iSP(Pt a,Pt b,Pt c){
	int s=sig((b-a).det(c-a));
	if(s)return s;
	if(sig((b-a).dot(c-a))<0)return -2;
	if(sig((a-b).dot(c-b))<0)return +2;
	return 0;
}
bool iSS(Pt a,Pt b,Pt c,Pt d){
	return (iSP(a,b,c)*iSP(a,b,d)<=0&&iSP(c,d,a)*iSP(c,d,b)<=0);
}
double dSP(Pt a,Pt b,Pt c){
	if(sig((b-a).dot(c-a))<=0)return (c-a).Abs();
	if(sig((a-b).dot(c-b))<=0)return (c-b).Abs();
	return Abs(tri(a,b,c))/(b-a).Abs();
}
double dSS(Pt a,Pt b,Pt c,Pt d){
	return iSS(a,b,c,d)?0:min(min(dSP(a,b,c),dSP(a,b,d)),min(dSP(c,d,a),dSP(c,d,b)));
}
double dist[300][300];
int main(){
	int a,b;
	while(scanf("%d%d",&a,&b),a){
		for(int i=0;i<b;i++){
			int c;
			scanf("%d",&c);
			size[i]=c;
			for(int j=0;j<c;j++){
				scanf("%d%d",&y[i][j],&x[i][j]);
				point[i][j]=Pt(x[i][j],y[i][j]);
			}
		}
		for(int i=0;i<300;i++){
			for(int j=0;j<300;j++){
				if(i==j)dist[i][j]=0;
				else dist[i][j]=999999999;
			}
		}
		dist[b][b+1]=a;
		for(int i=0;i<b;i++){
			for(int j=0;j<size[i];j++){
				dist[b][i]=dist[i][b]=min(dist[b][i],point[i][j].y);
				dist[b+1][i]=dist[i][b+1]=min(dist[b+1][i],a-point[i][j].y);
			}
		}
		for(int i=0;i<b;i++){
			for(int j=i+1;j<b;j++){
				for(int k=0;k<size[i];k++)
					for(int l=0;l<size[j];l++)
						dist[i][j]=dist[j][i]=min(dist[i][j],dSS(point[i][k],point[i][(k+1)%size[i]],point[j][l],point[j][(l+1)%size[j]]));
			}
		}
		for(int k=0;k<b+2;k++)
			for(int i=0;i<b+2;i++)
				for(int j=0;j<b+2;j++)
					dist[i][j]=min(dist[i][j],dist[i][k]+dist[k][j]);
		printf("%.8f\n",dist[b][b+1]);
	}
}

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

#define PI acos(-1.0)
#define nl '\n'

typedef long long int ll;
typedef unsigned long long int  llu;

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

    double x,ans;
    cin>>x;
    ans=2*PI*x;
    cout<<fixed<<setprecision(20)<<ans<<nl;
    return 0;
}


Measured memory_bytes: 3800
function Main(input) {
	var list = input.split("\n")[1].split(" ").map((list)=>Number(list));
  var max = 0;
  for(var i = 0; i < list.length; i++){
    max += list[i];
  }
  
  var output = 10001;
  var ruiseki = 0;
  for(var i = 0; i < list.length - 1; i++){
    ruiseki += list[i];
    max -= list[i];
    output = Math.min(output,Math.abs(max - ruiseki));
  }
  console.log(output);
  
}

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


Measured memory_bytes: 7372
#include<stdio.h>
#include<stdlib.h>
int asc(const void* a, const void* b)
{
	return *(int*)a - *(int*)b;
}
int main()
{
	int n;
	scanf("%d", &n);
	int i;
	int d[100005];
	for (i = 0; i < n; i++)
		scanf("%d", &d[i]);
	qsort(d, n, sizeof(int), asc);
	printf("%d\n", d[n / 2] - d[(n - 2) / 2]);
	return 0;
}

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

using namespace std;
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))
#define endl "\n"
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){os << "["; for (const auto &v : vec) {os << v << ","; } os << "]"; return os; }
template <typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &p) {os << "(" << p.first << ", " << p.second << ")"; return os;}


struct UnionFindWeighted { 
    vector<int> p, w;
    UnionFindWeighted(int n): p(n, -1), w(n) {

    }
    bool connect(int i, int j, int weight) {
        int ri = root(i);
        int rj = root(j);
        if (ri == rj) {
            return weight == w[i] - w[j];
        }
        p[ri] = rj;
        w[ri] = weight - w[i] + w[j];
        return true;
    }

    int get(int i, int j) {
        int ri = root(i);
        int rj = root(j);
        if (ri != rj) return -1;
        return w[i] - w[j];
    }

    int root(int x) {
        if (p[x] == -1) {
            return x;
        } else {
            int r = root(p[x]);
            w[x] += w[p[x]];
            return p[x] = r;
        }
    }
};

int main() {
    int N, M;
    cin >> N >> M;
    UnionFindWeighted ufw(N);
    for (int i = 0; i < M; i++) {
        int l, r, d;
        cin >> l >> r >> d;
        l--, r--;
        if (!ufw.connect(l, r, d)) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
 
#define int long long 
#define ll long long 
#define pb push_back
#define mp make_pair
#define pii pair<ll,ll>
#define ff first
#define ss second
#define vi vector<ll>
#define vii vector<vector<ll>>
#define vpi vector<pii>
#define mod 1000000007
#define MOD 1000000007
#define full(a) a.begin(),a.end()
#define inf INT_MAX
#define minf INT_MIN
#define dd double
#define fori(x,n) for(ll i=x;i<n;i++)
#define modd 998244353
#define umap unordered_map<ll,ll>
#define mmap map<ll,ll>
#define mm 100000000
ll n,m;
pii D;
ll h[4]={1,-1,0,0};
ll v[4]={0,0,1,-1};
char a[1001][1001];

ll dijkstra(ll x,ll y){

  ll distance[n+1][m+1];
  fori(1,n+1)
  for(int j=1;j<=m;j++)distance[i][j]=1e9;

  distance[D.ff][D.ss]=0;
  set<pair<ll,pii>>s;
  s.insert({0,D});

  while(!s.empty()){
    auto p = *(s.begin());
    pii node = p.ss;
    ll node_dist = p.ff;
    s.erase(s.begin());

    //checking for edges of cost 0
    fori(0,4){
      ll row = node.ff+h[i],col=node.ss+v[i];
      if(row>=1 and row<=n and col>=1 and col<=m and a[row][col]=='.' and node_dist<distance[row][col]){
        auto it = s.find({distance[row][col],{row,col}});
        if(it!=s.end())s.erase(it);
        distance[row][col]=node_dist;
        s.insert({node_dist,{row,col}});
      }
    }
     
    //checking for edges of cost 1
    for(int row=node.ff-2;row<=node.ff+2;row++)
      for(int col=node.ss-2;col<=node.ss+2;col++){
         if(row>=1 and row<=n and col>=1 and col<=m and a[row][col]=='.' and node_dist+1<distance[row][col]){
        auto it = s.find({distance[row][col],{row,col}});
        if(it!=s.end())s.erase(it);
         distance[row][col]=node_dist+1;
        s.insert({node_dist+1,{row,col}});
      }
    }
  }

  return distance[x][y]==1e9?-1:distance[x][y];
}





int32_t main() 
{ 
  
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
 
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif


    
    ll t;
    t=1;
    // cin>>t;
    while(t--){
      cin>>n>>m;
      cin>>D.ff>>D.ss;
      ll x,y;
      cin>>x>>y;

      fori(1,n+1)
      for(int j=1;j<=m;j++)cin>>a[i][j];

      cout<<dijkstra(x,y);

      
    }





return 0;
}     



Measured memory_bytes: 12656
#include<bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rrep(i, n) for (int (i) = 1; (i) <= (n); (i++))
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define yn {puts("Yes");}else {puts("No");}
#define printd(x) printf("%.12f\n", ans);
template<class T> bool chmin(T& a, const T& b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> bool chmax(T& a, const T& b) {if (a < b) {a = b; return 1;} return 0;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main(void) {
  int n, k;
  cin >> n >> k;
  vector<int> l(n);
  rep (i, n) cin >> l[i];

  sort(rrng(l));

  int ans = 0;
  rep (i, k) ans += l[i];

  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
INF = float("inf")


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

    ans = 0
    state = None
    for i in range(N - 1):
        if a_list[i] == a_list[i + 1]:
            continue

        now = a_list[i] < a_list[i + 1]
        if state is None:
            state = now
            continue
        if state != now:
            ans += 1
            state = None

    print(ans + 1)


if __name__ == '__main__':
    main()


Measured memory_bytes: 14688
from collections import defaultdict
from heapq import heappop, heappush


class Graph(object):
    """
    隣接リストによる有向グラフ
    """

    def __init__(self):
        self.graph = defaultdict(list)

    def __len__(self):
        return len(self.graph)

    def add_edge(self, src, dst, weight=1):
        self.graph[src].append((dst, weight))

    def get_nodes(self):
        return self.graph.keys()


class Dijkstra(object):
    """
    ダイクストラ法（二分ヒープ）による最短経路探索
    計算量: O((E+V)logV)
    """

    def __init__(self, graph, start):
        self.g = graph.graph

        # startノードからの最短距離
        # startノードは0, それ以外は無限大で初期化
        self.dist = defaultdict(lambda: float('inf'))
        self.dist[start] = 0

        # 最短経路での1つ前のノード
        self.prev = defaultdict(lambda: None)

        # startノードをキューに入れる
        self.Q = []
        heappush(self.Q, (self.dist[start], start))

        while self.Q:
            # 優先度（距離）が最小であるキューを取り出す
            dist_u, u = heappop(self.Q)
            if self.dist[u] < dist_u:
                continue
            for v, weight in self.g[u]:
                alt = dist_u + weight
                if self.dist[v] > alt:
                    self.dist[v] = alt
                    self.prev[v] = u
                    heappush(self.Q, (alt, v))

    def shortest_distance(self, goal):
        """
        startノードからgoalノードまでの最短距離
        """
        return self.dist[goal]

    def shortest_path(self, goal):
        """
        startノードからgoalノードまでの最短経路
        """
        path = []
        node = goal
        while node is not None:
            path.append(node)
            node = self.prev[node]
        return path[::-1]


N, M, s, t = map(int, input().split())  # N個の町, M本の電車, 始点s, 終点t
s -= 1
t -= 1
# 最後は終点でしかスヌークにしか変えられなくなる
graph = Graph()
reverse_graph = Graph()
for _ in range(M):
    u, v, a, b = map(int, input().split())  # 始点, 終点, 円, スヌーク
    u -= 1
    v -= 1
    graph.add_edge(u, v, a)
    graph.add_edge(v, u, a)
    reverse_graph.add_edge(u, v, b)
    reverse_graph.add_edge(v, u, b)


shortest_from_start = Dijkstra(graph, s)
shortest_from_goal = Dijkstra(reverse_graph, t)


# 逆から考える, どんどん選択肢が増えるようにする, 最初は一番厳しい制約
price = shortest_from_start.shortest_distance(N-1)+shortest_from_goal.shortest_distance(N-1)
ans = [price]  # 最後にreverseする

# 最初に、どこでも換金できないパターンの値を求めて、それから、換金できる場所を増やしていってそこで換金する場合に値が変わるかどうかを確かめていく
for i in reversed(range(N-1)):  # iが換金する場所
    ans.append(min(ans[-1], shortest_from_start.shortest_distance(i)+shortest_from_goal.shortest_distance(i)))
ans.reverse()

for a in ans:
    print(10**15 - a)


Measured memory_bytes: 143860
# 1 "p.cpp"
# 1 "<built-in>"
# 1 "<command-line>"
# 1 "p.cpp"
# 1 "/home/tysm/dev/cpplib/bin/../include/cpplib/stdinc.hpp" 1
       
# 12 "/home/tysm/dev/cpplib/bin/../include/cpplib/stdinc.hpp"
# 1 "/home/tysm/dev/cpplib/bin/../stdlib/bits/stdc++.h" 1
 #include <bits/stdc++.h>
# 13 "/home/tysm/dev/cpplib/bin/../include/cpplib/stdinc.hpp" 2
# 1 "/home/tysm/dev/cpplib/bin/../stdlib/ext/pb_ds/assoc_container.hpp" 1
 #include <ext/pb_ds/assoc_container.hpp>
# 14 "/home/tysm/dev/cpplib/bin/../include/cpplib/stdinc.hpp" 2
# 1 "/home/tysm/dev/cpplib/bin/../stdlib/ext/pb_ds/tree_policy.hpp" 1
 #include <ext/pb_ds/tree_policy.hpp>
# 15 "/home/tysm/dev/cpplib/bin/../include/cpplib/stdinc.hpp" 2







using namespace std;
using namespace __gnu_pbds;

using ii = pair<long long, long long>;
using vi = vector<long long>;
using vd = vector<long double>;
using vb = vector<bool>;
using vii = vector<ii>;
using vvi = vector<vi>;
using vvd = vector<vd>;
using vvb = vector<vb>;
using vvii = vector<vii>;
# 50 "/home/tysm/dev/cpplib/bin/../include/cpplib/stdinc.hpp"
inline long long mod(const long long n, const long long m = ((long long)1e9+7)){
    return (n%m + m)%m;
}

/**
 * Euclidean GCD.
 *
 * Time Complexity: O(log(min(a, b))).
 * Space Complexity: O(log(min(a, b))).
 */
long long gcd(const long long a, const long long b){
    if(a < 0 or b < 0)
        return gcd(abs(a), abs(b));
    if(a == 0)
        return b;
    return gcd(b%a, a);
}

/**
 * Euclidean derivated LCM.
 *
 * Time Complexity: O(log(min(a, b))).
 * Space Complexity: O(log(min(a, b))).
 */
long long lcm(const long long a, const long long b){
    // same as a*b/gcd(a, b) but avoiding overflow.
    return a/gcd(a, b)*b;
}
# 2 "p.cpp" 2

long long n;
vvi adj;
long long dp[2][(long long)1e5+1];

long long solve(long long u, long long p = -1, long long pc = 0){
    long long &res = dp[pc][u];
    if(res != -1)
        return res;
    long long res_w = 1, res_b = !pc;
    for(long long v:adj[u]){
        if(v == p)
            continue;
        res_w = mod(res_w * solve(v, u, 0));
        res_b = mod(res_b * solve(v, u, 1));
    }
    return res = mod(res_w + res_b);
}


int32_t main(){
    (ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL));
    cin >> n;
    adj.resize(n+1);
    for(long long i=1; i<n; ++i){
        long long a, b;
        cin >> a >> b;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }
    memset(dp, -1, sizeof(dp));
    cout << solve(1) << "\n";
    return 0;
}


Measured memory_bytes: 15616
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL)
#define endl "\n"
#define pb push_back
#define mod 1000000007
int dx[]={1,-1,0,0};
int dy[]={0,0,1,-1};
int dx8[]={1,-1,0,0,1,1,-1,-1};
int dy8[]={0,0,1,-1,1,-1,1,-1};

ll binexp(ll a, ll b, ll m) {
	a %= m;
	ll res = 1;
	while (b > 0) {
		if (b & 1)
			res = res * a % m;
		a = a * a % m;
		b >>= 1;
	}
	return res;
}
ll modinvfermat(ll a, ll m)
{
	return binexp(a, m - 2, m);
}
void task(bool flag)
{
	if (flag)
		cout << "YES\n";
	else
		cout << "NO\n";
}
ll lcm(ll a, ll b)
{
	return ((1LL * a * b) / (__gcd(a, b)));
}





void solve(){
	char a;
	cin>>a;
	if(a>='a' and a<='z'){
		cout<<'a'<<endl;

	}
	else{
		cout<<'A'<<endl;


	}






return;
}




int main()
{  
#ifndef ONLINE_JUDGE
	// for getting input from input.txt
	freopen("input.txt", "r", stdin);
	// for writing output to output.txt
	freopen("output.txt", "w", stdout);
#endif
    fast;
    ll t;
    t=1;
  //  cin>>t;
    while(t--){
    	solve();
    }
    
   
  



#ifndef ONLINE_JUDGE
	cout << "\nTime Elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " sec\n";
#endif
return 0;
}

Measured memory_bytes: 3604
from collections import deque

N,u,v=map(int,input().split())
G=[[] for _ in range(N)]
for _ in range(N-1):
  a,b = map(int,input().split())
  G[a-1].append(b-1)
  G[b-1].append(a-1)

def bfs(s):
    seen = [0]*N
    d = [0]*N
    todo = deque()
    seen[s]=1
    todo.append(s)
    while len(todo):
      a = todo.popleft()
      for b in G[a]:
        if seen[b] == 0:
          seen[b] = 1
          todo.append(b)
          d[b] += d[a] + 1
    return d
  
d1 = bfs(u-1)
d2 = bfs(v-1)

print(max([d2[i] for i in range(N) if d1[i]<=d2[i]])-1)

Measured memory_bytes: 34324
X = int(input())

import random

def is_prime3(q,k=50):
    q = abs(q)
    #計算するまでもなく判定できるものははじく
    if q == 2: return True
    if q < 2 or q&1 == 0: return False

    #n-1=2^s*dとし（但しaは整数、dは奇数)、dを求める
    d = (q-1)>>1
    while d&1 == 0:
        d >>= 1
    
    #判定をk回繰り返す
    for i in range(k):
        a = random.randint(1,q-1)
        t = d
        y = pow(a,t,q)
        #[0,s-1]の範囲すべてをチェック
        while t != q-1 and y != 1 and y != q-1: 
            y = pow(y,2,q)
            t <<= 1
        if y != q-1 and t&1 == 0:
            return False
    return True

for i in range(X, X + 100):
    if is_prime3(i) == True:
        print(i)
        exit()

Measured memory_bytes: 4336
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using P = pair<int, int>;
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};


int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    int ans = mod;
    rep(i, n) {
        int v = a[i];
        int num = 0;
        while (v%2==0) {
            v /= 2;
            num++;
        }
        chmin(ans, num);
    }
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3604
def prime_checker(n, option = False) -> list:
    p = [False, True, False, False, False, True] * (n // 6 + 1)
    del p[n + 1:]
    p[1 : 4] = False, True, True
    for x in range(5, int(n**.5 + 1)):
        if p[x]:
            p[x * x :: 2*x] = [False] * ((n // x - x) // 2 + 1)
    return [e for e, q in enumerate(p) if q] if option else p

from itertools import accumulate
*p, = accumulate([0] + prime_checker(105010, True))
for i in [*map(int, open(0))][:-1]:
    print(p[i])


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

int main() {
  ll n, k;
  cin >> n >> k;
  if (k - (n % k) < n % k) {
    cout << (k - (n % k)) << endl;
  }
  else {
    cout << n % k << endl;
  }
  return 0;
}

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

def make_divisor_list(num):
    if num < 1:
        return []
    elif num == 1:
        return [1]
    else:
        divisor_list = []
        divisor_list.append(1)
        for i in range(2, num // 2 + 1):
            if num % i == 0:
                divisor_list.append(i)
        divisor_list.append(num)

        return divisor_list

list_A = make_divisor_list(A)
list_B = make_divisor_list(B)

list_and = set(list_A) & set(list_B)

list_and_sort = sorted(list_and, reverse=True)

print(list_and_sort[K-1])

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

#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define REP(i, n)  FOR(i, 0, n)
#define ASC(c) sort((c).begin(), (c).end())
#define DESC(c) sort((c).begin(), (c).end(), greater<int>())

#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define DEBUG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

typedef long long ll;
typedef unsigned long long ull;
struct edge { int u, v; ll w; };
 
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int main() {
    int A, B, m; cin >> A >> B >> m;
    vector<int> a(A), b(B);
    REP(i, A) cin >> a[i];
    REP(i, B) cin >> b[i];

    int ans = *std::min_element(a.begin(), a.end()) + *std::min_element(b.begin(), b.end());;

    REP(_, m) {
        int x, y, c; cin >> x >> y >> c;
        ans = min(ans, a[x - 1] + b[y - 1] - c);
    }
    cout << ans << endl;
}


Measured memory_bytes: 1024
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define D()
#define INF 1000000000000
#define MOD 10000007
#define MAXR 100000
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define INITA(a,i,j,v) for(ll k=i;k<=j;k++){a[k]=v;}

int main() {
    int h, w; cin >> h >> w;
    char a[101][101];
    REP(i, h) {
        REP(j, w) {
            cin >> a[i][j];
        }
    }
    set<char> white_row_idx;
    set<char> white_col_idx;
    REP(i, h) {
        bool is_white_row = true;
        REP(j, w) {
            if (a[i][j] != '.') {
                is_white_row = false;
            }
        }
        if (is_white_row) {
            white_row_idx.insert(i);
        }
    }
    REP(j, w) {
        bool is_white_col = true;
        REP(i, h) {
            if (a[i][j] != '.') {
                is_white_col = false;
            }
        }
        if (is_white_col) {
            white_col_idx.insert(j);
        }
    }
    REP(i, h) {
        if (white_row_idx.find(i) == white_row_idx.end()) {
            REP(j, w) {
                if (white_col_idx.find(j) == white_col_idx.end()) {
                    cout << a[i][j];
                }
            }
            cout << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
use std::cmp::*;

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

fn main() {
    let N: i64 = read();
    let mut m = 1i64 << 60;
    for _ in 0..5 {
        let tmp: i64 = read();
        m = min(m, tmp);
    }
    println!("{}", N/m+5-(N%m==0) as i64);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    int a;
    cin >> a;
    cout << 3 * a * a << '\n';
}


Measured memory_bytes: 256
/*
 * N
 * A1 B1
 * ...
 * An Bn
*/

#include <iostream>
#include <vector>
#include <utility>
#include <cmath>
#include <algorithm>
#include <cassert>

using namespace std;
using AB = pair<long long, long long>;

int main() {
  long long N;
  cin >> N;

  vector<AB> v(N);

  for (int i = 0; i < N; i++) {
    long long a, b;
    cin >> a >> b;
    v[i] = make_pair(a, b);
  }

  sort(v.begin(), v.end(), [](const AB& lhs, const AB& rhs) {
    return lhs.second < rhs.second;
  });

  long long current_time = 0; // 現在時刻

  for (int i = 0; i < N; i++) {
    if ((current_time + v[i].first) > v[i].second) {
      cout << "No" << endl;
      return 0;
    }

    current_time += v[i].first;
  }

  cout << "Yes" << endl;
}


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

#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define INF  (1<<30)
#define INFL (1LL<<60)
#define MOD 1000000007
#define EPS ((ld)(1e-9))

#define sz(x) ((int)(x).size())
#define setz(x) memset(x, 0, sizeof(x))
#define all(x) (x).begin(), (x).end()
#define rep(i, x)  for (int i = 0, _##i = (x); i < _##i; i++)
#define repp(i, s, e) for (int i = (s), _##i = (e); i < _##i; i++)
#define repr(i, s, e) for (int i = (s)-1, _##i = (e); i >= _##i; i--)
#define repi(i, x) for (auto &i : (x))


using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ld, ld> pdd;
typedef pair<ll, ll> pll;

template<typename T, typename V>
ostream &operator<<(ostream &os, const pair<T, V> pai) { 
    return os << '(' << pai.first << ' ' << pai.second << ')';
}

template<typename T>
ostream &operator<<(ostream &os, const vector<T> v) {
    cout << '[';
    rep(i, sz(v)) cout << v[i] << ",";
    cout << "]";
    return os;
}

template<typename T>
ostream &operator<<(ostream &os, const set<T> v) {
    cout << "{";
    for (auto p : v) cout << p << ",";
    cout << "}";
    return os;
}

template<typename T, typename V>
ostream &operator<<(ostream &os, const map<T, V> v) {
    cout << "{";
    for (auto p : v) cout << p << ",";
    cout << "}";
    return os;
}

#ifndef __SOULTCH
#define debug(...) 0
#define endl '\n'
#else
#define debug(...) cout << " [-] ", _dbg(#__VA_ARGS__, __VA_ARGS__)
template<class TH> void _dbg(const char *sdbg, TH h){ cout << sdbg << '=' << h << endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
    while(*sdbg != ',') cout << *sdbg++;
    cout << '=' << (h) << ','; 
    _dbg(sdbg+1, a...);
}
#endif

template<typename T> void get_max(T &a, T b) {a = max(a, b);}
template<typename T> void get_min(T &a, T b) {a = min(a, b);}

int N;
pii A[50];
set<pii> s;

int main(void) {
    iostream::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);

    cin >> N;
    rep(i, N) cin >> A[i].fi >> A[i].se, s.insert(A[i]);
    
    int res = N;
    rep(i, N) rep(j, N) if (i != j) {
        int p = A[i].fi-A[j].fi, q = A[i].se-A[j].se;
        int cost = N;
        rep(i, N) cost -= s.count(mp(A[i].fi-p, A[i].se-q));
        get_min(res, cost);
    }
    cout << res << endl;
}


Measured memory_bytes: 256