akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll>pll;
typedef pair<ll,pair<ll,ll>>plll;
#define fastread() (ios_base:: sync_with_stdio(false),cin.tie(NULL));
#define vll(v) v.begin(),v.end()
#define all(x) x.rbegin(),x.rend()
#define min3(a, b, c)   min(a, min(b, c))
#define max3(a, b, c)   max(a, max(b, c))
#define F first
#define S second
#define in  freopen("input.txt", "r", stdin)
#define out  freopen("output.txt", "w", stdout)
#define minheap int,vector<int>,greater<int>
#define pb push_back
#define eb emplace_back
#define ischar(x)  (('a' <= x && x <= 'z') || ('A' <= x && x <= 'Z'))
#define isvowel(ch) ((ch=='a'||ch=='e'||ch=='i'||ch=='o'||ch=='u')||(ch=='A'|| ch=='E' || ch=='I'|| ch=='O'|| ch=='U'))
#define bug cout<<"BUG"<<endl;
//const int Max = 2e6 + 10;
const int Mod = 1e9 + 7;
const double PI  =3.141592653589793238463;
bool compare(const pair<ll,ll> &a, const pair<ll,ll> &b)
{
    return (a.first > b.first);
}
ll lcm(ll a,ll b)
{
    if(a==0 || b==0)return 0;

    return a/__gcd(a,b)*b;
}

void input(ll ara[],ll n)
{
    for(ll i=0; i<n; i++)cin>>ara[i];
}
int main()
{

    fastread();

    ll i,j,n,m,p,a,sum=0,k,t,b,c,d,cnt=0,q,l,r;


    cin>>n>>k;

    ll ara[n+2],dp[n+2]= {};

    dp[0]=dp[1]=0;



    for(i=1; i<=n; i++)
    {
        cin>>ara[i];



          if(i>1)
          {
              j=i-1;

              dp[i]=1e18;

              ll &ret=dp[i];

              while(j>=max(1ll,i-k))
              {
                  ret=min(ret,dp[j]+abs(ara[i]-ara[j]));
                  j--;
              }
          }
    }

    cout<<dp[n]<<endl;



}



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

int dp[209][209];

int main() {
	for (int i = 0; i <= 200; i++) {
		for (int j = 0; j <= i; j++) {
			int px = j, py = i - j; // (黒石, 白石)

			int col[300]; for (int k = 0; k < 300; k++) col[k] = 0;
			if (px >= 1) col[dp[px - 1][py + 1]] = 1;
			if (py >= 1) col[dp[px][py - 1]] = 1;
			for (int k = 1; k <= min(px, py); k++) col[dp[px - k][py]] = 1;

			for (int k = 0; k < 300; k++) {
				if (col[k] == 0) { dp[px][py] = k; break; }
			}
		}
	}

	int Q, W, B, X = 0; cin >> Q;
	for (int i = 1; i <= Q; i++) {
		cin >> W >> B;
		X ^= dp[B][W];
	}
	if (X >= 1) cout << "0" << endl;
	else cout << "1" << endl;
	return 0;
}


Measured memory_bytes: 3244
n = int(input().strip())

li = list(map(int,input().strip().split()))

d = {}
res = []
for i in li:
    d[i] = d.get(i,0)+1
    if(d[i] == 2 or d[i]==4):
        res.append(i)

if(len(res)<2):print(0)
else:
    res = sorted(res,reverse=True)
    print(res[0]*res[1])
    


Measured memory_bytes: 18088
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <limits.h>
#include <stdlib.h>
#include <algorithm>
#include <iostream>
#include <utility>
#include <vector>
#include <string>
#include <unordered_map>
#include <map>
#include <queue>
#include <set>
#include <stack>

using namespace std;

#define long long long
#define fi first
#define se second
typedef pair<int,int> ii;

int n, m;
int U[100003], V[100003];
bool odd[100003], rev[100003], visited[100003];
vector<ii> vec[100003];

void dfs(int u)
{
	// printf("%d %d\n", u, odd[u]);
	visited[u] = 1;
	for(auto nxt : vec[u])
	{
		int v = nxt.fi;
		int idx = nxt.se;
		
		if(visited[v]) continue;
		dfs(v);
		
		if(odd[v])
		{
			odd[u] ^= 1;
			odd[v] = 0;
			rev[idx] ^= 1;
		}
	}
	// printf("%d %d\n", u, odd[u]);
}

int main()
{
	// ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	// freopen("input.in", "r", stdin);

	scanf("%d %d", &n, &m);
	for(int i = 1; i <= m; i++)
	{
		scanf("%d %d", &U[i], &V[i]);
		odd[U[i]] ^= 1;
		vec[U[i]].push_back({V[i], i});
		vec[V[i]].push_back({U[i], i});
	}
	if(m&1)
	{
		printf("-1\n");
		return 0;
	}

	dfs(1);
	// printf("\n");
	for(int i = 1; i <= m; i++)
	{
		if(!rev[i])
			printf("%d %d\n", U[i], V[i]);
		else printf("%d %d\n", V[i], U[i]);
	}
}










Measured memory_bytes: 12672
#include <iostream>
#include <fstream>
#include <vector>
#include <cstring>
#include <algorithm> // sort
#include <iomanip>
#include <map>
#include <list>
#include <bits/stl_numeric.h>

#define DEBUG 0
#define REP(i, n) for (long long i = 0; i < (n); i++) 
typedef long long ll;
static const ll MOD = 1000000007;
static const ll INF = 1000000000000000000LL;
using namespace std;

int main(){
    int N;
    cin >> N;
    vector <double> p(N);

    REP(i,N)cin >> p[i];

    double dp[N+1][N+1];
    //dp[i][j]: i個投げた時点で、表がj個である確率
    REP(i,N+1)
    {
        REP(j, N+1)
        {
            dp[i][j] = 0;
        }
    }
    dp[0][0] = 1;

    for(int i = 1; i <= N; ++i)
    {
        for(int j = 0; j < i; ++j)
        {
            for(int k = 0; k < 2; ++k)
            {
                //確率ゼロを許容デキテイナイ?
                if(k == 0)
                {
                    //裏
                    dp[i][j] += dp[i-1][j] * (1.0 - p[i-1]);
                    //dp[i][j] = dp[i-1][j];
                }
                else
                {
                    //表
                    dp[i][j+1] += dp[i-1][j] * p[i-1]; 
                }
            }
        }
    }

    double res = 0;
    //足し合わせる
    for(int j = N / 2 + 1; j <= N; ++j)
    {
        res += dp[N][j];
    }

    printf("%.12f\n",res);



    return 0;
}


Measured memory_bytes: 70528
while(True):
    n, s = map(int, input().split())
    if n == 0: break

    def dfs(a, b, used):
        if a == n: return s == b

        ret = 0
        for i in range(used+1, 10):
            ret += dfs(a + 1, b + i, i)
        return ret

    print(dfs(0, 0, -1))


Measured memory_bytes: 5592
#![allow(unused)]

use std::{cmp, collections, fmt, io, iter, ops, str};
use cmp::Ordering::{Equal, Greater, Less};
use collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, LinkedList, VecDeque};
use io::{Read, Write};

#[cfg(feature = "debug")]
macro_rules! debug {
    ($fmt: expr) => { eprintln!($fmt) };
    ($fmt: expr, $($args: tt)*) => { eprintln!($fmt, $($args)*) };
}

#[cfg(not(feature = "debug"))]
macro_rules! debug {
    ($fmt: expr) => {};
    ($fmt: expr, $($args: tt)*) => {};
}

macro_rules! vmax {
    ($x: expr, $y: expr) => { cmp::max($x, $y) };
    ($x: expr, $($args: expr),*) => { cmp::max($x, vmax!($($args),*)) };
}

macro_rules! vmin {
    ($x: expr, $y: expr) => { cmp::min($x, $y) };
    ($x: expr, $($args: expr),*) => { cmp::min($x, vmin!($($args),*)) };
}

fn read_line() -> String {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().to_owned()
}

fn read_word() -> String {
    const CAPACITY: usize = 16;

    let mut stdin = io::stdin();
    let mut byte: [u8; 1] = [0];

    loop {
        let mut buf = Vec::with_capacity(CAPACITY);

        loop {
            let res = stdin.read(&mut byte);

            if res.unwrap_or(0) == 0 || byte[0] <= b' ' {
                break;
            } else {
                buf.push(byte[0]);
            }
        }

        if buf.len() > 0 {
            return String::from_utf8(buf).unwrap();
        }
    }
}

fn parse_line<T: str::FromStr>() -> T {
    read_line().parse().ok().unwrap()
}

fn parse_word<T: str::FromStr>() -> T {
    read_word().parse().ok().unwrap()
}

fn parse_vec<T: str::FromStr>() -> Vec<T> {
    read_line()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn flush() {
    io::stdout().flush();
}

fn main() {
    let min = parse_word::<i32>();
    let max = parse_word::<i32>();

    let count = (min..(max + 1)).filter(|x| is_palindrome(*x)).count();
    println!("{}", count);
}

fn is_palindrome(x: i32) -> bool {
    let chars = {
        let s = x.to_string();
        s.chars().collect::<Vec<_>>()
    };

    chars[0] == chars[4] && chars[1] == chars[3]
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn test() {
        //
    }
}


Measured memory_bytes: 4352
#include <iostream>
#include <algorithm>

using namespace std;

int main(){
    long X;
    cin >> X;
    for(long x = -1000; x < 1000; x++){
        for(long y=-1000; y<1000; y++){
            if(x * x * x * x * x - y * y * y * y* y == X) {
                cout << x << " " << y << endl;
                return 0;
            }
        }
    }    
    return 0;
}

Measured memory_bytes: 3636
#!/usr/bin/env python3

import sys

P_NUM = 1000000007


def solv(n, m, a):
    comb_m2 = 1
    if 1 in a:
        comb_m1 = 0
    else:
        comb_m1 = 1

    comb = 1
    for i in range(2, n+1):
        if i in a:
            comb = 0
        else:
            comb = (comb_m1 + comb_m2) % P_NUM

        comb_m1, comb_m2 = comb, comb_m1

    return comb


if __name__ == '__main__':

    n, m = map(int, input().split())
    if m:
        a = set(map(int, sys.stdin))
    else:
        a = set()

    ans = solv(n, m, a)

    print(ans)


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

//#define int long long
#define ll long long
#define all(v) (v).begin(), (v).end()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

signed main()
{   
    gearup;
    int n,m;cin >> n >> m;
    int ma,mi; cin >> mi >> ma;
    rep1(i,m){
        int x,y; cin >> x >> y;
        mi = max(mi,x);
        ma = min(ma,y);
    }
    ll res = 0;
    rep(i,n){
        if(mi<=i+1 && i+1<=ma)res++;
    }
    cout << res << endl;
}


Measured memory_bytes: 256
/* ex3_3
	kanon */

#include <stdio.h>

int main(void)
{

    //与えられる値を入れる変数を宣言
    int num, base;

    //変数に値を入力する
    scanf("%d %d", &num, &base);

    //logを用いてNをK進法で表したときの桁数を計算する
    int answer=log(num)/log(base)+1;

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

    return 0;
}


Measured memory_bytes: 128
N = int(input())
inputs = [int(i) for i in input().split()]

slime = 10000

if N == 2 and inputs[0] == inputs[1]:
    print(1)
    exit()
else:
    for i in range(N):
        if i == 0 or i == N-1:
            continue
        else:
            if inputs[i-1] == inputs[i] == inputs[i+1]:
                inputs[i] = slime
                slime -= 1
            elif i+2 <= N-1 and inputs[i] == inputs[i+1] == inputs[i+2]:
                continue
            elif inputs[i-1] == inputs[i] or inputs[i] == inputs[i+1]:
                inputs[i] = slime
                slime -= 1

print(10000-slime)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int n,mx1,mx2;
map<int,int> mp;
long long ans;
 int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;++i) 
	{
		int x;
		scanf("%d",&x);
		if (mp[x]==1)
		{
			if (x>mx1) mx2=mx1,mx1=x;
			else if (x>mx2) mx2=x;
			mp[x]=0;
		}
		else mp[x]=1;
	}
	ans=1LL*mx1*mx2;
	printf("%lld",ans);
}

Measured memory_bytes: 4992
import numpy as np

a = []
ans = 'No'

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

n = int(input())

for i in range(n):
  d = int(input())
  for j in range(3):
    for k in range(3):
      if a[j][k] == d:
        a[j][k] = 0

if a[0][0] == a[1][0] == a[2][0] == 0:
  ans = 'Yes'
elif a[0][1] == a[1][1] == a[2][1] == 0:
  ans = 'Yes'
elif a[0][2] == a[1][2] == a[2][2] == 0:
  ans = 'Yes'
elif a[0][0] == a[0][1] == a[0][2] == 0:
  ans = 'Yes'
elif a[1][0] == a[1][1] == a[1][2] == 0:
  ans = 'Yes'
elif a[2][0] == a[2][1] == a[2][2] == 0:
  ans = 'Yes'
elif a[0][0] == a[1][1] == a[2][2] == 0:
  ans = 'Yes'
elif a[2][0] == a[1][1] == a[0][2] == 0:
  ans = 'Yes'

print(ans)

Measured memory_bytes: 12508
//Author: Rahul Purohit

#include<bits/stdc++.h>
#define vi vector<int>
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define ll  long long int
#define pi pair<ll,ll>
#define f first
#define mp make_pair
#define mod 1000000007
#define s second
#define pb push_back
#define mp make_pair
using namespace std;
int gcd(int a, int b)
{
	if(b==0)
		return a;
	else
		return (b,a%b);
}
/*ll isp[N]={1};
void sieve(int n)
{
	isp[0]=isp[1]=0;
	for(int i=2;i<=n;i++)
	{
		if(isp[i]==1)
		{
			for(int j=i*i;j<=n;j+=i)
			{
				isp[j]==0;
			}
		}
	}
}*/
ll pow(int x,int  y,int m)
{
	ll ans=1;
	while(y!=0)
	{
		if(y%2==1)
		{
			ans=(ans*x)%m;
		}
		x=(x*x)%m;
		y/=2;
	}
	return ans;
}
template <class x>
void swap(x &a,x &b)
{
	x tp;
	tp=a;
	a=b;
	b=tp;
}
int main(void)
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
    
    ll ar[5],k;
    for(ll i=0;i<5;++i)
    {
        cin>>ar[i];
    }
    sort(ar,ar+5);
    cin>>k;
    if(ar[4]-ar[0]<=k)
    {
        cout<<"Yay!\n";
    }
    else
    {
        cout<<":(\n";
    }
    return 0;
}


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

#define debug(x) cerr << #x << ": " << x << endl
#define debugArray(x, n)                                                       \
    for(long long hoge = 0; (hoge) < (n); ++(hoge))                            \
    cerr << #x << "[" << hoge << "]: " << x[hoge] << endl
using namespace std;

using ll = long long;
using ull = unsigned long long;
const ll INF = LLONG_MAX / 2;

struct KnuthMorrisPratt {
    vector<int> KMP;
    const string s;
    int n;
    KnuthMorrisPratt(const string &str) : s(str), n(s.length()) {
        KMP.resize(n + 1, -1);
        for(int i = 0, j = -1; i < n; i++) {
            while(j >= 0 && s[i] != s[j])
                j = KMP[j];
            j++;
            if((i + 1 == n ? '*' : s[i + 1]) == (j == n ? '*' : s[j]))
                KMP[i + 1] = KMP[j];
            else
                KMP[i + 1] = j;
        }
    }

    // the period of S[0:i]
    int period(int i) { return i - KMP[i]; }

    // positions for T that match s
    // O(|T|)
    vector<int> pattern_match(string T) {
        int m = T.length();
        vector<int> occur;
        for(int i = 0, k = 0; i < m; ++i) {
            while(k >= 0 && T[i] != s[k])
                k = KMP[k];
            if(++k == n) {
                /* match at T[i-n+1 ... i] */
                occur.push_back(i - n + 1);
            }
        }
        return occur;
    }
};

int n, m;
bool match[1012345];
bool check[1012345];
int dep[1012345];

int dfs(int v) {
    if(check[v]) {
        return -1;
    }
    if(dep[v]) {
        return dep[v];
    }
    if(!match[v]) {
        return 0;
    }
    check[v] = true;
    int ret = dfs((v + n) % m);
    if(ret < 0) {
        return -1;
    }
    check[v] = false;
    return dep[v] = ret + 1;
}

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    string s, t;
    cin >> s >> t;
    n = t.length(), m = s.length();
    KnuthMorrisPratt KMP(t);
    string ss = s;
    while(ss.length() < n)
        ss += s;
    ss += s;
    auto idx = KMP.pattern_match(ss);
    for(int i : idx) {
        match[i % m] = true;
    }
    int ans = 0;
    for(int i = 0; i < m; i++) {
        int a = dfs(i);
        if(a < 0) {
            ans = -1;
            break;
        }
        ans = max(ans, a);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 19796
from heapq import heapify, heappop, heappush
# from itertools import accumulate, permutations, combinations, combinations_with_replacement, groupby, product
# import math
# import numpy as np  # Pythonのみ！
# from operator import xor
# import re
# from scipy.sparse.csgraph import connected_components  # Pythonのみ！
# ↑cf.  https://note.nkmk.me/python-scipy-connected-components/
# from scipy.sparse import csr_matrix
# import string
import sys

sys.setrecursionlimit(10 ** 5 + 10)


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


def resolve():
    N, x = map(int, input().split())
    A = list(map(int, input().split()))
    cnt = 0
    heapify(A)
    while True:
        if cnt < N:
            p = heappop(A)
            x -= p
            if x>=0:
                cnt += 1
            else:
                break
        else:
            break
    if cnt==N and x!=0:
        cnt-=1
    print(cnt)


resolve()

Measured memory_bytes: 38384
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>

using namespace std;

#define int long long
#define rep(i,n) for(int i = 0; i < (n); i++)
#define INF ((long long)1e18)
#define MOD ((int)1e9+7)
#define endl "\n"

#define yn(f) ((f)?"Yes":"No")
#define YN(f) ((f)?"YES":"NO")

#define MAX

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	int N, ans = 0;
	int V[100];
	cin>>N;
	
	int t;
	
	for(int i = 0; i < N; i++){
		cin>>V[i];
	}
	
	for(int i = 0; i  < N; i++){
		cin>>t;
		if(V[i]-t >= 0) ans += V[i]-t;
	}
	
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define INF 2000000000
#define N_MAX 100010
int dp[N_MAX];
int main(void){
	
	int n;cin >> n;
	vector<int> a(n);
	for(int i=0;i < n;i++) cin >> a[i];
	
	fill(dp,dp+n,INF);

	for(int i = n-1;i >= 0;i--){
		*upper_bound(dp,dp+n,a[i]) = a[i];
	}
	cout << lower_bound(dp,dp+n,INF) - dp << endl;
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int a[2005],b[2005],c[2005];
int n,k,q,ans;
int main(){
	scanf("%d%d%d",&n,&k,&q);
	for (int i=1;i<=n;i++) scanf("%d",&a[i]);
	ans=1e9+1;
	for (int i=1;i<=n;i++){
		int l=0;
		int cnt=0;
		for (int j=1;j<=n+1;j++)
			if (a[j]<a[i]){
				if (!l) continue;
				int r=j-1; 
				for (int p=l;p<=r;p++)
					b[p]=a[p];
				sort(b+l,b+r+1);
				for (int p=l;p+k-1<=r;p++)
					c[++cnt]=b[p];
				l=0;
			}
			else if (!l) l=j;
		if (cnt<q) continue;
		sort(c+1,c+cnt+1);
		//printf("%d\n",c[q]);
		ans=min(ans,c[q]-a[i]);
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 256
package main
import "fmt"
func main() {
  var n int
  fmt.Scan(&n)
  cnt := make([]int, 8)
  var pro int
  for i := 0; i < n; i++ {
    var a int
    fmt.Scan(&a)
    if a >= 3200 {
      pro++;
    } else {
      cnt[a/400]++;
    }
  }
  ans := 0
  for _, x := range cnt {
    if x != 0 {
      ans++;
    }
  }
  if ans == 0 {
    fmt.Printf("1 %d\n", pro)
  } else {
    fmt.Printf("%d %d\n", ans, ans + pro)
  }
}

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


int solve(int a,int b,int n){
  int ans=0;
  a%=b;
  a*=10;
  for(int i=0;i<n;i++){
    ans+=a/b;
    a%=b;
    a*=10;
  }
  return ans;
}

int main(){
  int a,b,c;
  while(cin>>a>>b>>c){
    cout<<solve(a,b,c)<<endl;
  }
}

Measured memory_bytes: 1160
#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;

int main()
{
	string s;
	int ans = 999;
	cin >> s;

	int n = s.size();

	for (int i = 0; i < n - 2; ++i) {
		int num = (s[i] - '0') * 100 + (s[i + 1] - '0') * 10 + s[i + 2] - '0';
		ans = min(ans, abs(753 - num));
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
n = int(input())
as_ = sorted(list(map(int, input().strip().split())))

ans = 1
if as_[0] == 0:
    print(0)
    exit(0)

for a in as_:
    ans *= a
    if ans > 1e18:
        print(-1)
        exit(0)

print(ans)


Measured memory_bytes: 21668
n = int(input())
d = set()
a = [ int(i) for i in input().split() ]
a = sorted(a)
for i in range(2):
    for j in range(1,int(a[i]**0.5)+1):
        if a[i] % j == 0:
            d.add(j)
            d.add(a[i]//j)
ans = 0
for i in d:
    cnt = 0
    for j in a:
        if j % i != 0:
            cnt += 1

        if cnt >= 2:
            break

    if cnt < 2:
        ans = max(ans,i)
print(ans)


Measured memory_bytes: 14060
#include <bits/stdc++.h>
using namespace std;
#define rep0(i,n) for(ll (i) = 0; (i) < (n); ++(i))
#define rrep0(i,n) for(ll (i) = (n) - 1; (i) >= 0; --(i))
#define rep1(i,n) for(ll (i) = 1; (i) <= (n); ++(i))
#define rrep1(i,n) for(ll (i) = (n); (i) >= 1; --(i))
#define nfor(i,a,b) for(ll (i) = (a); (i) < (b); ++(i))
#define rfor(i,a,b) for(ll (i) = (a); (i) > (b); --(i))
#define ll long long
#define mod (1000000007)
#define pf(x) cout << (x) << endl;
#define all(x) (x).begin(),(x).end()

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

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

ll factorial(ll n){
    ll t = 1;
    rep1(i, n)t *= i;
    return t;
}

ll combinations(ll n, ll k) {
    ll r = 1;
    for (ll i = 1; i <= k; ++i) {
        r *= n--;
        r /= i;
    }
    return r;
}

int main()
{
    int a,b;
    vector<bool> ans(3,true);
    cin >> a >> b;
    ans[a - 1] = false;
    ans[b - 1] = false;
    rep0(i, 3)if(ans[i])pf(i + 1);
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
 
int main(){
	int i,j,n=0,m;
	scanf("%d", &j);
	for(i=0;i<j;i++){
		scanf("%d", &m);
		if(m-n<-1){
			break;
		}
		if(m>n){
          n=m;
        }
	}
	if(i==j){
		printf("Yes");
	}else{
		printf("No");
	}
	return 0;
}
 

Measured memory_bytes: 128
use proconio::{input, fastout};

#[fastout]
fn main() {
    input! {
        x: u64,
    }

    let mut money = 100u64;
    let mut ans = 0;

    while money < x {
        money += money / 100;
        ans += 1;
    }

    println!("{}", ans);
}


Measured memory_bytes: 2172
let N = Int(readLine()!)!
let A = readLine()!.characters.split(" ").map{Int(String($0))!}.sort()
let tmp = (0..<N).map{$0+($0+N+1)%2}
if N == 1 {
    print(1)
} else if A == tmp {
    print((0..<N/2).reduce(1){i,_ in i*2%1000000007})
} else {
    print(0)
}

Measured memory_bytes: 7232
using System;

public class Hello
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        var s = Console.ReadLine().Trim();
        var a = new int[n];
        var b = new int[n];
        var c = new int[n];
        var count = 0;   var cmax = -99999999;   var imax = 0;
        for (int i = 0; i < n; i++)
        {
            if (s[i] == 'E') count++;
            a[i] = count;
            b[i] = i + 1 - a[i];
            c[i] = a[i] - b[i];
            if (c[i] > cmax) { imax = i;  cmax = c[i]; }
        }
        int ret;
        if (imax == 0) ret = a[n - 1] - a[imax];
        else if (imax == n - 1) ret = b[imax];
        else ret = b[imax] + (a[n - 1] - a[imax]);
        Console.WriteLine(ret);
    }
}


Measured memory_bytes: 15584
import Control.Applicative ((<$>), (<*>))
import Control.Monad
import Data.List
import Data.Array (range)
import qualified Data.IntMap as IM

main :: IO ()
main = do
  let tbl = mkTbl
  solve tbl

solve :: IM.IntMap (Int,Int,Int) -> IO ()
solve tbl = do
  x <- getl toInt
  when (x /= 0) $ do
    print . toPrice $ tbl IM.! x
    solve tbl

mkTbl :: IM.IntMap (Int,Int,Int)
mkTbl = foldl f IM.empty ilst
  where
    ilst = map (\(d,t,c) -> (200*d+300*t+500*c,(d,t,c))) . filter (\(d,t,c) -> 200*d+300*t+500*c <= 5000) $ range ((0,0,0),(25,16,10))
    f tbl (w,(d,t,c)) = IM.insertWith (\(pd,pt,pc) (cd,ct,cc) -> if toPrice (pd,pt,pc) < toPrice (cd,ct,cc) then (pd,pt,pc) else (cd,ct,cc)) w (d,t,c) tbl

toPrice :: (Int,Int,Int) -> Int
toPrice (d,t,c) = (d `div` 5) * 1520 + (d `mod` 5) * 380 + (t `div` 4) * 1870 + (t `mod` 4 ) * 550 + (c `div` 3) * 2244 + (c `mod` 3) * 850

toInt :: String -> Int
toInt s = read s

getl :: (String -> a) -> IO a
getl f = f <$> getLine

Measured memory_bytes: 4544
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

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

const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

template <class Abel> struct BIT {
    const Abel UNITY_SUM = 0;                       // to be set
    vector<Abel> dat;
    
    /* [1, n] */
    BIT(int n) : dat(n + 1, UNITY_SUM) { }
    void init(int n) { dat.assign(n + 1, UNITY_SUM); }
    
    /* a is 1-indexed */
    inline void add(int a, Abel x) {
        for (int i = a; i < (int)dat.size(); i += i & -i)
            dat[i] = dat[i] + x;
    }
    
    /* [1, a], a is 1-indexed */
    inline Abel sum(int a) {
        Abel res = UNITY_SUM;
        for (int i = a; i > 0; i -= i & -i)
            res = res + dat[i];
        return res;
    }
    
    /* [a, b), a and b are 1-indexed */
    inline Abel sum(int a, int b) {
        return sum(b - 1) - sum(a - 1);
    }
    
    /* debug */
    void print() {
        for (int i = 1; i < (int)dat.size(); ++i) cout << sum(i, i + 1) << ",";
        cout << endl;
    }
};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    ll K;
    cin>>N>>K;
    vector<ll> sum(N+1),con(N+1);
    REP(i,N){
        ll a;cin>>a;
        a-=K;
        sum[i+1] = sum[i] + a;
    }
    ++N;
    map<ll,int> ma;
    REP(i,N) ma[sum[i]]++;
    int iter=1;
    for(auto it = ma.begin();it!=ma.end();++it) it->second = iter++;
    REP(i,N) con[i] = ma[sum[i]];

    ll res = 0;
    BIT<ll> bit(N);
    //bit.init(N);
    REP(j,N){
        ll tmp = bit.sum(1,con[j]+1);
        res += tmp;
        bit.add(con[j],1);
    }
    cout<<res<<endl;
}

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

int day[12] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
string date[7] = {
    "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"
};

int main() {
    int m, d;
    while (cin >> m >> d, m && d) {
        int t = d;
        for (int i=0; i<m-1; ++i) {
            t += day[i];
        }
        cout << date[(t + 2) % 7] << endl;
    }
    return 0;
}

Measured memory_bytes: 1196
import sys
input = sys.stdin.readline
from collections import defaultdict


dict = defaultdict(int)
n = int(input())
for _ in range(n):
    s = input()
    dict[s] += 1

maxim = max(dict.values())

candidates = []

for key, count in dict.items():
    if count == maxim:
        candidates.append(key)

candidates.sort()

print(*candidates, sep='\n')


Measured memory_bytes: 34652
//#pragma GCC         optimize("O3")
#include            <bits/stdc++.h>
#include            <ext/pb_ds/assoc_container.hpp>
#include            <ext/pb_ds/tree_policy.hpp>
#define FastIO      ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)
#define pb          push_back
#define mp          make_pair
#define mem(x,i)    memset(x,i,sizeof(x))
#define ff          first
#define ss          second
#define popcount(x) __builtin_popcount(x)
#define all(x)      x.begin(),x.end()
#define Case(t)     for(int ks=1;ks<=t;ks++)
#define fileout     freopen("output.txt","w",stdout)
#define filein      freopen("input.txt","r",stdin)
#define D(x)        cerr<< __LINE__ <<": "<< #x << " = "<<(x) <<'\n';
#define endl        '\n'

using namespace std;
//using namespace __gnu_pbds;

using ll  = long long;
using ld  = long double;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using pil = pair<int,ll>;

const int INF    = 0x3f3f3f3f;
const ll LL_INF  = 0x3f3f3f3f3f3f3f3f;
const double PI  = acos(-1);
const double eps = 1e-4;
const int mod    = 1e9+7;
const int mx     = 300005;
/*template <typename T>  using orderedSet =
    tree<T, null_type, less_equal<T>,
    rb_tree_tag, tree_order_statistics_node_update>;//find_by_order,order_of_key*/

/*------------------------------Graph Moves----------------------------*/
//const int fx[]= {+1,-1,+0,+0};
//const int fy[]= {+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
/*---------------------------------------------------------------------*/

//ll powmod(ll a,ll b){ll res=1;a%=mod;assert(b>=0);for(; b; b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
/*----------------------BitMask-----------------------------------------*/
//inline int setBit(int N,int pos){return N=N | (1<<pos);}
//inline int resetBit(int N,int pos){return N= N & ~(1<<pos);}
//inline bool checkBit(int N,int pos){return (bool) (N& (1<<pos));}

int main()
{
    int n;
    cin>>n;
    int arr[n];
    multiset<int>m;
    for(int i=0;i<n;i++)
    {
        cin>>arr[i];
        m.insert(arr[i]);
    }
    while(m.size()>1)
    {
        multiset<int>t;
        int x=*m.begin();
       // D(x);
        t.insert(x);
        m.erase(m.begin());
        while(m.size())
        {
            int y=*m.begin();
            m.erase(m.begin());
            //D(y);
            y%=x;
            if(y) t.insert(y);
        }
        m=t;
    }
    cout<<*m.begin()<<endl;
}




Measured memory_bytes: 13124
N=int(input())
L=list(map(int,input().split()))
max_Lindex=L.index(max(L))
max_L=L[max_Lindex]
L.pop(max_Lindex)
sum_L=sum(L)
if sum_L>max_L:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]

n = int(input())
x = make_divisors(n)

if len(x)%2 == 0:
    print(x[len(x)//2]+x[(len(x)//2)-1]-2)
else:
    print((x[(len(x)//2)]*2)-2)


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

  private static int ROW_NUMBER = 20, COL_NUMBER = 20;

  public static void main(String[] args) { 
      Scanner sc = new Scanner(System.in);
      int h = sc.nextInt();
      int w = sc.nextInt();
      char[][] grid = new char[h][w];
      for(int i = 0; i < h; i++)
        grid[i] = sc.next().toCharArray();
      int max = 0;

      for(int i = 0; i < h; i++) {
        for(int j = 0; j < w; j++) {
          if(grid[i][j] == '#') continue;
          max = Math.max(max, bfs(grid, i, j));
        }
      }

      System.out.println(max);
  }

  private static int bfs(char[][] grid, int start_row, int start_col) {
    int step = 0;
    int[] rows = new int[]{-1, 1, 0, 0};
    int[] cols = new int[]{0, 0, -1, 1};

    Set<Integer> visited = new HashSet<>();
    visited.add(start_row * COL_NUMBER + start_col);
    Queue<int[]> queue = new LinkedList<>();
    queue.offer(new int[]{start_row, start_col});
    while(!queue.isEmpty()) {
      int size = queue.size();
      for(int i = 0; i < size; i++) {
        int[] cood = queue.poll();
        int row = cood[0];
        int col = cood[1];
        for(int d = 0; d < rows.length; d++) {
          int next_row = rows[d] + row;
          int next_col = cols[d] + col;
          if(isValid(grid, visited, next_row, next_col)) {
            queue.offer(new int[]{next_row, next_col});
            visited.add(next_row * COL_NUMBER + next_col);
          }
        }
      }
      if(!queue.isEmpty())step++;
    }
    return step;
  }

  private static boolean isValid(char[][] grid, Set<Integer> visited, int row, int col) {
    if(row < 0 || row >= grid.length || col < 0 || col >= grid[row].length || grid[row][col] == '#' || visited.contains(row * COL_NUMBER + col))
      return false;
    return true;
  }
}

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

int main() {
	int n,a=0,b=0;
	cin >> n;
	vector<int> ary(n);

	for (int i = 0; i < n; i++)
	{
		cin >> ary[i];
	}
	sort(ary.begin(),ary.end(),greater<int>());

	ary.erase(std::unique(ary.begin(), ary.end()), ary.end());

	cout << ary.size() << endl;


}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>

using namespace std;

int n;
double x[3], y[3];

int main()
{
	cin >> n;
	for(int i=0; i<n; i++)
	{
		cin >> x[0] >> y[0] >> x[1] >> y[1] >> x[2] >> y[2];
		double a1 = 2.0 * (x[1] - x[0]);
		double b1 = 2.0 * (y[1] - y[0]);
		double c1 = x[0]*x[0] - x[1]*x[1] + y[0]*y[0] - y[1]*y[1];
		double a2 = 2.0 * (x[2] - x[0]);
		double b2 = 2.0 * (y[2] - y[0]);
		double c2 = x[0]*x[0] - x[2]*x[2] + y[0]*y[0] - y[2]*y[2];

		double cx = (b1*c2-b2*c1) / (a1*b2-a2*b1);
		double cy = (c1*a2-c2*a1) / (a1*b2-a2*b1);
		
		double dx = x[0] - cx;
		double dy = y[0] - cy;
		double r = sqrt(dx*dx + dy*dy);
		
		printf("%.3f %.3f %.3f\n", cx, cy, r);
	}
}

Measured memory_bytes: 0
#include<iostream>
#include<cmath>
#include<cstdio>
using namespace std;
long double a, l, x, p;
int main() {
	while (cin >> a >> l >> x) {
		long double z = sqrtl(l*l - a*a / 4); p = 0;
		p += z*a / 2;
		z = sqrtl((l + x)*(l + x) / 4 - l*l / 4);
		p += z*l;
		printf("%.15Lf\n", p);
	}
	return 0;
}

Measured memory_bytes: 1240
#include<bits/stdc++.h>
#define fr(i1,m) for(int i1=0;i1<m;i1++)
using namespace std;
int main()
{

    long a,b,c;
    cin>>a>>b>>c;
    if(b-a==c-b)
    {
        cout<<"YES\n";
    }
    else
    {
        cout<<"NO\n";
    }
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }
template<typename T>
struct BinarySearchTree {
	struct Node {
		T key;
		Node *l, *r, *p;
		Node() {}
		Node(T key) :key(key) {}
		Node(T key, Node *l, Node *r) :key(key), l(l), r(r) {}
		bool operator<(Node &other) {
			return key < other.key;
		}
		bool operator>(Node &other) {
			return key > other.key;
		}
	};
	Node *root = nullptr, *NIL = nullptr;
	void insert(T key) {
		Node *x = root, *y = NIL;
		while (x != NIL) {
			y = x;
			if (key < x->key)x = x->l;
			else x = x->r;
		}
		dump(y);
		Node *z = (Node*)malloc(sizeof(Node));
		z->l = z->r = NIL;
		z->key = key;
		z->p = y;
		if (y == NIL)root = z;
		else {
			if (key < y->key)y->l = z;
			else y->r = z;
		}
	}
	void find(T key) {
	// Node *find(T key) {
		Node *x = root;
		while (x != NIL&&x->key != key) {
			if (key < x->key)x = x->l;
			else x = x->r;
		}
		if (x != NIL)cout << "yes" << endl;
		else cout << "no" << endl;
		// return x;
	}
	void inorder() {
		inorder(root);
		puts("");
	}
	void inorder(Node *u) {
		if (u == NIL)return;
		inorder(u->l);
		printf(" %d", u->key);
		inorder(u->r);
	}
	void preorder() {
		preorder(root);
		puts("");
	}
	void preorder(Node *u) {
		if (u == NIL)return;
		printf(" %d", u->key);
		preorder(u->l);
		preorder(u->r);
	}
};
signed main() {
	int n; scanf("%d", &n);
	BinarySearchTree<int>bst;
	rep(i, 0, n) {
		string com;
		cin >> com;
		if (com == "insert") {
			int x; scanf("%d", &x);
			bst.insert(x);
		}
		else if (com == "print") {
			bst.inorder();
			bst.preorder();
		}
		else if (com == "find") {
			int x; scanf("%d", &x);
			bst.find(x);
		}
	}
	return 0;
}

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

using namespace std;

void solve()
{
	int n;
	while(cin >> n, n != -1)
	{
		if(n == 0)
		{
			cout << 0 << endl;
			continue;
		}
		string binary;
		while(n)
		{
			binary += (char)(n % 2 + '0');
			n /= 2;
		}
		if(binary.size() % 2)
		{
			binary += "0";
		}
		string fourDigits = "";
		for(int i = 0; i < binary.size(); i += 2)
		{
			fourDigits += binary[i] - '0' + 2 * (binary[i + 1] - '0') + '0';
		}
		reverse(fourDigits.begin(), fourDigits.end());
		cout << fourDigits << endl;
	}
}

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

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

int main(){
    int n;
    cin >> n;
    if(n/100 == 7 || (n-n/100*100)/10 == 7 || n%10 == 7){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    return 0;
}

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

using namespace std;

typedef long long ll;
#define mod 1000000007
#define rep(i, a, b) for(ll i = a; i < b; i++)
#define repc(i, a, b, c) for (ll i = a; (c > 0 ? i < b : i > b) and c != 0; i += c)
#define fi first
#define si second
#define pb push_back
#define all(name) (name.begin(), name.end())
#define fact(n) vector<ll> ft(1, 1LL);rep(i, 1, n+1)ft.pb((ft[i-1]*i)%mod);
#define mod_in(a) power(a, mod - 2)
#define ncr(n, r) ((ft[n]*mod_in((ft[r]*ft[(n)-(r)])%mod))%mod)
#define deb(x) cerr << "[" << #x << " " << x << << "]\n";
// #define int ll

ll power(ll x, ll y) {
     ll res = 1;x %= mod;
    while (y > 0) {
        if (y & 1)res = (res*x) % mod;
        y = y>>1;
        x = (x*x) % mod;
    }
    return res%mod;
}
/*================================================================*/




void solve() {
    int n;
    cin >> n;
while(n){if(n%10 == 7){cout << "Yes\n";return;}n/=10;}
    cout << "No";
}

signed main() {
    int t = 1;
    // cin >> t;
    while(t--){
        solve();
    }
}


Measured memory_bytes: 3600
#include <stdio.h>
int main(){
int n,low=0,temp,t,lv;
scanf("%d",&n);
for(int i=0;i<n;i++){
scanf("%d%d",&t,&temp);
if(t>low){
low=t;
lv=temp;
}
}
printf("%d\n",lv+low);
}


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

int main() {
    int D,G;
    int p[10];
    int c[10];
    cin >> D >> G;
    for(int i=0; i<D; ++i) cin >> p[i] >> c[i];

    int ans = 1001001001;
    for(int b=0; b < (1<<D); ++b) {
        int num = 0;
        long long pt = 0;
        for(int i=0; i<D; ++i) {
            if((b >> i) & 1) {
                num += p[i];
                pt += 100 * (i+1) *p[i] + c[i];
            }
        }
        if(pt >= G) {
            ans = min(ans,num);
            continue;
        } else {
            for(int i=D-1; i>=0; --i) {
                if(!((b >> i) & 1)) {
                    int tmp = min(1 + (G - pt - 1) / (100 * (i+1)), (long long)p[i]);
                    pt += 100 * (i+1) * tmp;
                    num += tmp;
                    if(pt >= G) {
                        ans = min(ans,num);
                        break;
                    }
                }
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b;
    cin>>a>>b;
    if(a<=b)
    {
        while(b--)
        {
            cout<<a;

        }

    }
    else
    {

        while(a--)
            cout<<b;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define ld long double
#define pb push_back
#define pob pop_back
#define vi vector<ll>
#define mp make_pair
#define sz size()
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define rep(i,n) for(ll i=0;i<n;i++)
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define maxx 10005
#define se second
#define fi first
#define sortv(v) sort(v.begin(),v.end());
#define w() ll _;cin>>_;while(_--)
#define edge pair<ll,ll>
#define pq priority_queue<ll>
#define M 10000007
#define Endl "\n"
using namespace std;



int main()
{
	fast;
	
	ll x,n;
	cin>>x>>n;
	ll i;
	ll a;
	set<ll>d;
	rep(i,n)
	{
		cin>>a;
		d.insert(a);
	}
	
	ll p=x;
	ll mi=0,ma=0;
	while(1)
	{
		if(d.count(p)==0)
		{
			ma=p;
			break;
		}
		p++;
	}
	p=x;
	while(1)
	{
		if(!d.count(p))
		{
			mi=p;
			break;
		}
		p--;
	}
	p=x;
//	cout<<ma<<" "<<mi<<endl;
	if(abs(ma-p)<abs(mi-p))
	{
		cout<<ma<<endl;
	}
	else
	{
		cout<<mi<<endl;
	}
	
	return 0;
}

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

int main(){
  int N; cin>>N;
  int ans;
  rep(i,N){
    int A; cin>>A;
    if(i) ans=__gcd(ans,A);
    else ans=A;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
n, a, b = map(int, input().split())
mod = 10**9+7
s = pow(2, n, mod)-1
x = 1
y = 1
for i in range(1, b+1):
    x = x*(n-i+1)%mod
    y = y*i%mod
    if i==a or i==b:
        s -= x*pow(y, mod-2, mod)

print(s%mod)

Measured memory_bytes: 3064
import java.io._
import java.util.StringTokenizer
import scala.util.control.Breaks.{breakable,break}

object Main extends App {
  val in = new InputReader(System.in)
  val pw = new PrintWriter(System.out)

  val N = in.next().toInt
  val a = new Array[Int](N)

  for (i <- 0 until N) {
    a(i) = in.next().toInt
  }

  var mx = a.max
  var mn = a.min

  def printer(ans: List[(Int, Int)]): Unit = {
    pw.println(ans.length)
    for (e <- ans)
      pw.println(s"${e._1} ${e._2}")
    pw.flush()
  }

  var ans: List[(Int, Int)] = List()

  if (Math.abs(mx) == 0 && Math.abs(mn) == 0) {
    println(0)
  }
  else if (Math.abs(mx) > Math.abs(mn)) {
    var ind = 0
    for (i <- 0 until N) {
      if(a(i) == mx)
        ind = i
    }

    for (i <- 0 until N) {
      ans = (ind+1, i+1) :: ans
    }

    for(i <- 1 until N) {
      ans = (i-1+1, i+1) :: ans
    }

    printer(ans.reverse)
  }
  else {
    var ind = 0
    for (i <- 0 until N) {
      if(a(i) == mn)
        ind = i
    }

    for (i <- 0 until N) {
      ans = (ind+1, i+1) :: ans
    }

    for(i <- (0 until N-1).reverse) {
      ans = (i+1+1, i+1) :: ans
    }

    printer(ans.reverse)
  }
}


class InputReader(stream: InputStream) {
  private val reader = new BufferedReader(new InputStreamReader(stream))
  private var tokenizer: StringTokenizer = new StringTokenizer(reader.readLine())
  def next(): String = {
    while (!tokenizer.hasMoreTokens()) {
      tokenizer = new StringTokenizer(reader.readLine())
    }
    tokenizer.nextToken()
  }
}


Measured memory_bytes: 27204
#include<bits/stdc++.h>
using namespace std;
int main(void){
  int n, k, q;
  cin >> n >> k >> q;
  int p[n + 1];
  fill(p, p + n + 1, q * -1);
  for(int i = 0; i < q; i++){
    int ans;
    cin >> ans;
    p[ans]++;
  }
  for(int i = 1; i <= n; i++){
    if(p[i] + k > 0) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
  return 0;
}
  

Measured memory_bytes: 1024
import java.util.ArrayList;
import java.util.Scanner;

public class Main{

    public static void main(String[] args) {
        
        Scanner scan = new Scanner(System.in);

        int n = scan.nextInt();
        ArrayList<String> list = new ArrayList<>();

        for(int i=0; i<n; i++){
            String s = scan.next();
            if(!list.contains(s)) list.add(s);
        }
        if(list.size() == 4) System.out.println("Four");
        else System.out.println("Three");
        

        scan.close();
    
    }

}

Measured memory_bytes: 23892
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define fio ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long long ll;

const int N = 55;
ll a[N];

int main() {
	fio;
	int n;
	cin >> n;
	for(int i = 0; i < n; ++i)
		cin >> a[i];
	int best = 0;
	for(int i = 1; i < n; ++i)
		if(abs(a[best]) < abs(a[i]))
			best = i;
	cout << 2*n-1 << "\n";
	for(int i = 1; i <= n; ++i) {
		cout << best+1 << " " << i << "\n";
	}
	if(a[best] < 0) {
		for(int i = n; i > 1; --i)
			cout << i << " " << i-1 << "\n";
	} else {
		for(int i = 1; i < n; ++i)
			cout << i << " " << i+1 << "\n";
	}
}

Measured memory_bytes: 256
use std::io;

fn main() {
    let last_index = input_number();
    let mut numbers = input_number();
    numbers.reverse();
    for (index, number) in numbers.iter().enumerate() {
        print!{"{}", number};
        if last_index[0] - 1 != index as i64 { print!(" ") }
    }
    println!("");
}

#[allow(dead_code)]
fn input_number() -> Vec<i64> {
    let mut input = String::new();

    io::stdin().read_line(&mut input)
        .expect("Failed to read line");

    let vec: Vec<i64> = input
        .split_whitespace()
        .map(|x| x.parse().unwrap_or(0))
        .collect();
    vec
}



Measured memory_bytes: 5032
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

    static Scanner scanner;

    public static void main(String[] args) {
        scanner = new Scanner(System.in);

        String S=gs();
        List<Integer> rs=new ArrayList<Integer>();
        List<Integer> ls=new ArrayList<Integer>();
        int[] ans=new int[S.length()];

        rs.add(0);
        for (int i=1;i<S.length();i++) {
            char bc=S.charAt(i-1);
            char nc=S.charAt(i);
            if(bc=='L' && nc=='R') {
                rs.add(i);
            } else if(bc=='R' && nc=='L') {
                ls.add(i);
            }
        }

        for (int i=0;i<rs.size();i++) {
            int s=rs.get(i);
            int e=S.length();
            if(i+1<rs.size()) e=rs.get(i+1);
            int m=ls.get(i);
            int num=e-s;
            if(num%2==0) {
            	ans[m-1]=num/2;
            	ans[m]=num/2;
            } else {
            	if((m-s)%2==1) {
            		ans[m-1]=Math.floorDiv(num, 2)+1;
            		ans[m]=Math.floorDiv(num, 2);
            	} else {
            		ans[m-1]=Math.floorDiv(num, 2);
            		ans[m]=Math.floorDiv(num, 2)+1;
            	}
            }
        }
        StringBuilder sb=new StringBuilder();
        for (int i=0;i<S.length();i++) {
            if(i!=0)sb.append(" ");
            sb.append(ans[i]);
        }

        System.out.println(sb);
    }

    // 文字列として入力を取得
    public static String gs() {
         return scanner.next();
    }

    // intとして入力を取得
    public static int gi() {
         return Integer.parseInt(scanner.next());
    }

    // longとして入力を取得
    public static long gl() {
         return Long.parseLong(scanner.next());
    }

    // doubleとして入力を取得
    public static double gd() {
         return Double.parseDouble(scanner.next());
    }
}

Measured memory_bytes: 42944
n, m = map(int, input().split())
inf = 10**9+7
ans = 0
if abs(n-m) >= 2:
  pass
else:
  ans = 1
  for i in range(1, n+1):
    ans *= i
    ans %= inf
  for i in range(1, m+1):
    ans *= i
    ans %= inf
  if n == m:
    ans *= 2
    ans %= inf
print(ans)

Measured memory_bytes: 3064
import java.util.Scanner;
import java.util.Random;;
import java.util.Arrays;
import java.lang.Math;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);

        int N = scan.nextInt();
        int A = scan.nextInt();
        int B = scan.nextInt();

        long h[] =new long[N];
        for(int i = 0; i < N; i++){
            h[i] = scan.nextLong();
        }
        Arrays.sort(h);

        long l = 0;
        long r = 1000000000;

        while(l < r) {
            long m = (r + l) / 2;
            //System.out.println(m);
            long need = 0;
            for (int i = 0; i < N; i++) {
                long remind = h[i] - (B * m);
                if (remind > 0) {
                    need += (remind + A - B - 1 )/ (A - B);
                }
            }
            if (need > m) {
                l = m+1;
            } else {
                r = m;
            }
        }
        System.out.println(l);
    }
}


Measured memory_bytes: 50744
package main

import (
	"fmt"
	"math"
)

func main() {
	var (
		N int
		S string
	)
	fmt.Scan(&N, &S)
	counts := make([]int, N-1)

	for i := 1; i < N; i++ {
		alphabets := make(map[byte]bool, 26)
		left := S[0:i]
		right := S[i:N]
		for j := 0; j < len(left); j++ {
			if alphabets[left[j]] {
				continue
			} else {
				alphabets[left[j]] = true
			}
			for k := 0; k < len(right); k++ {
				if left[j] == right[k] {
					counts[i-1]++
					break
				}
			}
		}
	}
	fmt.Println(maxSlice(counts))
	return
}

func maxSlice(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 strSearch(a []string, b string) bool {
	for i := 0; i < len(a); i++ {
		if a[i] == b {
			return true
		}
	}
	return false
}


Measured memory_bytes: 512