akhauriyash/Code-Regression huggingface dataset:
n, k = map(int, input().split())
a = list(map(int, input().split()))
a.sort()

# prepare combs upto 10000
mod = 10**9 + 7
facts = [1] * 100001
for i in range(0, 100000):
	facts[i+1] = facts[i] * (i + 1) % mod

ifacts = [1] * 100001
ifacts[100000] = pow(facts[100000], mod - 2, mod)
for i in range(100000, 0, -1):
	ifacts[i-1] = ifacts[i] * i % mod

def comb(n, k):
	return facts[n] * ifacts[n-k] % mod * ifacts[k] % mod

ans = 0

for i in range(k-1, n):
	# take k-1 from i
	ans = (ans + a[i] * comb(i, k-1)) % mod

for i in range(0, n-k+1):
	# take k-1 from n-i-1
	ans = (ans - a[i] * comb(n-i-1, k-1)) % mod

print(ans)

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)

#define DEBUG(x) cout<<#x<<": "<<(x)<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

template<typename T> inline void CHMAX(T& a, const T b) {if(a<b) a=b;}
template<typename T> inline void CHMIN(T& a, const T b) {if(a>b) a=b;}

constexpr ll MOD=1000000007ll;
// constexpr ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-9;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  // cout<<setprecision(10)<<fixed;
  string s;
  cin>>s;
  cout<<(s[2]==s[3] && s[4]==s[5] ? "Yes" : "No")<<'\n';
  return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cassert>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
using namespace std;
#define MOD 1000000007
#define MOD2 998244353
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;

Int fact[1100000];
Int revfact[1100000];
Int rev[1100000];

void init(){
    Int m = MOD;
    fact[0] = 1;
    revfact[0] = 1;
    rev[0] = 0;
    rev[1] = 1;
    for(Int i = 1;i < 1100000;i++){
        fact[i] = fact[i-1] * i % m;
        if(i>1)rev[i] = MOD / i * (MOD-rev[MOD % i]) % MOD;
        revfact[i] = revfact[i-1] * rev[i] % MOD;
    }
}

Int nCk(Int n, Int k){
    if(n < k)return 0;
    return fact[n] * revfact[n-k] % MOD * revfact[k] % MOD;
}



Int dp1[220000];
Int dp2[220000];
Int size1[220000];
Int size2[220000];

Int n, a, b;
vector<Int> edge[220000];

Int mod_pow(Int x, Int a, Int m = MOD){
    if(a == 0)return 1;
    Int res = mod_pow(x, a / 2, m);
    res = res * res % m;
    if(a % 2)res *= x;
    return res % m;
}

Int inv(Int x, Int m = MOD){
    return mod_pow(x, m-2, m);
}


void dfs1(Int x, Int last = -1){
    size1[x] = 1;
    dp1[x] = 1;
    for(auto to: edge[x]){
        if(to == last)continue;
        dfs1(to, x);
        size1[x] += size1[to];
        dp1[x] *= dp1[to];dp1[x] %= MOD;
        dp1[x] *= revfact[size1[to]];dp1[x] %= MOD;
    }
    size2[x] = n - size1[x];
    dp1[x] *= fact[size1[x]-1];dp1[x] %= MOD;
}

void dfs2(Int x, Int last = -1){
    if(last == -1)dp2[x] = 1;
    Int all_product = dp2[x] * revfact[size2[x]] % MOD;
    for(auto to:edge[x]){
        if(to == last)continue;
        all_product*= dp1[to];all_product %= MOD;
        all_product *= revfact[size1[to]];all_product %= MOD;
    }
    for(auto to:edge[x]){
        if(to == last)continue;
        Int tmp = all_product;
        tmp *= inv(dp1[to]);tmp %= MOD;
        tmp *= inv(revfact[size1[to]]);tmp %= MOD;
        tmp *= fact[size2[to]-1];tmp %= MOD;
        dp2[to] = tmp;
        dfs2(to, x);
    }
}
Int ans[220000];

void dfs3(Int x, Int last=-1){
    if(last == -1)dp2[x] = 1;
    Int all_product = dp2[x] * revfact[size2[x]] % MOD;
    for(auto to:edge[x]){
        if(to == last)continue;
        dfs3(to, x);
        all_product*= dp1[to];all_product %= MOD;
        all_product *= revfact[size1[to]];all_product %= MOD;
    }
    all_product *= fact[n-1];all_product %= MOD;
    ans[x] = all_product;
    
}

int main(){
    init();
    cin >> n;
    for(Int i = 0;i < n-1;i++){
        cin >> a >> b;a--,b--;
        edge[a].push_back(b);
        edge[b].push_back(a);
    }

    dfs1(1);
    dfs2(1);
    dfs3(1);

    for(Int i = 0;i < n;i++){
        cout << ans[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 49392
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n, m, k; cin >> n >> m >> k;
  for(int i = 0; i <= n; i++){
     for(int j = 0; j <= m; j++){
  	   if(i*j+(n-i)*(m-j)==k){
    	cout << "Yes" << endl;
    	return 0;
    }
   }
  }
  cout << "No" << endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>


using namespace std;

#define Dmax 10
#define Pmax 100
int dp[Dmax+1][Dmax * Pmax  +1];

int main() {
	int D, G;
	cin >> D >> G;
	vector<pair<int, int> > points;
	points.reserve(D);
	for (int _ = 0; _ < D;++_) {
		int p, c;
		cin >> p >> c;
		points.emplace_back(p, c);
	}

	for (int i = 1; i <= D; ++i) {
		for (int p = 0; p <= i * Pmax; ++p) {
			dp[i][p] = dp[i - 1][p];
			for (int l = 1; l <= min(points[i - 1].first, p); ++l) {
				dp[i][p] = max(dp[i ][p],
					dp[i - 1][p -l] + 100 * i * l + (points[i - 1].first == l ? points[i - 1].second : 0)
				);
			}
		}
	}

	for (int p = 0; p <= Dmax * Pmax; ++p) {
		if (dp[D][p] >= G) {
			cout << p << endl;
			break;
		}
	}

	return 0;
}

Measured memory_bytes: 256
#![allow(non_snake_case)]
#![allow(unused_imports)]
use proconio::input;
use std::cmp::max;
use std::cmp::min;
use std::collections::HashMap;
use std::collections::VecDeque;

fn main() {
    input! {
      sx: i64,
      sy: i64,
      tmp_tx: i64,
      tmp_ty: i64,
    }

    // 簡単のため、(sx, sy)を(0, 0)に平行移動する
    let tx = tmp_tx - sx;
    let ty = tmp_ty - sy;

    // まず、(0,0) -> (tx, 0) -> (tx, ty) -> (0, ty) -> (0,0)
    // 次に、(0,0) -> (0, -1) -> (tx + 1, -1) -> (tx + 1, ty) -> (tx, ty)
    // そして、(tx, ty) -> (tx, ty + 1) -> (-1, ty + 1) -> (-1, 0) -> (0, 0)

    let mut ans: Vec<char> = Vec::new();
    for _ in 0..tx {
        ans.push('R');
    }
    for _ in 0..ty {
        ans.push('U');
    }
    for _ in 0..tx {
        ans.push('L');
    }
    for _ in 0..ty {
        ans.push('D');
    }

    ans.push('D');

    for _ in 0..tx + 1 {
        ans.push('R');
    }
    for _ in 0..ty + 1 {
        ans.push('U');
    }
    ans.push('L');

    ans.push('U');
    for _ in 0..tx + 1 {
        ans.push('L');
    }
    for _ in 0..ty + 1 {
        ans.push('D');
    }
    ans.push('R');

    for c in ans.iter() {
        print!("{}", c);
    }
    println!("");
}


Measured memory_bytes: 2160
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
    
    Scanner sc = new Scanner(System.in);
     
      //入力
      int stone = sc.nextInt();
      int coordinate = sc.nextInt();
      
      //黒石の可能性がある小さい数字から大きい数字まで
    for(int i = (coordinate-stone)+1; i<=(coordinate+stone)-1; i++){
        System.out.print(i+" ");
     
     }
    }
}

Measured memory_bytes: 24020
#include<iostream>
#include<cmath>
#include<iomanip>
#include<algorithm>
using namespace std;
#include<vector>
struct UF{
	int n;
	vector<int>parent,rank;
	UF(int n_=0):n(n_),parent(n_),rank(n_,0)
	{
		for(int i=0;i<n_;i++)parent[i]=i;
	}
	int find(int a)
	{
		return parent[a]!=a?parent[a]=find(parent[a]):a;
	}
	bool same(int a,int b)
	{
		return find(a)==find(b);
	}
	bool unite(int a,int b)
	{
		a=find(a),b=find(b);
		if(a==b)return false;
		if(rank[a]<rank[b])
		{
			parent[a]=b;
		}
		else
		{
			parent[b]=a;
			if(rank[a]==rank[b])rank[a]++;
		}
		return true;
	}
};
main()
{
	int n;
	while(cin>>n,n)
	{
		double x[100],y[100],z[100],r[100];
		for(int i=0;i<n;i++)cin>>x[i]>>y[i]>>z[i]>>r[i];
		UF uf(n);
		vector<pair<double,pair<int,int> > >e;
		for(int i=0;i<n;i++)for(int j=i+1;j<n;j++)
		{
			e.push_back(make_pair(
				max(0.0,hypot(hypot(x[i]-x[j],y[i]-y[j]),z[i]-z[j])-r[i]-r[j]),
				make_pair(i,j)
			));
		}
		sort(e.begin(),e.end());
		double ans=0;
		for(int i=0;i<e.size();i++)
		{
			if(uf.unite(e[i].second.first,e[i].second.second))
			{
				ans+=e[i].first;
			}
		}
		cout<<fixed<<setprecision(3)<<ans<<endl;
	}
}


Measured memory_bytes: 3384
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ok() puts(ok?"Yes":"No");
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef set<int> si;
typedef map<string, int> msi;
typedef greater<int> gt;
typedef priority_queue<int, vector<int>, gt> minq;
typedef long long ll;
const ll LINF = 1e18L + 1;
const int INF = 1e9 + 1;
//clang++ -std=c++11 -stdlib=libc++ 

int main() {
  int x,a,b; cin>>x>>a>>b;
  x-=a;
  while(1) {
    if (x-b>=0) x-=b;
    else break;
  }
  cout << x<<endl;
  return 0;
}

Measured memory_bytes: 256
/*
貪欲
後ろから見る
DP
順位表をチェック



*/
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
#include <cmath>
#include <limits>
#include <iostream>
#include<set>
#include<tuple>
using namespace std;
#define INF 3e18+7
#define MAX 100000
#define MOD 1000000007
typedef long long ll;
typedef pair<int,int> P;
typedef pair<pair<int,ll>,ll> p;
#define bit(n,k) ((n>>k)&1) /*nのk bit目*/
#define rad_to_deg(rad) (((rad)/2/M_PI)*360)
struct edge{ll to,cost,val;};
template<class T,class U>bool chmin(T&a,const U&b){if(a<=b)return false;a=b;return true;}
template<class T,class U>bool chmax(T&a,const U&b){if(a>=b)return false;a=b;return true;}
//__builtin_popcount(S);


int main(){
    string s;
    cin>>s;
    if(s=="SAT") cout<<1<<endl;
    else if(s=="SUN") cout<<7<<endl;
    else if(s=="MON") cout<<6<<endl;
    else if(s=="TUE") cout<<5<<endl;
    else if(s=="WED") cout<<4<<endl;
    else if(s=="THU") cout<<3<<endl;
    else if(s=="FRI") cout<<2<<endl;
    
}


Measured memory_bytes: 768
#include<iostream>
using namespace std;
int main(){
    int a,b,count=0;
    
    cin>>a;
    int bubble[a];
    for(int i=0;i<a;i++){
        cin>>b;
        bubble[i]=b;
    }
    
   
    for(int i=0;i<a;i++){
        int flag = 1 ;// 逆の隣接要素が存在する
        while (flag){
            flag = 0;
            for (int j= a-1;j>0;j--) {
                if (bubble[j] < bubble[j-1]){
                    int c=bubble[j];
                    int d=bubble[j-1];
                    bubble[j]= d;
                    bubble[j-1]=c;
                    flag = 1;
                    count++;
                }
                
            }
            
        }
        

    }
    for(int p=0;p<a;p++){
        if(p<a-1){
            cout<<bubble[p]<<" ";
        }
        else if(p==a-1){
            cout<<bubble[p]<<endl;
        }
    }
    cout<<count<<endl;
    return 0;
}



Measured memory_bytes: 3104
N = int(input())
s = input()
ans = 0
for i in range(N):
    l = set()
    r = set()
    tmp = 0
    x = s[0:i]
    y = s[i:]
    for j in x:
        l.add(j)
    for j in y:
        r.add(j)
    for j in l:
        if j in r:
            tmp += 1
    ans = max(ans,tmp)
print(ans)

Measured memory_bytes: 3064
from math import gcd

from math import factorial as f

from math import ceil, floor, sqrt
import math

import bisect
import re
import heapq

from copy import deepcopy
import itertools
from itertools import permutations

from sys import exit

ii = lambda: int(input())
mi = lambda: map(int, input().split())
li = lambda: list(map(int, input().split()))

yes = "Yes"
no = "No"


def main():
    s = input()
    s = 'S' + s + 'S'
    cnt = 0
    tmp = 0
    for i in s:
        if i == 'S':
            cnt = max(cnt, tmp)
            tmp = 0
        else:
            tmp += 1
    print(cnt)


main()


Measured memory_bytes: 9748
s = input().split("T")
x,y = map(int,input().split())

dx = []
dy = []
hv = 0
for i in s:
    if hv % 2 == 0:
        dx.append(len(i))
    else:
        dy.append(len(i))
    hv += 1
    
nx = dx.pop(0)
ny = 0

for a in sorted(dx,reverse=True):
    if nx > x:
        nx -= a
    else:
        nx += a

for a in sorted(dy,reverse=True):
    if ny > y:
        ny -= a
    else:
        ny += a

if nx == x and ny == y:
    print("Yes")
else:
    print("No")

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

using namespace std;

const int N = 2e5;
const int V = 1e6;
const int MOD = 998244353;

template <int _MOD> struct Mint
{
    int v = 0;
    Mint() {}
    Mint(int _v) : v((_v%_MOD+_MOD)%_MOD) {}
    Mint(long long _v) : v(static_cast<int>((_v%_MOD+_MOD)%_MOD)) {}
    Mint operator = (const int _v) { this->v = _v; return *this; }
    Mint operator = (const long long _v) { this->v = static_cast<int>(_v%_MOD); return *this; }
    bool operator < (const Mint &b) const { return v < b.v; }
    bool operator > (const Mint &b) const { return v > b.v; }
    bool operator == (const Mint &b) const { return v == b.v; }
    bool operator != (const Mint &b) const { return v != b.v; }
    bool operator <= (const Mint &b) const { return v < b.v || v == b.v; }
    bool operator >= (const Mint &b) const { return v > b.v || v == b.v; }
    Mint operator + (const Mint &b) { return Mint(v+b.v); }
    Mint operator - (const Mint &b) { return Mint(v-b.v); }
    Mint operator * (const Mint &b) { return Mint(1ll*v*b.v); }
    Mint operator / (const Mint &b) { return Mint(b.inv()*v); }
    Mint operator += (const Mint &b) { return *this = *this+b; }
    Mint operator -= (const Mint &b) { return *this = *this-b; }
    Mint operator *= (const Mint &b) { return *this = *this*b; }
    Mint operator /= (const Mint &b) { return *this = *this/b; }
    Mint pow(int p) const {
        Mint res(1), x(*this);
        while (p) {
            if (p&1) res = res*x;
            x *= x;
            p >>= 1;
        }
        return res;
    }
    Mint inv() const { return pow(_MOD-2); }
    friend istream& operator >> (istream &is, Mint &mt) { return is >> mt.v; }
    friend ostream& operator << (ostream &os, const Mint &mt) { return os << mt.v; }
};
using mint = Mint<MOD>;

int n;
mint res;
mint w[V+7], s[V+7];

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

    for (int i = 1; i <= V; ++i) {
        w[i] += mint(i).inv();
        for (int j = i+i; j <= V; j += i)
            w[j] -= w[i];
    }

    cin >> n;
    for (int i = 1, a; i <= n; ++i) {
        cin >> a;
        s[a] += a;
        res -= a;
    }
    for (int i = 1; i <= V; ++i) {
        mint x;
        for (int j = i; j <= V; j += i)
            x += s[j];
        res += x*x*w[i];
    }
    res /= 2;
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 8064
mod = 998244353

# N,S,A <= 3000

N,S = map(int,input().split())
A = list(map(int,input().split()))

DP = [0]*S
DP[0] = 1
ans = 0

for i in range(N):
    #print(DP)
    #print(ans)
    a = A[i]
    for j in range(S):
        k = S-1-j
        if k+a <S:
            if k==0:
                DP[k+a] += i+1
            else:
                DP[k+a] += DP[k]
        elif k+a ==S:
            if k==0:
                ans += (i+1)*(N-i)
                ans %= mod
            else:
                ans += DP[k]*(N-i)
                ans %= mod

#print(DP)
print(ans)

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

int main() {
    double W, H; cin >> W >> H;
    double x, y; cin >> x >> y;
    double ans = W * H / 2;
    cout << ans << endl;
    if(x == W / 2 && y == H / 2){
        cout << "1" << endl;
    } else {
        cout << "0" << endl;
    }

    return 0;
}

Measured memory_bytes: 3780
use std::cmp::Ordering;
use std::collections::BinaryHeap;

#[allow(dead_code)]
use std::collections::HashSet;

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

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

struct NandD {
    node: usize,
    distance: i32,
}

impl Ord for NandD {
    fn cmp(&self, other: &Self) -> Ordering {
        self.distance.cmp(&other.distance)
    }
}

impl PartialOrd for NandD {
    fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
        Some(self.cmp(other))
    }
}

impl PartialEq for NandD {
    fn eq(&self, other: &Self) -> bool {
        self.node == other.node && self.distance == other.distance
    }
}

impl Eq for NandD { }

fn main() {
    let nm = read_vec::<usize>();
    let n = nm[0];
    let m = nm[1];
    let a = read_vec::<usize>();


    let answer = solve(n, m, &a);
    println!("{}", answer);
}

fn solve(n: usize, m: usize, a: &[usize]) -> usize {
    let mut heap : BinaryHeap<usize> = BinaryHeap::with_capacity(n);
    for x in a {
        heap.push(*x);
    }

    for i in 0..m {
        let highest = heap.pop().unwrap();
        let discount = highest / 2;
        heap.push(discount);
    }

    let mut sum : usize = 0;
    for x in heap {
        sum += x;
    }
    
    return sum;
}


Measured memory_bytes: 8444
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <array>
#include <bitset> 
#include <unordered_map>

using namespace std;
typedef long long LL;
typedef pair<int,int> P;

int main() {
	int N;
	cin >> N;
	if(N%2==0){
		cout << (N-1)/2 << endl;
	}
	else{
		cout << N/2 << endl;
	}

	return 0;
}



Measured memory_bytes: 888
/*suri_kumkaran*/

#include <bits/stdc++.h>

using namespace std;

#define UB upper_bound
#define LB lower_bound
#define BS binary_search
#define MP make_pair
#define EB emplace_back
#define endl "\n"
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define F first
#define S second
#define ALL(a) (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define int long long

typedef long long int64;
typedef vector<int> VI64;
typedef vector<pair<int,int>> VII64;
typedef vector<string> VS;
typedef vector<vector<int>> VVI;


bool ch(map<int,vector<int>> &mp,map<int,int> &tot)
{
	for(auto x:mp)
	{
		bool b=true;
		for(auto y:x.S)
		{
			if(!tot[y])
			{
				b=false;
				break;
			}
		}
		if(b)
			return b;
	}
	return false;
}

int32_t main()
{
	IOS;
	int T=1;
	//cin>>T;
	while(T--)
	{
		int a[3][3],i,j,tem;
		map<int,vector<int>> mp1,mp2,mp3,mp4;
		for(i=0;i<3;i++)
		{
			for(j=0;j<3;j++)
			{
				cin>>a[i][j];
				mp3[j].EB(a[i][j]);
				mp4[i].EB(a[i][j]);
			}
		}
		mp1[0].EB(a[0][0]);
		mp1[0].EB(a[1][1]);
		mp1[0].EB(a[2][2]);
		mp1[1].EB(a[0][2]);
		mp1[1].EB(a[1][1]);
		mp1[1].EB(a[2][0]);
		int n;
		cin>>n;
		map<int,int> mp;
		for(i=0;i<n;i++)
		{
			cin>>tem;
			mp[tem]++;
		}
		bool ans=ch(mp1,mp)||ch(mp2,mp)||ch(mp3,mp)||ch(mp4,mp);
		if(ans)
			cout<<"Yes";
		else
			cout<<"No";
		
	}

	return 0;
}

Measured memory_bytes: 256
import math
import sys
import queue
from collections import Counter
from itertools import accumulate
from fractions import gcd
from functools import reduce


def lcm(a, b):
    return a * b // gcd(a, b)

def combination_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def permutations_count(n, r):
    return math.factorial(n) // math.factorial(n - r)

sys.setrecursionlimit(10000)

mod = 1000000007

"""
# 0埋め, 小数点出力桁指定時のときの出力
a = 100
b = 0.987654321
print("{0:06d}-{1:6f}".format(a,b))
000100-0.987654

# 文字列をリストに格納
char_list = list("abcd") # ["a","b","c","d"]

# 標準入力取得
## 文字列
    = sys.stdin.readline().rstrip()
    = list(sys.stdin.readline().rstrip())

## 数値
    = int(sys.stdin.readline())
    = map(int, sys.stdin.readline().split())
    = list(map(int, sys.stdin.readline().split()))
    = [list(map(int,list(sys.stdin.readline().split()))) for i in range(N)]
"""

if __name__ == "__main__":
    N = int(sys.stdin.readline())
    S = sys.stdin.readline().rstrip()
    if N >= 3200:
        print(S)
    else:
        print("red")

Measured memory_bytes: 5712
#include <bits/stdc++.h>
using namespace std;
int main () {
  int N,K,count=0;
  cin>>N>>K;
  vector<int>h(N);
for(int i=0;i<N;i++){
  cin>>h[i];
  if(K<=h[i]){
    count++;
  }
}
cout<<count<<endl;
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <typeinfo>

std::vector<std::string> split(const std::string& input, char delimiter)
{
    std::istringstream stream(input);

    std::string field;
    std::vector<std::string> result;
    while (std::getline(stream, field, delimiter)) {
        result.push_back(field);
    }
    return result;
}

void solve() {
    std::vector<int> stack;
    std::vector<std::string> input;
    int sum = 0;

    std::string tmp;
    std::getline(std::cin, tmp);
    //std::cout << tmp << std::endl;
    input = split(tmp, ' ');

    /*
    for (std::string str : input) {
        std::cout << str << std::endl;
    }
    */



    for (std::string str: input) {
        switch (str[0]) {
            int tmp_left;
            int tmp_right;
            case '+':
                tmp_right = stack.back();
                stack.pop_back();
                tmp_left = stack.back();
                stack.pop_back();
                stack.push_back(tmp_left + tmp_right);
                break;
            case '-':
                tmp_right = stack.back();
                stack.pop_back();
                tmp_left = stack.back();
                stack.pop_back();
                stack.push_back(tmp_left - tmp_right);
                break;
            case '*':
                tmp_right = stack.back();
                stack.pop_back();
                tmp_left = stack.back();
                stack.pop_back();
                stack.push_back(tmp_left * tmp_right);
                break;
            /*
            case '/';
                break;
            */
            default:
                stack.push_back(std::stoi(str));
                break;
        }
        //stack.push_back(tmp);
    }
    std::cout << stack.back() << std::endl;
}

int main(int argc, char const *argv[])
{
    solve();
    return 0;
}


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

#define pb push_back
#define vi vector < int >
#define ii pair < int, int >
#define vii vector < pair < int, int > >
#define vvi vector < vector < int > >
#define ll long long
#define X first
#define Y second
#define mp make_pair
#define FOR( i, lo, hi ) for( int i = (lo);i < (hi);i++ )
#define DFOR( i, hi, lo ) for( int i = (hi);i >= (lo);i-- )
#define pqueue priority_queue

using namespace std;

const long long int MOD = 1e9 + 7;

ll REM( ll a )
{
	a %= MOD;
	if ( a < 0 )
	   a += MOD;
	return a;
}

ll ADD( ll a, ll b )
{
	return REM( REM( a ) + REM( b ) );
}

ll SUB( ll a, ll b )
{
	return REM( REM( a ) - REM( b ) );
}

ll MUL( ll a, ll b )
{
	return REM( REM( a ) * REM( b ) );
}

ll POT( ll n, ll k )
{
	if ( k == 0 )
		return 1;

	ll ret = POT( n, k / 2 );
	ret = MUL( ret, ret );

	if ( k % 2 )
		return MUL( ret, n );
	return ret;
}

ll DIV( ll a, ll b )
{
	return MUL( a, POT( b, MOD - 2 ) );
}

bool isPrime( ll x )
{
	for ( ll i = 2;i <= sqrt( x ); i++ )
		if ( x % i == 0 )
			return false;
	return true;
}

const int MAXN = 2e5 + 10;

int n;
ll A[ MAXN ];

int main()
{
	cin >> n;
	ll sum = 0;
	FOR( i, 0, n )
	{
		cin >> A[ i ];
		sum += A[ i ];
	}
	
	ll pre = 0;
	ll ans = sum;
	FOR( i, 0, n )
	{
		pre += A[ i ];
		sum -= A[ i ];
		ll x = pre - sum;
		if ( x < 0 )
			x = sum - pre;
		ans = min( ans, x );
	}
	cout << ans << "\n";
	return 0;
}


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


class Program
{
    public void Proc()
    {
        Reader.IsDebug = false;
        long[] inpt = Reader.ReadLine().Split(' ').Select(a => long.Parse(a)).ToArray();
        this.H = inpt[0];
        this.W = inpt[1];

        int queryCount = (int)inpt[2];

        Dictionary<long, Dictionary<long, int>> map = new Dictionary<long, Dictionary<long, int>>();

        for (int i = 0; i < queryCount; i++)
        {
            Pos p = new Pos(Reader.ReadLine());

            list.Add(p);

            for (long j = p.H - 2; j <= p.H; j++)
            {
                if (j < 0)
                {
                    continue;
                }
                if (j + 2 >= this.H)
                {
                    break;
                }
                if (!map.ContainsKey(j))
                {
                    map.Add(j, new Dictionary<long, int>());
                }
                for (long k = p.W - 2; k <= p.W; k++)
                {
                    if (k < 0)
                    {
                        continue;
                    }
                    if (k + 2 >= this.W)
                    {
                        break;
                    }
                    if (map[j].ContainsKey(k))
                    {
                        map[j][k]++;
                    }
                    else
                    {
                        map[j].Add(k, 1);
                    }
                }
            }
        }



        long[] ans = new long[10];
        ans[0] = ((this.H - 2) * (this.W - 2)) - map.Sum(a=>a.Value.Count());
        foreach (long key in map.Keys)
        {
            foreach (long k2 in map[key].Keys)
            {
                int num = map[key][k2];
                ans[num]++;
            }
        }
      
        for (int i = 0; i <= 9; i++)
        {
            Console.WriteLine(ans[i]);
        }
    
    }

    public List<Pos> list = new List<Pos>();
    
    public class Pos
    {
        public long H;
        public long W;
        public Pos(string inpt)
        {
            long[] tmp = inpt.Split(' ').Select(a => long.Parse(a)).ToArray();
            this.H = tmp[0] - 1;
            this.W = tmp[1] - 1;
        }
    }
    private long H;
    private long W;


    public class Reader
    {
        public static bool IsDebug = true;
        private static String PlainInput = @"

4 5 8
1 1
1 4
1 5
2 3
3 1
3 2
3 4
4 4

";
        private static System.IO.StringReader Sr = null;
        public static string ReadLine()
        {
            if (IsDebug)
            {
                if (Sr == null)
                {
                    Sr = new System.IO.StringReader(PlainInput.Trim());
                }
                return Sr.ReadLine();
            }
            else
            {
                return Console.ReadLine();
            }
        }
    }
    static void Main()
    {
        Program prg = new Program();
        prg.Proc();
    }
}

Measured memory_bytes: 105384
#include <stdio.h>
int main()
{
	int N,x,y,b,p,sum;
	scanf("%d",&N);
	for(int i=0;i<N;i++){
		scanf("%d %d %d %d",&x,&y,&b,&p);
		sum=x*b+y*p;
		if(b>=5&&p>=2)
			printf("%.0f\n",sum*0.8);
		else{
			if(b>=5&&p<2)
				p=2;
			else if(b<5&&p>=2)
				b=5;
			else{
				b=5;
				p=2;
			}
			if((x*b+y*p)*0.8<sum)
				printf("%.0f\n",(x*b+y*p)*0.8);
			else
				printf("%d\n",sum);
		}
	}
	return 0;
}

Measured memory_bytes: 1064
### ----------------
### ここから
### ----------------

import sys
from io import StringIO
import unittest

def yn(b):
    print("Yes" if b==1 else "No")
    return

def resolve():
    readline=sys.stdin.readline

    #n,m,k=map(int, readline().rstrip().split())
    #arr=list(map(int, readline().rstrip().split()))
    ss=readline().rstrip()
    s=ss[len(ss)-1]
    if s=="3":
        print("bon")
    elif s=="0" or s=="1" or s=="6" or s=="8":
        print("pon")
    else:
        print("hon")
    #yn(1)


    return

if 'doTest' not in globals():
    resolve()
    sys.exit()

### ----------------
### ここまで 
### ----------------

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

bool xp(int a){
  for(int i=2;i*i<=a;i++){
    if(a%i==0) return false;
  }
    return a!=1;
}
  

int main(){
  int n;
  while(cin>>n){
    for(int i=n-1;i>1;i--){
      if(xp(i)){
	cout<<i<<" ";break;
      }
    }
    for(int i=n+1;;i++){
      if(xp(i)){
	cout<<i<<endl;break;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
#define mem(a,x) memset(a,x,sizeof(a))
using namespace std;
typedef long long ll;
typedef pair <int,int> PAIR;
const int maxn = 2e5 + 7;
const double pi = acos(-1);
const int mod = 1e9 + 7;
const double eps = 1e-6;
const int inf = 0x3f3f3f3f;
ll a[maxn];

int main(){	
	int n;
	ll res = 0;
	scanf("%d",&n);
	for(int i = 1;i <= n;++i) scanf("%lld",&a[i]),res ^= a[i];
	for(int i = 1;i <= n;++i) printf("%lld%c",res^a[i],i == n ?'\n' :' ');
	return 0;
}

Measured memory_bytes: 5372
#include <bits/stdc++.h>
#define INF 1e9
using namespace std;

#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a)  (a).begin(),(a).end()
#define endl "\n"

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

void solve() {
    int N,K;
    cin >> N >> K;
    vector<int> v(N);
    REP(i,N) cin >> v[i];
    sort(ALL(v));
    int ans = 0;
    REP(i,K) ans+=v[i];
    cout << ans << endl;
}

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

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

char data[100000];
char type[2]={'S','W'};
int main(){

  int N;
  string s;
  cin>>N;
  cin>>s;

  string ans;
  bool exit=false;
  
  for (int first=0;first<2&&!exit;first++)
    for (int second=0;second<2&&!exit;second++)
      {
	data[0]=type[first];
	data[1]=type[second];
	for (int i=1;i<N-1;i++){
	  if(data[i]=='S'){
	    if(s[i]=='o')data[i+1]=data[i-1];
	    else data[i+1]=(data[i-1]=='S')?'W':'S';
	  } else {
	    if(s[i]=='o')data[i+1]=(data[i-1]=='S')?'W':'S';
	    else data[i+1]=data[i-1];
	  }
	}
	bool flag1 = false, flag2 = false;
	if (data[N-1]=='S'){
	  if(s[N-1]=='o'&&(data[N-2]==data[0]))flag1=true;
	  else if(s[N-1]=='x'&&(data[N-2]!=data[0]))flag1=true;
	} else {
	  if(s[N-1]=='o'&&(data[N-2]!=data[0]))flag1=true;
	  else if(s[N-1]=='x'&&(data[N-2]==data[0]))flag1=true;
	}
	if (data[0]=='S'){
	  if(s[0]=='o'&&(data[N-1]==data[1]))flag2=true;
	  else if(s[0]=='x'&&(data[N-1]!=data[1]))flag2=true;
	} else {
	  if(s[0]=='o'&&(data[N-1]!=data[1]))flag2=true;
	  else if(s[0]=='x'&&(data[N-1]==data[1]))flag2=true;
	}
	if (flag1&&flag2)exit=true;
      }
  
  if (exit) {
    for (int i=0;i<N;i++)
      cout<<data[i];
    cout<<endl;
  } else
    cout<<"-1"<<endl;
  
  return 0;
}


Measured memory_bytes: 640
/* ---------- STL Libraries ---------- */
// IO library
#include <cstdio>
#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>
#include <random>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>

/* ---------- Namespace ---------- */
using namespace std;

/* ---------- Type ---------- */
using ll = long long;
#define int ll
#define P pair<ll, ll>

/* ---------- Constants  */
const ll MOD = 1e9 + 7;
const int INF = 1LL << 55;

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */
struct TopologicalSort{
    int n;
    vector<set<int> > G;
    vector<bool> used;
    vector<int> indeg,p;

    TopologicalSort(){}
    TopologicalSort(int sz):n(sz),G(n),used(n),indeg(n),p(0){}

    void add_edge(int s,int t){
        G[s].insert(t);
    }

    void bfs(int s){
        queue<int> q;
        q.push(s);
        used[s]=1;
        while(!q.empty()){
            int v=q.front();q.pop();
            p.push_back(v);
            for(int u:G[v]){
                indeg[u]--;
                if(indeg[u]==0&&!used[u]){
                    used[u]=1;
                    q.push(u);
                }
            }
        }
    }

    vector<int>  build(){
        fill(used.begin(),used.end(),0);
        fill(indeg.begin(),indeg.end(),0);

        for(int i=0;i<n;i++)
            for(int v:G[i]) indeg[v]++;

        for(int i=0;i<n;i++)
            if(indeg[i]==0&&!used[i]) bfs(i);

        return p;
    }
};

signed main() {
    int N, M;
    cin >> N >> M;

    vector<int> table[N];

    int parent[N];
    fill(parent, parent + N, -2);

    TopologicalSort ts(N);
    for (int i = 0; i < N - 1 + M; i++) {
        int s, t;
        cin >> s >> t;
        s--; t--;
        ts.add_edge(s, t);
        table[s].push_back(t);
    }

    auto p = ts.build();

    for (int node : p) {
        for (int next : table[node]) {
            parent[next] = node;
        }
    }

    for (int i = 0; i < N; i++) {
        if (parent[i] == -2) {
            cout << 0 << endl;
            continue;
        }

        cout << parent[i] + 1 << endl;
    }

    return 0;
}

Measured memory_bytes: 18940
a, b, c, d = map(int, input().split(' '))
# -100 100 	-200 200
# 0 100 	1 100
# -100 -50 	100 100
# -100 -50	-5 -10
r1 = a * c
r1 = max(r1, a * d)
r1 = max(r1, b * c)
r1 = max(r1, b * d)
print(r1)

Measured memory_bytes: 9156
#include <stdio.h>
#include <cstdlib>
#include <iostream>
#include <map>
#include <vector>
#include <cmath>

using namespace std;

typedef struct Plan {
    int t;
    int x;
    int y;
}Plan;

bool judge(Plan p1,Plan p2) {
    int dis = abs(p1.x - p2.x) + abs(p1.y - p2.y);
    int dt = p2.t - p1.t;
    return dis%2 == dt%2 && dis <= dt;
}

int main() {
    int N;
    Plan *plan;
    scanf("%d",&N);
    plan = new Plan[N + 1];
    plan[0].t = 0;
    plan[0].x = 0;
    plan[0].y = 0;
    for(int i = 1;i < N + 1;i++) {
        scanf("%d%d%d", &plan[i].t, &plan[i].x, &plan[i].y);
    }

    bool po = true;
    for(int i = 0;i < N;i++) {
        po = judge(plan[i],plan[i + 1]);
    }

    if(po) {
        printf("Yes\n");
    }else{
        printf("No\n");
    }

    delete[] plan;
}


Measured memory_bytes: 1408
mod=10**9+7

x,y=map(int,input().split())
if (x+y)%3!=0:
  print(0)
  exit()
  
if x*2<y or y*2<x:
  print(0)
  exit()
  
z=(x+y)//3

x-=z
y-=z

n=x+y
r=x

if x==0 or y==0:
  print(1)
  exit()
  

lst=[0]+[1]
for i in range(2,n+10):
  lst.append((lst[-1]*i)%mod)


xxx=lst[n]
xxx*=pow(lst[n-r],10**9+5,mod)
xxx%=mod
xxx*=pow(lst[r],10**9+5,mod)
xxx%=mod

print(xxx)

Measured memory_bytes: 35280
L = []
while True:
    tmp = list(map(int,input().split()))
    if tmp[0] == 0 and tmp[1] == 0:
        break
    else:
        L.append(tmp)
for l in L:
    count = 0
    for i in range(1,l[0]+1):
        for j in range(i+1,l[0]+1):
            for k in range(j+1,l[0]+1):
                if i + j + k == l[1]:
                    count += 1
    print(count)


Measured memory_bytes: 5596
function Main(input) {
  input = input.trim()
 input=input.split(" ").map(Number);
  function compareFunc(a, b) {
  return a - b;
}
 
var num = [5, 3, 10, 6, 55];
 input = input.sort(compareFunc);
  console.log(input[2]*10+input[1]+input[0])
}Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

typedef long long ll;

ll dfs(int n, ll x){
    if(n == 0)  return 1;
    if(x <= 1)  return 0;

    ll len = (1ll<<(n+2))-3;
    ll center = len/2+1;
    
    // 区間を完全に覆ってしまった時点で枝刈りをしないとdfsの呼び出しが指数的に爆発して死ぬ
    if(x == len)    return 1 + 2ll*dfs(n-1, center-2);
    
    if(x < center)          return dfs(n-1, x-1);
    else if(x == center)    return 1 + dfs(n-1, center-2);
    else if(x > center)     return 1 + dfs(n-1, center-2) + dfs(n-1, x-1-center+1);
}

int main(){
    int n;
    ll x;
    cin >> n >> x;
    cout << dfs(n, x) << endl;
    return 0;
}


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

int main() {
    int k, a, b; cin >> k >> a >> b;
    int flag = 0;
    for (int i = a; i <= b; i++) {
        if (i % k == 0) flag = 1;
    }
    if (flag) cout << "OK" << endl;
    else cout << "NG" << endl;
}

Measured memory_bytes: 3624
N,W = map(int,input().split())
dp = [[0 for i in range(W+1)] for j in range(N+1)]
for i in range(N):
    w,v = map(int,input().split())
    for j in range(W+1):
        if j < w:
            dp[i+1][j] = dp[i][j]
        else:
            dp[i+1][j] = max(dp[i][j-w]+v,dp[i][j])
print(dp[N][W])

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

int main(){ 
  string s;
  cin >> s;
  int n = sz(s);
  vector<ll> dp(5,0);
  dp[0] = 1;
  for (int i = 0; i < n; i++) {
    vector<ll> next(5,0);
    for (int j = 0; j < 4; j++) {
      if (s[i] == '?') (next[j] += dp[j]*3%mod) %= mod; 
      else (next[j] += dp[j]) %= mod;
    }
    if (s[i] == 'A' || s[i] == '?') (next[1] += dp[0]) %= mod;
    if (s[i] == 'B' || s[i] == '?') (next[2] += dp[1]) %= mod;
    if (s[i] == 'C' || s[i] == '?') (next[3] += dp[2]) %= mod;
    dp = next;
  }
  cout << dp[3] << endl;
  return 0;
} 

Measured memory_bytes: 512
n = int(input())
A = map(int, input().split())

s = sorted(A)

ac = 0
startI = 0
for i, a in enumerate(s):
    if i == len(s) - 1:
        print(len(s) - startI)
        exit()

    ac += a

    if ac * 2 < s[i+1]:
        startI = i+1







Measured memory_bytes: 85384
#include <iostream>

using namespace std;

int main(void) {
	string str;
	cin >> str;
	char c;
	int res = 0;
	for (int i = 0; i < 3; ++i) {
		cin >> c;
		if (str[i] == c) {
			++res;
		}
	}
	cout << res << endl;

	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <climits> // INT_MAX, LONG_MAX, LLONG_MAX, UINT_MAX, ULONG_MAX, ULLONG_MAX
#include <cmath>
#include <cstdint>
#include <cstring> // memset
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>

#define ALL(x) (x).begin(), (x).end()
#define INF 1e9
#define LOG(x) cout << #x << " = " << (x) << endl
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)

using namespace std;


int n[4];

string func(int i, int sum, string equation) {
    if (i == 3) {
        if (sum == 7)
            return equation + "=7";
        else
            return "";
    }

    int next = n[i + 1];
    string s1 = func(i + 1, sum + next, equation + "+" + to_string(next));
    string s2 = func(i + 1, sum - next, equation + "-" + to_string(next));

    return s1 != "" ? s1 : s2;
}


int main() {
    string s;
    cin >> s;
    REP(i, s.size())
        n[i] = s[i] - '0';

    cout << func(0, n[0], to_string(n[0])) << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string.h>
using namespace std;

typedef long long ll;
int N,M,P;
ll D[2510];
ll inf = 1e18;
struct edge {int from,to; ll cost;};

vector<edge> v;

void shortest_path(int s){
	for(int i=1;i<=N;i++) D[i] = inf;
	D[s] = 0;
	for(int j=0;j<N-1;j++){
		for(int i=0;i<v.size();i++){
			edge e = v[i];
			if(D[e.from] != inf && D[e.to] > D[e.from] + e.cost){
				D[e.to] = D[e.from] + e.cost;
			}
		}
	}
}

void find_negative_loop(){
	for(int i=1;i<=N;i++){
		for(int j=0;j<v.size();j++){
			edge e = v[j];
			if(D[e.to]!=inf && D[e.to] > D[e.from] + e.cost){
				D[e.to] = -inf;
			}
		}
	}
}

int main(){
	cin >> N >> M >> P;
	for(int i=0;i<M;i++){
		int a,b,c;
		cin >> a >> b >> c;
		v.push_back((edge{a,b,P-c}));
	}
	shortest_path(1);
	ll ans = max(-D[N],0LL);
	find_negative_loop();
    cout << (D[N]==-inf? -1:ans) << endl;
}


Measured memory_bytes: 512
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <vector>
#include <utility>
#include <algorithm>
#include <string>
#include <queue>
#include <stack>
#include <tuple>
#include <set>
#include <map>
#include <functional>
#include <cmath>
#include <cstring>
using namespace std;
#define sci(n) scanf("%lld", &(n))
#define scd(n) scanf("%Ld", &(n))
typedef long long LL;
typedef long double LD;
typedef pair<LL, LL> pll;
int main(void)
{
	LL arr[10] = { 0, };
	for (int i = 0; i < 4; i++) {
		LL temp; sci(temp);
		arr[temp]++;
	}
	if (arr[1] && arr[9] && arr[7] && arr[4]) {
		cout << "YES";
	}
	else {
		cout << "NO";
	}



	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
#include <map>
#include <vector>
using namespace std;

int main() {
	int N, A, count, r, min = pow(10, 8);

	cin >> N;
	
	for (int i = 0; i < N; i++) {
		count = 0;
		cin >> A;
		r = A % 2;
		if (r == 1) {
			min = 0;
		}

		while (r != 1) {
			A /= 2;
			r = A % 2;
			count += 1;
		}
		if (min > count) { min = count; }

	}

	cout << min;

	return 0;
}

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

const int N = 1000010;

struct edge{
	int next, to;
};

edge e[N << 2];
bool vis[N];
int first[N], n, m, e_cnt = 0, col[N], gl;

void addedge(int u, int v){
	e[++ e_cnt] = {first[u], v};
	first[u] = e_cnt;
	e[++ e_cnt] = {first[v], u};
	first[v] = e_cnt;
}

void dfs(int u){
	vis[u] = true;
	for (int i = first[u]; i; i = e[i].next){
		int v = e[i].to;
		if (vis[v]){
			if (col[v] == col[u]){
				gl = 1;
			}
			continue;
		}
		col[v] = !col[u];
		dfs(v);
	}
}

int main(){
	scanf("%d%d", &n, &m);
	for (int i = 0, u, v; i < m; ++ i){
		scanf("%d%d", &u, &v);
		addedge(u, v);
	}
	int a = 0, n1 = 0, n2 = 0;
	for (int i = 1; i <= n; ++ i){
		if (!first[i]){
			++ a;
			continue;
		}
		if (vis[i]){
			continue;
		}
		gl = 0;
		dfs(i);
		gl ? ++ n2 : ++ n1;
	}
	ll ans = 2ll * a * n - 1ll * a * a;
	ans += 2ll * n1 * n1 + 1ll * n2 * n2 + 2ll * n1 * n2;
	return printf("%lld\n", ans), 0;
}

Measured memory_bytes: 12672
a,b,c,d = input()
for i in range(2**3):
    ls = ["+","+","+"]
    for j in range(len(ls)):
        if (i >> j) & 1:
            ls[j] = "-"
    if eval(a+ls[0]+b+ls[1]+c+ls[2]+d) == 7:
        print(a+ls[0]+b+ls[1]+c+ls[2]+d+"=7")
        break

Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using Vbo = vector<bool>;
using VV = vector<V>;
using VVll = vector<Vll>;
using VVld = vector<Vld>;
using VVbo = vector<Vbo>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
#define rep2(i, m, n) for(ll i=int(m); i<int(n); ++i)
#define drep2(i, m, n) for(ll i=int(m)-1; i>=int(n); --i)
#define rep(i, n) rep2(i, 0, n)
#define drep(i, n) drep2(i, n, 0)
#define all(a) a.begin(), a.end()
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (auto &e : v) is >> e; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << " "; return os; }
template<typename T> inline int count_between(vector<T> &a, T l, T r) { return lower_bound(all(a), r) - lower_bound(all(a), l); } // [l, r)
inline int Log2(ll x) { int k; for (k = 0; x > 0; ++k) x >>= 1; return k; } // number of binary digits
const int INF  = 1<<30;
const ll INFll = 1ll<<62;
const ld EPS   = 1e-10;
const int MOD  = int(1e9)+7;


int main() {
  ll n; cin >> n;
  map<ll, ll> mp;

  ll ans = 0;
  rep(i, n) {
    ll x; cin >> x;
    ans += mp[i-x];
    ++mp[i+x];
  }

  cout << ans << "\n";
  return 0;
}


Measured memory_bytes: 26220
#include <bits/stdc++.h>
using namespace std;
int main(){
	string n;
	cin >> n;
	int c = 0, f = 0;
	for(int i = 0; i <= n.size(); i++){
		if(n[i] == 'C'){
			c++;
		}
		if(c >= 1)
		if(n[i] == 'F'){
			
			f++;
		}
	}
	if(c >= 1 && f >= 1){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main() {
    string s;
    cin >> s;
    int k, n;
    cin >> k;
    n = s.size();

    vector<pair<char, int>> idx;
    rep(i, n){
        idx.push_back(make_pair(s[i], i));
    }
    sort(idx.begin(), idx.end());

    set<string> ans;
    char c = idx[0].first;
    char last = c;
    int cnt = 0;
    while(ans.size() < k || c == last){
        rep(i, k){
            int l = i + idx[cnt].second;
            if (l < n) {
                string sub = s.substr(idx[cnt].second, i + 1);
                ans.insert(sub);
            }
        }
        cnt++;
        last = c;
        c = idx[cnt].first;
    }
    
    cnt = 0;
    for (string sub : ans){
        cnt++;
        if(cnt == k) {
            cout << sub << endl;
            return 0;
        }
    }
}

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

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    divisors.sort()
    save = -1
    for i in range(len(divisors)):
        if divisors[i] >= 130:
            save = i
            break
    if save > 0:
        divisors = divisors[:save]
    return divisors

def f(a, b):
  return a**5 - b**5

divs = make_divisors(X)
ans = 0
for div in divs:
  a = -120+div
  b = -120
  while f(a, b) > X and b < 2:
    a += 1
    b += 1
  if f(a, b) == X:
    ans = (a, b)
    
print(ans[0], ans[1])

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

using namespace std;

#define ll long long

int main() {
#ifdef __APPLE__
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    ll a, b, c, y;
    scanf("%lld %lld %lld %lld", &a, &b, &c, &y);
    a *= 4;
    b *= 2;
    ll x = min({a, b, c});
    ll n;
    scanf("%lld", &n);
    if (x * 2ll < y)
        printf("%lld", n * x);
    else
        printf("%lld", (n / 2) * y + (n % 2) * x);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (long long i = 0; i < (long long)n; i++)
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using Vecl = vector<ll>;
using Graph = vector<vector<int>>;
#define mod 1000000007;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll N, ans = 1;
  cin >> N;
  for (int i = 1; i <= N; i++) {
    ans = ans * i;
    ans = ans % mod;
  }
  cout << ans << endl;
}

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

#define FOR(i,a,b) for(int i=(a);i<(int)(b);i++)
#define rep(i,n) FOR(i,0,n)
#define ZERO(a) memset(a,0,sizeof(a))

int F[110][110];

void solve(int n) {
    ZERO(F);
    int w,h; cin>>w>>h;
    rep(i,n) {
        int x,y; cin>>x>>y;
        --x; --y;
        F[y][x] = 1;
    }
    int s,t; cin>>s>>t; // w,h

    int ans = 0;
    rep(y,h-t+1) rep(x,w-s+1) {
        int cnt = 0;
        FOR(i,y,y+t) FOR(j,x,x+s) if(F[i][j] == 1) ++cnt;
        ans = max(ans, cnt);
    }
    cout << ans << "\n";
}

int main() {
    int n;
    while(cin>>n && n) solve(n);
    return 0;
}

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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

int A, B;

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

    std::cin >> A >> B;

    int d = A - 1;
    if(A <= B){
        d += 1;
    }

    std::cout << d << std::endl;
}


Measured memory_bytes: 256