akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<list>
#include<cstdint>
#include<bits/stdc++.h>
#include<queue>
#include<set>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep_r(i, n) for(int i = n-1; i >= 0; i--)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((ll)(x).size())
#define bit(n) (1LL<<(n))
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define INF bit(60)
#define pb push_back
#define mod 1000000007

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

using namespace std;
using uif=uint_fast64_t;
using ll=long long int;

int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mod;a=1ll*a*a%mod;}while(b>>=1);return ans;}
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}

int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};


#define FACSIZE 2002

ll invfac[FACSIZE];
ll fac[FACSIZE];

ll mod_pow(ll ,ll );
ll mod_add(ll ,ll );
ll mod_mul(ll ,ll );
ll mod_div(ll ,ll );
void make_fact(ll );
void make_invfact(ll );



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

  sort(begin(l),end(l));
  ll ans=0;
  for(ll i=0;i<n;i++){
    for(ll j=i+1;j<n;j++){

      ll two=l[i]+l[j];
      auto itr=lower_bound(begin(l),end(l),two);
      ll num=distance(begin(l)+j,itr)-1;
      if(n>0) ans+=num;
    }
  }
  cout << ans << endl;

  return 0;

}

ll mod_pow(ll x,ll r){
  if(r==0) return 1;
  else if(r==1) return x%mod;
  else if(r%2==0){
    ll t=mod_pow(x,r/2)%mod;
    return t*t %mod;
  } 
  else{
    ll t=mod_pow(x,r/2)%mod;
    ll k= t*t %mod;
    return k*x%mod;
  } 
}
ll mod_add(ll a,ll b){
  return (a+b)%mod;
}

ll mod_mul(ll a,ll b){
  return (a*b)%mod;
}

ll mod_div(ll a,ll b){
  return mod_mul(a,mod_pow(b,mod-2));
}

void make_fact(ll n){
  fac[0]=1;
  rep(i,n){
    fac[i+1]=mod_mul(fac[i],i+1);
  }  
}

void make_invfact(ll n){
  invfac[n]= mod_pow( fac[n] ,mod-2);
  for(int i=n-1;i>=0;i--){
    invfac[i]=mod_mul(invfac[i+1],i+1);
  }

}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define min_3(a,b,c) min(a,min(b,c))
#define max_3(a,b,c) max(a,max(b,c))
#define nout(ans) cout << (ans) << "\n"
#define sout(ans) cout << (ans) << " "
using namespace std;

const double pi = 3.14159265359;
const ll INF = 1e12;
const ll MOD = 1e9 + 7;
const ll N = 2e5+5; 
/*
Decimal Places: cout << fixed << setprecision(n) << ans << endl
*/

bool compare(const pair<int, int>&i, const pair<int, int>&j)
{
    return i.second < j.second;
}

ll raise(ll a, ll b) {
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}


ll n,m, x, y, vis[N], cnt[N]; set <ll> adj[N];

void dfs(int s) {
	cnt[s]=1;
	for (auto u : adj[s]) {
		if (vis[u]) continue;
		vis[u]=1;
		dfs(u);
		cnt[s]+=cnt[u];
	}
}

void solve()
{
	ll ans=0;
    cin >> n >> m;
    for (int i=0; i<m; ++i) {
    	cin >> x >> y;
    	adj[x].insert(y); adj[y].insert(x);
    }

    for (int i=1; i<=n; ++i) {
    	if (!vis[i]) {
    		vis[i]=1;
    		dfs(i);
    		ans=max(ans,cnt[i]);
    	}
    }nout(ans);
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int t = 1;
    //cin >> t;
    for (int i=1; i<=t; i++)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 47392
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
total = 0
before = 0
for i in range(n + 1):
    nowkill = 0
    if i != n:
        nowkill = b[i]
    nowneedkill = a[i]
    if nowneedkill <= before:
        before = nowkill
        total = total + nowneedkill
    else:
        nowkill = before + nowkill
        if nowkill > nowneedkill:
            before = nowkill - nowneedkill
            total = total + nowneedkill
        else:
            total = total + nowkill
            before = 0
print(total)

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

int main()
{
    int n,l;
    cin >> n >> l;
    string s[n];
    for(int i = 0; i < n; i++)
        cin >> s[i];
    
    sort(s,s+n);
    
    for(string i : s) cout << i;
    cout << endl;
    
    return 0;
}

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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}
ll nextLong() { ll x; scanf("%lld", &x); return x;}

const int MAX_N = 212345;
vector<int> g[MAX_N];
ll A[MAX_N];
ll ans[MAX_N];


void dfs(int cur, int prev, ll sum) {
  ans[cur] = sum + A[cur];
  for (int nxt : g[cur]) if (nxt != prev) {
    dfs(nxt, cur, sum + A[cur]);
  }
}

int main2() {
  REP(i, MAX_N) g[i].clear();
  CLR(A, 0);

  int N = nextInt();
  int Q = nextInt();

  REP(i, N-1) {
    int a = nextInt() - 1;
    int b = nextInt() - 1;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  REP(i, Q) {
    int x = nextInt() - 1;
    int v = nextInt();
    A[x] += v;
  }

  CLR(ans, 0);
  dfs(0, -1, 0);
  REP(i, N) {
    if (i > 0) printf(" ");
    printf("%lld", ans[i]);
  }
  printf("\n");
  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}

Measured memory_bytes: 29440
import sys
INF = 1 << 60
MOD = 10**9 + 7 # 998244353
sys.setrecursionlimit(2147483647)
input = lambda:sys.stdin.buffer.readline().rstrip()

class SegmentTree(object):
    def __init__(self, A, dot, unit):
        n = 1 << (len(A) - 1).bit_length()
        tree = [unit] * (2 * n)
        for i, v in enumerate(A):
            tree[i + n] = v
        for i in range(n - 1, 0, -1):
            tree[i] = dot(tree[i << 1], tree[i << 1 | 1])
        self._n = n
        self._tree = tree
        self._dot = dot
        self._unit = unit

    def __getitem__(self, i):
        return self._tree[i + self._n]

    def update(self, i, v):
        i += self._n
        self._tree[i] = v
        while i != 1:
            i >>= 1
            self._tree[i] = self._dot(self._tree[i << 1], self._tree[i << 1 | 1])

    def add(self, i, v):
        self.update(i, self[i] + v)

    def sum(self, l, r):
        l += self._n
        r += self._n
        l_val = r_val = self._unit
        while l < r:
            if l & 1:
                l_val = self._dot(l_val, self._tree[l])
                l += 1
            if r & 1:
                r -= 1
                r_val = self._dot(self._tree[r], r_val)
            l >>= 1
            r >>= 1
        return self._dot(l_val, r_val)

from operator import add, itemgetter
def resolve():
    n, q = map(int, input().split())
    C = list(map(lambda x : int(x) - 1, input().split()))

    A = [0] * n
    used = [0] * n
    for i, c in enumerate(C):
        if used[c]:
            continue
        used[c] = 1
        A[i] = 1
    tree = SegmentTree(A, add, 0)

    next = [-1] * n
    used = [-1] * n
    for i in range(n - 1, -1, -1):
        c = C[i]
        if used[c] != -1:
            next[i] = used[c]
        used[c] = i

    queries = [None] * q
    for i in range(q):
        l, r = map(int, input().split())
        queries[i] = (l - 1, r, i)
    queries.sort(key = itemgetter(0), reverse = 1)

    ans = [0] * q
    for l in range(n):
        while queries and queries[-1][0] == l:
            l, r, i = queries.pop()
            ans[i] = tree.sum(l, r)
        if next[l] != -1:
            tree.add(next[l], 1)

    print(*ans, sep = '\n')
resolve()

Measured memory_bytes: 224868
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
#include <functional>
#include <bitset>

using namespace std;

int main()
{
	//// 1つの値を読み込み
	long N;
	cin >> N;
	string S;
	cin >> S;

	string output;
	for (int ic = 0; ic < (int)S.length(); ic++)
	{
		//1つ取得
		char buf = S[ic];

		//何番目か検索
		int count = 0;
		for (char moji = 'A'; moji <= 'Z'; ++moji)
		{
			if (buf == moji)
			{
				int AnsIndex = count + N;
				//N足した文字を探す
				AnsIndex = AnsIndex % 26;
				//stringのアウトプット用に入れる
				char bbb = 'A'+AnsIndex;
				output.push_back(bbb);
				break;
			}
			count++;
		}
	}

	cout << output;

	return 0;

}


Measured memory_bytes: 256
// Template from https://techracho.bpsinc.jp/jhonda/2019_08_05/78537

// input macro for competive-programming from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };

    ($iter:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, bytes) => {
        read_value!($iter, String).into_bytes()
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    use std::io::Read;
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();

    println!("{}", solve(&s));
}

macro_rules! test {
    ($($input:expr => $output:expr),* $(,)*) => {
        #[test]
        fn solve_test() {
            $(
                assert_eq!(solve($input), $output);
            )*
        }
    };
}

test! {
r#"1"# => "1",
r#"2"# => "8",
r#"3"# => "27",
}

fn solve(src: &str) -> String {
    input! {
        source = src,
        n: usize,
    }
    n.pow(3).to_string()
}

Measured memory_bytes: 4352
#include <iostream>
//#include <iomanip>
//#include <string>
//#include <vector>
//#include <algorithm>
//#include <utility>
//#include <set>
//#include <map>
//#include <queue>
//#include <deque>
//#include <bitset>
//#include <math.h>
using namespace std ;
using ll = long long ;
//using ld = long double ;
//using vll = vector<ll> ;
//using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;

//ll mod = 1000000007 ;
//long double pie = acos(-1) ;

//void yorn(bool a){if(a) cout << "Yes" << endl ; else cout << "No" << endl ;}
//void YorN(bool a){if(a) cout << "YES" << endl ; else cout << "NO" << endl ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void mysort(vector<long long> &a){sort(a.begin(),a.end()) ;}
//void myrev(vector<long long> &a){reverse(a.begin(),a.end()) ;}

int main(){
	ll n,m ;
	cin >> n >> m ;
	if(n*2<m) cout << n+(m-n*2)/4 << endl ;
	else cout << m/2 << endl ;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <cmath>
#include <iomanip>
#include <deque>
#include <queue>
#include <unordered_map>
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;
ll intpow(ll N, ll P){
    if(P==0) return 1;
    if(P%2==0){
        ll t = intpow(N, P/2);
        return t*t;
    }
    return N * intpow(N, P-1);
}
ll modpow(ll N, ll P,ll k){
    if(P==0) return 1;
    if(P%2==0){
        ll t = modpow(N, P/2,k)%k;
        return t*t%k;
    }
    return N * modpow(N, P-1,k)%k;
}
ll modkai(ll n,ll m,ll k){//n*(n-1)*(n-2)*...(m+1)%k
    if(n == m)return 1;
    return modkai(n-1,m,k)*n%k;
}
ll mod_cnb(ll n,ll m,ll k){//nCm%k,kは十分大きい素数
  int m_=modkai(m,0,k);
  return modkai(n,n-m,k)*modpow(m_,k-2,k)%k;
}
ll gcd(ll n,ll m){
    ll n_ = max(n,m);
    ll m_ = min(n,m);
    if(n_%m_ == 0)return m_;
    return gcd(m_,n_%m_);
}
ll lcm(ll n,ll m){
    return n*m/gcd(n,m);
}
int main(){
    double n,m;cin>>n>>m;
    vector<double>a(n);
    double sum=0;
    rep(i,n)cin>>a[i],sum+=a[i];
    sort(a.begin(),a.end(),greater<double>());
    if(a[m-1]/sum<0.25/m)cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
}

Measured memory_bytes: 256
from itertools import *

def main():
	n, c, *L = map(int, open(0).read().split())
	a = [0] * (10 ** 5 + 1)
	bef = (0, 0)
	for c, s, t in sorted((c, s, t) for s, t, c in zip(*[iter(L)] * 3)):
		a[s - 1 + (bef==(c, s))] += 1
		a[t] -= 1
		bef = (c, t)
	print(max(accumulate(a)))

if __name__=="__main__":
	main()

Measured memory_bytes: 30908
#include <bits/stdc++.h>
#define x first
#define y second
#define MAX_N 100000
#define P 1000000007
using namespace std;
typedef long long lnt;
typedef pair<int,int> pnt;
template <class T> inline void read(T &x) {
	x = 0; int c = getchar(), f = 1;
	for (; !isdigit(c); c = getchar()) if (c == 45) f = -1;
	for (; isdigit(c); c = getchar()) (x *= 10) += f*(c-'0');
}
int N, M, n, m, a[MAX_N+5], b[MAX_N+5];
int val[MAX_N+5]; pnt p[MAX_N+5]; lnt tr[MAX_N+5];
void add(int p, lnt c) {for (; p <= m; p += (p&-p)) (tr[p] += c) %= P;}
lnt sum(int p) {lnt ret = 0; for (; p; p -= (p&-p)) (ret += tr[p]) %= P; return ret;}
bool cmp(const pnt &a, const pnt &b) {return a.x == b.x ? a.y > b.y : a.x < b.x;}
int main() {
	read(N), read(M);
	for (int i = 1; i <= N; i++) read(a[i]);
	for (int i = 1; i <= M; i++) read(b[i]);
	for (int i = 1; i <= N; i++) if (a[i] > b[1] && a[i] < b[M]) {
		int r = (int)(lower_bound(b+1, b+M+1, a[i])-b), l = r-1;
		if (a[i] ^ b[r]) p[++n] = pnt(a[i]-b[l], b[r]-a[i]);
	}
	for (int i = 1; i <= n; i++) val[i] = p[i].y;
	sort(val+1, val+n+1), m = (int)(unique(val+1, val+n+1)-val-1);
	for (int i = 1; i <= n; i++)
		p[i].y = (int)(lower_bound(val+1, val+m+1, p[i].y)-val);
	sort(p+1, p+n+1, cmp), n = (int)(unique(p+1, p+n+1)-p-1);
	lnt tot = 1, f;
	for (int i = 1; i <= n; i++)
		(tot += (f = sum(p[i].y-1)+1)) %= P, add(p[i].y, f);
	return printf("%lld\n", tot), 0;
}


Measured memory_bytes: 2560
N=int(input())
S=list(map(int,input().split()))

select=len(S)
goukei=10**10
for i in range(1,100):
    kouho=0
    for j in range(select):
        kouho+=(S[j]-i)**2
    
    if kouho<goukei:
        goukei=kouho
    
print(goukei)



Measured memory_bytes: 2940
function main()
	lines=readlines()
	N,C=map(x->parse(Int,x),split(shift!(lines)))
	D=Array{Int}(C,C)
	for i=1:C
		d=map(x->parse(Int,x),split(shift!(lines)))
		for j=1:C
			D[i,j]=d[j]
		end
	end
	cnt=zeros(Int,3,C)
	for i=1:N
		d=map(x->parse(Int,x),split(shift!(lines)))
		for j=1:N
			cnt[mod1(i+j,3),d[j]]+=1
		end
	end
	ans=1145141919810
	for i=1:C,j=1:C,k=1:C
		if i==j||j==k||k==i
			continue
		end
		ret=0
		for l=1:C
			ret+=D[l,i]*cnt[1,l]
			ret+=D[l,j]*cnt[2,l]
			ret+=D[l,k]*cnt[3,l]
		end
		ans=min(ans,ret)
	end
	println(ans)
end
main()


Measured memory_bytes: 187508
#include <stdio.h>

int main(void)
{
	int a, b, c, d;
	char str[1001];
	
	fgets(str, 1001, stdin);
	
	a = 0;
	
	for (a = 0; str[a] != '\0'; a++) {
		if (str[a] == 'a' && str[a + 1] == 'p' && str[a + 2] == 'p' && str[a + 3] == 'l' && str[a + 4] == 'e') {
			str[a] = 'p';
			str[a + 1] = 'e';
			str[a + 2] = 'a';
			str[a + 3] = 'c';
			str[a + 4] = 'h';
		}
		
		else if (str[a] == 'p' && str[a + 1] == 'e' && str[a + 2] == 'a' && str[a + 3] == 'c' && str[a + 4] == 'h') {
			str[a] = 'a';
			str[a + 1] = 'p';
			str[a + 2] = 'p';
			str[a + 3] = 'l';
			str[a + 4] = 'e';
		}
	}
	
	printf("%s", str);
	return (0);
}

Measured memory_bytes: 524
using System;
using System.Collections.Generic;

class Program
{
    static void Main(string[] args)
    {
        string[] str = Console.ReadLine().Split(' ');

        int W = int.Parse(str[0]);
        int H = int.Parse(str[1]);
        int x = int.Parse(str[2]);
        int y = int.Parse(str[3]);
        int r = int.Parse(str[4]);

        if(( x - r ) < 0 || ( x + r ) > W)
        {
             Console.WriteLine("No");
        }
        else if(( y - r ) < 0 || ( y + r ) > H)
        {
            Console.WriteLine("No");
        }
        else
        {
            Console.WriteLine("Yes");
        }

    }
}

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

int main() {
    int a,b;
    cin >> a >> b;
    if(a <= 0 && 0 <= b) {
        cout << "Zero" << endl;
    } else if(a < 0 && (b - a + 1) % 2 == 1) {
        cout << "Negative" << endl;
    } else {
        cout << "Positive" << endl;
    }
}

Measured memory_bytes: 256
from functools import reduce
from operator import mul
def prime_factorize_dict(n, N):
    d = {1: 1}
    while not n & 1:
        d[2] = d.get(2, 0) + 1
        n >>= 1
    f = 3
    while f * f <= n:
        if not n % f:
            d[f] = d.get(f, 0) + 1
            n //= f
        else:
            f += 2
    if n != 1:
        d[n] = d.get(n, 0) + 1
    return d

N, P = map(int, input().split())
print(reduce(mul, (factor ** (power // N) for factor, power in prime_factorize_dict(P, N).items())))

Measured memory_bytes: 3572
typedef unsigned char C,*S;typedef int I;typedef long long J;typedef double F;typedef void V;typedef unsigned long long UJ;
#define R return
#define P(b,a...)   if(b)return(a);
#define N(n,a...)   {I i=0,_n=(n);while(i<_n){a;++i;}}
#define W(b...)     while((b))
#define $(b,a...)   if(b){a;}else           
#define C(i,a...)   case i:{a;}break;       
#define S(i,c,a...) switch(i){c default:a;} 

#define MN(a,b)    ({typeof(a)_a=(a);typeof(a)_b=(b);_a<_b?_a:_b;})
#define MX(a,b)    ({typeof(a)_a=(a);typeof(a)_b=(b);_a>_b?_a:_b;})

#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define O printf
#define SC scanf
I main(){C s[250];J k,i; // freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
 SC("%s\n%lld",s,&k);k--;for(i=0;s[i]=='1';i++);O("%c\n",k<i?'1':s[i]);} 

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define ll long long
#define ld long double
using namespace std;
ll n, x;
ld s;
int  main()
{
    cout << fixed << setprecision(10);
    cin >> n;
    for(int i = 0; i < n; i++)
        cin >> x, s += ((ld)1.0 / (ld)x);
    cout << (ld)1.0 / s << endl;
    return 0;

}


Measured memory_bytes: 256
//int a = stoi(c); 文字列をintへ
//小文字から大文字
//transform(a.begin(), a.end(), a.begin(), ::toupper);
//途中の出力をそのまま残さない
//数値計算 個数以外はdouble
//map<キー,値> p は辞書。p[キー] = 値
//map 全探索
//auto begin = p.begin(), end = p.end();
//for (auto it = begin; it != end; it++) {}
//mapのキー：it->first mapのバリュー：it->second
//絶対値 abs()
//入力は空白で切れる
//大文字判定 isupper(文字) 小文字判定 islower(文字)
//do{}while(next_permutation(ALL(配列)))
//while(N)で回すとき、Nはコピーを作っておく
//小文字に対応する文字コード：S[i] - 'a'
//文字コード→小文字：(char)(数字+'a')
//グラフの距離:隣接行列で扱う
//等価なものに変換する思考
//bool型　初期値はTrue
//島渡りの問題：中間ノードに着目
//配列はvector<>を使う：意味わからないエラーがなくなる。
//背反な事象にちゃんとわける
//チェックリストはマップを使う
//数が大きい時の比較はstring型で行う
//全て0になったか調べたい->0になるたびにcntする
//またはかかつか
//例外処理は最初にする
//x = p^m + q^n...の約数の個数:(n+1)*(m+1)....
//N!のどの素因数で何回割れるか
//⇔1~Nまでの数がそれぞれどの素因数で何回割り切れるかの和
//パズルの問題->一般化して全探索
//数が大きい時のせぐふぉはコードテストで試してみる
//スペルミスに注意
//stack<ll> s;
//s.push(要素);s.top();s.pop();
//queue<ll> q;
//q.push(要素);q.front();q.pop();
#include <bits/stdc++.h>
#define rep(i,N) for(int i = 0; i < N;i++)
#define ALL(a) (a).begin(),(a).end()
#define ll long long int
using namespace std;

//円周率
const double PI = 3.14159265358979323846;
//割るやつ
const ll M = (pow(10, 9) + 7);

// K進数でのNの桁数
ll dig(ll N, ll K) {
	ll dig = 0;
	while (N) {
		dig++;
		N /= K;
	}
	return dig;
}
// a,bの最大公約数
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;
}

//nC2の計算
ll C(ll N) {
	return N * (N - 1) / 2;
}

//階乗計算
ll f(ll n) {
	if (n == 0 || n == 1) return 1;
	else return (n * f(n - 1)) % M;
}

//Nをdで何回割れるか
ll divcnt(ll N, ll d) {
	ll ans = 0;
	while (1) {
		if (N%d == 0) {
			ans++;
			N /= d;
		}
		else break;
	}

	return ans;
}

//素数判定
bool prime(ll num) {
	if (num < 2) return false;
	else if (num == 2) return true;
	else if (num % 2 == 0) return false;
	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2) {
		if (num % i == 0) return false;
	}
	return true;
}

//フィボナッチ数列
vector<ll> memo(pow(10, 6) + 1);
ll fibo(ll n) {
	if (n == 1) return 1;
	else if (n == 2) return 1;
	else if (memo[n] != 0) return memo[n];
	else return memo[n] = fibo(n - 1) + f(n - 2);
}

int main() {
	double r; cin >> r;
	cout << 2 * PI * r << endl;
}

Measured memory_bytes: 11028
#include<cstdio>
#include<algorithm>
using namespace std;
long long n,a,b,s[200000],f[200000],g[200000],mod=1000000007;
int main()
{
	scanf("%lld%lld%lld",&n,&a,&b);
	if(a>b)swap(a,b);
	for(int i=1;i<=n;i++)scanf("%lld",s+i);
	s[0]=-b;
	f[0]=g[0]=1;
	for(int i=2;i<n;i++)
		if(s[i+1]-s[i-1]<a){puts("0");return 0;}
	long long sf=0,sg=0,pf=0,pg=0;
	for(int i=2;i<=n;i++)
	{
		for(;pf<i-1&&s[i]-s[pf]>=a;pf++)sf=(sf+f[pf])%mod;
		for(;pg<i-1&&s[i]-s[pg]>=b;pg++)sg=(sg+g[pg])%mod;
		f[i-1]=sg;g[i-1]=sf;
		if(s[i]-s[i-1]<b)sf=0,pf=i-1;
		if(s[i]-s[i-1]<a)sg=0,pg=i-1;
		//printf("sf=%lld,sg=%lld,pf=%lld,pg=%lld\n",sf,sg,pf,pg);
	}
	for(int i=pf;i<n;i++)sf=(sf+f[i])%mod;
	for(int i=pg;i<n;i++)sg=(sg+g[i])%mod;
	printf("%lld\n",(sf+sg)%mod);
	//printf("pf=%lld,pg=%lld\n",pf,pg);
	//for(int i=0;i<=n;i++)printf("(f,g)[%d]=%lld,%lld\n",i,f[i],g[i]);
	return 0;
}

Measured memory_bytes: 3584
from collections import defaultdict
N, K = map(int, input().split())
Q = defaultdict(int)
for i in range(N):
    a, b = map(int, input().split())
    Q[a] += b

current = 0
for q in sorted(Q.items()):
    if current + q[1] < K:
        current += q[1]
    else:
        print(q[0])
        break

Measured memory_bytes: 14940
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	ll n;cin>>n;
	set<ll> st;
	st.insert(n);
	for(ll i=2;i*i<=n;i++){
		if(n%i==0){
			ll t=n;
			while(t%i==0){
				if(t/i%i==1) st.insert(i);;
				t/=i;
			}
			if(t==1) st.insert(i);
		}
	}
	for(ll i=1;i*i<=n-1;i++){
		if((n-1)%i==0){
			st.insert(i);
			st.insert((n-1)/i);
		} 
	}
	st.erase(1);
	cout<<st.size()<<"\n";
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef  long long ll;
typedef  vector<int> vi;
typedef  pair<int,int> pii;
typedef  pair<int,string> pis;
double pi=3.1415926535898;
#define speed      ios::sync_with_stdio(false);cin.tie(NULL); cout.tie(NULL);
#define lop(i,n)   for(int i=0;i<int(n);i++)
#define rep(i,a,b) for(int i=a;i<=int(b);++i)
#define rng(i,a,b) for(int i=a;i>=int(b);i--)
#define ms(x,a)    memset(x,a,sizeof(x))
#define all(x)     (x).begin(),(x).end()
#define sz(x)      int(x.size())
#define pb         push_back
#define r0         return 0;
#define CC         continue;
#define bb(x)      cerr<< x <<endl;
#define F          first
#define S          second       //  __builtin_popcount;
//freopen("output.txt","w",stdout),freopen("input.txt","r",stdin);
const ll M  = 1e9+7 ;
//const int N = 100100;
const int inf = INT_MAX;
const double eps = 1e-7;
//////////////////////    Hi    ^_^  hack me if you can :P
int n, a,b;
int dis[3][100100];
int vis[100100];
vector <int > v[100100];
void bfs(int s,int p)
{
    queue < int > q;
    q.push(s);
    dis[p][s]=0;
    while(sz(q))
    {
        int u = q.front();
        q.pop();
 
        for (auto c:v[u])
        {
            if (dis[p][c] > dis[p][u]+1 )
            {
                dis[p][c] = dis[p][u]+1;
                q.push(c);
            }
        }
    }
 
}
int dfs(int u, int p)
{
    if(vis[u])return 0;
    vis[u]=1;
    if ( dis[p][u] > dis[1+p][u])
    {
        return 0;
    }
    int res = 0;
    res = 1;
    for (auto c : v[u])
    {
        res += dfs(c,p);
    }
    return res;
}
int main()
{
    //speed;
    cin >> n;
    lop(i,n-1)
    {
        cin >> a >> b;
        v[a].pb(b);
        v[b].pb(a);
    }
    rep(i,1,2) rep(j,1,n) dis[i][j]=200005;
    
    bfs(1,1);
    bfs(n,2);
 
    int ans = dfs(1,1);
 
    if ( ans > n-ans ) cout << "Fennec";
    else cout << "Snuke";
 
    return 0;
}

Measured memory_bytes: 8448
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define sp(n) cout << fixed << setprecision(n)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
using namespace std;
int main(void){
   int h1,m1,h2,m2,k;cin>>h1>>m1>>h2>>m2>>k;
   if(h1>h2||(h1==h2&&m1>m2)) h2+=24;
   int h=(h2-h1)*60,m=(m2-m1);
   int res=h+m;
   res-=k;
   cout<<res<<endl;
}

Measured memory_bytes: 3600
n = int(input())
s = [int(input()) for _ in range(n)]

s.sort()
ans = sum(s)
flag = True
if not ans%10:
    flag = False
    for i in s:
        if i%10:
            ans -= i
            flag = True
            break

if not flag:
    ans = 0

print(ans)

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



int main(){
    int A,B;
    cin >> A >> B;
    int count = 0;
    for(int i = 0;i<=B-A;i++){
        int C = A + i;
        int a = C/10000;
        int b = C/1000 - a*10;
        int c = C/100 - a*100 - b*10;
        int d = C/10 - a*1000 - b*100 - c*10;
        int e = C%10;
        if(a == e && b == d){
            count++;
        }
    }
    cout << count << endl;
}

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;

const ll LongINF=1e13+7;
const int INF=1e9+7;
const int dx[]={0,1,0,-1};
const int dy[]={1,0,-1,0};

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, class Y>T GCD(T a, Y b){if(a<b){int c=a;a=b;b=c;}if (a % b == 0){return b;}return GCD(b, a % b);}
template<class T,class Y>T LCM(T a,Y b){return (a*b)/GCD(a,b);}
void clear(queue<pair<int, int>> &q){queue<pair<int, int>> empty;swap(q, empty);} //queueの中身の型は適時変更を忘れない

using vi=vector<int>;
using vii=vector<vi>;

#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define rv reverse
#define ALL(a) (a).begin(),(a).end()
#define decimal(x) fixed<<setprecision(x)


int main(){
    ll N;
    ll Red=0,Green=0,Blue=0;
    string S;
    cin>>N>>S;
    rep(i,N){
        if(S[i]=='R')Red++;
        else if(S[i]=='G')Green++;
        else if(S[i]=='B')Blue++;
    }
    ll sum=Red*Green*Blue;
    //cout<<sum<<endl;
    rep(i,2000){
        rep(j,N){
            if(j-i<0||i+j>=N)continue;
            if(S[j]!=S[j-i]&&S[j]!=S[j+i]&&S[j+i]!=S[j-i]){
                //cout<<j-i<<" "<<j<<" "<<j+i<<endl;
                sum--;
            }
        }
    }

    cout<<sum<<endl;

    return 0;
}

//a=97,z=122


Measured memory_bytes: 3624
import collections

n=int(input())
a=input().split()

a_odd=list([int(a[i]) for i in range(n) if i%2==1])
a_even=list([int(a[i]) for i in range(n) if i%2==0])

ca_odd=collections.Counter(a_odd)
ca_even=collections.Counter(a_even)

def count_change(a_sublist, i):
    return len([num for num in a_sublist if num!=i])

loop_set_a_odd=set ([i[0] for i in ca_odd.most_common()[0:min(len(ca_odd),2)]])
loop_set_a_even=set( [ i[0] for i in ca_even.most_common()[0:min(len(ca_even),2)]])

temp=n
for i in loop_set_a_odd:
    for j in loop_set_a_even:
        if i!=j:
            c=count_change(a_odd,i)+count_change(a_even,j)
            if temp>c:
                temp=c

if temp==n:
    print(len(a_odd))
else:
    print(temp)

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

int main(){
    int h, w, d;
    cin >> h >> w >> d;

    vector<vector<pair<int, int>>> grid(d, vector<pair<int, int>>(h*w/d+1));
    vector<vector<int>> a(h, vector<int>(w));
    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            cin >> a[i][j];
            grid[a[i][j] % d][a[i][j] / d] = make_pair(i,j);
        }
    }

    int q;
    cin >> q;
    vector<int> l(q), r(q);
    for(int i=0; i<q; i++){
        cin >> l[i] >> r[i];
    }

    vector<vector<int>> data(d, vector<int>(h*w/d+1));
    for(int i=0; i<d; i++){
        for(int j=1; j<h*w/d+1; j++){
            data[i][j] = abs(grid[i][j].first - grid[i][j-1].first)
                       + abs(grid[i][j].second - grid[i][j-1].second);
        }
    }

    // cumulative sum for each remainder
    for(int i=0; i<d; i++){
        for(int j=1; j<h*w/d+1; j++){
            data[i][j] += data[i][j-1];
        }
    }

    // solve
    for(int i=0; i<q; i++){
        int j = l[i] % d;
        cout << data[j][r[i]/d] - data[j][l[i]/d] << endl;
    }
    
    return 0;
}

Measured memory_bytes: 11392
/*There's a possibility*/
/*but stop sucking first*/
#define dbg(...) ; 
#define db(...) ; 
#include "bits/stdc++.h"
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define f(i,a,b) for(i=a;i<b;i++)
#define fr(i,a,b) for(i=a;i>=b;i--)
#define endl '\n'
#define tst cout<<'*';
#define ll long long int
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mod 1000000007
using namespace std;
 
char grid[1005][1005];
int dp[1005][1005];

int main()
{
    fast;
    int h,w,i,j;
    cin>>h>>w;
    f(i,0,h)
        f(j,0,w)
            cin>>grid[i][j];
    f(j,0,w)
        if(grid[0][j]=='.')
            dp[0][j]=1;
        else break;
    f(i,0,h)
        if(grid[i][0]=='.')
            dp[i][0]=1;
        else break;


    f(i,1,h)
        f(j,1,w)
            (grid[i][j]=='#')?dp[i][j]=0:dp[i][j]=(dp[i-1][j]+dp[i][j-1])%mod;

    cout<<dp[h-1][w-1];
}

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

int main() {
    int N;
    cin >> N;
    vector<int> X(N), sX(N);
    rep(i, N) cin >> X[i];
    rep(i, N) sX[i] = X[i];
    sort(sX.begin(), sX.end());

    for(int i=0; i<N; i++) {
        if(X[i] <= sX[N/2-1]) cout << sX[N/2];
        else cout << sX[N/2-1];
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 3712
from queue import Queue
from sys import stdin, stdout
input = stdin.readline
print = stdout.write

n = int(input())
adj = [[] for _ in range(n + 1)]
edges = []
for _ in range(n - 1):
    a, b = map(int, input().split())
    adj[a].append(b)
    adj[b].append(a)
    edges.append((a, b))

root = 0
maxdeg = 0
for i in range(1, n + 1):
    if len(adj[i]) > maxdeg:
        maxdeg = len(adj[i])
        root = i

print(str(maxdeg) + '\n')
colors = [i+1 for i in range(maxdeg)]

hashc = {}
q = Queue()
q.put((root, -1, -1))
while not q.empty():
    u, par, col = q.get()
    i = 0
    for child in adj[u]:
        if child == par: continue
        if colors[i] == col: i += 1
        hashc[(u, child)] = colors[i]
        hashc[(child, u)] = colors[i]
        q.put((child, u, colors[i]))
        i += 1

for e in edges:
    print(str(hashc[e]) + '\n')


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

#define FOR(i,a,b)  for(ll (i)=a;(i)<(b);++(i))
#define RFOR(i,a,b) for(ll (i)=a;(i)>=(b);--(i))
#define REP(i,n)    FOR(i,0,n)
#define RREP(i,n)   RFOR(i,n,0)
#define ALL(v)      (v).begin(),(v).end()
#define BIT(n)      (1LL<<(n))
#define IN(x,l,r)   ((l)<=(x)&&(x)<=(r))
#define LEN(s)      (string(s)).length()
#define NPOS        string::npos
#define SHOW(x)     cout<<#x<<" = "<<x<<endl
#define SORT(v)     sort(ALL(v))
#define SZ(v)       (ll)(v).size()
#define UNIQ(v)     SORT(v);(v).erase(unique(ALL(v)),(v).end())
#define PERM(v)     for(bool p=1;p;p=next_permutation(ALL(v)))
#define PQ(T)       priority_queue<T,vector<T>,greater<T>>

template<class T>string join(const vector<T>& v,string d=" ")
{stringstream s;REP(i,SZ(v))s<<d<<v[i];return s.str().substr(LEN(d));}

template<class T>ostream& operator<<(ostream& s,const vector<T>& v)
{s<<"{";if(SZ(v))s<<join(v,", ");s<<"}";return s;}

template<class T>bool contain(const string& s,const T& v)
{return s.find(v)!=NPOS;}

template<class T,class U>string& replace(string& s,const T& f,const U& t)
{for(auto p=s.find(f);p!=NPOS;p=s.find(f,p+LEN(t)))s.replace(p,LEN(f),t);}

const ll INF = 1e15;
const ll MOD = 1e9+7;
const double EPS = 1e-10;

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

int main() {
    string S; cin >> S;
    replace(S, ",", " ");
    cout << S << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <algorithm>
#include <limits.h>
#include <cmath>
#include <time.h>
#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
/* ここからが本編 */
/*  */
int main(void)
{
  int test = 1;
  int i,j,k,l;
  int n;
  int min = INT_MAX;
  int rep = INT_MIN;
  static int a[200005];
  scanf("%d",&n);
  rep(i,n) {
    scanf("%d",&a[i]);
    if(a[i] - min > rep) rep = a[i] - min;
    if(min > a[i]) min = a[i];
  }
  printf("%d\n",rep);
  return 0;
}

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

#define F(i, a, b) for(int i=a; i<b; i++)
#define mem(arr, val) memset(arr, val, sizeof(arr))

#define MOD 1000000007
#define INF 1000000001
#define epsilon 1e-15

typedef long long int ll;
typedef unsigned long long int ull;

/*int seive(int N){
    bool primes[N+1];
    int cnt=0;
    mem(primes, true); primes[1] = false;
    int m = sqrt(N);
    for(int i=2; i<=m; i++){
        if(primes[i]){
            for(int p = i*i; p<=N; p+=i)
                primes[p] = false;
        }
    }

    for(int i=2; i<=N; i++){
        if(primes[i])
            cnt++;
    }

    return cnt;
} */

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


   
int main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif

    int X, kyu;
    cin >> X;

    if(X < 600) kyu = 8; 
    else if(X < 800) kyu = 7;
    else if(X < 1000) kyu = 6;
    else if(X < 1200) kyu = 5;
    else if(X < 1400) kyu = 4;
    else if(X < 1600) kyu = 3;
    else if(X < 1800) kyu = 2;
    else  kyu = 1;
    
    cout << kyu << '\n';

    return 0;
   
}

Measured memory_bytes: 3612
N,K = map(int,input().split())
A = list(map(lambda x: int(x)-1,input().split()))
B = [0]*N

o = [0] * 63

def bi(x):
    i = 0
    while x != 0:
        o[i] = x%2
        x //= 2
        i += 1

bi(K)

n = 0
for i in range(63):
    if o[i]:
        n = A[n]
    for j in range(N):
        B[j] = A[A[j]]
    for j in range(N):
        A[j] = B[j]
        
print(n+1)

Measured memory_bytes: 92072
using System;
using System.Linq;
public class Hello{
    public static void Main(){
        int[] a = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
        int n = a[0];
        int m = a[1];
        int[] c = Console.ReadLine().Split(' ').Select(y => int.Parse(y)).ToArray();
        int[] dp = new int[50010]; //dp[i] i円を支払うために必要な最小の枚数
        for(int i = 0; i < dp.Length; i++)　//dpを初期化
        {
            dp[i] = 100000;
        }
        
        dp[0] = 0;
        for(int i = 0; i < dp.Length; i++)
        {
            for(int j = 0; j < c.Length; j++)
            {
                if(i + c[j] <= n) // i + c[j]がdpの範囲からはみ出すのを防ぐための条件
                {
                    dp[i + c[j]] = Math.Min(dp[i + c[j]], dp[i] + 1);
                }
                
            }
        }
        
        Console.WriteLine(dp[n]);
    }
}



Measured memory_bytes: 20408
#include <algorithm>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <map>
#include <numeric>
#include <queue>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;


int main() {
    int N;
    int _A = 0, B_ = 0, B_A = 0;
    cin >> N;

    int res = 0;
    for (int n = 0; n < N; n++) {
        string S;
        cin >> S;
        bool b_ = false, _a = false;
        if (S[0] == 'B') b_ = true;
        if (S[S.size() - 1] == 'A') _a = true;
        if (b_ && _a) B_A++;
        else if (b_) B_++;
        else if (_a) _A++;
        for (int i = 0; i < S.size() - 1; i++) if (S[i] == 'A' && S[i + 1] == 'B') res++;
    }

    if (B_A > 0) {
        res += B_A - 1;
        if (_A > 0) {
            res++;
            _A--;
        }
        if (B_ > 0) {
            res++;
            B_--;
        }
    }

    res += min(_A, B_);

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
int main()
{
	int N,a[200000];
	scanf("%d",&N);
	for(int i=0;i<N;i++)
	scanf("%d",&a[i]);
	sort(a,a+N);
	for(int i=1;i<N;i++)
	{
		if(a[i]==a[i-1])
		{
			printf("NO\n");
			return 0;
		}
	}
	printf("YES\n");
	return 0;
}


Measured memory_bytes: 896
# 入力
import sys
stdin = sys.stdin

def li(): return [int(x) for x in stdin.readline().split()]
def li_(): return [int(x)-1 for x in stdin.readline().split()]
def lf(): return [float(x) for x in stdin.readline().split()]
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(ns())
def nf(): return float(ns())

x,y = li()

ans = 10**10

cands = [y-x, -y-x+1, y+x+1, -y+x+2]
for cand in cands:
    if cand >= 0:
        ans = min(ans,cand)
        
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep_1(i,n) for(int (i)=0;(i)<=(n);(i)++)
#define rep_2(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int main()
{
    int k,x;cin>>k>>x;
    cout << (k*500 >= x ? "Yes" : "No") <<endl;
    return 0;
}

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

int main()
{
    long N,K,S;
    std::cin >> N >> K >> S;
    long maxnum=1000000000;
    for(long i=0; i<N; i++){
        long temp;
        if(i<K){
            std::cout << S << " ";
        }else{
            if(S==maxnum){
                temp=maxnum-1;
            }else{
                temp=S+1;
            }
            std::cout << temp << " ";
        }
    }
    std::cout << std::endl;
    return 0;
}

Measured memory_bytes: 1280
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        
        int count = 0;

        while(count < c){
            if(a <= b){
                count++;
                b -= a;
            }
            else{
                break;
            }
        }

        System.out.println(count);
        
    }
}

Measured memory_bytes: 23252
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
using namespace std;
 
typedef int Weight;;
struct Edge {
    int src, dst;
    Weight weight;
    Edge(int src_, int dst_, Weight w_) :
        src(src_), dst(dst_), weight(w_) { }
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
typedef vector<Weight> Array;
typedef vector<Array> Matrix;
 
const int inf = 1e8;
 
char g[1010][1010];
int open[1010][1010];
int n,h,w;
int vis[1010][1010];
 
bool check(int lim){
    rep(i,h)rep(j,w) vis[i][j] = false;
    vector<pair<int,int>> S = { { 0,0 } };
    while(S.size()){
        int ci,cj;
        tie(ci,cj) = S.back();
        S.pop_back();
        //cout << ci << " " << cj << endl;
        vis[ci][cj] = true;
        if(g[ci][cj] == 't') return true;
        int ds[4][2] = {{0,1},{0,-1},{1,0},{-1,0}};
        for(auto & d : ds){
            int ni = ci + d[0];
            int nj = cj + d[1];
            if(ni >= h || nj >= w || ni < 0 || nj < 0) continue;
            if(vis[ni][nj]) continue;
            if(g[ni][nj] == '.' || g[ni][nj] == 't' || (g[ni][nj] == '#' && open[ni][nj] <= lim)){
                S.emplace_back(ni,nj);
            }
        }
    }
    return false;
}

int solve(){
    int l = -1, r = n+10;
    // xxxxoooo
    //    lr
    while(l+1 < r){
        int m = (l+r)/2;
        if(check(m)) r = m;
        else l = m;
    }
    if(r > n) return -1;
    else return r;
}

int main(){
    while(cin >> w >> h && w){
        rep(i,h) cin >> g[i];
        rep(i,h)rep(j,w) open[i][j] = inf;
        cin >> n;
        rep(i,n){
            int x,y;
            cin >> x >> y;
            open[y][x] = i+1;
        }
        cout << solve() << endl;
    }
}

Measured memory_bytes: 26320
#include <cstdio>
#define NO {puts("NO"); return 0;}
long long n, n2, s, k, d, a[100005];
int main() {
	int i;
	scanf("%d", &n);
	for(i=0; i<n; i++) scanf("%d", a+i), s += a[i];
	n2 = n*(n+1)/2;
	if(s%n2) NO;
	k = s/n2;
	for(i=s=0; i<n; i++) {
		d = a[(i+1)%n] - a[i];
		if(k<d || (k-d)%n) NO;
		s += (k-d)/n;
	}
	puts(s==k ? "YES":"NO");
	return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
#define ll long long
#define res register int
#define inf 0x3f3f3f3f
using namespace std;
ll n;
inline int read(){
    res w = 0, X = 0; register char ch = 0;
    while(!isdigit(ch)){w |= ch == '-'; ch = getchar();}
    while(isdigit(ch)){X = (X << 1) + (X << 3) + (ch ^ 48); ch = getchar();}
    return w ? -X : X;
}
int main(){
	cin >> n;
	printf("%lld\n", n * (n - 1) / 2LL);
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static String Y = "Yes";
	public static String N = "No";
	public static long MOD = (long) (Math.pow(10, 9) + 7);
	public static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		int x = ni();
		int y = ni();

		boolean flg = false;

		for (int i = 0; i <= 100; i++) {
			for (int j = 0; j <= 100; j++) {
				if (i + j == x) {
					if (i * 2 + j * 4 == y) {
						flg = true;
						break;
					}
				}
			}
		}

		if (flg) {
			out(Y);
		} else {
			out(N);
		}
	}

	/*
	 * 以下メソッド集
	 */

	static int ketasuu(int n) {
		String str = "" + n;
		return str.length();
	}

	static int abcount(String str) {
		int count = 0;
		int len = str.length();
		for (int i = 0; i < len - 1; i++) {
			if ("AB".equals(str.substring(i, i + "AB".length()))) {
				count++;
			}
		}
		return count;
	}

	static int ni() {
		return sc.nextInt();
	}

	static long nl() {
		return sc.nextLong();
	}

	static double nd() {
		return sc.nextDouble();
	}

	static String n() {
		return sc.next();
	}

	static char[] nc() {
		return sc.next().toCharArray();
	}

	static int kaijo(int n) {
		if (n == 0 || n == 1) {
			return 1;
		} else {
			return n * kaijo(n - 1);
		}
	}

	static int fib(int n) {
		return (n == 1 || n == 0) ? n : fib(n - 2) + fib(n - 1);
	}

	static long lcm(long m, long n) {

		return m * n / gcd(m, n);
	}

	static int lcm(int m, int n) {

		return m * n / gcd(m, n);
	}

	static long gcd(long a, long b) {
		return (b == 0) ? a : gcd(b, a % b);
	}

	static int gcd(int a, int b) {
		return (b == 0) ? a : gcd(b, a % b);
	}

	static void out(String info) {
		System.out.println(info);
	}

	static void out(int info) {
		System.out.println(info);
	}

	static void out(double info) {
		System.out.println(info);
	}

	static void out(long info) {
		System.out.println(info);
	}

	static void out(char info) {
		System.out.println(info);
	}

	static void out(Object obj) {
		System.out.println(obj.toString());
	}

	static void outn(String info) {
		System.out.print(info);
	}

	static void outn(int info) {
		System.out.print(info);
	}

	static void outn(double info) {
		System.out.print(info);
	}

	static void outn(long info) {
		System.out.print(info);
	}

	static void outn(char info) {
		System.out.print(info);
	}

	static double max(double d, double e) {
		return Math.max(d, e);
	}

	static long max(long a, long b) {
		return Math.max(a, b);
	}

	static double min(double d, double e) {
		return Math.min(d, e);
	}

	static long min(long a, long b) {
		return Math.min(a, b);
	}
}

class XY {
	int h;
	int c;

	XY(int h, int c) {
		this.h = h;
		this.c = c;
	}
}


Measured memory_bytes: 35848
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = nextInt(scanner);
        int m = nextInt(scanner);
        int[] h = new int[n];
        for (int i = 0; i < n; i++) {
            h[i] = nextInt(scanner);
        }
        Map<Integer, List<Integer>> map = new HashMap<>();
        for (int i = 0; i < n; i++) {
            map.put(i + 1, new ArrayList<>());
        }
        for (int i = 0; i < m; i++) {
            int a = nextInt(scanner);
            int b = nextInt(scanner);
            map.get(a).add(b);
            map.get(b).add(a);
        }
        int count = 0;
        for (int i = 0; i < n; i++) {
            int highest = 0;
            for (int j : map.get(i + 1)) {
                if (h[j - 1] > highest) {
                    highest = h[j - 1];
                }
            }
            if (h[i] > highest) {
                count++;
            }
        }
        System.out.println(count);
    }

    public static int nextInt(Scanner scanner) {
        return Integer.parseInt(scanner.next());
    }
}


Measured memory_bytes: 76940
#include<bits/stdc++.h>
using namespace std;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s,t;
    cin >> s >> t;
    if(s.size()>t.size()){
        cout << "GREATER" << endl;
        return 0;
    }else if(s.size()<t.size()){
        cout << "LESS" << endl;
        return 0;
    }else{
        for(int i=0;i<s.size();i++){
            if(s[i]-'0'>t[i]-'0'){
                cout << "GREATER" << endl;
                return 0;
            }else if(s[i]-'0'<t[i]-'0'){
                cout << "LESS" << endl;
                return 0;
            }
        }
    }
    cout << "EQUAL" << endl;
    return 0;
}

Measured memory_bytes: 256