akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<stdio.h>
#include<string.h>
#include<cmath>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;


int main()
{
    int n, k, l[50], ans = 0;
    cin >> n >> k;
    for (int i = 0; i < n; i++)
    {
        cin >> l[i];
    }
    sort(l, l + n, greater<int>());
    for (int i = 0; i < k; i++)
    {
        ans += l[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
N=int(input())
G=[[] for i in range(N)]
for i in range(N-1):
    u,v,w=map(int,input().split())
    u-=1; v-=1; w%=2
    G[u].append([v,w])
    G[v].append([u,w])
col=[-1 for i in range(N)]
col[0]=0
 
from collections import deque
dq=deque([0])
 
while len(dq)>0:
    p=dq.popleft()
    for i in range(len(G[p])):
        if col[G[p][i][0]]==-1: # 色がまだついていない場合
            dq.append(G[p][i][0]) # 頂点をキューに追加
            col[G[p][i][0]]=(col[p]+G[p][i][1])%2 # キューに追加された頂点と同じ偶奇かで色つけする
        
for i in col:
    print(i)

Measured memory_bytes: 42220
#include<stdio.h>

void insubunkai(int N,int *A){
  int i;
  for(i=2;i<=N;i++){
    if(N%i == 0){
      A[i]++;
      N /= i;
      i = 1;
    }
  }
}

int main(){
  int N;
  int A[1001]={};
  long long int count=1;
  int i;

  scanf("%d", &N);
  for(i=1;i<=N;i++){
    insubunkai(i,A);
  }
  for(i=0;i<=N;i++){
    if(A[i]>=1){
      count *= A[i]+1;
      count %= 1000000007;
    }
  }
  printf("%lld\n", count);
  return 0;
}


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

int gcd(int x, int y) {
	if (y == 0) return x;
	else return gcd(y, x % y);
}

int main(){
    int a, b;
    while( scanf("%d %d", &a, &b) != EOF ){
        cout<<gcd(a,b)<<endl;
    }
    return 0;
}

Measured memory_bytes: 1208
#include"bits/stdc++.h"
using namespace std;
#define REP(k,m,n) for(int (k)=(m);(k)<(n);(k)++)
#define rep(i,n) REP((i),0,(n))
using ll = long long;

ll solve1(ll N, vector<pair<ll, ll>> lr) {
    ll fres = 0;

    vector<ll> resL(N), resR(N);
    ll minr = 1ll << 60;
    rep(i, N) {
        ll l = lr[i].first;
        minr = min(minr, lr[i].second);
        resL[i] = max(0ll, minr - l + 1);
    }

    ll maxl = -(1ll << 60);
    minr = 1ll << 60;
    for (int i = N - 1; i >= 0; i--) {
        maxl = max(maxl, lr[i].first);
        minr = min(minr, lr[i].second);
        resR[i] = max(0ll, minr - maxl + 1);
    }
    rep(i, N - 1)fres = max(fres, resL[i] + resR[i + 1]);
    return fres;
}

ll solve2(ll N, vector<pair<ll, ll>> lr) {
    set<ll> stl, str;
    map<ll, ll> cntl, cntr;
    for (auto p : lr) {
        ll l, r;
        tie(l, r) = p;
        stl.insert(l);
        str.insert(r);
        cntl[l]++;
        cntr[r]++;
    }

    ll res = 0;
    for (auto p : lr) {
        ll l, r, tres;
        tie(l, r) = p;
        tres = r - l + 1;

        if (cntl[l] == 1)stl.erase(l);
        if (cntr[r] == 1)str.erase(r);

        auto itrl = stl.end();
        itrl--;
        ll ml = *itrl;
        ll mr = *str.begin();
        if (ml <= mr)tres += mr - ml + 1;
        res = max(res, tres);

        stl.insert(l);
        str.insert(r);
    }
    return res;
}

int main()
{
    ll N, fres = 0;
    cin >> N;
    vector<pair<ll, ll>> lr;
    rep(i, N) {
        ll l, r;
        cin >> l >> r;
        lr.push_back({ l,r });
    }
    sort(lr.begin(), lr.end());
    //cout << solve2(N, lr) << endl;
    cout << max(solve1(N, lr), solve2(N, lr)) << endl;
    return 0;
}


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

int main()
{
    int n, k;
    double d = 0.0;
    cin >> n >> k;
    double f = double(n);

    for(int i=1; i<=n; i++){
        int sum = i;
        double tmp = 1.0 /f;
        while(sum <= k-1){
            sum *= 2;
            tmp *= 0.5;
        }
        d += tmp;
    }
    printf("%14.12lf\n", d);
    return 0;
}

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

int main() {
	int n; cin >> n;
	vector<int> a;

	int z;
	for (int i = 0; i < n; i++) {
		cin >> z; a.push_back(z);
	}

	sort(a.begin(), a.end(), greater<int>());

	int ans = 0;
	for (int i = 0; i < a.size(); i++) {
		ans += a[i] * (i % 2 == 0 ? 1 : -1);
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string s;
int ans=0;
int main(){
    int n;
    cin>>n>>s;
for(int k=1;k<s.size();k++){
   if(s[k]!=s[k-1])
        ans++;
}
cout<<ans+1;
return 0;
}


Measured memory_bytes: 512
fn s(x: usize) -> usize {
    let mut s = x;
    let mut result = 0;
    while s > 0 {
        result += s % 10;
        s /= 10;
    }
    result
}

fn main() {
    let mut sc = Scanner::new();
    let k = sc.read();

    let mut cur: usize = 1;
    for _ in 0..k {
        println!("{}", cur);
        let mut t = 1;
        let mut candidate = cur + 1;
        while cur * 100 >= t {
            for i in 0..10 {
                let next = (cur / t + i) * t + t - 1;
                if next > cur && next * s(candidate) < candidate * s(next) {
                    candidate = next;
                }
            }
            t *= 10;
        }
        cur = candidate;
    }
}

struct Scanner {
    ptr: usize,
    length: usize,
    buf: Vec<u8>,
    small_cache: Vec<u8>,
}

#[allow(dead_code)]
impl Scanner {
    fn new() -> Scanner {
        Scanner {
            ptr: 0,
            length: 0,
            buf: vec![0; 1024],
            small_cache: vec![0; 1024],
        }
    }

    fn load(&mut self) {
        use std::io::Read;
        let mut s = std::io::stdin();
        self.length = s.read(&mut self.buf).unwrap();
    }

    fn byte(&mut self) -> u8 {
        if self.ptr >= self.length {
            self.ptr = 0;
            self.load();
            if self.length == 0 {
                self.buf[0] = b'\n';
                self.length = 1;
            }
        }

        self.ptr += 1;
        return self.buf[self.ptr - 1];
    }

    fn is_space(b: u8) -> bool {
        b == b'\n' || b == b'\r' || b == b'\t' || b == b' '
    }

    fn read_vec<T>(&mut self, n: usize) -> Vec<T>
    where
        T: std::str::FromStr,
        T::Err: std::fmt::Debug,
    {
        (0..n).map(|_| self.read()).collect()
    }

    fn usize_read(&mut self) -> usize {
        self.read()
    }

    fn read<T>(&mut self) -> T
    where
        T: std::str::FromStr,
        T::Err: std::fmt::Debug,
    {
        let mut b = self.byte();
        while Scanner::is_space(b) {
            b = self.byte();
        }

        for pos in 0..self.small_cache.len() {
            self.small_cache[pos] = b;
            b = self.byte();
            if Scanner::is_space(b) {
                return String::from_utf8_lossy(&self.small_cache[0..(pos + 1)])
                    .parse()
                    .unwrap();
            }
        }

        let mut v = self.small_cache.clone();
        while !Scanner::is_space(b) {
            v.push(b);
            b = self.byte();
        }
        return String::from_utf8_lossy(&v).parse().unwrap();
    }
}


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

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define TO_STRING(VariableName) # VariableName
#define LOG(x) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<endl;
#define LOG2(x,y) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<endl;
#define LOG3(x,y,z) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;
#define LOG4(w,x,y,z) if(DEBUG)cout<<TO_STRING(w)<<"="<<w<<" "<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;

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; }

map<lli,lli> dp;

lli N,a,b,c,d;

lli calc(lli now){
    if(dp.count(now)!=0)return dp[now];
    if(now==0)return 0;
    if(now==1)return d;

    LOG(now);
    lli rtn = d*now;
    if(rtn<0)rtn = INF;
    //2で割り算掛け算
    if(now%2==0)chmin(rtn,calc(now/2) + a);
    else{
        lli target = (now/2*2);
        LOG3(now,rtn,target);
        chmin(rtn,calc(target/2)+a+d*(abs(now-target)));

        target = ((now/2+1)*2);
        chmin(rtn,calc(target/2)+a+d*(abs(now-target)));
        LOG3(now,rtn,target);
    }    
    //3で割り算掛け算
    if(now%3==0)chmin(rtn,calc(now/3)+b);
    else{
        lli target = (now/3*3);
        chmin(rtn,calc(target/3)+b+d*(abs(now-target)));
        LOG3(now,rtn,target);

        target = ((now/3+1)*3);
        chmin(rtn,calc(target/3)+b+d*(abs(now-target)));
        LOG3(now,rtn,target);
    }

    //5で割り算掛け算
    if(now%5==0)chmin(rtn,calc(now/5)+c);
    else{
        lli target = (now/5*5);
        chmin(rtn,calc(target/5)+c+d*(abs(now-target)));
        LOG3(now,rtn,target);

        target = ((now/5+1)*5);
        chmin(rtn,calc(target/5)+c+d*(abs(now-target)));
        LOG3(now,rtn,target);
    }

    LOG2(now,rtn);
    return dp[now]=rtn;

}

void solve(){
    cin>>N>>a>>b>>c>>d;

    dp.clear();
    cout<<calc(N)<<endl;
}

int main(){

    lli t;
    cin>>t;
    while(t--)solve();
    return 0;
}


Measured memory_bytes: 4280
# util functions

# debug
$debugFlag = ( ARGV[0] != nil )
p "==== DEBUG MODE ====" if $debugFlag

def pd(str)
  p str if $debugFlag
end

def printd(str)
  print str if $debugFlag
end

# input
inputs = []
lc = 0
while l = $stdin.gets do
  if false
    inputs << l.chomp.split(" ").map(&:to_s)
  else
    inputs << l.chomp.split(" ").map(&:to_i)
  end
  lc += 1
end

hh = inputs[0][0]
ww = inputs[0][1]
kk = inputs[0][2]

# input check
if $debugFlag
  p "--- INPUT (begin) ---"
  inputs.each do |l_i|
    p l_i
  end
  p "--- INPUT (end) ---"
  print "\n"
end

# body
if $debugFlag
end

$memo = {}
def pat(n)
  if n <= 0
    return 1
  elsif n == 1
    return 2
  elsif n == 2
    return 3
  else
    return $memo[n] if $memo[n] != nil
    $memo[n] = pat(n-1) + pat(n-2)
    return $memo[n]
  end
end

$memorec = {}
def rec(n, k, w)
  if n == 0
    if k == 1
      return 1
    else
      return 0
    end
  end
  if k > w or k <= 0
    return 0
  end

  #pd "pat(#{k-3})*pat(#{w-k-1})*rec(#{n-1}, #{k-1}, #{w}) + pat(#{k-2})*pat(#{w-k-1})*rec(#{n-1}, #{k}, #{w}) + pat(#{k-2})*pat(#{w-k-2})*rec(#{n-1}, #{k+1}, #{w})"
  return $memorec["#{n},#{k}"] if $memorec["#{n},#{k}"] != nil

  $memorec["#{n},#{k}"] = pat(k-3)*pat(w-k-1)*rec(n-1, k-1, w) + pat(k-2)*pat(w-k-1)*rec(n-1, k, w) + pat(k-2)*pat(w-k-2)*rec(n-1, k+1, w)
  return $memorec["#{n},#{k}"]
end

puts rec(hh, kk, ww) % 1000000007


Measured memory_bytes: 2300
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
using namespace std;
typedef long long int ll;
typedef vector< int > vi;
typedef pair< int, int > ii;
typedef vector< ii > vii;
typedef vector< ll > vll;
// #define DEBUG_MODE
#ifdef DEBUG_MODE
	#define errp(...) fprintf(stderr, __VA_ARGS__)
	#define dbg(x) fprintf(stderr, "[%s = %d]\n", #x, x)
#else
	#define errp(...)
	#define dbg(x) 
#endif

int main () { 
#ifdef DEBUG_MODE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int r, d, a[15];
	scanf("%d%d%d", &r, &d, &a[0]);
	for (int i = 1; i <= 10; i++) a[i] = r * a[i - 1] - d;
	for (int i = 1; i <= 10; i++) printf("%d\n", a[i]);
}

Measured memory_bytes: 128
import Data.List
import Control.Applicative
import Control.Monad

getDivisor :: Int -> [Int]
getDivisor n = [m | m <- [1..n], n `mod` m == 0]

getCommon :: [Int] -> [Int] -> [Int]
getCommon xs ys = [x | x <- xs, y <- ys, x == y]

main :: IO ()
main = do
  getLine
  xs <- fmap read . words <$> getLine :: IO [Int]
  let cds = foldr1 getCommon $ fmap getDivisor xs
  putStr . unlines $ show <$> cds


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

#define ll long long
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()
void foreach_permutation(int n, std::function<void(int *)> f) {
  int indexes[n];
  for (int i = 0; i < n; i++) indexes[i] = i;
  do {
    f(indexes);
  } while (std::next_permutation(indexes, indexes + n));
}
int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<pair<long double,long double>> x(n);
    vector<int> array(n);

    rep(i,0,n){
        cin >> x[i].first >> x[i].second;
        array[i] = i;
    }
    long double sum = 0;
    do{
        long double s_sum = 0;
        rep(i,0,n-1){
            s_sum += sqrt(pow(x[array[i]].first-x[array[i+1]].first,2)+pow(x[array[i]].second-x[array[i+1]].second,2));
        }
        //s_sum += sqrt(pow(x[array[n-1]].first-x[array[0]].first,2)+pow(x[array[n-1]].second-x[array[0]].second,2));
        sum += s_sum;
    }while(next_permutation(all(array)));
    rep(i,2,n+1) sum /= i;
    cout << fixed << setprecision(20) << sum << endl;

}

Measured memory_bytes: 256
N, A, B = map(int, input().split())
number = range(A, N+1)
number_str = list(map(str, number))
arc = []
for item in number_str:
    num = list(map(int, item))
    s = sum(num)
    if A <= s and s <= B:
        arc.append(int(item))
print(sum(arc))

Measured memory_bytes: 4196
#include <bits/stdc++.h>
using namespace std;
int r,c,n,cnt,idx,a[5000][5000];
int b[1000001];
int main(){
	vector<int> v;
	cin >> r >> c >> n;
	for(int i = 1;i <= n;i++){
			cin >> b[i];
	}
	for(int i = 1;i <= n;i++){
		for(int j = 1;j <= b[i];j++){
			v.push_back(i);
			cnt++;
		}
	}
	for(int i = 1; i<= r;i++){
		if(i % 2 == 0){
			for(int j = c;j >= 1;j--){
					a[i][j] = v[idx];
					idx++;
			}
		} else {
			for(int j = 1 ; j <= c;j++){
				a[i][j] = v[idx];
				idx++;
			}
		}
	}
	for(int i = 1;i <= r;i++){
		for(int j = 1;j<= c;j++){
			if(j == c)cout << a[i][j];
			else cout << a[i][j] << ' ';
		}
		cout << endl;
	}
}

Measured memory_bytes: 4480
#include <stdio.h>
#define MAXSIZE 200000

int main(void){
    int maxBenefit=-2000000000,min,size,i,a[MAXSIZE];
    scanf("%d",&size);
    for(i=0;i<size;i++){
        scanf("%d",&a[i]);
    }

    min=a[0];
    for(i=1;i<=size-1;i++){
        maxBenefit=maxBenefit>(a[i]-min)?maxBenefit:(a[i]-min);//更新最大利益：比较当前值与此前最小值的差和此前的最大利益
        min=min<a[i]?min:a[i];//更新最小值
    }

    printf("%d\n",maxBenefit);
    return 0;
}




Measured memory_bytes: 2508
#include <bits/stdc++.h>
using namespace std;
#define int                 long long   
#define double              long double
#define endl                "\n"
#define pb                  push_back
#define PI                  3.1415926535897932384626433832795l
#define F                   first
#define S                   second
#define mp                  make_pair
#define f(i,n)              for(int i=0;i<n;++i)
#define loop(i,a,b)         for (int i=a ; i<b ;++i)
#define fastio              ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define all(v)              (v).begin(),(v).end()
#define rall(v)             (v).rbegin(),(v).rend()
#define gcd(a,b)            __gcd((a),(b))
#define fill(a,value)       memset(a,value,sizeof(a));
#define minn(v)             *min_element(v.begin(), v.end());
#define maxx(v)             *max_element(v.begin(), v.end());
#define print(x)            cout<<(x)<<endl;
typedef pair<int,int> pii;  
typedef vector<int> vi;
signed main() 
{
    fastio;
    int n;
    cin>>n;
    vi a(n);
    f(i,n)
    {
        cin>>a[i];
    }
    int x=a[0];
    int ans=0;
    
    for(int i=1;i<n;i++)
    {
        ans+=max(0ll,x-a[i]);
        x=max(x,a[i]);
    }
    print(ans)
    
    return 0;
    
    
}

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

using namespace std;
typedef long long ll;

int M, K;

int main() {
	cin >> M >> K;
	if (K >= (1 << M)) {
		cout << -1 << endl;
		return 0;
	}
	vector<int> ans;
	if (M == 0 && K == 0) {
		cout << 0 << " " << 0 << endl;
		return 0;
	}
	if (K == 1 && M == 1) {
		cout << -1 << endl;
		return 0;
	}
	if (K == 0) {
		for (int i = 0; i < (1 << M); i++) {
			cout << i << " " << i << " ";
		}
		cout << endl;
	}
	else {
		for (int i = 0; i < (1 << M); i++) {
			if (i != K)cout << i << " ";
		}
		cout << K << " ";
		for (int i = (1 << M) - 1; i >= 0; i--) {
			if (i != K)cout << i << " ";
		}
		cout << K << endl;
	}

	return 0;
}

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



class Myon
{
    public Myon() { }
    public static int Main()
    {
        cin = new Scanner();
        new Myon().calc();
        return 0;
    }

    static Scanner cin;

    void calc()
    {
        var n = cin.nextInt();
        var p = cin.ArrayInt(n);
        int[] check = new int[3];
        var ret = 0;
        for(var i = 0;i < n - 2; i++)
        {
            for(var k = 0;k < 3; k++)
            {
                check[k] = p[i + k];
            }
            if (judge(check))
            {
                ret++;
            }
        }
        Console.WriteLine(ret);
    }

    bool judge(int[] array)
    {
        int target = array[1];
        Array.Sort(array);
        if(array[1] == target)
        {
            return true;
        }
        return false;
    }


    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }

        public string next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return next();
            i = 0;
            return s[i++];
        }

        public int nextInt()
        {
            return int.Parse(next());
        }
        public int[] ArrayInt(int N, int add = 0)
        {
            int[] Array = new int[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt() + add;
            }
            return Array;
        }

        public long nextLong()
        {
            return long.Parse(next());
        }

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong() + add;
            }
            return Array;
        }

        public double nextDouble()
        {
            return double.Parse(next());
        }


        public double[] ArrayDouble(int N, double add = 0)
        {
            double[] Array = new double[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextDouble() + add;
            }
            return Array;
        }
    }
}

Measured memory_bytes: 13140
from heapq import heappop, heappush

manhattan = [[abs((i % 4) - (j % 4)) + abs((i // 4) - (j // 4)) for j in range(16)] for i in range(16)]
movables = [{1, 4}, {0, 2, 5}, {1, 3, 6}, {2, 7}, {0, 5, 8}, {1, 4, 6, 9}, {2, 5, 7, 10}, {3, 6, 11},
            {4, 9, 12}, {5, 8, 10, 13}, {6, 9, 11, 14}, {7, 10, 15}, {8, 13}, {9, 12, 14}, {10, 13, 15}, {11, 14}]
swap_cache = [[(1 << mf) - (1 << mt) for mt in range(0, 64, 4)] for mf in range(0, 64, 4)]
destination = 0xfedcba9876543210


def swap(board, move_from, move_to):
    return board + swap_cache[move_from][move_to] * (15 - ((board >> (4 * move_from)) & 15))


i = 0
board_init = 0
blank_init = 0
for _ in range(4):
    for n in map(int, input().split()):
        if n:
            n -= 1
        else:
            n = 15
            blank_init = i
        board_init += n * 16 ** i
        i += 1

estimation_init = sum(manhattan[i][((board_init >> (4 * i)) & 15)] for i in range(16) if i != blank_init)

queue = [(estimation_init, board_init, blank_init)]
visited = set()

while True:
    estimation, board, blank = heappop(queue)
    if board in visited:
        continue
    elif board == destination:
        print(estimation)
        break
    visited.add(board)
    for new_blank in movables[blank]:
        new_board = swap(board, new_blank, blank)
        if new_board in visited:
            continue
        num = (board >> (4 * new_blank)) & 15
        new_estimation = estimation + 1 - manhattan[new_blank][num] + manhattan[blank][num]
        if new_estimation > 45:
            continue
        heappush(queue, (new_estimation, new_board, new_blank))

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

using namespace std;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl;
#define OK(ok) cout << (ok ? "Yes" : "No") << endl;
typedef long long ll;

void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail) {
  cin >> head; CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

const int INF = 1e9 + 1;
const int MOD = 1e9 + 7;
const int MAX_N = 1e4 + 1;

bool check(int i, vector< int > D) {
  int tmp;
  while (i > 0) {
    if (i >= 10) {
      tmp = i % 10;
      REP(j, D.size()) {
	if (tmp == D[j]) {
	  return false;
	}
      }
      i /= 10;
    } else {
      REP(j, D.size()) {
	if (i == D[j]) {
	  return false;
	}
      }
      break;
    }
  }
  return true;
}

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

  CIN(N, K);
  vector< int > D(K);
  REP(i, K) {
    cin >> D[i];
  }

  FOR(i, N, INF) {
    if (check(i, D)) {
      cout << i << endl;
      break;
    }
  }

  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <cstring>
#include <map>
#include <set>
#include <cmath>
#include <cstdlib>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define INF 1145141919
typedef long long int ll;
using namespace std;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

ll lcm(ll m, ll n)
{
    if ((0 == m) || (0 == n))
        return 0;
    return ((m / gcd(m, n)) * n);
}

ll llpow(ll x, ll y)
{
    ll ans = 1;
    REP(i, y)
    ans *= x;
    return ans;
}

int ctoi(char c)
{
    if (c >= '0' && c <= '9')
    {
        return c - '0';
    }
    return 0;
}

////////////////////////////////////////////////////////////////////

int main()
{
    string s; cin >> s;
    char lead = s[0];
    int len = s.size();
    int num_lead = ctoi(lead);
    string res=s;
    res.erase(0,1);
    if(all_of(res.begin(), res.end(), [](char x){return x=='9';})){
        cout << num_lead+9*(len-1) << endl;
    }else{
        cout << num_lead+9*(len-1)-1 << endl;
    }

    return 0;
}


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

int main() {
    int n; cin >> n;
    vector<string> s(n);
    for (int i = 0; i < n; i++) {
        cin >> s[i];
    }
    
    int m; cin >> m;
    vector<string> t(m);
    for (int i = 0; i < m; i++) {
        cin >> t[i];
    }
    
    int ans = 0;
    for (int i = 0; i < n; i++) {
        int cnt = 1;
        for (int j = i+1; j < n; j++) {
            if (s[i] == s[j]) cnt++;
        }
        for (int j = 0; j < m; j++) {
            if (s[i] == t[j]) cnt--;
        }
        ans = max(ans, cnt);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <array>
#include <algorithm>
#include <utility>
#include <numeric>
#include <deque>
#include <stack>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cmath>
#include <limits>
#include <cassert>
#include <bitset>
#include <list>
#include <iomanip>
#include <cctype>
#include<chrono>
#include<random>

#define for0(i, N)    for (long long i = 0  ; i <  (N); ++i)
#define for1n(i, N)   for (long long i = 1  ; i <= (N); ++i)
#define for1(i, N)    for (long long i = 1  ; i <  (N); ++i)
#define forn(i, N)    for (long long i = 0  ; i <= (N); ++i)
#define forx(i, N, x) for (long long i = (x); i <  (N); ++i)
#define forl(i, N, x, a) for (long long i = (x), a = 0; a < (N);    \
                              i = (i + 1) % (N), ++a)
#define int long long

long double constexpr pi = 3.141592653589793;

template<class T>
constexpr T sigma1(T i, T n){
    return (n - i + 1) * (i + n) / 2;
}

template<class T>
constexpr T sigma2(T i, T n){
    return (i == 1 ? n * (n + 1) * (2 * n + 1) / 6 :
            sigma2(1, n) - sigma2(1, i - 1));
}

template<class T>
constexpr T sigma3(T i, T n){
    if (i == 1) {
        auto temp = sigma1(i, n);
        return temp * temp;
    }
    return sigma2(1, n) - sigma2(1, i - 1);
}

template<size_t i>
std::bitset<i> operator++(std::bitset<i> b, signed){
    static_assert(i <= 64, "Cannot cast 64bit int.");
    return b = (unsigned long long)b + 1;
}

template<size_t i>
std::bitset<i> operator++(std::bitset<i> b){
    static_assert(i <= 64, "Cannot cast 64bit int.");
    auto temp = b;
    b++;
    return temp;
}

template<size_t i>
std::bitset<i> operator--(std::bitset<i> b, signed){
    static_assert(i <= 64, "Cannot cast 64bit int.");
    return b = (unsigned long long)b - 1;
}

template<size_t i>
std::bitset<i> operator--(std::bitset<i> b){
    static_assert(i <= 64, "Cannot cast 64bit int.");
    auto temp = b;
    b--;
    return temp;
}

long long constexpr inf = std::numeric_limits<long long>::max();

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef priority_queue<ll> pq;
typedef priority_queue<ll,vector<ll>, greater<ll>> pql;
typedef stack<ll> stk;
typedef queue<ll> qu;
typedef pair<ll, ll> pll;
typedef map<ll, ll> mll;
typedef unordered_map<ll, ll> umll;
typedef set<ll> sll;
typedef unordered_set<ll> usll;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<vector<ll>> vvll;


signed main(void){
    cin.tie(0); ios::sync_with_stdio(false);cout<<fixed<<setprecision(10);
    ll n;
    cin >> n;
    vector<ull> v(n);

    for0(i, n){
        cin >> v[i];
    }

    ull ans = 0;
    for0(j, n){
        if (0 == j) {
            continue;
        }
        ans ^= v[j];
    }
        cout << ans;


    for1(i, n){
        ans ^= v[i - 1];
        ans ^= v[i];
        cout << " " << ans;

    }


    return 0;
}


Measured memory_bytes: 4720
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cmath>

typedef long long ll;
using namespace std;
const int mod = 1000000007;

int main() {

    int n;
    cin >> n;
    vector<ll> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    ll ans = 0;
    for (int i = 0; i < 60; i++) {
        ll x = 0;
        for (int j = 0; j < n; j++) {
            if (a[j] >> i & 1) {
                x++;
            }
        }
        ll now = x * (n-x) % mod;
        for (int j = 0; j < i; j++) {
            now = now * 2 % mod;
        }
        ans += now;
        ans %= mod;
    }

    cout << ans << '\n';

}


Measured memory_bytes: 2560
/* ABC110 */
/* A */
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;

int main(void){

    vector<int> vec;

    for (int i=0; i<3; ++i){
        int x;
        cin >> x;
        vec.push_back(x);
        // cout << vec[i] << endl;
    };
    // cout << vec.size() << endl;

    sort(vec.begin(), vec.end(), greater<int>());

    int X, Y;
    for (int i=0; i<3; ++i){
        if (i==0) X = vec[i]*10;
        else if (i==1) X += vec[i];
        else if (i==2) Y = vec[i];
    };

    cout << X + Y << endl;
}

Measured memory_bytes: 256
'use strict'

const Main = (input) => {
  const [A, B, H, M] = input.trim().split(' ').map(Number)

  const thetaH = ((H + M / 60) / 12) * Math.PI * 2
  const thetaM = (M / 60) * Math.PI * 2

  const theta = thetaH - thetaM

  let result = Math.sqrt(Math.pow(A, 2) + Math.pow(B, 2) - (2 * A * B * Math.cos(theta)))

  console.log(result)
  return result
}


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

Measured memory_bytes: 29880
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
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;
}

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s,t;
    cin >> s >> t;
    cout << t << s << endl;
    return 0;
}


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

int main() {
  string S;
  cin >> S;
  
  if ((S.at(0)==(S.at(1))) && (S.at(0)==(S.at(2))) && (S.at(2)==(S.at(1)))) {
    cout << "No";
  }
  else {
    cout << "Yes";
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int K, X,zahyou,m;
  cin >> K >> X ;
  zahyou=X-K+1;
  
  for(m=0;m<2*K-1;m++){
   cout << zahyou << endl;
   zahyou++;
  }
    
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    private static boolean canBeAppended(String s1, String s2) {
        if (s1 == null || s2 == null) {
            return false;
        }

        int m = s1.length(), n = s2.length(), i = 0;
        while (i < m && i < n) {
            if (s1.charAt(i) != s2.charAt(i)) {
                return false;
            }
            i++;
        }

        return n != i && n - i <= 2;
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s1 = sc.next();
        String s2 = sc.next();

        System.out.println(canBeAppended(s1, s2) ? "Yes" : "No");
        sc.close();
    }
}

Measured memory_bytes: 26896
#include<bits/stdc++.h>
#define INF 0x3f3f3f3f
using namespace std;
int main() {
    string S; cin >> S;
    int k=S.length();
    int tmp = 1;
    for(int i = 0; i < k-1;i++){
        if(S[i] != S[i+1]) tmp++;
    }
    cout << tmp-1 << endl;
	return 0;
}

Measured memory_bytes: 512
n,k = map(int,input().split())
L = []
for val in range(n):
    val = int(input())
    L.append(val)

L = sorted(L)
ans_L = []
for i in range(n-k+1):
    ans = L[i+k-1] - L[i]
    ans_L.append(ans)
print(min(ans_L))

Measured memory_bytes: 56408
#include <iostream>
#include <cstdlib>
#include <string>
#include <map>

using namespace std;
int maxs=0;
string a[300005];
int main()
{
    map<string,int> word_count;// empty
    int n;
    string word;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin >> word;
        ++word_count[word];
    }
    map<string, int>::iterator iter;
    int i=0;
    for(iter = word_count.begin(); iter != word_count.end(); iter++)
    {
        if(iter->second>maxs)
        {
            maxs=iter->second;
        }
    }
    for(iter = word_count.begin(); iter != word_count.end(); iter++)
    {
         if(iter->second==maxs)
         {
             a[i++]=iter->first;
         }
    }
    for(int j=0;j<i;j++)
    {
        cout<<a[j]<<endl;
    }
    return EXIT_SUCCESS;
}


Measured memory_bytes: 27520
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int T = sc.nextInt();
    int[] c = new int[1000];
    int[] t = new int[1000];
    int mincost = 1001;
    for (int i = 0; i < N; i++) {
      c[i] = sc.nextInt();
      t[i] = sc.nextInt();
    }
    for (int i = 0; i < N; i++) {
      if (t[i] <= T && c[i] < mincost) {
        mincost = c[i];
      }
    }
    if (mincost >= 1001) {
      System.out.println("TLE");
    } else {
      System.out.println(mincost);
    }
  }
}

Measured memory_bytes: 21204
function Main(input) {
  var n = input.split("\n")[0];
  var v = input.split("\n")[1].split(" ");
  var c = input.split("\n")[2].split(" ");
  var val = 0;
  for(var i in v){
  	if(parseInt(v[i])>parseInt(c[i]))val+=v[i]-c[i];
  }
  console.log(val);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 21192
#include <iostream>

using namespace std;

int main(){
    int x1, x2, y1, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    cout << x2 + (y1 - y2) << " " << y2 + (x2 - x1) << " " << x1 + (y1 - y2) << " " << y1 + (x2 - x1) << "\n";
}

Measured memory_bytes: 256
/*input

*/


//assic value of ('0'-'9') is(48 - 57) and (a-z) is (97-122) and (A-Z) is(65-90) and 32 for space
#include<bits/stdc++.h>
using namespace std;
#define ll          long long
#define pb          push_back
#define pii         pair<ll int,ll int>
#define vpii        vector< pii >
#define vi          vector<ll int>
#define vs			vector< string >
#define vvi         vector< vector< ll > >
#define inf			(ll)1e18
#define all(it,a)   for(auto it=(a).begin();it!=(a).end();it++) 
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define repr(i,a,b) for(ll int i=a;i>b;i--)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define mp          make_pair
#define whatis(x)   cout << #x << " is " << x << "\n";
#define graph(n)    adj(n,vector< ll > () )
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());


int solve()
{
	ll n,k;cin>>n>>k;
	vi a(n);
	ll ans=0;
	rep(i,0,n)
	{
		ll x;cin>>x;
		if(x>=k) ans++;
	}

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

int main()
{
	auto start = chrono::high_resolution_clock::now();

	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	ll test_cases=1;
	//cin>>test_cases;
	while(test_cases--)
		solve();

	auto stop = chrono::high_resolution_clock::now();
	auto duration = chrono::duration_cast<chrono::milliseconds>(stop-start);
	// cout<<"\nduration: "<<(double)duration.count()<<" milliseconds";
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
const int MAX=300030;
int N,A[MAX],x,y,l;
ll ans;
main(){
    scanf(" %d",&N);
    for(int i=0;i<N;i++) scanf(" %d",&A[i]);
    int cum=1;
    for(int i=0;i<N;i++){
        x^=A[i],y+=A[i];
        while(x!=y){x^=A[l], y-=A[l++];}
        ans+=(ll)i-l+1;
    }
    printf("%lld\n",ans);
}


Measured memory_bytes: 1024
import scala.io.StdIn._
object Main extends App {
  val Array(n, x) = readLine.split(" ").map(_.toInt)
  val ls = readLine.split(" ").map(_.toInt)
  println(ls.scanLeft(0){(z, l) => z + l}.indexWhere(_ > x) match {
    case -1 => n + 1
    case b => b
  })
}

Measured memory_bytes: 25544
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) debug(x) debug(y);
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sq(x) ((x) * (x))
const int MOD = 1e9 + 7;

template<class T> T gcd(T a, T b){ return ((b == 0) ? a : gcd(b, a % b)); }

ll fact[100005];
ll invFact[100005];

ll C(ll n, ll r){
	if(r > n) return 0;
	ll ret = fact[n];
	ret = ((ret * invFact[n - r]) + MOD) % MOD;
	ret = ((ret * invFact[r]) + MOD) % MOD;
	return ret;
}

ll mypow(ll a, ll p){
	if(p == 0) return 1;
	if(p == 1) return (a % MOD);
	if(p & 1) return ((a % MOD) * (mypow(a, p - 1) % MOD)) % MOD;
	ll x = mypow(a, p / 2) % MOD;
	return (x * x) % MOD;
}

ll inv(ll base){
	return mypow(base, MOD - 2);
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	fact[0] = 1;
	invFact[0] = 1;
	for(ll i = 1; i < 100005; i++){
		fact[i] = (1LL * fact[i - 1] * i) % MOD;
		invFact[i] = inv(fact[i]);
	}
	int n;
	cin >> n;
	vi a(n + 1);
	vi cnt(n + 2, -1);
	ll dist = 0;
	rep(i, n + 1){
		cin >> a[i];
		if(cnt[a[i]] != -1){
			dist = i - cnt[a[i]];
		}
		cnt[a[i]] = i;
	}
	repn(i, 1, n + 2){
		cout << (C(n + 1, i) - C(n - dist, i - 1) + MOD) % MOD << endl;
	}
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


Measured memory_bytes: 3584
// c.cpp : アプリケーションのエントリ ポイントを定義します。
//

#include <iostream>
#include <cmath>
using namespace std;

int main()
{
	int n, m;
	cin >> n >> m;
	long long p = pow(2, m);
	long long x = 1900 * m + (n - m) * 100;
	cout << (x * p) << endl;
    return 0;
}



Measured memory_bytes: 512
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using static MyIO;


public class B
{
	public static void Main()
	{
		int N = GetInt();
		int A = GetInt();
		int B = GetInt();
		int[] num = new int[3];
		for(int i = 0; i < N; i++)
		{
			int P = GetInt();
			if(P <= A)
				num[0]++;
			else if(P <= B)
				num[1]++;
			else
				num[2]++;
		}
		Console.WriteLine(num.Min());
	}
}


public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt(){ return int.Parse(getArg()); }
	public static long GetLong(){ return long.Parse(getArg()); }
	public static double GetDouble(){ return double.Parse(getArg()); }
	public static string GetString(){ return getArg(); }
}


Measured memory_bytes: 11220
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,x;
  cin >> n >> x;
  vector<int> da(n);
  for(int i=0;i<n;i++)
    cin >> da[i];
  sort(da.begin(),da.end());
  int ans=0,co=0,sum=0;
  while(x-da[co]>=0&&co<n){
    ans++;
    x-=da[co];
    co++;
  }
  if(x!=0&&co==n)
   cout << ans-1 << endl;
  else
    cout << ans << endl;
//  cout << co << endl;
}

Measured memory_bytes: 256
#import numpy as np
import sys, math
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial#, gcd
from bisect import bisect_left, bisect_right #bisect_left(list, value)
sys.setrecursionlimit(10**7)
enu = enumerate
MOD = 10**9+7
def input(): return sys.stdin.readline()[:-1]
pl = lambda x: print(*x, sep='\n')

N = int(input())
A = list(map(int, input().split()))
nA = [a-i-1 for i, a in enu(A)]

# print(nA)
nA.sort()
# print(nA)

# minA = min(nA)
# maxA = max(nA)
# for val in range(minA, maxA+1):
#     res = sum([abs(a-val) for a in nA])
#     print(val, ':', res)

midA1 = nA[N//2-1]
midA2 = nA[N//2]
res = min(sum([abs(a-midA1) for a in nA]), sum([abs(a-midA2) for a in nA]))
print(res)


Measured memory_bytes: 130356
#include <bits/stdc++.h>
#define ll long long
#define db double
#define ldb long double
#define pii pair<int,int>
#define pil pair<int,ll>
#define pli pair<ll,int>
#define pll pair<ll,ll>
#define ts puts("test  check")
#define xh1(a,b) for(int i=a;i<b;i++)
#define xh2(a,b) for(int j=a;j<b;j++)
#define stlbl(a) for(it=a.begin();it!=a.end();it++)
#define dzkt int T;cin>>T;while(T--)
#define mst(a,i) memset(a,i,sizeof(a))
#define iosks std::ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
const int N=3e5+10,M=3e4+10,inf=1e9+10,mod=1e9+7;
const db pi=atan(1)*4;
ll pow2(ll a,ll b) {ll s=1; while(b) {if(b&1) s=(s*a)%mod; a=(a*a)%mod; b/=2; } return s;}
int gcd(int a,int b) {return b==0?a:gcd(b,a%b); }
int lcm(int a,int b) {return a/gcd(a,b)*b; }
ll prime(ll x) {for(ll i=2;i<=sqrt(x+0.5);i++) if(x%i==0) return 0; return 1; }
int read()
{
    int s=0,f=1;
    char ch=getchar();
    while(ch<'0'&&ch>'9') {if(ch=='-') f=-1; ch=getchar();}
    while(ch>='0'&&ch<='9') {s=s*10+ch-'0'; ch=getchar();} return s*f;
}
set<ll> st;
vector<ll> vec;

int vis[N][26],nex[N][26],vv[M],len,tot=1,f,n;
string s[M];

int main()
{
    iosks;
    int l,r,d,ans=0;
    cin>>l>>r>>d;
    xh1(l,r+1) if(i%d==0) ans++;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 4604
#coding:UTF-8
num = int(input())
s = input()
ss = s.split(" ")
t = int(ss[0])
a = int(ss[1])
high = input()
high_list = high.split(" ")
calc_list = list()
for i in range(num):
  high_work = int(high_list[i])
  work = t-high_work*0.006
  calc_list.append(abs(a-work))
print(calc_list.index(min(calc_list))+1)

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

int main()
{
    int a, b, c, d, e, k;
    cin >> a >> b >> c >> d >> e >> k;

    if (e - a > k) cout << ":(" << endl;
    else cout << "Yay!" << endl;


    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int main(){
    int n,l,sum=0;
    int kouho = 100000;
    cin >> n >> l;
    rep(i,n){
        sum += i+l;
        kouho = min(kouho,abs(l+i));
    }
    if(sum>0) cout << sum-kouho<<endl;
    else cout << sum+kouho << endl;
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define veci(x,n) vector<int> x((int) (n))
#define vecs(x,n) vector<string> x((int) (n))
#define vecbf(x,n) vector<bool> x((int) (n), false)

int main(){
  int n;
  cin >> n;
  vector<long> luca(87);
  luca.at(0) = 2;
  luca.at(1) = 1;
  for(int i=2;i<=86;i++){
    luca.at(i) = luca.at(i-1) + luca.at(i-2);
  }
  cout << luca.at(n) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <set>
 
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,j) FOR(i,0,j)
#define mp std::make_pair
 
const int INF = 1 << 30;
const int dx[4] = {0, 0, 1, -1}, dy[4] = {1, -1, 0, 0};
 
typedef unsigned long long ull;
typedef std::pair<int,int> P;
typedef std::pair<int,P> State;
 
int R, W[2], H[2], X[2], Y[2];
int Room[2][500][500];
std::vector<int> L[2]; // 事務所ごとの存在するレベル
int maxR[2][250001]; // maxR[i][j]: 事務所iでj番目に小さいレベルで行ける部屋の数
int used[500][500];
 
void travel(int r){
    REP(j, H[r]){
        REP(k, W[r]){
            used[j][k] = 0;
        }
    }
     
    std::priority_queue<State, std::vector<State>, std::greater<State>> q;
    q.push(mp(1, mp(X[r], Y[r])));
 
    while(!q.empty()){
        State s = q.top(); q.pop();
        int l = s.first;
        P p = s.second;
        int x = p.first, y = p.second;
 
        //std::cout << x << "," << y << "," << l << std::endl;
 
        if(used[y][x]){continue;}
        else{used[y][x] = 1;}

        maxR[r][std::lower_bound(L[r].begin(), L[r].end(), l) - L[r].begin()]++;

        REP(i, 4){
            int nx = x + dx[i], ny = y + dy[i];
            if(0 <= nx && nx < W[r] && 0 <= ny && ny < H[r] && !used[ny][nx]){
 
                int nl = std::max(l, Room[r][ny][nx]);
 
                q.push(mp(nl, mp(nx, ny)));
            }
        }
    }
}
 
int main(){
    while(std::cin >> R, R){
        REP(i, 2){
            std::cin >> W[i] >> H[i] >> X[i] >> Y[i];
            X[i]--; Y[i]--;
 
            L[i].clear();
            L[i].push_back(0);
            REP(j, H[i]){
                REP(k, W[i]){
                    std::cin >> Room[i][j][k];
                    L[i].push_back(Room[i][j][k]);
                }
            }
 
            std::sort(L[i].begin(), L[i].end());
            L[i].erase(std::unique(L[i].begin(), L[i].end()), L[i].end());
        }
 
        REP(i, 2){
            REP(j, L[i].size()){
                maxR[i][j] = 0;
            }
        }
 
        REP(i, 2){
            travel(i);
        }
 
        REP(i, 2){
            //std::cout << maxR[i][0] << std::endl;
            FOR(j, 1, L[i].size()){
                maxR[i][j] += maxR[i][j-1];
                // std::cout << maxR[i][j] << std::endl;
            }
            // puts("##############################");
        }
 
        int res = INF;
        REP(i, L[0].size()){
            int r1 = maxR[0][i],
                r2_index = std::lower_bound(maxR[1], maxR[1]+L[1].size(), R-r1) - maxR[1];
         
            if(r2_index == L[1].size()){
                continue;
            }
 
            res = std::min(res, L[0][i] + L[1][r2_index]);
        }
 
        std::cout << res << std::endl;
    }
}

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


void solve(){
    int n; cin >> n;
    int a[n];
    for(int i = 0;i < n; ++i) cin >> a[i];
    int q; cin >> q;
    while(q--){
        int k;cin >> k;
        int left = 0;
        int right = n;
        int middle = (right + left)/2;
        while(left < right){
            if(a[middle] >= k){
                right = middle;
            } else {
                left = middle + 1;
            }
            middle = (left + right)/2;
        }
        cout << middle << endl;
    }
}

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


Measured memory_bytes: 3500
#include<algorithm>
#include<bitset>
#include<cmath>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<string>
#include<unordered_map>
#include<utility>
#include<vector>

constexpr int IINF = (1 << 30) - 1;
constexpr long long LLINF = 1LL << 61;

template<typename T>
bool chmax(T& a, T b){
    if(a < b){
        a = b;
        return true;
    }
    return false;
}

template<typename T>
bool chmin(T& a, T b){
    if(b < a){
        a = b;
        return true;
    }
    return false;
}

class UnionFind{
    using Weight = long long;

    int n;
    std::vector<int> par;
    std::vector<Weight> weight;
    int siz;

public:
    UnionFind(int n_ = 0){
        init(n_);
    }

    void init(int n_ = 0){
        n = n_;
        par.assign(n, -1);
        weight.assign(n, 0);
        siz = n;
        return;
    }

    int find(int x){
        if(par[x] < 0){
            return x;
        }
        int root = find(par[x]);
        weight[x] += weight[par[x]];
        return par[x] = root;
    }

    bool same(int x, int y){
        return find(x) == find(y);
    }

    Weight get_weight(int x){
        find(x);
        return weight[x];
    }

    bool unite(int x, int y, Weight w = 0){
        w += get_weight(x) - get_weight(y);

        x = find(x);
        y = find(y);

        if(x == y){
            return false;
        }

        if(par[x] < par[y]){
            std::swap(x, y);
            w = -w;
        }

        par[x] += par[y];
        par[y] = x;
        weight[y] = w;
        --siz;

        return true;
    }

    Weight diff(int x, int y){
        return get_weight(y) - get_weight(x);
    }

    int size_of_set(int x){
        return -par[find(x)];
    }

    int count_set(void){
        return siz;
    }
};

int main(){
    int n, m;
    std::cin >> n >> m;

    UnionFind uf(n);
    for(int i = 0 ; i < m ; ++i){
        int x, y, z;
        std::cin >> x >> y >> z;
        uf.unite(x - 1, y - 1);
    }

    std::cout << uf.count_set() << std::endl;

    return 0;
}

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

int main(){
    string s;
    cin>>s;

    int l = s.length();

    bool result = true;

    for(int i=0; i<l; i++){
        if((i+1) & 1){
            if(s[i] == 'L'){
                result = false;
                break;
            }
        }
        else{
            if(s[i] == 'R'){
                result = false;
                break;
            }
        }
    }

    if(result){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }

}


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

const int N = (1e5) + 5;
int n, a[N];

int main() { // claudio van
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  int sum = 0;
  for (int i = 0; i + 1 < n; ++i) {
    for (int j = i + 1; j < n; ++j) {
      sum += a[i] * a[j];
    }
  }
  cout << sum << "\n";
  return 0;
}

Measured memory_bytes: 256