akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define MAXN 505

int N;

double R[MAXN], ans, cyc[MAXN];

void work() {
	for (int i = 1; i <= N; i ++) {
		scanf("%lf", &R[i]);
	}
	cyc[1] = R[1];
	ans = cyc[1] + R[1];
	for (int i = 2; i <= N; i ++) {
		double res = 0.0;
		for (int j = 1; j < i; j ++) {
			double tmp = cyc[j] + sqrt((R[i] + R[j]) * (R[i] + R[j]) - (R[i] - R[j]) * (R[i] - R[j]));
			tmp = max(tmp, R[i]);
			res = max(res, tmp);
		}
		cyc[i] = res;
		ans = max(ans, cyc[i] + R[i]);
	}
	printf("%.12lf\n", ans);
}

int main() {
	while (scanf("%d", &N) != EOF) {
		work();
	}
	return 0;
}

Measured memory_bytes: 1252
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
const double EPS = 1e-8;

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    map<string, int> mp;
    rep(i, n) {
        string s;
        cin >> s;
        mp[s]++;
    }
    int ma = 0;
    vector<string> ans;
    for(auto&& p: mp) {
        if(p.se > ma) {
            ma = p.se;
            ans.clear();
            ans.pb(p.fi);
        }
        else if(p.se == ma) {
            ans.pb(p.fi);
        }
    }
    rep(i, ans.size()) {
        cout << ans[i] << '\n';
    }
    return 0;
}

Measured memory_bytes: 25584
import heapq
N,M=map(int,input().split())
AB=[list(map(int,input().split())) for _ in range(N)]

AB.sort(reverse=True)
works=[]
heapq.heapify(works)
ans=0
for i in range(1,M+1):
  day=M-i
  latest=i
  while AB and AB[-1][0]<=latest:
    a,b=AB.pop(-1)
    heapq.heappush(works,-b)
  if not works:
    continue
  ans-=heapq.heappop(works)

print(ans)


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

using namespace std;

typedef long long ll;

int main(){
    ll x,k,d;cin >> x>>k>>d;
    x=abs(x);

    ll piece=min(k,x/d);
    k-=piece;
    x-=piece*d;

    if(k%2==0){
        cout << x<<endl;
    }else{
        cout << d-x<<endl;
    }
}



Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define N 100
#define WHITE 0
#define GRAY 1
#define BLACK 2

int n, M[N][N];
int color[N], d[N], f[N], tt;
int nt[N];

int next(int u) {
  for (int v = nt[u]; v < n; v++) {
    nt[u] = v + 1;
    if (M[u][v]) return v;
  }
  return -1;
}

void dfs_visit(int r) {
  for (int i = 0; i < n; i++) nt[i] = 0;

  stack<int> S;
  S.push(r);
  color[r] = GRAY;
  d[r] = ++tt;

  while ( !S.empty() ) {
    int u = S.top();
    int v = next(u);
    if (v != -1) {
      if (color[v] == WHITE) {
        color[v] = GRAY;
        d[v] = ++tt;
        S.push(v);
      }
    } else {
      S.pop();
      color[u] = BLACK;
      f[u] = ++tt;
    }
  }
}

void dfs() {
  for (int i = 0; i < n; i++) {
    color[i] = WHITE;
    nt[i] = 0;
  }
  tt = 0;

  for (int u = 0; u < n; u++) {
    if (color[u] == WHITE) dfs_visit(u);
  }
  for (int i = 0; i < n; i++) {
    cout << i+1 << " " << d[i] << " " << f[i] << endl;
  }
}

int main() {
  int u, k, v;

  cin >> n;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) M[i][j] = 0;
  }

  for (int i = 0; i < n; i++) {
    cin >> u >> k;
    u--;
    for (int j = 0; j < k; j++) {
      cin >> v;
      v--;
      M[u][v] = 1;
     }
   }

   dfs();

   return 0;
 }


Measured memory_bytes: 3164
#include<stdio.h>


int main()
{
	int n;
	scanf("%d",&n);
	int f = 1;
	for (int i = 1; i <= n; i ++ )
	{
		int x;
		scanf("%d",&x);
		if(x % 2 == 0)
		{
			if(x % 3 && x % 5)
				f = 0;
		}
	}
	if(f == 0)
	{
		printf("DENIED\n");
	}
	else
		printf("APPROVED\n");
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, n) for (lli i = 0; i < (n); i++)
#define rrep(i, n) for (lli i = (n)-1; i >= 0; i--)
using namespace std;
using lli = long long int;
int main()
{
    int n;
    cin >> n;
    int xx = 0, yy = 0;
    int tt = 0;
    rep(i, n)
    {
        int t, x, y;
        cin >> t >> x >> y;
        int hoge = abs(x - xx) + abs(y - yy);
        if (hoge % 2 == (t - tt) % 2 and hoge <= (t - tt)) {
            xx = x, yy = y, tt = t;
        } else {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<vector>
std::vector<int>v;
void f(int n,int d)
{
	int i;
	if(n==0)
	{
		for(i=0;i<v.size();++i)printf("%s%d",i?" ":"",v[i]);
		puts("");
	}
	else
		for(i=(d<n?d:n);i>0;--i)
		{
			v.push_back(i);
			f(n-i,i);
			v.pop_back();
		}
}
int main()
{
	int n;
	while(scanf("%d",&n),n) f(n,n);
	return 0;
}

Measured memory_bytes: 0
abc = sorted(list(map(int, input().split())))

if (abc[0]%2==0 and abc[1]%2==0) or (abc[0]%2==1 and abc[1]%2==1):
  ans = 0
  ans += abc[2]-abc[1]
  ans += (abc[1]-abc[0])//2
  print(ans)
else:
  count = 0
  for i in abc:
    if i%2 == 0: count+=1

  for i in range(len(abc)):
    if count == 2:
      if abc[i]%2 == 0: abc[i] += 1
    else:
      if abc[i]%2 == 1: abc[i] += 1
  ans = 1
  ans += abc[2]-abc[1]
  ans += (abc[1]-abc[0])//2
  print(ans)

Measured memory_bytes: 9224
#include <stdio.h>

int main()
{
	int a,b,c=0;
	while(scanf("%d %d",&a,&b) != EOF)
	{
		c=0;
		a+=b;
		while(a>0)
		{
			c++;
			a/=10;
		}
		printf("%d\n",c);
	}
	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<cstdio>
#include<cstring>
#include<ctime>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<string>
#include<queue>
#include<vector>
#include<map>
#include<set>
#include<utility>
#include<iomanip>
#include<map>
#include<vector>
using namespace std;
int read(){
    int xx=0,ff=1;char ch=getchar();
    while(ch>'9'||ch<'0'){if(ch=='-')ff=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){xx=xx*10+ch-'0';ch=getchar();}
    return xx*ff;
}
long long READ(){
    long long xx=0,ff=1;char ch=getchar();
    while(ch>'9'||ch<'0'){if(ch=='-')ff=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){xx=xx*10+ch-'0';ch=getchar();}
    return xx*ff;
}
char one(){
	char ch=getchar();
	while(ch==' '||ch=='\n')
		ch=getchar();
	return ch;
}
const int maxn=100010,INF=1<<30;
int N,M;
struct my{
	int a,b;
	bool friend operator<(const my&A,const my&B){
		return A.b>B.b||(A.b==B.b&&A.a>B.a);
	}
}C[maxn];
set<int>s;
set<int>::iterator it;
int main(){
	//freopen("in","r",stdin);
	N=read(),M=read();
	for(int i=1;i<=N;i++)
		C[i].a=read(),C[i].b=read();
	sort(C+1,C+1+N);
	s.clear();
	for(int i=1;i<=M;i++)
		s.insert(i);
	s.insert(INF);
	long long ans=0;
	for(int i=1;i<=N;i++){
		it=s.lower_bound(C[i].a);
		if(*it!=INF){
			s.erase(it);
			ans+=C[i].b;
		}
	}
	cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
typedef long long ll;
typedef pair<int,int> pint;

int p[101];
pint dp[101][60001];
int INF=1000100010;
int main(){
    int n;
    while(cin>>n,n){
        rep(i,n) cin>>p[i];
        FOR(i,0,n+1)rep(j,50001) dp[i][j]={0,-INF};
        dp[0][0]={0,0};
        rep(i,n){
            int cp=p[i];
            rep(j,50001){
                if(dp[i][j]==pint(0,-INF)) continue;
                dp[i+1][j]=max(dp[i+1][j],dp[i][j]);
                if(p[i]%1000==0){
                    if(j<500) continue;
                    else{
                        pint tmp=dp[i][j];
                        tmp.second-=cp;++tmp.first;
                        dp[i+1][j-500]=max(dp[i+1][j-500],tmp);
                    }
                    continue;
                }
                if(cp%1000>500){
                    if(cp%1000-500<=j){
                        pint tmp=dp[i][j];
                        tmp.second-=cp;
                        dp[i+1][j+1000-cp%1000]=max(dp[i+1][j+1000-cp%1000],tmp);
                        ++tmp.first;
                        dp[i+1][j-cp%1000+500]=max(dp[i+1][j-cp%1000+500],tmp);
                    }
                    else{
                        pint tmp=dp[i][j];
                        tmp.second-=cp;
                        dp[i+1][j+1000-cp%1000]=max(dp[i+1][j+1000-cp%1000],tmp);
                    }
                }
                else{
                    pint tmp=dp[i][j];
                    tmp.second-=cp;++tmp.first;
                    dp[i+1][j+1000-cp%1000-500]=max(dp[i+1][j+1000-cp%1000-500],tmp);
                }
            }
        }
        pint mx={0,-INF};
        rep(i,n+1)rep(j,50001) mx=max(mx,dp[i][j]);
        cout<<mx.first<<" "<<-mx.second<<endl;
    }
    return 0;
}


Measured memory_bytes: 42972
#include "bits/stdc++.h"

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

const ll INF = 1LL << 60;

int main() {
	ll n, a, b;

	cin >> n >> a >> b;

	cout << min(n * a, b) << endl;
}

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

using namespace std;

int main() {

    int n,a,b,c,d; cin >> n >> a >> b >> c >> d;
    string s; cin >> s;

    bool flag = true;

    if(c < d) {
        // A->C, B->Dの経路に岩が2つ並ぶところがないかを調べる
        bool prev_stone = false;
        for(int i = a-1; i < c; i++) {
            char now_status = s.at(i);
            if(prev_stone && now_status == '#') {
                flag = false;
                break;
            } else if(now_status == '#') {
                prev_stone = true;
            } else {
                prev_stone = false;
            }
        }
        
        prev_stone = false;
        for(int i = b-1; i < d; i++) {
            char now_status = s.at(i);
            if(prev_stone && now_status == '#') {
                flag = false;
                break;
            } else if(now_status == '#') {
                prev_stone = true;
            } else {
                prev_stone = false;
            }
        }
    } else {
        // AがどこかでBを追い抜く必要がある。
        // 岩２連続ないことの確認をA->Cまで
        // さらに A->Dの間に3つ連続して何もない空間があるかを調べる(Bが動けるDまでにどうにかする必要がある, 戻れないので)
        bool three_space = false;
        int stack_space = 0;
        for(int i = b-2; i < d+1; i++) {
            char now_status = s.at(i);
            if(now_status == '#') {
                stack_space = 0;
            } else {
                stack_space++;
                if(stack_space >= 3) three_space = true;
            }
        }
        if(!three_space) {
            flag = false;
            cout << "No" << endl;
            return 0;
        }

        bool prev_stone = false;
        for(int i = a-1; i < c; i++) {
            char now_status = s.at(i);
            if(prev_stone && now_status == '#') {
                flag = false;
                break;
            } else if(now_status == '#') {
                prev_stone = true;
            } else {
                prev_stone = false;
            }
        }

        prev_stone = false;
        for(int i = b-1; i < d; i++) {
            char now_status = s.at(i);
            if(prev_stone && now_status == '#') {
                flag = false;
                break;
            } else if(now_status == '#') {
                prev_stone = true;
            } else {
                prev_stone = false;
            }
        }
    }

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


    return 0;
}

/**
15 1 3 15 13
...#.#...#.#...
 */


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

int main() {
    int N, M;
    scanf("%d %d", &N, &M);

    std::priority_queue<long int> item;

    int i;
    long int a;
    for (i = 0; i < N; i++) {
        scanf("%ld", &a);
        item.push(a);
    }

    for (i = 0; i < M; i++) {
        a = item.top();
        item.pop();
        item.push(a/2);
    }

    long long int total = 0;
    for (i = 0; i < N; i++) {
        total += item.top();
        item.pop();
    }
    printf("%lld", total);

    return 0;
}

Measured memory_bytes: 1528
#include<bits/stdc++.h>
using namespace std;
string s[505],ss[505] ;
int main()
{
    int n,m ; cin>>n>>m ;
    for(int i = 0 ; i < n ; i++) cin>>s[i] ;
    for(int i = 0 ; i < n ; i++) {ss[i]=""; for(int j = 0 ; j < m ; j++) ss[i]+=s[i][j]; }
    //cout<<endl ;
    for(int i = 0 ; i < n ; i++)
    {
        if(i%2==0)
        {
            for(int j = 0 ; j < m-1 ; j++) {cout<<'#' ; ss[i][j]='#' ;}
            if(s[i][m-1]=='#') {cout<<'#' ; ss[i][m-1]='#' ;}
            else {cout<<'.' ; ss[i][m-1]='.' ;}
        }
        else
        {
            cout<<'#' ; ss[i][0]='#' ;
            for(int j = 1 ; j < m ; j++) {cout<<s[i][j] ; ss[i][j]=s[i][j] ;}
        }
        cout<<endl ;
    }
    cout<<endl ;
  //  for(int i = 0 ; i < n ; i++){for(int j = 0 ; j < m ; j++) cout<<ss[i][j] ; cout<<endl ; }
    //cout<<endl ;
    for(int i = 0 ; i < n ; i++)
    {
        for(int j = 0 ; j < m ; j++)
        {
            if(s[i][j]=='#' && s[i][j]==ss[i][j]) cout<<'#' ;
            else if(ss[i][j]=='.') cout<<'#' ;
            else cout<<'.' ;
        }
        cout<<endl ;
    }
}


Measured memory_bytes: 4632
/*
********************
Author : Sahil Kundu
********************
*/
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define mod 1000000007
#define pb(i) push_back(i)
#define f first
#define s second
#define mk(l,r) make_pair(l,r)
#define all(vc) vc.begin(),vc.end()
#define pii pair<int,int>
#define pll pair<ll,ll>
#define ms(i,j) memset(i,j,sizeof i)
#define w(t) while(t--)
#define len(s) s.length()
const ll MAX=1e5+5;
const ll INF=2e18+10;
const int inf=1e9+10;
bool isprime[MAX];
vector<ll> primes;
void allprimes()
{
    ms(isprime,true);
    isprime[1]=false;
    for(ll i=2;i*i<=MAX;i++)
    {
        if(isprime[i])
        {
            for(ll j=i*i;j<=MAX;j+=i)
                isprime[j]=false;
        }
    }
    for(ll i=2;i<=MAX;i++)
        if(isprime[i])
        primes.pb(i);
}
ll power(ll a,ll b)
{
    if(!b)return 1;
    ll res=power(a,b/2)%mod;
    res=res*res%mod;
    return (b%2 ? res*a : res)%mod;
}
void solve()
{
    allprimes();
    ll n,k;
    cin>>n>>k;
    ll ans=0;
    ll dp[k+1];
    ms(dp,0);
    for(int i=k;i>=1;i--)
    {
        ll cal=k/i;cal=power(cal,n);
        for(int j=2*i;j<=k;j+=i)
        {
            cal=(cal-dp[j]+mod)%mod;
        }
        dp[i]=cal;
        cal=(cal*i)%mod;
        ans=(ans+cal)%mod;
    }
    cout<<ans<<endl;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    t=1;
    //cin>>t;
    w(t) solve();
    return 0;
}

Measured memory_bytes: 4628
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repbtw(i, a, b) for (int i = a; i <= (int)(b); i++)
#define all(v) v.begin(), v.end()
#define pr(x) cout << x << endl


int main()
{
    int64_t n, k;
    cin >> n >> k;
    vector<int64_t> a(n);
    rep(i, n) {
        int64_t in;
        cin >> in;
        a.at(i) = in- 1;
    }
    vector<bool> visited(n, false);
    int64_t curr = 0, prev = 0;

    vector<int64_t> time(n);
    vector<int64_t> path(n);
    int64_t cnt = 0;
    bool noloop = false;
    while(!visited.at(curr)){
        visited.at(curr) = true;
        time.at(curr) = cnt;
        path.at(cnt) = curr;
        if(cnt == k){
            noloop = true;
            break;
        }

        prev = curr;
        curr = a.at(curr);
        cnt++;
    }
    if(noloop) {
        pr(curr + 1);
        return 0;
    }
    int64_t cnt_idx = (k - time.at(curr)) % (time.at(prev) - time.at(curr) + 1) + time.at(curr);
    pr((path.at(cnt_idx) + 1));
    return 0;   
}



Measured memory_bytes: 8012
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int k,n; cin >> k >> n;
  vector<int> data(n);
  for(int i=0; i<n; i++) cin >> data.at(i);
  int ans = 0;
  for(int i=0; i<n-1; i++)
    ans = max(ans,data.at(i+1)-data.at(i));
  ans = max(ans,data.at(0)+k-data.at(n-1));
  cout << k-ans << endl;
}

Measured memory_bytes: 1024
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define PI 3.141592
#define all(a) (a).begin(), (a).end()


int main(){
    string s;
    cin >> s;
    if(s == "ABC") puts("ARC");
    else puts("ABC");
}


Measured memory_bytes: 3596
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int m1 = Integer.parseInt(sc.next());
        int d1 = Integer.parseInt(sc.next());
        int m2 = Integer.parseInt(sc.next());
        int d2 = Integer.parseInt(sc.next());
        sc.close();

        // 主処理
        boolean judge = m1 != m2;
        int result = judge ? 1 : 0;

        // 出力
        System.out.println(result);
    }
}


Measured memory_bytes: 22868
fn = lambda: map(int, input().split())
N, M, R = fn()
r = [int(ri) - 1 for ri in input().split()]
A, B, C = [0]*M, [0]*M, [0]*M
for i in range(M):
    A[i], B[i], C[i] = fn()
    A[i], B[i] = A[i]-1, B[i]-1

from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import floyd_warshall
from itertools import permutations

G = csr_matrix(((C, (A, B))), shape=(N, N))
D = floyd_warshall(G, directed=False)

best = float('inf')
for route in permutations(r):
    d = sum([D[route[i], route[i+1]] for i in range(len(route) - 1)])
    best = min(d, best)
print(int(best))


Measured memory_bytes: 19796
import java.util.Scanner;
public class Main {
	 public static void main(String args[]){
		 Scanner std = new Scanner(System.in);
		 int i = std.nextInt();
		 int ato = i%100;
		 int mae = (i-ato)/100;
		 if(isM(mae) && isM(ato)) {
			 System.out.println("AMBIGUOUS");
		 }
		 else if(isM(mae)) {
			 System.out.println("MMYY");
		 }
		 else if(isM(ato)) {
			 System.out.println("YYMM");
		 }
		 else {
			 System.out.println("NA");
		 }
	 }

	 static boolean isM(int a) {
		if(0<a&&a<=12) {
			return true;
		}
		else {
			return false;
		}
	 }
}



Measured memory_bytes: 21844
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;
int N, K;
int arr[505];
int rem[505];
vector <int> factors;

void findFactors(int tot){
    int p = (int) sqrt(tot)+1;
    for (int i=1; i<=p; i++) {
        if (tot % i == 0) {
            factors.push_back(i);
            factors.push_back(tot/i);
        }
    }
    sort(factors.begin(), factors.end(), greater<>());
}

int main() {
    cin >> N >> K;
    int tot = 0;
    for (int i=1; i<=N; i++){
        scanf("%d", &arr[i]);
        tot += arr[i];
    }
    findFactors(tot);
    int ans;
    for (int f: factors){
        for (int i=1; i<=N; i++){
            rem[i] = arr[i] % f;
        }
        sort(rem+1, rem+N+1);
        int sum = 0, req = 0;
        int l = 0, r = N;
        while (l <= r){
            if (sum <= 0) {
                sum += rem[l];
                req += rem[l];
                l++;
            } else {
                sum -= (f-rem[r]);
                req += (f-rem[r]);
                r--;
            }
        }
        if (req <= 2*K) {
            ans = f;
            break;
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
    string number;
    int count=0;
    while(1){
        count=0;
        cin>>number;
        if(number=="0"){
            break;
        }
        rep(i, number.size()){
            count+=number.at(i)-'0';
        }
        cout<<count<<endl;
    }
}


Measured memory_bytes: 3180
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,d,p[1010];
  cin>>n>>d;
  for(int i=0;i<n;i++)cin>>p[i];
  sort(p,p+n);
  int ans=0;
  for(int i=0;i<n;i++){
    if(p[n-1-i]<=d)break;
    ans+=p[n-1-i]-d;
  }
  if(ans)cout<<ans<<endl;
  else cout<<"kusoge"<<endl;
  return 0;
}



Measured memory_bytes: 3168
#![allow(unused_imports)]

use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::{i32, i64, i128, u32, u64, u128, f64};
use std::io::{stdout, Write, BufWriter};
use std::mem::{swap};
use proconio::{input, marker::{Isize1, Usize1, Bytes, Chars}};

#[proconio::fastout]
fn main() {
    proconio::input!(
        s: String,
    );
    if s.ends_with('s' ) { println!("{}es", s); }
    else { println!("{}s", s); }
}


Measured memory_bytes: 2116
S = input().strip()
Q = int(input())
is_reverse = False
A = ""
B = ""
for i in range(Q):
  query = [j for j in input().strip().split()]
  T = int(query[0])
  if T == 1:
    is_reverse = not is_reverse
  else:
    F, C = int(query[1]), query[2]
    if F == 1:
      if not is_reverse:
        A = C + A
      else:
        B = B + C
    else:
      if not is_reverse:
        B = B + C
      else:
        A = C + A

res = A + S + B
if not is_reverse:
  print(res)
else:
  print(res[::-1])


Measured memory_bytes: 4624
N, *A = map(int, open(0).read().split())
MOD = 1_000_000_007
cnt = [0, 0, 0]
ans = 1
for a in A:
    possible = sum(c == a for c in cnt)
    ans *= possible
    ans %= MOD
    for i in range(3):
        if cnt[i] == a:
            cnt[i] += 1
            break
print(ans)


Measured memory_bytes: 20160
#include <bits/stdc++.h>
#define int long long

using namespace std;
using LL = long long;
using P = pair<int, int>;

#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e18;
const int MOD = 1e9 + 7;
// UnionFindを構築します
// 使用例:
// UnionFind uni(n);
// cout << uni.Same(1, 2) ? "YES" : "NO" << endl; <- NO
// uni.Unite(1, 2);
// cout << uni.Same(1, 2) ? "YES" : "NO" << endl; <- YES
// cout << uni.GetSize(1) << endl;                <- 2
class UnionFind
{
    private:
      vector<int> par;
      vector<int> rank;
      vector<int> sz;

    public:
      UnionFind(int n) : par(n), rank(n, 0), sz(n, 1)
      {
          iota(par.begin(), par.end(), 0);
      }
      int Find(int x)
      {
          if (par[x] == x) return x;
          else
          {
              int r = Find(par[x]);
              return par[x] = r;
          }
      }
      bool Unite(int x, int y)
      {
          x = Find(x);
          y = Find(y);
          if (x == y) return false;

          if (rank[x] < rank[y]) swap(x, y);
          par[y] = x;
          if (rank[x] == rank[y]) rank[x]++;
          sz[x] += sz[y];
          return true;
      }
      bool Same(int x, int y)
      {
          if (Find(x) == Find(y)) return true;
          else return false;
      }
      int GetSize(int x)
      {
          return sz[Find(x)];
      }
};

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

    int n, m;
    cin >> n >> m;
    vector<int> a(m), b(m);
    REP(i, m) cin >> a[i] >> b[i];
    reverse(all(a));
    reverse(all(b));

    UnionFind uf(n+1);
    vector<LL> ans(m);
    ans[0] = n * (n-1) / 2;
    REP(i, m-1){
        if(uf.Same(a[i], b[i])){
            ans[i+1] = ans[i];
        }else{
            ans[i+1] = ans[i] - uf.GetSize(a[i]) * uf.GetSize(b[i]);
            uf.Unite(a[i], b[i]);
        }
    }
    reverse(all(ans));
    REP(i, m) cout << ans[i] << endl;
}

Measured memory_bytes: 6016
N = int(input())

An = list(map(int, input().split()))
Q = int(input())

L = [0] * 100001
for item in An:
    L[item] += 1

sum = sum(An)

for i in range(Q):
    b, c = map(int, input().split())
    sum += (c-b) * L[b]
    L[c] += L[b]
    L[b] = 0
    print(sum)

Measured memory_bytes: 21000
#include<iostream>
#include<vector>
#include<sstream>
#include<string>
#include<numeric>
#include <algorithm>
#include<math.h>
#include<cstdio>
#include<string.h>
#include<stdio.h>
#include<stdlib.h>




using namespace std;
typedef long long ll;
struct point{
  int x;
  int y;

};
int gcd( int m, int n )
{
	// 引数に０がある場合は０を返す
	if ( ( 0 == m ) || ( 0 == n ) )
		return 0;
	
	// ユークリッドの方法
	while( m != n )
	{
		if ( m > n ) m = m - n;
		else         n = n - m;
	}
	return m;
}//gcd
int lcm( int m, int n )
{
	// 引数に０がある場合は０を返す
	if ( ( 0 == m ) || ( 0 == n ) )
		return 0;
	
	return ((m / gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}//lcm
int input(){
  int x;
  cin>>x;
  return x;
}

int moji(char in)
{
    int ans = (int)in-(int)'a';
    if((ans < 0) || (ans > 25)){
        ans = 26;
    }
    return ans;
}
const int VV=10;//場合に応じてVVの値のみ変更する必要あり
//dijkstra(s)sがスタート地点でそこからの最短距離を配列dで表す。正の重みのみ使用可能
int cost[VV][VV];
int d[VV];
bool used[VV];
void dijkstra(int s){
  fill(d,d+VV,100000);
  fill(used,used+VV,false);
  d[s]=0;
  while(true){
    int v=-1;
    for(int u=0;u<VV;u++){
      if(!used[u]&&(v==-1||d[u]<d[v]))v=u;
    }
    if(v==-1)break;
    used[v]=true;
    for(int u=0;u<VV;u++){
      d[u]=min(d[u],d[v]+cost[v][u]);
    }
  }

}

int compare_int(const void *a, const void *b)//qsort(quick sort利用時に使用)
{
    return *(int*)a - *(int*)b;
}





int main(){
  string S;
  cin>>S;
  long long sumb=0;
  for(int i=0;i<S.size();i++){
    if(S.at(i)=='W'){
      sumb++;
    }

  }
  long long sumbb=0;
  long long sum=0;
  for(int i=0;i<S.size();i++){
    if(S.at(i)=='B'){
      sum+=sumb-sumbb;
    }else{
      sumbb++;
    }


  }
  cout<<sum<<endl;

  

  



}


  
  

Measured memory_bytes: 640
#include<stdio.h>

int main(void)
{
  long long int s, c, a;
  scanf("%lld %lld", &s, &c);
  if(2 * s >= c)
  {
    printf("%lld", c / 2);
  }
  else
  {
    printf("%lld", s + (c - 2 * s) / 4);
  }
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define INF 2000000000000000000
#define ll long long
#define pll pair<ll, ll>
using namespace std;
bool debug = true;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll N;
  cin >> N;
  vector<pair<long double, pll>> dxy;
  for (ll i = 0; i < N; ++i) {
    ll x, y;
    cin >> x >> y;
    dxy.push_back({0.0, {x, y}});
  }
  for (ll i = 0; i < N; ++i) {
    dxy.at(i).first = atan2l(dxy.at(i).second.second, dxy.at(i).second.first);
  }
  sort(dxy.begin(), dxy.end());
  vector<pll> sorted_xy(N);
  for (ll i = 0; i < N; ++i) {
    sorted_xy.at(i) = dxy.at(i).second;
  }
  // for (ll i = 0; i < N; ++i) {
  //   cout << sorted_xy.at(i).first << sorted_xy.at(i).second << "\n";
  // }
  ll ans = 0;
  //i = len
  for (ll i = 1; i <= N; ++i) {
    // j = start
    for (ll j = 0; j < N; ++j) {
      ll fx = 0, fy = 0;
      for (ll k = 0; k < i; ++k) {
        ll x = sorted_xy.at((k + j) % N).first, y = sorted_xy.at((k + j) % N).second;
        fx += x;
        fy += y;
      }
      // cout << fx << ' ' << fy << "\n";
      ans = max(ans, (ll)(pow(fx, 2) + pow(fy, 2)));
    }
  }
  cout << fixed << setprecision(15) << pow(ans, 0.5) << "\n";
}


Measured memory_bytes: 4200
/* ex 7_3
   person_A */

#include <stdio.h>
#include <string.h>
#include <stdlib.h>


int main(void){
    //行列と行数、列数、空白の記録用配列の宣言
    char** matrix;
    int height,width,*whiterow,*whitecolumn,i,j;
    //行数、列数の入力
    scanf("%d %d",&height,&width);
    //配列の動的メモリ確保
    matrix=(char**)calloc(height,sizeof(char*));
    whiterow=(int*)calloc(height,sizeof(int));
    whitecolumn=(int*)calloc(width,sizeof(int));
    if(matrix==NULL||whiterow==NULL||whitecolumn==NULL){
        fprintf(stderr,"memory allocation error.\n");
        exit(1);
    }
    for(i=0;i<height;i++){
        matrix[i]=(char*)calloc(width,sizeof(char));
        if(matrix[i]==NULL){
            fprintf(stderr,"memory allocation error.\n");
            exit(1);
        }
    }
    //matrixの要素の入力
    for(i=0;i<height;i++){
        for(j=0;j<width;j++){
            scanf(" %c",&matrix[i][j]);
        }
    }

    //whiterowに空白行の記録
    for(i=0;i<height;i++){
        for(j=0;j<width;j++){
            if(matrix[i][j]!='.'){
                break;
            }
            else if(j==width-1){
                whiterow[i]=1;
            }
        }
    }
    //whitecolumnに空白列の記録
    for(j=0;j<width;j++){
        for(i=0;i<height;i++){
            if(matrix[i][j]!='.'){
                break;
            }
            else if(i==height-1){
                whitecolumn[j]=1;
            }
        }
    }
    //結果の出力
    for(i=0;i<height;i++){
        if(whiterow[i]==1){
            continue;
        }
        for(j=0;j<width;j++){
            if(whitecolumn[j]==0){
                printf("%c",matrix[i][j]);
            }
        }
        printf("\n");
    }

    return 0;
}

Measured memory_bytes: 1660
using System;
using System.Linq;
namespace algo
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] input = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();

            Console.WriteLine("{0} {1}", input[0] * input[1], 2 * (input[0] + input[1]));
        }
    }
}



Measured memory_bytes: 16160
fun main(args: Array<String>) {
    solve(java.util.Scanner(System.`in`))
}

fun solve(sc: java.util.Scanner) {
    val N = sc.nextInt()
    val X = (0 until N).map { sc.nextLong() }

    val Xs = X.sorted()
    val midL = Xs[N / 2 - 1]
    val midR = Xs[N / 2]

    println((0 until N).map {
        if (X[it] < midR) midR else midL
    }.joinToString("\n"))
}


Measured memory_bytes: 89204
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
typedef long long int ll;
typedef vector<ll> vi;
typedef vector<pair<ll, ll> > vp;
typedef vector<string> vs;
typedef vector<char> vc;
typedef list<ll> lst;
typedef pair<ll, ll> P;
const long long INF = numeric_limits<ll>::max();
const long long MOD = 1000000007;
const long double PI = 3.1415926;
template <class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <class T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
ll n, m, k, ans = 0, sum = 0, cnt = 0;
string s;
//char c;
 
#define Endl endl
 
/*--------------------template--------------------*/
ll sumF(ll i){
    ll ans=0;
    while(i/10>0){
        ans+=i%10;
        i/=10;
    }
    ans+=i;
    return ans;
}

int main() {
    ll N,A,B;
    cin>>N>>A>>B;
    REP(i,N+1){
        ll s=sumF(i);
        //cout<<s<<endl;
        if(s>=A&&s<=B)ans+=i;
    }
    cout<<ans<<endl;
    return 0;
}


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

using namespace std;

int main() {
  long long a, b, c;
  
  cin >> a >> b >> c;
  
  bool ans = (c - a - b > 0 && 4 * a * b < (c - a - b) * (c - a - b));
  
  cout << (ans ? "Yes" : "No") << endl;
  
  return 0;
}

Measured memory_bytes: 3632
#include<iostream>
#include<stdio.h>
#include<string.h>
using namespace std;
char s[5200000];
int f[5200000];
int ans=0,n;
int add(){
	int p=n;
	while(s[p]=='9')s[p]='0',p--,f[p]=n+1;
	f[p]=p+1;
	int l=p;
	while(s[l]==s[l-1]){
		f[l-1]=p;
		l--;
	}
	s[p]++;
	l=p;
	while(s[l]==s[l-1]){
		f[l-1]=p+1;
		l--;
	}
}
int main(){
	scanf("%s",s+1);
	n=strlen(s+1);
	for(int i=n;i>=1;i--){
		if(s[i]==s[i+1])f[i]=f[i+1];
		else f[i]=i+1;
	}
	for(int i=1;i<=n;i++){
		while(s[f[i]]>=s[i])i++;
	//	printf("ill:%d::%d:",i,ans+1);
		if(f[i]>n){
			ans++;
			break;
		}
		if(s[i]=='0')break;
		ans++;
		if(i>=n)break;
		int l=i-1;
		s[i]='0';
		add();
		if(s[i]!='0')i--;
	//	for(int j=1;j<i;j++)printf(" ");
	//	for(int j=i;j<=n;j++)printf("%c",s[j]);
	//	printf("\n");
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 6272
#include<bits/stdc++.h>
using namespace std;
int m[100];
int main()
{  int a,b,k;
    scanf("%d%d%d",&a,&b,&k);

    int z=1;
    if(a>b) swap(a,b);
    for(int i=a;i>=1;i--)
    {
        if(a%i==0&&b%i==0)
         m[z++]=i;

    }

    printf("%d\n",m[k]);

}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>

bool solve() {
    int n;
    std::cin >> n;
    if (n == 0) return false;

    std::vector<std::set<int>> xs(2);
    for (int i = 0; i < n; ++i) {
        int x;
        std::cin >> x;
        xs[0].insert(x);
    }

    for (int i = 1; i <= n * 2; ++i) {
        if (!xs[0].count(i)) xs[1].insert(i);
    }

    int turn = 0, prev = 0;
    while (!xs[0].empty() && !xs[1].empty()) {
        auto it = xs[turn].upper_bound(prev);

        if (it != xs[turn].end()) {
            prev = *it;
            xs[turn].erase(it);
        } else {
            prev = 0;
        }

        if (xs[turn].empty()) break;
        turn = 1 - turn;
    }

    std::cout << xs[1].size() << "\n"
              << xs[0].size() << "\n";

    return true;
}

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

    while (solve()) {}

    return 0;
}



Measured memory_bytes: 3036
#include <iostream>
using namespace std;
typedef long long ll;
#define MOD 1000000007

int main() {
    ll n, k; cin >> n >> k;
    ll ans = 0;
    for (ll i = k; i <= n + 1; i++) {
        ll left = i * (i - 1) / 2, right = i * n - i * (i - 1) / 2;
        (ans += right - left + 1) %= MOD;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int x = 1;
    
    for (int i = 0; x != 0; i++) {
        cin >> x;
        if (x != 0) {
            cout << "Case " << i+1 << ": " << x << endl;
        }
    }
}


Measured memory_bytes: 3052
package main

import (
	"fmt"
	"math"
	"strconv"
)

func main() {
	var a, b string
	fmt.Scan(&a, &b)
	cStr := a + b
	c, _ := strconv.ParseFloat(cStr, 64)
	cSqrt := math.Sqrt(c)
	if cSqrt-math.Trunc(cSqrt) == 0 {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 512
x,n = map(int,input().split())
if n == 0:
  print(x)
  exit()
p = list(map(int,input().split()))
t = [i for i in range(0,102)]

p.sort()
diff = list(set(t) ^ set(p))

for i in range(len(diff)):
  diff[i] -= x

ans = diff[0]
for i in range(1,len(diff)):
  if abs(ans) > abs(diff[i]):
    ans = diff[i]
    
ans += x
print(ans)

Measured memory_bytes: 9232
#include<bits/stdc++.h>
using namespace std;
int main(){
 int N;cin >> N;
 string S = "";
 while(N){
  if(N % 2){
	 N--;
	 S = '1' + S;
	}
	else{
	 S = '0' + S;
	}
	N /= -2;
 }
 if(S == "")
  S = '0';
 cout << S << endl;
 return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <sstream>
#include <vector>
#include <stack>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long int ll;


int main()
{
	int a,b,c;
	int N,Y;
	cin>>N>>Y;
	Y = Y /1000;
	a = -1;
	c = -1;
	for(b = 0; b < 2001; b++){
		if( ((Y-N) - 4* b) % 9 == 0){
			c = ((Y-N) - 4*b)/9;
			a = N - (b + c);
			if( a >= 0 && b >= 0 && c >= 0){
				break;
			}
		}
	}
	if(a >= 0 && b >= 0 && c >= 0){
		cout<<c<<" "<<b<<" "<<a<<endl;
		//cout<<10000*c + 5000*b + 1000*a<<endl;
	}else{
		cout<<"-1 -1 -1"<<endl;
	}
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pi M_PI
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1000000007,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

void Main() {
  ll n,m;
  cin >> n >> m;
  ll d[111111];
  mem(d);
  rep(i,n) {
    ll x,y;
    cin >> x >> y;
    d[x]+=y;
  }
  REP(i,1,111111) d[i]+=d[i-1];
  REP(i,1,111111) {
    if(d[i-1]<m&&d[i]>=m) {
      pr(i);
      return;
    }
  }
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 1152
#include<stdio.h>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <iterator>
#include <list>
#include <map>     
#include <numeric>
#include <utility>
#include <queue>
#include <set>
#include <sstream>
#include <iomanip>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define ll long long
#define ld long double
#define rep(a,t) for(int a=0;a<t;++a) 
#define forever while(true)
#define Sort(a) sort(a.begin(),a.end())
#define Reverse(a) reverse(a.begin(),a.end())
#define pb push_back
#define int_maxvalue numeric_limits<int>::max()
#define print_double(val,a) cout << fixed << setprecision(a) << val << endl;
ll mod = 1e9 + 7;
vector<int>era(int n) {
	bool* dp = new bool[n];
	for (int i = 0; i < n; i++) dp[i] = false;
	dp[0] = dp[1] = true;
	vector<int>prime;
	for (int i = 2; i < n; i++) {
		if (dp[i]) continue;
		prime.push_back(i);
		for (int j = i * 2; j < n; j += i) {
			dp[j] = true;
		}
	}
	return prime;
}
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<int>prime = era(55555);
	int ans=0;
	for (int i = 0; i < prime.size(); i++) {
		if (ans == n) { break; }
		if (prime[i] % 5 == 1) {
			if (ans != 0) { cout << " "; }
			cout << prime[i];
			ans++;
		}
	}
	return 0;
}

Measured memory_bytes: 384
import java.lang.Math;
import java.util.*;

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

        int x;
        int y;
        int z;

        if(a <= b && a <= c){
            x = a;
            if(b < c){
                y = b;
                z = c;
            }
            else{
                y = c;
                z = b;
            }
        }
        else if(b <= a && b <= c){
            x = b;
            if(a < c){
                y = a;
                z = c;
            }
            else{
                y = c;
                z = a;
            }
        }
        else{
            x = c;
            if(a < b){
                y = a;
                z = b;
            }
            else{
                y = b;
                z = a;
            }
        }

        System.out.println(x + " " + y + " " + z);

        scanner.close();
    }
}


Measured memory_bytes: 26156
import java.util.Comparator;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

public class Main {
    private static java.util.Scanner scanner = new java.util.Scanner(System.in);

    public static void main(String[] args) {
        int n = scanner.nextInt(), k = scanner.nextInt();
        System.out.println(IntStream.range(0, n)
                .boxed()
                .collect(Collectors.groupingBy(i -> scanner.nextInt(), Collectors.reducing(0, i -> 1, Integer::sum)))
                .values().stream()
                .sorted(Comparator.reverseOrder())
                .skip(k)
                .mapToInt(Integer::intValue)
                .sum());
    }
}

Measured memory_bytes: 106168
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int main(){
    int a,b,c,d;
    cin >> a >> b >> c>> d;
    int win;
    while(1){
        c -= b;
        if(c<= 0){
            win = 0;
            break;
        }
        a -= d;
        if(a<= 0){
            win = 1;
            break;
        }
    }
    if(win == 0) cout << "Yes" <<endl;
    else if(win == 1) cout << "No" <<endl;
}

Measured memory_bytes: 3636
/**
 *    author:  tourist
 *    created: 23.01.2020 03:51:26       
**/
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(17);
  int n, l;
  cin >> n >> l;
  vector<pair<double, double>> a;
  double res = 0;
  int i = 0;
  for (int it = 0; it < n; it++) {
    double t, v;
    cin >> t >> v;
    double rm = (it == 0 ? 0 : v);
    while (i < (int) a.size()) {
      if (rm > a[i].second) {
        rm -= a[i].second;
        res -= a[i].first * a[i].second;
        ++i;
      } else {
        a[i].second -= rm;
        res -= a[i].first * rm;
        break;
      }
    }
    res += t * v;
    while (i < (int) a.size() && a.back().first > t) {
      t = (t * v + a.back().first * a.back().second) / (v + a.back().second);
      v += a.back().second;
      a.pop_back();
    }
    a.emplace_back(t, v);
    cout << res / l << '\n';
  }
  return 0;
}


Measured memory_bytes: 21864
import java.util.Scanner;
import java.lang.Math;
import java.util.ArrayList;
import java.util.List;
//List<Integer> list = new ArrayList<>();

class Main {
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int n = stdIn.nextInt();
		int m = stdIn.nextInt();
		int c = stdIn.nextInt();
		int[] b = new int[m];
		for (int i = 0; i < m; i++)
			b[i] = stdIn.nextInt();
		int[][] a = new int[n][m];
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++)	
				a[i][j] = stdIn.nextInt();
		}

		int ans = 0;
		int sum;
		for (int i = 0; i < n; i++) {
			sum = c;
			for (int j = 0; j < m; j++)
				sum = sum + a[i][j] * b[j];
			ans = (sum > 0) ? ans + 1 : ans;
		}

		System.out.println(ans);
	}
}

Measured memory_bytes: 23252
#include <bits/stdc++.h>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define int long long
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
const int INF = 1010000000;
const double EPS = 1e-10;
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 

vector<int> init(int size){
  vector<int> par(size,-1);
  return par;
}

int root(int x, vector<int>& par){
  if(par[x] < 0){
    return x;
  }else{
    return par[x] = root(par[x],par);
  }
}

bool same(int x, int y, vector<int>& par){
  return root(x, par) == root(y, par);
}

void unite(int x, int y, vector<int>& par){
  x = root(x, par), y = root(y, par);
  if(same(x,y, par))return;
  par[x] += par[y];
  par[y] = x;
}

int size(int x, vector<int>& par){
  return -par[root(x, par)];
}

int pow(int x, int n){
  if(n == 0)return 1;
  if(n % 2 == 0)return pow(x * x % MOD, n/2);
  else return x * pow(x, n-1) % MOD;
}

signed main(){
  int a[5];rep(i,5)cin>>a[i];sort(a,a+5);int k;cin>>k;
    if(a[4]-a[0] > k){
      cout << ":(" << endl;
      return 0;
    }
  cout << "Yay!" << endl;
}


Measured memory_bytes: 256
// 見せてやるぜ、奇跡ってやつをよぉ……
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
// using namespace std;

// using ll=long long;
// template<class T> using V = vector<T>;
// template<class T, class U> using P = pair<T, U>;
// using vll = V<ll>;
// using vvll = V<vll>;
// #define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
// #define REP(i, n) rep(i, 0, n)
// #define ALL(v) v.begin(),v.end()
// template < class T > inline bool chmax(T& a, T b) {if (a < b) { a=b; return true; } return false; }
// template < class T > inline bool chmin(T& a, T b) {if (a > b) { a=b; return true; } return false; }
// #define DEBUG_VLL(vec) REP(sz, vec.size()) cerr<<vec[sz]<<(sz==vec.size()-1?'\n':' ');

// const ll MOD = 1000000007;
// const ll HIGHINF = (ll)1e18;

const int INF = 1e9;

int main() {
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    int k;
    std::cin >> k;
    std::vector< std::vector< std::pair<int, int> > > edges(k);
    for (int i = 0; i < k; i++) {
        edges[i].emplace_back((i + 1) % k, 1);
        if (i != 10 * i % k) edges[i].emplace_back(10 * i % k, 0);
    }

    std::deque<int> deq;
    std::vector<int> d(k, INF);
    d[1] = 0;
    deq.emplace_back(1);
    while (!deq.empty()) {
        int v = deq.front(); deq.pop_front();
        for (std::pair<int, int> e: edges[v]) {
            if (d[e.first] > d[v] + e.second) {
                d[e.first] = d[v] + e.second;
                if (e.second == 0) deq.emplace_front(e.first);
                else deq.emplace_back(e.first);
            }
        }
    }

    std::cout << d[0] + 1 << '\n';
    return 0;
}



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

int main(){
  int n;
  cin >> n;
  int vec[2][n];
  for (int i = 0 ; i < 2; i++){
  for (int j = 0; j < n; j++){
  cin >> vec[i][j];
  }
  }
  int count = 0;
  for(int i = 0; i < n; i++){
  if(vec[0][i]>=vec[1][i]){
  count += vec[0][i]-vec[1][i];
  }
  }
  cout << count;
}


Measured memory_bytes: 256
// AtCoder template
// 最近sabaがかまってくれないからキレて暴れてる
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i = 0; i < n; ++i)

template<class T>
bool isPrime(T n){
    if(n < 2) return false;
    for(long long i = 2; i*i <= n; ++i) if(n % i == 0) return false;
    return true;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll N; cin >> N;
    
    ll ans = 0LL;
    for(ll i = 2; i*i <= N; ++i){
        ll u = 0LL;
        while(N%i == 0){
            N /= i;
            u++;
        }
        for(ll t = 1LL; u >= 0; ++t){
            u -= t;
            if(u >= 0) ans++;
        }
    }
    if(isPrime(N)) ans++;
    
    cout << ans << endl;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG

using namespace std;
typedef long long ll;

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REP(a, b, m) for (ll a = (ll)(b); a < (ll)(m); a++)

int main()
{
    ll x;
    cin >> x;
    ll sum = 100;
    ll ans = 0;
    while (!(sum >= x))
    {
        sum *= 1.01;
        ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3632