akhauriyash/Code-Regression huggingface dataset:
/*  
     author : masaow    
     g++ : 17.3.20  
*/        
#include <bits/stdc++.h>  
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#define forn(i,a,b)        for( i = a ; i < b  ; i++ )
#define debug(x)           cout << #x << " " << x << " -- \n"
#define ll                 long long  
#define p(x)               cout << x << "\n" ; 
#define pi                 pair<int,int>
#define vi                 vector <int>
#define pb                 push_back
#define vp                 vector <pair<ll,ll>>
#define endl               cout << "\n"
#define mi                 map <int,int> 
#define f1                 first 
#define s1                 second    
#define in                 insert
#define all(x)             x.begin(),x.end() 
using namespace std ; 
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set ; 
const int SIZE = 1e5+7 ;  
const int MOD = 1e9 +7 ; 
const int INF = 2e9+7 ;
/*  
    time : 08 : 48    
    date : 16...02...2020
*/ 
void I_O(){
    ios::sync_with_stdio(false) ;
    cin.tie(NULL);
    cout.tie(NULL);
}
int N,H,dp[SIZE],best = INF; 
int A[SIZE],i,B[SIZE] ; 
int tests(){
  cin >> H >> N  ;
  forn(i,0,SIZE)
    dp[i] = INF ; 
  int j  ; 
  dp[0] = 0 ;
  forn(i,0,N)
    cin >> A[i] >> B[i] ;
  forn(i,0,H+1)
    forn(j,0,N)
      dp[i+A[j]] = min(dp[i+A[j]],B[j]+dp[i]) ; 
   
  forn(i,H,SIZE)
    best  = min(best,dp[i]) ;
  cout << best  << '\n' ;   
  return  0 ;   
}
int main(){ 

    I_O() ;  
    int cases = 1 ;
    // cin >> cases;  
    while(cases--) 
      tests(); 
  return 0 ;
}
// web dev simplified
// LearnCode.Academy
/*
 g++ subminnnt.cpp -Wall -Wextra -pedantic
 -std=c++11 -O2 -Wshadow -Wformat=2 -Wfloat-equal
 -Wconversion -Wlogical-op -Wshift-overflow=2
 -Wduplicated-cond -Wcast-qual -Wcast-align -D_GLIBCXX_DEBUG
 -D_GLIBCXX_DEBUG_PEDANTIC -D_FORTIFY_SOURCE=2 -fsanitize=address 
 -fsanitize=undefined -fno-sanitize-recover -fstack-protec    
*/         
         
  

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

typedef long long ll;
int L,R;

int main(){
	cin >> L >> R;
	if(R-L>=2019) puts("0");
	else {
		ll ans=0x3f3f3f3f;
		for(int i=L;i<=R;i++)
			for(int j=i+1;j<=R;j++)
			ans=min(ans,1ll*i*j%2019);
		cout<<ans;
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static class Place implements Comparable<Place>{
		int number;
		int freq;
		
		Place(int n, int f){
			number = n;
			freq = f;
		}
		
		@Override
		public int compareTo(Place arg0) {
			return arg0.freq - this.freq;
		}
		
		
	}
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		while (true) {
			final int n = sc.nextInt();
			final int m = sc.nextInt();
			
			if(n == 0 && m == 0){
				break;
			}
			
			Place[] places = new Place[m];
			
			for(int i = 0; i < m; i++){
				places[i] = new Place(i+1, 0);
			}
			
			for(int i = 0; i < n; i++){
				for(int j = 0; j < m; j++){
					int t = sc.nextInt();
					if(t == 1){
						places[j].freq++;
					}
				}
			}
			
			Arrays.sort(places);
			boolean first = true;
			for(Place p : places){
				if(first){
					System.out.print(p.number);
					first = false;
				}else{
					System.out.print(" " + p.number);
				}
			}
			System.out.println();
		}
	}

}

Measured memory_bytes: 12000
#include <iostream>
#define LEN 101
using namespace std;
int TIME;
int d[LEN];
int f[LEN];
int num;
int graph[LEN][LEN] = {0};
void dfs(int x){
    TIME++;
    d[x] = TIME;
    for(int i=1;i<num+1;i++){
        if(graph[x][i] == 1 && d[i]==0){
            dfs(i);
        }
    }
    f[x] = ++TIME;
}
int main(){
    int hon;
    int eda;
    int ver;
    cin>>num;
    for(int i=0;i<num;i++){
        cin>>eda;
        cin>>hon;
        for(int j=0;j<hon;j++){
            cin>>ver;
            graph[eda][ver]++;
        }
    }
    for(int i=1;i<num+1;i++){
        if(d[i]==0)
            dfs(i);
    }
    for(int i=1;i<num+1;i++){
        cout<<i<<" "<<d[i]<<" "<<f[i]<<endl;
    }
    return 0;
}



Measured memory_bytes: 3128
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using namespace std;
int main() {
  string s;
  cin>>s;
  if(s=="ABC"){
    cout<<"ARC"<<endl;
  }
  else{
    cout<<"ABC"<<endl;
  }
      
}



Measured memory_bytes: 3628
import java.util.Scanner;
class Main
{
    public static void main(String args[])
    {
	Scanner scan=new Scanner(System.in);
	while(scan.hasNext())
	    {
		int n=scan.nextInt();
		n%=39;
		if(n==0)n=39;
		
		System.out.println("3C"+((n<10)?"0"+n:n));
	    }
    }
}

Measured memory_bytes: 15336
#include <stdio.h>

int main(){
  int a[1000];
  int n,i,j,alt;

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

  
  for(i=0;i<n;i++){
    alt=a[i];
    j=i-1;
    while(j>=0&&a[j]>alt){
      a[j+1]=a[j];
      j--;
    }
    a[j+1]=alt;
    for(j=0;j<n-1;j++){
      printf("%d ",a[j]);
    }
    printf("%d\n",a[j]);
  }

  return 0;
}

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

// macro
#define rep(i,n) for(i=0;i<n;i++)
#define ll long long
#define all(v) v.begin(), v.end()

// code starts
int main()
{
  int n,m;cin>>n>>m;
  vector<int> x(n);
  vector<int> y(n);
  int i,j;
  rep(i,n)cin>>x[i]>>y[i];
  vector<int> xl(m);
  vector<int> yu(m);
  vector<int> xr(m);
  vector<int> yd(m);
  rep(i,m)cin>>xl[i]>>yu[i]>>xr[i]>>yd[i];
  vector<int> xpress;
  vector<int> ypress;
  xpress=x;
  ypress=y;
  sort(all(xpress));
  sort(all(ypress));
  auto itx=unique(all(xpress));
  xpress.erase(itx,xpress.end());
  auto ity=unique(all(ypress));
  ypress.erase(ity,ypress.end());
  int nx=xpress.size();
  int ny=ypress.size();
  vector<vector<int>> fld(ny,vector<int>(nx,0));
  rep(i,n)
  {
    auto xind=lower_bound(all(xpress),x[i])-xpress.begin();
    auto yind=lower_bound(all(ypress),y[i])-ypress.begin();
    fld[yind][xind]++;
  }
  rep(i,ny)
  {
    rep(j,nx)
    {
      if(i-1>=0&&j-1>=0)
      {
        fld[i][j]+=fld[i-1][j]+fld[i][j-1]-fld[i-1][j-1];
      }
      else if(i-1>=0)
      {
        fld[i][j]+=fld[i-1][j];
      }
      else if(j-1>=0)
      {
        fld[i][j]+=fld[i][j-1];
      }
    }
  }
  rep(i,m)
  {
    int xlind=lower_bound(all(xpress),xl[i]-1)-xpress.begin();
    int xrind=lower_bound(all(xpress),xr[i])-xpress.begin();
    int yuind=lower_bound(all(ypress),yu[i]-1)-ypress.begin();
    int ydind=lower_bound(all(ypress),yd[i])-ypress.begin();
    if(!binary_search(all(xpress),xl[i]-1))xlind--;
    if(!binary_search(all(xpress),xr[i]))xrind--;
    if(!binary_search(all(ypress),yu[i]-1))yuind--;
    if(!binary_search(all(ypress),yd[i]))ydind--;
    int ans=0;
    if(ydind>=0&&xrind>=0)ans+=fld[ydind][xrind];
    if(yuind>=0&&xrind>=0)ans-=fld[yuind][xrind];
    if(ydind>=0&&xlind>=0)ans-=fld[ydind][xlind];
    if(yuind>=0&&xlind>=0)ans+=fld[yuind][xlind];
    cout<<ans<<endl;
  }

}




Measured memory_bytes: 108728
from sys import stdin
input = stdin.buffer.readline

def main():
    n = int(input())

    edges = [[] for _ in range(n)]
    for _ in range(n-1):
        u, v, w = map(int, input().split())
        edges[u-1].append((v-1, w%2))
        edges[v-1].append((u-1, w%2))

    ans = [-1] * n
    ans[0] = 0
    todo = [0]
    while len(todo) > 0:
        parent = todo.pop(-1)
        color = ans[parent]

        for child, w in edges[parent]:
            if ans[child] == -1:
                if w == 0:
                    ans[child] = color
                else:
                    ans[child] = 1 - color
                todo.append(child)

    for i in ans:
        print(i)

main()

Measured memory_bytes: 92616
#include<bits/stdc++.h>
using namespace std;
using lint = long long;
template<typename T = lint>inline T in() { T x; cin >> x; return x; }
#define INF           1e9
#define INFL          static_cast<lint>(INF)
#define REP(i,n)      for(lint i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)     for(lint i=1,i##_len=(n);i<=i##_len;++i)
#define REPI(i,ini,n) for(lint i=(ini),i##_len=(n);i<i##_len;++i)
#define REPC(i,obj)   for(auto i:obj)
#define R_UP(a,b)     (((a)+(b)-1)/(b))
#define ALL(obj)      (obj).begin(),(obj).end()
struct product
{
	lint value, weight, date;
	string type, name;
	product() {}
	product(lint v, lint w, string t, lint d, string n) :value(v), weight(w), type(t), date(d), name(n) {}
	bool operator<(const product&p)const
	{
		if (value < p.value)return true;
		else if (value > p.value)return false;
		else
		{
			if (weight < p.weight)return true;
			else if (weight > p.weight)return false;
			else
			{
				if (type < p.type)return true;
				else if (type > p.type)return false;
				else
				{
					if (date < p.date)return true;
					else if (date > p.date)return false;
					else return name < p.name;
				}
			}
		}
	}
};
signed main()
{
	lint n = in();
	vector<product>p(n);
	REPC(&i, p)
	{
		lint v, w, d;
		string t, n;
		cin >> v >> w >> t >> d >> n;
		i = product(v, w, t, d, n);
	}
	sort(p.begin(), p.end());
	REPC(i, p)cout << i.value << ' ' << i.weight << ' ' << i.type << ' ' << i.date << ' ' << i.name << endl;
}


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

int main(){
  int N;
  cin >> N;
  
  vector<int>A(N);
  vector<int>B(N);
  rep(i,N){
    cin >> A[i];
    B[i] = A[i]; //ソート用にコピー
  }

  
  //最大値と２番目に大きい数を調べておく
  sort(B.begin(),B.end(),greater<>());
  int max_a = B[0];
  int max_b = B[1];
  
  rep(i,N){
    if(A[i] == max_a) cout << max_b << endl;
    else cout << max_a << endl;
  }
}

Measured memory_bytes: 4720
using System;
using System.Linq;

namespace ABC156A
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            int[] nk = Console.ReadLine().Split().Select(int.Parse).ToArray();
        
            Console.WriteLine(nk[0] >= 10 ? nk[1] : nk[1] + (100 * (10 - nk[0])));
        }
    }
}


Measured memory_bytes: 13268
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define vi vector<ll>
#define vvi vector<vi>
#define BITLE(n) (1LL<<((ll)n))
#define SHIFT_LEFT(n) (1LL<<((ll)n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll a,b,c,d,e,n,ans = 0;
  string s,ss,sss;
  cin>>s>>ss;
  cin>>a>>b;
  cin>>sss;
  if(sss == s){
    a--;
  }
  if(sss == ss)
    b--;
  cout<<a<<" "<<b<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdio>

using namespace std;

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

int a, l, x;

double s(double b, double c) 
{
    double h = sqrt(c*c-b*b/4);
    return b*h/2;
}


void solve()
{
    double ans = s(a, l)+2*s(l, (l+x)/2.0);
    printf("%.6lf\n", ans);
}

int main()
{
    while (cin >> a >> l >> x) solve();
    return 0;
}


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

#define endl "\n"
#define ll long long
#define F first
#define S second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define mll unordered_map<ll,ll>
#define dec(v) sort(v.rbegin(),v.rend());
#define REP(i, n) for (int i = 0; i < (n); i++)
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef vector<ll> vll;

#define deb(x) cout << ">" << #x << '=' << x << endl;
#define setbits(n) __builtin_popcountll(n)
#define done {cout<<"-1"<<endl; return;}

#define inf INT_MAX
#define ninf INT_MIN
const ll N = 2e5 + 5;
#define MOD 1000000007

vector<int> adj[N];
vector<bool> visited(N);
int ans;

void dfs(int node) {
   ans++;
   visited[node] = true;
   for (auto it : adj[node]) {
      if (!visited[it]) dfs(it);
   }
}
void solve()
{
   int n, e;
   cin >> n >> e;
   ans = 0;
   for (int i = 0; i <= n; i++) {
      adj[i].clear();
      visited[i] = false;
   }
   map<pair<int, int>, bool>mp;
   for (int i = 0; i < e; i++) {
      int a, b;
      cin >> a >> b;
      if (mp[ {min(a, b), max(a, b)}] == true) {
         //
      }
      else {
         mp[ {a, b}] = true;
         adj[a].pb(b);
         adj[b].pb(a);
      }
   }

   int m = 0;

   for (int i = 1; i <= n; i++) {
      ans = 0;
      if (!visited[i]) {
         dfs(i);
      }
      m = max(m, ans);
   }
   cout << m << endl;

}
int main()
{
   ios_base::sync_with_stdio(false);
   cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
   freopen("inputc.txt", "r", stdin);
   freopen("outputc.txt", "w", stdout);
#endif
   int t = 1;
   //cin >> t;
   while (t--)  solve();
   cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
   return 0;
}


Measured memory_bytes: 45964
N = int(input())
H = list(map(int, input().split()))

flg = True
for i in range(N-2, 0, -1):
    if H[i] - 1 > H[i+1]:
        flg = False
        break
    else:
        if H[i] > H[i+1]: H[i] -= 1
if flg:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 84760
N, K = map(int, input().split())
MOD = 10 ** 9 + 7

low, high = 0, 0
ans = 0
for x in range(1, N + 2):
    low += x - 1
    high += N - x + 1

    if x >= K:
        ans += (high - low + 1)
        ans %= MOD

print(ans)

Measured memory_bytes: 9084
#include <stdio.h>
#include <algorithm>
using namespace std;

#define INF 1e9

int init[111][111], after[111][111];

int main(void)
{
    int n, m, i, j, k, ans = 0;

    scanf("%d %d" ,&n, &m);

    for (i = 1; i <= n; i++)
		for (j = 1; j <= n; j++)
			if (i != j)
				after[i][j] = INF;

    while (m--)
	{
        int x, y, z;
        scanf("%d %d %d" ,&x, &y, &z);
        init[x][y] = init[y][x] = after[x][y] = after[y][x] = z;
	}

	for (k = 1; k <= n; k++)
		for (i = 1; i <= n; i++)
			for (j = 1; j <= n; j++)
                after[i][j] = min(after[i][j], after[i][k] + after[k][j]);

	for (i = 1; i <= n; i++)
		for (j = i + 1; j <= n; j++)
			if (init[i][j] > after[i][j])
				++ans;

	printf("%d" ,ans);
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    while (1) {
        char str1[201];
        scanf("%s", str1);

        if (str1[0] == '-')
            break;

        int m;
        scanf("%d", &m);

        int i;
        for (i = 0; i < m; i++) {
            int h;
            scanf("%d", &h);

            char str2[h];

            int j;
            for (j = 0; j < h; j++)
                str2[j] = str1[j];

            for (j = 0; str1[h + j] != '\0'; j++)
                str1[j] = str1[h + j];

            int k = j;

            for (j = 0; j < h; j++)
                str1[k + j] = str2[j];
        }

        printf("%s\n", str1);
    }

    return 0;
}

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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()

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

  int a,b;
  cin>>a>>b;
  if(a<=b)cout<<a<<endl;
  else cout<<a-1<<endl;
  return 0;
}


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

int N;

int main(void){
    
    scanf("%d", &N);
    int mx = 0, mn = INT_MAX;
    for(int i = 0; i < N; ++i){
        int a; scanf("%d", &a);
        mx = max(mx, a);
        mn = min(mn, a);
    }
    printf("%d\n", abs(mx - mn));
    
    return 0;
}


Measured memory_bytes: 256
import sys
import math
import collections
import bisect
import itertools

import numpy as np

sys.setrecursionlimit(10 ** 7)
INF = 10 ** 20
MOD = 10 ** 9 + 7
# MOD = 998244353

ni = lambda: int(sys.stdin.readline().rstrip())
ns = lambda: map(int, sys.stdin.readline().rstrip().split())
na = lambda: list(map(int, sys.stdin.readline().rstrip().split()))
na1 = lambda: list(map(lambda x: int(x) - 1, sys.stdin.readline().rstrip().split()))


# ===CODE===

def main():
    n = ni()
    s = list(input())

    table = [[-1 for _ in range(n)] for __ in range(4)]
    flg = [True] * 4

    init = []
    if s[0] == "o":
        init = [[1, 1, 1], [0, 1, 0], [1, 0, 0], [0, 0, 1]]
        for i in range(4):
            table[i][-1], table[i][0], table[i][1] = init[i]
    else:
        init = [[1, 1, 0], [0, 1, 1], [1, 0, 1], [0, 0, 0]]
        for i in range(4):
            table[i][-1], table[i][0], table[i][1] = init[i]

    for i in range(1, n):
        for j in range(4):
            if s[i] == "o":
                if table[j][(i + 1) % n] == -1:
                    if table[j][i] == 1:
                        table[j][(i + 1) % n] = table[j][i - 1]
                    else:
                        table[j][(i + 1) % n] = table[j][i - 1] ^ 1
                else:
                    if table[j][i] == 1:
                        if table[j][(i + 1) % n] != table[j][i - 1]:
                            flg[j] = False
                    else:
                        if table[j][(i + 1) % n] != table[j][i - 1] ^ 1:
                            flg[j] = False
            else:
                if table[j][(i + 1) % n] == -1:
                    if table[j][i] == 1:
                        table[j][(i + 1) % n] = table[j][i - 1] ^ 1
                    else:
                        table[j][(i + 1) % n] = table[j][i - 1]
                else:
                    if table[j][i] == 1:
                        if table[j][(i + 1) % n] == table[j][i - 1]:
                            flg[j] = False
                    else:
                        if table[j][(i + 1) % n] == table[j][i - 1] ^ 1:
                            flg[j] = False

    for i in range(4):
        if flg[i]:
            s = ""
            for ti in table[i]:
                if ti:
                    s += "S"
                else:
                    s += "W"
            print(s)
            exit()

    print(-1)


if __name__ == '__main__':
    main()


Measured memory_bytes: 30788
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll n;
  string s;
  cin >> n >> s;
  rep(i, 2) rep(j, 2) {
    ll a = i, b = j;
    vl ans(n + 1, 0);
    ans[0] = b;
    rep(k, n) {
      if(s[k] == 'o')
        ans[k + 1] = a ^ b;
      else
        ans[k + 1] = !(a ^ b);
      a = b;
      b = ans[k + 1];
    }
    if(i != ans[n - 1] || j != ans[n]) continue;
    rep(k, n) cout << (ans[k] ? "W" : "S");
    cout << endl;
    return 0;
  }
  cout << -1 << endl;
}

Measured memory_bytes: 4520
import bisect,collections,copy,itertools,math,string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
def main():
    
    n = I()
    ans = 0
    x, y, z = 0, 0, 0

    for _ in range(n):
        s = S()
        ans += s.count("AB")
        if s[0]=="B" or s[-1]=="A":
            if s[0]=="B" and s[-1]=="A":
                x += 1
            elif s[0]=="B":
                z += 1
            else:
                y += 1
    
    if x==0:
        ans += min(y,z)
    else:
        if y==0 or z==0:
            if y==0 and z==0:
                ans += x-1
            else:
                ans += x
        else:
            ans += x + 1 + min(y-1, z-1)

    print(ans)
                


main()


Measured memory_bytes: 10056
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC085A
{
    class Program
    {
        static void Main(string[] args)
        {
            String s;

            s = Console.ReadLine();

            char[] cs = s.ToCharArray();

            cs[3] = '8';

            Console.WriteLine(cs);

            Console.ReadKey();
        }
    }
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define INF 1000000000000000000

using namespace std;

int main(void){
  ll n, x, t;
  cin >> n >> x >> t;
  
  cout << (n + x - 1) / x * t << endl;

  return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <string>
#include <algorithm>
#include <stdio.h>
#include <cmath>

using namespace std;
#define PI 3.14159265359

int divisor_count(int n)
{
    int ans = 0;
    for(int i = 1; i <= n; i++){
        if(n % i == 0) ans++;
    }

    return ans;
}




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

    for(int i = 1; i <= N; i += 2){
        int temp = divisor_count(i);
        if(temp == 8) ans++;
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

int main(){

    //入力
    int n, k;
    cin >> n >> k;

    vector<long long> h(n);
    for (int i = 0; i < n; i++){
        cin >> h[i];
    }

    //vector dpを用意, 全てINFで埋める
    vector<long long> dp(n, 1000000007);
    dp[0] = 0;//初期化

    for (int i = 0; i < n; i++){
        for (int j = 1; j <= k; j++){//kまであるのでループで回す
            dp[i+j] = min(dp[i+j], dp[i] + abs(h[i+j] - h[i]));

        }
    }
    cout << dp[n-1] << endl;//一番最後まで行ってかかったコストを出力

    return 0;
}


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

int main(){
	int n,l;
	cin>>n>>l;
	ll ans=1;
	rep(i,n)ans*=100;
	if(l!=100)
		puts(ans*l);
	else puts(ans*(l+1));
}


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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 (a>b) { a=b; return 1; } return 0; }

#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

//-------------------------------------------------
//--ModInt
//-------------------------------------------------
const ::std::uint_fast64_t MOD = 998244353;

class mint
{
private:
    using value_type = ::std::uint_fast64_t;
    value_type n;
public:
    mint():n(0){}
    mint(::std::int_fast64_t _n):n(_n<0 ? MOD-(-_n)%MOD : _n%MOD){}
    mint(const mint &m):n(m.n){}

    friend ::std::ostream& operator<<(::std::ostream &os, const mint &a){
		return os << a.n;
	}
    friend ::std::istream& operator>>(::std::istream &is, mint &a){
        value_type temp; is>>temp;
        a = mint(temp);
        return is;
    }

    mint& operator+=(const mint &m){n+=m.n; n=(n<MOD)?n:n-MOD; return *this;}
    mint& operator-=(const mint &m){n+=MOD-m.n; n=(n<MOD)?n:n-MOD; return *this;}
    mint& operator*=(const mint &m){n=n*m.n%MOD; return *this;}
    mint& operator/=(const mint &m){return *this*=m.inv();}
    mint& operator++(){return *this+=1;}
    mint& operator--(){return *this-=1;}

    mint operator+(const mint &m) const {return mint(*this)+=m;}
    mint operator-(const mint &m) const {return mint(*this)-=m;}
    mint operator*(const mint &m) const {return mint(*this)*=m;}
    mint operator/(const mint &m) const {return mint(*this)/=m;}
    mint operator++(int){mint t(*this); *this+=1; return t;}
    mint operator--(int){mint t(*this); *this-=1; return t;}

    bool operator==(const mint &m) const {return n==m.n;}
    bool operator!=(const mint &m) const {return n!=m.n;}
    mint operator-() const {return mint(MOD-n);}

    mint pow(value_type b) const {
        mint ret(1), m(*this);
        while(b){
            if (b & 1) ret*=m;
            m*=m;
            b>>=1;
        }
        return ret;
    }

    mint inv() const {return pow(MOD-2);}
};

mint dp[3030][3030];

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,S; cin>>N>>S;
    vi a(N);
    rep(i,N) cin>>a[i];
    rep(i,N) dp[i][0]=1;
    rep(i,N)FOR(j,0,S){
        dp[i+1][j] += dp[i][j];
        if (j+a[i]<=S) dp[i+1][j+a[i]] += dp[i][j];
    }
    mint ans=0;
    rep(i,N+1) ans+=dp[i][S];
    cout<<ans<<"\n";
    return 0;
}


Measured memory_bytes: 72064
N = int(input())
S = []
march = [0, 0, 0, 0, 0]

for i in range(0, N):
    s = input()
    if s[0] == "M":
        march[0] += 1
    elif s[0] == "A":
        march[1] += 1
    elif s[0] == "R":
        march[2] += 1
    elif s[0] == "C":
        march[3] += 1
    elif s[0] == "H":
        march[4] += 1

#print(march)

ans = 0

for i in range(2, 5):
    ans = ans + march[0] * march[1] * march[i]
for i in range(3, 5):
    ans = ans + march[0] * march[2] * march[i]

ans = ans + march[0] * march[3] * march[4]

for i in range(3, 5):
    ans = ans + march[1] * march[2] * march[i]

ans = ans + march[1] * march[3] * march[4]

ans = ans + march[2] * march[3] * march[4]

print(ans)

"""
for i in range(0,3):
    for j in range(i+1,4):
        for k in range(j+1,5):
            ans = ans + march[i] * march[j] + march[k]

print(ans)
"""

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

void main()
{
    auto nm = readln.split.to!(long[]);
    auto N = nm[0];
    auto M = nm[1];
    auto AS = readln.split.to!(long[]);
    sort!"a > b"(AS);

    long l = AS[0]*2+1, r = AS[$-1]*2;
    while (l > r+1) {
        auto m = (l+r)/2;
        long count;
        foreach (a; AS) {
            if (a + AS[0] < m) continue;
            long ll, rr = N;
            while (ll+1 < rr) {
                auto mm = (ll+rr)/2;
                if (a + AS[mm] >= m) {
                    ll = mm;
                } else {
                    rr = mm;
                }
            }
            count += rr;
        }
        if (count < M) {
            l = m;
        } else {
            r = m;
        }
    }

    auto cs = new long[](N);
    foreach (i; 0..N) {
        if (i) cs[i] = cs[i-1];
        cs[i] += AS[i];
    }

    long res, count;
    foreach (a; AS) {
        if (a + AS[0] < r) continue;
        long ll, rr = N;
        while (ll+1 < rr) {
            auto mm = (ll+rr)/2;
            if (a + AS[mm] >= r) {
                ll = mm;
            } else {
                rr = mm;
            }
        }
        count += rr;
        res += a * rr + cs[ll];
    }
    writeln(res - r * (count - M));
}

Measured memory_bytes: 6352
H, W = map(int, input().split())
Ai = [input() for _ in range(H)]

removable_y = [i for i in range(H)]
removable_x = [i for i in range(W)]

for y in range(H):
    removable = True
    for x in range(W):
        if Ai[y][x] != ".":
            removable = False
            break
    if not removable:
        removable_y.remove(y)

for x in range(W):
    removable = True
    for y in range(H):
        if Ai[y][x] != ".":
            removable = False
            break
    if not removable:
        removable_x.remove(x)

removable_x.reverse()
removable_y.reverse()

for y in removable_y:
    Ai = Ai[:y] + Ai[y + 1:]
for i in range(len(Ai)):
    txt = Ai[i]
    for x in removable_x:
        txt = txt[:x] + txt[x + 1:]
    Ai[i] = txt

for a in Ai:
    print(a)

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

int main(){
	int k,n;
	cin>>k>>n;
	int a[n+1];
	for(int i=1;i<=n;i++)
	    cin>>a[i];
	
	int b[n+1];
	for(int i=1;i<=n-1;i++)
	    b[i]=a[i+1]-a[i];
	b[n]=k-a[n]+a[1];
	int maxv=0;
	for(int i=1;i<=n;i++)
	    maxv=max(maxv,b[i]);
	cout<<k-maxv<<endl;
	return 0;
} 

Measured memory_bytes: 1792
#include<stdio.h>
#include<cmath>
int main(){
	int N,K,X,Y;
	int total;
	scanf("%d\n%d\n%d\n%d",&N,&K,&X,&Y);
	{
		if(N<=K) { total=N*X;  printf("%d\n",total);}
		else  {total=K*X+(N-K)*Y;  printf("%d\n",total);}
	}
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  int sx, sy, tx, ty;
  cin >> sx >> sy >> tx >> ty;
  int dx = tx - sx, dy = ty - sy;
  string ans = "";

  ans += string(dy, 'U');
  ans += string(dx, 'R');

  ans += string(dy, 'D');
  ans += string(dx, 'L');

  ans += string(1, 'L');
  ans += string(dy + 1, 'U');
  ans += string(dx + 1, 'R');
  ans += string(1, 'D');

  ans += string(1, 'R');
  ans += string(dy + 1, 'D');
  ans += string(dx + 1, 'L');
  ans += string(1, 'U');

  cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		
		int n=sc.nextInt();
		int a=n%10;
		if(a==3){
			System.out.println("bon");
		}else if(a==0 || a==1 || a==8|| a==6){
			System.out.println("pon");
		}else System.out.println("hon");
	}

}


Measured memory_bytes: 35752
#include <stdio.h>
#include <iostream>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <limits>
#include <numeric>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;

int main()
{
	int n,max=0, x=0;
	string s;
	cin >> n >> s;
	for (int i = 0; i < n; i++) {
		if (s[i] == 'I') {
			x++;
			if (max < x)max = x;
		}
		else {
			x--;
		}
	}

	cout << max << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001
#define mod 1000000007
#define pi 3.141592653589793
ll gcd(ll a,ll b){
    if(b>a) swap(a,b);
    if(b==0) return a;
    return gcd(b,a%b);
}
ll lcm(ll a,ll b){
    ll g=gcd(a,b);
    return a/g*b;
}
ll rep_jijo(ll n,ll x){
    if(x==0) return 1;
    if(x%2==0){
        ll t=rep_jijo(n,x/2);
        return t*t%mod;
    }
    return n*rep_jijo(n,x-1)%mod;
}
ll com(ll n,ll r){
    ll x=1,y=1;
    ll tmp=n;
    while(tmp>=n-r+1){
        x=x*tmp%mod;
        tmp--;
    }
    while(r>0){
        y=y*r%mod;
        r--;
    }
    return x*rep_jijo(y,mod-2)%mod;
}

int main (){
    ll n ,k;
    cin >> n >>k;
    if(n>=k) {
        ll x=n%k-k;
        cout << min(n%k,-x) <<endl;
    }
    else cout << min(n,k-n) <<endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//#define LOCAL
#define fastIO ios::sync_with_stdio(0), cin.tie(0)
#define endl '\n'
#define forn(i,a,b) for(int i=a;i<b;i++)
#define ft first
#define sd second
#define sz size()
#define pb push_back
#define pob pop_back()
#define pf push_front
#define pof pop_front()
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<char,char> pcc;
typedef pair<double,double> pdd;
typedef pair<long long,long long> pll;
//cout << fixed << setprecision(12) <<x<<endl;

int main(){
fastIO;
#ifdef LOCAL
     freopen("in.txt", "r", stdin);
#endif

int n;
cin>>n;
cout<<(n)+(n*n)+(n*n*n)<<endl;
}



Measured memory_bytes: 3604
#include <stdio.h>
int main(void){
    int x,y;
    while(1){
    scanf("%d %d", &x, &y);
    if ( x == 0 && y == 0 ) break;
    if (x<y){
        printf("%d %d\n",x,y);
    } else {
        printf("%d %d\n",y,x);
    }

}
    return 0;
}



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

int main() {
	ios::sync_with_stdio(0);cin.tie(0);
	int n;
	cin >> n;
	vector<int> v(n);
	for(int i=0; i<n; i++) {
		cin >> v[i];
	}
	int ans = 0;
	for(int i=0; i<n; i++) {
		for(int j=i+1; j<n; j++) {
			ans += v[i]*v[j];
		}
	}
	cout << ans;
}

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

using namespace std;

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

int main() {
	char c[3] = {'a','b','c'};
	string str[3];
	
	REP(i, 3) {
		cin >> str[i];
		reverse(str[i].begin(), str[i].end());
	}
	
	int now = 0;
	while (true) {
		if (str[now].empty()) break;
		
		
		int next;
		REP(i, 3) if (str[now][str[now].size() - 1] == c[i])
			next = i;
		
		str[now].erase(str[now].end() - 1);
		now = next;
	}
	
	cout << (char)(c[now] - 'a' + 'A') << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  string S,T;
  cin >> S >> T;
 
  for(int i=0;i<N;i++)
  {
    cout << S.at(i) << T.at(i);
  }
    
}
    


Measured memory_bytes: 256
use proconio::{input,fastout};

#[fastout]
fn main(){
    input!{
        n: usize,
        a: [usize; n - 1]
    }
    let mut ans = vec![0; n];
    for b in a {
        ans[b-1] += 1;
    }
    for i in ans {
        println!("{}", i);
    }
}

Measured memory_bytes: 5484
#include <bits/stdc++.h>
// #include <iostream>
// #include <vector>
// #include <map>
// #include <algorithm>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())

template<typename T>
T mod(T a, T b){
    return (a + b) % b;
}

template<typename T>
T gcd(T a, T b){
    if (b == 0) return a;
    return gcd(b, a % b);
}

ll lcm(ll a, ll b){
    return a * b / gcd(a,b);
}

// n を素因数分解
map<ll, ll> factor(ll n){
    map<ll, ll> mp;
    for (ll i = 2; i*i <= n; i++) {
        while (n % i == 0) {
            mp[i]++;
            n /= i;
        }
    }

    if (n > 1) {
        mp[n]++;
    }

    return mp;
}

// 文字列に "hoge" が含まれているか
// string str = "hogepiyo";
// if (str.find("hoge") != string::npos) {
//     cout << "文字列が含まれています" << endl;
// }

// char to string
// char c = 'a';
// string str = {c};

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

    int A, B;
    cin >> A >> B;

    vi v(3, 0);
    for (int i = 0; i < N; i++) {
        int P;
        cin >> P;

        if (P <= A) {
            v[0]++;
        } else if (A < P && P <= B) {
            v[1]++;
        } else {
            v[2]++;
        }
    }

    cout << min(v[0], min(v[1], v[2])) << endl;

    return;
}

int main(int argc, char const* argv[])
{
    solve();
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

template <typename T>
void print(T x) {
    cout << x << endl;
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;


int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    
    int a, b;
    cin >> a >> b;
    
    if (a > b) {
        print(a - 1);
    } else {
        print(a);
    }

}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
using namespace std;
int main(){
  int n,m;
  cin >> n >> m;
  char a[n][n]={};
  char b[m][m]={};
  string A,B,ans="No";
  for(int i=0;i<n;i++){
	  cin >> A;
	  for(int j=0;j<n;j++){
	  a[i][j]=A[j];
	  }
  }
  for(int i=0;i<m;i++){
	  cin >> B;
	  for(int j=0;j<m;j++){
	  b[i][j]=B[j];
	  }
  }
  for(int i=0;i<=n-m;i++){
	  for(int l=0;l<=n-m;l++){
		  int judge=1;
		  for(int j=0;j<m;j++){
			  for(int k=0;k<m;k++){
				  if(a[j+i][k+l]!=b[j][k]){
					  judge=0;
				  }
			  }
		  }
		  if(judge==0);
		  else if(judge==1) ans="Yes";
	  }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define sz(v) (ll((v).size()))
#define forn(i,n) for(ll i=0;i<(n);i++)
#define forr(i,n) for(ll i=(n)-1;i>=0;i--)
#define forv(i,v) forn(i,sz(v))
#define fors(i,s) for(auto i=(s).begin();i!=(s).end();++i)
#define all(v) (v).begin(),(v).end()
#define clr(x) memset(x,0,sizeof(x))
#define debug(x) cout<<"["#x<<": "<<x<<"] "
#define debugnl(x) cout<<"["#x<<": "<<x<<"]\n"

const ll mod =998244353 ;
const ll N = 1e5+5;

void add_self(ll &a, ll b){a+=b;if(a>=mod)a-=mod;}
void sub_self(ll &a, ll b){a-=b;if(a<0)a+=mod;}
void mul_self(ll &a, ll b){a*=b;a%=mod;}
void max_self(ll &a, ll b){if(b>a)a=b;}

ll power(ll a, ll x){ll ret=1;while(x){if(x%2)mul_self(ret,a);x/=2;mul_self(a,a);}return ret;}



int main()
{
    ios_base::sync_with_stdio(false);

	ll n;cin>>n;
	vector<pair<ll,ll>> ans;
	ll x=n;if(n%2==0)x++;

	for(int i=1;i<=n;i++)
	{
		for(int j=i+1;j<=n;j++)
		{
			if(j == x-i)continue;
			ans.pb(mp(i,j));
		}
	}
	cout<<ans.size()<<endl;
	for( auto i :ans)cout<<i.F<<" "<<i.S<<endl;
}


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

using namespace std;

int l,r,d,ans;

int main()
{
	scanf("%d%d%d",&l,&r,&d);
	for(int i=l;i<=r;i++)
	    if(i%d==0)
	        ans++;
	printf("%d\n",ans);
	return 0;
} 

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

/* */

int main(){
    // 入力スタンダード
    ll a, b, c;
    cin >> a >> b >> c;

    if(c-a-b >0){
        if( 4*a*b < (c-a-b)*(c-a-b)){
            cout << "Yes" <<endl;
            return 0;
        }
    }
    cout << "No" <<endl;
    return 0;
}

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

using ll = long long;
using ld = long double;
using vi = vector<int>;
using vll = vector<ll>;
using P = pair<int, int>;

const int INF = 1e9;
const ll INFLL = 1e18;
const int MOD = 1e9 + 7;
const int NIL = -1;
const ld PI = acosl(-1);

#define rep(i,n) for(int i=0; i<(n); ++i)
#define all(n) n.begin(),n.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; }

int main()
{
	ios::sync_with_stdio(false); cin.tie(nullptr);
	//cout << fixed << setprecision(6);
	int n; cin >> n;
	vector<string> vs(n);
	rep(i, n) cin >> vs[i];

	bool ans = true;
	map<string, int> ms;
	rep(i, n) ms[vs[i]]++;
	for(auto t : ms){
		if(t.second != 1) ans = false;
	}
	rep(i, n-1){
		if(vs[i].back() != vs[i+1].front()){
			ans = false;
		}
	}

	cout << (ans ? "Yes" : "No") << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n, a, b; cin >> n >> a >> b;
  int ba = 0, bb = 0;
  vector<int> v(n); for(int & i : v) cin >> i;
  for(int i = 0; i < n; i++) if(v[i] <= a) ba++; else if(v[i] > b) bb++;
  cout << min(ba, min(bb, n - ba - bb) ) << endl;
  return 0;
}

Measured memory_bytes: 256
import sys
from heapq import heappop, heappush

ans_l = []
T = int(input())
for t in range(T):
    ans = 0
    N = int(input())
    left = []
    right = []
    neutral = []
    for i in range(N):
        K, L, R = map(int, sys.stdin.readline().split())
        if L > R:
            heappush(left, (K, L - R, L, R))
        elif L < R:
            heappush(right, (-K, R - L, L, R))
        else:
            ans += L
    # left
    pool = []
    pos = 1
    while left:
        while left and left[0][0] == pos:
            k, d, l, r = heappop(left)
            heappush(pool, (d, l, r))
        while len(pool) > pos:
            d, l, r = heappop(pool)
            ans += r
        pos += 1
    while pool:
        d, l, r = heappop(pool)
        ans += l
            
    # right
    pool = []
    pos = N
    while right:
        while right and right[0][0] == -pos:
            k, d, l, r = heappop(right)
            heappush(pool, (d, l, r))
        while len(pool) > N - pos:
            d, l, r = heappop(pool)
            ans += l
        pos -= 1
    while pool:
        d, l, r = heappop(pool)
        ans += r

    ans_l.append(ans)


print(*ans_l, sep='\n')


Measured memory_bytes: 141620
#include<stdio.h>
int main(void){
  char b;
  scanf("%c",&b);
    if(b=='A'){printf("T\n");}
    if(b=='C'){printf("G\n");}
    if(b=='G'){printf("C\n");}
    if(b=='T'){printf("A\n");}
  return 0;
}

Measured memory_bytes: 128
n=int(input())
S=input().split()
q=int(input())
T=input().split()
cnt=0
for i in range(len(T)):
    T[i]=int(T[i])
for i in range(len(S)):
    S[i]=int(S[i])
for i in range(len(T)):
    c=0
    left=0
    right=n
    while left<right and c==0:
        mid=(left+right)/2
        mid=int(mid)
        if S[mid]==T[i]:
            cnt+=1
            c+=1
        elif T[i]<S[mid]:
            right=mid
        else:
            left=mid+1
print(cnt)


Measured memory_bytes: 15984
//Exponential

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a/__gcd(a, b)*b)
#define range(a) (a).begin(),(a).end() 
#define pb push_back
#define mp make_pair
#define nnn "\n"
template<class T>inline bool chmin(T& a,T b,bool f){
if(f==1){if(a>b){a=b;return true;}return false;}
else if(f==0){if(a<b){a=b;return true;}return false;}return false;}
typedef pair<int,string> p;
const int inf = 2147483647;//2*10^9
const ll INF = 9223372036854775807;//9*10^18

int main (){
    int a,ans=1;cin>>a;
    rep(i,1,34){
        rep(j,2,10){
            if(pow(i,j)<=a)ans=max((double)ans,pow(i,j));
        }
    }
    cout<<ans<<nnn;
    return 0;
}

Measured memory_bytes: 512
#include <stdio.h>

int main(){
  int i, j, n, m, min;
  int count = 0;
  int A[100];

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

  for(i = 0; i < n; i++){
    min = i;
    for(j = i; j < n; j++){
      if(A[j] < A[min]){
          min = j;
      }
    }

    if(i != min){
      m = A[i];
      A[i] = A[min];
      A[min] = m;
      count++;
    }
  }

  for(i = 0; i < n; i++){
    if(i>0){
        printf(" ");
    }
    printf("%d", A[i]);
  }
  printf("\n%d\n", count);

  return 0;
}

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


class Main {

    public static void main(String[] args) throws IOException {

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(System.out);

        int n = Integer.parseInt(br.readLine());

        StringTokenizer st1 = new StringTokenizer(br.readLine());

        int arr[] = new int [n];

        for(int i = 0 ; i < n ; i++)
        {
            arr[i] = Integer.parseInt(st1.nextToken());
        }

        int dp[] = new int [n];

        dp[1] = Math.abs(arr[1] - arr[0]);

        for(int i = 2 ; i < n ; i++)
        {
            dp[i] = Math.min(Math.abs(arr[i]-arr[i-1]) + dp[i-1] , Math.abs(arr[i] - arr[i-2]) + dp[i-2]);
        }

        out.println(dp[n-1]);

        out.flush();
        out.close();
    }

}

Measured memory_bytes: 34096
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <cmath>
#include <iomanip>

using namespace std;
using ll = long long;
using vi = vector<int>;

#define in(v) v; cin >> v;
void ins() {}
template<class T,class... Rest>void ins(T& v,Rest&... rest){cin>>v;ins(rest...);}


#define rep(i,n) for(int i=0,_i=(n);i<_i;++i)
#define all(f,c,...) (([&](decltype((c)) cccc) { return (f)(begin(cccc), end(cccc), ## __VA_ARGS__); })(c))
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;}

// debug
template<class T>ostream& operator<<(ostream& os,const vector<T>& vec){os<<"{";for(size_t i=0;i<vec.size();++i)os<<(i?", ":"")<<vec[i];os<<"}";return os;}
ostream& operator<<(ostream& os,const vector<char>&v){for(size_t i=0;i<v.size();++i)os<<v[i];return os;}
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>& rhs){os<<"("<<rhs.first<<", "<<rhs.second<<")";return os;}

#ifdef LOCAL
void debug() {cerr << "\n";}
template<class First> void debug(const First& first) {cerr<<first<<"\n";}
template<class First, class... Rest> void debug(const First& first, const Rest&... rest) {cerr<<first<<",";debug(rest...);}
void debug2() {cerr << "\n";}
template<class First> void debug2(const First& first) {cerr<<first<<" ";}
template<class First, class... Rest> void debug2(const First& first, const Rest&... rest) {cerr<<first<<" ";debug2(rest...);}
#else
#define debug(...) 42
#define debug2(...) 42
#endif


int N;
double dp[601][601][301];
double dfs(int a, int b, int c) {
  if (a == 0 && b == 0 && c == 0)
    return 0;
  if (dp[a][b][c] != -1)
    return dp[a][b][c];
  double ans = 1.0 * N / (a + b + c);
  if (a > 0) ans += 1.0 * a / (a + b + c) * dfs(a-1, b, c);
  if (b > 0) ans += 1.0 * b / (a + b + c) * dfs(a+1, b-1, c);
  if (c > 0) ans += 1.0 * c / (a + b + c) * dfs(a, b+1, c-1);
  return dp[a][b][c] = ans;
}
int main() {
  in(N);

  rep(i, 601) rep(j, 601) rep(k, 301) dp[i][j][k] = -1;
  vi v(4,0);
  rep(i, N) {
    int in(a);
    ++v[a];
  }
  cout << fixed << setprecision(15) << dfs(v[1], v[2], v[3]) << endl;

  return 0;
}


Measured memory_bytes: 849664
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <cstdio>
#include <cmath>
#define rep(i, n) for(i = 0; i < n; i++)
#define int long long
using namespace std;

int n, k;
int a[200000];

bool check(int x) {
	int i;
	int cst = 0;
	rep(i, n) {
		cst += (a[i] + x - 1) / x - 1;
	}
	return cst <= k;
}

signed main() {
	int i;
	
	cin >> n >> k;
	rep(i, n) cin >> a[i];
	
	int sumA = 0;
	rep(i, n) { sumA += a[i]; }
	if (k >= sumA - n) { cout << 1 << endl; return 0; }
	
	int ng = 1, ok = 1e+9, mid;
	while (ok - ng >= 2) {
		mid = (ng + ok) / 2;
		if (check(mid)) ok = mid;
		else ng = mid;
	}
	cout << ok << endl;
	return 0;
}

Measured memory_bytes: 5144