akhauriyash/Code-Regression huggingface dataset:
import std.stdio, std.algorithm, std.conv;
void main()
{
    int[101] count;
    int max_;

    foreach(n; stdin.byLine().map!(to!int))
    {
        ++count[n];
        max_ = max(max_, count[n]);
    }
    foreach(i; 1..101)
    {
        if(count[i] == max_) i.writeln;
    }
}

Measured memory_bytes: 1052
L, R = map(int, input().split())

minimum=2019
z=0
for i in range(L, R+1):
    for j in range(i+1, R+1):
        tmp = (i*j)%2019
        if minimum>tmp:
            minimum = tmp
        if minimum==0:
            z=1
            break
    if z==1:
        break
    
print(minimum)

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

int main(){
  int X,Y;
  cin >> X >> Y;
  int m=0;
  int counter=0;
  for(int m=0;m<=X;m++){
    if(4*X-2*m==Y && X-m>=0){
      counter = counter+1;
    }
  }
  if(counter>0){
    cout << "Yes" <<endl;
  }
  else if(counter<=0){
    cout << "No" <<endl;
  }
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
  ll n,k;
  cin >>n>>k;
  string s;
  cin >>s;
  if(s[k-1]=='A') s[k-1]='a';
  else if(s[k-1]=='B') s[k-1]='b';
  else if(s[k-1]=='C') s[k-1]='c';
  cout <<s<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
static auto faster_iostream = []() { ios::sync_with_stdio(0); cin.tie(0); return 0; }();
typedef long long ll; typedef long double db;
const int N = 1e6 + 5, M = 1e9 + 7;

// #pragma GCC optimize ("trapv")

struct node {
  ll x, h;
  bool operator < (const node &b) const {
    return x < b.x;
  }
} a[N];

int main() {
  ll n, d, s;
  cin >> n >> d >> s;
  for (int i = 0; i < n; i++) {
    cin >> a[i].x >> a[i].h;
    a[i].h = a[i].h / s + (a[i].h % s > 0);
  }
  sort(a, a + n);
  for (int i = n - 1; i > 0; i--) {
    a[i].h -= a[i-1].h;
  }
  ll ans = 0, las = 0;
  for (int i = 0; i < n; i++) {
    las += a[i].h;
    if (las <= 0) continue;
    ll r = a[i].x + 2 * d;
    int b = lower_bound(a + i, a + n, node{r, 0}) - a;
    if (a[b].x == r) b++;
    ans += las;
    a[b].h += las;
    las = 0;
    // cout << i << ' ' << b << ' ' << ans << endl;
  }
  cout << ans << endl;
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#include <array>
using namespace std;
using ULL = unsigned long long;
using UL = unsigned;
using LL = long long;
#define rep(i, n) for(UL i = 0; i < (n); i++)

bool f(const pair<UL, UL> &l, const pair<UL, UL> &r) {
	return make_pair(~l.first, l.second) < make_pair(~r.first, r.second);
}

struct Problem {

	void Solve() {
		UL N; cin >> N;
		vector<pair<UL, UL>> A(N); rep(i, N) { cin >> A[i].first; A[i].second = i; }
		UL p = 0; rep(i, N) p = max(p, A[i].first);
		sort(A.begin(), A.end(), f);
		UL n = 0;
		UL m = N - 1;
		vector<ULL> ans(N);
		rep(i, N) {
			ans[m] += ULL(n) * (p - A[i].first);
			p = A[i].first;
			n++;
			m = min(m, A[i].second);
		}
		ans[0] += ULL(n) * p;
		rep(i, N) cout << ans[i] << endl;
	}


	Problem();
};
int main() {
	unique_ptr<Problem> p(new Problem());
	p->Solve();
	return 0;
}
Problem::Problem() {
	cout << fixed << setprecision(10);
}


Measured memory_bytes: 2688
#include <bits/stdc++.h> 
using namespace std; 
typedef long long int ll;
ll mo=1000000007;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t=1;
    //cin>>t;
    while(t)
    {
        ll n,d;
        cin>>n>>d;
        ll count=0;
        while(n){
            ll x,y;
            cin>>x>>y;
            ll num=x*x+y*y;
            if(num<=d*d)count++;
            n--;
        }
        cout<<count<<endl;
        
        t--;
    }
}

Measured memory_bytes: 3648
/*
 * 5:51:00
 */

#include<bits/stdc++.h>

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define EPS (1e-8)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

#define MAX_N 500

int n;
double radii[MAX_N],xs[MAX_N];

void compute() {
  xs[0] = radii[0];
  REP(i,1,n) {
    double maxi_x = 0;
    rep(j,i) {
      double tmp_x = -1;
      if( radii[i] == radii[j] ) tmp_x = xs[j] + radii[i] * 2.0;
      else {
	double r1 = radii[i], r2 = radii[j];
	double len_x = sqrt( pow(r1+r2,2.0) - pow(r1-r2,2.0) );
	tmp_x = xs[j] + len_x;
      }
      maxi_x = max(maxi_x,tmp_x);
    }
    xs[i] = maxi_x;
    if( !equals(0.0,xs[i]-radii[i]) && xs[i]-radii[i] < 0 ) {
      xs[i] += fabs(xs[i]-radii[i]);
    }
  }
  double maxi = 0;
  rep(i,n) maxi = max(maxi,xs[i]+radii[i]);
  printf("%.10f\n",maxi);
}

int main() {
  cin >> n;
  rep(i,n) cin >> radii[i];
  compute();
  return 0;
}

Measured memory_bytes: 1256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(ll i = n;i >= 0;--i)
#define FOR(i,m,n) for(ll i = m, i##_len=(n);i <i##_len; ++i)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
const int INF = 1e9;
const ll LLINF = 1e16;
 
ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}


int main(void)
{
    string s;
    cin >> s;
    if(s[2] == s[3] && s[4] == s[5]){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
long long a=0,b=0,c=0,d=0,m=0,n=0,p=0,q=0;

string x;
cin >> x;
for(int i=0;i<x.size();i++)
{
if(x.at(i)=='0')
a+=0;
if(x.at(i)=='1')
a+=1;
if(x.at(i)=='2')
a+=2;
if(x.at(i)=='3')
a+=3;
if(x.at(i)=='4')
a+=4;
if(x.at(i)=='5')
a+=5;
if(x.at(i)=='6')
a+=6;
if(x.at(i)=='7')
a+=7;
if(x.at(i)=='8')
a+=8;
if(x.at(i)=='9')
a+=9;
}
  if(a%9==0)
cout << "Yes";
  else
cout <<"No";
}

Measured memory_bytes: 3660
#include <stdio.h>
#include <math.h>

int main(void)
{
	int n, s[1010], sum, j = 0, i;
	double ave, dev[1010], bun;


	while (1)
	{
		scanf("%d", &n);
		if (n == 0)
			break;

		sum = 0;
		for (i = 0; i<n; i++)
		{
			scanf("%d", &s[i]);
			sum += s[i];
		}

		ave = (double)sum / (double)n;
		bun = 0.0;

		for (i = 0; i<n; i++)
			bun += pow(s[i] - ave, 2);

		dev[j++] = sqrt(bun / (double)n);
	}

	for (i = 0; i<j; i++)
	{
		printf("%f\n", dev[i]);
	}
	return 0;
}


Measured memory_bytes: 2112
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const int MOD = 998244353;
const ll INF = 1000000000000000000;


int main()
{
	int N;
	string S;
	cin >> N >> S;
	string T = S.substr(0, N / 2);
	if (T + T == S) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 3628
#include <stdio.h>

int main() {

	int K, A, B;
	
	scanf("%d", &K);
	scanf("%d %d", &A, &B);
	
	int M = B%K;
	int N = B-M;
	
	if (N>=A) {
		printf("OK\n");
	}
	else {
		printf("NG\n");
	}

    return 0;
}


Measured memory_bytes: 3148
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "set"
#include "functional"
#include "algorithm"
#include "math.h"
#include "utility"

using namespace std;

int a,b;
int ans;

int main() {
	cin >> a >> b;
	ans = abs(abs(a) - abs(b));
	if (a >= 0 && b >= 0) {
		if (a > b)ans += 2;
	}
	else if (a <= 0 && b <= 0) {
		if (a > b)ans += 2;
	}
	else ans++;
	if (a == 0 || b == 0) {
		ans = abs(a - b);
		if (a > b)ans++;
	}
	
	cout << ans << "\n";
	return 0;
}


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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = ((int)(n)-1); i >= 0; i--)
#define all(x) (x).begin(),(x).end()
 
using namespace std;
using ll = long long;
 
struct edge { int to, cost; };
 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> P;
 
const int INF = ~(1<<31);
const int MOD = 1e9+7;
const double EPS = 1e-10;
const double PI = acos(-1.0);
 
const int mx4[] = {0,1,0,-1};
const int my4[] = {1,0,-1,0};
const int mx8[] = {0,1,1,1,0,-1,-1,-1};
const int my8[] = {1,1,0,-1,-1,-1,0,1};

int main()
{
	int a,b;
	cin >> a >> b;
	cout << max(0,a-b*2) << endl;

	return 0;
}

Measured memory_bytes: 256
#define	_USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cctype>
#include <cstdlib>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cfloat>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <string>
#include <set>
#include <complex>
#include <utility>
#include <numeric>
#define  rep(i,n) for(int i=0;i<(n);i++)
#define  REP(i,a,n) for(int i=a;i<(n);i++)
#define  rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define  VI	vector<int>
#define	 VS vector<string>
#define  all(a) (a).begin(),(a).end()
#define  debug(x) cout<<#x<<": "<<x<<endl

using namespace std;
typedef long long int ll;
typedef string::const_iterator State;
typedef pair<int,int> P;
class ParseError {};
const ll INF=1LL<<50;
char fi[101][101];
int day[12]={31,28,31,30,31,30,31,31,30,31,30,31};
double EPS = 1e-14;
const int MAX_V=100;
const int MAX_N=100;
char o[3]={'+','-','*'};
#define md 1000003



int bow[353][353]={0};
double add(double a,double b){
	if(abs(a+b)<EPS*(abs(a)+abs(b)))
	return 0;
	return a+b;
}

/*struct P{
	double x,y;
	P(){}
		P(double x,double y):x(x),y(y){
		}
		P operator + (P p){
			return P(add(x,p.x),add(y,p.y));
		}
		P operator - (P p){
			return P(add(x,-p.x),add(y,-p.y));
		}
		P operator *(double d){
			return P(x*d,y*d);
		}
		double dot(P p){
			return add(x*p.x,y*p.y);
		}
		double det(P p){
			return add(x*p.y,-y*p.x);
		}
};

bool cmp_x(const P& p,const P& q){
	if(p.x!=q.x) return p.x<q.x;
	return p.y<q.y;
}

vector<P> convex_hull(P* ps, int n){
	sort(ps,ps+n,cmp_x);
	int k=0;
	vector<P> 	qs(n*2);
	
	rep(i,n){
		while(k>1&&(qs[k-1]-qs[k-2]).det(ps[i]-qs[k-1])<=0)
			k--;
		qs[k++]=ps[i];
	}
	for(int i=n-2,t=k;i>=0;i--){
		while(k>t&&(qs[k-1]-qs[k-2]).det(ps[i]-qs[k-1])<=0)
		k--;
		qs[k++]=ps[i];
	}
	qs.resize(k-1);
	return qs;
}

int n,m;
vector<double> p;
P ps[101];
*/
//char c[520][520];
long long mod=1000000007;
long long pow(ll i,ll j){
	ll tmp=1;
	while(j){
		if(j%2) tmp=tmp*i%mod;
		i=i*i%mod;
		j/=2;
	}
	return tmp;
}

int expression(State&);
int term(State&);
int factor(State&);
int number(State&);
int expression(State &begin){
	int ret = term(begin);
	
	for(;;){
		if(*begin == '+'){
			begin++;
			ret += term(begin);
		}
		else if(*begin == '-'){
			begin++;
			ret -= term(begin);
		}
		else
			break;
	}
	return ret;
}

int term(State &begin){
	int ret = factor(begin);
	
	for(;;){
		if(*begin=='*'){
			begin++;
			ret *= factor(begin);
		}
		else if(*begin=='/'){
			begin++;
			ret /= factor(begin);
		}
		else
			break;
	}
	return ret;
}

int factor(State &begin){
	int ret;
	if(*begin == '('){
		begin++;
		ret = expression(begin);
		begin++;
	}
	else
	ret = number(begin);
	
	return ret;

}

int number(State &begin){
	int ret =0;
	
	while(isdigit(*begin)){
		ret*=10;
		ret+=*begin - '0';
		begin++;
	}
	return ret;
}






int main(void){
	
	ll a,b;
	
	cin>>a>>b;
	
	if(a+b>=10)
		cout<<"error"<<endl;
	else
		cout<<a+b<<endl;
	



	
}

Measured memory_bytes: 256
#include <iostream>

int n, s;
//int num[10]={0,1,2,3,4,5,6,7,8,9};

int func(int de, int k, int sum){
	int res = 0;
	if(de == n){
		if(sum == s)return 1;
		return 0;
	}
	//if(sum > s || > n)return 0;
	for(int i = k; i < 10 && sum+i<=s; ++i){
		
		res += func(de + 1, i + 1, sum + i);
		//res += func(de, i + 1, sum);
	}
	return res;
}

int main(){
	while(std::cin >> n >> s, n + s){
		std::cout << func(0, 0, 0) << std::endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#coding:utf-8
n = int(input())
S = list(map(int, input().split()))
q = int(input())
T = list(map(int, input().split()))

def search_banpei(array, target, cnt):
    tmp = array[len(array)-1]
    array[len(array)-1] = target

    n = 0
    while array[n] != target:
        n += 1

    array[len(array)-1] = tmp
    if n < len(array) - 1 or target == tmp:
        cnt += 1
    return cnt        

def linear_search():  
    cnt = 0
    for t in T:
        for s in S:
            if t == s:
                cnt += 1
                break
    return cnt

def linear_banpei_search():
    cnt = 0
    for target in T:
        cnt = search_banpei(S, target, cnt)
    return cnt

cnt = linear_search()

print(cnt)



Measured memory_bytes: 6556
a,b,c=map(int, input().split())
k=int(input())
count=0
while(c<=b):
    count+=1
    c=c*2
while(b<=a):
    count+=1
    b=b*2
while(c<=b):
    count+=1
    c=c*2
if k>=count:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 9180
#include<stdio.h>
    #include<string.h>
    int main(void){

        int A,i;
    double B,C,D,E,N,M,x,y,j,cou=0,cou2,v[1000000],w[1000000],min_i,en=0.0;
        char S[100][100],W[100],s[10],X,Y;
    scanf("%d",&A);
    for(i=0;i<A;i++){
        scanf("%lf %s",&v[i],&S[i]);
        if(S[i][0]=='B'){
            en+=v[i]*380000.0;
        }else{
            en+=v[i];
        }
    }
    printf("%f",en);
    return 0;
    }

Measured memory_bytes: 128
#
import sys
import math
import numpy as np




n = int(input())
min_sum=9999999
for a in range(1,n):
    aa=a
    bb=n-a
    sumab = 0
    while aa > 0:
        sumab += (aa % 10)
        aa = aa // 10
    while bb > 0:
        sumab += (bb % 10)
        bb = bb // 10
    min_sum = min(min_sum,sumab)
print(min_sum)


Measured memory_bytes: 16044
#include <cstring>
#include <cstdio>
#include <iostream>
#include <vector>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <stack>
#include <cmath>
#include <queue>
using namespace std;
const int maxn=500000;
int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    if(a==b)
        cout<<c<<endl;
    else if(a==c)
        cout<<b<<endl;
    else
        cout<<a<<endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); i++)
#define REP(i, d, n) for(int i=(d); i<(n); i++)
typedef long long ll;
const int mod = 1e9 + 7;
int main() {

    int n;
    cin >> n;
    vector<int> p(n), q(n);
    rep(i, n){
        cin >> p[i];
    }
    rep(i, n){
        cin >> q[i];
    }
    
    vector<int> v(n);
    iota(v.begin(), v.end(), 1);

    int cnt = 0, a, b;
    do {
        cnt++;
        if(v == p){
            a = cnt;
        }
        if(v == q){
            b = cnt;
        }
    } while (next_permutation(v.begin(), v.end()));

    cout << abs(a-b) << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

#define N 50

int main() {
	static int aa[N], bb[N], cc[N], dd[N];
	int n, m, i, j, j_, min, x;

	scanf("%d%d", &n, &m);
	for (i = 0; i < n; i++)
		scanf("%d%d", &aa[i], &bb[i]);
	for (j = 0; j < m; j++)
		scanf("%d%d", &cc[j], &dd[j]);
	for (i = 0; i < n; i++) {
		min = 1000000000, j_ = -1;
		for (j = 0; j < m; j++)
			if (min > (x = abs(aa[i] - cc[j]) + abs(bb[i] - dd[j])))
				min = x, j_ = j;
		printf("%d\n", j_ + 1);
	}
	return 0;
}


Measured memory_bytes: 128
import math
p=int(input())
ll=["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
a=0
n=0
prevn=0

while n<1000000000000001:
  a+=1
  prevn=n
  n+=26**a
  if n>=p:
    break
    
p2=p-prevn-1

al=""
for i in range(a):
  s1=math.floor(p2/(26**(a-i-1)))
  al=al+ll[s1]
  p2=p2%26**(a-i-1)

print(al)

Measured memory_bytes: 9048
N = int(input())
A = [[0,0,0]]
for i in range(N):
  A.append(list(map(int, input().split())))

flag = True
for i in range(N):
  if not flag:
    break
  time = int(A[i+1][0]) - int(A[i][0])
  dist = abs(A[i+1][1] - A[i][1]) + abs(A[i+1][2] - A[i][2]) # x2-x1 + y2-y1
  if time < dist:
    flag = False
  elif time % 2 != dist % 2:
    flag = False

if flag:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 27184
/*  ex5_3
    takafumi_ueki*/
#include <stdio.h>
    int main(void){
        int i,j,length,width;
        int row[100]={0};
        int col[100]={0};
        char field[100][100];
        //縦と横の長さを受け取る
        scanf("%d %d",&length,&width);
        //'.'か'#'かを受け取る
        for(i=0;i<length;i++){
            for(j=0;j<width;j++){
                scanf(" %c",&field[i][j]);
            }
        }
        //列ごとに'.'が含まれているかどうかを調べる
        //もし含まれていたらrow[i]が1になる
        for(i=0;i<length;i++){
            for(j=0;j<width;j++){
                if(field[i][j]=='#'){
                    row[i]=1;
                    break;
                }
            }
        }
        //次に行ごとに'.'が含まれていないか調べる
        for(j=0;j<width;j++){
            for(i=0;i<length;i++){
                if(field[i][j]=='#'){
                    col[j]=1;
                    break;
                }
            }
        }
        //もし '.'がひとつでも含まれていたらその行、列は'#'と'.'で構成されているので、書き出すようにする
        for(i=0;i<length;i++){
            for(j=0;j<width;j++){
                if(row[i]==1&&col[j]==1){
                    printf("%c",field[i][j]);
                }
            }
            printf("\n");
        }
        return 0;
    }


Measured memory_bytes: 128
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
const int N=200005,md=1000000007;
int b,w,c[N],s1[N],s2[N],jc[N],rjc[N],inv[N],ipw2[N],i,j;
int main()
{
	scanf("%d%d",&w,&b);
	ipw2[0]=1,ipw2[1]=(md+1)/2;
	for(i=2;i<=b+w;++i)
		ipw2[i]=1ll*ipw2[i-1]*ipw2[1]%md;
	inv[1]=1;
	for(i=2;i<=b+w;++i)
		inv[i]=1ll*inv[md%i]*(md-md/i)%md;
	jc[0]=rjc[0]=1;
	for(i=1;i<=b+w;++i)
		jc[i]=1ll*jc[i-1]*i%md,rjc[i]=1ll*rjc[i-1]*inv[i]%md;
	for(i=1;i<=b;++i)
	{
		j=1ll*jc[b-i+w-1]*rjc[b-i]%md*rjc[w-1]%md*ipw2[b-i+w]%md;
		s1[b+w-i-1]=(s1[b+w-i-1]+1ll*j*(w-1)%md*inv[b-i+w-1]%md)%md;
		c[b+w-i]=(c[b+w-i]+j)%md;
	}
	for(i=1;i<=w;++i)
	{
		j=1ll*jc[w-i+b-1]*rjc[w-i]%md*rjc[b-1]%md*ipw2[w-i+b]%md;
		s1[b+w-i-1]=(s1[b+w-i-1]+1ll*j*(w-i)%md*inv[w-i+b-1]%md)%md;
		s2[b+w-i+1]=(s2[b+w-i+1]+j)%md;
	}
	for(i=1;i<=b+w;++i)
	{
		s2[i]=(s2[i]+s2[i-1])%md;
		c[i]=(c[i]+s2[i])%md;
	}
	for(i=b+w;i>=1;--i)
	{
		s1[i]=(s1[i]+s1[i+1])%md;
		c[i]=(c[i]+s1[i])%md;
	}
	for(i=1;i<=b+w;++i)
		printf("%d\n",c[i]);
	return 0;
}


Measured memory_bytes: 7552
#!/usr/bin/env python3
import sys


def solve(A: int, B: int, K: int):
    if (A<K):
        print(0,max(0,B+A-K))
    else:
        print(A-K,B)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    solve(A, B, K)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <stdio.h>

int main()
{
    int a,b,c,d;
    scanf("%d%d%d%d",&a,&b,&c,&d);
    for(int i=0;;i++)
    {
        c-=b;
        if(c<=0)
        {
            printf("Yes\n");
            return 0;
        }
        a-=d;
        if(a<=0){
            printf("No\n");
            return 0;
        }
    }
}

Measured memory_bytes: 1660
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
using namespace std;
#define all(c) begin(c), end(c)
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)

const int MOD = 1e9 + 7;
string A, B, C;
int a[55], b[55], c[55];

int main() {
    while (cin >> A >> B >> C && A != "0") {
        reverse(all(A));
        reverse(all(B));
        reverse(all(C));
        int n = A.size();
        rep(i,n){
            a[i] = isdigit(A[i]) ? A[i] - '0' : -1;
            b[i] = isdigit(B[i]) ? B[i] - '0' : -1;
            c[i] = isdigit(C[i]) ? C[i] - '0' : -1;
        }
        
        int dp[55][2] = {};
        dp[0][0] = 1;
        rep(i, n)rep(j, 2)rep(ia, 10)rep(ib, 10)rep(ic, 10) {
            if (a[i] != -1 && ia != a[i]) continue;
            if (b[i] != -1 && ib != b[i]) continue;
            if (c[i] != -1 && ic != c[i]) continue;
            if (i == n - 1 && (ia == 0 || ib == 0 || ic == 0)) continue;
            int dig = ia + ib + j;
            if (dig % 10 != ic) continue;
            (dp[i + 1][dig >= 10] += dp[i][j]) %= MOD;
        }
        cout << dp[n][0] << endl;
    }
}

Measured memory_bytes: 3000
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<ll,ll>
#define vii vector<pii>
vii a[100005],b[100005];
ll arr[100005],ans[100005];
//ll a[100005];
//ll b[100005];
bool vis[100005];
ll dis1[100005],dis2[100005];
int main(){
priority_queue<pii,vii,greater<pii>> q;
int n,m,s,t;
cin>>n>>m>>s>>t;
for(int i=1;i<=n;i++){
	vis[i]=0;
	dis1[i]=1e18;
	dis2[i]=1e18;
}
while(m--){
	int u,v;
	ll c,d;
	cin>>u>>v>>c>>d;
	a[u].push_back(make_pair(c,v));
	a[v].push_back(make_pair(c,u));
	b[u].push_back(make_pair(d,v));
	b[v].push_back(make_pair(d,u));
}
//1
dis1[s]=0;
q.push(make_pair(0,s));
while(!q.empty()){
	pii tmp=q.top();
	int u=tmp.second;
	q.pop();
	if(vis[u])
	continue;
	vis[u]=1;
	for(int i=0;i<a[u].size();i++){
		int v=a[u][i].second;
		ll e=a[u][i].first;
		if(dis1[u]+e<dis1[v]){
			dis1[v]=dis1[u]+e;
			q.push(make_pair(dis1[v],v));
		}
	}
}
for(int i=1;i<=n;i++)
vis[i]=0;
dis2[t]=0;
q.push(make_pair(0,t));
while(!q.empty()){
	pii tmp=q.top();
	int u=tmp.second;
	q.pop();
	if(vis[u])
	continue;
	vis[u]=1;
	for(int i=0;i<b[u].size();i++){
		int v=b[u][i].second;
		ll e=b[u][i].first;
		if(dis2[u]+e<dis2[v]){
			dis2[v]=dis2[u]+e;
			q.push(make_pair(dis2[v],v));
		}
	}
}
for(int i=1;i<=n;i++){
	arr[i]=dis1[i]+dis2[i];
}
ans[n]=arr[n];
for(int i=n-1;i>0;i--){
	ans[i]=min(ans[i+1],arr[i]);
}
ll y=1e15;
for(int i=1;i<=n;i++){
	cout<<y-ans[i]<<endl;
}



}

Measured memory_bytes: 20600
//#pragma GCC target("avx2")
//#pragma GCC optimize("O3")
   
//#include <x86intrin.h>
#include <bits/stdc++.h>   
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace __gnu_pbds;
using namespace std;

template<typename T> using ordered_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
     
#define F first
#define S second           
#define lb lower_bound               
#define ub upper_bound
#define pb push_back
#define pf push_front    
#define ppb pop_back
#define mp make_pair                                     
#define bpp __builtin_popcountll                                                                                        
#define sqr(x) ((x) * (x)) 
#define al 0x3F3F3F3F
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define in insert
#define ppf pop_front
#define endl '\n'
//#define int long long
 
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
 
const int mod = (int)1e9 + 7;
const int N = (int)3e5 + 123;
const ll inf = (ll)1e18 + 1;

const double pi = acos (-1.0);
const double eps = 1e-7;                  
const int dx[] = {0, 0, 1, 0, -1};
const int dy[] = {0, 1, 0, -1, 0};

int n, m, d[N][3], s, t;
queue <int> q;
vector <int> g[N];

inline void boost () {                    
   ios_base :: sync_with_stdio (NULL);
   cin.tie (NULL), cout.tie (NULL);          
}                                                     

inline void Solve () {
   cin >> n >> m;
   for (int i = 1; i <= m; i ++) {
      int x, y;
      cin >> x >> y;
      g[x].pb (y);
   }
   for (int i = 1; i <= n; i ++)
      for (int j = 0; j < 3; j ++)
         d[i][j] = mod;
   cin >> s >> t;
   d[s][0] = 0;
   q.push (s);
   while (sz (q)) {
      int v = q.front ();
      q.pop ();
      for (int ost = 0; ost < 3; ost ++) {
         int nxt = (ost + 1) % 3;
         for (auto to : g[v]) {    
            if (d[to][nxt] > d[v][ost] + 1) {
               d[to][nxt] = d[v][ost] + 1;
               q.push (to);
            }
         }
      }
   }
   if (d[t][0] == mod) cout << -1, exit (0);
   cout << d[t][0] / 3;
}

main () {                                       
// freopen (".in", "r", stdin);    
// freopen (".out", "w", stdout);              
   boost ();
   int tt = 1;
   //cin >> tt;   
   while (tt --) {
      Solve ();
   }                                               
   return 0;      
}
                          

Measured memory_bytes: 13568
#define DIN freopen("input.txt","r",stdin);
#define DOUT freopen("output.txt","w",stdout);
#include <bits/stdc++.h>
#include <cstdio>
#define mem(a,b) memset(a,b,sizeof(a))
#define REP(i,a,b) for(int i=(a);i<=(int)(b);i++)
#define REP_(i,a,b) for(int i=(a);i>=(b);i--)
#define pb push_back
using namespace std;
typedef long long LL;
typedef std::vector<int> VI;
typedef std::pair<int,int> P;
int read()
{
    int x=0,flag=1; char c=getchar();
    while((c>'9' || c<'0') && c!='-') c=getchar();
    if(c=='-') flag=0,c=getchar();
    while(c<='9' && c>='0') {x=(x<<3)+(x<<1)+c-'0';c=getchar();}
    return flag?x:-x;
}

const LL M=1e9+7;
const int maxn=2e5+5;
LL A[maxn];

int main()
{
    int n=read();
    REP(i,1,n) A[i]=A[i-1]+read();
    LL ans=0;
    for(int i=1;i<n;i++)
    {
        ans=(ans+(A[n]-A[i])%M*(A[i]-A[i-1]))%M;
    }
    cout<<ans;

    return 0;
}


Measured memory_bytes: 5152
def hantei(array):
  for i in range(3):
    if array[i][0] and array[i][1] and array[i][2]:
      return True
    
  for i in range(3):
    if array[0][i] and array[1][i] and array[2][i]:
      return True
    
  if array[0][0] and array[1][1] and array[2][2]:
    return True
  
  if array[2][0] and array[1][1] and array[0][2]:
    return True
  
  return False

bingo = []
array = [[False for i in range(3)] for j in range(3)]

for i in range(3):
  tmp = list(map(int, input().split()))
  bingo.append(tmp)

n = int(input())

for i in range(n):
  b = int(input())
  
  for j in range(3):
    for k in range(3):
      if b == bingo[j][k]:
        array[j][k] = True
        
if hantei(array):
  print('Yes')
else:
  print('No')


  
  

Measured memory_bytes: 3192
N, K = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]

X = 0
for i in range(42, -1, -1):
    if X | (1 << i) > K:
        continue
    cnt1, cnt0 = 0, 0
    for a in A:
        if a & (1 << i) == 0:
            cnt0 += 1
        else:
            cnt1 += 1
    if cnt0 > cnt1:
        X |= (1 << i)

ans = 0
for a in A:
    ans += (X ^ a)

print(ans)


Measured memory_bytes: 14620
import java.util.Scanner

object Main {
  def main(args: Array[String]): Unit = {
    val sc = new Scanner(System.in)
    val s = sc.next().toCharArray
    
    val one = s.count(_ == '1')
    val zero = s.count(_ == '0')
    
    println(math.min(one, zero) * 2)
  }
  
  def printArray[T](arr: Array[T]): Unit = {
    for (i <- arr.indices) {
      print(s"${arr(i)} ")
    }
    println()
  }
}

Measured memory_bytes: 29520
#pragma GCC optimize("O2")

#include <bits/stdc++.h>
#ifdef DEBUG
    #include "debug.hpp"
#endif

using namespace std;

#define all(c) (c).begin(), (c).end()
#define traverse(c, it) for(auto it = (c).begin(); it != (c).end(); it++)
#define rep(i, N) for(int i = 0; i < (N); i++)
#define rep1(i, N) for(int i = 1; i <= (N); i++)
#define rep2(i, s, e) for(int i = (s); i <= (e); i++)
#define rep3(i, s, e, d) for(int i = (s); (d) >= 0 ? i <= (e) : i >= (e); i += (d))
#define pb push_back


#ifdef DEBUG
    #define debug(x...) {dbg::depth++; string dbg_vals = dbg::to_string(x); dbg::depth--; dbg::fprint(__func__, __LINE__, #x, dbg_vals);}
    #define light_debug(x) {dbg::light = 1; dbg::dout << __func__ << ":" << __LINE__ << "  " << #x << " = " << x << endl; dbg::light = 0;}
#else
    #define debug(x...)
    #define light_debug(x) 
#endif

template<typename T>
T& ckmin(T& a, T b){ return a = a > b ? b : a; }

template<typename T>
T& ckmax(T& a, T b){ return a = a < b ? b : a; }

using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;

namespace ioUtils {

    char vector_delimiter = ' ';

    template<typename T>
    istream& operator >>(istream&, vector<T>&);

    template<typename... Ts>
    istream& operator >>(istream& is, pair<Ts...>& p){
        is >> p.first >> p.second;
        return is;
    }

    template<typename T> 
    istream& operator >>(istream& is, vector<T>& v){
        for(auto& e : v) is >> e;
	       return is;
    }

    template<typename T>
    ostream& operator <<(ostream&, vector<T>&);

    template<typename... Ts>
    ostream& operator <<(ostream& os, pair<Ts...>& p){
        os << p.first << " " << p.second;
        return os;
    }

    template<typename T>
    ostream& operator <<(ostream& os, vector<T>& v){
        for(auto&& e : v) os << e << vector_delimiter;
        return os;   
    }   
}

using namespace ioUtils;


vector<ll> a; 
ll dp[400][401];

ll rec(int s, int e){
	if(e - s <= 1) return 0;
	if(dp[s][e]) return dp[s][e];
	ll ans = -1;
	ll total = accumulate(a.begin() + s, a.begin() + e, 0LL);
	rep2(m, s + 1, e - 1){
		ll l = rec(s, m), r = rec(m, e);
		if(m == s + 1) ans = l + r + total;
		else ckmin(ans, l + r + total);
	}
	return dp[s][e] = ans;
}


signed main(){

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

    #ifdef DEBUG
        freopen("debug", "w", stderr);
    #endif
    	
    int n;
    cin >> n;
    a.resize(n);
    cin >> a;

    cout << rec(0, n) << '\n';	
    #ifdef DEBUG
        dbg::dout << "\nExecution time: " << clock() << "ms\n";
    #endif

    return 0;
}


Measured memory_bytes: 4924
#include "bits/stdc++.h"
using namespace std;
using ll = long long;

template <typename T>
void print_vec(const vector<T>& v, bool is_reverse=false, ll num=0){
  if(num == 0) num = (ll)v.size();
  if(is_reverse) for(ll i=num-1; i>=0; i--){ cout<<v[i]; if(i!=0) cout<<" ";}
  else for(ll i=0; i<num; i++){ cout<<v[i]; if(i!=num-1) cout<<" ";}
  cout << endl;
}

template <typename T>
void print_pairvec(const vector<T> &v, ll num=0){
  if(num == 0) num = (ll)v.size();
  cout << endl;
  for(ll i=0; i<num; i++){ cout << v[i].first << " " << v[i].second << endl;}
}

template <typename T>
void print_vec2(const vector<vector<T>>& v){
  cout << endl; cout << "       ";
  for(ll i=0; i<v[0].size(); i++) cout << i << "   "; 
  cout << endl;
	for(ll i=0; i<v.size(); i++){
		cout << "i=" << i << ":   ";
		for(ll j=0; j<v[i].size(); j++){
			if(v[i][j] == 0) cout << "\x1B[0m" << v[i][j] << "   ";
      else cout << "\x1B[31m" << v[i][j] << "   ";//https://stackoverrun.com/ja/q/12618775
		}
		cout << "\x1B[0m" << endl;
	}
}

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

  for(ll i=0; i<n; i++) a[i] -= i+1;
  sort(a.begin(), a.end());
  ll mid = n / 2;
  ll b = a[mid];
  ll ans = 0;
  for(ll i=0; i<n; i++) ans += abs(a[i] - b);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4752
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {

    void run() {
        Scanner sc = new Scanner(System.in);
        while (true) {
            // さらに、 m は 2 以上 1000 以下の整数、 n は 1 以上 10000 以下の 整数とし、s
            // は数字、Fizz、Buzz、FizzBuzz、あるいは間違った発言を示すその他の文字列です。
            // Input
            //
            // 複数のデータセットの並びが入力として与えられます。入力の終わりはゼロふたつの行で示されます。 各データセットは以下のとおりです。
            //
            // 1 行目 プレイヤー数 m 発言回数 n (整数 整数;半角空白区切り)
            // 2 行目 第 1 の発言 s1 (半角英数字)
            // 3 行目 第 2 の発言 s2 (半角英数字)
            // :
            // n+1 行目 第 n の発言 sn (半角英数字)
            int m = sc.nextInt();
            int n = sc.nextInt();
            if (n == 0 && m == 0)
                break;
            List<Integer> p = new ArrayList<Integer>();
            for (int i = 1; i <= m; i++) {
                p.add(i);
            }
            String fb[] = new String[n + 1];
            for (int i = 1; i <= n; i++) {
                if (i % 15 == 0) {
                    fb[i] = "FizzBuzz";
                } else if (i % 5 == 0) {
                    fb[i] = "Buzz";
                } else if (i % 3 == 0) {
                    fb[i] = "Fizz";
                } else
                    fb[i] = "" + i;
            }
            int id = 0;
            for (int i = 1; i <= n; i++) {
                if (sc.next().equals(fb[i])) {
                    id = (id + 1) % p.size();
                    continue;
                }
                p.remove(id);
                if (p.size() == 1) {
                    for (int j = i + 1; j <= n; j++) {
                        sc.next();
                    }
                    break;
                }
                id %= p.size();
            }
            boolean init = true;
            for (int i = 0; i < p.size(); i++) {
                if (init)
                    init = false;
                else
                    System.out.print(" ");
                System.out.print(p.get(i));
            }
            System.out.println();
        }
    }

    public static void main(String[] args) throws Exception {
        new Main().run();
    }
}

Measured memory_bytes: 16000
#include <algorithm>
#include <array>
#include <cmath>
#include <iostream>
#include <utility>
#include <vector>

#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(a) (a).begin(), (a).end()

#define INF 1000000000

using namespace std;

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

    int fail1 = 0;
    // try 010101...
    REP(i, str.size()) {
        int v = i % 2;

        if (str[i] != ('0' + v)) fail1++;
    }

    int fail2 = 0;
    REP(i, str.size()) {
        int v = (i + 1) % 2;

        if (str[i] != ('0' + v)) fail2++;
    }

    cout << min(fail1, fail2) << endl;

    return 0;
}


Measured memory_bytes: 512
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
    int N;
    long long int A,B;
    cin>>N;
    for(int i=0;i<N;i++){
        int a,b;
        cin>>a>>b;
        if(i==0){
            A=a;
            B=b;
        }
        else{
            if(fabs((double)a/(double)b-(double)A/(double)B)<0.00001){

            }
            else if((double)A/(double)B>(double)a/(double)b){
                while(A%a){
                    A++;
                }
                B=A/a*b;
            }
            else{
                while(B%b){
                    B++;
                }
                A=B/b*a;
            }
        }
    }
    printf("%lld\n",A+B);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using pii=pair<int,int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define INF 1e9
#define EPS 1e-9
#define MOD (1e9+7)


int main(){
	int m,n;
	while(cin>>m>>n,n){
		vector<pii> C1(m),C2(n);
		vector<vector<double>> yp(201),zp(201);
		vector<double> y(201,0.0),z(201,0.0);
		rep(i,m){int a,b; cin>>a>>b; C1[i]={a+100,b+100};}	//xy
		rep(i,n){int a,b; cin>>a>>b; C2[i]={a+100,b+100};}	//xz
		int limit[4]={200,0,200,0};
		rep(i,m){
			limit[0]=min(limit[0],C1[i].first);
			limit[1]=max(limit[1],C1[i].first);
			int j=(i+1)%m;
			auto xr=make_pair(C1[i].first,C1[j].first);
			auto yr=make_pair(C1[i].second,C1[j].second);
			if(xr.second<xr.first){
				swap(xr.second,xr.first);
				swap(yr.second,yr.first);
			}
			int diff=xr.second-xr.first;
			if(diff==0){
				y[xr.first]=fabs(yr.second-yr.first);
			}
			rep(x,diff){
				double l=yr.second-yr.first;
				l/=diff;
				yp[x+xr.first].push_back(yr.first+l*x);
			}
		}
		rep(i,n){
			limit[2]=min(limit[2],C2[i].first);
			limit[3]=max(limit[3],C2[i].first);
			int j=(i+1)%n;
			auto xr=make_pair(C2[i].first,C2[j].first);
			auto zr=make_pair(C2[i].second,C2[j].second);
			if(xr.second<xr.first){
				swap(xr.second,xr.first);
				swap(zr.second,zr.first);
			}
			int diff=xr.second-xr.first;
			if(diff==0){
				z[xr.first]=fabs(zr.second-zr.first);
			}
			rep(x,diff){
				double l=zr.second-zr.first;
				l/=diff;
				zp[x+xr.first].push_back(zr.first+l*x);
			}
		}
		rep(i,201){
			if(yp[i].size()!=0) y[i]=fabs(yp[i][0]-yp[i][1]);
			if(zp[i].size()!=0) z[i]=fabs(zp[i][0]-zp[i][1]);
		}
		double ans=0.0;
		//for(auto i:limit)cout<<i<<",";cout<<endl;
		limit[1]--; limit[3]--;
		for(int x=max(limit[0],limit[2]);x<=min(limit[1],limit[3]);x++){
			double f1=y[x]*z[x+1];
			double f2=y[x+1]*z[x];
			double f3=2*(y[x]*z[x]+y[x+1]*z[x+1]);
			ans+=(f1+f2+f3)/6;
		}
		cout.precision(6);
		cout<<fixed<<ans<<endl;
	}
	return 0;
}



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

using namespace std;

int main() {
    int n5 = 0, n7 = 0;
    for(int i = 0; i < 3; i++) {
        int temp;
        cin>>temp;
        temp == 5 ? n5++ : temp == 7 ? n7++ : n7 += 0;
    }
    if(n5 == 2 && n7 == 1) {
        cout<<"YES"<<endl;
    }
    else {
        cout<<"NO"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
using namespace std;
int main(){
  int n;
  cin>>n;
  if(n%2==0) cout<<0.5<<endl;
  else{
    int m=(n+1)/2;
    cout<<fixed<<setprecision(10)<<(double)m/n<<endl;
  }
}


Measured memory_bytes: 256
#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 n,m;
  cin >> n >> m;
   vector<vector<int>>data(m,vector<int>(2));
  rep(i,m){
    rep(j,2) cin >> data[i][j];
  }
  int ans = 1001;
  if( n == 1){
    for(int k=0; k<10; k++){
      bool b =1;
      rep(i,m){
        rep(j,2){
         if( data[i][0] == 1) {
           int l = k;
           if( l != data[i][1]) b =0;
         }
        }
      }
      if( b == 1) ans = min (ans , k);
    }
  }
  if( n == 2){
    for(int k=10; k<100; k++ ){
      bool b = 1;
      rep(i,m){
        rep(j,2){
          if( data[i][0] == 1){
            int l = k/10;
            if( l != data[i][1]) b =0; 
          }
          if( data[i][0] == 2){
            int l = k%10;
            if( l != data[i][1]) b =0;
          }
        }
      }
      if( b == 1) ans = min (ans , k);
    }
  }
  if( n == 3){
    for(int k=100; k<1000; k++ ){
      bool b = 1;
      rep(i,m){
        rep(j,2){
          if( data[i][0] == 1){
            int l = k/100;
            if( l != data[i][1]) b =0;
          }
          if( data[i][0] == 2){
            int l = (k%100)/10;
            if( l != data[i][1]) b =0;
          }
          if( data[i][0] == 3){
            int l = k%10;
            if( l != data[i][1]) b =0;
          }
        }
      }
      if( b == 1) ans =min ( ans ,k);
    }
  }
  if ( ans == 1001) ans = -1;
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, b) for(ll i = ll(a); i < ll(b); i++)
#define rer(i, a, b) for(ll i = ll(a) - 1; i >= ll(b); i--)
#define sz(v) (int)(v).size()
#define pb push_back
#define sc second
#define fr first
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
using namespace std;
typedef long long int ll;
typedef pair <int, int> P;

const ll MOD=1000000007;
ll N;
vector<ll> A,B;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>N;
    A.resize(N); B.resize(N);
    bool t=false;
    ll res=-1;
    ll sum=0;
    rep(i,0,N){
        cin>>A[i]>>B[i];
        sum+=A[i];
        if(A[i]>B[i]){
            t=true;
            if(res==-1){
                res=i;
            }
            else if(B[i]<B[res]){
                res=i;
            }
        }
    }
    if(t) cout <<sum-B[res]<<"\n";
    else cout <<0<<"\n";
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define o(a) cout << a << endl
// #define int long long
#define fi first
#define se second
using namespace std;
typedef pair<int, int> P;

signed main(){
    int n;
    while(1){
        cin >> n;
        if(n == 0) break;
        int h, m, s, hh, mm, ss;
        int d[24 * 3600 + 100] = {};
        rep(i, 0, n){
            scanf("%d:%d:%d %d:%d:%d", &h, &m, &s, &hh, &mm, &ss);
            int st = h * 3600 + m * 60 + s;
            int ed = hh * 3600 + mm * 60 + ss;
            d[st]++; d[ed]--;
        }
        int MAX = 0;
        rep(i, 1, 24 * 3600 + 10){
            d[i] += d[i - 1];
            MAX = max(MAX, d[i]);
        }
        cout << MAX << endl;
    }
}

Measured memory_bytes: 3396
#include <bits/stdc++.h>
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define RFOR(i,n1,n2) for(ll i=((ll)(n1)-1);i>=(ll)(n2);i--)
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
template<typename T1, typename T2> inline bool chmin(T1& a, T2 b) { if (a > b) { a = b; return 1; }return 0; }
template<typename T1, typename T2> inline bool chmax(T1& a, T2 b) { if (a < b) { a = b; return 1; }return 0; }
template<class Type>struct is_vector : std::false_type {};
template<class ValueType, class Alloc>struct is_vector<std::vector<ValueType, Alloc>> : std::true_type {};
template <typename T> inline ostream& operator << (ostream& out, const vector<T>& v) {
	if (v.empty())return out;
	constexpr bool is_vector_v = is_vector<T>::value;
	if (is_vector_v)for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? "\n" : "");
	else for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? " " : "");
	return out;
}
inline void put() {}
template<class T> inline void put(const T& first) { std::cout << first; printf("\n"); }
template<class T, class... N> inline void put(const T& first, const N& ... rest) { std::cout << first; printf(" "); put(rest...); }
inline void putn() {}
template<class T, class... N> inline void putn(const T& first, const N& ... rest) { std::cout << first; printf("\n"); putn(rest...); }

int main() {
	int k,x;
	cin >> k >> x;
	FOR(i,-k+1, k) {
		cout << x + i << " ";
	}
	put("");
	return 0;
}

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

int main(){
  int N, Y, A, B, C, flag;
  cin>>N>>Y;
  flag = 0;
  for(A=0; A<=N; A++)
    for(B=0; B<=N-A; B++) {
      C = N-A-B;
      if(Y == 10000*A+5000*B+1000*C) {
        cout<<A<<' '<<B<<' '<<C<<endl;
        return 0;
      }
    }
  cout<<-1<<' '<<-1<<' '<<-1<<endl;
  return 0;
}

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

int main() {
  ll A,B;
  cin >> A >> B;
  for(ll i=1;i<=10000;i++){
    if(A==i*8/100 && B==i*10/100){
      cout << i << endl;
      return 0;
    }
  }
  cout << -1 << endl;
  return 0;
}

Measured memory_bytes: 3652
A11,A12,A13 = map(int, input().split())
A21,A22,A23 = map(int, input().split())
A31,A32,A33 = map(int, input().split())
N = int(input())
b = []
for i in range(N):
    b.append(int(input()))

def check_bingo(bingo_card):
    bingo_cnt = 0
    ret = False
    bingo_list = [[0, 1, 2],
                  [3, 4, 5],
                  [6, 7, 8],
                  [0, 3, 6],
                  [1, 4, 5],
                  [2, 5, 8],
                  [0, 4, 8],
                  [2, 4, 6],]    

    for i in range(len(bingo_list)):
        for j in range(len(bingo_list[i])):
            if bingo_card[bingo_list[i][j]] == 0:
                bingo_cnt +=1
            else:
                break
        
        if bingo_cnt == 3:
            ret = True
            break
        else:
            bingo_cnt = 0
    
    return(ret)

def main():
    bingo_card = [A11,A12,A13,A21,A22,A23,A31,A32,A33]
    cnt = 0
    for i in range(N):
        for j in range(len(bingo_card)):
            if b[i] == bingo_card[j]:
                bingo_card[j] = 0
                cnt += 1
                break
            else:
                pass

    if cnt <= 2:
        print('No')                
        
    elif 3 <= cnt <= 6:
        judge_bingo = check_bingo(bingo_card)
        if judge_bingo == True:
            print('Yes')
        else:
            print('No')
    else:
        print('Yes')                
    
if __name__ == "__main__":
    main()



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

#define ll long long
#define INF 99999999
#define INF_LL 1LL << 60
#define MOD (ll)1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, a, n) for(int i = a; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

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 put_double(double obj){printf("%.12f\n",obj);};

template < typename T > std::string to_string( const T& n )
{
    std::ostringstream stm ;
    stm << n ;
    return stm.str() ;
}

int main()
{
    ll H,W;
    cin >> H >> W;

    if( H == 1 || W == 1 ) cout << 1 << endl;
    else if( H%2 != 0 && W%2 != 0 ) cout << H*W/2+1 << endl;
    else cout << H*W/2 << endl;
}


Measured memory_bytes: 256
#if !defined(__clang__) && defined(__GNUC__)
#include <bits/stdc++.h>
#else
#include <cstdlib>
#include <climits>
#include <iostream>
#include <cstdint>
#include <vector>
#include <string>
#include <complex>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#endif //  !defined(__clang__) && defined(__GNUG__)
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/math/common_factor_rt.hpp>

using namespace std;

int main()
{
    int64_t N, K;
    std::cin >> N >> K;

    std::string D;
    D = "[";
    for (size_t i = 0; i < K; ++i) {
        char t;
        std::cin >> t;
        D += t;
    }
    D += "]";

    cerr << D << endl;

    std::regex re(D);
    for (;;) {
        auto s = boost::lexical_cast<std::string>(N);
        if (!std::regex_search(s, re)) {
            std::cout << s << std::endl;
            return 0;
        }
        N++;
    }


    return 0;
}


Measured memory_bytes: 256
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getInts(N int) []int {
	ret := make([]int, N)
	for i := 0; i < N; i++ {
		ret[i] = getInt()
	}
	return ret
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

func main() {
	sc.Split(bufio.ScanWords)
	A, B := getInt(), getInt()
	out((A + B) % 24)
}


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

using ll = long long;

const int INF = 1001001001;
const ll INF_LL = 1001001001001001001LL;

int main(void){
  int n; cin >> n;
  set<int> a;
  rep(i,n){
    int k; cin >> k;
    a.insert(k);
  }
  
  int cost = 0;
  auto x = a.begin();
  auto y = a.begin();
  y++;
  while(y!=a.end()){    
    cost+=(*y)-(*x);
    x++;
    y++;
  }

  cout << cost << endl;
  
  return 0;
}


Measured memory_bytes: 3620