akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;

int main()
{
  int a, b;
  string a2, b2;
  cin>>a>>b;
  
  for (int i = 0; i<b; i++){
    a2 = a2 + to_string(a);
  }
  
  for (int i = 0; i<a; i++){
    b2 = b2 + to_string(b);
  }
  
  if (a2 > b2){
  	cout<< b2 << endl;
  }
  else{
    cout<< a2 << endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
import sys
from io import StringIO
import unittest


def resolve():
    s = input()
    # n = int(input())
    # a, b = map(int, input().split())
    # l = [list(map(int, input().split())) for _ in range(n)]

    if s.islower():
        print('a')
    else:
        print('A')


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """B"""
        output = """A"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """a"""
        output = """a"""
        self.assertIO(input, output)


if __name__ == "__main__":
    # unittest.main()
    resolve()


Measured memory_bytes: 71044
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <cstring>
#define rep(i, N) for (int i = 0; i < (int)N; i++)
using namespace std;
typedef long long ll;
const ll LLINF = 9223372036854775807;
const int MOD = 1000000007;

int main() {
  int A, B; cin >> A >> B;
  string S; cin >> S;

  string result = "Yes";
  rep(i, A+B+1) {
    if ( i==A && S[i]=='-' ) continue;
    else if ( i!=A && S[i]!='-' ) continue;
    result = "No";
  }
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string.h>
#include <stack>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <memory.h>
#include <set>
#include <cmath>
#define fio ios::sync_with_stdio(false); cin.tie(NULL);
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
int a, b, ans;
int main(void) {
	scanf("%d %d", &a, &b);
	ans = a + b;
	if (ans & 1) printf("IMPOSSIBLE\n");
	else printf("%d\n", ans>>1);
}

Measured memory_bytes: 384
#include <stdio.h>
int main(void){
    // Your code here!
    int D;
    scanf("%d",&D);
    switch(D)
    {
        case 22:
            printf("Christmas Eve Eve Eve\n");
            break;
        case 23:
            printf("Christmas Eve Eve\n");
            break;
        case 24:
            printf("Christmas Eve\n");
            break;
        case 25:
            printf("Christmas\n");
            break;
    }
}


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

using namespace std;

int main() {

  int a, b;

  cin>> a >> b ;

int seki =a*b;
if (seki%2== 0) {
cout << "Even" << endl;

  }

  

  else if(seki%2==1){

    // ここにプログラムを追記

    cout<<"Odd"<<endl;

  }

  
 

  }



Measured memory_bytes: 3572
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <list>
#include <algorithm>

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long llong;
typedef unsigned long long ullong;

using namespace std;

int main() {
	string s;
	cin >> s;
	int q;
	cin >> q;
	int t;
	int f;
	string c;

	string front, end;
	int hanten = 0;
	rep(i, q)
	{
		cin >> t;
		switch (t)
		{
		case 1:
			// 反転する
			++hanten;
			break;
		case 2:
			cin >> f >> c;
			switch (f)
			{
			case 1:
				// 先頭につける
				if(hanten%2 == 0)
					front = front + c;
				else
					end = end + c;
				break;
			case 2:
				// 末尾につける
				if (hanten % 2 == 0)
					end = end + c;
				else
					front = front + c;
				break;
			}
			break;
		}

	}

	if (hanten % 2 == 0)
	{
		std::reverse(front.begin(), front.end());
		s = front + s + end;
	}
	else
	{
		std::reverse(end.begin(), end.end());
		std::reverse(s.begin(), s.end());
		s = end + s + front;
	}
	
	cout << s;
}

Measured memory_bytes: 1596
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;
 
const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll INF = 1ll << 60;
const double PI = 2 * asin(1);

int N, M, P[10];
vector <int> Switch[10];

int main(){
  cin >> N >> M;
  for (int i = 0; i < M; i++){
    int K; cin >> K;
    for (int j = 0; j < K; j++){
      int S; cin >> S; S--;
      Switch[S].push_back(i);
    }
  }
  for (int i = 0; i < M; i++) cin >> P[i];

  int ans = 0, all = pow(2, N);
  for (int i = 0; i < all; i++){
    int num = i, now[M] = {};
    for (int j = 0; j < N; j++){
      if (num % 2 == 1){
        for (int k = 0; k < Switch[j].size(); k++){
          now[Switch[j][k]]++;
        }
      }
      num /= 2;
    }

    int cnt = 0;
    for (int j = 0; j < M; j++){
      if (now[j] % 2 == P[j]) cnt++;
    }
    if (cnt == M) ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,A[100000],s = 0;
  cin >> N;
  A[-1] == 0;
  A[N+1] == 0;
  for (int i = 1;i <= N+1; i++){
    cin >> A[i];
    s += abs(A[i]-A[i-1]);
  }
  for ( int i = 1;i <= N; i++){
   cout << s - (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
// Problem : A - Circle
// Contest : AtCoder Beginner Contest 145
// URL : https://atcoder.jp/contests/abc145/tasks/abc145_a
// Memory Limit : 1024,000000 MB 
// Time Limit : 2000,000000 milisec 
// Powered by CP Editor (https://github.com/coder3101/cp-editor2)

#include <algorithm>
#include <cmath>
#include <iostream>
#include <iterator>
#include <map>
#include <set>
#include <vector>

using namespace std;

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

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

  cout.precision(16);
  cout << fixed;
  
  int r;
  cin >> r;
  
  cout << r * r;
}


Measured memory_bytes: 256
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static string[] s_rd;
T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }
T[] ARR(T = long)(in string str, T fix = 0) { auto r = str.split.to!(T[]); r[] += fix; return r; }
size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
long lcm(long x, long y) { return x * y / gcd(x, y); }

long mod = 10^^9 + 7;
//long mod = 998244353;
//long mod = 1_000_003;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

void main()
{
	auto N = RD;
	auto D = RD;
	auto X = RD;
	foreach (i; 0..N)
	{
		auto a = RD;
		long b = 1;
		++X;
		while (b + a <= D)
		{
			++X;
			b += a;
		}
	}

	writeln(X);
	stdout.flush();
	debug readln();
}


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

int main () {
    int n, k;
    cin >> n >> k;
    vector<int> x(n);
    for (int i = 0; i < n; i++) {
        cin >> x[i];
    }

    int res = 1e9;
    for (int i = 0; i <= n - k; i++) {
        res = min(x[k + i - 1] - x[i] + abs(x[i]), res);
        res = min(x[k + i - 1] - x[i] + abs(x[k + i - 1]), res);
    }   
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 640
import java.util.Scanner;
import java.util.Arrays;
public class Main{
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int n = sc.nextInt();
		long h = sc.nextLong();
		long[] b = new long[n];
		long max=0;
		for(int i = 0; i<n; i++){
			long a = sc.nextLong();
			long b1 = sc.nextLong();
			b[i]=b1;
			max=Math.max(max,a);
		}
		long ans=0;
		int count=n-1;
		Arrays.sort(b);
		while(h>0){
			if(count>=0 && b[count]>max){
				h-=b[count];
				count--;
			}else{
				h-=max;
			}
			ans++;
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 83232
import sys

sys.setrecursionlimit(10 ** 7)
rl = sys.stdin.readline


def solve():
    H, W, N = map(int, rl().split())
    sr, sc = map(lambda x: int(x) - 1, rl().split())
    S = input()
    T = input()
    
    cy = sr
    for i in range(N):
        if S[i] == 'U':
            cy -= 1
            if cy < 0:
                print('NO')
                exit()
        if T[i] == 'D' and cy < H - 1:
            cy += 1
    
    cy = sr
    for i in range(N):
        if S[i] == 'D':
            cy += 1
            if H <= cy:
                print('NO')
                exit()
        if T[i] == 'U' and 0 < cy:
            cy -= 1
    
    cx = sc
    for i in range(N):
        if S[i] == 'L':
            cx -= 1
            if cx < 0:
                print('NO')
                exit()
        if T[i] == 'R' and cx < W - 1:
            cx += 1
    
    cx = sc
    for i in range(N):
        if S[i] == 'R':
            cx += 1
            if W <= cx:
                print('NO')
                exit()
        if T[i] == 'L' and 0 < cx:
            cx -= 1
    
    print('YES')


if __name__ == '__main__':
    solve()


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

int main() {
  int a,b;
  cin >> a >> b;
  if(a+b == 15) cout << "+" << endl;
  else if(a*b == 15) cout << "*" << endl;
  else cout << "x" << endl;
}

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

using namespace std;

const int L = 128;
const int Q = 850;
int cnt = 0;

int query(const string &s) {
	cnt++;
	assert(cnt <= Q);
	printf("? %s\n", s.c_str()); fflush(stdout);
	int ans;
	scanf("%d", &ans);
	return ans;
}

int tot;
priority_queue<pair<int, string>> pq;
void prec(char c) {
	string s(L, c);
	int len = L - query(s);
	if(len > 0) {
		s.resize(len);
		tot += len;
		pq.emplace(-len, s);
	}
}

void merge(string a, string b) {
	if(a.size() < b.size()) swap(a, b);

	for(int i = (int)a.size(); i >= 0 and !b.empty(); i--) {
		while(!b.empty()) {
			string tmp = a;
			tmp.insert(tmp.begin() + i, b.back());
			if(query(tmp) == tot - (int)tmp.size()) {
				a = tmp;
				b.pop_back();
			}
			else break;
		}
	}
	pq.emplace(-(int)a.size(), a);
}

int main() {

	for(char c = 'a'; c <= 'z'; c++) prec(c);
	for(char c = 'A'; c <= 'Z'; c++) prec(c);
	for(char c = '0'; c <= '9'; c++) prec(c);

	while(pq.size() > 1) {
		string a = pq.top().second; pq.pop();
		string b = pq.top().second; pq.pop();
		merge(a, b);
	}

	string ans = pq.top().second;

	assert(query(ans) == 0);

	printf("! %s\n", ans.c_str());
	fflush(stdout);
}



Measured memory_bytes: 3776
n,z,w = map(int,input().split())
a = list(map(int,input().split()))
xp = [0]*(n)
yp = [10000000000]*(n)
xp[0] = abs(a[n-1]-w)
for i in reversed(range(n)):
    for j in range(i+1,n):
        xp[i] = max(xp[i], yp[j])
        yp[i] = min(yp[i], xp[j])
    xp[i] = max(xp[i], abs(a[i-1]-a[n-1]))
    yp[i] = min(yp[i], abs(a[i-1]-a[n-1]))
print(xp[0])

Measured memory_bytes: 3188
import heapq

N, M = [int(n) for n in input().split()]
A = [-1*int(n) for n in input().split()]
hq = []
[heapq.heappush(hq, v) for v in A]
for _ in range(M):
   heapq.heappush(hq, -1*(-1*heapq.heappop(hq)//2))
print(-1*sum(hq))

Measured memory_bytes: 14180
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <cmath>
#include <deque>
#include <iterator>
#include <map>
#include <queue>
#include <string>
#include <tuple>
#include <utility>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
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;}

int main() {
  ll n; cin >> n;
  vvll edges(n, vll());
  REP(i, n) {
    ll u, k; cin >> u >> k;
    REP(j, k) {
      ll to; cin >> to;
      edges.at(u-1).push_back(to-1);
    }
  }
  vll d(n, -1);
  V<bool> visited(n, false);
  queue<ll> q; q.push(0);
  ll tmpd = 0;
  while (!q.empty()) {
    queue<ll> tmpq;
    while (!q.empty()) {
      ll to = q.front(); q.pop();
      if (visited.at(to)) continue;
      visited.at(to) = true; d.at(to) = tmpd;
      REP(i, edges.at(to).size()) {
        if (visited.at(edges.at(to).at(i))) continue;
        tmpq.push(edges.at(to).at(i));
      }
    }
    q = tmpq; tmpd++;
  }
  REP(i, n) cout << i+1 << ' ' << d.at(i) << endl;
  return 0;
}



Measured memory_bytes: 3168
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
int n, m;
const int maxN = 7e5 + 10;
vector < pair < int, int > > init[maxN];
vector < int > clr[maxN];
vector < pair < int, int > > g[maxN];
vector < int > id_clr[maxN];
pair < int, int > bck[maxN];
vector < int > trans[maxN];
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
//    freopen("input.txt", "r", stdin);
    cin >> n >> m;
    for (int i = 1; i <= m; i++) {
        int a, b, c;
        cin >> a >> b >> c;
        clr[a].emplace_back(c);
        clr[b].emplace_back(c);
        g[a].emplace_back(b, c);
        g[b].emplace_back(a, c);
    }
    for (int i = 1; i <= n; i++) {
        sort(clr[i].begin(), clr[i].end());
        clr[i].erase(unique(clr[i].begin(), clr[i].end()), clr[i].end());
        id_clr[i].resize(clr[i].size());
    }
    int sz = n + 1;
    for (int i = 1; i <= n; i++) {
        for (int j = 0; j < clr[i].size(); j++) {
            bck[sz] = make_pair(i, j);
            id_clr[i][j] = sz++;
        }
    }
    for (int i = 1; i <= n; i++) {
        for (auto it : g[i]) {
            int c = it.second;
            int his_pos = lower_bound(clr[i].begin(), clr[i].end(), c) - clr[i].begin();
            trans[id_clr[i][his_pos]].emplace_back(id_clr[it.first][lower_bound(clr[it.first].begin(), clr[it.first].end(), c) - clr[it.first].begin()]);
        }
    }
    vector < int > dist(sz + 1, -1);
    deque < int > q;
    for (int v : id_clr[1]) {
        dist[v] = 1;
        q.push_front(v);
    }
    while (!q.empty()) {
        int v = q.front();
        q.pop_front();
        if (v <= n) {
            for (int id : id_clr[v]) {
                if (dist[id] == -1 || dist[id] > dist[v] + 1) {
                    dist[id] = dist[v] + 1;
                    q.push_back(id);
                }
            }
        }
        else {
            for (int p : trans[v]) {
               if (dist[p] == -1 || dist[p] > dist[v]) {
                   dist[p] = dist[v];
                   q.push_front(p);
               }
               if (dist[bck[p].first] == -1 || dist[bck[p].first] > dist[v]) {
                   dist[bck[p].first] = dist[v];
                   q.push_front(bck[p].first);
               }
            }
        }
    }
    int best = 1e9;
    for (int v : id_clr[n]) {
        if (dist[v] != -1) best = min(best, dist[v]);
    }
    if (dist[n] != -1) best = min(best, dist[n]);
    if (best > 1e7) best = -1;
    cout << best;
    return 0;
}

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

int main(){
    int n;
    int d[100];

    cin >> n;
    for(int i = 0; i < n; i++)
        cin >> d[i];
    
    sort(d, d+n);

    int counter = 1;
    int comp = d[0];
    for(int i = 0; i < n; i++){
        if(comp != d[i]){
            ++counter;
            comp = d[i];
        }
    }

    cout << counter << endl;

    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <queue>
#define PB push_back
#define ll long long
using namespace std;
template <class T>
inline void rd(T &x) {
	x=0; char c=getchar(); int f=1;
	while(!isdigit(c)) { if(c=='-') f=-1; c=getchar(); }
	while(isdigit(c)) x=x*10-'0'+c,c=getchar(); x*=f;
}
const int N=1e5+10;
vector<int> G[N];
int du[N],vis[N],n;
queue<int> q;
void del(int u) {
	for(int i=0;i<G[u].size();++i) if(!vis[G[u][i]]) {
		du[G[u][i]]--;
		if(du[G[u][i]]==1) q.push(G[u][i]);
	}
	vis[u]=1;
}
	
int main() {
	rd(n);
	for(int x,y,i=1;i<n;++i) {
		rd(x),rd(y);
		G[x].PB(y),G[y].PB(x);
		du[x]++,du[y]++;
	}
	for(int i=1;i<=n;++i) if(du[i]==1) q.push(i);
	while(!q.empty()) {
		int u=q.front(); q.pop();
		if(du[u]!=1) {
			printf("First");
			return 0;
		}
		for(int i=0;i<G[u].size();++i)
			if(!vis[G[u][i]]) { del(G[u][i]); break; }
		del(u);
	}
	for(int i=1;i<=n;++i) if(!vis[i]) { printf("First"); return 0; }
	printf("Second");
	return 0;
}

Measured memory_bytes: 6784
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// Welcome to my source code!

int main() {
    int n;
    cin >> n;
    priority_queue<double, vector<double>, greater<double>> que;
    for (int i = 0, u; i < n; i++) {
        cin >> u;
        que.push(u);
    }
    while (que.size() != 1) {
        double x = que.top(); que.pop();
        double y = que.top(); que.pop();
        que.push((x + y) / 2);
    }
    cout << fixed << setprecision(5) << que.top() << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef struct{
    long x;
    long y;
} ax;
int main(){
    int n,K; cin>>n>>K;
    vector<ax> v(n);
    for(int i=0;i<n;i++){
        long x,y; cin>>x>>y;
        v[i].x=x,v[i].y=y;
    }
    unsigned long min=-1;
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            for(int k=0;k<n;k++){
                for(int l=0;l<n;l++){
                    int count=0;
                    for(int m=0;m<n;m++){
                        if(v[m].y>=v[i].y&&v[m].y<=v[j].y&&v[m].x<=v[k].x&&v[m].x>=v[l].x)
                            count++;
                    }
                    unsigned long area=abs(v[i].y-v[j].y)*abs(v[k].x-v[l].x);
                    if(count>=K&&area<min)
                        min=area;
                }
            }
        }
    }
    cout<<min;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define N 20000000
using namespace std;
typedef unsigned long long ll;
bool used[N];

ll SumD(ll a,ll d,ll n){return (n*(2*a+(n-1)*d))/2;}

bool mark(ll n){
  bool res=1;
  for(ll i=1;i*i<=n;i++){
    if(n%i)continue;
    if(i<N)res&=!used[i],used[i]=1;
    if(i!=n/i&&n/i<N)res&=!used[n/i],used[n/i]=1;
  }
  return res;
}

int main(){
  while(1){
    ll n,m,p[21];
    cin>>n>>m;
    if(!n&&!m)break;
    for(int i=0;i<m;i++)cin>>p[i];
    sort(p,p+m);

  
    ll sum=0,cnt=0;
    for(int i=0;i<m;i++){
      sum+=SumD(p[i],p[i],n/p[i]);
      cnt+=n/p[i];
      memset(used,0,sizeof(used));
      for(int j=0;j<i;j++){
	ll gcd=__gcd(p[i],p[j]);
	ll lcm=(p[i]/gcd)*p[j];
	if(!mark(lcm))continue;
	sum-=SumD(lcm,lcm,n/lcm);
	cnt-=n/lcm;
      }
    }
    double ans=1.0*(SumD(1,1,n)-sum)/max(1,(int)(n-cnt));
    if(p[0]==1)ans=0;
    printf("%.8f\n",ans);
  }
  return 0;
}

Measured memory_bytes: 22660
#include <iostream>
#include <stdlib.h>
#include <string.h>
#include <algorithm>
#include <cstdio> 
using namespace std; 
int main(){
	long long a,b;
	char s;
	cin >> a >> s >> b;
	if(s == '+'){
		cout << a+b << endl;
	}
	else{
		cout << a-b << endl;
	}
	return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(os.Stdout)

	n := getNextInt(scanner)
	hh := make([]int, n)
	max := 0
	ans := "Yes"
	for i := 0; i < n; i++ {
		hh[i] = getNextInt(scanner)
		if max < hh[i] {
			max = hh[i]
		}
		if i == 0 {
			continue
		}
		if hh[i]+1 < max {
			ans = "No"
			break
		}
	}
	fmt.Fprintln(writer, ans)

	writer.Flush()
}


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

using namespace std;

int main()
{
	int n;
	int a[100];
	int rate[9];
	int zerocnt=0;
	int M=0;
	int m=0;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	for(int i=0;i<9;i++)
	{
		rate[i]=0;
	}

	for(int i=0;i<n;i++)
	{
		for(int j=0;j<9;j++)
		{
			if(j!=8)
			{
				if(a[i]<(j+1)*400)
				{
					rate[j]++;
					break;
				}
			}else{
				rate[8]++;
				break;
			}
		}
	}

	for(int i=0;i<8;i++)
	{
		if(rate[i]==0)
		{
			zerocnt++;
		}else{
			m++;
		}
	}

	M = m + rate[8];
	if(m==0)
	{
		m=1;
	}

	cout<<m<<" "<<M<<endl;
	return 0;
}

Measured memory_bytes: 256
#pragma once

#include <stdio.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>

using namespace std;
string S;
long long int N, A, B ,X;
long long int a[100002];
bool b[100002] = {};
long long int myMax,myMin;
long long int result=0;




int main() {
	cin >>N;
	A = 1;
	X = 0;
	for (int i = 0; i < N; i++) {
		cin >> a[i];
	}

	
	while (true) {
		X++;
		if (a[A-1] == 2) {
			cout << X << endl;
			break;
		}
		if (b[A-1] == false) {
			b[A-1] = true;
			A = a[A-1];
			continue;
		}
		cout << -1 << endl;
		break;
	
	}
	
	

	return 0;
}




Measured memory_bytes: 1152
import scala.math.{min,max}

object Main {
  val sc = new java.util.Scanner(System.in)
  def main(args: Array[String]) {
    while(true) {
      val n = sc.nextInt
      if(n == 0) return 
      val conv = (1 to n).map(_ => sc.next -> sc.next).toMap
      val m = sc.nextInt
      val ans = (1 to m).map({_ => 
        val c = sc.next
        conv.getOrElse(c, c)
      }).mkString("")
      println(ans)
    }
  }
}

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

  int main() {
    int a,b;
    cin >> a >> b;
  if ( (a+b) % 2 == 0 ) {
    cout << (a+b) / 2 << endl;
}
  else { 
    cout << (a+b) / 2 + 1 << endl;
} 
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
     unsigned long long t,a,b,i;
    scanf("%llu%llu",&a,&b);
     t=a*b;
    if(a<b)
     {
         i=a;a=b;b=i;
     }
   while(b!=0)
   {
       i=a%b;
       a=b;
       b=i;

   }
   printf("%llu",t/a);
    return 0;
}


Measured memory_bytes: 128
import java.io.InputStream;
import java.io.PrintStream;
import java.util.*;

public class Main {

  public static void main(String[] args) {
    solve(System.in, System.out);
  }

  private static class Task {
    long weight;
    long deadline;
  }

  static void solve(InputStream is, PrintStream os) {
    Scanner sc = new Scanner(is);

    /* read */
    long n = sc.nextLong();
    List<Task> tasks = new ArrayList<>();
    for (int i = 0; i < n; i++) {
      Task task = new Task();
      task.weight = sc.nextLong();
      task.deadline = sc.nextLong();
      tasks.add(task);
    }
    tasks.sort(Comparator.comparingLong(t -> t.deadline));

    long current = 0;
    for (int i = 0; i < n; i++) {
      Task task = tasks.get(i);
      current += task.weight;
      if (task.deadline < current) {
        os.println("No");
        return;
      }
    }
    os.println("Yes");
  }
}

Measured memory_bytes: 103548
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<numeric>
#include<utility>
#include<unordered_map> //hash map

#define rep(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define rrep(i,a,n) for(int (i)=(a);(i)>=(n);(i)--)

#define INF 1000000000
#define MOD 1000000007

typedef  long long ll;

using namespace std;

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

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

double euclid_distance(double a,double b){
    return sqrt(a*a+b*b);
}

ll gcd(ll  a,ll b){
    ll r;
    if(a < b){
        ll tmp;
        tmp = a;
        a = b;
        b = tmp;
    }
    while(r = a % b){
        a = b;
        b = r;
    }
    return b;
}

void Integer_factorization(long long int b,long long int n){
    long long int a = 2;
    long long int count = 0;
    long long int ans = 1;
    long long int ndash = n;
    if(b == 1) cout << n << endl;
    else{
    while(ndash >= a*a){
        if(n % a  == 0){
            count++;
            n/=a;

        if(count % b == 0){
            ans *= a;
        }
        }else{a++;count = 0;}
    }

    cout<<  ans << endl;
    }
}

ll r_fuct[2000];
ll fuct[2000];

//MOD逆元
void conb(ll n,ll k){
    fuct[0] = 1;
    for(int i = 1;i < k+1;i++){
        fuct[i] *= fuct[i-1]%MOD;
        
        ll b = MOD, u = 1, v = 0;
        ll value = fuct[i];
        while (b) {
            ll t = value / b;
            value -= t * b;
            swap(value, b);
            u -= t * v;
            swap(u, v);
        }
        u %= MOD;
        if (u < 0) u += MOD;
        r_fuct[i] = u;
    }
}

ll factrial(ll n){
    if(n == 0) return 1;
    ll p = factrial(n-1)*n%MOD;
    return p;
}

//MOD逆元
ll farmat(ll n,ll p){    
    if(p == 0) return 1;
    else if(p == 1) return n%MOD;
    ll d = farmat(n,p/2);
    if(p%2 == 0){
        return (d*d)%MOD;
    }else{
        return ((n*d)%MOD*d)%MOD;
    }
}

ll conbination(ll n,ll k){
    ll a = factrial(n);
    ll b = factrial(k);
    ll c = factrial(n-k);
    return (a*farmat(b,MOD-2)%MOD*farmat(c,MOD-2))%MOD;
}

int n;
int memo[10000000];

int fib(int i){
    if(i <= 1) return i;
    if(memo[i] != 0) return memo[i];
    return memo[i] = fib(i-1)+fib(i-2);
}


void solve() {
   ll n;
   cin >> n;
   cout << (n-1)*n/2 << endl;
}

int main() {

	cin.tie(0);
	ios::sync_with_stdio(false);
	solve();
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define M 1000000007
#define INF ((1LL<<62LL) - 1)

signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n; cin >> n;
    int a[n];

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

    int ans = 0;
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            for(int k=j+1;k<n;k++){
                if(a[i]!=a[j] && a[i]!=a[k] && a[j]!=a[k]){
                    int temp[] = {a[i], a[j], a[k]};
                    sort(temp, temp + 3);
                    if(temp[2] < temp[0] + temp[1]) ans++;
                }
            }
        }
    }

    cout << ans << "\n";

}


Measured memory_bytes: 3644
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <numeric>
#include <queue>
#include <sstream>
#include <string>
#include <string.h>
#include <tuple>
#include <vector>

#define REP(i,x) for(int i{ 0 }; i < (int)(x); i++)
#define REPC(i,x) for(int i{ 0 }; i <= (int)(x); i++)
#define RREP(i,x) for(int i{ (int)(x) - 1 }; i >= 0 ;i--)
#define RREPC(i,x) for(int i{ (int)(x)}; i >= 0; i--)
#define REP1O(i,x) for(int i{ 1 }; i < (int)(x); i++)
#define REP1C(i,x) for(int i{ 1 }; i <= (int)(x); i++)

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

using namespace std;

typedef int64_t ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef pair<int, int> pii;
typedef tuple<int, int, int> tupiii;
typedef tuple<ll, ll, ll> tuplll;

const int INTMAX = 2147483647;
const ll LLMAX = 9223372036854775807;
const int MOD = 1000000007;

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


const char WALL = '#';
const char PATH = '.';
int h, w;
vector<string> f;
vector<vector<ll>> dp;

//// BODY ////

void init()
{
	cin >> h >> w;
	f.resize(h);
	REP(i, h)
		cin >> f[i];

	dp.resize(h, vector<ll>(w, 0));
}

int main()
{
	init();

	dp[0][0] = 1;

	REP(i, h)
		REP(j, w)
	{
		if (i - 1 >= 0 && f[i - 1][j] == PATH)
			dp[i][j] = (dp[i][j] + dp[i - 1][j]) % MOD;
		if (j - 1 >= 0&& f[i][j - 1] == PATH)
			dp[i][j] = (dp[i][j] + dp[i][j - 1]) % MOD;
	}


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

Measured memory_bytes: 9216
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		@SuppressWarnings("resource")
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();

		int add = a + b;
		int sub = a - b;
		int mul = a * b;
		if (add >= sub && add >= mul) {
			System.out.println(add);
		} else if (sub >= mul) {
			System.out.println(sub);
		} else {
			System.out.println(mul);
		}
	}

}


Measured memory_bytes: 24916
#include<cstdio>
#include<iostream>
using namespace std;
struct edge{
	int to,next;
}ed[200010];
int size,head[100010],vis[100010],x[100010],y[100010],z[100010],k[100010],p[100010],cnt,yes[100010];
void add_edge(int from,int to)
{
	size++;
	ed[size].to=to;
	ed[size].next=head[from];
	head[from]=size;
}
void dfs(int u)
{
	vis[u]=1;
	k[++cnt]=u;
	z[cnt]=p[u];
	for(int i=head[u];i;i=ed[i].next)
	{
		int v=ed[i].to;
		if(!vis[v])
		{
			dfs(v);
		}
	}
}
int main()
{
	int n,m,ans=0;
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++) scanf("%d",&p[i]);
	for(int i=1;i<=m;i++) scanf("%d%d",&x[i],&y[i]),add_edge(x[i],y[i]),add_edge(y[i],x[i]);
	for(int i=1;i<=n;i++)
	{
		if(!vis[i]) 
		{
			cnt=0;
			dfs(i);
			for(int j=1;j<=cnt;j++) yes[z[j]]=1;
			for(int j=1;j<=cnt;j++) if(yes[k[j]]) ans++;
			for(int j=1;j<=cnt;j++) yes[z[j]]=0;
		}
	}
	cout<<ans;
}

Measured memory_bytes: 5888
def resolve():
    MOD = 10**9+7
    N, K = map(int, input().split())
    A = list(map(int, input().split()))

    dp = [[0]*(K+1) for _ in range(N+1)]
    # init 0個配る状態は1通り
    for i in range(N+1):
        dp[i][0] = 1

    for i in range(1, N+1):
        for j in range(1, K+1):
            dp[i][j] = (dp[i - 1][j] + dp[i][j - 1]) % MOD
            if j - A[i-1] - 1 >= 0:
                dp[i][j] = dp[i][j] - dp[i-1][j-A[i-1]-1]
                dp[i][j] %= MOD

    print(dp[N][K])


if __name__ == "__main__":
    resolve()

Measured memory_bytes: 144596
#include<iostream>
using namespace std;
int main(){
   int n,a,b,c,t;

   cin >> n;
   for(int i=0;i<n;i++){
	cin >> a >> b >> c;
	if(a > b){
		t = a;
		a = b;
		b = t;
	}
	if(b > c){
		t = b;
		b = c;
		c = t;
	}
	if(a > c){
		t = a;
		a = c;
		c = t;
	}

	if((a*a+b*b) == c*c){
		cout << "YES" << endl;
	}else{
		cout << "NO" << endl;
	}

   }

   return 0;
}

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

int main(){
  int N;cin >> N;
  string S;cin >> S;
  vector<int> L(N,0);
  for(int i=1;i<N;i++){
    if(S[i-1]=='W'){
      L[i] = L[i-1] + 1;
    }else{
      L[i] = L[i-1];
    }
  }
  vector<int> R(N,0);
  for(int i=N-2;i>=0;i--){
    if(S[i+1]=='E'){
      R[i] = R[i+1] + 1;
    }else{
      R[i] = R[i+1];
    }
  }
  int ans = N ;
  for(int i=0;i<N;i++){
    ans = min(ans,L[i] + R[i]);
  }
  cout << ans << endl;
}

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

using namespace std;

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

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

    UnionFind tree(N);

    for(int i = 0; i < M; i++) {
        int x, y;
        x--; y--;
        cin >> x >> y;
        tree.unite(x, y); // xの木とyの木を併合する
    }
  
  int a[N+5]={0};
  for(int i = 0; i < N; i++) a[tree.root(i)]++;
  int ans = 0;
  for(int i = 0; i < N; i++) ans = max(ans,a[i]);
  cout << ans << endl;
  return 0;
}

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

int main(){
    int n;
    cin>>n;
    vector<ll> a(3*n);
    for(int i=0;i<3*n;i++) cin>>a[i];
    sort(a.begin(),a.end());
    int k=n;
    int m=3*n-1-1;
    ll ans=0;
    while(k--){
        ans+=a[m];
        m-=2;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 2560
import std.stdio;

void main() {
  int tHp, tAttack, aHp, aAttack;
  
  readf(" %s %s %s %s", &tHp, &tAttack, &aHp, &aAttack);
  
  for (;;) {
    aHp -= tAttack;
    if (aHp <= 0) {
      writeln("Yes");
      return;
    }
    tHp -= aAttack;
    if (tHp <= 0) {
      writeln("No");
      return;
    }
  }
}


Measured memory_bytes: 2764
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.List;
import java.util.PriorityQueue;
import java.util.Scanner;

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

    int N = scanner.nextInt();
    Node[] nodes = new Node[N];
    for (int i = 0; i < N; i++) {
      nodes[i] = new Node(i, scanner.nextInt(), scanner.nextInt());
    }

    Arrays.sort(nodes, Comparator.comparingInt(o -> o.x));
    for (int i = 0; i < N - 1; i++) {
      Node a = nodes[i];
      Node b = nodes[i + 1];
      int d = b.x - a.x;
      a.edges.add(new Edge(a, b, d));
      b.edges.add(new Edge(b, a, d));
    }
    Arrays.sort(nodes, Comparator.comparingInt(o -> o.y));
    for (int i = 0; i < N - 1; i++) {
      Node a = nodes[i];
      Node b = nodes[i + 1];
      int d = b.y - a.y;
      a.edges.add(new Edge(a, b, d));
      b.edges.add(new Edge(b, a, d));
    }

    PriorityQueue<Edge> queue = new PriorityQueue<>(Comparator.comparingInt(o -> o.dist));
    Node a = nodes[0];
    queue.addAll(a.edges);
    a.visited = true;

    long d = 0;
    while (!queue.isEmpty()) {
      Edge e = queue.poll();

      if (!e.to.visited) {
        d += e.dist;
        e.to.visited = true;
        queue.addAll(e.to.edges);
      }
    }
    System.out.println(d);
  }

  private static class Node {
    final int id;
    final int x;
    final int y;
    final List<Edge> edges = new ArrayList<>();
    boolean visited;

    private Node(int id, int x, int y) {
      this.id = id;
      this.x = x;
      this.y = y;
    }
  }

  private static class Edge {
    final Node from;
    final Node to;
    final int dist;

    private Edge(Node from, Node to, int dist) {
      this.from = from;
      this.to = to;
      this.dist = dist;
    }
  }
}


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

  const int MOD = 1000000007;

  //long long
  using ll = long long;

  //出力系
  #define print(x) cout << x << endl
  #define yes cout << "Yes" << endl
  #define YES cout << "YES" << endl
  #define no cout << "No" << endl
  #define NO cout << "NO" << endl
  
  // begin() end()
  #define all(x) (x).begin(),(x).end()

  //for
  #define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

  //最大公約数（ll）
  ll gcd(ll x, ll y) { return y ? gcd(y,x%y) : x;}

  //素因数分解
  vector<pair<ll, int>>factorize(ll n){
    vector<pair<ll, int>> res;
    for(ll i = 2; i * i <= n; ++i){
      if(n % i) continue;
      res.emplace_back(i, 0);
      while(n % i == 0){
        n /= i;
        res.back().second++;
      }
    }
  if(n != 1) res.emplace_back(n, 1);
  return res;
  }






int main() {

int N, C, K;
cin >> N >> C >> K;
vector<int>T(N);
REP(i, N) cin >> T.at(i);
sort(all(T));

int lim = T.at(0) + K;
int cur = 1, ans = 0;

for(int i = 1; i < N; i++){
  if(T.at(i) <= lim){
    cur += 1;
  }else{
    ans += 1;
    lim = T.at(i) + K;
    cur = 1;
  }

  if(cur > C){
    ans += 1;
    lim = T.at(i) + K;
    cur = 1;
  }
}

print(ans + 1);
}



Measured memory_bytes: 640
using System;

namespace ABC061
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine().Split(' ');
            var n = int.Parse(s[0]);
            var m = int.Parse(s[1]);

            var roadsFromCity = new int[n];

            for (var i = 0; i < m; i++)
            {
                s = Console.ReadLine().Split(' ');
                var a = int.Parse(s[0]);
                var b = int.Parse(s[1]);

                roadsFromCity[a - 1]++;
                roadsFromCity[b - 1]++;
            }

            foreach(var x in roadsFromCity)
            {
                Console.WriteLine(x);
            }
        }
    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
struct Fast {
    Fast() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} fast;

long long mod = 1000000007;

long long div(long long a, long long b, long long c) { return b / c - (a - 1) / c; }

void print_binary(long long a) {
    for (int i = 31; i >= 0; i--) {
        cout << (a >> i & 1);
    }
    cout << endl;
}
long long modpow(long long m, long long n) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        long long t = modpow(m, n / 2);
        return t * t;
    } else {
        return modpow(m, n - 1) * m;
    }
}
void yes() {
    cout << "Yes" << endl;
    exit(0);
}
void no() {
    cout << "No" << endl;
    exit(0);
}

int main() {
    long long n, ans = 0;
    cin >> n;
    string s;
    cin >> s;
    for (int i = 0; i < s.size() - 2; i++) {
        if (s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C') {
            ans++;
        }
    }
    cout << ans << endl;
}

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

int main()
{
    int N;
    string S;
    cin >> N >> S;
    string ret;
    for(int i = 0;i < S.length();i++){
        int tmp = int(S[i]) + N;
        if(tmp > 90) tmp -= 26;
        ret += char(tmp);
    }
    cout << ret << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

//---------------------------------------
int c(int n, int x);   //????????????????????°
//---------------------------------------

int main(void)
{
	int n, x;   //1~n???????¨?x
	
	while(1){
		scanf("%d %d", &n, &x);
		if((n == 0) && (x == 0)){
			break;
		}
		else{
			printf("%d\n", c(n, x));
		}
	}
	return 0;
}
//-----------------------------//????????????????????°
int c(int n, int x)
{
	int count = 0;
	
	for(int i = n; i >= 3; i--){
		for(int j = i-1; j >= 2; j--){
			for(int k = j-1; k >= 1; k--){
				if((i+j+k) == x){
					count++;
				}
			}
		}
	}
	return count;
}

/*-----------------------------//????????????????????°
int c(int n, int x)
{
	int count = 0;
	
	for(int n1 = 1; n1 <= n/2, n1++){  
		x -= n1;
		for(int n2 = 2; n2 <= n/2, n2++){
			x -= n2;
			if((n1 != n2) && (n1 != x) && (n2 != x)){
				count++;
			}
		}
	}
	return count;
}
-----------------------------------*/

Measured memory_bytes: 2744
n = int(input())
a = [int(i) for i in input().split()]

a = sorted(a)

import numpy as np
def getNearestValue(list, num):
    idx = np.abs(np.asarray(list) - num).argmin()
    return list[idx]
  
from operator import mul
from functools import reduce

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

tmp0 = a[n-1] / 2
tmp1 = getNearestValue(a[0:n-1], tmp0)
print(a[n-1], tmp1)


Measured memory_bytes: 20756
#include<vector>
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
#include<map>
#include<functional>
#include<queue>
#include<stack>
#include<string.h>
#include<list>
#include<limits>
#include<bitset>
#include<ctype.h>
#include<set>
#define all(vec) vec.begin(),vec.end()
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,k,q;cin>>n>>k>>q;
    vector<int> co(n);
    for(int i=0;i<q;i++){
        int a;cin>>a;--a;
        co[a]++;
    }
    for(int i=0;i<n;i++){
        if(q-co[i]<k){
            cout<<"Yes"<<endl;
        }else{
            cout<<"No"<<endl;
        }
    }
}


Measured memory_bytes: 1024
#include <stdio.h>

//選択ソート

int sentakuSort(int A[],int N){
  int i, j, t, sw=0, mini;

  for(i=0; i<N-1; i++)
    {
      mini=i;

      for(j=i; j<N; j++)
	{
	  if(A[j] < A[mini])
	    mini=j;
	}
      
      t=A[i];     
      A[i]=A[mini];    
      A[mini]=t;
      
      if(i != mini)
	sw++;
    }
  
  return sw;
}


int main(){
  int A[100], N, i, sw;

  scanf("%d", &N);
  
  for(i=0; i<N; i++)
    scanf("%d", &A[i]);

  sw = sentakuSort(A, N);

  for(i=0; i<N; i++)
    {
      if(i > 0)
	printf(" ");

      printf("%d", A[i]);
    }

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

  return 0;
}



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

int main() {
    double a, b, e;
    int c, d;

    cin >> a >>b;

    c=a; d=b; e = (( c + d ) % 2);
    
    cout << ( a + b ) /2 + e / 2 << endl;
}

Measured memory_bytes: 3740
use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;

#[allow(dead_code)]
struct Scanner<'a> {
    cin: StdinLock<'a>,
}
#[allow(dead_code)]
impl<'a> Scanner<'a> {
    fn new(cin: StdinLock<'a>) -> Scanner<'a> {
        Scanner { cin: cin }
    }

    fn read<T: FromStr>(&mut self) -> Option<T> {
        let token = self.cin.by_ref().bytes().map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        token.parse::<T>().ok()
    }

    fn input<T: FromStr>(&mut self) -> T {
        self.read().unwrap()
    }

    fn vec<T: FromStr>(&mut self, len: usize) -> Vec<T> {
        (0..len).map(|_| self.input()).collect()
    }

    fn mat<T: FromStr>(&mut self, row: usize, col: usize) -> Vec<Vec<T>> {
        (0..row).map(|_| self.vec(col)).collect()
    }
}
fn enumerate_divisors(n: usize) -> Vec<usize> {
    let mut ret = Vec::new();
    let mut i = 1;
    while i * i <= n {
        if n % i == 0 {
            ret.push(i);
            if i * i != n {
                ret.push(n / i);
            }
        }
        i += 1;
    }
    ret
}
fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);

    let n: usize = sc.input();

    let mut cnt = 0usize;
    for a in 1..n + 1 {
        let b = n / a;
        cnt += b;
        if n % a == 0 {
            cnt -= 1;
        }

    }
    // for c in 1..n + 1 {
    //     let rest = n - c;
    //     let divs = enumerate_divisors(rest);
    //     cnt += divs.len();
    // }
    println!("{}", cnt);
}


Measured memory_bytes: 2172
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) unique(v.begin(), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
#define all(v) (v).begin(), (v).end()
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

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

    int H, W;
    cin >> H >> W;
    int a[H][W];
    rep(i, 0, H) rep(j, 0, W) cin >> a[i][j];

    int j = 0;
    vector<pair<int, int> > v1, v2;

    rep(y, 0, H) {
        if(y % 2 == 0) {
            for(int x = 0; x < W; x++) {
                if(a[y][x] % 2 != 0) {
                    if(x != W - 1) {
                        v1.push_back(make_pair(y, x));
                        v2.push_back(make_pair(y, x + 1));
                        a[y][x + 1]++;
                        a[y][x]--;
                    } else {
                        if(y + 1 < H) {
                            a[y + 1][x]++;
                            a[y][x]--;
                            v1.push_back(make_pair(y, x));
                            v2.push_back(make_pair(y + 1, x));
                        }
                    }
                }
            }
        } else {
            for(int x = W - 1; x >= 0; x--) {
                if(a[y][x] % 2 != 0) {
                    if(x != 0) {
                        a[y][x - 1]++;
                        a[y][x]--;
                        v1.push_back(make_pair(y, x));
                        v2.push_back(make_pair(y, x - 1));
                    } else {
                        if(y + 1 < H) {
                            a[y + 1][j]++;
                            a[y][x]--;
                            v1.push_back(make_pair(y, x));
                            v2.push_back(make_pair(y + 1, x));
                        }
                    }
                }
            }
        }
    }

    cout << v1.size() << endl;
    rep(i, 0, v1.size()) {
        cout << v1[i].first + 1 << " " << v1[i].second + 1 << " " << v2[i].first + 1 << " " << v2[i].second + 1<< endl;
    }
}


Measured memory_bytes: 5228
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define rep2(i,n) for(int i = 1; i <= (n); ++i)
#define rrep2(i,n) for(int i = (n); i > 0; --i)
#define srep(i,s,n) for(int i = s; i < (n); ++i)
#define rsrep(i,s,n) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { int n = (__VA_ARGS__).size(); rep(i, n) printf("%d%s", (__VA_ARGS__)[i], i != n-1 ? " " : "\n"); }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;


int main() {
    string s;
    cin >> s;
    int a = 0, b = 0;
    rep(i, s.length()) {
        if (s[i] == '0') a++;
        else b++;
    }

    int ans = min(a, b)*2;

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 512