akhauriyash/Code-Regression huggingface dataset:
import math
import heapq

N,M,S=map(int,input().split())

Us=[0]*M
Vs=[0]*M
As=[0]*M
Bs=[0]*M
for i in range(M):
    Us[i],Vs[i],As[i],Bs[i] = map(int,input().split())
    Us[i] -= 1
    Vs[i] -= 1

# ---
V={}
Ns = max(As)*N
Nv=N*(Ns+1)
cnt=0
for i in range(N):
    for ns in range(Ns+1):
        V[(i,ns)]=cnt
        cnt+=1

G=[[] for _ in range(Nv)]

if S > Ns:
    S = Ns

# U <-> V
for _ in range(M):
    u = Us.pop()
    v = Vs.pop()
    a = As.pop()
    b = Bs.pop()
    #
    for i in range(Ns+1): # i = 0,..,Ns
        ns_s = Ns - i
        ns_g = ns_s - a
        if ns_g >= 0:
            # U -> V
            G[ V[(u,ns_s)] ].append( (V[(v,ns_g)],b) )
            # V -> U
            G[ V[(v,ns_s)] ].append( (V[(u,ns_g)],b) )
            #print(u,v,a,b,ns_s,ns_g,V[(u,ns_s)],V[(v,ns_g)])

# -----

for i in range(N):
    c,d = map(int,input().split())
    for j in range(Ns): # j = 0,...,Ns-1
        ns_s = j
        ns_g = j + c
        if ns_g > Ns:
            ns_g = Ns
        G[ V[(i,ns_s)] ].append( (V[(i,ns_g)],d) )

# -----
D=[math.inf]*Nv
q=[]
# -----

s=V[(0,S)]
D[s] = 0
heapq.heappush(q,(0,s))

while len(q) > 0:
    p_cost,p_v = heapq.heappop(q)
    if D[p_v] < p_cost:
        continue
    for e_to,e_cost in G[p_v]:
        if D[ e_to ] > D[p_v] + e_cost:
            D[e_to] = D[p_v] + e_cost
            heapq.heappush(q, (D[e_to], e_to))

for i in range(1,N):
    ans = min([D[i*(Ns+1)+v] for v in range(Ns+1)])
    print(ans)

Measured memory_bytes: 97040
#include<stdio.h>
#include<math.h>
int main()
{
    int i,j,m,n,a[1002],y=0; double sum=0;
    scanf("%d%d",&n,&m);
     for(i=0;i<n;i++){
        scanf("%d",&a[i]);
        sum=sum+a[i];
     }
    /*for(i=0;i<n;i++){
        for(j=0;j<n;j++){
            if(a[j]>a[j+1]){
                temp=a[j];
                a[j]=a[j+1];
                a[j+1]=temp;
            }
        }
    }*/
    //sorting
    double x=ceil(sum/(4.0*m));
    for(i=0;i<n;i++){
        if(a[i]>=x){y++;}
    }
    /*for(i=n-1;a[i]>=x;i--){
        if(a[i]>=x){y++;}
    }*/
    if(y>=m){printf("Yes");}
    else{printf("No");}
    return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
  /*
     input: 46979
     output: 13:2:59
  */
  public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);
    int S = scan.nextInt();
    int h = S / 3600;
    int m = (S % 3600) / 60;
    int s = (S % 3600) % 60 % 60;
    System.out.printf("%d:%d:%d\n", h,m,s);
  }
}


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

int main(){
  int n,point,total=0;;
  for(int i = 0; i < 5; i++){
    cin >> point;
    if(point >= 40){
      total+=point;
    }else{
      total+=40;
    }
  }
  cout << total/5 << endl;
  return 0;
}

Measured memory_bytes: 1160
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int W = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
		int answer = 0;
		answer = Math.abs(a-b)-W;
		if(Math.abs(a-b)<=W)answer = 0;
		System.out.println(Math.abs(answer));
	}

}


Measured memory_bytes: 21972
#include<bits/stdc++.h>
#define long long long
using namespace std;
const int N=1e6,inf=1e9;
int main()
{
  ios_base::sync_with_stdio(0);cin.tie(0);
  int n;cin>>n;

  vector<int>v;
  for(int i=1;i<=n;i++)
    v.push_back(i);
  map<vector<int>,int>mp;
  int cnt=0;
  do
  {
    mp[v]=++cnt;
  }while(next_permutation(v.begin(),v.end()));
  vector<int>a(n),b(n);
  for(int i=1;i<=n;i++)cin>>a[i-1];
  for(int i=1;i<=n;i++)cin>>b[i-1];

  cout<<abs(mp[a]-mp[b])<<endl;

  return 0;
}

Measured memory_bytes: 5248
#include<iostream>
#include<stdio.h>
#define MAX 2001
#define NIL -1
#define B -2
#define W -1
#define G 0
#include<queue>
#include<algorithm>
using namespace std;

int d[MAX];
int p[MAX];
int color[MAX];
int n;
int M[MAX][MAX];
queue <int> Q;

void Prim() {
	for (int i = 0; i < n; i++) {
		d[i] = MAX;
		p[i] = NIL;
		color[i] = W;
	}
	d[0] = 0;
	color[0] = B;
	int s = 0;
	Q.pop();
	while (!Q.empty()) {
		
		for (int i = 0; i < n; i++) {
			if (M[s][i] != -1 && M[s][i] < d[i] && color[i] != B) {
				d[i] = M[s][i];
				p[i] = s;
				color[i] = G;

			}
		}
		int mini = MAX;
		for (int j = 0; j < n; j++) {
			if (color[j] == G) {			
				if (mini > d[j]) {
					s = j;
				}
				mini= min(mini, d[j]);
			}
		}
		color[s] = B;
		Q.pop();
	}

}
int main() {
	
	cin >> n;
	int a;
	
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			cin >> a;
			M[i][j] = a;
		}
		Q.push(i);
	}

	Prim();
	int sum = 0;
	for (int i = 0; i < n; i++) {
		sum = sum + d[i];
	}
	cout << sum << endl;
}


Measured memory_bytes: 3552
#include<stdio.h>

int main (void) {
   int i, x, y, tmp;

   for (i=1;; i++){
      scanf("%d %d", &x, &y);
      if (x == 0 && y == 0) break;
      if (x>y){
         tmp = x;
         x = y;
         y = tmp;
      }
      printf("%d %d\n", x, y);
      
   }  
   return 0;
}


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

int main(){
  int s;
  cin >> s;
  vector<ll> dp(s+1);
  dp[0] = 1;
  ll sum = 1;
  for(int i = 3; i <= s; i++) {
    dp[i] = sum;
    (sum += dp[i-2]) %= mod;
  }
  cout << dp[s] << endl;
  return 0;
}


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

using ll=long long;
#define int ll

#define FOR(i,a,b) for(int i=int(a);i<int(b);i++)
#define REP(i,b) FOR(i,0,b)
#define MP make_pair
#define PB push_back
#define ALL(x) x.begin(),x.end()
#define REACH cerr<<"reached line "<<__LINE__<<endl
#define DBG(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl

using pi=pair<int,int>;
using vi=vector<int>;
using ld=long double;

template<class T,class U>
ostream& operator<<(ostream& os,const pair<T,U>& p){
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator <<(ostream& os,const vector<T>& v){
	os<<"[";
	REP(i,(int)v.size()){
		if(i)os<<",";
		os<<v[i];
	}
	os<<"]";
	return os;
}

int read(){
	int i;
	scanf("%lld",&i);
	return i;
}

void printSpace(){
	printf(" ");
}

void printEoln(){
	printf("\n");
}

void print(int x,int suc=1){
	printf("%lld",x);
	if(suc==1)
		printEoln();
	if(suc==2)
		printSpace();
}

string readString(){
	static char buf[3341919];
	scanf("%s",buf);
	return string(buf);
}

char* readCharArray(){
	static char buf[3341919];
	static int bufUsed=0;
	char* ret=buf+bufUsed;
	scanf("%s",ret);
	bufUsed+=strlen(ret)+1;
	return ret;
}

template<class T,class U>
void chmax(T& a,U b){
	if(a<b)
		a=b;
}

template<class T,class U>
void chmin(T& a,U b){
	if(a>b)
		a=b;
}

template<class T>
T Sq(const T& t){
	return t*t;
}

const int inf=LLONG_MAX/3;

void NO(){
	cout<<"NO"<<endl;
	exit(0);
}
void YES(){
	cout<<"YES"<<endl;
	exit(0);
}

vi g[114514];
vi st;

int dfs(int v,int p){
	if(int(g[v].size())==1)
		return st[v];
	vi k;
	for(auto to:g[v])if(to!=p)
		k.PB(dfs(to,v));
	int sum=accumulate(ALL(k),0LL);
	int dif=sum-st[v];
	if(dif<0)
		NO();
	int w=*max_element(ALL(k));
	int caldel=min(sum-w,sum/2);
	if(dif>caldel)
		NO();
	sum-=dif*2;
	return sum;
}

signed main(){
	int n=read();
	REP(i,n)
		st.PB(read());
	REP(i,n-1){
		int a=read()-1,b=read()-1;
		g[a].PB(b);
		g[b].PB(a);
	}
	if(n==2){
		if(st[0]!=st[1])
			NO();
		else
			YES();
	}
	REP(i,n)if(int(g[i].size())>1){
		if(dfs(i,-1))
			NO();
		break;
	}
	YES();
}


Measured memory_bytes: 14836
/*
	  Chase
	   Your
	  Legend

	英雄志逐传奇
*/

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <math.h>
#include <stdio.h>

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

int main() {
	string a, b;
	cin >> a >> b;

	int ans = 0;
	rep(i, 3) {
		if (a[i] == b[i]) {
			ans++;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 764
#include <iostream>
#include <vector>

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

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

struct UnionFind {
  vector<int> p;

  UnionFind(int n = 0) : p(n, -1) {}

  int find(int x) {
    if (p[x] < 0) return x;
    return p[x] = find(p[x]);
  }

  bool unite(int x, int y) {
    x = find(x);
    y = find(y);

    if (x == y) return false;
    if (p[x] > p[y]) swap(x, y);
    p[x] += p[y];
    p[y] = x;
    return true;
  }

  int same(int x, int y) { return find(x) == find(y); }
  int size(int x) { return -p[find(x)]; }
};

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

  vector<P> p;
  rep(i, m) {
    int a, b;
    cin >> a >> b;
    --a, --b;
    p.push_back({a, b});
  }

  UnionFind uf(n);

  vector<ll> ans;

  ll now = (ll)n * (ll)(n - 1) / 2LL;
  ans.push_back(now);

  for (auto it = p.rbegin(); it != p.rend() - 1; ++it) {
    int a = it->first, b = it->second;

    ll as = uf.size(a), bs = uf.size(b);
    bool ok = uf.unite(a, b);

    if (ok) now -= as * bs;
    now = now < 0 ? 0 : now;
    ans.push_back(now);
  }

  for (auto it = ans.rbegin(); it != ans.rend(); ++it) {
    cout << *it << '\n';
  }

  return 0;
}


Measured memory_bytes: 3444
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


n = int(input())
a = list(map(int, input().split()))
a.sort()
s = sum(a)
target = s//2 if s%2==0 else s//2+1
dp = 1
for i in range(1, n+1):
    dp = dp | (dp<<a[i-1])
ans = float("inf")
for i in range(target, s+1):
    if (dp>>i&1)==1:
        ans = min(ans, i)
        break
print(ans)

Measured memory_bytes: 11192
S = input()
s = list(map(int, S))
t = s.copy()
n = len(s)
x = 0
y = 1

if t[0] == 0:
    t[0]=1
else:
    t[0]=0

for i in range(n-1):
    if s[i+1]==0 and s[i+1] == s[i]:
    	s[i+1]=1
    	x +=1
    elif s[i+1]==1 and s[i+1]==s[i]:
    	s[i+1]=0
    	x +=1
    
for i in range(n-1):
    if t[i+1]==0 and t[i+1] == t[i]:
    	t[i+1]=1
    	y +=1
    elif t[i+1]==1 and t[i+1]==t[i]:
    	t[i+1]=0
    	y +=1

print(min([x,y]))

Measured memory_bytes: 4852
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <math.h>
#include <numeric>
#include <iomanip>
#include <map>
#include <queue>
#include <list>


#define REP(i, n ,N) for(ll i = (n); i < (N); i++)
//#define RREP(i, n ,N) for(ll i = (N-1); i >= (n); i--)
#define p(s) cout<<(s)<<endl
#define p2(a, b) cout<<(a)<<" "<<(b)<<endl
#define vint vector<int>
#define INF 1e9

using namespace std;
typedef long long  ll;

int main(){
    int n;
    cin >> n;
    vector<double > v(n);
    REP(i, 0, n){
        cin >> v[i];
    }

    sort(v.begin(), v.end());
    double ans = (v[0] + v[1])/2;
    REP(i, 2, n){
        ans = (ans + v[i])/2;
    }

    cout << fixed << setprecision(20) << ans << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
 
         
        public static void main(String[] args) throws java.io.IOException{
            Scanner scan = new Scanner(System.in);
            while (true){
            	int n =scan.nextInt();
            	if(n==0)break;
            	int a=0;
            	int b=0;
            	
            	for(int i=0;i<n;i++){
            		int sa=scan.nextInt();
                	int sb=scan.nextInt();
            	if(sa==sb){
            		a+=sa;
            		b+=sb;
            	}
            	else if(sa>sb)a+=sa+sb;
            	else b+=sa+sb;
            	}
            	System.out.println(a+" "+b);
            	
            }
        }
}

Measured memory_bytes: 12000
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx2")
#pragma GCC optimize("Os")
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);
#define FO cout.tie(NULL);
#define FI cin.tie(NULL);
#define IN cin>>
#define OUT cout<<
#define loop(i,a,n) for(int i=a; i<n; i++)
#define rloop(i,a,n) for(int i=a; i>=n; i--)
#define endl "\n";
#define pb push_back
#define mp make_pair
#define set_bits(a) __builtin_popcountll(a)
#define ll long long int
#define ld long double
#define vll vector<long long int>
#define pll pair<long long int, long long int>
#define mod 1000000007
#define M 998244353
using namespace std;
ll gcd(ll a, ll b)
{
    return (b?gcd(b,a%b):a);
}
ll P(ll B, ll power, ll modulo)
{
    ll ans=1LL;
    while(power>0LL)
    {
        if(power%2LL==1LL)
        {
            ans=(ans*B)%modulo;
        }
        B=(B*B)%modulo;
        power/=2LL;
    }
    return ans;
}
bool isPrime(ll n)
{
    if(n<=1LL)
    {
        return false;
    }
    if(n<=3LL)
    {
        return true;
    }
    if(n%2==0LL || n%3==0LL)
    {
        return false;
    }
    for(ll i=5LL; (i*i)<=n; i+=6LL)
    {
        if(n%i==0LL || n%(i+2LL)==0LL)
        {
            return false;
        }
    }
    return true;
}
void vok()
{
    FAST
    FO
    FI
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
        freopen("error.txt","w",stderr);
    #endif
}
int main()
{
    vok();
    int t;
    IN t;
    while(t--)
    {
        int n;
        IN n;
        vector<array<ll,3>> v(n);
        vector<int> curr[n+3], next[n+3];
        loop(i,0,n)
        {
            IN v[i][0]>>v[i][1]>>v[i][2];
            curr[v[i][0]].pb(i);
            next[v[i][0]+1].pb(i);
        }
        ll ans=0;
        set<pll> s;
        vector<bool> vis(n,false);
        rloop(i,n,1)
        {
            for(auto x:curr[i])
            {
                s.insert({v[x][1]-v[x][2],x});
            }
            if(!s.empty())
            {
                pll topp=*s.rbegin();
                if(topp.first>0)
                {
                    vis[topp.second]=true;
                    s.erase(topp);
                }
            }
        }
        s.clear();
        loop(i,1,n+1)
        {
            for(auto x:next[i])
            {
                s.insert({v[x][2]-v[x][1],x});
            }
            if(!s.empty())
            {
                pll topp=*s.rbegin();
                if(topp.first>0)
                {
                    vis[topp.second]=true;
                    s.erase(topp);
                }
            }
        }
        loop(i,0,n)
        {
            if(vis[i])
            {
                ans+=max(v[i][1],v[i][2]);
            }
            else
            {
                ans+=min(v[i][1],v[i][2]);
            }
        }
        OUT ans<<endl
    }
    return 0;
}

Measured memory_bytes: 30880
#include <stdio.h>

int main(){
    int y,m,d;
    scanf("%4d/%2d/%2d/",&y,&m,&d);
    if(y>2019) printf("TBD\n");
    else if(m>=5) printf("TBD\n");
    else printf("Heisei\n");

    return 0;
} 

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

long long Lucas(int n) {
	const int MAX_VAL = 87;
	long long result[MAX_VAL];

	result[0] = 2;
	result[1] = 1;
	for (int i = 2; i <= n; i++)
		result[i] = result[i - 1] + result[i - 2];
	return result[n];

}

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

	cout << Lucas(N) << endl;

	return 0;
}

Measured memory_bytes: 256
/*************************************************************************
	> File Name: abc120_a.cpp
	> Author: 
	> Mail: 
	> Created Time: 2019年03月03日 星期日 20时00分18秒
 ************************************************************************/

#include<iostream>
using namespace std;
int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    if((b/a)>c)
    cout<<c<<endl;
    else cout<<b/a<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <queue>
#include <vector>
#include <algorithm>
#include <cmath>
#include <chrono>

#define MOD (int64_t)(1e+9 + 7)

using namespace std;

int main(int argc, const char * argv[]) {
    
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int64_t n, m; cin >> n >> m;
    
    if (m == 1) {
        cout << 1 << endl;
        return 0;
    }
    
    map<int64_t, int64_t> mp;
    int64_t a = m;
    bool flag = 1;
    while (flag) {
        flag = 0;
        for (int64_t i = 2; i <= (int64_t)sqrt((double)a); i++) {
            if (a % i == 0) {
                mp[i]++;
                a /= i;
                flag = 1;
                break;
            }
        }
        if (!flag) {
            mp[a]++;
            break;
        }
    }
    
    vector<vector<int64_t>> comb(n + 30, vector<int64_t>(31, 0));
    comb[0][0] = 1;
    for (int i = 0; i < n + 30 - 1; i++) {
        for (int j = 0; j <= 30; j++) {
            if (j == 0) comb[i + 1][j] = 1;
            else comb[i + 1][j] = (comb[i][j - 1] + comb[i][j]) % MOD;
        }
    }
    
    int64_t ans = 1;
    for (auto &iter : mp) {
        int64_t p = iter.second;
        ans *= comb[p + n - 1][p];
        ans %= MOD;
    }
    
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 27648
# coding: utf-8
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N, M = lr()
A = lr()
BC = [lr() for _ in range(M)]
BC.sort(key=lambda x: x[1], reverse=True)
D = []
count = 0
for b, c in BC:
    A.extend([c] * b)
    count += b
    if count >= N:
        break

A.sort(reverse=True)
answer = sum(A[:N])
print(answer)


Measured memory_bytes: 34880
#include<bits/stdc++.h>
using namespace std;
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define SZ(x) ((int)(x).size())
#define debug(x) cerr << #x << ": " << x << '\n'
#define INF 999999999
typedef long long int Int;
typedef pair<int,int> P;
using ll = long long;
using VI = vector<int>;
int ans = 0;
vector<string> an;

int main(){
    string s;cin >> s;
    string prev="";
    int i=0;
    int ans = 0;    
    string c = "";
    while(i<s.size()){
        c+=s[i];
        if(prev==c){
            i+=1;
            if(i==s.size()){
                break;
            }
        }else{
            //debug(c);
            prev = c;
            c="";
            ans+=1;
            i+=1;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <cmath>
#include <stack>
#include <vector>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
#define all(a) a.begin(),a.end()
#define pb push_back
#define mp make_pair
const int N = 100001;
int t;
int n,k;
int a[N],dp[N];
int main(){
    cin>>n;
    for(int i=0;i<n;i++)
        scanf("%d",a+i);
    dp[1]=abs(a[1]-a[0]);
    for(int i=2;i<n;i++)
        dp[i]=min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i]-a[i-2]));
    cout<<dp[n-1];
}


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

using namespace std;

int main() {
  int k;
  cin >> k;
  int a[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  cout << a[k - 1] << '\n';
  return 0;
}



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

int main()
{
    char c;
    cin >> c;
    if (c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o')
    {
        cout << "vowel" << endl;
    }
    else
    {
        cout << "consonant" << endl;
    }
}


Measured memory_bytes: 256
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort(reverse=True)
    return divisors

N, M = map(int, input().split())
L = make_divisors(M)
for l in L:
    if M // l >= N:
        print(l)
        exit()
print(1)

Measured memory_bytes: 3060
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <numeric>
#include <string>
#include <vector>
#include <iostream>
#include <forward_list>
using namespace std;

#define SCAN_INT(i) scanf("%d", i)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define PRINT_INT(i) printf("%d\n", i)
#define PRINT_TWO_INT(i, j) printf("%d %d\n", i, j)
#define PRINT_THREE_INT(i, j, k) printf("%d %d %d\n", i, j, k)

void foo(int *a, int *aa)
{
    *aa = (*a / 10 + 1) * 10;
    if (*a % 10 == 0)
        *aa -= 10;
}

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

    int aa, bb, cc, dd, ee;
    foo(&a, &aa);
    foo(&b, &bb);
    foo(&c, &cc);
    foo(&d, &dd);
    foo(&e, &ee);

    int moda = a % 10, modb = b % 10, modc = c % 10, modd = d % 10, mode = e % 10;
    int m = 10;
    if (moda != 0)
        m = min(moda, m);
    if (modb != 0)
        m = min(modb, m);
    if (modc != 0)
        m = min(modc, m);
    if (modd != 0)
        m = min(modd, m);
    if (mode != 0)
        m = min(mode, m);

    PRINT_INT(aa + bb + cc + dd + ee + m - 10);
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>


int main(void){
  char s[1001], order[8], ch[1001];
  int i, j, n, a, b;

  scanf("%s\n%d", s, &n);

  for(i=0;i<n;i++){
    scanf("%s %d %d", order, &a, &b);
    
    if(!strcmp(order, "reverse")){
      for(j=a;j<=b;j++)
        ch[b-j] = s[j];
      for(j=a;j<=b;j++)
        s[j] = ch[j-a];
    }

    if(!strcmp(order, "replace")){
      scanf("%s", ch);
      for(j=0;ch[j]!='\0';j++)
        s[a+j] = ch[j];
    }

    if(!strcmp(order, "print")){
      for(j=a;j<=b;j++)
        printf("%c", s[j]);
      printf("\n");
    }
  }

  return 0;
}


Measured memory_bytes: 2104
import sys
N, K = map(int, sys.stdin.readline().split())
A = list(map(int, sys.stdin.readline().split()))

x = A[0]
visited = [0] * N
visited[0] = 1
visited_num = [1]
for i in range(N):
    if visited[x - 1] == 1:
        b = i + 1
        break
    visited[x - 1] = 1
    visited_num.append(x)
    x = A[x - 1]
    
for j, p in enumerate(visited_num):
    if p == x:
        a = j
        
if K < a:
    ans = visited_num[K]
else:
    n = (K - a) % (b - a)
    ans = visited_num[a + n]
    
print(ans)

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

int main(){
    int N;
      cin >> N;
      int A[N];
      int z=0;
      rep(i,N)cin >> A[i];
      sort(A,A+N);
      rep(i,N){
          rep(j,N-i){
              if(A[N-i] == A[N-i-j-1])z=1;
              break;
          }
      }
      if(z==1)cout << "NO";
      else cout << "YES";
	return 0;
}

Measured memory_bytes: 1024
from collections import defaultdict as dd
n, m = map(int, input().split())

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

uf = UnionFind(n+1)
for i in range(m):
    a, b = map(int, input().split())
    uf.union(a, b)

max_mem = 0
for i in range(n+1):
    max_mem = max(max_mem, uf.size(i))
print(max_mem)


Measured memory_bytes: 75444
N, K = map(int, input().split())
x = list(map(int, input().split()))
d = 2 * (x[-1] - x[0])
for i in range(N-K+1):
    d = min(d, abs(x[i]) + abs(x[i + K - 1] - x[i]),abs(x[i + K -1]) + abs(x[i + K - 1] - x[i]))
print(d)

Measured memory_bytes: 14252
import sys
input = lambda: sys.stdin.readline().rstrip()

def main():
    antennas = [int(input()) for _ in range(5)]
    k = int(input())
    for i in range(4):
        for j in range(i+1, 5):
            if antennas[j] - antennas[i] > k:
                print(":(")
                return
    print("Yay!")
        
if __name__ == '__main__':
    main()

Measured memory_bytes: 9068
#include<iostream>
#include<vector>

using namespace std;

vector<int> f(int H,int h,int m){
  int n=60*h+(1+H)*m;
  int ad=60*H;
  vector<int> cand;
  if((n>=ad)){
    cand.assign({n-ad,n});
  }else{
    cand.assign({n,n+ad});
  }
  vector<int> r;
  for(auto e:cand){
    int D=119*H-1;
    if((H-1)*(D*m+e)==60*D*h)continue;
    r.push_back(e);
  }
  return r;
}

int gcd(int a,int b){
  return b?gcd(b,a%b):a;
}

void output(int h,int m,int ns,int d,int H){
  while(ns>=d){
    ns-=d;
    m++;
    if(m==60){
      m=0;
      h++;
      if(h==H){
	h=0;
      }
    }
  }
  int s=ns*60;
  if(s==0){
    d=1;
  }else{
    int g=gcd(s,d);
    s/=g;
    d/=g;
  }
  cout<<h<<' '<<m<<' '<<s<<' '<<d<<endl;
}
 
int main(){
  for(int H,h,m,s;cin>>H>>h>>m>>s,H|h|m|s;){
    auto r=f(H,h,m);
    int d=119*H-1;
    for(auto e:r){
      if(e*60>=s*d){
	output(h,m,e,d,H);
	goto next;
      }
    }
    s=0;
    m++;
    if(m==60){
      m=0;
      h++;
      if(h==H){
	h=0;
      }
    }
    output(h,m,f(H,h,m)[0],d,H);
  next:
    ;
  }
}

Measured memory_bytes: 1212
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = (a); i <= (b); i++)
#define rng(a) a.begin(), a.end()
#define ina(n,a) cin >> n; for(int i = 1; i <= n; i++) cin >> a[i]
#define sz(x) (int)(x).size()
#define se second
#define fi first
#define prev            coyhhhhhhyoc    
#define next          sdNNNmNNNNNNNmds  
#define y0           hNNNNy_yNNNNNN_sNh
#define y1          mNNNNNdtdNNNNNNtsNNm
#define yn          mNNNNNNNNy___smNNNms
#define tm            oooooosyysooooot 
#define read               tyhyt        
#define rank              ytmNmo         
#define index              yyy
#define pb push_back
#define pcnt __builtin_popcountll
#define rrep(i,a,b) for(int i = (b); i >= (a); i--)
#define rall(x,a) for(auto x : a)
#define MOD 1000000007
#define endl "\n"
typedef long long ll;
using namespace std;

const int N = 111;
int a[N];
int n;

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> n;
    rep(i, 1, n) {
        cin >> a[i];
    }
    int ans = 0;
    rep(i, 1, n) {
        ans += (i & 1) && (a[i] & 1);
    }
    cout << ans << endl;
    return 0;
}


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

// a^bを返す
ll powder(ll a,ll b){
  ll n = 1;
  for (ll i=0; i<b; i++){
    n = n * a % 998244353;
  }
  return n;
}

int main() {
  int n; cin >>n;
  ll ans = 0;
  const ll divi = 998244353;
  bool ok = true;
  vector<int> d(n);
  for (int i=0; i<n; i++){
    cin >>d.at(i);
    if (i==0 && d.at(i)!=0){
      ok = false; break;
    }else if (i!=0 && d.at(i)==0){
      ok = false; break;
    }
  }
  /* 距離は0, 1, 1, ..., 2,2, ..., 3, ...というふうに
    1～xのうち全てが存在する必要がある。
  */
  sort(d.begin(), d.end());
  vector<int> dd(n);
  dd.at(0) = 1;
  
  for (int i=1; i<n; i++){
    if (d.at(i)>d.at(i-1)+1){
      ok = false; break;
    }
    dd.at(d.at(i))++;
  }
  // dd: 距離iの点がdd.at(i)子ある
  if (!ok){ ans = 0;
  }else if (n==1){ ans = 1;
  }else if (d.at(0)==0 && d.at(1)!=0){
    ans = 1;
    for (int i=1; i<n; i++){
      if (dd.at(i)==0){
        break;
      }else{
        ans = ans * powder(dd.at(i-1),dd.at(i)) % divi;
      }
    }
  }else{
    ans = 0;
  }
  cout <<ans <<endl;
}


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

a = (A * 100 + 7) // 8
b = ((A+1) * 100 + 7) // 8 - 1
c = B * 10
d = (B+1) * 10 - 1

ma = min(b, d)
mi = max(a, c)
print(mi if mi <= ma else -1)

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

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

    std::cout<<std::min(a, b) + std::min(c, d)<<std::endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
 
using namespace std;
 
using int64 = long long;
 
int main()
{
  int N;
  cin >> N;
  // 4/N = 1/h + 1/n + 1/w
  // 4/N hnw = hnw(1/h + 1/n + 1/w)
  // 4/N hnw = nw + hw + hn
  // 4 hnw = Nnw + Nhw + Nhn
  // 4 hnw - Nnw - Nhw = Nhn
  // (4 hn - Nn - Nh) w = hnN
 
  for(int h = 1; h <= 3500; h++) {
    for(int n = 1; n <= 3500; n++) {
      int64 mother = 4LL * h * n - N * n - N * h;
      if(mother > 0 && 1LL * h * n * N % mother == 0) {
        cout << h << " " << n << " " << 1LL * h * n * N / mother << endl;
        return (0);
      }
    }
  }
}

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

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

  int n, k; cin >> n >> k;
  if( k == 1 ) cout << 0 << '\n';
  else cout << n - k << '\n';

  return 0;
}

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

int main(){
  string s;
  int i;
  int k = 0;
  cin >> s;
  for( i = 0 ; i < 3 ; i++){
    if(s.at(i) == '1'){
      k++;
    }
  }
  cout << k << endl;
}

Measured memory_bytes: 256
def f(x):
  J=0
  I=0
  for i in range(len(x)-2):
    if x[i:i+3]=='JOI':
      J=J+1
    if x[i:i+3]=='IOI':
      I=I+1
  print(J)
  print(I)

while True:
  try:
    f(input())
  except:
    break


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

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

  vector<string> s(n);
  rep(i, n) cin >> s[i];
  map<string, int> cnt;

  for (string result : s) {
    cnt[result]++;
  }

  printf("AC x %d\n", cnt["AC"]);
  printf("WA x %d\n", cnt["WA"]);
  printf("TLE x %d\n", cnt["TLE"]);
  printf("RE x %d\n", cnt["RE"]);
  return 0;
}

Measured memory_bytes: 6428
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<map>
#include<tuple>
#include<cmath>


#define MOD 1000000007
#define rep(i,k,N) for(int i=k;i<N;i++)
#define MP make_pair
#define MT make_tuple //tie,make_tuple は別物
#define PB push_back

typedef long long ll;

using namespace std;

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

void YN(bool ans){
    if(ans)cout<<"Yes"<<endl;
    else cout <<"No"<<endl;
    return;
}

int main(){
    int a,b;
    cin>>a>>b;
    int N=1,b_=b;
    while(b_>=1){
        b_/=10;
        N*=10;
    }
    int X =a*N+b;
    bool ans=false;
    rep(i,0,1000){
        if(i*i==X)ans=true;
    }
    YN(ans);
    return 0;
}

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

typedef long long int int64;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))

void run(void){
  char *s=(char *)malloc(sizeof(char)*(100000+1));
  scanf("%s",s);
  int n=0;
  while(s[n]!='\0') n++;
  char *t[]={"dream","dreamer","erase","eraser"};
  int len[]={5,7,5,6};
  while(n>0){
    int i;
    for(i=0;i<4;i++){
      if(n<len[i]) continue;
      int j;
      for(j=0;j<len[i];j++){
	if(s[n-len[i]+j]!=t[i][j]) break;
      }
      if(j>=len[i]){
	n-=len[i];
	break;
      }
    }
    if(i==4){
      printf("NO\n");
      return;
    }
  }
  printf("YES\n");
}

int main(void){
  run();
  return 0;
}


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

typedef long long ll;
typedef pair<ll,ll> P;

const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;

#define rep(i, a, b) for(ll (i) = (a); (i) < (b);++i)

int main() {
	ll F;
	cin >> F;
	cout << (F - 30) / 2 << endl;
	return 0;
}



Measured memory_bytes: 3108
#include <algorithm>     //sort,二分探索,など
#include <bitset>        //固定長bit集合
#include <cmath>         //pow,logなど
#include <complex>       //複素数
#include <deque>         //両端アクセスのキュー
#include <functional>    //sortのgreater
#include <iomanip>       //setprecision(浮動小数点の出力の誤差)
#include <iostream>      //入出力
#include <iterator>      //集合演算(積集合,和集合,差集合など)
#include <map>           //map(辞書)
#include <numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include <queue>         //キュー
#include <set>           //集合
#include <stack>         //スタック
#include <string>        //文字列
#include <unordered_map> //イテレータあるけど順序保持しないmap
#include <unordered_set> //イテレータあるけど順序保持しないset
#include <utility>       //pair
#include <vector>        //可変長配列

using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= (ll)(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= (ll)(b); i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(), (x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())      //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))   //最大値を求める
#define MIN(x) *min_element(ALL(x))   //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 10000007      //10^9+7:合同式の法
#define MAXR 100000       //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first      //pairの一つ目の要素
#define S second     //pairの二つ目の要素

signed main()
{
    int N, K;
    cin >> N >> K;
    vector<int> A(N);

    int I;

    REP(i, N)
    {
        cin >> A[i];
        //cout << A[N];
        if (i == 1)
            I = i;
    }

    //N / (K - 1);

    int C = ceil((float)(N-1)/(float)(K-1));


    cout << C << endl;
}

Measured memory_bytes: 640
#include<stdio.h>
#include<math.h>
#include<stdlib.h>

//D日目時点のスコアを計算
int score(int D, int c[], int s[][26], int t[]){
    int pen_day[26];
    for(int i=0; i<26; i++){
        pen_day[i]=1;
    }
    int score=0;
    
    for(int i=0; i<D; i++){
        int type=t[i]-1;
        pen_day[type]=0;
        //満足度増加
        score+=s[i][type];
        //満足度低下
        for(int j=0; j<26; j++){
            int dec=c[j]*pen_day[j];
            score-=dec;
        }
        //日数追加
        for(int j=0; j<26; j++){
            pen_day[j]++;
        }        
    }
    return score;
}

//満足度の変移
int hen_pen(int st, int end, int c[], int s[][26], int t[], int type1, int type2){
    int sum=0;
    int de_type1=0;
    int de_type2=0;
    int last1=0, last2=0;

    for(int i=st; i<=end; i++){
        if(t[i]==type1){
            de_type1++;
            last1=i;
        }
        if(t[i]==type2){
            de_type2++;
            last2=i;
        }
    }

    sum+=c[type1]*de_type1;
    sum+=c[type2]*de_type2;
    sum+=(end-last1)*c[type1];
    sum-=(last2-st)*c[type2];

    return sum;
}

void Greedy(int D, int c[], int s[][26]){
    int t[D], max_type=0, max_score=0;

    for(int i=0; i<D; i++){
        max_score=0;
        for(int j=0; j<26; j++){
            t[i]=j+1;
            int S=score(i+1, c, s, t);
            if(max_score < S){
                max_score = S;
                max_type=j+1;
            }
        }
        t[i]=max_type;
    }

    //局所探索
    int tmp;
    int roop_num=0;
    int MAX=max_score;
    while(1){
        int a=rand()%D;
        int b=rand()%D;

        if(a>b){
            tmp=a;
            a=b;
            b=tmp;
        }

        //t[a],t[b]を入れ替え
        tmp=t[a];
        t[a]=t[b];
        t[b]=tmp;

        //scoreを計算
        /*
        int now_score=score(b+1, c, s, t);
        if(MAX<now_score) MAX=now_score;
        else{
            tmp=t[a];
            t[a]=t[b];
            t[b]=tmp;  
        }
*/
        int sa=hen_pen(a, b, c, s, t, t[b], t[a]);
        if(sa <= 0){
            tmp=t[a];
            t[a]=t[b];
            t[b]=tmp; 
        }

        roop_num++;
        if(roop_num==D*10000) break;
    }

    for(int i=0; i<D; i++){
        printf("%d\n", t[i]);
    }
}

int main(void){
    int D, c[26], s[365][26];

    //入力
    scanf("%d", &D);
    for(int i=0; i<26; i++){
        scanf("%d", &c[i]);
    }
    for(int i=0; i<D; i++){
        for(int j=0; j<26; j++){
            scanf("%d", &s[i][j]);
        }
    }

   /*ここから処理*/
   /*
    int num=1;
    for(int i=0; i<D; i++){
        printf("%d\n", num);
        num++;
        if(num>26) num=1;
    }
    */

   Greedy(D, c, s);


    return 0;
}

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

using namespace std;

typedef long long ll;

int main(int, char**)
{
	vector<ll> c;
	vector<pair<ll, ll>> op;
	ll  n, m;
	cin >> n >> m;
	c.resize(n);
	op.resize(m);
	for (int i = 0; i < n; ++i) {
		cin >> c[i];
	}
	sort(c.rbegin(), c.rend());
	for (int i = 0; i < m; ++i) {
		cin >> op[i].second >> op[i].first;
	}
	sort(op.rbegin(), op.rend());

	ll ans = 0;
	int x = 0, y = 0, z = 0;
	while (z < n) {
		if (c[x] >= op[y].first) {
			ans += c[x];
			x++;
			z++;
		} else {
			if (op[y].second >= (n - z)) {
				ans += op[y].first * (n - z);
				z = n;
			} else {
				ans += op[y].first * op[y].second;
				z += op[y].second;
				y++;
			}
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 2560
/*|In The Name Of Allah|*/

#include <bits/stdc++.h>

using namespace std;

const int N = 4e2+5;

const int mod = 1e9+7;

int n;
int ar[N];
long long prefix[N];
long long mem[N][N];

long long getsum(int l , int r){
    return prefix[r] - prefix[l - 1];
}

long long go(int l , int r){
    if(r - l + 1 == 2)
        return getsum(l , r);
    if(l >= r)
        return 0;
    if(~mem[l][r])
        return mem[l][r];
    long long best = 1e18;
    for(int i = l; i < r; i++){
        best = min(best , go(l , i) + go(i + 1 , r) + getsum(l , i) + getsum(i + 1 , r));
    }
    return mem[l][r] = best;
}

int main(){
    scanf("%d" , &n);
    for(int i = 1; i <= n; i++){
        scanf("%d" , &ar[i]);
        prefix[i] = ar[i] + prefix[i - 1];
    }
    memset(mem , -1 , sizeof mem);
    printf("%lld\n" , go(1 , n));
}


Measured memory_bytes: 1536
// B - Sum of Three Integers
#include <bits/stdc++.h>
using namespace std;

int main(){
	int k,s; cin>>k>>s;
	int ans = 0;

	if(s<=k){//(0<=s && s<=k)
		ans = (s+1)*(s+2)/2;
	}
	else if(k<s && s<=2*k){
		ans = (2*k-s+1)*(2*s-k+1)+(s-k-1)*(s-k)-k*(k+1)/2;
	}
	else{//(2k<s && s<=3k)
		ans = (3*k-s+1)*(2*k-s+1)+k*(k+1)/2-(s-2*k-1)*(s-2*k)/2;
	}

	cout<< ans <<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    string b;
    cin >> b;
    string ans;
    if(b=="SUN"){
      ans = "7";
    }else if(b=="MON"){
      ans = "6";
    }else if(b=="TUE"){
      ans = "5";
    }else if(b=="WED"){
      ans = "4";
    }else if(b=="THU"){
      ans = "3";
    }else if(b=="FRI"){
      ans = "2";
    }else if(b=="SAT"){
      ans = "1";
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
//To debug :  g++ -g file.cpp -o code
//to flush output : fflush(stdout) or cout.flush()
//cout<<setprecision(p)<<fixed<<var
//use 1LL<<i to for 64 bit shifting , (ll)2 because by default 2 is ll
//take care of precedence rule of operators 
//do not forget to change the sizes of arrays and value of contants and other things after debugging  
 
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,a,n) for(i=a;i<n;++i)
#define irep(i,n,a) for(i=n;i>a;--i)
#define mod 1000000007
#define pb push_back
#define big 9223372036854775807
#define big1 LONG_MAX
#define big2 ll_MAX
#define big3 1000000000
#define sma1 LONG_MIN
#define sma2 ll_MIN
#define sma3 -1000000000
#define mp make_pair
#define dub double
#define ivec vector<ll>
#define lvec vector<long long>
#define cvec vector<char>
#define svec vector<string>
#define mt make_tuple
#define MOD 998244353
#define ld long double
#define pi acos(-1.0)
 
#define SZ(x)  (ll)(x.size())
 
//comment the below if not required
 
/*
 
#define ss second.second
#define ff first.first
#define f first
#define s second
#define sf second.first
#define fs first.second
*/
 
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)

int main()
{

    int n,x,t;

    cin>>n>>x>>t;

    cout<<(int)(ceil(n/(1.0*x))*t);


    return 0;
}

Measured memory_bytes: 3620
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);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; }

typedef long long ll;

using namespace std;




int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout<<setprecision(10);
  int n;
  cin>>n;
  vector<int>a(n),b(n),c(n);
  rep(i,n)cin>>a[i];
  rep(i,n)cin>>b[i];
  rep(i,n)cin>>c[i];
  sort(all(a));
  sort(all(b));
  sort(all(c));
  ll res=0;
  vector<ll>mb(n);
  rep(i,n)
  {
    auto itr=upper_bound(all(c),b[i]);
    mb[i]=c.end()-itr;
  }
  for(int i=n-1;i>=1;i--)
  {
    mb[i-1]+=mb[i];
  }
  rep(i,n)
  {
    auto itr=upper_bound(all(b),a[i]);
    res+=mb[itr-b.begin()];
  }

  cout<<res<<endl;
  return 0;

}


Measured memory_bytes: 2176
'use strict';

const receive = require('fs')
  .readFileSync('/dev/stdin', 'utf8')
  .split(/\n/);

const main = input => {
  const N = input[0];
  const A = input[1].split(/ /).map(x => Number(x));
  const max = Math.max(...A);
  const min = Math.min(...A);
  const ans = max - min;
  console.log(ans);
};

main(receive);

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

using namespace std;
int main() {
	int N,x;
	int vet[10];
	scanf("%d", &N);
	memset(vet,0,sizeof(vet));
	for (int i = 0;i < N;i++) {
		scanf("%d", &x);

		if (x < 400){
			vet[0]=1;
		}else if (x < 800){
			vet[1]=1;
		}else if (x < 1200){
			vet[2]=1;
		}else if (x < 1600){
			vet[3]=1;
		}else if (x < 2000){
			vet[4]=1;
		}else if (x < 2400){
			vet[5]=1;
		}else if (x < 2800){
			vet[6]=1;
		}else if (x < 3200){
			vet[7]=1;
		}else{
			vet[8]++;
		}
	}
	int min = vet[0]+vet[1]+vet[2]+vet[3]+vet[4]+vet[5]+vet[6]+vet[7];
	printf("%d %d\n", min>0?min:1,min+vet[8] );
}

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

using namespace std;

int main(){

    string moji;
    int m, h;

    while(1){
        cin >> moji;
        if( moji == "-") break;
        cin >> m;

        for(int i=0; i<m; i++){
            cin >> h;
            moji = moji.substr(h) + moji.substr(0,h);
        }

        cout << moji << endl;
    }


    return 0;
}

Measured memory_bytes: 3140
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define FOR(i, a, b) for(ll i = a; i < b; i++)
#define rep(i, n) FOR(i, 0, n)
#define rFOR(i, a, b) for(ll i = a - 1; i >= b; i--)
#define rrep(i, a) rFOR(i, a, 0)
#define pb push_back
using namespace std;
using ll = long long;
using ld = long double;
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vP;
typedef vector<char> vc;
typedef vector<vc> vvc;
const ll MOD = 1000000007;
const ll MOD2 = 998244353;
const ld PI = acos(-1);
const ll INF = 1e18;
struct edge{ll to, cost;};

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

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    string s;
    cin >> s;
    if(s[s.size()-1]=='s'){
        s+="es";
    }
    else{
        s+='s';
    }
    cout << s << endl;
}
/*
overflow checked?
corner case checked?
boundary checked?
not TLE in worst case checked?
*/

Measured memory_bytes: 3664
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric, std.container;

long P = 10^^9+7;
long[1001] F, RF;

long pow(long x, long n) {
    long y = 1;
    while (n) {
        if (n%2 == 1) y = (y * x) % P;
        x = x^^2 % P;
        n /= 2;
    }
    return y;
}

long inv(long x)
{
    return pow(x, P-2);
}

void init()
{
    F[0] = F[1] = 1;
    foreach (i, ref x; F[2..$]) x = (F[i+1] * (i+2)) % P;

    {
        RF[$-1] = 1;
        auto x = F[$-1];
        auto k = P-2;
        while (k) {
            if (k%2 == 1) RF[$-1] = (RF[$-1] * x) % P;
            x = x^^2 % P;
            k /= 2;
        }
    }
    foreach_reverse(i, ref x; RF[0..$-1]) x = (RF[i+1] * (i+1)) % P;
}

long comb(N)(N n, N k)
{
    if (k > n) return 0;
    auto n_b = F[n];    // n!
    auto nk_b = RF[n-k]; // 1 / (n-k)!
    auto k_b = RF[k];    // 1 / k!

    auto nk_b_k_b = (nk_b * k_b) % P; // 1 / (n-k)!k!

    return (n_b * nk_b_k_b) % P;  // n! / (n-k)!k!
}

long perm(N)(N n, N k)
{
    if (k > n) return 0;
    auto n_b = F[n];
    auto n_k_b = RF[n-k];
    return (n_b * n_k_b) % P;
}

void main()
{
    init();
    auto nk = readln.split.to!(long[]);
    auto N = nk[0];
    auto K = nk[1];
    if (K > N) {
        writeln(0);
        return;
    }
    long r;
    foreach (e; 0..K) {
        (r += comb(K, e) * pow(K-e, N) % P * (-1)^^e + P) %= P;
    }
    writeln(r);
}


Measured memory_bytes: 2492
n=int(raw_input())
a=map(int,raw_input().split())
if max(a)-min(a)>=2:
    print "No"
    exit()
if max(a)==min(a):
    if max(a)==n-1:
        print "Yes"
    elif max(a)*2>n :
        print "No"
    else:
        print "Yes"
    exit()
cntmx=a.count(max(a))
cntmn=a.count(min(a))
if cntmn>=max(a):
    print "No"
elif (max(a)-cntmn)*2>n-cntmn:
    print "No"
else:
    print "Yes"


Measured memory_bytes: 11304
#include<bits/stdc++.h>
using namespace std;
using ll = int64_t;
template <typename T>
class Bit{
    private:
        ll size;
        T *data;
        T identity_ele;

    public:

        Bit(ll size, T identity_ele){
            ll newsize = 1;
            while(newsize < size)  newsize = newsize << 1;
            this->size = newsize + 1;
            this->identity_ele = identity_ele;
            data = new ll[this->size];
            for(ll i = 0; i < size; ++i){
                data[i] = identity_ele;
            }
        }

        /*
         * 0-origin
         */
        T sum(ll pos){
            pos++;
            T ret = identity_ele;
            while(pos > 0){
                ret += data[pos];
                pos -= pos & -pos;
            }
            return ret;
        }

        /*
         * 0-origin
         */
        void add(ll pos, T delta){
            pos++;
            while(pos <= size){
                data[pos] = data[pos] + delta;
                pos += pos & -pos;
            }
        }
};

const ll INF = 5e15;

int main(){
    ll N;
    cin >> N;
    vector<ll> white(N + 1), black(N + 1);
    for(ll i = 0; i < 2 * N; i++){
        char c;
        ll a;
        cin >> c >> a;
        (c == 'W' ? white : black)[a] = i;
    }
    vector<vector<ll>> dp(N + 1, vector<ll>(N + 1, INF));
    Bit<ll> B(2 * N, 0);
    dp[0][0] = 0;
    for(ll update = 1; update <= 2 * N; update++){
        ll b = min(N, update - 1);
        ll w = (update - 1) - b;
        for(ll i = b + 1; i <= N; i++) B.add(black[i], 1);
        for(ll i = w + 1; i <= N; i++) B.add(white[i], 1);
        while(0 <= b && b <= N && 0 <= w && w <= N){
            if(0 <= b && b <= N && 0 <= w + 1 && w + 1 <= N) dp[w + 1][b] = min(dp[w + 1][b], dp[w][b] + B.sum(white[w + 1]) - 1);
            if(0 <= b + 1 && b + 1 <= N && 0 <= w && w <= N) dp[w][b + 1] = min(dp[w][b + 1], dp[w][b] + B.sum(black[b + 1]) - 1);
            if(w + 1 > N) break;
            B.add(black[b], 1);
            B.add(white[w + 1], -1);
            b--;
            w++;
        }
        for(ll i = b + 1; i <= N; i++) B.add(black[i], -1);
        for(ll i = w + 1; i <= N; i++) B.add(white[i], -1);
    }
    cout << dp[N][N] << endl;
    return 0;
}


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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
#ifdef LOCAL
	std::ifstream in("in");
	std::cin.rdbuf(in.rdbuf());
#endif

	int X, Y;
	cin >> X >> Y;

	cout << X + Y / 2 << endl;

}


Measured memory_bytes: 896