akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define eb emplace_back
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (ll) (x).size()
#define pq priority_queue<ll>
#define pqg priority_queue<ll,vector<ll>,greater<ll>>
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) sort(v.begin(),v.end());v.erase(unique(v.begin(),v.end()),v.end())
#define int ll
// #define ll int
using namespace std;
const ll INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const ll mod = 998244353;
const ll MAX = 1100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[4] ={1,0,-1,0} , dy[4] ={0,1,0,-1};

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

struct Timer{
    chrono::system_clock::time_point start, end;
    Timer(){ start = chrono::system_clock::now(); }
    ~Timer(){
        end = chrono::system_clock::now();
        auto msec = chrono::duration_cast<chrono::milliseconds>(end - start).count();
        cerr<<"time : "<<msec<<" ms"<<endl;
    }
};



void solve(){
    ll a,b;
    cin>>a>>b;
    cout<<(a+b+1)/2<<endl;

}


signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    // Timer TM;
    
    solve();

    return 0;
}


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

class UnionFind {
private:
  int sz;
  vector<int> par, siz;
public:
  UnionFind() {}
  UnionFind(int n) : sz(n), par(sz), siz(sz, 1) {
    iota(par.begin(), par.end(), 0);
  }
  int root(int x) {
    if (par.at(x) == x) return x;
    else return par.at(x) = root(par.at(x));
  }
  void unit(int x,int y) {
    x = root(x), y = root(y);
    if (x == y) return;
    if (siz.at(x) < siz.at(y)) swap(x, y);
    par.at(y) = x;
    siz.at(x) += siz.at(y);
  }
  int size(int x) {
    x = root(x);
    return siz.at(x);
  }
  bool same(int x, int y) {
    return root(x) == root(y);
  }
};

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int N, M;
  cin >> N >> M;
  UnionFind UF(N);
  for (int i = 0; i < M; i++) {
    int A, B;
    cin >> A >> B;
    A--, B--;
    if (!UF.same(A, B)) UF.unit(A, B);
  }
  int mx = 0;
  for (int i = 0; i < N; i++) {
    mx = max(mx, UF.size(i));
  }
  cout << mx << "\n";
}

Measured memory_bytes: 4772
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
using namespace std;

int main() {

	int n;
	string s;
	string t;

	cin >> n >> s >> t;

	int r;
	rep(i, 0, n) {
		int f = 0;
		r = i;
		if (s[i] == t[0]) {
			rep(j, 1, n-i) {
				if (s[i + j] != t[j]) {
					f = 1;
					break;
				}
			}
		}
		else {
			f = 1;
			r++;
		}
		if (f == 0) break;
	}

	cout << n + r << endl;
	
	return 0;
}

Measured memory_bytes: 256
n=int(input())
l=list(map(int,input()))

a=[]
b=[]
c=[]
m=0
for i in range(n-2):
    if l[i] in a:
        continue
    a.append(l[i])
    for j in range(i+1,n-1):
        if l[j] in b:
            continue
        b.append(l[j])
        for k in range(j+1,n):
            if l[k] in c:
                continue
            c.append(l[k])
            m+=1
        c=[]
    b=[]

print(m)




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


int main(void)
{
    long long N,K;
    long long a[210000];

    cin >> N >> K;
    for(int i=0;i<N;++i) cin >> a[i];

    for(int i=K; i < N; ++i){
        if(a[i] > a[i-K]) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
}


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

int main() {

    string S;
    cin >> S;

    if (S[0] == 'A') {
        int cnt = 0;
        for (int i=2; i<S.size()-1; i++) {
            if (S[i]=='C') {
                cnt++;
            }
        }
        if (cnt == 1) {
            bool flg = true;
            for (int i=0; i<S.size(); i++) {
                if (S[i]=='A' || S[i]=='C') {
                    ;
                } else {
                    if((S[i]>= 'A') && (S[i]<='Z'))
                        flg = false;
                }
            }
            if (flg) {
                cout << "AC" << endl;
                return 0;
            }
        }
    }
    cout << "WA" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define For( i, j, k ) for( int i = j; i <= k; ++i )
long long n, s, ans = -1;
using std::cin;
using std::cout;
long long check( long long V, long long k )
{
	long long res = 0;
	while( V )
	{
		res += V % k;
		V /= k;
	}
	return res;
}
int main( )
{
	std::ios::sync_with_stdio( false );
	cin >> n >> s;
	if( n < s )
	{
		cout << -1;
		return 0;
	}
	if( n == s )
	{
		cout << n + 1;
		return 0;
	}
	For( i, 2, 1000000 )
		if( check( n, i ) == s )
		{
			ans = i;
			break;
		}
	if( ~ans )
	{
		cout << ans;
		return 0;
	}
	long long ns = n - s, __ = sqrt( ns );
	For( i, 1, __ )
	{
		if( ns % i == 0 )
		{
			// i, ns /i
			long long k = i;
			long long b = ns / k + 1;
			if( k + n % b == s && b > 1000000 )
			{
				if( !~ans )
					ans = b; 
				else
					ans = std::min( ans, b );
			}
		}
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 3664
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>

#define ll long long
#define ull unsigned long long

using namespace std;

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

	vector <ll> a(N);
	for (int ii = 0; ii < N; ++ii){
		cin >> a[ii];
	}

	vector <ll> ans(N, 0);

	//ans[0]を求める
	for (int ii = 1; ii < N; ++ii){
		ans[0] ^= a[ii];
	}

	ll ref = ans[0] ^ a[0];

	//他の
	for (int ii = 1; ii < N; ++ii){
		ans[ii] = ref ^ a[ii];
	}

	for (int ii = 0; ii < N; ++ii){
		cout << ans[ii] << " ";
	}
	cout << " ";

	return 0;
}


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

using namespace std;

int t;
long long n, a, b, c, d, ans;
map<long long, long long> m;

long long add(long long aa, long long bb) {
	if (bb > LLONG_MAX - aa)
		return LLONG_MAX;
	return aa + bb;
}

long long mul(long long aa, long long bb) {
	if (aa == 0)
		return 0;
	if (bb > LLONG_MAX / aa)
		return LLONG_MAX;
	return aa * bb;
}

void insert(long long aa, long long bb) {
	auto it = m.insert(make_pair(aa, bb)).first;
	it->second = min(it->second, bb);
}

int main() {
	scanf("%d", &t);
	while (t--) {
		scanf("%lld%lld%lld%lld%lld", &n, &a, &b, &c, &d);
		m.clear();
		long long at = n, val = 0;
		m[at] = val;
		while (at) {
			// printf("m[%lld]=%lld\n", at, val);
			insert(0, add(val, mul(at, d)));
			insert(at / 2, add(val, add(mul(at % 2, d), a)));
			insert(at / 2 + 1, add(val, add(mul(2 - at % 2, d), a)));
			insert(at / 3, add(val, add(mul(at % 3, d), b)));
			insert(at / 3 + 1, add(val, add(mul(3 - at % 3, d), b)));
			insert(at / 5, add(val, add(mul(at % 5, d), c)));
			insert(at / 5 + 1, add(val, add(mul(5 - at % 5, d), c)));
			tie(at, val) = *prev(m.find(at));
		}
		printf("%lld\n", m[0]);
	}
}


Measured memory_bytes: 4872
import math

n = int(input())

def mcxi2int(s):
    m = {'m': 1000, 'c': 100, 'x': 10, 'i': 1}

    ret = 0
    i = 0
    while i < (len(s)):
        num = 1
        maci = s[i]
        if maci.isdigit():
            num = int(maci)
            maci = s[i + 1]
            i += 1
        ret += num * m[maci]
        i += 1
    return ret


def int2mcxi(n):
    keys = ['m', 'c', 'x', 'i']
    values = [1000, 100, 10, 1]

    ret = ""
    for k, v in zip(keys, values):
        i = n / v
        n = n % v
        if i == 0:
            continue
        elif i == 1:
            ret = ret + k
        else:
            ret = ret + str(i) + k
    return ret

for _ in range(n):
    m1, m2 = raw_input().split()
    print int2mcxi(mcxi2int(m1) + mcxi2int(m2))

Measured memory_bytes: 6424
f=lambda x,y: int(x.replace("X",str(y)))
q=lambda x:len(str(x))
while True:
	try:
		ex = raw_input()
		a,b,c = ex[0:ex.index("+")],ex[ex.index("+")+1:ex.index("=")],ex[ex.index("=")+1:]
		for i in range(10):
			fa,fb,fc=f(a,i),f(b,i),f(c,i)
			if q(fa)==q(a) and q(fb)==q(b) and q(fc)==q(c):
				ans = i if fa+fb==fc else -1
				if ans!=-1:
					print ans
					break
			else:
				continue
		else:
			print "NA"
	except EOFError:
		break

Measured memory_bytes: 4288
import Control.Applicative
import Data.List
import Data.Int

primes = takeWhile (<=(truncate . sqrt . fromIntegral $ 10^9)) $ aux [2..]
  where aux (x:xs) = x : aux [y | y<-xs, y`mod`x/=0]

factorize n = aux n primes
  where
    aux n [] = if n == 1 then [] else [n]
    aux n (p:ps)
      | n `mod` p == 0 = p : aux (n`div`p) (p:ps)
      | otherwise = aux n ps

{-- nCk mod p (pは素数)--}
combinationModP :: Integral a => a -> a -> a -> a
combinationModP n k p
  | n < k || n < 0 || k < 0 = 0
  | n == 0 || k == 0 = 1
  | otherwise = (n * (powerMod k (p-2) p) * combinationModP (n-1) (k-1) p) `mod` p


{-- n^p mod m --}
powerMod :: Integral a => a -> a -> a -> a
powerMod n 0 m = 1
powerMod n 1 m = n `mod` m
powerMod n p m = (k * k * (if mod p 2 == 0 then 1 else n)) `mod` m
  where
    k = powerMod n (div p 2) m

main :: IO ()
main = do
  [n,m] <- map read . words <$> getLine :: IO [Integer]

  let
    fs = map (fromIntegral . length) . group . factorize $ m
    p = 10^9+7

  print $ foldl (\a b -> (a*b) `mod` p) 1 [combinationModP (n+a-1) a p | a<-fs]


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

#define ll long long 
using namespace std;



main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	map<ll,ll> mp;
	multimap<ll,ll>mp1;
	ll test,n,i,j,area,flag=0,a[100000*2],d=0,m=INT_MAX,amt,r,a2[100000*2],x,y,k,K,I,m1,m2,m3,o,o1,o2,o3,dp[100000*2],dp2[100000*2];
	
	cin>>n>>k;
	for(i=1;i<=n;++i)
		cin>>a[i];
	
	dp[1]=0;
	for(i=2;i<=k && i<=n;++i){
		dp[i]=abs(a[1]-a[i]);}
	
	for(i=k+1;i<=n;++i){
		for(j=1;i-j>=0 && j<=k;++j){
			dp[i]=dp[i-j]+abs(a[i-j]-a[i]);
			if(dp[i]<m)
				m=dp[i];}
			dp[i]=m;
			m=INT_MAX;}
		
	cout<<dp[n]<<endl;
	
	}
		
	

Measured memory_bytes: 3072
#include <math.h>
#include <bits/stdc++.h>//一括で読み込み
typedef long long ll;
using namespace std;

struct flowEdge 
{
	ll to, cap, rev;
};

class Max_Flow
//最大流問題のDinic法。頂点数10^3,辺数10^4程度なら大体間に合う
//またはO(最大流*辺数)
{
public:
	vector<vector<flowEdge>> G;
	vector<ll>level, iter;

	void init(ll size_) 
  {
		G.resize(size_);
		level.resize(size_);
		iter.resize(size_);
	}

	void add_flowEdge(ll from, ll to, ll cap) 
  {
		G[from].push_back(flowEdge{to, cap, (ll)G[to].size()});
		G[to].push_back(flowEdge{from, 0, (ll)G[from].size()-1});
	}

	void bfs(ll s) 
  {
		for (ll i = 0; i < level.size(); i++) level[i] = -1;
		queue<ll> que;
		level[s] = 0;
		que.push(s);
		while (!que.empty())
    {
			ll v = que.front(); que.pop();
			for (ll i = 0; i < G[v].size(); i++)
      {
				flowEdge &e = G[v][i];
				if (e.cap > 0 && level[e.to] < 0) 
        {
					level[e.to] = level[v] + 1;
					que.push(e.to);
				}
			}
		}
	}

	ll dfs(ll v, ll t, ll f) 
  {
		if (v == t) return f;
		for (ll &i = iter[v]; i < G[v].size(); i++)
    {
			flowEdge &e = G[v][i];
			if (e.cap > 0 && level[v] < level[e.to])
      {
				ll d = dfs(e.to, t, min(f, e.cap));
				if (d > 0) {
					e.cap -= d;
					G[e.to][e.rev].cap += d;
					return d;
				}
			}
		}
		return 0;
	}

	ll max_flow(ll s, ll t)
  {
		ll flow = 0;
		for(;;)
    {
			bfs(s);
			if (level[t] < 0) return flow;
			for (int i = 0; i < iter.size(); i++) iter[i] = 0;
			ll f;
			while ((f = dfs(s, t, (1LL<<60))) > 0)
      {
				flow += f;
			}
		}
	}
};

ll x, y, e, a, b;

vector<pair<ll, ll>> L;//最大流の頂点

int main()
{
	cin >> x >> y >> e;
  
  Max_Flow X;
  X.init(x+y+2);//頂点数で初期化

  for (int i = 0; i < e; i++)//辺数
  {
    cin >> a >> b;
    X.add_flowEdge(a+1, x+1+b, 1);//つなぐ頂点とコスト
  }
  
	for (int i = 0; i < x; i++) 
  {
		X.add_flowEdge(0, i+1, 1);
	}
  for (int i = 0; i < y; i++) 
  {
		X.add_flowEdge(x+1+i, x+y+1, 1);
	}
  
	cout << X.max_flow(0, x+y+1) << endl;//開始頂点から終了頂点までの最大流を求める
	return 0;
}


Measured memory_bytes: 3440
#include <iostream>
#include <numeric>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <utility>
using namespace std;
#define INF 100000000
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define rep(i, n) for(int (i)=1; (i)<=(n); (i)++)
typedef pair<int, int> P;
typedef long long ll;
int main(){
    int H, W;
    cin >> H >> W;
    vector<string> a(H);

    for(int i=0; i<H; i++){
        cin >> a[i];
    }

    vector<bool> row(H, false);
    vector<bool> col(W, false);
    for(int i=0; i<H; i++){
        for(int j=0; j<W; j++){
            if(a[i][j] == '#'){
                row[i] = true;
                col[j] = true;
            }
        }
    }

    for(int i=0; i<H; i++){
        if(row[i]){
            for(int j=0; j<W; j++){
                if(col[j]){
                    cout << a[i][j];
                }
            }
            cout << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
typedef long long ll;

int main(void) {
  ll n, i, j, k;
  scanf("%lld", &n);
  ll dp[n][9];
  char s[2][n +10];
  for(i = 0; i < 2; ++i) scanf("%s", s[i]);
  for(i = 0; i < n; ++i) for(j = 0; j < 9; ++j) dp[i][j] = 0;
  for(i = 0; i < 9; ++i) {
    if((i % 3 == i / 3 && s[0][0] == s[1][0]) || (i % 3 != i / 3 && s[0][0] != s[1][0])) ++dp[0][i];
  }
  for(i = 1; i < n; ++i) {
    for(j = 0; j < 9; ++j) {
      for(k = 0; k < 9; ++k) if((k % 3 == k / 3 && s[0][i] == s[1][i]) || (k % 3 != k / 3 && s[0][i] != s[1][i])) {
        if(s[0][i] == s[0][i - 1]) {
          if(j % 3 == k % 3 && j / 3 == k / 3) dp[i][k] += dp[i - 1][j];
        } else {
          if(j % 3 != k % 3 && j / 3 != k / 3) dp[i][k] += dp[i - 1][j];
        }
      }
    }
    for(j = 0; j < 9; ++j) dp[i][j] %= 1000000007;
  }
  ll ans = 0;
  for(i = 0; i < 9; ++i) ans += dp[n - 1][i];
  ans %= 1000000007;
  printf("%lld", ans);
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>

int main(){
    int a, b;
    std::cin>>a>>b;

    int k = [](int n) -> int {
        if(n / 10 == 0){
            return 10;
        }else if(n / 10 == 10){
            return 1000;
        }else{
            return 100;
        }
    }(b) * a + b;
    std::string ans = "No";
    for(int i = 1;i <= 1000;i++){
        if(i * i == k){
            ans = "Yes";
            break;
        }
    }
    std::cout<<ans<<std::endl;
    return 0;
}

Measured memory_bytes: 256
"""
C - Average Length
https://atcoder.jp/contests/abc145/tasks/abc145_c
"""
import itertools

n = int(input())
point = [list(map(int, input().split())) for i in range(n)]

distances = []

for i in range(n-1):
    for j in range(i+1, n):
        xi, yi = point[i]
        xj, yj = point[j]

        d = pow(pow(xi - xj, 2) + pow(yi - yj, 2), 0.5)
        distances.append(d)

ans = 2* sum(distances) / n

print(ans)


Measured memory_bytes: 3188
<?php
$n = intval(fgets(STDIN));
for($i = 0; $i < $n; $i++){
  $a[$i] = intval(fgets(STDIN));
  for($j = 0; $j < $a[$i]; $j++){
    list($b, $c) = array_map("intval", explode(" ", trim(fgets(STDIN))));
    $map[$i][$b-1] = $c; 
  }
}
$max = 0;
for($i = 0, $I = 2**$n; $i < $I; $i++){
  $bits = sprintf("%0".$n."b", $i);
  $flag = true;
  foreach($map as $from => $row){
    if($bits[$from] == "1"){ 
      foreach($row as $to => $v){
        if($bits[$to] != $v){ 
          $flag = false;
          continue 3;
        }
      }
    }
  }
  if($flag){
    $sum = 0;
    for($j = 0; $j < $n; $j++){
      $sum+=$bits[$j];
    }
    $max = max($max, $sum);
  }
}
echo $max;


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

using namespace std;

int main()
{
    string s,r;
    cin >> s;
    for(int bit = 0; bit <(1<<3); bit++)
    {
         int tmp = s[0] - '0';
          r = "=7";
        for(int i = 0; i < 3; i++)
        {
            if(bit&(1<<i))
            {
                tmp += s[3-i] - '0';
                r = s[3-i] + r;
                r = "+" + r ;
            }
            else
            {
                tmp -= s[3-i] - '0';
                r = s[3-i] + r;
                r = "-" + r;
            }
        }
        if(tmp == 7)
        {
            r= s[0] + r;
            cout << r;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

		String[] s = {sc.nextLine(), sc.nextLine(), sc.nextLine()};

		int turn = 'a';
		while (true) {
			if (s[turn - 'a'].length() == 0) {
				break;
			}
			char c = s[turn - 'a'].charAt(0);
			s[turn - 'a'] = s[turn - 'a'].substring(1);
			turn = c;
		}
		System.out.println(turn == 'a' ? "A" : turn == 'b' ? "B" : "C");
	}
}



Measured memory_bytes: 22996
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cstring>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <stack>
#include <cmath>
#define ll long long
#define LINF 0x3f3f3f3f3f3f3f3f
#define INF 0x3f3f3f3f
#define PI 3.14159265
using namespace std;
const int MAX = 1e5 + 10;
const ll MOD = 1e9 + 7;
int N, M, K, Q;
ll dp[3000][55];
int B[55];

int main()
{
	int i, j, k, A;
	scanf("%d%d", &N, &A);
	for (i = 1; i <= N; ++i) {
		scanf("%d", B + i);
	}

	for (i = 1; i <= N; ++i) {
		for (j = A*N; j >= 0; --j) {
			for (k = 2; k <= i; ++k) {
				if(j - B[i] >0) dp[j][k] += dp[j - B[i]][k - 1];
			}
		}
		dp[B[i]][1]++;
	}
	ll sum = 0;
	for (i = 1; i <= N; ++i) {
		sum += dp[A*i][i];
	}
	printf("%lld", sum);
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, a, b) for (int i = (a); i < (b); i++)
//#include "library/debug.cpp"

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

    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    rep(i, 0, n) cin >> a[i];
    vector<vector<bool>> b(n + 2, vector<bool>(k + 1)), c(n + 2, vector<bool>(k + 1));
    b[0][0] = true;
    c[n + 1][0] = true;

    rep(i, 0, n) {
        b[i + 1] = b[i];
        rep(j, 0, k) if (b[i][j]) {
            if (k > j + a[i])
                b[i + 1][j + a[i]] = true;
            else
                break;
        }
    }
    for (int i = n - 1; i >= 0; i--) {
        c[i + 1] = c[i + 2];
        rep(j, 0, k) if (c[i + 2][j]) {
            if (k > j + a[i])
                c[i + 1][j + a[i]] = true;
            else
                break;
        }
    }
    int ans = n;
    rep(i, 0, n) {
        if (a[i] >= k) {
            ans--;
            continue;
        }
        int sum = 0;
        vector<int> x;
        x.emplace_back(-1e5);
        rep(j, 0, k) if (c[i + 2][j]) x.emplace_back(j);
        x.emplace_back(k);
        rep(j, 0, k) if (b[i][j]) {
            int s = j;
            int t = *(lower_bound(x.begin(), x.end(), k - s) - 1);
            if (0 <= s + t && s + t < k)
                sum = max(s + t, sum);
            if (sum + a[i] >= k) {
                ans--;
                break;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
    int x1,x2,x3,x4,x5;
    cin >> x1 >> x2 >> x3 >> x4 >> x5;
    int ans = 0;
    if(x1 == 0){ans = 1;}
    if(x2 == 0){ans = 2;}
    if(x3 == 0){ans = 3;}
    if(x4 == 0){ans = 4;}
    if(x5 == 0){ans = 5;}
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
#include <stdio.h>
#include <cmath>
#include <tgmath.h>

using namespace std;

#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
//rep…「0からn-1まで」の繰り返し
#define rep2(i,s,n) for(long long i=s; i<=(long long)(n);i++)
//rep2…「sからnまで」の繰り返し
#define repr(i,s,n) for(long long i=s;i>=(long long)(n);i--)
//repr…「ｓからnまで」の降順の繰り返し

typedef long long ll;

const ll inf = 1e18+7;
const ll mod = 1e9+7;


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

    ll ans=0;

    bool jdg=true;
    
    if(s.size()==1){
          cout<<0<<endl;
          return 0;
      }

    while(jdg){
        jdg=false;
        rep(i,s.size()-1){
            if(s[i]!=s[i+1]){
                s.erase(s.begin()+i,s.begin()+i+2);
                ans+=2;
                jdg=true;
                break;
            }
        }
    }

    cout<<ans<<endl;
}


Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<algorithm>
#include<climits>

using namespace std;

int main(void){
  int N, T;
  cin >> N >> T;
  vector<int> cv(N, INT_MAX);
  for(int i = 0; i < N; i++){
    int c, t;
    cin >> c >> t;
    if(t <= T) cv[i] = c;
  }
  auto itr = min_element(cv.begin(), cv.end());
  if(*itr == INT_MAX) cout << "TLE" << endl;
  else cout << *itr << endl;
  return 0;
}

  

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

int main(){
  int x1,x2,x3,x4,x5;
  cin>>x1>>x2>>x3>>x4>>x5;
  if(x1==0)
    cout<<"1"<<endl;
  else if(x2==0)
    cout<<"2"<<endl;
  else if(x3==0)
    cout<<"3"<<endl;
  else if(x4==0)
    cout<<"4"<<endl;
  else
    cout<<"5"<<endl;
}

Measured memory_bytes: 3632
import java.util.*;
import java.io.*;

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

        int T = Integer.parseInt(sc.next());
        int X = Integer.parseInt(sc.next());
        sc.close();

        double t = (double)T / X;
        out.printf("%.10f\n", t);
        out.flush();
    }
}


Measured memory_bytes: 23764
how_many = int(input())
results = []
index = 0
numbers = {index+1:int(item) for index,item in zip(range(how_many),input().split())}
for key_value in numbers.items():
  if key_value[0] % 2 == 1 and key_value[1] % 2 == 1:
    results.append(True)
print(len(results))


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

int N;
int n,k;
int main() {
	cin >> N;
	for (int i=0; i<N; ++i){
		cin >> n >> k;
		int A[n];
		for (int i=0; i<n; ++i){
			cin >> A[i];
		}
		int B[n];
		for (int i=0; i<n; ++i){
			B[i] = A[i+1] - A[i];
		}
		sort(B,B+n-1);
		int dist = 0;
		for (int i=0; i<n-k; ++i){
			dist += B[i];
		}
		cout << dist << endl;
	}
}

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

class Main{

    static long L;

    static long grundy(long v){
        for(long i=0;i<60;++i)if(((v>>i)&1)==1)return (1L<<i);
        return 0;
    }

    // どの高さの木を新しく踏んだか？
    // 一番最初に未踏の地を踏んだとこの木を消す
    // そこから一番最後一個手前までの木を追加する

    static class Node{
        Node next[] = new Node[2];
        long depth = 0;
        Node(long d){
            depth=d;
        }
        void add(int i){
            next[i]=new Node(depth + 1);
        }
    }

    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int N = scan.nextInt();
        L  = scan.nextLong();
        Node root = new Node(-1);
        Map<Long, Integer> trees = new HashMap<>();
        trees.put(L, 2);
        for(int i=0;i<N;++i){
            String s = scan.next();
            Node r = root;
            long first=-1;
            for(int j=0;j<s.length();++j){
                int n = s.charAt(j)-'0';
                if(r.next[n]==null){
                    r.add(n);
                    r=r.next[n];
                    if(first<0){
                        first=L-r.depth;
                        trees.put(L-r.depth, trees.get(L-r.depth)-1);
                    }
                    else{
                        if(!trees.containsKey(L-r.depth))trees.put(L-r.depth, 0);
                        trees.put(L-r.depth, trees.get(L-r.depth)+1); // getだけで出来る？
                    }
                }else{
                    r=r.next[n];
                }
            }
        }
        long grn = 0;
        for(Map.Entry<Long,Integer> entry : trees.entrySet()){
            if((long)entry.getValue()%2==1)grn^=grundy((long)entry.getKey());
        }
        System.out.println(grn==0 ? "Bob":"Alice");
        
    }
}

Measured memory_bytes: 47148
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cctype>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip>
#include <cstdio>
#include <numeric>
#include <functional>
#include <cstdlib>
#include <regex>
#include <list>
	int main() {
		std::string s;
		std::cin >> s;
		int a = s.size();
		char d, w;
			d = s[0];
			w = s[a - 1];
			std::cout << d << a - 2 << w << std::endl;
			return 0;
	}

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

int main(){
  string S;
  string T;
  cin >> S >> T;
  int cnt = 0;
  for(int i = 0; i < 3; i++){
    if(S[i] == T[i]) cnt++;
  }
  printf("%d\n", cnt);
  return 0;
}


Measured memory_bytes: 256
n = int(input())
t,a = map(int,input().split())
h = list(map(int,input().split()))
ans = -1.0
d = 1e100
for i,j in enumerate(h):
  if abs(t - j*0.006 - a) < d:
    ans = i+1
    d = abs(t - j*0.006 - a)
print(ans)


Measured memory_bytes: 3060
def main():
    _ = int(input())
    A = list(map(int, input().split()))

    A.sort()
    a_max = A[-1]
    dp = [0] * (a_max + 1)

    for a in A:
        if dp[a] != 0:
            dp[a] = 2
            continue

        i = a
        while i < a_max + 1:
            dp[i] += 1
            i += a

    r = 0
    for a in A:
        if dp[a] == 1:
            r += 1

    print(r)


if __name__ == '__main__':
    main()

Measured memory_bytes: 32120
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int d = sc.nextInt();
		double[][] list = new double[n][d];
		for(int i = 0; i < n; i++) {
			for(int j = 0; j < d; j++) {
				list[i][j] = sc.nextDouble();
			}
		}
		long ans = 0;
		for(int i = 0; i < n - 1; i++) {
			for(int j = i + 1; j < n; j++) {
				double dis = 0;
				for(int k = 0; k < d; k++) {
					dis += Math.pow(list[i][k] - list[j][k], 2);
				}
				dis = Math.sqrt(dis);
				if(dis == (long) dis) {
					ans++;
				}
			}
		}
		System.out.println(ans);

	}

}


Measured memory_bytes: 23252
#include<bits/stdc++.h>
#define maxn 100050
#define inf 0x3f3f3f3f
#define LL long long
#define pb push_back
#define pii pair<int,int>
#define fi first
#define se second
#define mm(a,b) memset(a,b,sizeof(a))
#define mp(a,b) make_pair(a,b)
const LL mod=1e9+7;
const LL INF=(LL)1e18;
using namespace std;
struct node{
	int x,y,id;
	node(){}
	node(int x,int y,int id):x(x),y(y),id(id){}
}s[maxn];
struct edge{
	int u,v,w;
	edge(){}
	edge(int u,int v,int w):u(u),v(v),w(w){}
	bool operator < (const edge& x) const{
		return w<x.w;
	}
}e[maxn<<1];
int n,len;
int p[maxn];
int cmp1(node a,node b){
	return a.x<b.x;
}
int cmp2(node a,node b){
	return a.y<b.y;
}
int find(int x){
	return x==p[x]?x:p[x]=find(p[x]);
}
int kruskal(){
	int ans=0;
	int cnt=0;
	sort(e,e+len);
	for(int i=0;i<=n;i++) p[i]=i;
	for(int i=0;i<len;i++){
		int x=find(e[i].u),y=find(e[i].v);
		if(x!=y){
			ans+=e[i].w;
			p[x]=y;
			cnt++;
		}
		if(cnt==n-1) break;
	}
	return ans;
}
int main(){
//	freopen("input.txt","r",stdin);
//	freopen("ouput.txt","w",sdout);
	ios::sync_with_stdio(false);
	cin.tie(0),cout.tie(0);
	cin>>n;
	for(int i=0;i<n;i++){
		int x,y;
		cin>>x>>y;
		s[i]=node(x,y,i+1);
	}
	sort(s,s+n,cmp1);
	len=0;
	for(int i=0;i<n-1;i++){
		int ww=min(abs(s[i+1].x-s[i].x),abs(s[i+1].y-s[i].y));
		e[len++]=edge(s[i].id,s[i+1].id,ww);
	}
	sort(s,s+n,cmp2);
	for(int i=0;i<n-1;i++){
		int ww=min(abs(s[i+1].x-s[i].x),abs(s[i+1].y-s[i].y));
		e[len++]=edge(s[i].id,s[i+1].id,ww);
	}
	cout<<kruskal()<<endl;
	return 0;
}

Measured memory_bytes: 4224
package main

import (
  "fmt"
  "strconv"
)

func main() {
  var h, w int
  var s string
  fmt.Scanf("%d %d", &h, &w)
  
  ans := ""
end:
  for i := 0; i < h; i++ {
    for j := 0; j < w; j++ {
      fmt.Scanf("%s", &s)
      if s == "snuke"{
        ans = string(65+j) + strconv.Itoa(i+1)
        break end
      }
    }
  }
  
  fmt.Printf("%s\n", ans)
}

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

int main()
{
    int a,b;
    int res;

    scanf("%d%d",&a,&b);

    if((a+b)%2)
        printf("%d\n",(a+b)/2+1);
    else
        printf("%d\n",(a+b)/2);

    return 0;
}

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

int main(int argc, const char * argv[]) {
    int N; cin >> N;
    vector<int> A(N+2);
    A[0] = 0;
    for(int i = 1; i <= N; i++) {
        int inp; cin >> inp;
        A[i] = inp;
    }
    A[N+1] = 0;
    
    int sum = 0;
    for(int i = 1; i <= N+1; i++) {
        sum += abs(A[i] - A[i-1]);
    }
    
    for(int i = 1; i <= N; i++) {
        cout << sum - abs(A[i-1]-A[i]) - abs(A[i] - A[i+1]) + abs(A[i-1] - A[i+1]) << endl;
    }
    
    return 0;
}


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

int main()
{
    using namespace std;
    int n;
    cin >> n;
    vector<pair<int, pair<int, int>>> point(n);
    try {
        for (int i = 0; i < n; i++) {
            cin >> point[i].second.first >> point[i].second.second >> point[i].first;
        }
        for (int cx = 0; cx < 101; cx++) {
            for (int cy = 0; cy < 101; cy++) {
                int H;
                bool flag = true;
                for (auto&& var : point) {
                    if (var.first > 0) {
                        H = var.first + abs(var.second.first - cx) + abs(var.second.second - cy);
                        break;
                    }
                }
                for (auto&& var : point) {
                    if ((var.first > 0 && H != var.first + abs(var.second.first - cx) + abs(var.second.second - cy)) || (var.first == 0 && H > abs(var.second.first - cx) + abs(var.second.second - cy))) {
                        flag = false;
                        break;
                    }
                }
                if (flag) {
                    std::cout << cx << " " << cy << " " << H << std::endl;
                    throw exception();
                }
            }
        }
    } catch (exception& e) {
        return 0;
    }

    return 0;
}

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

int main(void)
{
  int a,b,c;
  unsigned long long d;
  cin>>a>>b>>c>>d;
  if(abs(b-a)>= pow(10,18))
    cout<<"Unfair";
  if(d%2==1)
    cout<<b-a;
  else
    cout<<a-b;

return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;
#define f(i, n) for(int i = 0; i < n; ++i)
#define pb push_back
typedef long long int ll;

void input(){
   string s, t;
   cin >> s >> t;
   int l1 = s.size(), l2 = t.size();
   string temp = s;
   map<char, int>m;
   f(i, l1)m[s[i]]++;
   f(i, l2){
    if(!m[t[i]]){
        cout << -1 << endl;return;
    }
   }
   map<char, int>fir;
   f(i, l1){
       if(fir.find(s[i]) == fir.end()){
        fir.insert({s[i], i});
       }
   }
   map<char, set<int> > all;
   f(i, l1){
    all[s[i]].insert(i);
   }
   ll ans  = 0;
   int j = 0;
   f(i, l2){
     char c = t[i];
     auto it = all[c].lower_bound(j);
     if(it != all[c].end()){
        ans += ((*it) - j + 1);
        j = ((*it) + 1) % l1;
     }else{
        ans += l1 - j;
        int x = fir[c];
        ans += x + 1;
        j = x + 1;
     }
   }
   cout << ans << endl;
}
int main()
{
 input();
 return 0;
}


Measured memory_bytes: 5248
import sys
#print(316736)
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
from operator import itemgetter
N,M=map(int,readline().split())
ab=[]
#print(112)
for i in range(M):
    x,y=map(int,readline().split())
    ab.append((x,y))
#print(111)
ab=sorted(ab,key=itemgetter(1))
ans=0
x=0
for a,b in ab:
    #print(a,x,b)
    if a<=x:
        continue
    x=b-1
    ans+=1
print(ans)

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

using namespace std;

/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree < int ,  null_type ,  less<int> ,  rb_tree_tag ,  tree_order_statistics_node_update >
#define smallk order_of_key
#define kth find_by_order
*/

#define nl '\n'
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define pb push_back

typedef long long ll;

const int N = (int)1 + 123;
const int M = 1e9 + 7;
const int K = 500;

int n;
long long W;
long long w[N], v[N];
int main(){

    //ios_base :: sync_with_stdio(0), cin.tie(0), cout.tie(0);

    #ifdef LOCAL
        freopen("B.txt", "r", stdin);
    #endif // LOCAL

    cin >> n >> W;
    int mx = 0;
    for(int i = 1; i <= n; ++i) {
            cin >> w[i] >> v[i]; mx += v[i];
    }
    vector<long long> wei(mx + 1, -1);
    mx = 0;
    wei[0] = 0;
    int ans = 0;
    for(int i = 1; i <= n; ++i){
        mx += v[i];
        for(int j = mx; j >= v[i]; --j){
            if(wei[j - v[i]] != -1){
                long long weireq = wei[j - v[i]] + w[i];
                if(weireq <= W){
                    ans = max(ans, j);
                }
                if(wei[j] == -1 || wei[j] > weireq){
                    wei[j] = weireq;
                }
            }
        }
    }
    cout << ans;
    return 0;
}



Measured memory_bytes: 1024
n,k = map(int,input().split())
h = list(int(input()) for _ in range(n))

h.sort(reverse = True)
answer = h[0] - h[k-1]

for i in range(1,n-k+1):
    if h[i] - h[i+k-1] < answer:
        answer = h[i] - h[i+k-1]

print(answer)


Measured memory_bytes: 7496
//
//  main.cpp
//  usaco
//
//  Created by 김현수 on 2020/08/30.
//  Copyright © 2020 김현수. All rights reserved.
//

#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int main()
{
    int a, b;
    scanf("%d %d", &a, &b);
    if(a>8 or b>8)
    {
        printf(":(");
    }
    else
    {
        printf("Yay!");
    }
}


Measured memory_bytes: 3660
import collections

n,q = map(int, input().split())
cnt = [0] * (n+1)
g = [[] for _ in range(n+1)]

for _ in range(n-1):    #隣接リストの生成
    a,b = map(int, input().split())
    g[a].append(b)
    g[b].append(a)

for _ in range(q):
    v,val = map(int, input().split())
    cnt[v] += val

q = collections.deque()
q.append(1)
checked = [0]*(n+1)

while q:
    v = q.pop()
    checked[v] = 1
    for u in g[v]:
        if checked[u] == 1:
            continue
        cnt[u] += cnt[v]
        q.append(u)
print(*cnt[1:])


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

  typedef long long int ll;
  typedef pair<int,int> pi;
  typedef pair<ll,ll> pll;
  typedef vector<int> vi;
  typedef vector<ll> vll;
  typedef vector<pi> vpi;
  typedef vector<pll> vpll;

  #define  ff         first
  #define  ss         second
  #define  pb         push_back
  #define  all(x)     (x).begin(), (x).end()
  #define  rep(i,a,b) for(ll i=a ; i<b ; ++i)
  #define  D(x)       cout << #x << " - " << x << endl;
  #define  IOS        ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
  #define  D2(x)      cout << "[" << #x << ": "; for(auto it:x) cout << it << " "; cout << "]" << endl;
  #define  D2p(x)      cout << #x << " ~ [ "; for(auto n: x) cout << n.first << "-" << n.second << " / "; cout << "]" << endl;
  #define  ps(x,y)    fixed<<setprecision(y)<<x

  const ll MOD = 1e9 + 7;
  const ll INF = 1e18;
  const ll maxn = 2e5+1;
  int cal(int md,int k){
     int cnt=1;
     while(md>0){
       cnt++;
       int a = __builtin_popcount(md);
       md = md%a;
     }
     return cnt;
  }
  void solve(){
     int n;
     cin >> n;
     string s;
     cin >> s;
     int k = count(all(s),'1');
     vector<vector<int>> arr(n+1,vector<int>(2));
     map<int,int> mp;
     mp[-1]=0;
     mp[1]=1;
     for(int i=0;i<=n;i++){
        for(int x:{-1,1}){
          if(x+k<=0)continue;
           int c = mp[x];
           if(!i){
             arr[i][c]=(1%(k+x));
           }
           else{
              arr[i][c] = ((arr[i-1][c]*2))%(k+x);
           }
        }
     }
      int md0=0;
      int md2=0;
     for(int i=n-1;i>=0;i--){
        if(s[i]=='1'){
          if(k-1>0)
          md0 = (md0+arr[n-i-1][0])%(k-1);
          md2 = (md2+arr[n-i-1][1])%(k+1);
        }
      }

     for(int i=0;i<n;i++){
       if(s[i]=='0'){
          int md = (md2+arr[n-i-1][1])%(k+1);
          cout << cal(md,k+1);
       }
       else{
         if(k-1>0){
         int md = ((md0-arr[n-i-1][0])%(k-1)+(k-1))%(k-1);
         cout << cal(md,k-1);
        }
         else cout << 0;
       }
       cout << '\n';
     }
  }


  int main(){
    IOS
       solve();
       cerr <<endl <<"[ Time : " << (float)clock() / CLOCKS_PER_SEC << " secs ]" << endl;
  }
// integer overflow
// remember to clear visited array
// take input as vector<string> while using grid
// don't assign after modifying


Measured memory_bytes: 14392
#include <bits/stdc++.h>
using namespace std;
#define rep0(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define ll long long
#define coYes cout << "Yes" << endl;
#define coYES cout << "YES" << endl;
#define coyes cout << "yes" << endl;
#define coNo cout << "No" << endl;
#define coNO cout << "NO" << endl;
#define cono cout << "no" << endl;
#define BIT_FLAG_0 (1<<0) // 0000 0000 0000 0001
int gcd(int a, int b){
    if(a%b == 0){
        return b;
    }else{
    return gcd(b, a%b);
    }
}

int main(){
    int n,T,x=0,min=1001;
    cin >> n >> T;
    vector<int> c(n),t(n);
    rep0(i,n){
        cin >> c[i] >> t[i];
        //if(t[i]>T) x++;
    }
    /*if(x==n){
        cout << "TLE" << endl;
        return 0;
    }*/
    rep0(i,n){
        if(t[i]<=T){
            if(min>c[i])
                min=c[i];
        }
    }
    if(min<=1000)
        cout << min << endl;
    else 
        cout << "TLE" << endl;
    return 0;
}

Measured memory_bytes: 3576
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using Pair = pair<int, int>;
using Vec = vector<int>;
using Graph = vector<Vec>;
#define INF 1000000007
#define MOD 1000000007
#define SEP " "

vector<ll> counter;
Graph g;
map<int, int> p;

void dfs(int node, int parent)
{
	counter[node] = counter[parent] + p[node];
	for (auto it = g[node].begin(); it != g[node].end(); it++)
	{
		if (*it == parent)
			continue ;
		dfs(*it, node);
	}
}

int		main(void)
{
	int n, q;
	cin >> n >> q;
	g.resize(n);
	for (int i = 0; i < n-1; i++)
	{
		int a, b;
		cin >> a >> b;
		a--;
		b--;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	for (int i = 0; i < q; i++)
	{
		int a, b;
		cin >> a >> b;
		p[--a] += b;
	}
	counter.resize(n);
	dfs(0, 0);
	cout << counter[0];
	for (int i = 1; i < n; i++)
	{
		cout << SEP << counter[i];
	}
	cout << endl;
}


Measured memory_bytes: 39936
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		//スキャナー
		Scanner s = new Scanner(System.in);


		int numx = s.nextInt();
		int numn = s.nextInt();

		if(numn == 0) {

			System.out.println(numx);

			s.close();

			System.exit(0);
		}
		Integer[] array = new Integer[numn];

		for(int i = 0 ; i < numn ; i++) {

			array[i] = s.nextInt();

		}

		//リストへ変換
		List<Integer> listNum = Arrays.asList(array);

		//スキャナーを閉じる
		s.close();

		//answer
		int ans = 0;

		boolean flg_con = true;

		if(! listNum.contains(numx)) {
			//同数が配列にいない場合
			ans = numx;
			
			flg_con = false;
		}

		int count = 0;

		while(flg_con) {

			count++;

			int mnx = numx - count;
			int plx = numx + count;

			if(! listNum.contains(mnx)) {

				ans = mnx;

				flg_con = false;
			}else if (! listNum.contains(plx)) {

				ans = plx;

				flg_con=false;
			}

		}

		System.out.println(ans);
	}

}


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

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

    int ans = 0;
    for(int i = 0; i < N; i++){
        if(v[i] >= K) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include<cstdio>
#include<cstring>
char s[105];
int len[105];
int main(){
	int n,k,i,cnt=1;
	long long ans=0ll;
	scanf("%s%d",s+1,&k);n=strlen(s+1);
	len[1]=1;
	for(i=2;i<=n;++i)if(s[i]!=s[i-1])len[++cnt]=1;
	else ++len[cnt];
	if(cnt==1){
		printf("%lld\n",1ll*n*k>>1ll);
		return 0;
	}
	for(i=2;i<cnt;++i)ans+=len[i]>>1;
	ans*=k;
	if(s[n]==s[1])ans+=1ll*(len[1]+len[cnt]>>1)*(k-1);
	else ans+=1ll*((len[1]>>1)+(len[cnt]>>1))*(k-1);
	printf("%lld\n",ans+(len[1]>>1)+(len[cnt]>>1));
	return 0;
}

Measured memory_bytes: 128
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())

list = [A,B,C,D,E]
num =[]
num_t = []
for i in range(len(list)):
    s = 0
    t = 0
    if list[i] >= 100:
        s = list[i] - 100
        t = 100
    else:
        s = list[i]
    while s >= 10:
        s -= 10
        t += 10
    num.append(s)
    if s != 0:
        t += 10
    num_t.append(t)
    
last_index = -1
for i in range(len(num)):
    if num[i] != 0:
        if last_index == -1:
            last_index = i
        if num[i] <= num[last_index]:
            last_index = i

sum = 0
for i in range(len(num_t)):
    sum += num_t[i]
    
sum = sum - num_t[last_index] + list[last_index]
print(sum)

Measured memory_bytes: 3064
#include <iostream>
#include <string>

using namespace std;

int main() {
	string s, t;

	cin >> s >> t;

	int i, j;
	for (i = 0; i < s.size(); i++) {
		for (j = 0; j < s.size(); j++) {
			if (t[j] != s[(i + j) % s.size()])break;
		}
		if (j == s.size()) {
			cout << "Yes" << endl;
			return 0;
		}
	}

	cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
using namespace std;

class union_find
{
private:
	std::vector<int>parent;
	std::vector<int>rank;
public:
	union_find(int siz)
	{
		parent.resize(siz);
		rank.resize(siz);
		for (int i = 0; i < siz; ++i)
		{
			parent[i] = i;
			rank[i] = 0;
		}
	}
	void unite(int x, int y)
	{
		int xr = find(x);
		int yr = find(y);
		if (rank[xr] > rank[yr])
		{
			parent[yr] = xr;
		}
		else if (rank[xr] > rank[yr])
		{
			parent[xr] = yr;
		}
		else if (xr != yr)
		{
			parent[yr] = xr;
			++rank[xr];
		}
	}
	int find(int x)
	{
		if (parent[x] == x)
		{
			return x;
		}
		else
		{
			return parent[x] = find(parent[x]);
		}
	}
	bool check(int x, int y)
	{
		return find(x) == find(y);
	}
};

int n, m;
vector<int>slot[123456];

int main(void)
{
	union_find *uf;
	scanf("%d %d", &n, &m);
	uf = new union_find(n);
	for (int i = 0; i < n; ++i)
	{
		int k;
		scanf("%d", &k);
		for (int j = 0; j < k; ++j)
		{
			int tmp;
			scanf("%d", &tmp);
			--tmp;
			if (!slot[tmp].empty())
			{
				uf->unite(slot[tmp][0], i);
			}
			slot[tmp].push_back(i);
		}
	}
	for (int i = 1; i < n; ++i)
	{
		if (!uf->check(i - 1, i))return 0 * printf("NO\n");
	}
	return 0 * printf("YES\n");
}


Measured memory_bytes: 5376
#include<stdio.h>

  int main(void)
  {
    int a;
    char s[11];

    scanf(" %d", &a);
    scanf(" %s", s);

    if (a >=3200) {
      printf("%s\n", s);
    } else {
      printf("red");
    }

    return 0;
  }


Measured memory_bytes: 128
void solve(int n, int a, int b, string s){
	int cnt_a, cnt_b;
	foreach(ch; s){
		switch(ch){
			case 'a':
				if(cnt_a <a+b){
					writeln("Yes");
					cnt_a++;
				}else writeln("No");
				break;
			case 'b':
				if(cnt_a<a+b && cnt_b<b){
					cnt_a++;
					cnt_b++;
					writeln("Yes");
				}else{
					writeln("No");
				}
				break;
			default:
				writeln("No");
				break;
		}
	}	
}
void main(){
	int n, a, b;
	readf("%d %d %d\n", &n, &a, &b);
	string s = readln().chomp();
	solve(n, a, b, s);
}
     
import std.stdio, std.conv, std.algorithm, std.numeric, std.string, std.math, std.range;
const long mod = 10^^9+7;      
// 1要素のみの入力
T inelm(T= int)(){
	return to!(T)( readln().chomp() );
}
     
// 1行に同一型の複数入力
T[] inln(T = int)(){
	T[] ln;
	foreach(string elm; readln().chomp().split())ln ~= elm.to!T();
	return ln;
}


Measured memory_bytes: 2908
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val fList = mutableListOf<List<Int>>()
    val pList = mutableListOf<List<Int>>()
    val oList = mutableListOf<List<Int>>()
    for (i in 1..n) {
        fList.add(readLine()!!.split(" ").map(String::toInt))
    }
    for (i in 1..n) {
        pList.add(readLine()!!.split(" ").map(String::toInt))
    }
    (1..1023).forEach { i ->
        run {
            oList.add(String.format("%010d", Integer.toBinaryString(i).toInt()).split("").filter { it.isNotEmpty() }.map(String::toInt))
        }
    }

    var max = Long.MIN_VALUE
    for (own in oList) {
        var benefit = 0L
        fList.forEachIndexed { index, list ->
            run {
                var both = 0
                for (i in 0..9) {
                    if (own[i] == 1 && list[i] == 1) both++
                }
                benefit += pList[index][both]
            }
        }
        max = Math.max(max, benefit)
    }
    println(max)
}


Measured memory_bytes: 43852
#include <iostream>
using namespace std;
int main() {
	int x, y;
	while (1){
		cin >> x >> y;
		if (x == 0 && y == 0)
			break;
		if (x > y)
			swap(x, y);
		cout << x << " " << y << endl;
	}

	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
int div(int n){
    int c=1,temp=7;
    while(temp%n!=0){
        temp=(temp*10+7)%n;
        c++;
    }
    return c;
}
int main()
{
    int n;
    cin>>n;
    if(n%2==0 || n%5==0){
        cout<<-1;
        return 0;
    }
    cout<<div(n);
    return 0;
}

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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define ASC(x) sort(ALL((x)))
#define DESC(x) sort(ALL((x)),greater<ll>())
#define REV(x) reverse(ALL((x)))
#define pb push_back

int main()
{
    ll N, M;
    cin >> N >> M;
    mat G(N);
    REP(i,0,M) {
        ll x, y, z;
        cin >> x >> y >> z;
        --x; --y;
        G[x].pb(y);
        G[y].pb(x);
    }

    vec F(N+1, false);
    queue<ll> Q;
    ll k = 0, cnt = 0;
    Q.push(0);
    F[0] = true;
    while(k < N) {
        while(!Q.empty()) {
            ll v = Q.front(); Q.pop();
            FORR(nv,G[v]) {
                if(!F[nv]) {
                    Q.push(nv);
                    F[nv] = true;
                }
            }
        }
        while(k < N && F[k]) ++k;
        Q.push(k);
        F[k] = true;
        ++cnt;
    }
    PR(cnt);

    return 0;
}

/*



*/

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

int main()
{
    int a, b, c, ans;
    cin >> a >> b >> c;

    if(a*a + b*b == c*c)
    {
        ans = (a*b)/2;
    }
    else if(b*b + c*c == a*a)
    {
        ans = (b*c)/2;

    }
    else
    {
        ans = (c*a)/2;
    }
    cout << ans << endl;
    //cout << "This triangle has an area of " << ans << ".\n";

    return 0;
}


Measured memory_bytes: 256