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

//template
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll;
const int inf = 0x3fffffff; const ll INF = 0x1fffffffffffffff; const double eps=1e-12;
void tostr(ll x,string& res){while(x)res+=('0'+(x%10)),x/=10; reverse(ALL(res)); return;}
template<class T> inline bool chmax(T& a,T b){ if(a<b){a=b;return 1;}return 0; }
template<class T> inline bool chmin(T& a,T b){ if(a>b){a=b;return 1;}return 0; }
//template end



int main(){
   int a,b; scanf("%d%d",&a,&b);
   printf("%d\n",(a+b-1)/b);
   return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const long long INF = 1ll<< 61;
int main(){
  int64_t n,k;
  cin >> n >> k;
  int64_t a[n];
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  sort(a,a+n);
  long long Left=-INF,Right=INF;
  while(Right-Left>1){
    int64_t x=(Left+Right)/2;
    int64_t S=0,T=0;    
    for(int64_t i=0;i<n;i++){
      if(a[i]>0){
        int l2=-1,r2=n;
        while(r2-l2>1){
          int m=(l2+r2)/2;
          if(a[i]*a[m]<=x)l2=m;
          else r2=m;
        }
        S+=r2;
      }else if(a[i]<0){
        int l2=-1,r2=n;
        while(r2-l2>1){
          int m=(l2+r2)/2;
          if(a[i]*a[m]<=x)r2=m;
          else l2=m;
        }
        S+=n-r2;
      }else if(x>=0)S+=n;
      if(a[i]*a[i]<=x)T++;
    }
    int64_t num=(S-T)/2;
    if(num>=k)Right=x;
    else Left=x;
  }
  cout << Right << endl;
}


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

#define pb push_back
#define mk make_pair
#define lob lower_bound
#define upb upper_bound
#define fst first
#define scd second

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

inline int read(){
	int f=1,x=0;char ch=getchar();
	while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
	while(isdigit(ch)){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
inline ll readll(){
	ll f=1,x=0;char ch=getchar();
	while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
	while(isdigit(ch)){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}

const int MAXN=1e6+5;
int n;
bool vis[MAXN];
int main() {
	n=read();if(n==1){puts("1");return 0;}
	deque<pii>dq;dq.pb(mk(1,1));
	while(!dq.empty()){
		pii u=dq.front();dq.pop_front();
		if(vis[u.fst])continue;
		if(u.fst==0){cout<<u.scd<<endl;return 0;}
		vis[u.fst]=1;
		dq.push_front(mk(u.fst*10%n,u.scd));
		dq.push_back(mk((u.fst+1)%n,u.scd+1));
	}return 0;
}

Measured memory_bytes: 1152
function mkdivisor(n::Int) 
  divisors=Int[] 
  for i=1:div(n^0.5,1) 
    if n%i==0 
      push!(divisors,i) 
      if i!= fld(n,i); push!(divisors,fld(n,i));end
    end
  end
  sort!(divisors)
  return divisors
end

macro p(z);:((x->parse(Int,x)).(split($z)));end
a,b,k=@p(readline())
print([i for i=mkdivisor(a) if i in mkdivisor(b)][end-k+1])

Measured memory_bytes: 120240
/*
AizuOnline A2401
Title Equation
13/3/24 WA
*/
#include <stdio.h>
// Select Below
//#include <stdlib.h>
#include <string.h>
//#include <float.h>
//#include <math.h>
//#include <limits.h>
//Global data section
#define MAXLEN 1001
#define NVARS 10
char expr[MAXLEN];

//
void strreplace(char * s,int len,char from,char to)
{
  int i;
  for(i=0;i<len;i++)
    if(s[i]==from)
      s[i]=to;
}
char * find_binary_operator2(char * s,int len,char op1,char op2)
{
  int i,d;
  char *p;
  
  d=0;
  for(i=len-1;i>=0;i--)
    { 
      if(s[i]==')')
	d++;
      else if (s[i]=='(')
	d--;
      else
	{
	  if((op1==s[i]) && (op2==s[i+1]) && d==0)
	    return(&s[i]);
	}
    }
  return(NULL);
}

char * find_binary_operator(char * s,int len,char op)
{
  int i,d;
  char *p;
  
  d=0;
  for(i=len-1;i>=0;i--)
    { 
      if(s[i]==')')
	d++;
      else if (s[i]=='(')
	d--;
      else
	{
	  if((op==s[i]) && d==0)
	    return(&s[i]);
	}
    }
  return(NULL);
}
int logical_equal(int e1,int e2)
{
#ifdef DEBUG
  printf("EQ:%d %d\n",e1,e2);
#endif
  return((e1==e2)?1:0);
}
int logical_and(int e1,int e2)
{
  return((e1 && e2)?1:0);
}
int logical_or(int e1,int e2)
{
  return((e1 || e2)?1:0);
}
int logical_naraba(int e1,int e2)
{
  return((e1<=e2)?1:0);
}
int logical_cpl(int e1)
{
  return((!e1)?1:0);
}
int logical_eval(char * exp,int len)
{
  char * r;
  
  if(len==1)
    {
      if(exp[0]=='T')
	return(1);
      else
	return(0);
    }
  if(r=find_binary_operator(exp,len,'='))
    {
      return(logical_equal(logical_eval(exp,r-exp),
			   logical_eval(r+1,len-(r-exp+1))));
    }
  if(r=find_binary_operator(exp,len,'*'))
    {
      return(logical_and(logical_eval(exp,r-exp),
			   logical_eval(r+1,len-(r-exp+1))));
    }
  if(r=find_binary_operator(exp,len,'+'))
    {
      return(logical_or(logical_eval(exp,r-exp),
			   logical_eval(r+1,len-(r-exp+1))));
    }
  if(r=find_binary_operator2(exp,len,'-','>'))
    {
      return(logical_naraba(logical_eval(exp,r-exp),
			   logical_eval(r+2,len-(r-exp+2))));
    }
  if(exp[0]=='-')
     return(logical_cpl(logical_eval(exp+1,len-1)));
  else   if(exp[0]=='(' && exp[len-1]==')')
    return(logical_eval(exp+1,len-2));
  return(0);
}
int check_log_equation(char * exp,int len)
{
  int i,j;
  char wk[MAXLEN];
  memset(wk,0,MAXLEN);

    for(i=0;i<1024;i++)   // 2^NVARS
    {
      memcpy(wk,exp,len);
      for(j=0;j<10;j++)
	  {
	    strreplace(wk,len,'a'+j,(i & (1<<j)?'T':'F'));
	  }
#ifdef DEBUG
      printf("%*s\n",len+1,wk);
#endif
      
      if(!logical_eval(wk,len))
	return(0);
    }
    return(1);

}
main()
{
  char *p;
  int ret;

  while(EOF!=scanf("%s",expr) && expr[0]!='#')
    {
      ret=check_log_equation(expr,strlen(expr));

      printf("%s\n",ret?"YES":"NO");
    }
  return(0);
}

Measured memory_bytes: 584
H,W = map(int,input().split())
S = [list(input()) for i in range(H)]
dpyoko = [[1]*(W) for i in range(H)]
for j in range(W):
    for i in range(H):
        if S[i][j] == '#':
            dpyoko[i][j] = 0
        else:
            if j != 0:
                dpyoko[i][j] += dpyoko[i][j-1]
for j in range(W-1,-1,-1):
    for i in range(H):
        if dpyoko[i][j] == 0:
            continue
        if j == W-1:
            continue
        dpyoko[i][j] = max(dpyoko[i][j],dpyoko[i][j+1])
dptate = [[1]*(W) for i in range(H)]
for i in range(H):
    for j in range(W):
        if S[i][j] == '#':
            dptate[i][j] = 0
        else:
            if i != 0:
                dptate[i][j] += dptate[i-1][j]
for i in range(H-1,-1,-1):
    for j in range(W):
        if dptate[i][j] == 0:
            continue
        if i == H-1:
            continue
        dptate[i][j] = max(dptate[i][j],dptate[i+1][j])
res = 0
for i in range(H):
    for j in range(W):
        res = max(res,dptate[i][j]+dpyoko[i][j]-1)
print(res)       


Measured memory_bytes: 244872
fun main(args: Array<String>) {
    val (N, K) = readLine()!!.split(" ").map(String::toInt)
    val (GUU, CHOKI, PAR) = readLine()!!.split(" ").map(String::toInt)
    val T = readLine()!!

    fun calc(c: Char): Int {
        return when (c) {
            'r' -> PAR
            's' -> GUU
            else -> CHOKI
        }

    }

    var scores = IntArray(T.length)
    for (i in T.indices) {
        scores[i] = if (i < K || (T[i] != T[i - K] || scores[i - K] == 0)) {
            calc(T[i])
        } else {
            0
        }
    }
    println(scores.sum())

}



Measured memory_bytes: 41572
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = ll(1e9)+1;
const ll mod = ll(1e9)+7;
#define rep0(i,n) for(ll (i) = 0; (i) < (n); ++(i))
#define rrep0(i,n) for(ll (i) = (n) - 1; (i) >= 0; --(i))
#define rep1(i,n) for(ll (i) = 1; (i) <= (n); ++(i))
#define rrep1(i,n) for(ll (i) = (n); (i) >= 1; --(i))
#define nfor(i,a,b) for(ll (i) = (a); (i) < (b); ++(i))
#define pf(x) cout << (x) << endl
#define all(x) (x).begin(),(x).end()

ll gcd(ll a,ll b){
    if(a < b)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 factorial(ll n){
    ll t = 1;
    rep1(i, n)t *= i;
    return t;
}

ll combinations(ll n, ll k) {
    ll r = 1;
    rep1(i, k)r = r * n-- / i;
    return r;
}

int main(){
    ll n,k,ans = 0,cnt;
    cin >> n >> k;
    cnt = k;
    while (1) {
        ++ans;
        if(n < cnt)break;
        cnt *= k;
    }
    pf(ans);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#define ALL(a)    a.begin(), a.end() 
#define rep(i, K, N)  for(long long int i = K; i < N; i++)
#define ll long long int
using namespace std;

int main() {
ll N;cin >> N;
ll AC = 0, WA = 0, TLE = 0, RE = 0;
rep(i, 0, N){
string S;cin >> S;
if(S == "AC")AC++;
if(S == "WA")WA++;
if(S == "TLE")TLE++; 
if(S == "RE")RE++;


}

cout << "AC x " << AC << endl;

cout << "WA x " << WA << endl;

cout << "TLE x " << TLE << endl;

cout << "RE x " << RE << endl;

}

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

using namespace std;

typedef long ll;


bool ps[9][9];

int n, m;

#define DB

ll dfs(int node, vector<bool>& bs) 
{
	ll as = 0;
	vector<bool> st(bs);
	st[node] = true;

	for (int i = 0; i < n; ++i) {
		if ( ! ps[node][i]) continue;
		if (st[i]) continue;

		as += dfs(i, st); 
	}

	bool isOK = true;
	for (int i = 0; i < n; ++i) {
		if( ! st[i]) { isOK = false; break; }
	}

	if (isOK) as++;
	return as;
}

int main(int, char**)
{
	ll ans;
	cin >> n >> m;

	for (int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		--a; --b;
		ps[a][b] = ps[b][a] = true;
	}

	vector<bool> st(n, false);
	ans = dfs(0, st);

	cout << ans << endl;

	return 0;
}



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

const int INF = 1001001001;

int main()
{
    int h, w, sy, sx, gy, gx;
    cin >> h >> w >> sy >> sx >> gy >> gx;
    sy--; sx--; gy--; gx--;
    vector<string> s(h);
    for(int i = 0; i < h; i++) cin >> s[i];
    vector<vector<int>> cost(h, vector<int>(w, INF));
    deque<pair<int, int>> q;
    cost[sy][sx] = 0;
    q.push_back({sy, sx});
    while (!q.empty()) {
        int y = q.front().first;
        int x = q.front().second;
        q.pop_front();
        for(int ny = y - 2; ny <= y + 2; ny++) {
            for(int nx = x - 2; nx <= x + 2; nx++) {
                if(ny < 0 || ny >= h || nx < 0 || nx >= w) continue;
                if(s[ny][nx] == '#') continue;
                bool warp = (abs(y - ny) + abs(x - nx) != 1);
                int c = cost[y][x];
                if(warp) c++;
                if(c < cost[ny][nx]) {
                    cost[ny][nx] = c;
                    if(warp) q.push_back({ny, nx});
                    else q.push_front({ny, nx});
                }
            }
        }
    }
    if(cost[gy][gx] == INF) cout << -1 << endl;
    else cout << cost[gy][gx] << endl;
    return 0;
}


Measured memory_bytes: 9440
#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <list>

auto& in = std::cin;
auto& out = std::cout;
#define all_range(C) std::begin(C), std::end(C)
const double PI = 3.141592653589793238462643383279502884197169399375105820974944;

int32_t D,G;
int32_t c[12];
int32_t p[12];

int main()
{
	using std::endl;
	in.sync_with_stdio(false);
	out.sync_with_stdio(false);
	in.tie(nullptr);
	out.tie(nullptr);

	in >> D>>G;
	for (int32_t i = 1; i <= D; i++)
	{
		in >> p[i] >> c[i];
	}

	int32_t res = 10000000;
	for (uint32_t mask = 0; mask < (1u << D); mask++)
	{
		int32_t count = 0;
		int32_t score = 0;
		for (size_t i = 1; i <= D; i++)
		{
			if (mask&(1 << (i - 1))) {
				count += p[i];
				score += c[i];
				score += 100*i*p[i];
			}
		}

		if (score  >= G) {
			res = std::min(res, count);
			continue;
		}

		for (size_t i = D; i >= 1; i--)
		{
			if (mask&(1 << (i - 1))) {
			}
			else {
				if (score + 100 * i*p[i] < G) {
					count += p[i];
					score += 100 * i*p[i];
				}
				else {
					count += (G - score + 100 * i - 1) / (100 * i);
					score += ((G - score + 100 * i - 1) / (100 * i))*((100 * i));
					break;
				}
			}
		}
		if (score >= G) {
			res = std::min(res, count);
			continue;
		}
	}

	out << res << endl;

	return 0;
}
#endif


Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
string s,t,a;
int b;
int main(){
	cin>>s>>t;
	a=t+s;
	b=s.size()+t.size();
	for(int i=0;i<b;i++)
	  cout<<a[i];
	return 0;
}

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

int gcd(int a, int b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}

int main() {
  ll A, B;
  cin >> A >> B;

  cout << A * B / gcd(A, B) << endl;
  return 0;
}

Measured memory_bytes: 3576
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
typedef int long long ll;

using namespace std;
int main(){
    
    int n;
    cin>>n;
    int ans=100000;
    rep(i,n){
        ans=ans*1.05;
        if(ans%1000>0){
            ans=ans/1000;
            ans++;
            ans=ans*1000;
        }
    }
    
    
    cout<<ans<<endl;
    
    return 0;
}


Measured memory_bytes: 3000
#include <bits/stdc++.h>
using namespace std;
int a[100005];
vector<pair<int, int> > p;
int main(){
	ios_base::sync_with_stdio(0), cin.tie(0);
	int N, M; cin>>N>>M;
	for(int i=0; i<N; ++i) cin>>a[i];
	for(int i=1; i<N; ++i){
		int s = a[i-1]%M+1, e = a[i];
		if(s<=e){
			p.emplace_back(s, -1);
			p.emplace_back(e, e-s+1);
			p.emplace_back(e+1, s-e);
		}
		else{
			p.emplace_back(1, -1);
			p.emplace_back(e, M-s+e+1);
			p.emplace_back(e+1, -M+s-e);
			p.emplace_back(s, -1);
		}
	}
	sort(p.begin(), p.end());
	long long x = 0;
	for(int i=1; i<N; ++i) x += min((a[i]+M-a[i-1])%M, 1+(a[i]-1)%M);
	long long ans = x, m = 0; 
	for(int i=1, j=0; i<M; ++i){
		while(j < p.size() && p[j].first <= i) m += p[j].second, ++j;
		x += m;
		ans = min(ans, x);
	}
	cout<<ans;
	return 0;
}

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

using namespace std;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define REP(i, n) FOR(i, 0, n)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define RREP(i, n) RFOR(i, n, 0)
#define MFOR(i, m) for(auto i=(m).begin();i!=(m).end();i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((int)(x).size())

typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1 << 30;

template<typename T>
void printv(vector<T> const& s) {
  REP(i, SZ(s)) {
    cout << s[i] << " ";
  }
  cout << endl;
}

int main () {
  cin.tie(0);
  cout << setprecision(10);

  while(1) {
    int n, m;cin >> n >> m;
    if(n == 0 && m == 0) break;
    vector<pair<int, P>> p(m);
    REP(i, m) {
      cin >> p[i].fi >> p[i].se.fi >> p[i].se.se;
    }
    sort(ALL(p));
    vector<bool> infected(n+1, false);
    infected[1] = true;
    REP(i, m) {
      if(infected[p[i].se.fi]) infected[p[i].se.se] = true;
    }
    int ans = 0;
    REP(i, n+1) {
      ans += infected[i];
    }
    cout << ans << endl;
  }
}



Measured memory_bytes: 3292
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll dp[3005][3005],a[3005],ans=0ll;
const ll MOD=1e9+7ll;
int n;
string s;
int main()
{
    cin>>n>>s;
    dp[1][1]=1;
    for(int i=2;i<=n;i++)
    {
        for(int j=1;j<i;j++)
            a[j]=(a[j-1]+dp[i-1][j])%MOD;
        for(int j=1;j<=n;j++)
        {
            int l,r;
            if(s[i-2]=='<')
            {
            	l=1;
				r=j-1;
			}
            else
            {
            	l=j;
            	r=i-1;
			}
            if(l<=r)dp[i][j]=(dp[i][j]+a[r]-a[l-1]+MOD)%MOD;
        }
    }
    for(int i=1;i<=n;i++)
    {
    	ans+=dp[n][i];
    	ans%=MOD;
	}
    cout<<ans<<endl;
	return 0;
}

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

#define f(i,a,b) for( ll i = a; i < b ; i++ ) 
#define af(i,a,b) for( ll i = a; i >= b ; i--)
#define rep(i,a,b,k) for(ll i = a; i < b ; i+= k )
#define arep(i,a,b,k) for( ll i = a; i >= b ; i-= k)
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz(a) (ll) a.size()
#define all(a) a.begin(), a.end()
#define sor(a) sort( a.begin(), a.end() )
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define inter ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr)

// policy-based
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;	


using namespace std;


typedef int ll; // int or long long
typedef long double ld;
typedef pair<ll,ll> ii ;
typedef vector<ll>  vi ;
typedef vector<ii> vii ;

/*
typedef tree<
ll,
null_type,
less<ll>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
*/
 
const ll MAX = 2e6+10;
const ll inf = 1e9;


int main(){
	fastio;
	ll a;
	cin >> a;
	cout<<a+a*a+a*a*a<<endl;
	return 0;
}


Measured memory_bytes: 3652
package main

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

const (
	initialBufSize = 100000
	maxBufSize     = 10000000
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wt = bufio.NewWriter(os.Stdout)
)

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

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

func nextInt2() (int, int) {
	return nextInt(), nextInt()
}

func nextInt3() (int, int, int) {
	return nextInt(), nextInt(), nextInt()
}

func nextInt4() (int, int, int, int) {
	return nextInt(), nextInt(), nextInt(), nextInt()
}

func nextInts(n int) []int {
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}
	return slice
}

func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(next(), 64)
	return f
}

func nextFloat64s(n int) []float64 {
	slice := make([]float64, n)
	for i := 0; i < n; i++ {
		slice[i] = nextFloat64()
	}
	return slice
}

func putf(format string, a ...interface{}) {
	fmt.Fprintf(wt, format, a...)
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, initialBufSize), maxBufSize)
	defer wt.Flush()

	s, t := next(), next()
	ok := true
	for i := range s {
		ok = ok && (s[i] == t[i])
	}
	if ok {
		puts("Yes")
	} else {
		puts("No")
	}
}


Measured memory_bytes: 1764
package main

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

func main() {
	n := getInt()
	k := getInt()
	hs := make([]int, n)
	for i := range hs {
		hs[i] = getInt()
	}
	sort.Ints(hs)

	ans := 1 << 60
	d := k - 1
	for i := 0; i < n-d; i++ {
		ans = min(ans, hs[i+d]-hs[i])
	}

	fmt.Println(ans)
}

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

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

var sc = bufio.NewScanner(os.Stdin)

func init() {
	// buf := 200001
	// sc.Buffer(make([]byte, buf), buf)
	sc.Split(bufio.ScanWords)
}

func getInt() int {
	i, err := strconv.Atoi(getString())
	if err != nil {
		panic(err)
	}
	return i
}

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


Measured memory_bytes: 3072
def main():
    S = int(input())
    INF = int(1e9+7)
    combs = [0 for _ in range(S+1)]
    cum = 0
    for i in range(3, S+1):
        if i < 3:
            combs[i] = 1

        if i >= 3 and i < 6:
            combs[i] = 1
        else:
            cum += combs[i-3]
            cum = cum % INF
            combs[i] = cum + 1

    ans = combs[-1]
    """
    for i in range(3, S):
        if S % i == 0:
            ans = 1
    """
    print(ans % INF)
    
    
if __name__ == '__main__':
    main()

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

using namespace std;
int h[100005],dp[100005];
int main(){
	int n;
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>h[i];
	}
	dp[1]=0;
	dp[2]=abs(h[2]-h[1]);
	for(int i=3;i<=n;i++){
		dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
	}
	cout<<dp[n];
	return 0;
}

Measured memory_bytes: 1024
import itertools
from collections import deque
from sys import stdin
input = stdin.readline


def main():
  H, W = list(map(int, input().split()))

  M = [input()[:-1] for _ in range(H)]

  def bfs(start):
    dist = [[float('inf')]*W for _ in range(H)]
    dist[start[0]][start[1]] = 0

    is_visited = [[0]*W for _ in range(H)]
    q = deque([start])
    max_ = 0

    while len(q):
      now_h, now_w = q.popleft()
      if M[now_h][now_w] == '#':
        return
      # is_visited[now_h][now_w] = 1
      is_visited[now_h][now_w] = float('inf')
      for next_h, next_w in ((now_h+1, now_w),
                             (now_h-1, now_w),
                             (now_h, now_w-1),
                             (now_h, now_w+1)):

        if not(0 <= next_h < H) or not(0 <= next_w < W) or \
           (dist[next_h][next_w] != float('inf')) or \
           M[next_h][next_w] == '#':
           # (is_visited[next_h][next_w] == float('inf')) or \
          continue

        dist[next_h][next_w] = dist[now_h][now_w] + 1
        max_ = max(max_, dist[next_h][next_w])
        q.append((next_h, next_w))
    return max_

  max_ = 0
  for h in range(H):
    for w in range(W):
      if M[h][w] == '.':
        max_ = max(bfs((h, w)), max_)

  print(max_)


if(__name__ == '__main__'):
  main()


Measured memory_bytes: 9392
#include <cassert>

#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 <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

// C++
#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 <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
//#include <boost/foreach.hpp>
//#include <boost/range/algorithm.hpp>
#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define ll long long
#define Sort(v) sort(all(v))
#define INF 1e9
#define LINF 1e18
#define END return 0
#define pb push_back
#define se second
#define fi first
#define pb push_back
#define all(v) (v).begin() , (v).end()
#define MP make_pair
#define MOD 1000000007LL
#define int long long
using namespace std;
int day[12]={31,28,31,30,31,30,31,31,30,31,30,31};
struct edge{int to,cost;};
typedef pair<int,int> P;

bool isupper(char c){if('A'<=c&&c<='Z')return 1;return 0;}
bool islower(char c){if('a'<=c&&c<='z')return 1;return 0;}
bool isPrime(int x){if(x==1)return 0;if(x==2)return 1;if(x%2==0)return 0;for(int i=3;i*i<=x;i++)if(x%i==0)return 0;return 1;}
bool iskaibun(string s){for(int i=0;i<s.size()/2;i++)if(s[i]!=s[s.size()-i-1])return 0;return 1;}
bool isnumber(char c){return ('0'<=c&&c<='9');}
bool isalpha(char c){return (isupper(c)&&islower(c));}

signed main (){
    int n,a,b;
    cin>>n>>a>>b;

    cout<<min(a,b)<<" ";
    cout<<max(0LL,a+b-n)<<endl;
}
/*
*/


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

using namespace std;

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

std::vector<std::string> split(const std::string &str, char sep){
    std::vector<std::string> v;
    std::stringstream ss(str);
    std::string buffer;
    while( std::getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}

set<int> solve(std::vector<int> v, set<int> st){
	if (v.size() == 0) {
		return st;
	}

	int last = v.back();
	v.pop_back();

	if (last == 0) {
		return solve(v,st);
	}
	else {
		set<int> newst;
		for(auto itr = st.begin(); itr != st.end(); itr++){
			newst.insert(*itr + last);
			newst.insert(*itr - last);
		}
		return solve(v,newst);
	}

}

int main(int argc, char const *argv[]) {
	string s;
	std::cin >> s;
	int x,y;
	std::cin >> x >> y;

	std::vector<int> vecx;
	std::vector<int> vecy;
	std::vector<string> splits(split(s,'T'));

	// x方向、y方向にどれだけ進むかをいれる
	for (size_t i = 1; i < splits.size(); i++) {
		if (i % 2 == 0) {
			vecx.push_back(splits[i].size());
		}
		else {
			vecy.push_back(splits[i].size());
		}
	}

	set<int> xx = solve(vecx, set<int> {x});
	set<int> yy = solve(vecy, set<int> {y});

	if (xx.find(splits[0].size()) != xx.end() && yy.find(0) != yy.end()) {
		std::cout << "Yes" << '\n';
	}
	else {
		std::cout << "No" << '\n';
	}
	return 0;
}


Measured memory_bytes: 348800
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i,a,b) for(int64_t i=(a);i<(b);++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int64_t i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define RANGE(a,b,c) (a).begin()+(b),(a).begin()+(c) // [b,c) イテレータ
#define INF 1000000000000000
#define MOD 1000000007
using PII = pair<int64_t, int64_t>;
using VI = vector<int64_t>;
using VVI = vector<VI>;
using VS = vector<string>;
using VP = vector<PII>;
using i64 = int64_t;
template<typename T> void invec(vector<T> &A){for(T& a:A) cin >> a;} 

#define MAX 100001
int64_t fac[MAX], finv[MAX], inv[MAX]; // n!, (n!)^-1, n^-1 の mod
// テーブルを作る前処理
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;
    }
}
// 二項係数計算。最悪 O(k).
int64_t COM(i64 n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    if (k >= MAX) {cout <<"k >= MAX\n"; return 0;}
    if (n >= MAX) { // O(k)
        i64 com = finv[k];
        rep(i, 0, k) (com *= (n - i)) %= MOD;
        return com;
    }
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

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

int N, K; cin >> N >> K;
VI A(N); invec(A);
sort(ALL(A));
i64 maxi = 0, mini = 0;

COMinit();

rep(i, K, N+1) (maxi += A[i-1] * COM(i-1, K-1) %MOD) %= MOD;
rep(i, 1, N-K+2) (mini += A[i-1] * COM(N-i, K-1) %MOD) %= MOD;

cout << (maxi - mini + MOD) % MOD << "\n";

return 0;
}
// コンテスト前はtemplate振り返り。
// 書いて考える．場合分け．情報整理．
// 単純に分かる量から．愚直解を実装して研究．
// 境界，出力文字列 チェック．行末にスペース入れない．
// 可読性優先．高速化次点．
// まずは全探索，分割，次にDP(小さい問題から大きな問題)
// 制限を見る．境界に注意．求めたい量の変域．動かせる量．
// 偶奇，逆から，ソート，出現回数，出現位置，DP， 余事象，包除
// データ構造． 問題の特徴量．単調性→二分探索
// 存在判定：構成方法，入力の特徴
// 構築問題。極端解を試す。
// 例外を十分に含む一般化．想像力の限界
// 小さい系から例示
// 代数的処理．前処理によるクエリ高速化．
// 始めは過剰に例示・場合分けしてもいい．各場合を確実に対処．
// 自明な例から処理，除外．
// 小数のときは，精度の設定する．doubel 変数に数値を入力するときは 123. とする．
// コーナーケース。境界値。数表出力プログラム作る
// 実行エラー：vector添え字超え．0割り．



Measured memory_bytes: 3328
import Queue

from sys import stdin
input = stdin.readline

N = int(raw_input())
tree = [[] for _ in xrange(N)]

for i in range(N-1):
    a, b, c = map(int, raw_input().split())
    a -= 1; b -= 1;
    tree[a].append((b, c))
    tree[b].append((a, c))

Q, K = map(int, raw_input().split())
K -= 1

d = [float("inf") for _ in xrange(N)]

def dijkstra(s):
    que = Queue.PriorityQueue()
    d[s] = 0
    que.put([0, s])

    while not que.empty():
        p = que.get()
        v = p[1]
        if d[v] < p[0]:
            continue
        for i, j in tree[v]:
            if d[i] > d[v] + j:
                d[i] = d[v] + j
                que.put([d[i], i])

dijkstra(K)

for i in range(Q):
    x, y = map(int, raw_input().split())
    x -= 1; y -= 1
    print d[x] + d[y]


Measured memory_bytes: 54060
//
// Created by Hideaki Imamura on 2020-03-12.
//
# include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef pair <ll, ll> l_l;
typedef pair<int, int> i_i;

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

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

# define EPS (1e-7)
# define INF (1e9)
# define PI (acos(-1))
//const ll mod = 1000000007;

double a, b, x;

int main() {
    cin >> a >> b >> x;

    double ans;
    if (x <= a * a * b / 2) {
        ans = atan(a * b * b / (2 * x)) * 180 / PI;
    } else {
        ans = atan(2 * (a * a * b - x) / (a * a * a)) * 180 / PI;
    }
    printf("%f\n", ans);
    return 0;
}

Measured memory_bytes: 512
n = int(input())
a = []
for i in range(n):
	a.append(int(input()))
max1 = max(a)
idx = a.index(max1)
a[idx] = 0
max2 = max(a)

for i in range(n):
	if i != idx:
		print(max1)
	else:
		print(max2)

Measured memory_bytes: 12584
#include <bits/stdc++.h>
using namespace std;
bool check(int n,int x,int y){return x>=0&&x<n&&y>=0&&y<n;}
int dx[8]={-1,-1,-1,0,0,1,1,1},dy[8]={-1,0,1,-1,1,-1,0,1};

int main() {
  int n=8,r=0;
  string s[n],t="ox";
  for(int i=0; i<n; i++) cin >> s[i];
  for(int l=0; l<64; l++) {
    int xx,yy,M=0;
    for(int i=0; i<n; i++) {
      for(int j=0; j<n; j++) {
        if(s[i][j]!='.') continue;
        int c=0;
        for(int k=0; k<8; k++) {
          int x=i+dx[k],y=j+dy[k],z=0;
          while(check(n,x,y)&&s[x][y]==t[r^1]) {
            z++;
            x+=dx[k];
            y+=dy[k];
          }
          if(check(n,x,y)&&s[x][y]==t[r]) c+=z;
        }
        if(M<c) M=c,xx=i,yy=j;
        else if(r&&M==c) xx=i,yy=j;
      }
    }
    if(M) {
      s[xx][yy]=t[r];
      for(int k=0; k<8; k++) {
        int x=xx+dx[k],y=yy+dy[k];
        while(check(n,x,y)&&s[x][y]==t[r^1]) {
          x+=dx[k];
          y+=dy[k];
        }
        if(check(n,x,y)&&s[x][y]==t[r]) {
          x=xx+dx[k],y=yy+dy[k];
          while(check(n,x,y)&&s[x][y]==t[r^1]) {
            s[x][y]=t[r];
            x+=dx[k];
            y+=dy[k];
          }
        }
      }
    }
    r^=1;
  }
  for(int i=0; i<n; i++) cout << s[i] << endl;
  return 0;
}


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

ll dp[1001][1001];
ll vis[1001][1001];

ll solve(ll h, ll w, char **a, ll i, ll j)
{
	if(a[i][j]=='#') return 0;
	if(i==0 && j==0) return 1;

	if(vis[i][j]) return dp[i][j];
	vis[i][j] = 1;
	
	if(i==0) return dp[i][j] = solve(h,w,a,i,j-1);
	if(j==0) return dp[i][j] = solve(h,w,a,i-1,j);
	
	return dp[i][j] = (solve(h,w,a,i-1,j) + solve(h,w,a,i,j-1))%mod;
}

int main()
{
	ll h, w;
	cin>>h>>w;
	char **a;
	a = new char *[h];
	for(ll i=0; i<h; i++) a[i] = new char [w];
	for(ll i=0; i<h; i++)
		for(ll j=0; j<w; j++)
			cin>>a[i][j];
	cout<<solve(h,w,a,h-1,w-1);
	return 0;
}

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

int main(){
    string s,ans;
    cin>>s;
    ll n=s.size();
    for(ll i=0;i<n;++i){
        if(s[i]=='B'){
            if(ans.size()){
                ans.pop_back();
            }
        }else{
            ans.push_back(s[i]);
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>

using namespace std;
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807int
#define I64_MAX2 1223372036854775807int
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(),(x).end()
// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return;std::cout << e << std::endl;}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class X> void DEBUG(X d, T e){if(DEBUG_OUT == false)return;std::cout <<d<<" ";DEBUG(e);};
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }


//FUNCTION  
 
//solve

void solve(void)
{
  int N;
  cin>>N;
  vector<int> A(N),B(N);
  for (int i = 0; i < N; i++)
  {
    cin>>A[i]>>B[i];
  }
  reverse(ALL(A));
  reverse(ALL(B));
  int SUM = 0;
  for (int i = 0; i < N; i++)
  {
    A[i] += SUM;
    if(A[i]%B[i] != 0)
    SUM += B[i] -  A[i]%B[i];
  }
  cout<<SUM<<endl;
  
  return;
}

int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

  return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<vector>
#include<string>
#include<map>
#include<algorithm>
#include<cmath>
using namespace std;

typedef long long int llint;

int main(){
	int H,W;
	cin >> H >> W;
	for(int x=-1;x<W+1;x++){
		cout << '#';
	}
	cout << endl;
	for(int y=0;y<H;y++){
		cout << '#';
		for(int x=0;x<W;x++){
			char c;
			cin >> c;
			cout << c;
		}
		cout << '#' << endl;
	}
	for(int x=-1;x<W+1;x++){
		cout << '#';
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define endl "\n"  
char ch[20000010];
//std::vector<int> v, a;

int main(){
  
	#ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);  
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);  
#endif
       ios_base::sync_with_stdio(false);    
       cin.tie(NULL);
       /*
int t;
cin>>t;
while(t--){
	int n;
	cin>>n;
	string s;
	cin>>s;
	string s1  = "";
	if(s.size() == 1){
		cout<<1<<endl;
	}
	for(int i = 1 ; i<=n; i+= 2){
		s1 += '1';
	}
	for(int i = 2 ; i <= n ; i+= 2){
		s1 += '0';
	}
	cout<<s1<<endl;  
}
}
*/
    int n, x,t;
    cin>>n>>x>>t;
    int time = (n + x -1)/x;   
  int ans = time*t;
  cout<<ans<<endl;
}

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

int main(void)
{
    long long A,V,B,W,T;
    cin>>A>>V>>B>>W>>T;
    if(A <B)
    {
        if(W - V > 0)
        {
            if(0<=A-B&&A-B<=T*(W-V))
                cout<<"YES"<<endl;
            else cout<<"NO"<<endl;
        }else
        {
            if(0>=A-B&&A-B>=T*(W-V))
                cout<<"YES"<<endl;
            else cout<<"NO"<<endl;
        }
    }else
    {
        if(W - V > 0)
        {
            if(0<=B-A&&B-A<=T*(W-V))
                cout<<"YES"<<endl;
            else cout<<"NO"<<endl;
        }else
        {
            if(0>=B-A&&B-A>=T*(W-V))
                cout<<"YES"<<endl;
            else cout<<"NO"<<endl;
        }
    }
    return 0;
}


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


int main()
{
	int n; cin >> n;
	ll ans = 1, maxvalue = 1e18;
	double t = 1;

	for (int i = 0; i < n; ++i)
	{
		ll a; cin >> a;
		ans *= a;
		t *= a;
	}
	if (ans > maxvalue || t > maxvalue)
		cout << -1 << endl;
	else
		cout << ans << endl;
}



Measured memory_bytes: 3640
#define _USE_MATH_DEFINES
#include<iostream>
#include<fstream>
#include<vector>
#include<string>
#include<algorithm>
#include<climits>
#include<numeric>
#include<cmath>
#include<cstring>
#include<deque>
#include<map>
#include<iomanip>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define VSORT(v) sort(v.begin(), v.end());
#define VE vector<int>
#define VEP vector<pair<int,int>>
#define llong long long
#define pb(a) push_back(a)
using namespace std;
const vector<VE> DIR{ {-1,0},{1,0},{0,-1},{0,1} };
const llong MOD = 1000000007;
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}
template<class T>
int dp2csv(const vector<vector<T>> & dp, const string fname);
int range_check(int val, int min, int max) {
	if (val < min) {
		return -1;
	}
	if (val > max) {
		return -1;
	}
	return val;
}
template<class T,class T1>
bool array_find(const T& array, const T1& dst) {
	auto result = find(array.first(), array.end(), dst);
	if (result == array.end()) {
		return false;
	}
	else {
		return true;
	}
}
template<class T>
bool array_same(const T& array, const T& array1) {
	bool is_same = true;
	REP(i, array.size()) {
		if (array[i] != array1[i]) {
			is_same = false;
			break;
		}
	}
	return is_same;
}
int main() {
	int n;
	cin >> n;
	vector<int> p(n), Q(n);
	REP(i, n) {
		cin >> p[i];
	}
	REP(i, n) {
		cin >> Q[i];
	}
	vector<int> vec;
	REP(i, n) {
		vec.push_back(i + 1);
	}
	int cnt = 1;
	int pi, Qi;
	do{
		if (array_same(vec, p))
			pi = cnt;
		if (array_same(vec, Q))
			Qi = cnt;
		cnt++;
	} while (next_permutation(vec.begin(), vec.end()));
	cout << abs(pi-Qi) << endl;
	return 0;
}
template<class T>
int dp2csv(const vector<vector<T>> & dp, const string fname) {
	ofstream ofs(fname);
	if (ofs.fail()) { cerr << "cannot open file. :" + fname << endl; return -1; }
	for (auto dp_row : dp) {
		for (auto dp_cell : dp_row) {
			ofs << dp_cell << ",";
		}
		ofs << endl;
	}
	ofs.close();
	return 0;
}


Measured memory_bytes: 256
from functools import lru_cache

N, A = map(int, input().split())
X = tuple(int(x) for x in input().split())

# 平均を出すのに選んだ個数が必要
@lru_cache(maxsize=None)
def rec(i, a, k):
    """
    :param i: int 
        数列の長さ
    :param a: int
        総和
    :param k: int
        選ぶ個数
    :return: int
        通り数
        Number of patterns
    """
    if k == 0:
        if a == 0:
            return 1
        else:
            return 0

    if a < 0 or i < k:
        return 0

    ret = rec(i - 1, a, k)
    ret += rec(i - 1, a - X[i - 1], k - 1)
    return ret

i = len(X)
m = (rec(i, k * A, k) for k in range(1, N + 1))
print(sum(m))

Measured memory_bytes: 82688
import java.util.Scanner;

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

    int x, y;
    if(a > b) {
      x = b;
      y = a;
    }
    else if(a == b) {
      x = a;
      y = a;
    }
    else {
      x = a;
      y = b;
    }

    for(int i=0; i<y; i++) {
      System.out.print(x);
    }
    System.out.println();
  }
}

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

int n;
ll m;
vector<int> a;

bool chk(int x)
{
  ll cnt = 0;
  rep(i, n)
  {
    int pos = lower_bound(a.begin(), a.end(), x - a[i]) - a.begin();
    cnt += n - pos;
  }
  return cnt < m;
}

int main()
{
  cin >> n >> m;
  a.resize(n);
  rep(i, n)
    cin >> a[i];
  sort(a.begin(), a.end());
  int ng = 0, ok = 2 * 100000 + 1;
  while (ok - ng > 1)
  {
    int mid = (ok + ng) / 2;
    if (chk(mid))
      ok = mid;
    else
      ng = mid;
  }
  vector<ll> csum(n + 1, 0);
  rep(i, n)
    csum[i+1] = csum[i] + a[i];
  ll ans = 0;
  rep(i, n)
  {
    int pos = lower_bound(a.begin(), a.end(), ok - a[i]) - a.begin();
    ll cnt = n - pos;
    ans += csum[n] - csum[pos] + cnt * a[i];
    m -= cnt;
  }
  ans += m * ng;
  cout << ans << endl;
  return 0;
}

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

#define NEW(p,n){p=malloc((n)*sizeof(p[0]));if(p==NULL){printf("not enough memory\n");exit(1);};}
//pの型の変数n個の要素分のメモリを確保し、そのアドレスをpに代入するマクロ

#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define SWAP(type, x, y) do { type tmp = x; x = y; y = tmp; } while (0)

#define MOD 1000000007 

typedef struct{
    int priority;
    double value;
}data;

//昇順
int asc(const void* a, const void* b){
    return *(int*)a-*(int*)b;
}

//降順
int desc(const void* a, const void* b){
    return *(int*)b-*(int*)a;
}

int main(void){
    long X,Y;
    scanf("%ld%ld",&X,&Y);

    long ans=1;
    while(X*2<=Y){
        X*=2;
        ans++;
    }
    printf("%ld\n",ans);

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <string>
#include <set>
#include <queue>
#include <stack>
using namespace std;
typedef vector<int> vi;
typedef vector< vi > vvi;
int main() {
	int r, c;
	cin >> r >> c;
	vvi A(r + 1, vi(c + 1));
	for (int i = 0; i < r; i++) {
		for (int k = 0; k < c; k++) {
			cin >> A[i][k];
		}
	}
	for (int i = 0; i < r; i++) {
		A[i][c] = 0;
	}
	for (int i = 0; i < c; i++) {
		A[r][i] = 0;
	}
	A[r][c] = 0;
	for (int i = 0; i < r; i++) {
		for (int k = 0; k < c; k++) {
			A[i][c] += A[i][k];
		}
	}
	for (int i = 0; i < c;i++) {
		for (int k = 0; k < r; k++) {
			A[r][i] += A[k][i];
		}
	}
	for (int i = 0; i < r; i++) {
		A[r][c] += A[i][c];
	}
	for (int i = 0; i < r + 1; i++) {
		for (int k = 0; k < c + 1; k++) {
			if (k == c) {
				cout << A[i][k] << endl;
			}
			else {
				cout << A[i][k] << " ";
			}
		}
	}
}

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

int main(){
    long long n,m;
    cin>>n>>m;
    long long l[m+1];
    long long r[m+1];
    for(long long i=1; i<m+1; i++){
        long long L,R;
        cin>>L>>R;
        l[i]=L;
        r[i]=R;
    }
    long long p=0;
    long long q=1e+10;
    for(long long i=1; i<m+1; i++){
        p=max(p,l[i]);
        q=min(q,r[i]);
    }
    long long t=q-p;
    if ((t>=0) ? cout<<t+1<<endl : cout<<0<<endl);
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <cstdio>
#include <vector>
#include <algorithm>

typedef long long ll;
using namespace std;
#define rep(i,b) for(ll i=0;i<(b);++i)
#define rep1(i,b) for(ll i=1;i<=(b);++i)
#define vec vector
#define FOR(I,A,B) for(ll I=(A);I<(B);++I)
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl;

ll N;
ll H[25];

int main() {
   cin >> N;
   rep(i, N) {
      cin >> H[i];
   }
   int cnt = 1;
   for (int j=1;j<N;j++) {
      int isok = 1;
      rep(k, j) {
         if (H[k] > H[j]) { 
            isok = 0;
         }
      }
      if (isok) {
         cnt++;
      }
   }
   cout << cnt << endl;
}


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

string s[102];
int n, l;

int main()
{
	ios::sync_with_stdio(false);
	cin >> n >> l;
	for (int i = 1; i <= n; i++) cin >> s[i];
	sort(s + 1, s + n + 1);
	for (int i = 1; i <= n; i++) cout << s[i];
	return 0;
}


Measured memory_bytes: 256
def main():
    S = input()
    T = input()

    ans = len(T)
    for i in range(len(S)-len(T)+1):
        ch = 0
        for j in range(len(T)):
            if S[i+j] != T[j]:
                ch += 1
        ans = min(ans, ch)
    
    print(ans)



if __name__ == '__main__':
    main()

Measured memory_bytes: 67376
#include<bits/stdc++.h>
#define endl '\n';
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr double INFD = 1e100;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// ios::sync_with_stdio(false);
// cin.tie(nullptr);
// ---------------------------------------------------------------------------

int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  rep(i,N){
    cin >> A[i];
  }
  if(A[0] != 0){
    cout << -1 << endl;
    return 0;
  }
  ll ans = 0;
  for(int i=0; i<N-1; i++){
    if(A[i+1] == 0){
    }else if(A[i]+1 == A[i+1]){
      ans++;
    }else if(A[i] >= A[i+1]){
      ans += A[i+1];
    }else{
      cout << -1 << endl;
      return 0;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1024
def search(s):
    week_day = ["SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"]
    for i in range(len(week_day)):
        if s == week_day[i]:
            return len(week_day) - i

if __name__ == "__main__":
    s = input()
    print(search(s))

Measured memory_bytes: 2940
// AOJ 0118
#include<cstdio>
#define rep( i, a ) for( int i = 0; i != (a); ++i )

int H, W;
char fld[100][100];
const int dx[4] = { 0, 1, 0, -1 }, dy[4] = { -1, 0, 1, 0 };

void dfs( char ch, int x, int y )
{
	fld[y][x] = ' ';

	rep( i, 4 )
	{
		int nx = x + dx[i], ny = y + dy[i];

		if( nx >= 0 && nx < W && ny >= 0 && ny < H && fld[ny][nx] == ch )
			dfs( ch, nx, ny );
	}

	return;
}

int main()
{
	while( scanf( "%d%d", &H, &W ), H | W )
	{
		rep( i, H )
		{
			getchar();
			rep( j, W )
				fld[i][j] = getchar();
		}

		int ans = 0;
		rep( i, H )
			rep( j, W )
				if( fld[i][j] != ' ' )
					dfs( fld[i][j], j, i ), ++ans;

		printf( "%d\n", ans );
	}

	return 0;
}

Measured memory_bytes: 1504
#include <bits/stdc++.h>
using namespace std;
  
int main()
{
    int A,B,C,D,E,F;
    int Ai,Bi,tan,kefan,sum;
    int maxx1 = -1,maxx2 = 1;
    double maxx3 = -1.0;
    cin>>A>>B>>C>>D>>E>>F;
    Ai = A*E; Bi = B*E;
  
    for (int a=0;a*A*100<=F;a++)
    for (int b=0;b*B*100<=F-a*A*100;b++)
    for (int c=0;c*C<=F-a*A*100-b*B*100;c++)
    for (int d=0;d*D<=F-a*A*100-b*B*100-c*C;d++)
    {
        tan = c*C+d*D;
        sum = A*a*100+B*b*100+tan;
        kefan = Ai*a+Bi*b;
  
        if (kefan<tan||sum>F)continue;
   
        if (sum!=0&&tan*1.0/sum>maxx3) {
            maxx1 = sum;
            maxx2 = tan;
            maxx3 = tan*1.0/sum;
        }
    }
    cout<<maxx1<<" "<<maxx2<<endl;
    return 0;
}

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

using ll = int64_t;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)

#define rng(a) a.begin(), a.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

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

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

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

template <typename T, size_t S> void printArray(const T (&array)[S]) {
  for (auto val : array)
    std::cout << val << ", ";
  std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

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

  string s;
  std::cin >> s;
  ll dpbit = 0, len = s.length(), ans = 0;
  rep(dpbit, 1 << (len - 1)) {
    ll tmp = (s[0] - '0');
    rep(digit, len - 1) {
      if ((dpbit >> digit) & 1)
        ans += tmp, tmp = 0;
      else
        tmp = tmp * 10;
      tmp += s[digit + 1] - '0';
    }
    ans += tmp;
  }
  std::cout << ans << "\n";
}


Measured memory_bytes: 256