akhauriyash/Code-Regression huggingface dataset:
// بِسمِ اللہِ  الرَّحم?نِ  الرَّ حِیم
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define MOD 1000000007
#define ll long long
#define pb push_back
#define INF 1e18
#define N 1000100
typedef pair<ll,ll> pll;
ll power(ll a,ll b,ll p)
{
    a=a%p;
    if(b==1)return a;
    if(b==0)return 1;

    ll temp=power(a,b/2,p);
    ll ans=(temp*temp)%MOD;
    if(b&1)
        ans=(a*ans)%MOD;
    return ans;
}
ll inv(ll a)
{
    return power(a,MOD-2,MOD);
}
//code begins



signed main()
{
//    freopen("input.txt","r",stdin);
//    freopen("output.txt","w",stdout);

    cin.sync_with_stdio(false);
    ll t;
    t=1;
//    cin>>t;
    while(t--)
    {
        ll n,k;cin>>n>>k;
        ll h[n+1];
        for(ll i=1;i<=n;i++)cin>>h[i];
        if(k>=n)
        {
            cout<<0<<endl;
            continue;
        }
        sort(h+1,h+n+1);
        ll ans=0;
        for(ll i=1;i<=n-k;i++)
            ans+=h[i];
        cout<<ans<<endl;
    }
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define SIZE 10
#define PI 3.141592653589793

using namespace std;
typedef long long ll;

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

	int K,N;
	int i,j;
	int tmp;
	int counter=0;
	ll answer=0;
	vector<ll> given;
	vector<ll> distance;

	cin >> K >> N;

	for(i=0;i<N;i++){
		cin >> tmp;
		given.push_back(tmp);
	}

	for(i=0;i<N-1;i++)
		distance.push_back(abs(given[i]-given[i+1]));
	distance.push_back((K-given[N-1])+(given[0]));

	/*
	for(i=0;i<N;i++)
		cout << distance[i] << " ";
	cout << endl;
	*/
	
	ll max = *max_element(distance.begin(), distance.end());

	answer=accumulate(distance.begin(),distance.end(),0)-max;
	cout << answer << endl;

	return 0;
}



Measured memory_bytes: 7948
import java.util.*;
public class Main {

	public static void main(String[] args) {
		long start = System.currentTimeMillis();
		int INF = Integer.MAX_VALUE/2;
		StringBuilder ans = new StringBuilder();
		Scanner sc = new Scanner(System.in);
		int D = Integer.parseInt(sc.next());
		int[] c = new int[26];
		Arrays.setAll(c, i -> Integer.parseInt(sc.next()));
		int[][] s = new int[D][26];
		for(int i = 0; i < D; i++)
			Arrays.setAll(s[i], x -> Integer.parseInt(sc.next()));
		sc.close();
		int[] con = new int[D];
		Map<Integer, TreeSet<Integer>> used = new HashMap<>();
		for(int i = 0; i < 26; i++) {
			used.put(i, new TreeSet<>());
			used.get(i).add(-1);
		}
		for(int d = 0; d < D; d++) {
			int max = -INF, now = 0;
			for(int i = 0; i < 26; i++) {
				int temp = 0;
				temp += s[d][i];
				for(int j = 0; j < 26; j++)
					if(i != j)
						temp -= c[j] * (d - used.get(j).last());
				if(max < temp) {
					max = temp;
					now = i;
				}
			}
			con[d] = now;
			used.get(now).add(d);
		}
		for(int i = 0; i < 26; i++)
			used.get(i).add(D);
		Random r = new Random();
		while(true) {
			int d = r.nextInt(D);
			for(int q = 0; q < 26; q++) {
				long temp = 0;
				temp -= s[d][con[d]];
				temp += s[d][q];
				temp -= c[con[d]] * (used.get(con[d]).ceiling(d) - d) * (d - used.get(con[d]).lower(d));
				temp += c[q] * (d - used.get(q).lower(d)) * (used.get(q).ceiling(d) - d);
				if(temp > 0) {
					con[d] = q;
					used.get(con[d]).remove(d);
					used.get(q).add(d);
					break;
				}
			}
			if(System.currentTimeMillis() - start > 1850)
				break;
		}
		for(int i : con)
			ans.append((i+1) + "\n");
		System.out.println(ans);
	}

}


Measured memory_bytes: 68060
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    int n,x,m,min=INT_MAX;
    cin>>n>>x;
    for(int i=0; i<n; i++){
        cin>>m;
        x-=m;
        if(m<min){
            min=m;
        }
    }
    cout<< x/min + n <<endl;
}


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

template <long long MOD>
struct ModInt {
  using M = ModInt;
  long long v;
  ModInt(long long _v = 0) : v(_v % MOD + MOD) { norm(); }
  M& norm() {
    v = (v < MOD) ? v : v - MOD;
    return *this;
  }
  M operator+(const M& x) const { return M(v + x.v); }
  M operator-(const M& x) const { return M(v + MOD - x.v); }
  M operator*(const M& x) const { return M(v * x.v % MOD); }
  M operator/(const M& x) const { return M(v * x.inv()); }
  M& operator+=(const M& x) { return *this = *this + x; }
  M& operator-=(const M& x) { return *this = *this - x; }
  M& operator*=(const M& x) { return *this = *this * x; }
  M& operator/=(const M& x) { return *this = *this / x; }
  friend istream& operator>>(istream& input, M& x) {
    return input >> x.v, x.norm(), input;
  }
  friend ostream& operator<<(ostream& output, const M& x) {
    return output << x.v;
  }
  M pow(long long n) const {
    M x(v), res(1);
    while (n) {
      if (n & 1) res *= x;
      x *= x;
      n >>= 1;
    }
    return res;
  }
  M inv() const { return this->pow(MOD - 2); }
  // M inv() const {
  //   int x, y;
  //   extgcd(this->v, MOD, x, y);
  //   return *this + M(x);
  // }

  static vector<M> fact, finv;
  static void build(int n) {
    fact.assign(n + 1, 1);
    finv.assign(n + 1, 1);
    for (int i = 1; i < n + 1; i++) fact[i] = fact[i - 1] * M(i);
    for (int i = 0; i < n + 1; i++) finv[i] = fact[i].inv();
  }
  static M comb(int n, int k) {
    if (n < k || k < 0) return M(0);
    return fact[n] * finv[n - k] * finv[k];
  }
  static M extgcd(int a, int b, int* x, int* y) {
    M d(a);
    if (b) {
      d = extgcd(b, a % b, y, x);
      *y -= (a / b) * *x;
    } else {
      *x = 1, *y = 0;
    }
    return d;
  }
};
template <long long MOD>
vector<ModInt<MOD>> ModInt<MOD>::fact = vector<ModInt<MOD>>();
template <long long MOD>
vector<ModInt<MOD>> ModInt<MOD>::finv = vector<ModInt<MOD>>();
using mint = ModInt<(long long)(1e9 + 7)>;

int main() {
  int a, b; cin >> a >> b;
  int x, y;
  mint::extgcd(a, b, &x, &y);
  cout << x << ' ' << y << endl;
}



Measured memory_bytes: 3108
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

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

	int PC = 0, QC = 0;

	vector<bool> TFP(N + 1); //  使われてなければ false
	TFP.at(0) = true;

	vector<bool> TFQ(N + 1); //  使われてなければ false
	TFQ.at(0) = true;

	vector<int> sou(9);
	sou.at(0) = 1;
	sou.at(1) = 1;
	sou.at(2) = 2;
	sou.at(3) = 6;
	sou.at(4) = 24;
	sou.at(5) = 120;
	sou.at(6) = 720;
	sou.at(7) = 5040;
	sou.at(8) = 40320;

	vector<int> P(N), Q(N);
	for (int i = 0; i < N; i++) 
	{
		cin >> P.at(i);
		int sa = 0;
		for (int j = P.at(i) - 1; j >= 1; j--)
		{
			if (TFP.at(j) == false) 
			{
				sa++;
			}
		}
		TFP.at(P.at(i)) = true;
		PC += sa * sou.at(N - i - 1);
	}
	for (int i = 0; i < N; i++)
	{
		cin >> Q.at(i);
		int sa = 0;
		for (int j = Q.at(i) - 1; j >= 1; j--)
		{
			if (TFQ.at(j) == false)
			{
				sa++;
			}
		}
		TFQ.at(Q.at(i)) = true;
		QC += sa * sou.at(N - i - 1);
	}

	cout << abs(PC - QC) << endl;

	return 0;
}

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

#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 ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
typedef long long ll;


int main() {
    int N,M,X; cin >>N>>M>>X;
    vector<int> C(N);
    vector<vector<int>> A(N,vector<int>(M));
    REP(i,N){
        cin >> C[i];
        REP(j,M){
            cin >> A[i][j];
        }
    }
    int ans = INF;
    REP(bit,1<<N){
        int cost = 0;
        vector<int> skills(M,0);
        REP(n,N){
            if(bit & (1<<n)){
                cost += C[n];
                REP(i,M){
                    skills[i] += A[n][i];
                }
            }
        }
        bool archived = true;
        REP(i,M){
            if (skills[i] < X){
                archived = false;
            }
        }
        if(archived){
            ans = min(ans, cost);
        }
    }
    if(ans == INF){
        cout << -1 << endl;
    }else{
        cout << ans << endl;
    }
    return 0;
}

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

int main() {
  int n,m;
  cin>>n>>m;
  int ans = 0;
  auto check = [&](int x) {
    if (ll(n) * x <= m) ans = max(ans, x);
  };
  for (int i=1;i*i<=m;i++) {
    if (m%i) continue;
    check(i);
    check(m/i);
  }
  cout<<ans<<endl;
  return 0;
}


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

#define MOD 1000000007

int main(void){

    int n;
    int i;
    long long *p;
    long long ans = 0;
    long long ans2 = 0;

    scanf("%d",&n);
    p = (long long*)malloc(sizeof(long long)*n);

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

    for(i=1;i<n;i++){
        ans += p[i];
    }

    i = 0;
    do{
        ans2 += ((ans%MOD)*p[i])%MOD;
        ans2 = ans2 % MOD;
        ans -= p[i+1];
        i++;
    }while(i<n-1);

    printf("%lld",ans2);
    free(p);
    return 0;
}

Measured memory_bytes: 3016
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
using namespace std;
typedef long long ll;

int S;

int main(){
    cin>>S;

    int s1=S/100;
    int s2=S%100;

    string ans;
    if(1<=s1 && s1<=12 && 1<=s2 && s2<=12){
        ans="AMBIGUOUS";
    }else if(1<=s1 && s1<=12){
        ans="MMYY";
    }else if(1<=s2 && s2<=12){
        ans="YYMM";
    }else{
        ans="NA";
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 256
A, B, Q = [int(a) for a in input().split(" ")]
S = sorted([int(input()) for i in range(A)])
T = sorted([int(input()) for i in range(B)])
X = [int(input()) for i in range(Q)]
INF = float("inf")

def search(arr, x):
    l, r = (0, len(arr))
    while r-l>1:
        med = (l+r)//2
        if arr[med] == x:
            return med
        l, r = (l, med) if x<arr[med] else (med+1, r)
    return l

for x in X:
    s1 = min(search(S, x), len(S)-1)
    t1 = min(search(T, x), len(T)-1)
    ss, ts = None, None
    
    if S[s1]==x:
        ss = (0, 0)
    elif s1==0 and x<S[s1]:
        ss = (INF, abs(S[s1]-x))
    elif s1==len(S)-1 and S[s1]<x:
        ss = (abs(S[s1]-x), INF)
    elif S[s1]<x:
        ss = (abs(S[s1]-x), abs(S[s1+1]-x))
    else:
        ss = (abs(S[s1-1]-x), abs(S[s1]-x))
    
    if T[t1]==x:
        ts = (0, 0)
    elif t1==0 and x<T[t1]:
        ts = (INF, abs(T[t1]-x))
    elif t1==len(T)-1 and T[t1]<x:
        ts = (abs(T[t1]-x), INF)
    elif T[t1]<x:
        ts = (abs(T[t1]-x), abs(T[t1+1]-x))
    else:
        ts = (abs(T[t1-1]-x), abs(T[t1]-x))

    ans = min([max(ss[0], ts[0]), max(ss[1], ts[1]),
               2*ss[0]+ts[1], 2*ss[1]+ts[0], ss[0]+2*ts[1], ss[1]+2*ts[0]])
    print(ans)


Measured memory_bytes: 139992
#include <iostream>
#include <cmath>
#include <bits/stdc++.h>
#include <string>

using namespace std;

void printVectorInt(vector<int> const &input)
{
	for (int i = 0; i < input.size(); i++) {
		cout << input.at(i) << ' ';
	}
}

// stringをintに
// string a = "123";
// stoi(a)
//
// intをstringに
// int a = 123;
// to_string(a)
//
// charをintに
// char a = '1';
// (int)a - 48 // asciiコードを値にする

// stringのソート
// string str = "abccba";
// sort(str.begin(), str.end());
//
// ハッシュテーブル
// unordered_map<string, int> mp;
// mp["aabbcc"] = 0;

// 配列Aにcinする
//int main() {
//  int N;
//  cin >> N;
//  vector<int> A(N);
//  for (int i = 0; i < N; i++) {
//    cin >> A.at(i);
//  }
//  return 0;
//}

// ビット全探索
// int main() {
// 	int K, S;
// 	cin >> K >> S;
//   int counter = 0;
//   for (int bit = 0; bit < (1<<K); bit++) {
//     vector<int> combination;
//     for (int i = 0; i < K; i++) {
//       if (bit & (1<<i)) {
//         combination.push_back(i);
//       }
//     }
//
//     int sum = accumulate(combination.begin(), combination.end(), 0);
//     if (sum == S) {
//       counter++;
//     }
//
//     cout << bit << ": {";
//     for (int i = 0; i < (int)combination.size(); ++i) {
//         cout << combination[i] << " ";
//     }
//     cout << "}" << endl;
//
//   }
//   cout << counter << endl;
//   return 0;
// }

// 文字列を1文字ずつループ
//int main() {
//  string str;
//  cin >> str;
//  int sum = 0;
//  for(int i = 0; i < (int)str.size(); ++i){
//    char ch = str[i];
//
//    if (ch == '1') {
//      sum++;
//    }
//  }
//  cout << sum << endl;
//  return 0;
//}

int main () {
  int K, S;
  cin >> K >> S;
  int counter = 0;
  for (int i = 0; i <= K; i++) {
    for (int j = 0; j <= K; j++) {
      if (S - i - j <= K && 0 <= S - i - j) {
        counter++;
      }
    }
  }
  cout << counter << endl;
  return 0;
}


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


bool Prime(ll x){
    ll i = 2;
    while(x%i !=0){
        if(i>x) break;
            i++;
    }
    if(x==i) return true;
    return false;
}


int main(){
    ll x;
    cin>>x;
    while(Prime(x)==0){
        x++;
    }
    cout<<x<<endl;
    
    
    
}

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

int main()
{
    int a[300000],n,t,i;
    cin >> n >> t;
    for(i=0 ; i<n ; i++)
    {
        cin >> a[i];
    }
    int sum=t;
    for(i=0 ; i+1<n ; i++)
    {
        int d= a[i+1]-a[i];
        if(d<t)
        {
            sum+=d;
        }
        else
        {
            sum+=t;
        }
    }
    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>                          
                                            
int main(void){                             
  int time;                                 
  int h,m,s;                                
  scanf("%d",&time);                        
  h = (int)(time / 3600);                   
  m = (int)((time - (h * 3600))/ 60);       
  s = time - (3600) * h - 60 * m;           
  printf("%d:%d:%d\n",h,m,s);               
  return 0;                                 
}                                           

Measured memory_bytes: 592
n = int(input())
l = list(map(int, input().split()))
mi = min(l)
ma = max(l)
l.remove(mi)
l.remove(ma)
u = []
for i in l:
    if i <= 0 :
        u.append([ma,i])
        ma -= i
    else :
        u.append([mi,i])
        mi -= i
u.append([ma,mi])
print(ma-mi)
for i in u:
    print(*i)


Measured memory_bytes: 67404
void main(){
  import std.stdio, std.string, std.conv, std.algorithm;

  int n; rd(n);
  auto q=readln.split.to!(int[]);

  const int m=1_000_000+5;
  auto isPrime=new bool[](m);
  fill(isPrime, true);
  isPrime[1]=false;
  for(int i=2; i*i<=m; i++)if(isPrime[i]){
    for(int j=2; i*j<m; j++) isPrime[i*j]=false;
  }

  const long mod=1_000_000_000+7;

  auto dp_p=new long[](n), dp_e=new long[](n);
  dp_p[0]=(isPrime[q[0]] ? 1L : 0L);
  for(int i=1; i<n; i++){
    if(isPrime[q[i-1]]) (dp_e[i]+=dp_p[i-1])%=mod;
    if(isPrime[q[i]]){
      if(isPrime[q[i-1]] && q[i-1]<q[i]) (dp_p[i]+=dp_p[i-1])%=mod;
      if(i-2>=0 && isPrime[q[i-2]] && q[i-2]<q[i]) (dp_p[i]+=dp_e[i-1])%=mod;
    }
  }

  writeln((dp_p[n-1]+dp_e[n-1])%mod);

}

/+
  qi: 素数
    dp_e[i]=dp_p[i-1]
    q(i-1):素数 and q(i-1)<qi: dp_p[i]+=dp_p[i-1]
    q(i-2):素数 and q(i-2)<qi: dp_p[i]+=dp_p[i-2] ? xx
                               dp_p[i]+=dp_e[i-1] ? ok
  qi: 合成数
    dp_e[i]=dp_p[i-1]
+/

void rd(T...)(ref T x){
  import std.stdio, std.string, std.conv;
  auto l=readln.split;
  assert(l.length==x.length);
  foreach(i, ref e; x){
    e=l[i].to!(typeof(e));
  }
}



Measured memory_bytes: 7628
import collections
S=list(str(input()))
cc=collections.Counter(S)

if cc['S']==0 and cc['N']!=0:
    print('No')
elif cc['S']!=0 and cc['N']==0:
    print('No')
elif  cc['E']==0 and cc['W']!=0:
        print('No')
elif  cc['E']!=0 and cc['W']==0:
        print('No')
else:
    print('Yes')


Measured memory_bytes: 9304
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;


int main(){
  ll sx,sy,tx,ty; cin >> sx >> sy >> tx >> ty;
  ll dx = tx-sx; ll dy = ty-sy;
  
  cout << string(dx,'R') << string(dy,'U') << string(dx,'L') 
       << string(dy,'D') << 'D' << string(dx+1,'R')  
       << string(dy+1,'U') << 'L' << 'U' << string(dx+1,'L')
       << string(dy+1,'D') << 'R' << endl;
}

Measured memory_bytes: 256
#include<cstdio>
using namespace std;
int main(void){
    int sum1 = 0,sum2 = 0;
    int a;
    for(int i = 0;i < 4;i++){
        scanf("%d",&a);
        sum1 += a;
    }
    for(int i = 0;i < 4;i++){
        scanf("%d",&a);
        sum2 += a;
    }
    if(sum1 >= sum2) printf("%d\n",sum1);
    else printf("%d\n",sum2);
    return 0;
}

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

typedef long long ll;

typedef pair<ll, ll> P;
struct edge { ll to, cost; };

const int MAX_V =100000;
const ll INF = 1LL<<60;

int V;
vector<edge> G[MAX_V];
ll d[MAX_V];

void dijkstra(ll s) {
    // greater<P>を指定することでfirstが小さい順に取り出せるようにする
    priority_queue<P, vector<P>, greater<P> > que;
    fill(d, d + V, INF);
    d[s] = 0;
    que.push(P(0, s));

    while (!que.empty()) {
        P p = que.top(); que.pop();
        int v = p.second;
        if (d[v] < p.first) continue;
        rep(i,G[v].size()) {
            edge e = G[v][i];
            if (d[e.to] > d[v] + e.cost) {
                d[e.to] = d[v] + e.cost;
                que.push(P(d[e.to], e.to));
            }
        }
    }
}

int main() {
    int u, v, w;
    cin >> V;
    rep(i, V - 1) {
        cin >> u >> v >> w;
        G[u - 1].push_back({v - 1, w});
        G[v - 1].push_back({u - 1, w});
    }
    dijkstra(0);
    rep(i, V) {
        cout << d[i]% 2 << "\n";
    }
}

Measured memory_bytes: 8704
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rng(i, a, b) for (int i = int(a); i < int(b); i++)
#define rep(i, b) rng(i, 0, b)
#define gnr(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define per(i, b) gnr(i, 0, b)
#define bg begin()
#define ed end()
#define all(x) x.bg, x.ed
#define vi vector<int>
template <class t, class u>
bool chmax(t &a, u b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class t, class u>
bool chmin(t &a, u b)
{
    if (b < a)
    {
        a = b;
        return true;
    }
    return false;
}

ll mod = 1000000007;

signed main()
{
    int n;
    cin>>n;
    ll ans = 0;
    rep(i, n)
    {
        int a;
        cin>>a;
        if(i%2==0&&a%2==1){
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3632
c = str(input())

if c == 'a':
	print('vowel')
elif c == 'i':
	print('vowel')
elif c == 'u':
	print('vowel')
elif c == 'e' :
	print('vowel')
elif c == 'o':
	print('vowel')
else:
	print('consonant')
	

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

using namespace std;

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

int N, K;
vector<ll> A;

void solve(){
    ll m = 1e16;
    ll height = A[0];
  
    for (int b = 0; b < (1 << N); b++)
    {
        height = A[0];
        ll cost = 0;
        bitset<20> bs(b);
        int cnt = 0;
        vector<int> v;

        for (int i = 0; i < N; i++){
            if(bs.test(i)){
                cnt++;
                v.push_back(i);
            }
        }

        if(cnt == K && bs.test(0)){
            for (int i = 1; i < N; i++){
                if(bs.test(i)){
                    cost += max(height - A[i] + 1, (ll)0);
                    height = max(height + 1, A[i]);
                   
                }
                else{
                    height = max(height, A[i]);
                }

                
            }
            m = min(m, cost);
        }
    }
    
    cout << m << endl;
}


int main(){
    cin >> N >> K;
    for (int i = 0; i < N; i++)
    {
        ll a;
        cin >> a;
        A.push_back(a);
    }
    
    solve();

    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;
using P = pair<int,int>;


int main() {
  int n, x, t;
  cin >> n >> x >> t;
  n =(n+x-1)/x;
  cout << (n*t) << endl;
  return 0;
}

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

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

  int a, b, c;
  cin >> a >> b >> c;
  if (a > b)
    swap(a, b);
  if (b > c)
    swap(b, c);
  if (a > b)
    swap(a, b);
  cout << a << " " << b << " " << c << endl;
}



Measured memory_bytes: 3184
// parameter "input" gets all data
function Main(input) {
	// the first line is assigned to input[0], the second line is assigned to input[1] similarly.
	input = input.split("\n");
	// convert string from integer using "parseInt"
	var a = input[0];
	var b = parseInt(input[1], 10);
	var p = 0;
	var N = 5*Math.pow(10,15);
	for (var i = 0; i < a.length; i++) {
		p+=Math.pow(a[i], N);
		if(b<=p){
			console.log('%d',a[i]);
			break;
		}
	}

	//output
	
}
// Don't edit this line!
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
using System;
using System.Linq;
using System.Collections.Generic;

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var a = int.Parse(Console.ReadLine());


            bool ans = n % 500 <= a;

            Console.WriteLine(ans ? "Yes" : "No");
        }
    }
}


Measured memory_bytes: 11092
package main

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

var (
	L, R, d int
)

func main() {
	defer writer.Flush()
	readVariables()
	if L%d != 0 {
		L += d - L%d
	}
	var answer int
	if R >= L {
		answer = (R-L)/d + 1
	} else {
		answer = 0
	}
	println(answer)
}

func readVariables() {
	L, R, d = nextInt(), nextInt(), nextInt()
}

/* Template */

var (
	scanner *bufio.Scanner
	writer  *bufio.Writer
)

func init() {
	Max := 1001001
	scanner = bufio.NewScanner(os.Stdin)
	scanner.Buffer(make([]byte, 0, Max), Max)
	scanner.Split(bufio.ScanWords)
	writer = bufio.NewWriterSize(os.Stdout, Max)
}

func println(a ...interface{}) {
	fmt.Fprintln(writer, a...)
}

func printf(format string, a ...interface{}) {
	fmt.Fprintf(writer, format, a...)
}

//nextInt converts next token from stdin and returns integer value.
//nextInt panics when conversion into an integer fails.
func nextInt() int {
	if !scanner.Scan() {
		panic("No more token.")
	}
	num, err := strconv.Atoi(scanner.Text())
	if err != nil {
		panic("nextInt(): cannot convert to int: " + scanner.Text())
	}
	return num
}

func nextStr() string {
	if !scanner.Scan() {
		panic("No more token.")
	}
	return scanner.Text()
}

// MinInt returns minimum argument
func MinInt(x, y int) int {
	if x < y {
		return x
	} else {
		return y
	}
}

//MaxInt returns maximum argument
func MaxInt(x, y int) int {
	if x < y {
		return y
	} else {
		return x
	}
}

//AbsInt returns |x| for x
func AbsInt(x int) int {
	if x < 0 {
		return -x
	}
	return x
}


Measured memory_bytes: 1844
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <string>
#include <queue>
#include <iomanip>
#include <iterator>

#define MOD 1000000007
#define INF 1000000001

using namespace std;
typedef unsigned long long ull;
typedef long long ll;


template <class T>
ostream &operator<<(ostream &o, const vector<T>&obj) {
    o << "["; for (int i = 0; i < (int)obj.size(); ++i) o << (i > 0 ? ", " : "") << obj[i]; o << "]"; return o;
}
template <class T, class U>
ostream &operator<<(ostream &o, const pair<T, U>&obj) {
    o << "(" << obj.first << ", " << obj.second << ")"; return o;
}
template <class T, class U>
ostream &operator<<(ostream &o, const map<T, U>&obj) {
    o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;
}
template <class T>
ostream &operator<<(ostream &o, const set<T>&obj) {
    o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;
}
template <class T>
ostream &operator<<(ostream &o, const queue<T>&obj) {
    queue<T> obj_cp = obj;
    bool first = true;
    o << "{";
    while (!obj_cp.empty()) { o << (!first ? ", " : "") << obj_cp.front(); obj_cp.pop(); first = false; }
    o << "}"; return o;
}

void print() {
    cout << "\n";
}
template<class Head, class... Body>
void print(Head head, Body... body) {
    cout << head << " ";
    print(body...);
}


int main(int argc, char const *argv[]) {
    int N, L;
    cin >> N >> L;

    vector<ll> a(N);
    for (int i = 0; i < N; ++i) {
        cin >> a[i];
    }

    ll pair_len_max = 0;
    int pair_idx;
    for (int i = 0; i < N-1; ++i) {
        ll pair_len = a[i] + a[i+1];
        if (pair_len > pair_len_max) {
            pair_len_max = pair_len;
            pair_idx = i;
        }
    }
    // print("pair_idx =", pair_idx);

    if (pair_len_max < L) {
        cout << "Impossible" << endl;
    } else {
        cout << "Possible" << endl;
        for (int i = 0; i < pair_idx; ++i) {
            cout << i+1 << endl;
        }
        for (int i = N-2; i > pair_idx; --i) {
            cout << i+1 << endl;
        }
        cout << pair_idx + 1 << endl;
    }

    return 0;
}


Measured memory_bytes: 1664
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <iomanip>
#include <cmath>
#include <stack>

using namespace std;
using ll = long long int;

template <class T> ostream &operator<<(ostream &os, vector<T> &v) {
  for (auto i = v.begin(); i != v.end(); i++) {
    os << *i << " ";
  }
  return os;
}


void solve(long long N, long long K, std::vector<long long> a){
  vector<ll> v(N+1, 0);
  for(ll i=0; i<N; i++) {
    v[i+1]+=v[i]+a[i];
  }

  ll ans = 0;
  for(ll i=50; i>=0; i--) {
    ll k=0;
    for(ll l=0; l<N+1; l++) {
      for(ll r=l+1; r<N+1; r++) {
	ll sum=v[r]-v[l];
	//std::cout << sum << std::endl;
	if(((ans + (1LL<<i)) & sum) == (ans + (1LL<<i))) {
	  k++;
	}
      }
    }
    if(k>=K)
      ans += (1LL<<i);
  }
  std::cout << ans << std::endl;
}

int main(){
  long long N;
  scanf("%lld",&N);
  long long K;
  scanf("%lld",&K);
  std::vector<long long> a(N);
  for(int i = 0 ; i < N ; i++){
    scanf("%lld",&a[i]);
  }
  solve(N, K, std::move(a));
  return 0;
}



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

using namespace std;

int main(void) {
  string s;
  map<char, int> mp;
  mp['I'] = 1;
  mp['V'] = 5;
  mp['X'] = 10;
  mp['L'] = 50;
  mp['C'] = 100;
  mp['D'] = 500;
  mp['M'] = 1000;
  
  while (cin >> s) {
    int ans = 0, sz = s.size();
    for (int i = 0; i < sz; i++) {
      if (i + 1 < sz && mp[s[i]] < mp[s[i + 1]]) {
        ans += mp[s[i + 1]] - mp[s[i]];
        i++;
      } else {
        ans += mp[s[i]];
      }
    }

    cout << ans << endl;
  }

  return 0;
}


Measured memory_bytes: 3156
<?php
$n = intval(fgets(STDIN));
$str = fgets(STDIN);
$c = 0;
$min = 10**10;
$str = "O".$str."O";
$n+=2;
for($i = 0; $i < $n; $i++){
    if($str[$i] == "E")$c++;
}
for($i = 1; $i < $n; $i++){
    if($str[$i] == "E"){
        $c--;
    }
    if($str[$i-1] == "W"){
        $c++;
    }
    $min = min($min, $c);
}
echo $min;


Measured memory_bytes: 4604
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main() {
    string w;

    cin >> w;

    int count[26] = {0};

    for (int i = 0; i < w.size(); i++) {
        count[w[i] - 'a']++;
    }

    for (int i = 0; i < 26; i++) {
        if ((count[i] % 2) != 0) {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;

    return 0;
}


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

#define MAX_N 2005
#define bit(mask, i) (mask & (1<<i))

using namespace std;

typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long long ll;
typedef double lf;

class SegmentTree {
private:
    vector<ll> st, A;
    int n;
    int leftc(int p) { return (p << 1) + 1; }
    int rightc(int p) { return (p << 1) + 2; }
    ll join(ll a, ll b) { return min(a, b); }

    void build(int p, int L, int R) {
        if (L == R) { st[p] = A[L]; }
        else {
            int c = (L + R)/2, p1 = leftc(p), p2 = rightc(p);
            build(p1, L, c);
            build(p2, c + 1, R);
            st[p] = join(st[p1], st[p2]);
        }
    }

    ll query(int p, int L, int R, int i, int j) {
        if (i == L && j == R) { return st[p]; }
        int c = (L + R)/2, p1 = leftc(p), p2 = rightc(p);
        if ( j <= c ) { return query(p1, L, c, i, j); }
        if ( i > c ) { return query(p2, c + 1, R, i, j); }
        ll q1 = query(p1, L, c, i, c), q2 = query(p2, c + 1, R, c + 1, j);
        return join(q1, q2);
    }

public:
    SegmentTree(const vector<ll> &_A) {
        A = _A; n = (int)A.size();
        st.assign(4 * n, 0);
        build(0, 0, n - 1);
    }
    ll query(int i, int j) { return query(0, 0, n - 1, i, j); }
};

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

    //freopen("a.in", "r", stdin);
    //freopen("a.out", "w", stdout);

    ll n, x;

    cin>>n>>x;
    vector<ll> colors(n);
    ll sol = 0;
    for(ll i = 0; i < n; ++i) {
        cin>>colors[i];
        sol += colors[i];
    }

    SegmentTree st(colors);

    ll psol, mincol;

    for(int p = 1; p < n; ++p) {
        psol = x * p;
        for(int i = 0; i < n; ++i) {
            mincol = st.query(max(0, i - p), i);
            if(p > i) { mincol = min(mincol, st.query(n - p + i, n - 1)); }
            psol += mincol;
        }
        sol = min(sol, psol);
    }

    cout<<sol<<"\n";

    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
long long inf=(long long)1E17;
//#define i_7 (long long)(1E9+7)
#define i_7 998'244'353
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;

//typedef long long ll;
long long po(long a, long b){
    if(b==0){
        return 1;
    }
    
    long long z = po(a,b/2);
    z = mod(z*z);
    if(b%2!=0){
        z = mod(a*z);
    }
    return z;
}

//配列のSIZEは問題ごとに定義する必要がある。
const int SIZE=10'000'010;
long long inv[SIZE+1];//各iの逆元を格納する配列。
long long kai[SIZE+1];//i!のmodを格納する配列。
long long invkai[SIZE+1];//各i!の逆元を格納する配列。
const int MOD=i_7;
void invinit(){//上の配列を初期化する関数。
    inv[1]=1;
    for(int i=2;i<=SIZE;i++){
        inv[i] = MOD - ((MOD/i)*inv[MOD%i])%MOD;
    }
    
    kai[0]=invkai[0]=1;
    for(int i=1;i<=SIZE;i++){
        kai[i]=(kai[i-1]*i)%MOD;
        invkai[i]=(invkai[i-1]*inv[i])%MOD;
    }
}

long long comb(long long a, long long b){
    if(b<0 || a<b){
        return 0;
    }
    return mod(kai[a]*mod(invkai[b]*invkai[a-b]));
}

int main(){
  invinit();
  long long n;
  cin>>n;
  long long ans = po(3LL, n);
  for(long long k = n/2 + 1; k<=n; k++){
    long long temp = comb(n,k);
    temp *= po(2LL, n-k);
    temp = mod(temp);
    ans -= 2*temp;
    ans = mod(ans);
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 234752
#include <bits/stdc++.h>
//#define int long long
#define double long double
#define endl "\n"
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb(x) push_back(x)
#define mp(a,b) make_pair(a,b)
#define ms(v,x) memset(v,x,sizeof(v))
#define ff first
#define ss second
#define frr(i,n) for(int i=0;i<n;i++)
#define td(v) v.begin(),v.end()
#define M   1000000007 // 1e9 + 7
#define MAXN 100100
using namespace std;
typedef pair<int,int> pii;
typedef pair<int,double> pdd;
inline int mod(int n, int m){int ret = n%m; if(ret < 0) ret += m; return ret;}
int gcd(int a, int b){return (b == 0 ? a : gcd(b, a%b));}
int exp(int a,int b,int m){
    if(b==0) return 1;
    if(b==1) return mod(a,m);
    int k = mod(exp(a,b/2,m),m);
    if(b&1){
        return mod(a*mod(k*k,m),m);
    }    else return mod(k*k,m);
}

int32_t main(){
	fastio;
   	string s;
   	cin>>s;
   	int i=0,j=s.size()-1;
   	int r=0;
   	while(i<j){
	     if(s[i]!=s[j])r++;
		   i++;
		   j--;	   
    }
	cout<<r<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,b,n) for(int i=b;i<(int)n;i++)
#define rep(i,n) REP(i,0,n)
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string ss;cin>>ss;
    ll ans=0;
    int n=ss.size();
    for(int i=0;i<(1<<(n-1));i++){
        ll tot=ss[0]-'0';
        for(int j=0;j<n-1;j++){
            if(i&(1<<j)){
                ans+=tot;
                tot=0;
            }
            tot=tot*10+(ss[j+1]-'0');
        }
        ans+=tot;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <cmath>
#include <string>
#include <sstream>
#include <iomanip>
#include <complex>
using namespace std;

#define ll long long
#define vvi vector< vector<int> >
#define vi vector<int>
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
	int n;
	ll int sum = 0;
	ll int saidai = -9000000;
	ll int saishou = 9000000;
	cin >> n;
	REP(i,n){
		ll int tmp;
		cin >> tmp;
		sum += tmp;
		saidai = max(saidai,tmp);
		saishou = min(saishou,tmp);
	}
	cout << saishou << " " << saidai << " " << sum << endl;
}

Measured memory_bytes: 1168
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int n;
  cin>>n;
  int s[n];
  for(int i=0;i<n;i++) cin>>s[i];
  int q;
  cin>>q;
  int t[q];
  for(int i=0;i<q;i++) cin>>t[i];
  int ans=0;
  int used[q];
  memset(used,0,sizeof(used));
  for(int i=0;i<n;i++){
    for(int j=0;j<q;j++){
      if(used[j]) continue;
      if(s[i]==t[j]){
	ans++;
	used[j]=1;
      }
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3156
import java.util.*;
import java.io.*;
import java.util.function.*;

class Main {
    static Scanner scanner = new Scanner();
    static int mod = 1000000007;
    static int inf = 0x7ffffff;

    void solve() {
        int n = scanner.nextInt();
        int m = scanner.nextInt();
        char[] s = scanner.next().toCharArray();
        int[] prev = new int[n + 1];
        for (int l = 0, r = 0; r <= n; r++) {
            while (s[l] == '1' || r - l > m) {
                l++;
                if (l == r) {
                    System.out.println(-1);
                    return;
                }
            }
            prev[r] = l;
        }
        int now = n;
        List<Integer> list = new ArrayList<>();
        while (now > 0) {
            list.add(now - prev[now]);
            now = prev[now];
        }
        for (int i = list.size() - 1; i >= 0; i--) {
            System.out.println(list.get(i));
        }
    }

    public static void main(String[]$) throws Exception {
        new Main().solve();
        System.out.flush();
    }
}

class System {
    static PrintWriter out = new PrintWriter(java.lang.System.out);

    static void exit() {
        java.lang.System.exit(0);
    }
}

class Scanner {
    private BufferedReader reader = new BufferedReader(new InputStreamReader(java.lang.System.in), 0x10000);
    private StringTokenizer tokenizer;

    String next() {
        try {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                tokenizer = new StringTokenizer(reader.readLine());
            }
        } catch (IOException ignored) {
        }
        return tokenizer.nextToken();
    }

    int nextInt() {
        return Integer.parseInt(next());
    }

    long nextLong() {
        return Long.parseLong(next());
    }

    char[][] nextCharArray(int n, int m) {
        char[][] a = new char[n][m];
        for (int i = 0; i < n; i++) {
            a[i] = next().toCharArray();
        }
        return a;
    }

    int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = nextInt();
        }
        return a;
    }

    int[] nextIntArray(int n, IntUnaryOperator op) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = op.applyAsInt(nextInt());
        }
        return a;
    }

    long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++) {
            a[i] = nextLong();
        }
        return a;
    }

    long[] nextLongArray(int n, LongUnaryOperator op) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++) {
            a[i] = op.applyAsLong(nextLong());
        }
        return a;
    }
}


Measured memory_bytes: 28956
N,M = map(int, input().split())
A = {}
C = 0
P = 0
for i in range(M):
    p,S = map(str, input().split())
    if S == 'AC' and A.get(p+S) is None:
        A[p+S] = 0
        C += 1
    elif S == 'WA' and A.get(p+'AC') is None and A.get(p+S) is None:
        A[p+S] = 1
    elif S == 'WA' and A.get(p+'AC') is None:
        A[p+S] += 1
for i in range(1,N+1):
    if A.get(str(i)+'AC') is not None and A.get(str(i)+'WA') is not None:
        P += A[str(i)+'WA']
print(C,P)

Measured memory_bytes: 17216
/*
 * @Author: Kaizyn
 * @Date: 2020-03-16 17:27:28
 * @LastEditors: Kaizyn
 * @LastEditTime: 2020-03-16 17:30:31
 * @FilePath: \Code\atcoder\panasonic2020D.cpp
 */
#include <bits/stdc++.h>

// #define DEBUG

using namespace std;

const int N = 10;
const int MOD = 1e9+7;
const double eps = 1e-7;
const int INF = 0x3f3f3f3f;
typedef pair<int, int> pii;

int n;
string s;

void f(const int &u, const int &l)
{
    if (u >= n) {
        cout << s << endl;
        return;
    }
    for (int i = 0; i <= l+1; ++i) {
        s.push_back('a'+i);
        f(u+1, max(l, i));
        s.pop_back();
    }
}

inline void solve()
{
    cin >> n;
    f(0, -1);
}

signed main()
{
    ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    int testcase = 1;
    // cin >> testcase;
    for (int i = 1; i <= testcase; ++i) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 1536
#include<algorithm>/*{{{*/
#include<cctype>
#include<cassert>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<ctime>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<vector>
using namespace std;
typedef long long lld;
typedef long double lf;
typedef unsigned long long uld;
typedef pair<int,int> pii;
#define fi first
#define se second
#define pb push_back
#define mk make_pair
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define ROF(i,a,b) for(int i=(a);i>=(b);--i)
namespace RA{
    int r(int p){return 1ll*rand()*rand()%p;}
    int r(int L,int R){return r(R-L+1)+L;}
}/*}}}*/
/******************heading******************/
const int N=500;

int n,K,P;
long long f[N][N],C[N][N];
//f[i,j]表示i个点，根结点的权值为j的树的个数（默认根结点的id=0）

int main(){
    scanf("%d%d%d",&n,&K,&P);
    FOR(i,0,K)f[1][i]=1;
    ROF(i,K,0)f[1][i]=(f[1][i]+f[1][i+1])%P;
    C[0][0]=1;
    FOR(i,1,n+1){
        C[i][0]=1;
        FOR(j,1,i)C[i][j]=(C[i-1][j-1]+C[i-1][j])%P;
    }
    FOR(i,2,n+1){
        ROF(j,K,0){
            FOR(k,1,i-1){
                long long s=f[k][j+1];
                f[i][j]=(f[i][j]+(f[i-k][j]-f[i-k][j+1])*C[i-2][k-1]%P*s)%P;
            }
            f[i][j]=(f[i][j]+f[i][j+1])%P;
        }
    }
    printf("%lld\n",(f[n+1][0]-f[n+1][1]+P)%P);
    return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    if(a<=b){
        cout<<a*c<<endl;
    }else{
        cout<<b*c+(a-b)*d<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<iostream>
#include<cstring>
#include<vector>
#include<string> 
#include<queue>
#include<set>
#include<map>
#include<algorithm>
using namespace std;
#define INF 0x3f3f3f3f
#define mod 1000000007
#define ll long long
#define mp make_pair
int main()
{
	int x,y;
	cin>>x>>y;
	if(x%y)cout<<x<<endl;
	else cout<<-1<<endl;
	return 0;
}

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

using namespace std;
static constexpr int INF = 1000000000;

int main(){
	ios_base::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<int> a(n), b(n);
	for(int i = 0; i < n; ++i){ cin >> a[i]; }
	for(int i = 0; i < n; ++i){ cin >> b[i]; }
	vector<array<int, 51>> dp(1 << n);
	for(auto& a : dp){ fill(a.begin(), a.end(), INF); }
	dp[0][0] = 0;
	for(int i = 0; i < (1 << n); ++i){
		for(int j = 0; j <= 50; ++j){
			for(int k = 0, c = 0; k < n; ++k){
				if(i & (1 << k)){ continue; }
				const int flip = (c ^ __builtin_popcount(i & ~((1 << k) - 1))) & 1;
				const int v = flip ? b[k] : a[k];
				if(v >= j){ dp[i | (1 << k)][v] = min(dp[i | (1 << k)][v], dp[i][j] + c); }
				++c;
			}
		}
	}
	int answer = INF;
	for(int i = 0; i <= 50; ++i){
		answer = min(answer, dp.back()[i]);
	}
	if(answer >= INF){ answer = -1; }
	cout << answer << endl;
	return 0;
}



Measured memory_bytes: 52608
#include <iostream>
#include <cmath>

using namespace std;

int main()
{
        int n;

        while (cin >> n) {
                bool *isPrime = new bool[n + 1];
                isPrime[0] = false;
                isPrime[1] = false;
                for (int i = 2; i < n + 1; i++) {
                        isPrime[i] = true;
                }
                for (int i = 2; i <= (int)sqrt(n); i++) {
                        if (isPrime[i]) {
                                for (int j = 2; j <= n / i; j++) {
                                                isPrime[i * j] = false;
                                }
                        }
                }
                int ans = 0;
                for (int i = 2; i <= n; i++) {
                        if (isPrime[i]) {
                                ans++;
                        }
                }
                cout << ans << endl;
                delete [] isPrime;
        }

        return 0;
}

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

int main()
{
ll n ;
cin >> n ;
rep(i,50010){
  ll t=i*1.08;
  if(t==n)ans=i;
}
if(ans==-1){
  cout << ":(" << endl;
return 0;
}
cout << ans << endl;
return 0;
}

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

int main() { 
  string S;
  cin >> S;
  int C=0;
  if (S=="SUN") {C=7;}
  if (S=="MON") {C=6;}
  if (S=="TUE") {C=5;}
  if (S=="WED") {C=4;}
  if (S=="THU") {C=3;}
  if (S=="FRI") {C=2;}
  if (S=="SAT") {C=1;}
  cout << C << endl;
} 

Measured memory_bytes: 3632
#include <cstdio>
#include <algorithm>
using namespace std;

int main() {
  for(int tci = 0; ; tci++) {
    int N, M; scanf("%d%d", &N, &M);
    if(N==0) break;
    static int h[1501], w[1501];
    h[0] = 0;
    for(int i = 0; i < N; i++) {
      scanf("%d", h+i+1);
      h[i+1] += h[i];
    }
    w[0] = 0;
    for(int i = 0; i < M; i++) {
      scanf("%d", w+i+1);
      w[i+1] += w[i];
    }
    static int a[1501*1501+1];
    int asz = 0;
    for(int i = 0; i <= N; i++) {
      for(int j = 0; j <= M; j++) {
        a[asz++] = h[i]+w[j];
      }
    }
    sort(a, a+asz);
    a[asz] = -1;
    long long cnt = 0;
    int subcnt = 0;
    for(int i = 0; i < asz; i++) {
      subcnt++;
      if(a[i] != a[i+1]) {
        cnt += (long long)subcnt*(subcnt-1)/2;
        subcnt = 0;
      }
    }
    printf("%lld\n", cnt);
  }
  return 0;
}

Measured memory_bytes: 9856
N,L = map(int, raw_input().split())
if L >= 0:
	print(N*(N+1)/2 + N*(L-1)- L)
elif L >= 1-N:
	print(N*(N+1)/2 + N*(L-1))
else:
	print(N*(N+1)/2 + N*(L-1)- (L+N-1))

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

#define all(v) (v).begin(), (v).end()
#define sortv(v) sort(all(v))
#define uniqv(v) (v).erase(unique(all(v)), (v).end())
#define pb push_back
#define FI first
#define SE second
#define lb lower_bound
#define ub upper_bound
#define mp make_pair
#define test 1
#define TEST if(test)

using namespace std;

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

const int MOD = 1000000007; // 998244353
const int INF = 2e9;
const ll INFLL = 1e18;
const int MAX_N = 30;

int N;
int A[MAX_N+1], B[MAX_N+1], C[MAX_N+1];
int ans=0;

int main(){
	cin>>N;
	for(int i=1; i<=N; i++){
		scanf("%d", &A[i]);
	}
	for(int i=1; i<=N; i++){
		scanf("%d", &B[i]);
	}
	for(int i=1; i<N; i++){
		scanf("%d", &C[i]);
	}
	for(int i=1; i<=N; i++){
		ans += B[A[i]];
		if(i!=1){
			if(A[i]==A[i-1]+1){
				ans += C[A[i-1]];
			}
		}
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
	"strconv"
	"strings"
)

func solution(n, k, s int) []int {
	ans := make([]int, n)
	for i := 0; i < k; i++ {
		ans[i] = s
	}
	if s == 1e9 {
		for i := k; i < n; i++ {
			ans[i] = 1
		}
	} else {
		for i := k; i < n; i++ {
			ans[i] = s + 1
		}
	}

	return ans
}

func main() {
	var n, k, s int
	fmt.Scan(&n, &k, &s)
	ans := solution(n, k, s)

	l := len(ans)
	strs := make([]string, l)

	for i := range ans {
		strs[i] = strconv.Itoa(ans[i])
	}

	fmt.Println(strings.Join(strs, " "))
}


Measured memory_bytes: 9088
let () = Scanf.scanf "%d %d\n" @@ fun n k ->
  let xs = Array.init n @@ fun _ -> Scanf.scanf "%d " @@ fun x -> x in
  Printf.printf "%d\n" @@ Array.fold_left min max_int @@ 
  Array.init (n - k + 1) @@ fun i ->
    if (xs.(i) <= 0) = (xs.(i + k - 1) <= 0) then
      max (abs xs.(i)) (abs xs.(i + k - 1))
    else
      min (2 * abs xs.(i) + abs xs.(i + k - 1)) (abs xs.(i) + 2 * abs xs.(i + k - 1))



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

int main() {
  int A, B;
  cin >> A >> B;
  
  int count = 0;
  for(int i = 0; i <= B-A; i++){
    int C,a,b,c,d,e;
    C = A + i;
    a = C/10000;
    b = (C-10000*a)/1000;
    c = (C-10000*a-1000*b)/100;
    d = (C-10000*a-1000*b-100*c)/10;
    e = C-10000*a-1000*b-100*c-10*d;
    if(a==e && b==d) count++;
  }
  cout << count << endl;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.NoSuchElementException;
import java.util.Scanner;

public class Main {
	
	private static ArrayList<Long> gcd = new ArrayList<Long>();
	private static ArrayList<Long> lcm = new ArrayList<Long>();
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		try{
			while(sc.hasNextLong()){
				long a = sc.nextLong();
				long b = sc.nextLong();
				gcd.add(getGCD(a, b));
				lcm.add(getLCM(a, b));
			}
		}catch(NoSuchElementException e){
			//ツ禿シツ療債づ個終ツづュツづィツつェツ禿シツ療債つウツづェツつスツづァツ篠淞づ個コツーツドツづ鳴渉按猟敖づーツ進ツづ淞づゥ
		}
		
		//ツ催妥・ツ古カツ姪アツ青板δ環スツトツづ催渉ャツ古カツ倍ツ青板δ環スツトツづーツ出ツ療債つキツづゥ
		int sizeAnswerList = gcd.size();
		for(int i = 0; i < sizeAnswerList; i++){
			System.out.println(gcd.get(i) + " " + lcm.get(i));
		}
	}
	
	private static long getGCD(long a, long b){
		long numBigger;
		long numSmaller;
		if(a > b){
			numBigger = a;
			numSmaller = b;
		}
		else{
			numBigger = b;
			numSmaller = a;
		}
		
		long gcd;
		while(true){
			if(numBigger == numSmaller){
				gcd = numBigger;
				break;
			}
			long tmp = numBigger;
			numBigger = numSmaller;
			numSmaller = tmp - numSmaller;
			if(numBigger < numSmaller){
				tmp = numBigger;
				numBigger = numSmaller;
				numSmaller = tmp;
			}
		}
		
		return gcd;
	}
	
	private static long getLCM(long a, long b){
		long tmp = b / getGCD(a, b);
		return a * tmp;
	}
}

Measured memory_bytes: 11000