akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define int long long
//#undef int
#define mk make_pair
#define pb push_back
#define pf push_front
typedef pair<int, int> pii;
const int mod = 1000000007;
const int INF = 1000000009;
const long long INFL = 1000000000000000018ll;

int N, h[100100];

signed main()
{
    cin >> N;
    int mx = 0;
    for(int i = 0; i < N; i++){
        cin >> h[i];
        mx = max(mx, h[i]);
    }
    h[N] = 0;
    int ans = 0;
    for(int i = 1; i <= mx; i++){
        for(int j = 0; j < N; j++){
            if(h[j] >= i && h[j + 1] < i){
                ans++;
            }
        }
    }
    cout << ans << endl;

    return 0;
}
/*


*/




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

int main(){
  int n,t;
  cin >> n >> t;
  int costmin=1001;
  int c1, t1;
  for(int i=0; i<n; i++){
    cin >> c1 >> t1;
    if(t1<=t)costmin = min(costmin, c1);
  }
  if(costmin==1001)cout << "TLE" << endl;
  else cout << costmin << endl;
}

Measured memory_bytes: 256
/**********************************************
 * author : deepak nayan
 * file   : e:/Solutions/atcoder/abc163_a.cpp
 * time   : Sat May  2 21:31:38 2020
 * quest  : A - Circle Pond
 *********************************************/
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>

using namespace std;

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int r;
  cin >> r;
  cout << 2 * r * 3.14159 << "\n";
  return 0;
}


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

using ll = long long;
using pp = pair<ll,ll>;
const ll amari = 1e9+7;
const char BC = 'A' - 'a';
#define ben(a) a.begin(),a.end()
#define pb(a,b) a.push_back(b)
//fixed << setprecision(20)
int main(){
	string a,b,c;
	cin >> a >> b >> c;
	cout << "A" << b[0] << "C" << endl; //AとCの間に2つ目の文字列の頭文字
	return 0;
}

Measured memory_bytes: 256
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
#include<iomanip>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
void init_io(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(10);
}
signed main(){
  init_io();
  ll n,m;
  cin >> n >> m;
  ll p,ac=0,psum=0;
  string s;
  vector<ll> pe(n);
  vector<bool> solve(n,false);
  for(int i=0;i<m;i++){
    cin >> p >> s;
    p--;
    if(solve[p]) continue;
    if(s=="AC"){
      solve[p] = true;
    }else{
      pe[p]++;
    }
  }
  for(int i=0;i<n;i++){
    if(solve[i]){
      ac++;
      psum += pe[i];
    }
  }
  cout <<ac <<" "<<psum<<endl;
}


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

int main()
{
  int a, b, c;
  cin >> a >> b >> c;
  int max ;
  max = 10*a + b + c;
  if(max < a + 10*b + c){
    max = a + 10*b + c;
  }
  if(max < a + b + 10*c){
    max = a + b + 10*c;
  }

    cout << max <<endl;
}


Measured memory_bytes: 256
N,K=map(int,input().split())
t=set()
for _ in range(K):
    D=int(input())
    A=list(map(int,input().split()))
    for i in A:
        t.add(i)
ans=0
for i in range(1,N+1):
    if i not in t:
        ans+=1
print(ans)

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

int main() {
	int a, b, c;
	scanf("%d%d%d", &a, &b, &c);
	for (int i = 0; i <= 1000; ++i) {
		int ta, tb, tc;
		if ((a & 1) || (b & 1) || (c & 1)) {
			printf("%d\n", i);
			return 0;
		}
		ta = (b / 2 + c / 2);
		tb = (a / 2 + c / 2);
		tc = (a / 2 + b / 2);
		a = ta;
		b = tb;
		c = tc;
	}
	puts("-1");
}

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

using namespace std;

struct edge {
    int to;
    int cost;
};

const long long INF = 1e18;

typedef pair<long long, long long> P;
vector<long long> dijk(vector<vector<edge>> &g, int n, int s) {
    vector<long long> d(n);
    priority_queue<P, vector<P>, greater<P>> q;
    fill(d.begin(), d.end(), INF);
    d[s] = 0;

    q.push({0, s});

    while(!q.empty()) {
        auto p = q.top(); q.pop();
        auto v = p.second;
        if (d[v] < p.first) continue;
        for (auto &e : g[v]) {
            if (d[e.to] > d[v] + e.cost) {
                d[e.to] = d[v] + e.cost;
                q.push({d[e.to], e.to});
            }
        }
    }
    return d;
}

int main() {
    int n, m, s, t;
    cin >> n >> m >> s >> t;

    vector<vector<edge>> G1(n), G2(n);
    for (int i = 0; i < m; ++i) {
        int u, v, a, b;
        cin >> u >> v >> a >> b;
        --u, --v;
        G1[u].push_back({v, a});
        G1[v].push_back({u, a});
        G2[u].push_back({v, b});
        G2[v].push_back({u, b});
    }
    auto d1 = dijk(G1, n, s - 1);
    auto d2 = dijk(G2, n, t - 1);

    priority_queue<P> q;
    const long long X = 1e15;
    for (int i = 0; i < n; ++i) {
        q.push({X - (d1[i] + d2[i]), i});
    }
    for (int i = 0; i < n; ++i) {
        while (q.top().second < i) q.pop();
        cout << q.top().first << endl;
    }

    return 0;
}

Measured memory_bytes: 17016
using System;
using System.Collections.Generic;
using System.Linq;
class abc168_c{
  public static void Main(){
    String[] str = Console.ReadLine().Split(' ');
    int a = int.Parse(str[0]);
    int b = int.Parse(str[1]);
    int h = int.Parse(str[2]);
    int m = int.Parse(str[3]);
    double ha = 30*h + m*0.5;
    double ma = 6*m;
    double agl = Math.Abs(ha - ma);
    double ans = Math.Sqrt(a*a+b*b-2*a*b*Math.Cos(Math.PI*agl/180));
    Console.WriteLine(ans);
  }
}


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

long long mg(int A[],int l,int m,int r){
  long long cnt=0;
  int n1=m-l,n2=r-m;
  int L[n1+1],R[n2+1];
  for(int i=0;i<n1;i++)L[i]=A[l+i];
  for(int i=0;i<n2;i++)R[i]=A[m+i];
  L[n1]=1000000001,R[n2]=1000000001;
  int i=0,j=0;
  for(int k=l;k<r;k++){
    if(L[i]<=R[j]){
      A[k]=L[i];
      i++;
    }else{
      A[k]=R[j];
      j++;
      cnt+= (long long)n1- (long long)i;
    }
  }
  return cnt;
}

long long mgs(int A[],int l,int r){
  long long cnt=0;
  if(l+1<r){
    int m=(l+r)/2;
    cnt+=mgs(A,l,m);
    cnt+=mgs(A,m,r);
    cnt+=mg(A,l,m,r);
  }
  return cnt;
}

int main(){
  int n,A[200000];
  long long cnt;
  cin>>n;
  for(int i=0;i<n;i++)scanf("%d",&A[i]);
  cnt=mgs(A,0,n);
  cout<<cnt<<endl;
  return 0;
}

Measured memory_bytes: 4708
import sys
N = int(sys.stdin.readline().rstrip())
A = list(map(int, sys.stdin.readline().rstrip().split()))
S = [0]*(10**5)

ans = 0
for n in range(N):
    a = A[n]
    S[a-1] += a
    ans += a

Q = int(sys.stdin.readline().rstrip())

for q in range(Q):
    B, C = list(map(int, sys.stdin.readline().rstrip().split()))
    up = C * S[B-1]//B
    down = S[B-1]
    S[C-1] += C * S[B-1]//B
    S[B-1] = 0
    ans = ans + up - down
    print(ans)

Measured memory_bytes: 20724
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
#define int long long
signed main() {
	int n; cin >> n;
	cout << "0\n" << flush;
	string s; cin >> s;
	if (s[0] == 'V')return 0;
	int l = 0, r = n;
	string ls = s, rs = s;
	while (1) {
		int p = (l + r) / 2;
		cout << p << endl << flush;
		cin >> s;
		if (s[0] == 'V')return 0;
		if ((ls != s) + ((p - l) % 2 == 0) == 1) {
			ls = s;
			l = p;
		}
		else {
			r = p;
			rs = s;
		}
	}
}

Measured memory_bytes: 976
/* ex3_4
   kohei_suzuki */

#include <stdio.h>

int main(void){
    int pro, div=9 ; //割られる整数proと割る整数div

    scanf("%d",&pro); //proを入力

    int quot; //proをdivで割った整数quot

    while(pro % div != 0){ //9から順に1ずつ割っていき、割り切れるまで繰り返す
        div -= 1;
        quot = pro / div;
    }

    if(quot < 10){ //割り切れてかつlが10より小さければyes
        printf("Yes\n");
    }else{ //それ以外ならno
        printf("No\n");
    }

    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
  ll n,ma=0,c=0,cnt=-1,to;
  cin>>n;
  while(n!=0){
    c+=n%10;
    n/=10;
    cnt++;
    if(n<10&&n!=0){
      to=n;
    }
  }
  cout<<max(c,to-1+9*cnt);
}
  


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] p = new int[n];

		for(int i = 0 ; i < n ; i++) {
			p[i] = sc.nextInt();
		}

		int ans = 0;
		for(int i = 1 ; i < n - 1 ; i++) {
			if((p[i] <= p[i + 1] && p[i] >= p[i - 1]) || (p[i] >= p[i + 1] && p[i] <= p[i - 1])) {
				ans++;
			}
		}
		System.out.println(ans);

		sc.close();

	}

}


Measured memory_bytes: 21844
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   ff   first
#define   ss   second
#define   pii  pair<int,int>
using namespace std;

inline void solve(){ 
    int n,ans=0; 
    cin>>n; n--; 
    vi a(n); 
    for (int &i: a) cin >> i; 
    ans = a[0]; 
    ans += a[n-1]; 
    for (int i=0;i<n-1;i++)
        ans += min(a[i],a[i+1]); 
    cout << ans << endl; 
} 
 
signed main() 
{ 
    int n=1; // cin>>n; 
    while (n--) solve(); 
    return 0; 
} 


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define fi			first
#define se			second
#define fz(i,a,b)	for(int i=a;i<=b;i++)
#define fd(i,a,b)	for(int i=a;i>=b;i--)
#define put(x)		putchar(x)
#define eoln        put('\n')
#define space		put(' ')
inline int read(){
	int x=0,neg=1;char c=getchar();
	while(!isdigit(c)){
		if(c=='-')	neg=-1;
		c=getchar();
	}
	while(isdigit(c))	x=x*10+c-'0',c=getchar();
	return x*neg;
}
inline void print(int x){
	if(x<0){
		putchar('-');
		print(abs(x));
		return;
	}
	if(x<=9)	putchar(x+'0');
	else{
		print(x/10);
		putchar(x%10+'0');
	}
}
int n=read();
struct edge{
	int u,v,w;
};
vector<edge> g[100005];
int dist[100005];
inline void dijkstra(){
	priority_queue<pair<int,int>,vector<pair<int,int> >,greater<pair<int,int> > > pq;
	memset(dist,63,sizeof(dist));
	dist[1]=1;
	pq.push({1,1});
	while(!pq.empty()){
		pair<int,int> p=pq.top();
		pq.pop();
		int s=p.first,x=p.second;
		if(s>dist[x])	continue;
		for(int i=0;i<g[x].size();i++){
			int y=g[x][i].v,z=g[x][i].w;
			if(dist[y]>dist[x]+z){
				dist[y]=dist[x]+z;
				pq.push({dist[y],y});
			}
		}
	}
}
int main(){
	fz(i,0,n-1){
		if(i!=0)	g[i].push_back({i,i*10%n,0});
		g[i].push_back({i,(i+1)%n,1});
	}
	dijkstra();
	print(dist[0]);
	return 0;
}

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

sd = {}
for i in s:
    if i not in sd:
        sd[i] = 0
    sd[i] += 1
td = {}
for i in t:
    if i not in td:
        td[i] = 0
    td[i] += 1
d = {}
for i in sd.keys():
    try:
        d[i] = (sd[i] - td[i])
    except:
        d[i] = sd[i]

if max([d[i] for i in d.keys()]) <= 0:
    print(0)
else:
    print(max([d[i] for i in d.keys()]))

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

int main(){
    cin.sync_with_stdio(0); cin.tie(0);
    cin.exceptions(cin.failbit);
	
	int n;
	long a, b;
	cin >> n >> a >> b;
	if(a > b) {
		cout << 0 << endl;
		return 0;
	}
	if(n == 1 && a < b){
		cout << 0 << endl;
		return 0;
	}
	cout << (n-1)*(b-a)+a-b+1 << endl;
	return 0;
}

Measured memory_bytes: 3620
a,b,q = gets.split.map(&:to_i)
jinja = []
tera = []
xs = []
a.times do
  j = gets.to_i
  jinja << j
end
b.times do
  t = gets.to_i
  tera << t
end
q.times do
  xs << gets.to_i
end

jinja.sort!
tera.sort!

def search_low(current, j_or_t)
  i = j_or_t.bsearch_index{|j| j > current}
  if i.nil?
    i = -1
  elsif i != 0
    i = i-1
  elsif i == 0
    return [nil, Float::INFINITY]
  end
  [j_or_t[i], (current-j_or_t[i]).abs]
end

def search_high(current, j_or_t)
  i = j_or_t.bsearch_index{|j| j > current}
  if i.nil?
    i = -1
  end
  [j_or_t[i], (current-j_or_t[i]).abs]
end

def hoge1(x, jinja, tera)
  current1, cost1 = search_low(x, jinja)
  return Float::INFINITY if current1.nil?
  current2, cost2 = search_low(current1, tera)
  cost2 = Float::INFINITY if current2.nil?
  current3, cost3 = search_high(current1, tera)
  cost3 = Float::INFINITY if current3.nil?
  [cost1+cost2, cost1+cost3].min
end

def hoge2(x, jinja, tera)
  current1, cost1 = search_high(x, jinja)
  return Float::INFINITY if current1.nil?
  current2, cost2 = search_low(current1, tera)
  cost2 = Float::INFINITY if current2.nil?
  current3, cost3 = search_high(current1, tera)
  cost3 = Float::INFINITY if current3.nil?
  [cost1+cost2, cost1+cost3].min
end

def hoge3(x, jinja, tera)
  current1, cost1 = search_low(x, tera)
  return Float::INFINITY if current1.nil?
  current2, cost2 = search_low(current1, jinja)
  cost2 = Float::INFINITY if current2.nil?
  current3, cost3 = search_high(current1, jinja)
  cost3 = Float::INFINITY if current3.nil?
  [cost1+cost2, cost1+cost3].min
end

def hoge4(x, jinja, tera)
  current1, cost1 = search_high(x, tera)
  return Float::INFINITY if current1.nil?
  current2, cost2 = search_low(current1, jinja)
  cost2 = Float::INFINITY if current2.nil?
  current3, cost3 = search_high(current1, jinja)
  cost3 = Float::INFINITY if current3.nil?
  [cost1+cost2, cost1+cost3].min
end

xs.each do |x|
  puts [
    hoge1(x, jinja, tera),
    hoge2(x, jinja, tera),
    hoge3(x, jinja, tera),
    hoge4(x, jinja, tera)
  ].min
end

Measured memory_bytes: 6768
#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
const ll mod = 1000000007;


const ll LINF = 1e13;
const ll LLINF = 1e18;
const ll ALPHABET = 26;

template <class T>
void Swap(T& r, T& l) {
  T tmp = r;
  r = l;
  l = tmp;
}

template<typename T>
istream& operator >> (istream& is, vector<T>& vec) {
  for (T& x : vec) is >> x; //for(int i=0; i<vec.size(); i++) is >> x[i]; とかでもいい
  return is;
}


// mod. m での a の逆元 a^{-1} を計算する
ll modinv(long long a, long long m) {
  long long b = m, u = 1, v = 0;
  while (b) {
    long long t = a / b;
    a -= t * b; swap(a, b);
    u -= t * v; swap(u, v);
  }
  u %= m;
  if (u < 0) u += m;
  return u;
}



map<ll, ll> prime_factors(ll n) {
  map<ll, ll> res;
  if (n == 1) { // n=1 の素因数分解は n^1
    res[n] = 1;
    return res;
  }
  for (ll i = 2, _n = n; i * i <= _n; ++i) {
    while (n % i == 0) {
      ++res[i]; // 素数i^{res[i]}
      n /= i;
    }
  }
  if (n != 1) res[n] = 1;
  return res;
}



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

  vector<string> mp(h);

  for (int i = 0; i < h; i++) {
    cin >> mp[i];
  }
  ll ans = 0;

  ll wnum = 0;
  ll bnum = 0;
  ll num = w * h;
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if (mp[i][j] == '.') {
        wnum++;
      } else {
        bnum++;
      }
    }
  }


  pair<ll, ll> start = make_pair(0, 0);
  pair<ll, ll> goal = make_pair(h - 1, w - 1);


  vector<vector<ll>> mptmp(h, vector<ll>(w, 0));

  mptmp[start.first][start.second] = 1;

  vector<pair<ll, ll>> tmp;
  tmp.push_back(start);

  ll count = 1;

  while (tmp.size() > 0) {
    vector<pair<ll, ll>> tmp2;

    for (auto v : tmp) {
      ll hh = v.first;
      ll ww = v.second;

      for (int x = -1, y = 0, i = 0; i < 4; x += y, y = x - y, x = y - x, ++i) {
        ll h_ = max(min(hh + x, h - 1), (ll)0);
        ll w_ = max(min(ww + y, w - 1), (ll)0);
        // cout << "x " << x << " y " << y << endl;
        if (mp[ max(min(hh + x, h - 1), (ll)0) ][ max(min(ww + y, w - 1), (ll)0) ] == '.' ) {
          mp[ max(min(hh + x, h - 1), (ll)0) ][ max(min(ww + y, w - 1), (ll)0) ] = '#';
          mptmp[ max(min(hh + x, h - 1), (ll)0) ][ max(min(ww + y, w - 1), (ll)0) ] = count + 1;
          tmp2.push_back(make_pair(h_,w_));
        }
      }

    }
    tmp = tmp2;


    count++;
  }


  ll minSq = mptmp[goal.first][goal.second];

  ans = num - bnum - minSq;

  if (mptmp[goal.first][goal.second] == 0)ans = -1;


  cout << ans << endl;
}




















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

int A, B, C;
int main()
{
	cin >> A >> B >> C;
	if (A == B)
	{
		cout << C << endl;
	} else if (A == C)
	{
		cout << B << endl;
	} else
	{
		cout << A << endl;
	}

	cin.get();
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#define INF 1e9+7
#define rep(i,n) for(int i=0;i<n;i++)
#define NO cout<<"NO"<<endl;
#define YES cout << "YES"<<endl;
#define No cout << "No"<<endl;
#define Yes cout << "Yes"<<endl;
#define all(a) a.begin(),a.end()
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

//(int)'a'は97 (int)'A'は65 (int)'1'は49
//おまじない

int main(){
    
    string s;
    vector<string> vs(4);
    
    cin >> s;
    
    vs[0]="resare";
    vs[1]="esare";
    vs[2]="remaerd";
    vs[3]="maerd";
    
    reverse(all(s));
    
    int i=0;
    
    while(i<s.size()){
        bool key=false;
        for(int j=0;j<vs.size();j++){
            
            string c=s.substr(i,vs[j].size());
            if(vs[j]==c){
                i+=vs[j].size();
                key=true;
                break;
            }
            
        }
        if(!key){
            NO;
            return 0;
        }
    }
    
    YES;
    
    return 0;
}


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

int main(){
    vector<char> A(4);

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

for(int i = 0; i < 3; i++){
    if(A.at(i) == A.at(i+1)) {
        cout << "Bad" << endl;
        return 0;
    }
}

    cout << "Good" << endl;
    return 0;
}

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

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


const int N = 25000;
int n, p[N], b[N];

int main() {
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> p[i];
        b[i] += N * (n - i + 1);
        b[p[i]] += i;
    }
    for (int i = 1; i <= n; i++)
        cout << N * i << ' ';
    cout << '\n';
    for (int i = 1; i <= n; i++)
        cout << b[i] << ' ';
    cout << '\n';
}


Measured memory_bytes: 768
/*?´??????°????§£*/
#include<stdio.h>
int pr[50847534];

int x=0;
int nextpr(int p){
  int nxp=p+2;
  int i=0;
  int ok=1;
  pr[x]=p;
  x++;
  if(p==2)return 3;
  while(1){
    for(i=0;pr[i]*pr[i]<=nxp;i++){
      ok = 1;
      if(nxp%pr[i]==0){
        ok = 0;
        break;
      }
    }
    if(ok){
      return nxp;
    }else{
      nxp+=2;
    }
  }
}

int main(){
  int n,n2;
  int p=2;
  int done=1;
  scanf("%d",&n);
  printf("%d:",n);
  n2 = n;
  while(n>1){
    if(n%2==0){
      printf(" 2");
      n /= 2;
      done = 0;
    }else if(n%p==0){
      printf(" %d",p);
      n /= p;
      done = 0;
    }else{
      /*printf("X%d\n",p);*/
      p = nextpr(p);
    }
    if(p*p>n2&&done){
      printf(" %d",n2);
      break;
    }
  }
  printf("\n");
}

Measured memory_bytes: 1036
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <ccomplex>
#include <unordered_map>
#include <cstring>
#include <iostream>
#include <numeric>
#include <sstream>
#include <set>
#include <map>
#include <iomanip>

using namespace std;
#define MAX 1LL << 60
#define MOD 1000000007

typedef long long ll;

#define rep(i, s, e) for(ll i = s; i < e; i++)
#define repR(i, s, e) for(ll i = s; i > e; i--)
#define reft0(i, j) setfill('0') << setw(i) << j
#define fix(i) fixed << setprecision(i)


template<class T> inline bool chMax(T& a, T b){ if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chMin(T& a, T b){ if (a > b) { a = b; return true; } return false; }
template<class T> inline ll gcd(T a, T b){ if (a % b == 0){ return b; } else{ return gcd(b, a%b); } }
template<class T> inline ll lcm(T a, T b){ return a * b / gcd(a, b); }
template<class T> inline ll fact(T a){ if (a <= 1){ return 1; } else{ return a * fact(a - 1); } }
template<class T> inline ll comb(T a, T b){ return a == 0 ? 0 : fact(a) / fact(b) / fact(a - b); }

int main(){
    ll H, A;
    cin >> H >> A;
    ll ans = H / A;
    cout << (H % A != 0 ? ans + 1 : ans) << endl;
}

Measured memory_bytes: 256
import Control.Applicative ((<$>), (<*>))
import Control.Monad
import Data.List
import Data.Function (on)

main :: IO ()
main = do
  xs <- getl $ wrds toInt
  unless (xs == [0,0]) $ do
    ys <- replicateM 4 (getl $ wrds toInt)
    putStrLn . solve $ xs : ys
    main
    
solve :: [[Int]] -> String
solve = f . maximumBy (compare `on` snd) . zip ["A","B","C","D","E"] . map sum
  where f (x, y) = x ++ " " ++ show y

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

wrds :: (String -> a) -> String -> [a]
wrds f = map f . words

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

getc :: ([String] -> a) -> IO a
getc f = f . lines <$> getContents

Measured memory_bytes: 4136
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) FOR(i,0,n)
#define FOR(i,a,b) for(int i=(a),i##Len_=(b);i<i##Len_;i++)

int main(){
    int r,D,x2000;
    cin >> r >> D >> x2000;

    int res[11];

    res[0] = x2000;

    //2001から2010まで出力
    //x2001 = r*x2000 - D;

    REP(i,10){
        res[i+1] = r*res[i] - D;
        cout << res[i+1] << endl;
    }
    return 0;
}



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

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

    while(true){
      int h=Integer.parseInt(scan.next());
      int w=Integer.parseInt(scan.next());
      if(h==0 && w==0)break;

      for(int i=0;i<w;i++){
        System.out.print("#");
      }
      System.out.println();

      for(int i=0;i<h-2;i++){
        for(int j=0;j<w;j++){
          if(j==0 || j==w-1){
            System.out.print("#");
            if(j==w-1)System.out.println();
          }else{
            System.out.print(".");
          }
        }
      }

      for(int i=0;i<w;i++){
        System.out.print("#");
      }
      System.out.println();
      System.out.println();
    }
  }
}


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

int main() {
    int x, y;
    cin >> x >> y;
    int ans;
    if (x > 0) {
        if (y <= -x) ans = -y - x + 1;
        if (-x <= y && y <= 0) ans = x + y + 1;
        if (0 < y && y < x) ans = x - y + 2;
        if (x <= y) ans = y - x;
    }
    else if (x < 0) {
        if (y < x) ans = x - y + 2;
        if (x <= y && y <= 0) ans = y - x;
        if (0 < y && y <= -x) ans = -x - y + 1;
        if (-x < y) ans = x + y + 1;
    }
    else {
        if (y >= 0) ans = y;
        else ans = -y + 1;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
  long N,A[100000],i,x,a=1;
  
  scanf("%ld",&N);
  x=1;
  for(i=0;i<N;i++){
    scanf("%ld",&A[i]);
    if(A[i]==0){
      puts("0");
      return 0;
    }
    if((long)1e18/x/A[i]<1){
      a=0;
    }
    else x=x*A[i];
  }
  if(a==0)puts("-1");
  else printf("%ld\n",x);
  return 0;
}

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

ll mod = 1000000007;


int main() {
	long long x; cin >> x;
	int cnt = 0;
	long long money = 100;
	while(money < x){
		long long tmp = money /100;
		money += tmp;
		cnt++;
	}
	cout << cnt << endl;
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
int main (){
    int n;
    cin >> n;
    
    vector<int> b(n),ans(0);
    
    for(int i=0;i<n;i++){
        cin >> b.at(i);
        /*if(b.at(i) > i+1){
            cout << -1 << endl;
            return 0;
        }*/
    }//input

    for(int j=n;0<j;j--){//nかいやる
        bool check = false;
        for(int k=j;0<k;k--){
            
            if(b.at(k-1) == k){
                ans.push_back(b.at(k-1));
                b.erase(b.begin()+k-1);
                check = true;
                break;
            }
        }
        
        if(check == false){
            cout << -1 << endl;
            return 0;
        }
    }

    reverse(ans.begin(),ans.end());
    for(int i=0;i<n;i++){
        cout << ans.at(i) << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
#define rep(i,n) for(int i=0;i<n;++i)
#define rep2(i,x,n) for(int i=x;i<n;++i)

int main()
{    
    const i64 MOD = 1e9+7;
    int n;
    cin >> n;
    vector<i64> a(n);
    rep(i,n) cin >> a[i];

    i64 sum = 0;
    i64 base = 1;
    rep(i,61)
    {
        i64 cnt[2] = {0};
        rep(j,n)
        {
            if((a[j] & 1) == 1) cnt[1]++;
            else cnt[0]++;
            a[j] >>= 1;
        }

        sum += ((cnt[0] * cnt[1]) % MOD) * base;
        sum %= MOD;
        base = (base * 2) % MOD;
    }

    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 2560
str = gets.chomp
a = str[0].to_i
b = str[2].to_i
c = str[4].to_i
xs = Array.new()
xs.push(a*10+b+c)
xs.push(a+b*10+c)
xs.push(a+b+c*10)
max_xs = 0
for i in 0..2
	if max_xs <= xs[i]
    	max_xs = xs[i]
    end
end
puts max_xs.to_s

Measured memory_bytes: 1788
package main

import "fmt"

func main() {
	// Code for B - Path
	var a, b int
	c := make(map[int]int, 4)
	for i := 0; i < 3; i++ {
		fmt.Scanf("%d %d", &a, &b)
		c[a]++
		c[b]++
	}

	var count1, count2 int
	for _, v := range c {
		if v == 1 {
			count1++
		} else if v == 2 {
			count2++
		}
	}

	if count1 == 2 && count2 == 2 {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}


Measured memory_bytes: 1836
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define ll long long
#define imfor(i, n) for(int i = 0; i < n; i++)
using namespace std;
ll MOD = 1000000007;

int main() {
    int x, a, b;
    cin >> x >> a >> b;
    x -= a;
    while (x - b >= 0) {
        x -= b;
    }
    cout << x << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int n;
const int maxn = 2e5+ 5;
int a[maxn];
int main(){
	scanf("%d", &n);
	map<int, int>mp;
	for(int i = 1; i <= n - 1; i++){
		scanf("%d", &a[i]);
		mp[a[i]]++;
	}
	for(int i = 1; i <= n; i++){
		printf("%d\n", mp[i]);

	}

	return 0;
}

Measured memory_bytes: 13944
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#define _USE_MATH_DEFINES
#include <cmath>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <iomanip>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007; // 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};

struct IOSetup {
  IOSetup() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    cerr << fixed << setprecision(10);
  }
} iosetup;
/*-------------------------------------------------*/
int main() {
  int n; cin >> n;
  cout << "ABC" << n << '\n';
  return 0;
}


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

int main() {
  int n;
  
  while(cin >> n, n) {
    vector<string> s(n);
    for(auto& x: s)
      cin >> x;

    vector<int> d(n, 0);
    int d_max = 0;
    for (int i= 0; i < n; i++) {
      for (int j = 0; j < s[i].size(); j++) {
	if (s[i][j] != '.') {
	  d[i] = j;
	  s[i] = s[i].substr(j);
	  d_max = max(d_max, j);
	  break;
	}
      }
    }

    vector<bool> used(d_max, false);
    int c_d = 0;
    for (int i = 0; i < n; i++) {
      if (d[i] > c_d) {
	for (int j = i+1; j < n; j++) {
	  if(d[j] < c_d) break;
	  if(d[j] == c_d) used[c_d] = true;
	}
      }

      if (d[i] < c_d) {
	used[d[i]] = false;
      }

      c_d = d[i];
      for (int j = 0; j < c_d; j++) {
	if(j == c_d - 1) cout << "+";
	else if(used[j+1]) cout << "|";
	else cout << " ";
      }
      cout << s[i] << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 3764
fun main(args: Array<String>) {
    val o = readLine()!!
    val e = readLine()!!
    var i = 0
    while(i != e.count()){
        print(o[i])
        print(e[i])
        i += 1
    }
    if (o.count() > e.count()) print(o.last())
}

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

typedef long long ll;
typedef std::pair<ll, ll> P;
typedef std::tuple<ll, ll, ll> t3;
constexpr ll INF = 1e15;
constexpr ll mod = 1e9+7;

#define rep(i,n) for(int i = 0; i < int(n); i++)
using namespace std;

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

struct UnionFind {
public:
	vector <ll> par; // 
	vector <ll> siz; // 

	UnionFind() {}

	UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) {
		for (ll i = 0; i < sz_; ++i) par[i] = i;
	}
	void init(ll sz_) {
		par.resize(sz_);
		siz.assign(sz_, 1LL);
		for (ll i = 0; i < sz_; ++i) par[i] = i;
	}

	ll root(ll x) {
		while (par[x] != x) {
			x = par[x] = par[par[x]];
		}
		return x;
	}

	bool merge(ll x, ll y) {
		x = root(x);
		y = root(y);
		if (x == y) return false;
		if (siz[x] < siz[y]) swap(x, y);
		siz[x] += siz[y];
		par[y] = x;
		return true;
	}

	bool issame(ll x, ll y) {
		return root(x) == root(y);
	}

	ll size(ll x) {
		return siz[root(x)];
	}
};

int main() {
    ll n;
    cin >> n;
    vector<t3> ps(n);
	map<ll, ll> right;
	rep(i, n) {
        ll x, y;
        cin >> x >> y;
        ps[i] = { x,y,i };
		right[y] = i;
    }
    sort(ps.begin(), ps.end());
	UnionFind uf(n);
	vector<ll> ans(n);
	vector<int> visit(n + 1, 0);
    rep(i, n) {
		ll x, y, id;
		tie(x, y, id) = ps[i];
		if (visit[id]) {
			right.erase(y);
			continue;
		}
		//cout << x << "," << y << "," << id << endl;
		visit[id] = 1;
		auto it = right.lower_bound(y);
		for (; it != right.end(); it++) {
			if (id != it->second) {
				//cout << "merge:" << id << "," << it->second << endl;
				uf.merge(id, it->second);
				visit[it->second] = true;
			}
		}
		right.erase(y);
    }
    rep(i, n) {
        cout << uf.size(i) << endl;
    }
    return 0;
}


Measured memory_bytes: 25884
#include<bits/stdc++.h>
using namespace std;
int main(){
 char S[100];
  cin>>S;
  int n=strlen(S);
  for(int i=0;i<n;i++){
  if(i%2==0){
  if(S[i]=='L'){
    cout<<"No"<<endl;
    return 0;
  }
  }
    else{
    if(S[i]=='R'){
    cout<<"No"<<endl;
      return 0;
    }
    }
  }
  cout<<"Yes"<<endl;
  return 0;
}


Measured memory_bytes: 256
// see https://gist.github.com/LumaKernel/ff55d49ee1af69b7388f15b707e75c15
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <complex>
#include <random>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> VI;
typedef vector<P> VP;

#define omajinai ios::sync_with_stdio(false);cin.tie(0)

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define RREP(i,n) RFOR(i,0,n)

#define LFOR(i,a,b) for(ll i=(a);i<(b);++i)
#define RLFOR(i,b,a) for(ll i=(b)-1;i>=(a);--i)

#define ALL(a) (a).begin(),(a).end()
#define UNIQUE(a) (a).erase(unique((a).begin(),(a).end()),(a).end())
#define MP make_pair
#define PB push_back
#define EACH(i,c) REP(i,(int)(c).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

#define dump(x) cerr << "[L " << __LINE__ << "] " << #x << " = " << (x) << "\n";
#define dump2(x,y) cerr << "[L " << __LINE__ << "] " << #x << " = " << (x)\
			<< " , " << #y << " = " << (y) << "\n";

const int INF = 1e9;
const double EPS = 1e-10;

int n,m;
ll k;
string s;

int main() {
	cin >> s;
	REP(i, s.size()-1)
		if(s[i]=='A'&&s[i+1]=='C')
		{
			cout << "Yes"<<endl;
			return 0;
		}
	cout << "No"<< endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int H,W,K;
const int MaxH=10;
const int MaxW=1000;
string S[MaxH];
int main(){
	cin>>H>>W>>K;
	for(int i=0;i<H;i++){
		cin>>S[i];
	}
	int ret=1e9;
	for(int mask=0;mask<(1<<(H-1));mask++){
		int abs_of_mask=__builtin_popcount(mask);
		vector<int>count(abs_of_mask+1);
		int tmp=abs_of_mask;
		
		bool suc=false;
		for(int j=0;j<W;j++){
			int now=0;
			for(int i=0;i<H;i++){
				if(S[i][j]=='1')count[now]++;
				if((mask>>i)&1)now++;
			}
			if(*max_element(count.begin(),count.end())>K){
				if(suc){
					tmp=1e9;
					break;
				}
				tmp++;
				for(int k=0;k<(int)count.size();k++){
					count[k]=0;
				}
				j--;
				suc=true;
				continue;
			}
			suc=false;
		}
		if(ret>tmp){
			ret=tmp;
		}
	}
	cout<<ret<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <string>
#include <iomanip>
#include <map>
#include <set>
#include <cmath>
#include <cstdio>
#include <cstdint>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

int main() {
    int N, K, S;
    cin >> N >> K >> S;
    vector<int> A(N);
    if(S != 1e9) {
        rep(i, K) { A[i] = S; }
        for(int i = K; i < N; i++) {
            A[i] = S + 1;
        }
    } else {
        rep(i, K) { A[i] = S; }
        for(int i = K; i < N; i++) {
            A[i] = 1;
        }
    }
    rep(i, N) cout << A[i] << (i == N - 1 ? "\n" : " ");
    return 0;
}

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

void f()
{
  return;
}

void g()
{

}

int main()
{
  int n,u,v; cin>>n>>u>>v; u--; v--;
  vector<int> ta(n, 1001001001);
  vector<int> ao(n, 1001001001);
  ta[u] = 0;
  ao[v] = 0;
  vector<vector<int>> tr(n);
  rep(i, n-1) {
    int a,b; cin>>a>>b; a--; b--;
    tr[a].push_back(b);
    tr[b].push_back(a);
  }
  {
    queue<int> q;
    q.push(u);
    while (!q.empty()) {
      int now = q.front(); q.pop();
      for (auto c:tr[now]) {
        if (ta[c] > ta[now]+1) {
          ta[c] = ta[now]+1;
          q.push(c);
        }
      }
    }
  }
  {
    queue<int> q;
    q.push(v);
    while (!q.empty()) {
      int now = q.front(); q.pop();
      for (auto c:tr[now]) {
        if (ao[c] > ao[now]+1) {
          ao[c] = ao[now]+1;
          q.push(c);
        }
      }
    }
  }
  int ans = 0;
  rep(i, n) {
    if (ta[i] < ao[i]) {
      ans = max(ans, ao[i]-1);
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 6656
#include<iostream>
#include<vector>
using namespace std;
int main(){
    int H,W;
    cin >> H >> W;
    vector<vector<char>> c(H,vector<char>(W));
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            cin >> c[i][j];
        }
        for(int j=0;j<W;j++){
            cout << c[i][j];
        }
        cout << endl;
        for(int j=0;j<W;j++){
            cout << c[i][j];
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
using namespace std;
char a[4];
int num[180];
int main()
{
	int pd=0;
	scanf("%s",&a);
	for(int i=0;i<4;i++)
	{
		num[a[i]]++;
	}
	for(int i=0;i<180;i++)
	{
		if(num[i]%2!=0)
		pd=1;
		if(num[i]>2)
		pd=1;
	}
	if(pd==1)
	printf("No");
	else
	printf("Yes");
} 

Measured memory_bytes: 128
///
// File:  b.go
// Author: ymiyamoto
//
// Created on Sun Mar 25 19:32:13 2018
//
package main

import (
	"fmt"
	"strconv"
)

var A, B int

func is_palidrome(str string) bool {
	for i := range str {
		if str[i] != str[len(str)-1-i] {
			return false
		}
	}
	return true
}
func main() {
	fmt.Scan(&A, &B)

	count := 0
	for i := A; i <= B; i++ {
		str := strconv.Itoa(i)
		if is_palidrome(str) {
			count++
		}
	}
	fmt.Println(count)
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define ALL(v) (v).begin(), (v).end()
#define ios() ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int,int>;
//constexpr int MOD = 10e9+7;
constexpr int INF = 1LL << 60;
//constexpr int INF = 1 << 9;
inline int in() {int x; cin >> x; return x;}
template <typename T> inline void out(const T& x) {cout << x << endl;}
template <class T> inline bool chmin(T &a, T b){if (a > b){a = b;return 1;}return 0;}
template <class T> inline bool chmax(T &a, T b){if (a < b){a = b;return 1;}return 0;}
//UP = 0;RIGHT = 1; DOWN = 2; LEFT =3;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b)
{
  if (a < b)
    gcd(b, a);
  int r;
  while ((r = a % b))
  {
    a = b;
    b = r;
  }
  return b;
}
void eratos(bool * isPrime,int max){
  fill(isPrime,isPrime + max,true);
  isPrime[0] = false; 
  isPrime[1] = false; 
  for(int i=2; i<=max/i; ++i) 
      if(isPrime[i]) 
          for(int j=2; j<=max/i; ++j) 
              isPrime[i*j] = false;    
}
//
inline int hoge(int s, int t,int x)
{
  return min(abs(s-x) + abs(t-s),abs(t-x) + abs(t-s));
}
signed main()
{
  ios();
  int A,B,Q;
  cin >> A >> B >> Q;
  vector<int> s(A+2,0);
  vector<int> t(B+2,0);
  vector<int> x(Q,0);
  s[0] = -INF;
  s[A+1] = INF;
  t[0] = -INF;
  t[B+1] = INF;
  rep(i,A) cin >> s[i+1];
  rep(i,B) cin >> t[i+1];
  rep(i,Q) cin >> x[i];

  rep(i,Q)
  {
    auto S = lower_bound(ALL(s),x[i]);
    auto T = lower_bound(ALL(t),x[i]);
    int min =INF;
    rep(k,2)
    {
      rep(j,2)
      {
        chmin(min,hoge(*(S+k-1),*(T+j-1),x[i]));
      }
    }
    cout << min << endl;
  }
  
}


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

using pii = pair<int,int> ;
using pll = pair<long,long> ;
using umpii = unordered_map<int,int> ;
using mpii = map<int,int> ;

#define f first
#define s second

int32_t main(){
	long long n ;
	cin >> n ;
	cout << (n*(n-1))/2 ;
	return 0 ;
}



Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<math.h>
#define loop(i, l, r) for(i=l; i<r; i++)/*Instead of function, (for).*/
#define rep(i,r) for(i=0; i<r; i++)
#define Min(a, b) ((a < b)? a : b)
#define Max(a, b) ((a > b)? a : b)
#define Abs(x) ((x>=0)? x : -x)/*Return the absolute value of x.*/
typedef long long int lli;
/*  scan  */
#define sd(a) scanf("%d",&a)
#define sc(a) scanf("%c",&a), getchar()
#define sf(a) scanf("%f",&a)
#define ss(a) scanf("%s",a)
#define sld(a) scanf("%lld",&a)
/*  print  */
#define odn(a) printf("%d\n",a)
#define oldn(a) printf("%lld\n",a)
#define ocn(a) printf("%c\n",a)
#define ofn(a) printf("%f\n",a)
#define osn(a) printf("%s\n",a)
#define od(a) printf("%d ",a)
#define old(a) printf("%lld\n",a)
#define oc(a) printf("%c ",a)
#define of(a) printf("%f ",a)
#define os(a) printf("%s ",a)
/*Return Combination ,(nCr)*/
int combi(int n, int r)
{
	if(r==0 || r==n) return 1;
	else return combi(n-1,r) + combi(n-1,r-1);
}
/*Return gcd(a, b)*/
int gcd(int a, int b){
	if(b == 0) return a;
	else return gcd(b, a % b);
}
int main(void)
{
	int a, b, c;
	sd(a); sd(b); sd(c);
	if(c-(a-b)<0){
		od(0);
		return 0;
	}
	od(c-(a-b));
	return 0;
}

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

using namespace std;

int main()
{
	long long int a, b, c, k;
	cin >> a >> b >> c >> k;
	if (k % 2 == 1) {
		a = -a;
		b = -b;
	}
	cout << a - b;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner stdIn=new Scanner(System.in);
		int A=stdIn.nextInt();
		int B=stdIn.nextInt();
		int K=stdIn.nextInt();
		int s[]=new int[A+B];
		int z=1,y=0;
		while(z<=A&&z<=B){
			if(A%z==0&&B%z==0){
				s[y]=z;
				y++;
			}
			z++;
		}
		System.out.println(s[y-K]);
	}

}

Measured memory_bytes: 23764
def calc(n, N, x):
    m, M = -1, -1
    L, R = 0, 10**13
    while L+1 < R:
        P = (L+R)//2
        if n <= x*P:
            R = P
        else:
            L = P
    if n <= x*R <= N:
        m = x*R
    L, R = 0, 10**13
    while L+1 < R:
        P = (L+R)//2
        if N < x*P:
            R = P
        else:
            L = P
    if n <= x*L <= N:
        M = x*L + (x-1)
    return m, M

def main():
    k = int(input())
    a = list(map(int, input().split()))
    f = True
    m, M = 2, 2
    for i in reversed(range(k)):
        m, M = calc(m, M, a[i])
        if m == -1 or M == -1:
            f = False
            break
    if f:
        print(m, M)
    else:
        print(-1)

if __name__ == "__main__":
    main()

Measured memory_bytes: 14428
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE BangPatterns #-}

import Control.Applicative
import Control.Monad
import Control.Arrow
import Data.List
import Data.Maybe
import Data.Char
import qualified Data.ByteString.Char8 as B
import Text.Printf

readInt = ( readLn :: IO Int )
readInts = map ( read :: String -> Int ) . words <$> getLine

getList = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

main = do
	[ n, k ] <- readInts
	a <- reverse . sort <$> readInts
	print $ sum $ take k a


Measured memory_bytes: 764
import java.util.Scanner;

public class Main {
	public static int ceil(int a, int b){
		int x = (a + (b - 1))/b;
		return x;
	}

	
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		String S = sc.next();
		int c = 0;
		int ans = 0;

		for(int i=0; i < N-1; i++) {
			if (S.charAt(i) != S.charAt(i+1)){
				c += 1;
			}
		}

		ans = N - 1 - Math.max(c - 2*K, 0);
		System.out.println(ans);
	}
}

Measured memory_bytes: 24328
#include <stdio.h>

int main() {
	int pos, a, b, distA, distB;
	scanf("%d %d %d", &pos, &a, &b);
	
	distA = a - pos;
	distB = b - pos;
	if(distA < 0) {
		distA *= -1;
	} if(distB < 0) {
		distB *= -1;
	}
	
	if(distA < distB) {
		printf("A");
	} else {
		printf("B");
	}
	
	return 0;
}

Measured memory_bytes: 1612
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long LL;
int main() {
    int n;
    scanf("%d",&n);
    bool f=false;
    for(int i=0;;i++){
        if(i*7>n)
            break;
        for(int j=0;;j++){
            if(i*7+j*4==n){
                f=true;
                break;
            }
            if(i*7+j*4>n)
                break;
        }
    }
    if(f)
        printf("Yes\n");
    else
        printf("No\n");
}


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

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

    int n;
    cin >> n;
    vector<int> l(2*n);
    rep(i, 2*n) cin >> l[i];

    sort(l.begin(), l.end(), greater<int>());
    
    int res = 0;
    rep(i, n){
        res += min(l[2*i], l[2*i+1]);
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define ALL(n) begin(n),end(n)
int main()
{

    int n;
    cin >> n;
    vector<int> id(n);
    vector<string> s(n);
    vector<int> p(n);
    iota(ALL(id), 0);
    for (int i = 0; i < n; i++)
    {
        cin >> s[i] >> p[i];
    }
    sort(ALL(id), [&s, &p](int l, int r) { return make_pair(s[l], -p[l]) < make_pair(s[r], -p[r]); });
    for (int i : id)
    {
        cout << i + 1 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
A, B= map(int, input().split())

count=0
for tmp in range(A, B+1):
    num=[]
    while tmp > 0:
        num.append(tmp % 10)
        tmp = tmp // 10
    
    if num[0]==num[4] and num[1]==num[3]:
        count+=1

print(count)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
int main() {
  
  int A,B;
  cin >> A >> B;
  int sum;
  
  for(int i = A ; i <= B ; i++ ){
    
    int a = i/10000;
    int b = i/1000 - a*10;
    int c = i/100 - a*100 - b*10;
    int d = i/10 - a*1000 -b*100 -c*10;
    int e = i - a*10000 -b*1000 -c*100 -d*10;
    
    if(a == e && b == d){
      sum ++;
    }
    if(i == B){
      cout << sum << endl;
    }
  }
}
    
    
    


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

#define INF 114514191

int N, M;
int D[100][100];
int E[100][100];
int pv[100][100];
bool U[1000];

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

  for (int i=0; i<N; i++) {
    for (int j=0; j<N; j++) {
      D[i][j] = INF;
      E[i][j] = INF;
      pv[i][j] = i;
    }
    D[i][i] = 0;
  }
  for (int i=0; i<M; i++) {
    int a, b, c; cin >> a >> b >> c;
    a--, b--;
    D[a][b] = c, E[a][b] = i;
    D[b][a] = c, E[b][a] = i;
  }

  for (int k=0; k<N; k++) {
    for (int i=0; i<N; i++) {
      for (int j=0; j<N; j++) {
        if (D[i][k] + D[k][j] < D[i][j]) {
          D[i][j] = D[i][k] + D[k][j];
          pv[i][j] = pv[k][j];
        }
      }
    }
  }
  for (int k=0; k<N; k++) {
    for (int i=0; i<N; i++) {
      int c = pv[k][i], lc = i;
      while (k != lc) {
        if (E[c][lc] != INF) {
          U[E[c][lc]] = true;
        }
        lc = c, c = pv[k][c];
      }
    }
  }
  int c = 0;
  for (int i=0; i<M; i++) {
    if (!U[i]) c++;
  }
  cout << c << "\n";
  return 0;
}


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

int main() {
	int X;
	cin >> X;

	for (int A = -200; A < 201; A++) {
		for (int B = -200; B < 201; B++) {
	       		if (pow(A, 5) - pow(B, 5) == X) {
				cout << A << ' ' << B << endl;
				return 0;
			}
		}
	}	

	return 0;
}


Measured memory_bytes: 4024
#include<bits/stdc++.h>
#define MAXN 100010
#define P 1000000007LL
#define ii pair<int, int>
#define ll long long
#define ff first
#define ss second
using namespace std;

vector<ii> gr[MAXN];
int N, M;

void shortest_path(int S, vector<ll> &dist, vector<ll> &poss){
	dist = vector<ll> (N+1, (1LL << 60));
	poss = vector<ll> (N+1, 0);

	priority_queue<pair<ll, int> > pq;
	pq.push({0, S});
	dist[S] = 0;
	ll d;
	int u;
	vector<int> elem;
	while(!pq.empty()){
		tie(d, u) = pq.top();
		pq.pop();
		d *= -1;

		if(d != dist[u]) continue;
		elem.push_back(u);

		for(auto &v : gr[u]){
			if(dist[v.ff] > dist[u] + v.ss){
				dist[v.ff] = dist[u] + v.ss;
				pq.push({-dist[v.ff], v.ff});
			}
		}
	}
	poss[S] = 1;
	for(auto &u : elem){
		for(auto &v : gr[u]){
			if(dist[v.ff] + v.ss == dist[u]){
				poss[u] += poss[v.ff];
				if(poss[u] >= P)
					poss[u] -= P;
			}
		}
	}

}

vector<ll> distS, possS, distT, possT; 
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int S, T;
	int a, b, c;
	
	cin >> N >> M >> S >> T;

	for(int i = 0; i < M; i++){
		cin >> a >> b >> c;
		gr[a].push_back({b, c});
		gr[b].push_back({a, c});
	}

	shortest_path(S, distS, possS);
	shortest_path(T, distT, possT);

	ll ans = 0LL;
	for(int i = 1; i <= N; i++){
		if(distS[i] + distT[i] != distS[T]) continue;
		if(distS[i] == distT[i]) ans += ((possS[i] * possS[i]) %P ) * ((possT[i] * possT[i]) % P), ans %= P;

		for(auto &u : gr[i]){
			if(distS[u.ff] + u.ss != distS[i] || distT[i] + u.ss != distT[u.ff]) continue;

 			if(distT[i] < distS[i] && distS[u.ff] < distT[u.ff]){
 				/*
 				cout << i << " " << u.ff << " : " << distS[i] << " " << distT[u.ff] << " " << u.ss << endl;
 				cout << possS[i] << " " << possT[u.ff] << "\n"; */
				ans += ((possS[u.ff] * possS[u.ff]) %P ) * ((possT[i] * possT[i]) % P), ans %= P;
 			}
		}
	}
	ans = possS[T] * possT[S] - ans;
	ans %= P;
	ans += P;
	ans %= P;

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

Measured memory_bytes: 15188