akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<string.h>
#pragma GCC optimize("O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define rep(i,N) for(int i=0;i<(int)N;i++)
static inline void PUT(char c)
{
  static char buf[1<<15],*ptr=buf;
  if(ptr==buf+strlen(buf)||c==0){fwrite(buf,1,ptr-buf,stdout),ptr=buf;}*ptr++=c;
}
static inline int IN(void)
{
  int x=0,f=0,c=getchar();while(c<48||c>57){f^=c==45,c=getchar();}
  while(c>47&&c<58){x=x*10+c-48,c=getchar();}return f?-x:x;
}
static inline void OUT(int a)
{
  if(a<0)PUT('-'),a=-a;
  int d[40],i=0;do{d[i++]=a%10;}while(a/=10);
  while(i--){PUT(d[i]+48);}PUT('\n');
}
int main()
{
  int N=IN(),D1=0,D2=0,count=0,judge=0;
  while(N--)
  {
    D1=IN(),D2=IN();if(D1==D2){count++;if(count>2){judge=1;}}else{count=0;}
  }
  return puts(!judge?"No":"Yes"),0;
}

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

// @@ !! LIM()

int main(int argc, char *argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  ll N, K; cin >> N >> K;
  ll M = 63;
  vector v(M, vector<ll>(N));
  for (ll i = 0; i < N; i++) {
    ll a; cin >> a; a--;
    v.at(0).at(i) = a;
  }
  for (ll k = 0; k < M-1; k++) {
    for (ll i = 0; i < N; i++) {
      v.at(k+1).at(i) = v.at(k).at(v.at(k).at(i));
    }
  }

  ll i = 0;
  for (ll k = M-1; k >= 0; k--) {
    ll b = 1LL << k;
    if ((b & K) != 0) i = v.at(k).at(i);
  }
  cout << i + 1 << endl;

  return 0;
}



Measured memory_bytes: 103252
n = int(input())
A = list(map(int,input().split()))
data = [0]*3
ans = 1
mod = pow(10,9)+7
for i in A:
    ans *= data.count(i)
    ans %= mod
    if ans == 0:
        break
    data[data.index(i)] += 1
print(ans)

Measured memory_bytes: 20696
N,K = map(int,input().split())
A = list(map(int,input().split()))
s = 1
B = [0]*(10**6)
B[0] = 1
C = [0]*(10**6)
C[1] = 1 
for i in range(K):
    s -= 1
    s = A[s]
    B[i + 1] = s
    C[s] += 1
    if C[s] > 1:
        k = B.index(s)
        l = i + 1 - k
        s = 10**10
        break
if s < 10**10:
    print(s)
else:
    B1 = B[k:k+l]
    r = (K - k)%l
    print(B1[r])

Measured memory_bytes: 36584
#include "bits/stdc++.h"

#define REP(i, n ,N) for(ll i = (n); i < (N); i++)
#define RREP(i, n ,N) for(ll i = (N-1); i >= 0; i--)
#define p(s) cout<<(s)<<endl
#define p2(a, b) cout<<(a)<<" "<<(b)<<endl
using namespace std;
typedef long long ll;
ll mod = 1e9+7;
ll inf = 1e18;

ll N;
ll d[55];
ll ans;
int main(){
	cin >> N;
	REP(i,0,N) cin>>d[i];
	REP(i,0,N){
		REP(j,i+1,N){
			ans += d[i] * d[j];
		}
	}
	p(ans);
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<deque>
#include<map>
#include<bitset>
using namespace std;

typedef long long ll;
#define rep(i, n) for(int i = 0;i < (n);i++)
#define repr(i, n) for(int i = (n);i >= 0;i--)
#define repf(i, m, n) for(int i = (m);i < (n);i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1;} return 0;}
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
//////////////////////////////////////////////////


int main() {
    string s; cin >> s;
    int ans = 0;
    int cnt = 0;
    rep(i,s.size()) {
        if (s[i] == 'A' || s[i] == 'C' || s[i] == 'G' || s[i] == 'T') {
            cnt++;
        } else {
            chmax(ans, cnt);
            cnt = 0;
        }
    }
    chmax(ans, cnt);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
template<class T> inline bool chmin(T&a, T b){if(a > b){a = b; return true;}else{return false;}}
template<class T> inline bool chmax(T&a, T b){if(a < b){a = b; return true;}else{return false;}}
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1.0)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

const int MAX = 5000000;
long long fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % mod;
        inv[i] = mod - inv[mod%i] * (mod / i) % mod;
        finv[i] = finv[i - 1] * inv[i] % mod;
    }
}
 
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}

ll modpow(ll a, ll n, ll modo) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % modo;
        a = a * a % modo;
        n >>= 1;
    }
    return res;
}

int main() {
    ll k, ans = 0;
    string s;
    cin >> k >> s;
    COMinit();
    rep(i, k+1){
        ans += ((COM(s.size()+k-i-1, s.size()-1) * modpow(25, k-i, mod) % mod) * modpow(26, i, mod)) % mod; 
        ans %= mod;
    }
    cout << ans << endl;
}

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

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

	if (b - a == c - b) {

		cout << "YES" << endl;

	}
	else {

		cout << "NO" << endl;

	}
	return 0;
}

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

typedef long long ll;
using namespace std;
const int N = 100010;
int _w;

void bmax( ll &a, ll b ) {
	a = a > b ? a : b;
}

int n, a[N];
ll f[N][2];

int main() {
	_w = scanf( "%d", &n );
	for( int i = 1; i <= n; ++i )
		_w = scanf( "%d", a+i );
	memset(f, 0x80, sizeof f);
	f[1][0] = 0;
	for( int i = 1; i <= n; ++i ) {
		if( a[i] ) {
			int now = a[i] / 2;
			if( a[i] & 1 ) {
				bmax( f[i+1][0], f[i][1] + now + 1 );
				bmax( f[i+1][1], f[i][0] + now );
				bmax( f[i+1][1], f[i][1] + now );
			} else {
				bmax( f[i+1][0], f[i][0] + now );
				bmax( f[i+1][0], f[i][1] + now );
				bmax( f[i+1][1], f[i][0] + now - 1 );
				bmax( f[i+1][1], f[i][1] + now );
			}
		} else {
			bmax( f[i+1][0], f[i][0] );
			bmax( f[i+1][0], f[i][1] );
		}
	}
	printf( "%lld\n", max( f[n+1][0], f[n+1][1] ) );
	return 0;
}


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

class Program
{
    static void Main(string[] args)
    {
        string[] s = Console.ReadLine().Split(' ');
        int N = int.Parse(s[0]);
        ulong K = ulong.Parse(s[1]);
        var array = Enumerable.Repeat((ulong)0, AMAX + 1).ToArray();
        for (int i = 0; i < N; i++)
        {
            string[] ss = Console.ReadLine().Split(' ');
            int a = int.Parse(ss[0]);
            int b = int.Parse(ss[1]);
            array[a] += (ulong)b;
        }
        ulong itemNum = 0;
        for (int i = 1; i <= AMAX; i++)
        {
            if (K <= array[i])
            {
                Console.WriteLine(i);
                return;
            }
            K -= array[i];
        }
    }
  	public const int AMAX = 100000;
}

Measured memory_bytes: 17752
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)

const string YES = "Yes";
const string NO = "No";

void solve(long long N){

}

int main(){
    string s;
    cin >> s;
    if(s[0] == '9' || s[1] == '9') {
        cout << YES << endl;
    } else{
        cout << NO << endl;
    }

}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, n) for (ll i = 0; i < n; i++)
#define REPR(i, n) for (ll i = n; i >= 0; i--)
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define FORR(i, m, n) for (ll i = m; i >= n; i--)
#define REPO(i, n) for (ll i = 1; i <= n; i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(), n.end()
#define MOD 1000000007
#define P pair<ll, ll>

ll n, dp0[110000], dp1[110000], dp2[110000], ndp2[110000], p[110000], ans = MINF;
vector<ll> g[110000];

void dfs(ll v, ll par){
    vector<ll> s0, s1, s2;
    REP(i, g[v].size()){
        ll w = g[v][i];
        if (w == par) continue;
        dfs(w, v);
        if(dp0[w] - 2 > 0) dp0[v] += dp0[w] - 2;
        s0.push_back(dp0[w] - 2);
        s1.push_back(dp1[w] - 1);
        s2.push_back(dp2[w] - 2);
    }
    //dp1
    REP(i, s0.size()){
        if (s0[i] >= 0) dp1[v] += s0[i];
    }
    ll dp1ma = 0;
    REP(i, s0.size()){
        if (s0[i] >= 0) dp1ma = max(dp1ma, s1[i] - s0[i]);
        else dp1ma = max(dp1ma, s1[i]);
    }
    dp1[v] += dp1ma;

    //dp2 * 1
    REP(i, s0.size()){
        if (s0[i] >= 0) ndp2[v] += s0[i];
    }
    ll dp2ma = 0;
    REP(i, s0.size()){
        if (s0[i] >= 0) dp2ma = max(dp2ma, s2[i] - s0[i]);
        else dp2ma = max(dp2ma, s2[i]);
    }
    ndp2[v] += dp2ma;

    //dp1 * 2
    vector<ll> d2;
    REP(i, s0.size()){
        if (s0[i] >= 0) dp2[v] += s0[i];
    }
    REP(i, s0.size()){
        if (s0[i] >= 0) d2.push_back(s1[i] - s0[i]);
        else d2.push_back(s1[i]);
    }
    sort(ALL(d2), greater<ll>());
    REP(i, min(2ll, (ll)d2.size())){
        if(d2[i] > 0) dp2[v] += d2[i];
    }
    dp2[v] = max(dp2[v], ndp2[v]);
    dp0[v] += p[v];
    dp1[v] += p[v];
    dp2[v] += p[v];
    ans = max({ans, dp0[v], dp1[v], dp2[v]});
}
int main(){
    cin >> n;
    REP(i, n)cin >> p[i];
    REP(i, n - 1){
        ll a, b;
        cin >> a >> b;
        a--;
        b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    dfs(0, -1);
    cout << ans << endl;
}




Measured memory_bytes: 36216
def main():
    n, c, k = map(int, input().split())
    t_lst = [int(input()) for i in range(n)]

    t_lst.sort()
    idx, bus = 0, 0
    while idx < n:
        t = t_lst[idx]
        bus += 1
        cus = 1
        idx += 1
        while idx < n and cus < c and t_lst[idx] - t <= k:
            cus += 1
            idx += 1

    print(bus)


if __name__ == '__main__':
    main()


Measured memory_bytes: 7384
#include<math.h>
#include<stdlib.h>
#include<string.h>
#include<algorithm>
#include<array>
#include<iomanip>
#include<iostream>
#include<limits>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<vector>
#include<functional>

using namespace std;

typedef long long ll;
const ll INF = 1e9;
const ll MOD = 1e9 + 7;
#define rep(i, n) for( int i = 0; i < (n); i++)
#define loop(i, a, n) for(int i = a; i < (n); i++)
#define all(in) in.begin(), in.end()
#define vint vector<int> 

int main(){
    int r;
    cin >> r;
    cout << r * r << endl;
    return 0;
}

Measured memory_bytes: 256
using System;

namespace _139b
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] read = Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
            int A = read[0];
            int B = read[1];
            int res = 1;
            if(B == 1){
                res = 0;    
            }
            else{
                int count = 0;
                int extend_A = 0;
                while(extend_A < B){
                    extend_A = A + count * (A-1);
                    count ++;
                }
                res = count;
            }
            Console.WriteLine(res);
        }
    }
}

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

using namespace std;
using ll = long long;

//container util
#define SORT(c) sort((c).begin(),(c).end())

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


int main(void){

	int a; cin >> a;
	int ans = 3 * a * a;
	cout << ans << endl;


	return 0;

}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<climits>
#include<iostream>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<list>
#include<map>
#include<set>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define pb push_back
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};
 
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)

ll n,w,h;
ll ww[300000],hh[300000];

int main(){
    cin >> n >> w >> h;
    REP(i,n){
        ll x,y,www;
        cin >> x >> y >> www;
        ww[max(0ll,x - www)]++;
        ww[x + www]--;
        hh[max(0ll,y - www)]++;
        hh[y + www]--;
    }

    /*REP(i,w + 1) {
        cout << ww[i] << " ";
    }
    cout << endl;*/
    REP(i,w) {
        ww[i + 1] += ww[i];
        //cout << ww[i] << " ";
    }
    //cout << ww[w] << endl;
    REP(i,h){
        hh[i + 1] += hh[i];
    }

    bool fw = true,fh = true;

    REP(i,w) {
        if(ww[i] < 1) {
            fw = false;
            break;
        } 
    }
    REP(i,h) {
        if(hh[i] < 1) {
            fh = false;
            break;
        } 
    }
    if(!fw && !fh) {
        cout << "No" << endl;
    }else {
        cout << "Yes" << endl;
    }
    return 0;
}




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


int main() {
  long int N;
  cin>>N;
  if(N>1){
  vector<long int>vec(N,0);
  for(int i=0;i<N;i++){cin>>vec.at(i);}
  vector<long int>dai(N-1,0);
  if(vec.at(0)>vec.at(1)){dai.at(0)=vec.at(0)-vec.at(1);}
for(int j=0;j<N-2;j++){
if(vec.at(j+1)+dai.at(j)>vec.at(j+2)){dai.at(j+1)=vec.at(j+1)+dai.at(j)-vec.at(j+2);}
}
long int s=0;
  for(int k=0;k<N-1;k++){s+=dai.at(k);}
  cout<<s<<endl;}
  else{cout<<0<<endl;}
}

Measured memory_bytes: 6356
// Gaurav Aggarwal

/*
useful stl
array<ll,size> ar;         //size(),front(),back(),fill(),empty()
deque<ll> d                //push_back(),push_front(),pop_front(),pop_back()
vector<ll> v(size,val);    //push_back(),*max_element(v.begin(),v.end()),accumulate(v.begin(),v.end(),0)
stack<ll> g;               //push(),pop(),top(),size(),empty()         LIFO
queue<ll> q;               //push(),size(),front(),back(),empty()      FIFO
priority_queue<ll> pq
*/

#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<ll,ll> ipair;
typedef pair<long,long> lpair;
#define scan(x) do{while((x=getchar_unlocked())<'0'); for(x-='0'; '0'<=(_=getchar_unlocked()); x=(x<<3)+(x<<1)+_-'0');}while(0)
char _;
#define For(i, a, b) for(__typeof (a) i=a; i<=b; i++)
#define mod 1000000007
#define PI 3.141592653589793238462643383279502884 
#define debug1(a) cout<<a<<"\n";
#define debug2(a,b) cout<<a<<" "<<b<<"\n";
#define debug3(a,b,c) cout<<a<<" "<<b<<" "<<c<<"\n";
#define debug_arr(a,n) {for(__typeof (n) i=0; i<n; ++i) {cout<<a[i]<<" ";}}
#define inp_arr(a,n) for(__typeof (n) i=0; i<n; ++i) {cin>>a[i];}
#define beg_arr(a,n) for(__typeof (n) i=0; i<n; ++i) {a[i] = 0;}

ll power(ll x, ll y) 
{ 
    ll res = 1;   
    while (y > 0) { 
        if (y & 1) 
            res = (res*x)%mod; 
        y = y>>1;
        x = (x*x)%mod; 
    } 
    return res%mod; 
}

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

    // #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin);
    // freopen("out.txt", "w", stdout); 
    // #endif  

    char s;
    cin>>s;
    if(s == 'A') {
        cout<<"T\n";
    }
    else if(s == 'T') {
        cout<<"A\n";
    }
    else if(s == 'G') {
        cout<<"C\n";
    }
    else {
        cout<<"G\n";
    }
    
    
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys

N = int(input())
A = list(map(int, input().split()))

num_even = 0
num_odd = 0

for i in range(N):
    if A[i] % 2 == 0:
        num_even += 1
    else:
        num_odd += 1

if (num_even == 0) and (num_odd == 0):
    print("NO")
    sys.exit(0)
if (num_even == 1) and (num_odd == 0):
    print("YES")
    sys.exit(0)
if num_odd == 1 and num_even == 0:
    print("YES")
    sys.exit(0)

if num_odd % 2 == 1:
    print("NO")
    sys.exit(0)

print("YES")


Measured memory_bytes: 62704
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define gt(n) scanf("%d", &n)
#define gtll(n) scanf("%ld", &n)
#define out(n) printf("%d", n)
#define outll(n) printf("%ld", n)
#define loop(n) for(int i=0; i<n; i++)
#define MAXX 1001
#define mem(x, y) memset(x, y, sizeof(x))
#define loop1(n) for(int i=1; i<=n; i++)
#define ll long long
#define pb push_back
#define pi acos(-1)
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
//(only in c)char[33];itoa(n,buffer,base);printf("%s",buffer);
#define dec_to_bin(n) std::string binary = std::bitset<64>(n).to_string();
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL)
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
int main()
{
    fast;
    int n;
    string s;
    cin>>s;
    string q="",p="";
    bool f=0;
    for(int i=1; i<=s.size(); i++)
    {
        if(i&1)p+='1';
        else p+='0';
    }
    int c1=0,c2=0;
    for(int i=0; i<s.size(); i++)
    {
        if(s[i]!=p[i])c1++;
    }
    for(int i=1; i<=s.size(); i++)
    {
        if(i&1)q+='0';
        else q+='1';
    }
    for(int i=0; i<s.size(); i++)
    {
        if(s[i]!=q[i])c2++;
    }
    cout<<min(c1,c2)<<endl;

    return 0;
}


Measured memory_bytes: 720
#include<bits/stdc++.h>
#define LL long long
#define REP(i,n) for(int i=0;i<(n);++i)
#define PER(i,n) for(int i=n-1;i>=0;--i)
#define REPA(i,n) for(int i=1;i<(n);++i)
#define foreach(i, n) for(auto &i:(n))
#define PII pair<int,int>
#define PLI pair<long long, int>
#define PLL pair<long long, long long>
#define MOD ((LL)1e9+7) 
#define INF ((LL)1e9+7)
#define INFLL ((LL)1e18)
#define ALL(x) (x).begin(),(x).end()
#define BIT(x) (1LL << (x))
using namespace std;
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(a>b){a=b;return true;}return false;}

LL modpow(LL x, LL b){
	LL res = 1;
	while(b){
		if(b&1)res = res * x % MOD;
		x = x * x % MOD;
		b>>=1;
	}
	return res;
}

LL modinv(LL x){
	return modpow(x, MOD-2);
}

LL factorial(LL x){
	static vector<LL> memo((int)2e5, 0);
	memo[1]=1;
	if(x<=1)return 1;
	if(memo[x]>=1)return memo[x];
	int i;
	for(i=memo.size()-1;!memo[i];--i);
	LL res = memo[i];
	for(i=i+1;i<=x;++i){
		res *= i;
		res %= MOD;
		memo[i] = res;
	}
	return memo[x];
}


LL C(LL a, LL b){
	return factorial(a) * modinv(factorial(b) * factorial(a-b) % MOD) % MOD;
}

LL H(LL a, LL b){
	return C(a+b, b);
}

int main(){
	string str;
	cin >> str;
	REP(i, str.size()-1){
		if(str[i]==str[i+1]){
			cout << i+1 << " " << i+2 << endl;
			return 0;
		}
	}
	REP(i, str.size()-2){
		if(str[i]==str[i+2]){
			cout << i+1 << " " << i+3 << endl;
			return 0;
		}
	}
	cout << "-1 -1" << endl;
	return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define fo(i,n) for(int i=0;i<n;i++)
#define Fo(i,k,n) for(int i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long
#define si(x)	scanf("%d",&x)
#define sl(x)	scanf("%lld",&x)
#define ss(s)	scanf("%s",s)
#define pi(x)	printf("%d\n",x)
#define pl(x)	printf("%lld\n",x)
#define ps(s)	printf("%s\n",s)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pl;
typedef vector<int>		vi;
typedef vector<ll>		vl;
typedef vector<pii>		vpii;
typedef vector<pl>		vpl;
typedef vector<vi>		vvi;
typedef vector<vl>		vvl;
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());

int mpow(int base, int exp);
void ipgraph(int n, int m);
void dfs(int u, int par);

const ll mod = 1'000'000'007;
const ll mod1= 998244353;
const int N = 5e5, M = N;
//=======================

vi g[N];
int a[N];
int f[1000000];


void solve() {
    double n,x,t;
    cin>>n>>x>>t;
    cout<<(ll)(ceil(n/x)*t)<<"\n";
}


int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    srand(chrono::high_resolution_clock::now().time_since_epoch().count());

    int t;
    //cin>>t;
    t=1;
    while(t--)
    {
      solve();
    }
    return 0;
}

int mpow(int base, int exp) {
  base %= mod;
  int result = 1;
  while (exp > 0) {
    if (exp & 1) result = ((ll)result * base) % mod;
    base = ((ll)base * base) % mod;
    exp >>= 1;
  }
  return result;
}

void ipgraph(int n, int m){
	int i, u, v;
	while(m--){
		cin>>u>>v;
    u--, v--;
		g[u].pb(v);
		g[v].pb(u);
	}
}


void dfs(int u, int par){
	for(int v:g[u]){
		if (v == par) continue;
		dfs(v, u);
	}
}


Measured memory_bytes: 15464
#include <cstdio>
#include <iostream>
#include <string>

using namespace std;

#define ll long long
#define INF (1 << 30)
#define INFLL (1LL << 60)

#define FOR(i,a,b) for(ll i = (a);i<(b);i++)
#define REP(i,a) FOR(i,0,(a))
#define MP make_pair

int main() {
	string a, b, c;
	cin >> a >> b >> c;
	cout << a[0] << b[0] << c[0] << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define rep_start(a,i,n) for(ll i=a;i<=n;i++)
#define rev(i,n) for(ll i=n-1;i>=0;i--)
#define rev1(i,n) for(ll i=n;i>0;i--)
#define sort(x) sort(x.begin(),x.end())
#define reverse(x) reverse(x.begin(),x.end())
#define zero0(x,n) fill(x.begin(),x.begin()+n,0)
#define zero1(x,n) fill(x.begin(),x.begin()+n,1)
#define zero(x) fill(x.begin(),x.end(),0)
#define pb push_back
#define vi vector<int>
#define vvi vector<vector<int>>
#define vpii vector<pair<int,int> >
#define vb vector<bool>
#define pii pair<int,int>
#define F first
#define S second
#define INF 1e9+7
typedef long long int ll;

void solve(){
    int n,m;
    cin>>n>>m;
    cout<<(n*(n-1)/2)+(m*(m-1)/2);
}
signed main() {
    // your code goes here
    IOS
    ll t=1;
    //cin>>t;
    rep1(i,t){
        solve(); 
    }
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    abc143d()
}

fun abc143d() {
    val n = readLine()!!.toInt()
    val lines = readLine()!!.split(" ").map { it.toInt() }
        .sorted().toIntArray()

    var answer = 0
    for (ai in 0..lines.size - 2) {
        for (bi in ai + 1..lines.size - 1) {
            val right = lowerBound(lines, lines[ai] + lines[bi])
            val left = bi + 1
            answer += right - left
        }
    }

    println(answer)
}

// list must be sorted
// find element's index, greater than or equals key
private fun lowerBound(list: IntArray, key: Int): Int {
    var ng = -1
    var ok = list.size

    while (ok - ng > 1) {
        val mid = (ok + ng) / 2
        if (list[mid] >= key) ok = mid else ng = mid
    }
    return ok
}


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

#define fast_io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

using namespace std;

#define debug(x) cout<<(#x)<<"="<<(x)<<", ";
#define debug1(x) debug(x) cout<<'\n';
#define debug2(x1, x2) debug(x1) debug(x2) cout<<'\n';
#define debug3(x1, x2, x3) debug(x1) debug(x2) debug(x3) cout<<'\n';
#define debug4(x1, x2, x3, x4) debug(x1) debug(x2) debug(x3) debug(x4) cout<<'\n';
#define debug5(x1, x2, x3, x4, x5) debug(x1) debug(x2) debug(x3) debug(x4) debug(x5) cout<<'\n';

#define fcout cout<<fixed<<setprecision(15)
#define repp(i,j,k) for(int i=j; i<k; ++i)
#define rep(i,j) repp(i,0,j)
#define rrep(i,j,k) for(int i=j; i>=k; --i)
#define all(x) (x).begin(), (x).end()
#define sort(x) sort(x.begin(), x.end())
#define lb(x,val) lower_bound(x.begin(), x.end(), val)
#define ub(x,val) upper_bound(x.begin(), x.end(), val)
#define pb(x) emplace_back(x);

typedef long long int lli;
typedef pair<int,int> pii;
typedef pair<lli,lli> pll;
typedef vector<int> vi;
typedef vector<lli> vl;
typedef tuple<int, int, lli> tiil;

//const lli M=998244353ll;
const lli M=1000000007ll;
const double D=1.0;

int main(){
fast_io
string a,b; cin>>a>>b;
if(a[0]==b[2] and a[1]==b[1] and a[2]==b[0]) cout<<"YES";
else cout<<"NO";
return 0;
}

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

typedef long long ll;
typedef long double ld;

int main(){
    ios_base::sync_with_stdio(false);
    cout.precision(10);
    cout<<fixed;

    int n;
    cin >> n;
    int i;
    for(i=1; ; i++){
        if(i*(i+1)/2 >= n){
            break;
        }
    }
    for(; i>=1; i--){
        if(i <= n){
            n -= i;
            cout << i << "\n";
        }
    }
    return 0;
}


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

using namespace std;

#define ll long long
#define rep(i, n) for (ll i = 1; i < (n + 1); i++)



int main()
{
    int a, b, c, d;
    int count_t, amari_t;
    int count_a, amari_a;
    bool hantei = false;
    cin >> a >> b >> c >> d;
    count_t = c / b;
    amari_t = c % b;
    count_a = a / d;
    amari_a = a % d;
    if (count_t < count_a) {
        hantei = true;
    } else if (count_t == count_a) {
        if (amari_t != 0 && amari_a == 0) {
            hantei = false;
        } else{
            hantei = true;
        }
    } else if (count_t > count_a) {
        if (amari_a > 0 && amari_t == 0) {
            hantei = true;
        } else{
            hantei = false;
        }
    }

    if(hantei) {
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 3100
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;
#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

#[allow(dead_code)]
fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main(){
    let n = read_as_vec::<u32>()[0];
    let a = read_as_vec::<u32>();

    if a.iter().filter(|x| *x%2 == 1).count()%2 == 1{
        println!("NO");
    }else{
        println!("YES");
    }
}


Measured memory_bytes: 4352
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <iomanip>
#include <set>
using namespace std;
typedef long long int ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define yes cout << "yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define no cout << "no" << endl

const int INF = 1001001001;
const int mod = 1000000007;
#define PI 3.14159265359;

void P(int x) {cout << x << endl;}
void P(long x) {cout << x << endl;}
void P(double x) {cout << x << endl;}
void P(ll x) {cout << x << endl;}
void P(string x) {cout << x << endl;}
void P(char x) {cout << x << endl;}

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;
  cin >> n;
  int p[n];
  rep (i, n) {
    cin >> p[i];
  }
  int ans = 0;
  for (int i = 1; i < n - 1; i++) {
    if (p[i] < max({p[i -1], p[i], p[i + 1]}) && p[i] > min({p[i -1], p[i], p[i + 1]})) {
      ans++;
    }
  }
  P(ans);
  return 0;

}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;

namespace AtCoder
{
    public class QuestionA
    {
        public static void Main(string[] args)
        {
            var waru = 1e9 + 7;
            double power = 1;

            // 整数の入力
            long n = long.Parse(Console.ReadLine());

            for (int i = 1; i <= n; ++i) {
                power = power * i % waru;
            }

            Console.WriteLine(power);

        }
    }
}

Measured memory_bytes: 18572
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

#define mem(dp,a)           memset(dp,a,sizeof dp)
#define rep(i,a,b)          for(ll i=a;i<b;i++)
#define pb(x)               push_back(x)
#define mp(x,y)             make_pair(x,y)
#define fastio              ios_base::sync_with_stdio(false);cin.tie(NULL)
#define F                   first
#define S                   second
#define all(v)              (v).begin(),(v).end()
#define pi                  3.14159265359
ll INF=1e18+10;
ll MOD=998244353;//1000000007;

int main()
{
    int n;cin>>n;
    ll a;
    multiset<ll> s;
    rep(i,0,n)
    {
        cin>>a;
        auto x=s.lower_bound(a);
        if(x==s.begin())
            s.insert(a);
        else
        {
            x--;
            if(*x==a)
                s.insert(a);
            else
                s.erase(x),s.insert(a);
        }
    }
    cout<<s.size()<<endl;
}


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

map<int,int> mp;
int ans;
int main(){
	int n,a;
	
	cin >> n;
	while(n--){
		cin >> a;
		if(mp[a]){
			mp[a] = 0;
			ans--;
		}
		else{
			mp[a] = 1;
			ans++;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 4992
#include<iostream>
#include<string>
using namespace std;
struct Dice{
  int s[6];
  void roll(char c){
    int b;
    if(c=='E'){
      b=s[0];
      s[0]=s[3];
      s[3]=s[5];
      s[5]=s[2];
      s[2]=b;
    }
    if(c=='W'){
      b=s[0];
      s[0]=s[2];
      s[2]=s[5];
      s[5]=s[3];
      s[3]=b;
    }
    if(c=='N'){
      b=s[0];
      s[0]=s[1];
      s[1]=s[5];
      s[5]=s[4];
      s[4]=b;
    }
    if(c=='S'){
      b=s[0];
      s[0]=s[4];
      s[4]=s[5];
      s[5]=s[1];
      s[1]=b;
    }
    if(c=='R'){
      b=s[1];
      s[1]=s[2];
      s[2]=s[4];
      s[4]=s[3];
      s[3]=b;
    }    
  }
  int top() {
    return s[0];
  }
  int right(){
    return s[2];
  }
  int left(){
    return s[3];
  }
  int front(){
    return s[1];
  }
};
int main(){
  Dice d;
  for(int i=0;i<6;i++) cin >> d.s[i];
  int n;cin >> n;
  while(n--){
    int a,b;cin >> a >> b;
    if(d.left()==a) d.roll('E');
    if(d.right()==a) d.roll('W');
    while(d.top()!=a) d.roll('N');
    while(d.front()!=b) d.roll('R');
    cout << d.right() << endl;
  }
  return 0;
}



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

using namespace std;

int main() {
    int d, t, s;
    cin >> d >> t >> s;
    if (1.0 * d / t <= s) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 3612
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Formatter;
import java.util.HashMap;

public class Main {

	public static void main(String[] args) throws IOException {
		// TODO ?????????????????????????????????????????????
//		System.out.println(getBinary('A'));
//		System.out.println(getBinary('P'));
//		System.out.println(getBinary('Z'));
//		System.out.println(getBinary(' '));
//		System.out.println(getBinary('?'));
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		TransMap tm = new TransMap();
		
		while(true){
			String str = br.readLine();

			if(str == null){
				break;
			}
			StringBuffer sb = new StringBuffer();
			for(int i = 0 ; i < str.length() ;i++){
				sb.append(getBinary(str.charAt(i)));
			}
			
			//System.out.println(sb);
			
			int start = 0;
			int end = 1;
			while(start <= sb.length() - 1 && end <= sb.length()){
				String sub = sb.substring(start, end);
				
				char tmpc = tm.translate(sub);
				if(tmpc != '\0'){
					System.out.print(tmpc);
					start = end;
					end = start + 1;
				}
				else {
					end++;
				}
			}
			System.out.println();
		}

	}

	static String getBinary(char c){
		if(c >= 'A' && c <= 'Z'){
			String tmpStr = Integer.toBinaryString(c-'A');
			if(tmpStr.length() >= 5){
				return tmpStr.substring(tmpStr.length() - 5, tmpStr.length());
			}
			else {
				Formatter fm = new Formatter();
				fm.format("%05d", Integer.parseInt(tmpStr));
				return fm.toString();
			}
		}
		
		switch (c){
		case ' ':
			return "11010";
		case '.':
			return "11011";
		case ',':
			return "11100";
		case '-':
			return "11101";
		case '\'':
			return "11110";
		case '?':
			return "11111";
			
		}
		return null;
	}
}

class TransMap {
	private HashMap<String, Character> map;
	
	public TransMap(){
		map = new HashMap<String, Character>();
		
		map.put("101", ' ');
		map.put("000000", '\'');
		map.put("000011", ',');
		map.put("10010001", '-');
		map.put("010001", '.');
		map.put("000001", '?');
		map.put("100101", 'A');
		map.put("10011010", 'B');
		map.put("0101", 'C');
		map.put("0001", 'D');
		map.put("110", 'E');
		map.put("01001", 'F');
		map.put("10011011", 'G');
		map.put("010000", 'H');
		map.put("0111", 'I');
		map.put("10011000", 'J');
		map.put("0110", 'K');
		map.put("00100", 'L');
		map.put("10011001", 'M');
		map.put("10011110", 'N');
		map.put("00101", 'O');
		map.put("111", 'P');
		map.put("10011111", 'Q');
		map.put("1000", 'R');
		map.put("00110", 'S');
		map.put("00111", 'T');
		map.put("10011100", 'U');
		map.put("10011101", 'V');
		map.put("000010", 'W');
		map.put("10010010", 'X');
		map.put("10010011", 'Y');
		map.put("10010000", 'Z');

	}
	
	public char translate(String input){
		if(map.containsKey(input)){
			return map.get(input);
		}
		
		else {
			return '\0';
		}
	}
}

Measured memory_bytes: 44468
#include <iostream>
#include <vector>
#include <algorithm>

int main(int argc, char *argv[])
{
  int n;
  std::cin >> n;
  std::vector<long long> h;
  for (int i = 0; i < n; i++)
  {
    long long h_i;
    std::cin >> h_i;
    h.push_back((double)h_i);
  }
  int max_move = 0;
  int move = 0;
  for (size_t i = 0; i < h.size() - 1; i++)
  {
    if (h[i] >= h[i + 1])
    {
      move++;
    }
    else
    {
      if (max_move < move)
      {
        max_move = move;
      }
      move = 0;
    }
  }
  if (max_move < move)
  {
    max_move = move;
  }

  std::cout << max_move << std::endl;
  return 0;
}


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

using namespace std;

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



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

  int N;
  cin >> N;

  vector<string> table(2);
  cin >> table[0];
  cin >> table[1];

  constexpr long long MOD = 1000000007;
  long long solutions = 1;

  bool up_down = false;
  int start = 0;

  if (table[0][0] == table[1][0]){
    solutions = (solutions * 3) % MOD;
    start += 1;
  }
  else{
    solutions = (solutions * 6) % MOD;
    up_down = true;
    start += 2;
  }

  for (int i = start; i < N; ){
    if (up_down){
      if (table[0][i] == table[1][i]){
        solutions = (solutions * 1) % MOD;
        up_down = false;
        i += 1;
      }
      else{
        solutions = (solutions * 3) % MOD;
        up_down = true;
        i += 2;
      }
    }
    else{
      if (table[0][i] == table[1][i]){
        solutions = (solutions * 2) % MOD;
        up_down = false;
        i += 1;
      }
      else{
        solutions = (solutions * 2) % MOD;
        up_down = true;
        i += 2;
      }
    }
  }

  cout << solutions << endl;

  return 0;
}


Measured memory_bytes: 256
from collections import deque

n = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)
a = deque(a)
ans = a[0]
a.popleft()
n-=2
while n>0:
    if n>=2:
        ans += a[0]*2
        n-=2
        a.popleft()
    else:
        ans += a[0]
        n-=1
print(ans) 


Measured memory_bytes: 32508
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 998244353;
const ll INF = 1LL << 60;
ll mod_pow(ll, ll, ll); ll mod_fact(ll, ll); ll mod_inv(ll, ll); ll gcd(ll, ll); ll lcm(ll, ll);
//
int main(){
    int a, b;
    cin >> a >> b;
    cout << a + b / 2;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=int;
int main()
{
    ll n,i,j,k,ct=0;
    //map<ll,ll>mp;
    ios::sync_with_stdio(false);
    cin.tie(0);
    unordered_map<ll,ll>seen;
    cin>>n;
    vector<ll>arr(n);
    for(i=0;i<n;i++)
    {
        cin>>arr[i];
        seen[arr[i]]++;
    }
    // sort(arr.begin(),arr.end());
    int f;
    for(i=0;i<n;i++)
    {
        f=0;
        for(j=1;j<=sqrt(arr[i]);j++)
        {
            if(arr[i]%j==0)
            {
                if(seen[j]>=1 and arr[i]!=j)
                {
                    f=1;
                    break;
                }
                else if(seen[j]>=2 and arr[i]==j)
                {
                    f=1;
                    break;
                }
                else if(seen[arr[i]/j]>=1 and arr[i]!=(arr[i]/j))
                {
                    f=1;
                    break;
                }
                else if(seen[arr[i]/j]>=2 and arr[i]==(arr[i]/j))
                {
                    f=1;
                    break;
                }
            }
        }
        if(f==0) ct++;
    }
    // for(i=0;i<n;i++)
    // {
    //     for(j=0;j<n;j++)
    //     {
    //         if(i!=j and arr[i]%arr[j]==0)
    //         {
    //             break;
    //         }
    //     }
    //     if(j==n) cout<<arr[i]<<" ";
    // }
    cout<<ct;
    return 0;
}

Measured memory_bytes: 32596
#include <bits/stdc++.h>
#include <algorithm>
#include <string>
#include <iomanip>
using namespace std;

int main() {
  int h, w;
  cin >> h >> w;
  char c[110][110] = {};
  for(int i = 0; i < h; i++){
    for(int j = 0; j < w; j++){
      cin >> c[i][j];
    }
  }

  for(int i = 0; i < h; i++){
    for(int j = 0; j < w; j++){
      cout << c[i][j];
    }
    cout << endl;
    for(int j = 0; j < w; j++){
      cout << c[i][j];
    }
    cout << endl;
  }
}


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

int N;
long long K;
vector<long long> a;
 
int main() {
    int N;
    cin >> N;
    vector<long long> a(N+1);
    for (int i = 1; i < N+1; i++){
        cin >> a[i];
    }

    vector<long long> v(N+1);
    for (int i = N; i > 0; i--){
        long long sums = 0;
        for (int j = 1; j <= N/i; j++){
            if(i > N/2) v[i] = a[i];
            else sums += v[i*j];
        }
        if(sums%2 != a[i]){
            v[i] = 1;
        }else{
            v[i] = 0;
        }
    }

    long long cnt = 0;
    long long res = 0;
    for (int i = 1; i <= N; i++)
    {
        if(v[i] != 0) cnt++;
        res += v[i];
    }
    cout << res << endl;
    for (int i = 1; i <= N; i++){
        if(v[i] != 0) cout << i << endl;
    }
}

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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

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

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

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

  LL N;
  cin >> N;
  VL xs(N);
  REP(i,N) cin >> xs[i];

  LL ans = 0;
  while(true){
	RSORT(xs);
	
	if(xs[0] < 1000) break;
	int e = 1;
	for(;e<N;++e)
	  if(xs[e-1] - xs[e] >= N+1) break;
	if(e == N) break;

	LL k = (xs[e-1] - xs[e]) / (N+1);
	REP(i,e){
	  xs[i] += (-N + e-1) * k;
	}
	FOR(i,e,N){
	  xs[i] += e*k;
	}
	ans += e*k;
  }
  if(xs[0] > 1000){
	LL d = xs[0] - 1000;
	ans += d*N;
	REP(i,N) xs[i] -= d;
  }

  while(true){
	RSORT(xs);
	if(xs[0] < N) break;
	xs[0] -= N;
	FOR(i,1,N) ++xs[i];
	++ans;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      	int d = sc.nextInt();
    	String christmas = "Christmas";
        String eve = " Eve";

      	if (d == 25) { 
			System.out.println(christmas);
       	} else if (d == 24) {
        	System.out.println(christmas + eve);
        } else if ( d == 23) {
        	System.out.println(christmas + eve + eve);
        } else if ( d == 22) {
        	System.out.println(christmas + eve + eve + eve);
        }else {
        	System.out.println("error");
        }
    }
}

  

Measured memory_bytes: 22868
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int s;
  cin >>s;
  int s1=s/100;
  int s2=(s-100*s1)/10;
  int s3=s-100*s1-10*s2;
  cout << s1+s2+s3 <<endl;
}

Measured memory_bytes: 3616
def yaku(card):
    table=[0]*13
    for i in range(5):
        table[card[i]-1]+=1
    if table.count(4)!=0:
        return "four card"
    elif table.count(3)!=0:
        if table.count(2)!=0:
            return "full house"
        else:
            return "three card"
    elif table.count(2)!=0:
        if table.count(2)==2:
            return "two pair"
        else:
            return "one pair"
    else:

        if ",".join(map(str,card)) in "1,2,3,4,5,6,7,8,9,10,11,12,13" or\
           ",".join(map(str,card)) in "1,10,11,12,13":
            return "straight"
        else:
            return "null"
while True:
    try:
        card=map(int,raw_input().split(","))
        card.sort()
        print yaku(card)
    except:
        break

Measured memory_bytes: 4232
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int INF = 0x3f3f3f3f;
const double pi = acos(-1);
namespace {
  template <typename T> inline void read(T &x) {
    x = 0; T f = 1;char s = getchar();
    for(; !isdigit(s); s = getchar()) if(s == '-') f = -1;
    for(;  isdigit(s); s = getchar()) x = (x << 3) + (x << 1) + (s ^ 48);
    x *= f;
  }
}
#define fio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define _for(n,m,i) for (register int i = (n); i < (m); ++i)
#define _rep(n,m,i) for (register int i = (n); i <= (m); ++i)
#define lson rt << 1, l, mid
#define rson rt << 1 | 1, mid + 1, r
#define lowbit(x) x & (-x)
#define pii pair<int,int>
#define fi first
#define se second
const int N = 200;
char s[N];
int main() {
  scanf("%s", s);
  for(int i = 0; s[i]; i++) {
    printf("x");
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include <vector>
#include <algorithm>
#include <functional>
#include <cstdio>
#include <iomanip>

using namespace std;
// for loop
#define F(i, L, R) for(int i = L; i < R; i++)
#define FE(i, L, R) for(int i = L; i <= R; i++)
// for (reversed)
#define FR(i, L, R) for(int i = L; i > R; i--)
#define FRE(i, L, R) for(int i = L; i >= R; i--)

// data types
#define ll long long
#define ull unsigned long long
#define ui unsigned int
#define us unsigned shoft

// vectors
typedef vector<int> vi;
typedef vector<long> vl;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
#define ALL(c) (c).begin(),(c).end()
#define last(vec) vec.size()-1
#define lastEle(vec) vec[last(vec)]

// debug
#define DBG(vari) cerr<<#vari<<" = "<<(vari)<<endl;
#define printA(a, L, R) FE(i, L, R) cout << a[i] << (i==R?'\n':' ')
#define printAF(a, L) printA(a, 0, L-1)
#define printV(a) printA(a, 0, a.size()-1)

// utils
#define char2int(c) (c-'0')
#define bit(x, i) (x&(1<<i))
#define space ' '
#define PI 3.14159265358979323

int main() {
    long a,b;
    char operand;
    vector<long> results;
    while(1){
        cin >> a >> operand >> b;
        long result;
        if(operand == '?')break;
        switch(operand){
            case '+':
                result = a + b;
                break;
            case '-':
                result = a - b;
                break;
            case '*':
                result = a * b;
                break;
            case '/':
                result = a / b;
                break;
            default:
                result = 0;
                break;
        }
        results.push_back(result);
    }
        
    F(i, 0, results.size()){
        cout << results[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 3128
#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()
#define dec(x) cout << fixed << setprecision(x);
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;


int main(){
  ll n,d; cin >> n >> d ;
  cout << (n+2*d)/(2*d+1) << endl;
}

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

int main(){
    int n, m;
    cin >> n >> m;
    if(n==m) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cerr<<*i<<" "; cerr<<endl; }
inline bool valid(int x, int y, int W, int H){ return (x >= 0 && y >= 0 && x < W && y < H); }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

int main(){
  int N;
  while(cin>>N && N){
    int d[100][100];
    REP(i, N)REP(j, N){
      cin>>d[i][j];
    }
    ll ans = 0;
    REP(i, N)FOR(j, i + 1, N){
      ans += min(d[i][j], d[j][i]);
    }
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 1196
#include<bits/stdc++.h>
using namespace std;
const int dx[]={1,-1,0,0};
const int dy[]={0,0,1,-1};
int n,m,ans;
char s[1111][1111];
int vis[1111][1111];
struct node
{
	int x,y,step;
}nex,now;
queue<node> que;
void bfs(){
	while(!que.empty()){
		now=que.front();que.pop();
		ans=max(ans,now.step);
		for(int i=0;i<4;i++){
			nex.x =now.x+dx[i];nex.y=now.y+dy[i];nex.step=now.step+1;
		
			if(s[nex.x][nex.y]=='.'&&!vis[nex.x][nex.y]){
				s[nex.x][nex.y]=='#';vis[nex.x][nex.y]=1;
				que.push(nex);
			}
		}
	}
}

int main(){

  scanf("%d%d",&n,&m);
  for(int i=1;i<=n;i++)
    for(int j=1;j<=m;j++)
    {
    	cin>>s[i][j];
    	now.x=i,now.y=j,now.step=0;
    	if(s[i][j]=='#')vis[i][j]=1,que.push(now);
    }
    bfs();
    printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 17808