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

using namespace std;

typedef long long int llint;
typedef pair<int, int> pii;
typedef pair<llint, llint> pll;
typedef vector<int> vi;
typedef vector<llint> vl;
typedef vector<pii> vii;
typedef vector<pll> vll;

#define ci cin
#define co cout
#define en endl
#define ln cout<< '\n'
#define rep(i, n) for(int i = 0; i < n; i++)
#define outl(x) cout<< (x) << '\n'
#define pb push_back
#define fi first
#define se second
#define MOD 1000000007

template<typename Tn> Tn gcd(Tn a, Tn b)
{
	return (b ? gcd(b, a % b) : a);
}

template<typename Tn> Tn lcm(Tn a, Tn b)
{
	return a / gcd(a, b) * b;
}

string IntToString(int number)
{
	stringstream ss;
	ss << number;
	return ss.str();
}

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

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

    int x[100001];
    rep(i, m) ci >> x[i];

    sort(x, x + m);

    llint ans = 0;
    vi v;
    rep(i, m - 1) {
	v.pb(x[i + 1] - x[i]);
	ans += x[i + 1] - x[i];
    }

    sort(v.begin(), v.end(), greater<int>());

    for(int i = 0; i < n - 1 && i < v.size(); i++) ans -= v[i];

    co << ans << en;
        
    return 0;
}





Measured memory_bytes: 1276
a,b = map(str,input().split())

a_int = int(a)
b_int = int(b)

ans = []
sa = ''
sb = ''
for _ in range(b_int):
	sa += a
for _ in range(a_int):
	sb += b

ans.append(sa)
ans.append(sb)

ans.sort()

print(ans[0])


Measured memory_bytes: 3060
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.math;
import std.regex;
 
void main() {
	auto ip = readln.split.to!(int[]), N = ip[0], K = ip[1];
	auto l = readln.split.to!(int[]);
	l.sort!"a > b";
	l[0..K].sum.writeln;
}

Measured memory_bytes: 256
while True:
    s=input()
    if s=='0':
        break
    
    A=0
    B=0
    for i in range(1,len(s)):
        if s[i]=='A':
            A+=1
        else:
            B+=1
    if A==10 and B<10:
        A+=1
    elif B==10 and A<10:
        B+=1
    elif A>B:
        A+=1
    else:
        B+=1
    print(A, B)    


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

using static Input;
using static Util;
class Program
{
    static long[] M;
    static void INPUT()
    {
        M = LineLong();
    }
    static void OUT()
    {
        var list = new List<long>();
        var a = TEST(M[0], M[1]).OrderBy(__ => __).ToArray();
        foreach (var i in a)
        {
            if (i == 1) continue;
            var b = true;
            foreach (var ii in list)
            {
                if (i % ii == 0)
                {
                    b = false;
                    break;
                }
            }

            if (b)
                list.Add(i);
        }

        Console.WriteLine(list.Count+1);
    }
    static void Main(string[] args)
    {
#if DEBUG  
        TESTINPUT();
        //INPUT();

#else
        INPUT();
#endif
        OUT();
    }

    static void TESTINPUT()
    {
        M = new long[] { 101 ,202 };
    }

}

public class Input
{
    public const long MOD = 1000000007;
    public const int INF = 1000000007;
    private static Queue<string> q = new Queue<string>();
    private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); }
    public static string NextString() { Confirm(); return q.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
}

class Util
{
    public static IEnumerable<long> TEST(long a, long b)
    {
        var l = Math.Min(a, b);
        var h = Math.Max(a, b);
        
        for (var i = 1L; i*i <= l; i++)
        {
            if (l % i == 0)
            {
                if ( h % i == 0)
                {
                    yield return i;
                }
                var ii = l / i;
                if (h % ii == 0 && ii != i)
                {
                    yield return ii;
                }
            }
        }
        yield break;
    }
}




Measured memory_bytes: 13576
n = int(input())
L1 = list(map(int,input().split()))

def gcd(a,b):
    while b:
        a,b = b,a%b
    return a

l = [0]*(n+1)
r = [0]*(n+1)
for i in range(n):
    l[i+1] = gcd(l[i],L1[i])
    r[n-(i+1)] = gcd(r[n-i],L1[n-(i+1)])

ans = 0
for i in range(n):
    ans = max(ans,gcd(l[i],r[i+1]))
print(ans)


Measured memory_bytes: 14524
#include <iostream>

void solve() {
    char prev;
    std::cin >> prev;
    for (int i = 0; i < 2; ++i) {
        char c;
        std::cin >> c;
        if (c != prev) {
            std::cout << "Yes" << std::endl;
            return;
        }
        prev = c;
    }
    std::cout << "No" << std::endl;
}

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

    solve();

    return 0;
}


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

int main()
{
	int i, l, b, m,j;
	char s[101], a[101],tm,tem,c;
	
	gets(s);
	gets(a);
	b=strlen(s);
	l=strlen(a);
	if (b!=l){
		printf("No\n");
		return 0;
	}
	if (strcmp(s,a)==0){
		printf("Yes\n");
		return 0;
	}
	
	for (i=2;i<=b+1;i++){
			tem=s[b-1];
			c=s[0];
			for (j=0;j<b-1;j++){
				tm=s[1+j];
				s[j+1]=c;
				c=tm;
			}
			s[0]=tem;
			
			if (strcmp(s,a)==0){
				printf("Yes\n");
				return 0;
			}
			//puts(s);
		}
		printf("No\n");
	
	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#define MAX 2000001
#define VMAX 10000

void CountingSort(int,int);
int A[MAX],B[MAX],C[VMAX+1];

int main(){
  int n,i;
  scanf("%d",&n);

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

  CountingSort(VMAX,n);

  for(i=1;i<n;i++){
    printf("%d ",B[i]);
  }
  printf("%d\n",B[n]);
  return 0;
}

void CountingSort(int l,int n){
  int i;

  for(i=0;i<=l;i++){
    C[i]=0;
  }

  for(i=0;i<n;i++){
    C[A[i]]++;
  }

  for(i=0;i<l;i++){
    if(i==0){
      C[i]=C[i];
    }
    else C[i]=C[i]+C[i-1];
  }

  for(i=n-1;i>=0;i--){
    B[C[A[i]]]=A[i];
    C[A[i]]--;
  }
}



Measured memory_bytes: 17404
class UnionFind(object):
  def __init__(self,n):
    *self.par,=range(n+1)
    self.rank=[0]*(n+1)

  def find(self,x):
    if self.par[x]==x:
      return x
    else:
      self.par[x]=self.find(self.par[x])
      return self.par[x]

  def union(self,x,y):
    x=self.find(x)
    y=self.find(y)
    if self.rank[x]<self.rank[y]:
      self.par[x]=y
    else:
      self.par[y]=x
      if self.rank[x]==self.rank[y]:
        self.rank[x]+=1

n=int(input())
x=[[0,0] for _ in range(n)]
y=[[0,0] for _ in range(n)]

for i in range(n):
  x[i][0],y[i][0]=map(int,input().split())
  x[i][1],y[i][1]=i+1,i+1

dx,dy=[],[]
x,y=sorted(x),sorted(y)
for i in range(n-1):
  dx.extend([(abs(x[i][0]-x[i+1][0]),x[i][1],x[i+1][1])])
  dy.extend([(abs(y[i][0]-y[i+1][0]),y[i][1],y[i+1][1])])

target=sorted(dx+dy)
tree=UnionFind(n)
cnt,cost,i=0,0,0

while cnt<n-1:
  c,a,b=target[i]
  if tree.find(a)!=tree.find(b):
    cost+=c
    tree.union(a,b)
    cnt+=1
  i+=1

print(cost)


Measured memory_bytes: 65516
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#include <set>
#include <stdio.h> 
using namespace std;
	typedef long long int lli;
	const int MaxN=200005;
	#define fst first
	#define snd second
	int mcd(int a,int b){	
		if(a==0)return b;
		return mcd(b%a,a);
	}		

int main(){
	lli N,K,i,j,p,q,aux,res=0;
	cin>>N>>p>>q;
	aux=N/(p+q);
	if(N%(p+q)!=0){
		res+=min(N%(p+q),p);
	}
	res+=aux*p;
	cout<<res;
}

Measured memory_bytes: 888
n,d = map(int,input().split())
points = []
count = 0
for _ in range(n):
    points.append(list(map(int,input().split())))
for i in range(n-1):
    for j in range(i+1,n):
        dis = 0
        for k in range(d):
            dis += (points[i][k]-points[j][k])**2
        if dis**0.5 == int(dis**0.5):
            count += 1
print(count)


Measured memory_bytes: 3064
import math
TICKET_PRICE = 100


def get_data_list():
    data_list = input().split()
    for i in range(len(data_list)):
        data_list[i] = int(data_list[i])
    return data_list

def get_input():
    input_data = int(input())
    return input_data

def make_ticket_dict(player):
    ticket_sum = 0
    ticket_list = dict()
    order = 1
    for i in range(player):
        input_data = get_input()
        ticket_list[order] = input_data
        order += 1
    return ticket_list

def calculate_distribution_money(ticket_list, deduction_rate):
    ticket_sum = 0
    for ticket_num in ticket_list.values():
        ticket_sum += ticket_num
    sum_money = ticket_sum * TICKET_PRICE
    distribution_money = sum_money * (100 - deduction_rate) / 100
    return distribution_money


if __name__ == "__main__":
    while True:
        data_list = get_data_list()
        if data_list[0] == 0:
            break
        player = data_list[0]
        winner = data_list[1]
        deduction_rate = data_list[2]
        ticket_list = make_ticket_dict(player)
        if ticket_list[winner] == 0:
            print(0)
            continue
        distribution_money = calculate_distribution_money(ticket_list, deduction_rate)
        each_distribution_money = math.floor(distribution_money / ticket_list[winner])
        print(each_distribution_money)



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

int n, m;
vector<vector<int>> adj;
vector<int> dp;

int dfs(int u) {
    if (dp[u] != -1)
        return dp[u];
    if (adj[u].size() == 0u)
        return dp[u] = 0;
    int d = 0;
    for (int v : adj[u])
        d = max(d, dfs(v));
    return dp[u] = d + 1;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> m;
    adj.resize(n);
    dp.resize(n, -1);
    for (int i = 0; i < m; i++) {
        int u, v;
        cin >> u >> v;
        --u, --v;
        adj[u].push_back(v);
    }
    int ans = 0;
    for (int i = 0; i < n; i++) {
        ans = max(ans, dfs(i));
    }
    cout << ans;
    return 0;
} 

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

int N,M,Q;
vector<int> G[100005];
int W[555][555];
int res[100005];
const int INF = (1<<28);
vector<int> qa,qb,qc;

void input_query(){
  cin >> Q;
  qa.resize(Q); qb.resize(Q); qc.resize(Q);
  for(int i=Q-1;i>=0;i--) {
    cin >> qa[i] >> qb[i] >> qc[i]; --qa[i];
  }
}

void solve1(){
  fill( W[0], W[N], INF );
  for(int i=0;i<N;i++) W[i][i] = 0;
  for(int i=0;i<M;i++){
    int a,b; cin >> a >> b; --a; --b;
    W[a][b] = 1;
  }

  for(int i=0;i<N;i++)
    for(int j=0;j<N;j++)
      for(int k=0;k<N;k++)
        W[j][k] = min( W[j][k], W[j][i] + W[i][k] );

  input_query();

  int cnt = 0;
  for(int i=0;i<Q;i++){
    int a = qa[i], b = qb[i], c = qc[i]; --a;
    for(int v = 0; v < N; v++ )
      if( !res[v] && W[a][v] <= b ) {
        res[v] = c;
        cnt++;
      }
    if( cnt == N ) break;
  }

  for(int i=0;i<N;i++)
    cout << res[i] << endl;
}


int F[100005];
struct state{
  int v,d;
};
void dijk(int v,int d,int c,int &cnt){
  queue<state> q;
  if( F[v] >= d ) return;
  //cout << "in " << v << " " << d << " "<< c << endl;
  if( !res[v] ) {
    res[v] = c; cnt++;
  }
  F[v] = d;
  if( d == 0 ) return;

  q.push( (state){v,d} );


  while(!q.empty()){
    state p = q.front(); q.pop();
    //cout << p.v << " "<< p.d << endl;
    for( int to : G[p.v] ) {
      int nd = p.d-1;
      //cout << " -> " << to  << " ? " << F[to] << endl;
      if( F[to] < nd ) {
        if( !res[to] ) {
          res[to] = c; cnt++;
        }
        F[to] = nd;
        if( nd == 0 ) continue;
        q.push( (state){to,nd} );
      }
    }

  }


}
void solve2(){

  for(int i=0;i<M;i++){
    int a, b; cin >> a >> b; --a; --b;
    G[a].emplace_back( b );
    G[b].emplace_back( a );
  }
  input_query();
  int cnt = 0;
  memset( F,-1,sizeof(F) );
  for(int i=0;i<Q;i++){
    int a = qa[i], b = qb[i], c = qc[i];
//    cout <<a  << " "<< b <<"  "<< c << endl;
    dijk( a, b, c, cnt );
    if( cnt == N ) break;
  }

  for(int i=0;i<N;i++)
    cout << res[i] << endl;

}

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

  cin >> N >> M;
 // if( N <= 500 ) solve1();
  solve2();
}

Measured memory_bytes: 8952
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 20000000
#define mod 1000000007
#define INF2 1000000000000000000

int H, W;
string S[21];
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};
typedef pair<int, int> P;
int bfs(int sx, int sy) {
    int d[21][21];
    rep(i, 21) rep(j, 21) d[i][j] = INF;
    d[sx][sy] = 0;
    int ret = 0;
    queue<P> que;
    que.push({sx, sy});
    while(que.size()) {
        P p = que.front(); que.pop();
        int a = p.first;
        int b = p.second;
        rep(i, 4) {
            int x = p.first + dx[i];
            int y = p.second + dy[i];
            if(x < 0 || x >= H || y < 0 || y >= W) continue;
            if(d[x][y] != INF) continue;
            if(S[x][y] == '#') continue;
            que.push({x, y});
            d[x][y] = d[a][b] + 1;
            ret = max(ret, d[x][y]);
        }
    }

    return ret;
}

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
   
    cin >> H >> W;
    
    rep(i, H) {
        cin >> S[i];
    }
    int ans = 0;
    rep(i, H) {
        rep(j, W) {
            if(S[i][j] == '#') continue;
            ans = max(ans, bfs(i, j));
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
//#include <atcoder/all>
using namespace std;
//using namespace atcoder;
#define ll long long
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rep1(i, n) FOR(i, 1, n+1)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define whole(x) (x).begin(),(x).end()
#define rwhole(x) (x).rbegin(), (x).rend()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define P pair<int, int>
#define debug(var) cerr << "[" << #var << "] " << var << endl
template<typename T1, typename T2>
bool chmax(T1 &a,T2 b){if(a<b){a=b;return true;}else return false;}
template<typename T1, typename T2>
bool chmin(T1 &a,T2 b){if(a>b){a=b;return true;}else return false;}
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define pr(s) cout << (s) << '\n'
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};
const int INF = 1001001001;
const ll INFll = 1E+18;

struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    
    // for prime mod
    mint inv() const {
        return pow(mod-2);
    }
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res/=a;
    }
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

struct combination {
    vector<mint> fact, ifact;
    combination(int n):fact(n+1),ifact(n+1) {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
    }
    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n]*ifact[k]*ifact[n-k];
    }
    mint per(int n, int k) {
        return fact[n]*ifact[n-k];
    }
};


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll n;
    cin >> n;
    mint ans = mint(10).pow(n);
    ans -= mint(9).pow(n)*2;
    ans += mint(8).pow(n);
    
    pr(ans);
    return 0;
}


Measured memory_bytes: 3684
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define pb push_back
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
#define PQ(T) priority_queue<T>
#define SPQ(T) priority_queue<T,vector<T>,greater<T>>
#define dame(a) {out(a);return 0;}
#define decimal cout<<fixed<<setprecision(15);
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef tuple<ll,ll,ll,ll> PPP;
typedef multiset<ll> S;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
using vp=vector<P>;
using vvp=vector<vp>;
using vb=vector<bool>;
using vvb=vector<vb>;
const ll inf=1001001001001001001;
const int INF=1001001001;
const int mod=1000000007;
const double eps=1e-10;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())cout<<'('<<v[i].fi<<','<<v[i].se<<')';cout<<'\n';}
template<class T> void outvvp(T v){rep(i,v.size())outvp(v[i]);}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size())outv(v[i]);}
template<class T> bool isin(T x,T l,T r){return (l)<=(x)&&(x)<=(r);}
template<class T> void yesno(T b){if(b)out("yes");else out("no");}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
template<class T> void YESNO(T b){if(b)out("YES");else out("NO");}
template<class T> void noyes(T b){if(b)out("no");else out("yes");}
template<class T> void NoYes(T b){if(b)out("No");else out("Yes");}
template<class T> void NOYES(T b){if(b)out("NO");else out("YES");}
void outs(ll a,ll b){if(a>=inf-100)out(b);else out(a);}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll modpow(ll a,ll b){a%=mod;if(b==0)return 1;if(b&1)return a*modpow(a,b-1)%mod;ll k=modpow(a,b/2);return k*k%mod;}
ll d;
ll ketadp(string s){
    ll n=s.size();
    vvi dp0(n,vi(d)),dp1(n,vi(d));
    REP(i,1,s[0]-'0')dp1[0][i%d]++;
    dp0[0][(s[0]-'0')%d]=1;
    rep(i,n-1){
        rep(j,d){
            rep(k,10){
                dp1[i+1][(j+k)%d]+=dp1[i][j];
                dp1[i+1][(j+k)%d]%=mod;
                if(k==s[i+1]-'0')dp0[i+1][(j+k)%d]+=dp0[i][j];
                if(k<s[i+1]-'0')dp1[i+1][(j+k)%d]+=dp0[i][j];
            }
        }
        REP(j,1,10)dp1[i+1][j%d]++;
    }
    return (dp0[n-1][0]+dp1[n-1][0])%mod;
}
int main(){
    string s;cin>>s;
    cin>>d;
    out(ketadp(s));
}

Measured memory_bytes: 16640
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cstdio>
#include<cstring>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(n) rep(i,n)
#define all(n) n.begin(),n.end()

int COIN[] = {10, 50, 100, 500};
const int MAXC = 21;

int main()
{
    int bil = 0, rest = 0, sec = 0;

    while(cin >> bil && bil)
    {
        if(sec) cout << endl;
        int w[4] = {}, p[4],  minw[] = {MAXC, MAXC, MAXC, MAXC}, minwsum = MAXC * 4;
        REP(4) cin >> w[i] ;

        for(p[0] = 0; p[0] <= w[0]; p[0]++)for(p[1] = 0;p[1] <= w[1]; p[1]++)
            for(p[2] = 0; p[2] <= w[2]; p[2]++)for(p[3] = 0; p[3] <= w[3]; p[3]++)
            {
                int sumpay = 0; REP(4) sumpay += p[i] * COIN[i];
                int r[4] = {}; 
                rest = sumpay - bil;
                if(rest < 0) continue;

                for(int j=3;j>=0;j--){ r[j] = rest /COIN[j]; rest = rest % COIN[j]; }
                
                int muda = 0;
                REP(4)if(p[i] * r[i] > 0){ muda = 1;}
                if(muda ) continue;

                int sumc = 0; REP(4) sumc += w[i] - p[i] + r[i];
                if(sumc < minwsum)
                {
                    REP(4) minw[i] = w[i] - p[i] + r[i];
                    minwsum = sumc;
                }
            }
        REP(4)if(w[i] - minw[i] > 0) cout << COIN[i] << " " << w[i] - minw[i] << endl;

        sec = 1;
    }

    return 0;
}

Measured memory_bytes: 1164
#include<bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
int main() {
int N;
  int D;
  int X;
  cin >>N>>D>>X;
  vector<int> A(N);
  rep(i,N) {
cin >>A.at(i);
  }
  
  vector<int>count(N);
  rep(i,N)  {
    repl(j,0,10000) {
      if(j*A.at(i)+1<=D) {
        count.at(i)++;
      }
    }
  }
  
  //cout<<count.at(0)<< count.at(1)<<count.at(2)<< endl;
  int sum=X;
  rep(i,N) {
    sum +=count.at(i);
  }
  
  cout << sum<< endl;
}
    
        
 

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <stdio.h>
using namespace std;
int mod1 = 1000000007;
const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit()
{
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++)
  {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

// 二項係数計算
long long COM(int n, int k)
{
  if (n < k)
    return 0;
  if (n < 0 || k < 0)
    return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
bool is_integer(double x)
{
  return floor(x) == ceil(x);
}

int main()
{
  // 前処理
  COMinit();

  // 計算例
  int s;
  cin >> s;
  int cnt = 0;
  for (int i = 1;; i++)
  {
    int r = s - i * 3;
    if (r < 0)
    {
      break;
    }
    // rC(i-1)
    cnt += COM(r + i - 1, i - 1);
    cnt %= mod1;
  }
  cout << cnt << endl;
}


Measured memory_bytes: 15580
#include <bits/stdc++.h>
using namespace std;
 
#define MAXN (int)(2*1e5 + 1)
#define MAXL 20
#define F first
#define endl "\n"
#define S second
#define MOD (int)(1e9 + 7)
#define MOD2 (lli) 998244353  
#define lli long long int
#define sz(a) int(a.size())
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};
int dddx[] = {1, -1, 0, 0, 1, 1, -1, -1};
int dddy[] = {0, 0, 1, -1, 1, -1, 1, -1};

vector<int> vec[MAXN];
int dis[MAXN], n, m, vis[MAXN];

void read(){
  cin >> n >> m;
  for(int i=0;i<m;i++){
    int a, b;
    cin >> a >> b;
    vec[a].push_back(b);
  }
}

int solve(int x, int atual){
  vis[x] = 1;
  if(dis[x] != -1) return dis[x];
  
  int a = 0;
  for(auto i : vec[x]){
    // if(vis[i]) continue;
    a = max(a, solve(i, atual) + 1);
  }
  // cout << x << " - " << a << endl;
  return dis[x] = a;
}

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  read();
  memset(dis, -1, sizeof dis);

  for(int i=1;i<=n;i++){
    if(!vis[i]) solve(i, 0);
  }

  // for(int i=1;i<=n;i++) cout << i << " _ " << dis[i] << endl;

  int ans = 0;
  for(int i=1;i<=n;i++) ans = max(ans, dis[i]);  

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 11264
using System;

class Program
{
    static void Main(string[] args)
    {
        var nk = Console.ReadLine().Split();
        var n = int.Parse(nk[0]);
        var k = int.Parse(nk[1]);
        var d = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);

        for (int i = n; i < int.MaxValue; i++)
        {
            var x = i;
            var any = false;
            while (0 < x)
            {
                for (int j = 0; j < k; j++)
                {
                    any |= x % 10 == d[j];
                }
                x /= 10;
            }

            if (!any)
            {
                Console.WriteLine(i);
                return;
            }
        }
    }
}


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

int n;

bool check(string& s) {

	if (n < stoi(s)) {
		return false;
	}

	bool b[3] = { false, false, false };
	for (auto& i : s) {
		if (i == '3') {
			b[0] = true;
		}
		else if (i == '5') {
			b[1] = true;
		}
		else if (i == '7') {
			b[2] = true;
		}
	}
	
	return b[0] & b[1] & b[2];
}

int main()
{
	cin >> n;

	queue<string> q;
	q.push("3");
	q.push("5");
	q.push("7");

	int ret = 0;
	while (!q.empty()) {

		string& s = q.front();

		if (check(s)) {
			++ret;
		}

		if (s.size() < 9) {
			q.push(s + "3");
			q.push(s + "5");
			q.push(s + "7");
		}

		q.pop();
	}

	cout << ret << endl;

	return 0;
}

Measured memory_bytes: 1664
X,N = map(int,input().split())
p = list(map(int,input().split()))

if not X in p:
    print(X)
else:
    for i in range(100):
        if not (X-i) in p:
            print(X-i)
            break
        elif not (X+i) in p:
            print(X+i)
            break






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

int main() {
  int a,b,c,s;
  cin >> a >> b >> c;
  
  s = a*100 + b*10 + c;
  if((s % 4) == 0){
    cout << "YES";
  }
  else cout << "NO";
  
  
}

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

int main(void) {
    int H,W;
    
    cin >> H >> W;
    
    vector<string> C(H);
    for(int i=0;i<H;i++) {
        cin >> C[i];
    }
    for(int i=0;i<2*H;i++) {
        cout << C[i/2] << "\n";
    }
    
    return 0;
}


Measured memory_bytes: 256
a,b = map(int,input().split())
a,b = a-1, b-1

w,x = a//50, a%50
y,z = b//50, b%50

print(100,100)
res = [['#' for _ in range(100)] for i in range(50)]
res += [['.' for _ in range(100)] for i in range(50)]

for i in range(0,w*2,2):
    for j in range(0,100,2):
        res[i][j] = '.'
for j in range(0,x*2,2):
    res[2*w][j] = '.'

for i in range(99,99-y*2,-2):
    for j in range(0,100,2):
        res[i][j] = '#'
for j in range(0,z*2,2):
    res[99-y*2][j] = '#'

for l in res:
    print(''.join(l))


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
 
#define froop1(a,n) for(int i = a;i < n;i++)
#define froop2(a,n) for(int i = a;i > n;i--)
int main(){
	int N;
  cin >> N;
  vector<int> a(N + 1,0);
  froop1(0,N -1){
    int b;
    cin >> b;
    a.at(b)++;
  }
  froop1(1,N + 1){
    cout << a.at(i) << endl;
  }
  
return 0;
}

Measured memory_bytes: 4048
#include <algorithm>
#include <cmath>
#include <vector>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <ctype.h>
#include <climits>
#include <queue>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)


int main(){
	int n,m;
    cin >> n >> m;
    vector<vector<int>> a(n);
    vector<int> check(n,-1); // -1は未訪問
    
    REP(i,m){
        int A,B;
        cin >> A >> B;
        a[A-1].push_back(B-1);
        a[B-1].push_back(A-1);
    }
	
    check[0]=0;
    queue<int> q;
    q.push(0);
    
    while(!q.empty()){
        int heya = q.front();
        q.pop();
        
        for(int tsugi: a[heya]){
            if(check[tsugi] != -1) continue;
            
            check[tsugi] = heya;
            q.push(tsugi);
        }
    }
    
    
    REP(i,n){
        if(check[i]==-1){
            cout << "No\n";
            return 0;
        }
    }
    
    cout << "Yes\n";
    for(int i=1;i<n;i++){
        cout << check[i]+1 << endl;
    }
    
    return 0;
}

Measured memory_bytes: 10244
#include <bits/stdc++.h>
#define IO_OP std::ios::sync_with_stdio(0); std::cin.tie(0);
#define F first
#define S second
#define V vector
#define PB push_back
#define MP make_pair
#define EB emplace_back
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << #x << " is " << x << endl
#define int ll

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
typedef V<int> vi;

const int INF = 1e9 + 7, N = 1e5 + 7;

int a[N], st[N][20], n;

int qry(int l, int r) {
	int g = __lg(r - l + 1);
	return max(st[l][g], st[r-(1<<g)+1][g]);
}

int ans;

void go() {
	for(int i=1;i<=n;i++)
		st[i][0] = a[i];
	for(int i=1;i<20;i++) {
		for(int j=1;j+(1<<i)-1<=n;j++) {
			st[j][i] = max(st[j][i-1], st[j+(1<<(i-1))][i-1]);
		}
	}
	for(int i=1;i<=n;i++) {
		int l = i+1, r = n;
		while(l <= r) {
			int m = (l + r) / 2;
			if(qry(i, m) > a[i])
				r = m - 1;
			else
				l = m + 1;
		}
 		int l2 = 1, r2 = i - 1;
		while(l2 <= r2) {
			int m = (l2 + r2) / 2;
			if(qry(m, i) > a[i])
				l2 = m + 1;
			else 
				r2 = m - 1;
		}
		int L = r2, R = l;
		if(R == n+1) continue;
		int cans = i - L;
		l = R+1, r = n;
		while(l <= r) {
			int m = (l + r) / 2;
			if(qry(R+1, m) > a[i])
				r = m - 1;
			else
				l = m + 1;
		}
		cans *= l - R;
		ans += cans * a[i];
	}
}

signed main()
{
	IO_OP;
	cin >> n;
	for(int i=1;i<=n;i++)
		cin >> a[i];
	go();
	reverse(a+1, a+n+1);
	go();
	cout << ans << endl;
	
}


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

using namespace std;

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

    int n;
    cin >> n;

    int prev = 2e9 , len = 0 , ans = 0;
    for (int i = 0 ;i < n ;i++) {
        int x;
        cin >> x;
        if (x <= prev)
            len++;
        else
            len = 1;
        prev = x;
        ans = max(ans , len - 1);
    }

    cout << ans;
}

Measured memory_bytes: 256
//
//  main.cpp
//

#include <algorithm>
#include <array>
#include <assert.h>
#include <iostream>
#include <limits>
#include <math.h>
#include <memory>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

using ll = long long;
using ull = unsigned long long;

int main() {
    int N;
    cin >> N;
    int prev = 0;
    for (int i = 0; i < N; i++) {
        int h;
        cin >> h;
        if (h >= prev + 1) {
            prev = h - 1;
        } else if (h == prev) {
            prev = h;
        } else {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}


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

int main()
{

 //freopen("in.txt","r",stdin);
	long long  a;
	int n;
	cin>>n;
	
	int chk_zero=false;
	bool chk=0;

	long long product=1000000000000000000,ans=1;


	 
	for(int i=1;i<=n;i++)
	{
        
        cin>>a;
        if(a==0)
        	chk_zero++;
        else 
        { 
        	ans*=a;
        	product/=a;
        	if(product==0)
        		chk=true;
        }
        
	}
	
	if(chk_zero)
		cout<<0;
	else if(chk)
		cout<<-1;
	else
		cout<<ans;


	return 0;
}

Measured memory_bytes: 3644
def resolve():
    n=int(input())
    import math
    from functools import reduce
    a=0

    def gcd(numbers):
        return reduce(math.gcd, numbers)

    for i in range(1,n+1):
        for j in range(1,n+1):
            for k in range(1,n+1):
                a+=gcd([i,j,k])
    print(a)
resolve()

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

string op = "+*()";

int calc (string exp) {
    if (exp[0] == '(') {
        int count = 0;
        string lhs_;
        for (int i = 1; count || (exp[i] != '*' && exp[i] != '+'); i++) {
            lhs_ += exp[i];
            if (exp[i] == '(') count++;
            if (exp[i] == ')') count--;
        }
        int lhs = calc(lhs_);
        char op = exp[lhs_.size() + 1];
        count = 0;
        string rhs_;
        for(int i = lhs_.size()+2;; i++) {
            if (exp[i] == '(') count++;
            if (exp[i] == ')') if (count == 0) break; else count--;
            rhs_ += exp[i];
        }
        int rhs = calc(rhs_);
        if (op == '*') return min(lhs,rhs);
        else return max(rhs,lhs);

    } else {
        int count = 0;
        int i = 0;
        while (exp[i] == '-') i++, count++;
        int num;
        if (exp[i] == '(') num = calc(string(exp.begin()+i, exp.end()));
        else num = atoi(&exp[i]);

        if (num == 1) return 1;
        else if (count % 2) return num == 2 ? 0 : 2;
        else return num;

    }
}

int main () {
    string str;
    while (cin >> str, str != ".") {
        int res = 0;
        for (int i = 0; i < 3; i++) {
            for (int j = 0; j < 3; j++) {
                for (int k = 0; k < 3; k++) {
                    string tmp(str.begin(), str.end());
                    for (int c = 0; c < str.size(); c++) {
                        if (tmp[c] == 'P') tmp[c] = ('0' + i);
                        if (tmp[c] == 'Q') tmp[c] = ('0' + j);
                        if (tmp[c] == 'R') tmp[c] = ('0' + k);
                    }
                    if (calc(tmp) == 2) res++;
                }
            }
        }

        cout << res << endl;
    }

    return 0;
}

Measured memory_bytes: 1204
-- Try AtCoder
-- author: Leonardone @ NEETSDKASU

main = putStrLn . solve . map read . words =<< getContents

solve [a,b]
    | mod a     3 == 0 = "Possible"
    | mod b     3 == 0 = "Possible"
    | mod (a+b) 3 == 0 = "Possible"
    | otherwise        = "Impossible"

Measured memory_bytes: 508
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(){
  int s;
  scanf("%d",&s);
  int n,i;
  i = 1;
  n = s;
  while(n != 1 && n != 2 && n != 4) {
    if(n%2 == 0) {
      n = n/2;
    } else {
      n = 3 * n + 1;
    }
    i++;
  }
  printf("%d\n",i+3);
  return 0;
}


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

vector<int> tsort_Kahn(const vector<vector<int>>& g) {
    const int V = g.size();

    vector<int> indeg(V,0);
    stack<int>  S;

    // ??¨???????????????????????????????????\?¬???°????¨????
    for(auto& u_out_edges : g)
	for(auto& v : u_out_edges)
	    indeg[v]++;

    // ??\?¬???° == 0 ?????????????¨????
    for(int i=0; i<V; ++i) 
	if( indeg[i] == 0 )
	    S.push(i);

    vector<int> ans;
    while( S.size() > 0 ) {
	int u = S.top(); S.pop();
	ans.emplace_back(u);
	for(auto& v : g[u]) {
	    indeg[v]--;
	    if( indeg[v] == 0 ) S.push(v);
	}
    }
    return ans;
}

int main () {

    int V,E;
    cin >> V >> E;

    vector<vector<int>> g(V);
    for (int i=0; i<E; ++i) {
	int s,t;
	cin >> s >> t;
	g[s].emplace_back(t);
    }

    vector<int> ans = tsort_Kahn(g);
    for(auto& e : ans) {
	cout << e << endl;
    }

    
    
    return 0;
}

Measured memory_bytes: 3696
n,m = map(int,input().split())
if n == 1:
  if m == 1:
    print(1)
  elif m == 2:
    print(0)
  else:
    print(m-2)
elif m == 1:
  if n == 2:
    print(0)
  else:
    print(n-2)
else:
  print(n*m-(n*2+m*2-4))

Measured memory_bytes: 3064
import sys

sys.setrecursionlimit(10 ** 6)
input = sys.stdin.readline
from math import floor, sqrt, factorial, hypot, log  # log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter, defaultdict, deque
from itertools import accumulate, permutations, combinations, product, combinations_with_replacement
from bisect import bisect_left, bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint


def ceil(a, b): return (a + b - 1) // b


inf = float('inf')
mod = 10 ** 9 + 7


def pprint(*A):
    for a in A:     print(*a, sep='\n')


def INT_(n): return int(n) - 1


def MI(): return map(int, input().split())


def MF(): return map(float, input().split())


def MI_(): return map(INT_, input().split())


def LI(): return list(MI())


def LI_(): return [int(x) - 1 for x in input().split()]


def LF(): return list(MF())


def LIN(n: int): return [I() for _ in range(n)]


def LLIN(n: int): return [LI() for _ in range(n)]


def LLIN_(n: int): return [LI_() for _ in range(n)]


def LLI(): return [list(map(int, l.split())) for l in input()]


def I(): return int(input())


def F(): return float(input())


def ST(): return input().replace('\n', '')


def main():
    N = I()
    S = []
    for _ in range(N):
        S.append(ST())
    cnt = Counter(S)
    print("AC x", cnt['AC'])
    print("WA x", cnt['WA'])
    print("TLE x", cnt['TLE'])
    print("RE x", cnt['RE'])

if __name__ == '__main__':
    main()

Measured memory_bytes: 85012
#include <bits/stdc++.h>
#define int long long
using namespace std;

signed main(){
    int n,a,b;
    cin>>n>>a>>b;
    if(a>b)swap(a,b);
    if((b-a)%2==0){
        printf("%lld\n",(b-a)/2);
    }
    else{
        int cost1=min(a-1,n-a),cost2=min(b-1,n-b);
        int ans=0;
        if(cost1>cost2){
            int aim=b-1<n-b?1:n;
            ans+=cost2;
            if(aim==1){
                a-=cost2;
                a--;
                ans++;
                if(a!=aim)ans+=abs(aim-a)/2;
            }
            else{
                a+=cost2;
                a++;
                ans++;
                if(a!=aim)ans+=abs(aim-a)/2;
            }

        }
        else{
            int aim=a-1<n-a?1:n;
            ans+=cost1;
            if(aim==1){
                b-=cost1;
                b--;
                ans++;
                if(b!=aim)ans+=abs(aim-b)/2;
            }
            else{
                b+=cost1;
                b++;
                ans++;
                if(b!=aim)ans+=abs(aim-b)/2;
            }
        }
        cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, l, r) for(int i = (l), i##end = (r);i <= i##end;++i)
using std::cin; using std::cout;
const int maxn = 500200;
typedef long long ll;
const int mod = 998244353;
inline ll pow(ll a,int b,int ans = 1) {
	for(;b;b >>= 1,a = a * a % mod) if(b & 1)
		ans = ans * a % mod;
	return ans;
}
inline ll inverse(int x){ return pow(x, mod - 2); }
typedef double db;
struct T {
	db a, b;
	inline void operator += (const T & y) { a += y.a, b += y.b; }
	inline void operator -= (const T & y) { a -= y.a, b -= y.b; }
	inline int operator < (const T & y) const { return a / b < y.a / y.b; }
} stack[maxn], ps[maxn];
db pre_b[maxn];
int n, L;
int top;
inline void ins(T x) {
	for(;top && x < stack[top];) {
		if(stack[top].b + x.b > L) {
			db rem = L - x.b, p = rem / stack[top].b;
			stack[top].a *= p;
			stack[top].b *= p;
		}
		x += stack[top--];
	}
	stack[++top] = x, pre_b[top] = pre_b[top - 1] + x.b;
	ps[top] = ps[top - 1], ps[top] += x;
}
inline db lol(db x){ return x == x ? x : 0; }
inline db get() {
	int x = std::upper_bound(pre_b + 1, pre_b + top + 1, pre_b[top] - L) - pre_b;
	T ans = ps[top]; ans -= ps[x];
	return (ans.a + (L - ans.b) / stack[x].b * stack[x].a) / L;
}
int main() {
	std::ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> n >> L;
	rep(i, 1, n) {
		int t, v;
		cin >> t >> v;
		ins((T){ (db) t * v, (db) v });
		printf("%.7lf\n", get());
	}
}


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


int main() { 
    ios::sync_with_stdio(false);
    cin.tie(0);
    long long a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << max({a*c, a*d, b*c, b*d}) << '\n';
    return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define N 1000005
typedef long long ll;
const ll LLINF=1ll<<60;
// const int mx=1e5+7;
// int n;
//vector<int> a(mx),b(mx);
// vector<int> g[mx];
// int deg[mx];
// vector<int> adj[mx];
//vector<int> ans;
//---dfs--
//bool visited[mx];
//vector<ll> val(mx,0);

// void dfs(int s,int e,int c1,int c2){
// 	if(a[s]^c1!=b[s]) {ans.push_back(s), c1^=1;}
// 	for(auto u:adj[s]){
// 		if(u!=e){
// 			dfs(u,s,c2,c1);
// 		}
// 	}
// }
//---dfs---

//---primes---
// const int N = 1e7 + 10;

// bool prime[N];
 
// int spf[N];
 
// void calc(){
// 	for(int i = 2; i<1e4; i++){
// 		if(prime[i])
// 			continue;
// 		spf[i] = i;
// 		for(int j = i * i; j < N; j += i){
// 			prime[j] = 1;
// 			spf[j] = i;
// 		}
// 	}
// 	for(int i = 2; i < N; i++)
// 		if(!spf[i])
// 			spf[i] = i;
// }

// vector<pair<int,int>> getp(int x){
// 	int curr=x;
// 	vector<pair<int,int>> ans;
// 	while(curr>1){
// 		int a=spf[curr];
// 		int count=0;
// 		while(curr%a==0){ curr/=a; count++;}
// 		ans.push_back(make_pair(a,count));
// 	}
// 	return ans;
// }

// bool ispr(int n) {
// 	if(n==1) return false;
//     for (int i=2;i*i<=n;++i){
//         if(n%i==0){
//             return false;
//         }
//     }
//     return true;
// }
//---primes---

//---segment_tree---
// int upd(int t,int val,int l,int r,int y, int z){
// 	if(y<l||y>r) return tr[val];
// 	if(l==r) return tr[val]=z;
// 	int s=(l+r)/2;
// 	upd(t^1,2*val+1,l,s,y,z);
// 	upd(t^1,2*val+2,s+1,r,y,z);
// 	if(t) tr[val]=tr[2*val+1]|tr[2*val+2];
// 	else tr[val]=tr[2*val+1]^tr[2*val+2];
// 	return tr[val];
// }
//int query(){}
//---segment_tree---


int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);cout<<setprecision(25);
	int T=1;
	//cin>>T;
	while(T--){
		int n,x,t;
		cin>>n>>x>>t;
		int p=(n+x-1)/x;
		ll ans=1ll*p*t;
		cout<<ans<<"\n";	
 	}
}

Measured memory_bytes: 3620
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
    int n,k;cin >> n >> k;
    long long int h[200200];
    for(int i = 0; i < n; i++) cin >> h[i];
    sort(h, h + n);
    if(n <= k){
        cout << 0 << "\n";
    }
    else{
        long long int s = 0;
        for(int i = 0; i < n - k; i++){
            s += h[i];
        }
        cout << s << "\n";
    }
}

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

int main() {
    int N;
    cin >> N;
    vector<int> P(N);
    int count = 0;
    int m = 2000000;
    rep(i, N) {
        int p;
        cin >> p;
        m = min(m, p);
        if (p <= m) count++;
    }
    cout << count << endl;
}

Measured memory_bytes: 1024
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)
INF = float('inf')

X = map(int, input().split())
for i, x in enumerate(X, start=1):
    if x == 0:
        print(i)

Measured memory_bytes: 9176
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner input = new Scanner(System.in);
		int N = input.nextInt();
		int M = input.nextInt();
		int X = input.nextInt();
		long[][] data = new long[N][M+1]; //Extra slot for cost
		for (int i = 0; i < N; i++) {
			data[i][0] = input.nextInt();
			for (int j = 1; j <= M; j++) {
				data[i][j] = input.nextInt();
			}
		}
		long cost = Integer.MAX_VALUE;
		String[] possibilities = Recur(N).split(" ");
		//System.out.println(Recur(N));
		for (int i = 0; i < possibilities.length; i++) {
			String x = possibilities[i];
			long[] cmp = new long[M];
			long curcost = 0;
			for (int j = 0; j < N; j++) {
				if (x.charAt(j)=='Y') {
					curcost+=data[j][0];
					for (int k = 1; k<=M; k++) {
						cmp[k-1]+=data[j][k];
					}
				}
			}
			boolean exceeded = true;
			for (int j = 0; j < M; j++) {
				if (cmp[j]<X) {
					exceeded=false;
					break;
				}
			}
			if (exceeded) cost = Math.min(cost, curcost);
		}
		if (cost!=Integer.MAX_VALUE) System.out.println(cost);
		else System.out.println(-1);
	}
	public static String Recur(int N) {
		if (N==1) return "Y N ";
		String[] arr = Recur(N-1).trim().split(" ");
		String ans = "";
		for (int i = 0; i < arr.length; i++) {
			ans+=arr[i]+"Y ";
		}
		for (int i = 0; i < arr.length; i++) {
			ans+=arr[i]+"N ";
		}
		return ans.trim();
	}
}

Measured memory_bytes: 45432
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(a) a.begin(), a.end()
#define P pair<int, int>
#define F first
#define S second
#define mod 1000000007
#define MOD 998244353
#define INF 40000000000000000
int dx8[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
int dy8[8] = {1, 1, 1, 0, -1, -1, -1, 0};
int dx4[4] = {-1, 0, 1, 0};
int dy4[4] = {0, -1, 0, 1};
signed main(void) {
    int h, w;
    cin >> h >> w;
    if(h==1||w==1)cout<<1<<endl;
    else cout<<(h*w+1)/2<<endl;
}


Measured memory_bytes: 256
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define rep(i,n) for(int i = 0; i < n; i++)
#define reps(i,j,n) for(int i = j; i < n; i++)
#define rrep(i,j,n) for(int i = j-1; i >= n; i--)
#define prec(n) fixed << setprecision(n)
#define print_array(v) rep(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define fi first
#define se second
#define endl "\n"
using namespace std;

//constexpr int inf = 2147483647;
//constexpr int64_t inf64 = 9223372036854775807;
//constexpr int mod = 1e9+7;

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

  int h1, m1, h2, m2, k;
  cin >> h1 >> m1 >> h2 >> m2 >> k;

  m1 += 60 * h1;
  m2 += 60 * h2;
  cout << m2 - m1 - k << endl;
  return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define srep(i,s,t) for (int i = s; i < t; i++)
#define drep(i,n) for(int i = (n)-1; i >= 0; i--)
#define MOD 1e9+7;
using namespace std;
using Graph = vector<vector<int>>;
typedef vector<vector<char>> field_t;
typedef long long ll;
typedef pair<int, int> point_t;
vector<vector<pair<int,int>>> z(100010);


signed main()
{
    long double A,ans;
    long double B;
    cin >> A >> B;
    B*=10000;
    ans+=A*B;
    ans/=10000;
    cout << (ll) ans <<endl;
  


    return 0;
}

Measured memory_bytes: 5428
package main

import (
	"fmt"
)

func main() {
	var a, b, c, x, count int
	fmt.Scan(&a, &b, &c, &x)
	for i := 0; i <= a; i++ {
		for j := 0; j <= b; j++ {
			for k := 0; k <= c; k++ {
				if 500*i+100*j+50*k == x {
					count++
				}
			}
		}
	}
	fmt.Println(count)
}


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

signed main() {
	int a, b;
	cin >> a >> b;
	if(b < 0) {
		if ((b - a+1) & 1) cout << "Negative" << endl;
		else cout << "Positive" << endl;
	}
	else if(a > 0) cout << "Positive" << endl;
	
	else cout << "Zero" << endl;
}


Measured memory_bytes: 3644