akhauriyash/Code-Regression huggingface dataset:
class Combination:
    def __init__(self, n, MOD):
        self.fact = [1] * (n + 1)
        for i in range(1, n + 1):
            self.fact[i] = self.fact[i-1] * i % MOD
        self.inv_fact = [pow(self.fact[i], MOD - 2, MOD) for i in range(n + 1)]
        self.MOD = MOD

    def factorial(self, k):
        """k!を求める O(1)"""
        return self.fact[k]

    def inverse_factorial(self, k):
        """k!の逆元を求める O(1)"""
        return self.inv_fact[k]

    def permutation(self, k, r):
        """kPrを求める O(1)"""
        if k < r:
            return 0
        return (self.fact[k] * self.inv_fact[r]) % self.MOD

    def combination(self, k, r):
        """kCrを求める O(1)"""
        if k < r:
            return 0
        return (self.fact[k] * self.inv_fact[k - r] * self.inv_fact[r]) % self.MOD


h, w, n = map(int, input().split())
info = [(1, 1)] + [tuple(map(int, input().split())) for i in range(n)] + [(h, w)]
info = sorted(info)
n += 2
MOD = 10**9 + 7
comb = Combination(w+h+1, MOD)

dp = {}
dp[0] = (0, 1)
def solve(ind):
    if ind in dp:
        return dp[ind]
    i, j = info[ind]
    dp0 = 0
    dp1 = 0
    for ind2 in range(n):
        if ind2 == ind:
            continue
        pi, pj = info[ind2]
        if pi <= i and pj <= j:
            tmp = comb.combination((i+j)-(pi+pj), i-pi)
            dp0 += tmp * solve(ind2)[1] % MOD
            dp1 += tmp * solve(ind2)[0] % MOD
    dp[ind] = (dp0, dp1)
    return dp[ind]

for i in range(n):
    solve(i)
print((dp[n-1][0] - dp[n-1][1]) % MOD)


Measured memory_bytes: 58220
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0; i<n; ++i)
#define rep1(i,n) for(ll i=1; i<=n; ++i)
#define revrep(i,n) for(ll i=n-1; n>=0; --i)
inline constexpr ll Inf = (1ULL << 62) -1;
#define fastio cin.tie(nullptr); ios_base::sync_with_stdio(false);
#define endl '\n'

template <class T>
void updatemax(T& a, T b) { if (b > a) a = b; }

int main() {
    fastio;
    ll ans=0, N, K;
    cin >> N >> K;
    for (ll c=K; c <= N+1; ++c) {
        ll s = (c-1)*c/2;
        ll l = (2*N -c+1)*c/2;
        ans += l - s + 1;
        ans %= (int)1e9+7;
    }
    cout << ans << endl;
}


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

bool check(const vector<int> &b){
	for(int i = 0; i < b.size(); ++i){
		if(b[i] != i + 1) return false;
	}
	return true;
}

int main(){
	int n;
	while(scanf("%d", &n), n){
		vector<int> b(n);
		for(int i = 0; i < n; ++i){
			scanf("%d", &b[i]);
		}

		int ans;
		for(ans = 0; ans <= 10000 && !check(b); ++ans){
			int k = b.size();
			for(int i = 0; i < k; ++i){
				--b[i];
			}
			b.erase(remove(b.begin(), b.end(), 0), b.end());
			b.push_back(k);
		}

		printf("%d\n", ans <= 10000 ? ans : -1);
	}
}

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

int main(){
    int N;
    cin >> N;
    vector<int> a(N);
    for(int i = 0;i < N;i++)    cin >> a[i];
    bool f = true;
    for(int i = 0;i < N;i++)    if(a[i]&1)  f = false;
    if(!f)  cout << "first" << endl;
    else    cout << "second" << endl;
}

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

unsigned egcd(unsigned a, unsigned b)
{
    if (a < b)
        return egcd(b, a);
    unsigned r;
    while ((r = a % b))
    {
        a = b;
        b = r;
    }
    return b;
}

int main()
{
    int k;
    cin >> k;
    long long ans = 0;

    for (int i = 1; i < k + 1; i++)
    {
        for (int j = 1; j < k + 1; j++)
        {
            for (int s = 1; s < k + 1; s++)
            {
                ans += __gcd(__gcd(i, j), s);
            }
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 3632
#include <iostream>
#include <cstdio>
#define _USE_MATH_DEFINES
#include <math.h>
#include <vector>
#include <string>
#include <ctype.h>
 
using namespace std;
 
void solve()
{
    string x;
    while (cin >> x)
    {
        if (x == "0")
        {
            break;
        }
        int ans = 0;
        for (int i = 0; i < x.size(); ++i)
        {
            ans += x[i] - '0';
        }
        cout << ans << endl;
    }
}
 
int main()
{
    solve();
    return(0);
}


Measured memory_bytes: 3148
def main():
    K = int(input())
    Kstr = str(K)
    
    if Kstr[-1] in ('0','2','4','6','8','5'):
        print(-1)
    else:
        if K%7 == 0:
            L = (9*K)/7
        else:
            L = 9*K
        S = 10
        for i in range(1,6000000):
            S = S%L
            if S == 1:
                print(i)
                break
            S = S*10
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 9196
#include <iostream>
#include <algorithm>
#include <unordered_map>
#include <vector>
#include <map>
using namespace std;

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

int main()
{
    long long n, m;
    cin >> n >> m;
    string s, t;
    cin >> s >> t;
    int g = gcd(n, m);
    long long z = n * m / g;
    bool success = true;
    for (int j = 0; j < g; ++j)
    {
        if (s[j * z / m] != t[j * z / n])
        {
            success = false;
        }
    }

    cout << (success ? z : -1) << endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define endl "\n"
#define pb push_back
#define SZ(x) ((int)(x.size()))
#define FOR(i,s,n) for (ll i = (s); (i) < (n); ++i)
#define FORD(i,s,l) for (ll i = (s); (i) >= l; --i)
#define F first
#define S second
#define TC int __tc; cin >> __tc; FOR(case_num,1,__tc+1)
#define TEST(x,i) ((x)&(1ll<<(i)))
#define SET(x,i) ((x)|(1ll<<(i)))
#define FLIP(x,i) ((x)^(1ll<<(i)))
#define CLEAR(x,i) ((x)&~(1ll<<(i)))

const double pi = 4 * atan(1);
using namespace std;
typedef long long ll;

const ll MOD = 1000000007;
const int MAXN = 200005;

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

	int a[5];
	FOR(i,0,5)
	{
		cin >> a[i];
	}
	sort(a, a + 5);
	int best = 1000000;
	do {

		int t = 0;
		FOR(i,0,5)
		{
			t += a[i];
			if (i < 4)
				while (t % 10 != 0) {
					t++;
				}
		}
		best = min(best, t);

	} while (next_permutation(a, a + 5));

	cout << best << "\n";

}


Measured memory_bytes: 3656
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
 
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
  ll a,b,c; cin>>a>>b>>c;
  vector<ll> d(b); for(auto& in:d) cin >> in;
ll it = lower_bound(d.begin(),d.end(),c)-d.begin();
  cout << min(it,b-it)<<endl;
    return 0;
}

Measured memory_bytes: 256
program name
    use,intrinsic :: iso_fortran_env
    implicit none
    integer(int32):: n,i,j,k,y

    read*, n,y

    do i=0,n
        do j=0,n-i
            k = n-i-j
            if (10000*i+5000*j+1000*k == y) then
                print'(3(i0,1x))', i,j,k
                stop
            end if
        end do
    end do

    print'(3(i0,1x))', -1,-1,-1
end program name

Measured memory_bytes: 768
#include<stdio.h>
int main(){
    long long N;
    long long move[5];
    scanf("%lld",&N);
    scanf("%lld",&move[0]);
    long long min=move[0];
    for(int i=1;i<5;i++){
        scanf("%lld",&move[i]);
        if(min>move[i]){
            min=move[i];
        }
    }
    long long ans=((N+min-1)/min)+4;
    printf("%lld\n",ans);
}

Measured memory_bytes: 128
fun solve(k: Int, a: Int, b: Int) {
    var ans = "OK"
    val aa = a % k
    val bb = b % k
    if (b - a < k) {
        if (aa == 0 || bb == 0) {
        } else {
            if (aa <= bb) {
                ans = "NG"
            }
        }
    }
    println(ans)
}

fun main() {
    val k = readLine()!!.toInt()
    val (a, b) = readLine()!!.split(" ").map { it.toInt() }
    solve(k, a, b)
}

Measured memory_bytes: 36328
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <map>
#include <set>
#include <iomanip>
using namespace std;

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

int main()
{
    int H,W;
    cin >> H >> W;
    vector<vector <bool> > tile(H+2,vector<bool>(W+2,0));
    vector<P> sted;
    for (int i=1; i<=H; i++){
        for (int j=1; j<=W; j++){
            char c;
            cin >> c;
            if(c=='.'){
                sted.push_back(P(i,j));
            }else tile[i][j]=1;
        }
    }

    
    int ans=0;
    for(P st: sted){
        for(P ed: sted){
            if(st==ed) continue;
            int tmp;
            queue<P> que;
            que.push(st);
            vector<vector <int> > dst(H+2,vector<int>(W+2,-1));
            vector<vector <bool> > flag(H+2,vector<bool>(W+2,0));
            flag=tile;

            dst[st.first][st.second]=0;
            flag[st.first][st.second]=true;
            for(int i=0; i<=W+1; i++){
                flag[0][i]=true;
                flag[H+1][i]=true;
            }
            for(int i=0; i<=H+1; i++){
                flag[i][0]=true;
                flag[i][W+1]=true;
            }

            while(!que.empty()){
                P now=que.front();
                que.pop();
                if(now==ed){
                    tmp=dst[now.first][now.second];
                    break;
                }
                int x=now.first;
                int y=now.second;
                
                if(flag[x+1][y]!=true){
                    dst[x+1][y]=dst[x][y]+1;
                    flag[x+1][y]=true;
                    que.push(P(x+1,y));
                }
                if(flag[x-1][y]!=true){
                    dst[x-1][y]=dst[x][y]+1;
                    flag[x-1][y]=true;
                    que.push(P(x-1,y));
                }
                if(flag[x][y-1]!=true){
                    dst[x][y-1]=dst[x][y]+1;
                    flag[x][y-1]=true;
                    que.push(P(x,y-1));
                }
                if(flag[x][y+1]!=true){
                    dst[x][y+1]=dst[x][y]+1;
                    flag[x][y+1]=true;
                    que.push(P(x,y+1));
                }
            }
            ans=max(ans,tmp);
        }
    }
    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 256
A = list(input())
op = ["-", "+"]
for op1 in op:
    for op2 in op:
        for op3 in op:
            left = A[0]+op1+A[1]+op2+A[2]+op3+A[3]
            if eval(left) == 7:
                print(left+"=7")
                exit()

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

int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  vector<int> B(N);
  int maxx=0;
  for(int i=0; i<N; i++){
    cin >> A.at(i);
    B.at(i) = A.at(i);
    maxx=max(maxx, A.at(i));
  }
  int cnt=0;
  for(int i=0; i<N; i++){
    if(maxx==A.at(i)) cnt++;
  }
  if(cnt==1){
    for(int i=0; i<N; i++){
      if(A.at(i)==maxx){
        B.at(i)=0;
        int maxy=0;
        for(int j=0; j<N; j++) maxy=max(maxy, B.at(j));
        cout << maxy << endl; 
      }
      else cout << maxx << endl;
    }
  }
  else{
    for(int i=0; i<N; i++) cout << maxx << endl;
  }
}

Measured memory_bytes: 3200
n = str(input())
s = []
for i in range(len(n)-2):
    s.append(n[i] + n[i+1] + n[i+2])
t = 753
for i in range(len(n)-2):
    if(t > abs(753-int(s[i]))):
        t = abs(753-int(s[i]))
print(t)

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

typedef long long ll;
const int maxn=1e6+7;
const int inf=INT_MAX;
const ll inff=1e18;
const ll mod=998244353;
#define pii pair<int,int>
#define mkp make_pair
#define F first
#define S second
#define pb push_back
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(),(v).end()
#define int ll

#ifdef HNO2
#define IOS
#else
#define endl '\n'
#define IOS ios::sync_with_stdio(0); cin.tie(0);
#endif // HNO2

int dp[3007][3007];

int32_t main()
{
    IOS
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    for (int i=a;i<=c;i++)
        for (int j=1;j<=d;j++)
    {
        if (i==a&&j==b) dp[i][j]=1;
        else if (i==a) dp[i][j]=dp[i][j-1]*a%mod;
        else if (j==b) dp[i][j]=dp[i-1][j]*b%mod;
        else dp[i][j]=(j*dp[i-1][j]+i*dp[i][j-1]+mod-(i-1)*(j-1)*dp[i-1][j-1]%mod)%mod;
    }
    cout<<dp[c][d]<<endl;
}



Measured memory_bytes: 73964
#include <iostream>
#include <math.h>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string>
using namespace std;
const double PI = acos(-1.0);
const string alp = "abcdefghijklmnopqrstuvwxyz";
const string ALP = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define REP1(i,n) FOR(i,1,n+1)
#define SUM(c) accumulate((c).begin(),(c).end(),0)
#define UNIQ(c) (c).erase(unique((c).begin(), (c).end()), (c).end());
#define Yn(b) puts(b?"Yes":"No")
#define YN(b) puts(b?"YES":"NO")

bool isprime(int p) {
  if (p==1) return false;
    FOR(i,2,p) {
      if (p%i==0) return false;
    }
  return true;
}

int main(){
  int w,h,v,z,n,x,y,a;
  cin >> w >> h >> n;
  v=z=0;
  REP(i,n){
    cin >> x >> y >> a;
    if(a==1){
      if(x>w){
        cout << 0;
        return 0;
      }
      if(x>v) v=x;
    } else if(a==2) {
      if(x<v){
        cout << 0;
        return 0;
      }
      if(x<w) w=x;
    } else if(a==3){
      if(y>h){
        cout << 0;
        return 0;
      }
      if(y>z) z=y;
    } else if(a==4) {
      if(y<z){
        cout << 0;
        return 0;
      }
      if(y<h) h=y;
    }
  }
  cout << (w-v)*(h-z);
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>


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

  int m=n/2,i,j;
  if(n%2==0)
    {
      printf("%d\n",(m-1)*n);
      for(i=1;i<=n;i++)
	for(j=i+1;j<=n;j++)
	  {
	    if(i+j!=n+1)
	      printf("%d %d\n",i,j);
	  }
    }
  else
    {
      printf("%d\n",(n-1)*m);
      for(i=1;i<n;i++)
	{
	  printf("%d %d\n",i,n);
	  for(j=i+1;j<n;j++)
	    {
	      if(i+j!=n)
		printf("%d %d\n",i,j);
	    }
	}
    }


  return 0;
}


Measured memory_bytes: 128
import java.util.PriorityQueue
import kotlin.comparisons.compareByDescending
fun main(args: Array<String>) {
    var (N, M) = listOfInt()
    val A = listOfLong()
    val Q = PriorityQueue<Long>(N, compareByDescending { it })
    Q.addAll(A)
    repeat(M) {
        val a = Q.poll()!!
        Q.add(a / 2)
    }
    var ans = Q.asIterable().sum()
    println(ans)
}

fun next() = readLine()!!
fun nextInt() = Integer.parseInt(next())
fun nextInt(offset: Int = 0) = nextInt() + offset
fun nextLong() = java.lang.Long.parseLong(next())
fun nextLong(offset: Long = 0L) = nextLong() + offset
fun nextDouble() = next().toDouble()
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map { Integer.parseInt(it) }
fun listOfInt(offset: Int = 0) = listOfString().map { Integer.parseInt(it) + offset }
fun listOfLong() = listOfString().map { java.lang.Long.parseLong(it) }
fun listOfLong(offset: Long = 0L) = listOfString().map { java.lang.Long.parseLong(it) + offset }
fun listOfDouble() = listOfString().map { it.toDouble() }


Measured memory_bytes: 73660
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mk make_pair
#define pii pair<int,int>
#define fst first
#define scd second
using namespace std;

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

const int MAXN=1e5+5;
int n,m,fa[MAXN];

struct EDGE {
	int u,v;
}e[MAXN];

ll ans[MAXN],sz[MAXN];

int get_fa(int x) {
	if(x==fa[x]) return x;
	return fa[x]=get_fa(fa[x]);
}

int main() {
	
	n=read();
	m=read();
	
	for(int i=1;i<=m;++i) {
		e[i].u=read(); 
		e[i].v=read();
	}
	
	for(int i=1;i<=n;++i) 
	   fa[i]=i,sz[i]=1;
	
	ans[m]=(ll)n*(n-1)/2;  
	
	for(int i=m;i>=1;--i) {
		int u=get_fa(e[i].u),v=get_fa(e[i].v);
		if(u==v) 
		    ans[i-1]=ans[i];
		else {
			ans[i-1]=ans[i]-sz[v]*sz[u];
			sz[v]+=sz[u]; fa[u]=v;
		}
	}
	
	for(int i=1;i<=m;++i) 
	   cout<<ans[i]<<endl;
	return 0;
}


Measured memory_bytes: 4096
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < int(n); i++)
using namespace std;
using ll = long long;
const int INF = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int r;
  cin >> r;
  cout << 2*r*M_PI << endl;
  return 0;
}

Measured memory_bytes: 3800
#!/mnt/c/Users/moiki/bash/env/bin/python
N = int(input())
H = list(map(int, input().split()))
A = list(map(int, input().split()))
# ---------------------------------------------------------------------------------
from collections import deque
N0 = 2**(N).bit_length()
INF = float("inf")
INF = -(2**31-1) 

data = [INF]*(2*N0)

def update(k,x):
    k += N0 - 1
    data[k] = x
    # oldk = k
    # k += N0-1 # $B$3$N:n6H$O!D!D(B? #$B0lHV2<$NCJ$K(B
    # data[k] = k # $B$3$l@N$NCM$rF~$l$J$$$H$$$1$J$$$s$8$c$J$$$N!)(B
    # data[k] = oldk # $B$3$l@N$NCM$rF~$l$J$$$H$$$1$J$$$s$8$c$J$$$N!)(B
    while k >= 0:
        k = (k-1)//2
        data[k] = max(data[2*k+1], data[2*k+2])

# $B6h4V(B[l, r)$B$N:G>.CM(B
def query(l,r):
    L = l + N0 # $B$J$s$G(BN0$B$rB-$7$F$$$k!D(B?
    R = r + N0
    s = INF
    while L < R:
        if R & 1:
            R -= 1
            s = max(s,data[R-1])
        if L & 1:
            s = max(s, data[L-1])
            L += 1
        L >>= 1; R >>= 1
    return s
# ---------------------------------------------------------------------------------
dp = [0] * (N+1)
#dp = [ [0] * (N+1) for _ in range(2*10**5+1)]

for i in range(1,N+1):
    dp[i] = max(query(0, H[i-1]), 0) + A[i-1]
    update(H[i-1], dp[i])
print(max(dp))



Measured memory_bytes: 123728
import numpy as np
K, N = map(int, input().split())
A = list(map(int, input().split()))
ans = 0
A = sorted(A)
new = []
for i in range(N-1):
    new.append(A[i+1]-A[i])
new.append(K + A[0] - A[-1])
new = sorted(new)
print(sum(new[:-1]))


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

//upper_bound, lower_boundを用いた
//のになぜか通らない・・・

int main(){
	int n;
	long long a;
	if(scanf("%d", &n)==EOF){return 0;}
	
	long long top[n];
	long long center[n];
	long long down[n];
	
	for(int i = 0; i<n; i++){if(scanf("%lld", &a)==EOF){return 0;} top[i] = a;}
	for(int i = 0; i<n; i++){if(scanf("%lld", &a)==EOF){return 0;} center[i] = a;}
	for(int i = 0; i<n; i++){if(scanf("%lld", &a)==EOF){return 0;} down[i] = a;}
	
	
	// top, downをソート
	sort(top, top+n);
	sort(down, down+n);
	//for(int i = 0; i<n; i++){cout << top[i] << ", "<<endl;}
	//for(int i = 0; i<n; i++){cout << down[i] << ", "<<endl;}
	
	long long sum = 0;
	//int ok1, ng1, ok2, ng2, mid;
	int ok1, ok2;

	for(int i = 0; i< n; i++){
		//center[i]より小さいtopの数を探す
		ok1 = lower_bound(top, top+n, center[i]) - top;
		ok2 = upper_bound(down, down+n, center[i]) - down;
		
		//cout << "top[ok1-1]" <<  top[ok1-1] << ", center:"<< center[i] <<", top[ok1]:"<< top[ok1] << endl;
		//cout << "down[ok2-1]:" << down[ok2-1] <<", center:"<< center[i] <<", down[ok2]:" << down[ok2] << endl;
		sum += (long long)ok1 * (long long)(n - ok2);
	}
	printf("%lld\n", sum);
	return 0;
}

Measured memory_bytes: 6096
#include <cstdio>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define all(a) (a).begin(), (a).end()

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

using ll = long long;
using namespace std;

template <typename T>
struct SegmentTree{
  using F = function<T(T,T)>;
  int n;
  F f;
  T ti;
  vector<T> dat;

  SegmentTree(){}
  SegmentTree(F f,T ti):f(f),ti(ti){}

  void init(int n_){
    n=1;
    while(n<n_) n<<=1;
    dat.assign(n<<1,ti);
  }

  void build(const vector<T> &v){
    int n_=v.size();
    init(n_);
    for(int i=0;i<n_;i++) dat[n+i]=v[i];
    for(int i=n-1;i;i--)
      dat[i]=f(dat[(i<<1)|0],dat[(i<<1)|1]);
  }

  void set_val(int k,T x){
    dat[k+=n]=x;
    while(k>>=1)
      dat[k]=f(dat[(k<<1)|0],dat[(k<<1)|1]);
  }

  T query(int a,int b){
    if(a>=b) return ti;
    T vl=ti,vr=ti;
    for(int l=a+n,r=b+n;l<r;l>>=1,r>>=1) {
      if(l&1) vl=f(vl,dat[l++]);
      if(r&1) vr=f(dat[--r],vr);
    }
    return f(vl,vr);
  }

  template<typename C>
  int find(int st,C &check,T &acc,int k,int l,int r){
    if(l+1==r){
      acc=f(acc,dat[k]);
      return check(acc)?k-n:-1;
    }
    int m=(l+r)>>1;
    if(m<=st) return find(st,check,acc,(k<<1)|1,m,r);
    if(st<=l&&!check(f(acc,dat[k]))){
      acc=f(acc,dat[k]);
      return -1;
    }
    int vl=find(st,check,acc,(k<<1)|0,l,m);
    if(~vl) return vl;
    return find(st,check,acc,(k<<1)|1,m,r);
  }

  template<typename C>
  int find(int st,C &check){
    T acc=ti;
    return find(st,check,acc,1,0,n);
  }
};

constexpr ll INF = 1ll<<60;

ll N, M;
std::string S;
ll dp[100010];
std::vector<ll> ans;
std::vector<ll> preV, pre;

int main()
{
  std::cin >> N >> M >> S;

  SegmentTree<ll> seg( []( ll a, ll b ){ return std::min(a,b); }, INF );

  seg.init( N+1 );

  rep( i, N+1 )
    dp[i] = INF;

  dp[N] = 0;
  seg.set_val( N, dp[N] );

  for( int i = N-1; i >= 0; --i )
  {
    if( S[i] == '0' )
    {
      ll mi = seg.query( i+1, std::min<ll>(i+1+M,N+1) );

      //printf( "(%d) %lld\n", i, mi );

      if( mi != INF )
        dp[i] = mi+1;

      seg.set_val( i, dp[i] );
    }
  }

  //rep( i, N+1 )
    //printf( "dp[%d] = %lld\n", i, dp[i] );

  if( dp[0] == INF )
  {
    puts("-1");

    return 0;
  }

  int p = 0;

  while( p < N )
  {
    int prv = p;

    while( dp[prv]-1 != dp[p] && p <= N )
      ++p;

    printf( "%d%c", p-prv, p==N?'\n':' ' );
  }
  
  return 0;
}

Measured memory_bytes: 3456
f :: (Int,Int)->IO ()
f (a,b) = do
    putStr $ show a
    putStr "x"
    putStr $ show b
    putStr "="
    putStr $ show $ a*b
    putStrLn ""
main = mapM_ f [(x,y)| x<-[1..9],y<-[1..9]]

Measured memory_bytes: 3856
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>

using namespace std;

#define ll long long int

#define SAY_YES cout << "Yes" << endl
#define SAY_NO cout << "No" << endl
#define say(s) cout << s << endl
#define rep(i, n) for(int i=0; i<(int)(n); i++)

#define vec vector

int main() {
  int N;
  cin >> N;
  map<string, int> m;
  rep(i, N) {
    string s;
    cin >> s;
    m[s] += 1;
  }

  int maxv = 0;
  for(auto it = m.begin(); it != m.end(); it++) {
    int v = it->second;
    maxv = max(maxv, v);
  }
  for(auto it = m.begin(); it != m.end(); it++) {
    int v = it->second;
    if (v == maxv) {
      say(it->first);
    }
  }

  return 0;
}


Measured memory_bytes: 17664
arg    = gets.chomp
first  = arg[0.. 1].to_i
second = arg[2..3].to_i

if 1 <= first && first <= 12 then
  if 1 <= second && second <= 12 then
    print "AMBIGUOUS"
  else
    print "MMYY"
  end
else
  if 1 <= second && second <= 12 then
    print "YYMM"
  else
    print "NA"
  end
end

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

int main(){
	int n;
	cin >> n;
	string s,t;
	cin >> s >> t;
	int count = n;
	string ans = "";
	rep(i,n){
		if(s.substr(i,n-i) == t.substr(0,n-i)){
			ans = s.substr(0,i) + t;
			cout << ans.size() << endl;
			return 0;
		}
	}
	cout << 2*n << endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#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(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int x;
  cin >> x;
  if(x < 100) {
    puts("0");
    return 0;
  }
  int sub = x / 100;
  int sub2 = x % 100;
  for(int i = 5; i > 0; i--) {
    sub -= sub2 / i;
    sub2 = sub2 % i;
    if(sub < 0) {
      puts("0");
      break;
    }
  }
  if(sub >= 0) puts("1");
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <set>
#include <vector>
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;

long long cost[100202];
const long long INF=1LL<<60;
int h[100202];
int N,K;
void dfs(int i){
if(i==N)return;
for(int j=1;j<=K;j++){
cost[i+j]=min(cost[i+j],cost[i]+abs(h[i+j]-h[i]));
}
dfs(i+1);
return;
}


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


rep(i,N){
cin >> h[i];
cost[i]=INF;
}

cost[0]=0;

// sort(array.begin(),array.end(),greater<long double>());

dfs(0);

cout << cost[N-1];

return 0;
}

Measured memory_bytes: 1408
import java.io.*;


class Main {
	
    public static void main(String[] args) {
        BufferedReader kb = new BufferedReader( new InputStreamReader( System.in ) );
        try {
            int n = Integer.parseInt( kb.readLine() );
			int[] A = new int[n];
            int i, j;
                        
            for( i=0; i<n; i++ ) {
            	A[i] = Integer.parseInt( kb.readLine() );
            }
			
			shellSort( A, n );
			
			StringBuilder output = new StringBuilder( n+1 );	
			output.append( A[0] );
            for( i=1; i<n; i++ ) {
            	output.append( "\n" );
               	output.append( A[i] );
            }
            System.out.println( output );

	 
            kb.close();
        } catch( IOException e ) {
            System.err.println( e );
        }        
    }
    static void shellSort( int[] A, int n ) 
    {
        int i, j;
        
        int cnt = 0;
        int m = 1;
        int mcnt;
        int[] G = new int[ 100+1 ];
        
		G[0] = 1;
        for( i=1; i<100; i++ ) {
        	G[i] = G[i-1]*3+1;
        	if( n < G[i] ) { 
        		m = i;
        		break;
        	}
        }
		StringBuilder output = new StringBuilder( 200 );
        output.append( m );
        output.append( "\n" );
        output.append( G[m-1] );
         for( i=m-2; 0<=i; i-- ) {
 	        output.append( " " );
	        output.append( G[i] );
	    }  
        System.out.println( output );
        
        for( i=0; i<m; i++ ) {
        	cnt += insertionSort( A, n, G[m-i-1] );
        }
        System.out.println( cnt );
        return;
    }    
    static int insertionSort( int[] A, int n, int g ) 
    {
    	int i, j;
    	int v;
		int cnt = 0;
   		for( i=g; i<n; i++ ) {
   			v = A[i];
   			j = i - g;
   			while( 0 <= j && v < A[j] ) {
   				A[ j+g ] = A[j];
   				j = j - g;
   				cnt++;
   			}
   			A[ j+g ] = v;
   		}
   		return cnt;
    }
}

Measured memory_bytes: 101964
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
using namespace std;
#define int long long
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
#define endl '\n'
typedef long long ll;
typedef pair<ll,ll> pll;
typedef long double ld;
const ll inf=1e9+7;
const ll mod=1e9+7;
vector<vector<ll> >G(100010);
vector<ll>d(100010,-1);
vector<bool>visited(100010);
set<pll>st;
ll dfs(ll i,ll p){
    visited[i]=1;
    ll cnt=0;
    for(auto e:G[i]){
        if(e==p)continue;
        if(visited[e]){
            if(st.find(mp(e,i))==st.end()&&st.find(mp(i,e))==st.end()){
                st.insert(mp(i,e));
                cnt++;
            }
            continue;
        }
        st.insert(mp(i,e));
        cnt+=dfs(e,i);
        cnt++;
    }
    ll k=0;
    if(cnt%2){
        st.erase(mp(p,i));
        st.insert(mp(i,p));
        cnt++;
        k++;
    }
    return k;
}
signed main(){
    ll n,m;cin>>n>>m;
    rep(i,m){
        ll a,b;cin>>a>>b;
        a--;b--;
        G[a].pb(b);
        G[b].pb(a);
    }
    if(m%2){
        cout<<-1<<endl;
        return 0;
    }
    dfs(0,-1);
    for(auto e:st){
        cout<<e.first+1<<' '<<e.second+1<<endl;
    }
}

Measured memory_bytes: 23296
#include <stdio.h>
#include <stdlib.h>
#define int long long

int ABS(int a){
	return a >= 0 ? a : -a;
}

int min(int a, int b){
	return a <= b ? a : b;
}

signed main(){
	int A, B, C, X, Y, a;
	scanf("%lld%lld%lld%lld%lld", &A, &B, &C, &X, &Y);
	if(X > Y){
		a = min(A * (X - Y) + 2 * C * Y, 2 * C * X);
	}
	else{
		a = min(B * (Y - X) + 2 * C * X, 2 * C * Y);
	}
	printf("%lld\n", min(A * X + B * Y, a));
	return 0;
}

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

#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define ll long long

int kyori(int a,int b){
	int x=0;
	x=(a-b)*(a-b);
	return x;
}

int main()
{
	int n; cin>>n;
	int g=0;
	vector<int> x(n);
	rep(i,n){
		cin>>x[i];
		g+=x[i];
	}
	g/=n;
	int ans[2]={0};
	rep(i,n){
		ans[0]+=kyori(g,x[i]);
		ans[1]+=kyori(g+1,x[i]);
	}
	cout<<min(ans[0],ans[1])<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>

using namespace std;

int main() {
  int h = 0;
  int a = 0;
  int n = 0;

  scanf("%d%d", &h, &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a);
    h = h-a;
    if (h <= 0) {
      printf("Yes");
      return 0;
    }
  }
  printf("No");

  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm> // next_permutation
#include <iomanip>
#include <cmath>
#include <vector>
#include <sstream>
#include <string>
#include <cstdio>
#include <stack>
#include <queue>
#include <list>
#include <numeric> //accumulate
//#include <unordered_map> //ハッシュ関数
#include <fstream> //ifstream, ofstream

//#define NDEBUG //NDEBUGが#include <cassert>より前に定義されている場合assertは無効になる。提出時はNDEBUGを定義しておいたほうがいいかも
#include <cassert> //assert


using namespace std;

//デバッグ時はTESTを定義する。本番時はこの行をコメントアウトする
#define TEST //*******************************************************************************************************************************************
//そうすることで、以下に定義する、デバッグ時にのみ標準出力する、doutコマンドが実現できる。本番時はダミーストリームに出力
//ただダミーストリームに出力する処理も結構CPU時間食うようなので、TLEを引き起こす原因になる可能性には注意                           ・・・もしかしてcerrを使ったほうがいいのかな？？？
#ifdef TEST
#define dout cout
#define din cin
#else
stringstream dummy; //デバッグ時のdoutコマンドのダミー出力先
#define dout dummy.str(""); dummy.clear(stringstream::goodbit); dummy //dummyを毎回リセットしておかないとメモリ溢れちゃう。
//どうせ表示しないからgoodbitしなくていいけど、表示する場合はこれしておかないとバグるらしいので、勉強のために。詳しくは http://d.hatena.ne.jp/linden/20060427/p1
#endif

//標準出力先をテキストファイルにしたい場合はOUTPUTFILEを定義する。本番時はこの行をコメントアウトする
//#define OUTPUTFILE "output.txt" //*******************************************************************************************************************************************
#ifdef OUTPUTFILE
#define dout outputfile //というのはTLE問題でどうせdoutを全部コメントアウトしなくちゃいけなくなるので上記方式は却下して、代わりに出力先を標準出力からファイルに切り替えできるようにする
ofstream outputfile(OUTPUTFILE);
#define OutputFilePath "/Users/Nag/Documents/Prgm/Test/DerivedData/Test/Build/Products/Debug/output.txt"
#endif

//標準入力元をテキストファイルにしたい場合はINPUTFROMTEXTFILEを定義する。本番時はこの行をコメントアウトする
//#define INPUTFILE "input.txt" //*******************************************************************************************************************************************
#ifdef INPUTFILE
#define din inputfile
ifstream inputfile(INPUTFILE);
#endif


#define disp(A) dout << #A << " = " << (A) << endl
#define disP(A) dout << setw(3) << (A) << " " // << setw(3) をたまに入れるかも
#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define dispAll(A,n) dout << #A << " = "; rep(j, 0, (n)) {disP(A[j]);} dout << endl

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


const int INF = 1e9-1;


int main() {
    int N; din >> N;
    int a, b;
    vector<pii> data;
    
    rep(i,0,N) {
        din >> a >> b;
        data.push_back(make_pair(a, b));
    }
    
    sort(data.begin(), data.end());
   
    
    
    dout << (data.end()-1)->first + (data.end()-1)->second << endl;
    
    
    
    
#ifdef INPUTFILE
    inputfile.close();
#endif
    
#ifdef OUTPUTFILE
    outputfile.close();
    cout << "\"" << OutputFilePath << "\"" << endl;
#endif
    
    return 0;
}

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

#define SUBMIT_MAX 2000

#define TEAM_MAX 50
#define PROBLEM_MAX 10

void score_sort(int score[TEAM_MAX][3], int T) {
    int temp[3];
    for(int i=0; i<T; i++) {
        for (int j=T-1; j>i; j--) {
            if (score[j-1][1] < score[j][1] ||
                (score[j-1][1] == score[j][1] && score[j-1][2] > score[j][2]) ||
                (score[j-1][1] == score[j][1] && score[j-1][2] == score[j][2] && score[j-1][0] < score[j][0])
                ) {
                temp[0] = score[j][0];
                temp[1] = score[j][1];
                temp[2] = score[j][2];
                score[j][0] = score[j-1][0];
                score[j][1] = score[j-1][1];
                score[j][2] = score[j-1][2];
                score[j-1][0] = temp[0];
                score[j-1][1] = temp[1];
                score[j-1][2] = temp[2];
            }
        }
    }
}

int main(void) {
    int M, T, P, R;
    int m[SUBMIT_MAX], t[SUBMIT_MAX], p[SUBMIT_MAX], j[SUBMIT_MAX];
    int score[TEAM_MAX][3];
    int accepted_flag[TEAM_MAX][PROBLEM_MAX];
    while (cin >> M >> T >> P >> R, M && T && P) {
        for(int i=0; i<T; i++) {
            score[i][0] = i+1;
            score[i][1] = 0;
            score[i][2] = 0;
            for(int j=0; j<P; j++) {
                accepted_flag[i][j] = 0;
            }
        }
        for(int i=0; i<R; i++) {
            cin >> m[i] >> t[i] >> p[i] >> j[i];
            if (i == R-1) {
                //cout << m[R-1] << " " << t[R-1] << " " << p[R-1] << " " << j[R-1] << endl;
            }
            t[i]--;
            p[i]--;
        }
        for(int i=0; i<R; i++) {
            if (j[i] == 0) {
                accepted_flag[t[i]][p[i]] = 1;
            }
        }
        for(int i=0; i<R; i++) {
            if (j[i] != 0 && accepted_flag[t[i]][p[i]]) {
                score[t[i]][2] += 20;
            }
            if (j[i] == 0) {
                score[t[i]][2] += m[i];
                score[t[i]][1] += 1;
            }
        }
        score_sort(score, T);
        for(int i=0; i<T; i++) {
            //cout << "[" << score[i][0] << " " << score[i][1] << " " << score[i][2] << "]" << endl;
        }
        for(int tmp1, tmp2, i=0; i<T; i++) {
            if (i!=0) {
                if (tmp1 == score[i][1] && tmp2 == score[i][2]) { cout << "="; } else { cout << ","; }
            }
            cout << score[i][0];
            tmp1 = score[i][1];
            tmp2 = score[i][2];
        }
        cout << endl;
        //sort(score, score + T, [](const int a[3], const int b[3]) { return a[0] > b[0];});
    }
    return 0;
}

Measured memory_bytes: 1192
#include<cstdio>
using namespace std;
typedef long long int ll;
static const double EPS = 1e-8;

int main(){
	double n, m, d;
	scanf("%lf %lf %lf", &n, &m, &d);
	if(d < EPS){
		printf("%.12lf\n", (m - 1.0) / n);
	}else{
		double num = 2.0 * (n - d) / (n * n);
      	printf("%.12lf\n", num * (m - 1.0));
	}
	return 0;
}


Measured memory_bytes: 128
//url:
//problem name: 

#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long long,long long>;
using veci = vector<int>;
using vecl = vector<long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;

int main() {
    int N; cin >> N;
    veci res(N);
    REP(i,N) cin >> res[i];
    int sum = 0;
    sort(res.begin(),res.end());
    reverse(res.begin(),res.end());
    REP(i,N) if(i != 0) sum += res[i];
    cout << (res[0]<sum ? "Yes":"No") << endl;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
using i64 = int_fast64_t;
#define rep(i, N) for(int (i) = 0; (i) < (N); (i)++)
#define all(v) (v).begin(), (v).end()
#define eb emplace_back

vector<int> Pfact(int N){
    vector<int> factor;
    int M = N;
    for(int i = 2; i*i <= M; i++){
        if(N % i == 0) factor.emplace_back(i);
        while(N % i == 0) N /= i;
    }
    if(N != 1) factor.emplace_back(N);
    return factor;
}

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

    auto factor = Pfact(N);

    int ans = 0;
    int bit_size = factor.size();
    for(int bit = 1; bit < (1 << bit_size); bit++){
        int pop_count = 0;
        int product = 1;
        for(int i = 0; i < bit_size; i++){
            if(bit & (1 << i)){
                pop_count++;
                product *= factor[i];
            }
        }

        if(pop_count & 1) ans += N / product;
        else ans -= N / product;
    }

    ans = N - ans;
    cout << ans << endl;
}


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

namespace AtCorder
{
	public class Program
	{
		static void Main(string[] args)
		{
			var cin = new Scanner2();
			int n = cin.Int();
			var to = new List<int>[n];
			for (int i = 0; i < n; i++) {
				to[i] = new List<int>();
			}

			for (int i = 0; i < n - 1; i++) {
				int a = cin.Int() - 1;
				int b = cin.Int() - 1;
				to[a].Add(b);
				to[b].Add(a);
			}

			var cs = cin.ArrayLong(n);
			Array.Sort(cs);
			Array.Reverse(cs);

			int[] d = new int[n];
			int index = 0;
			var q = new Queue<int>();
			q.Enqueue(0);
			while (q.Count > 0) {
				int target = q.Dequeue();
				d[target] = (int)cs[index];
				++index;
				foreach (int next in to[target]) {
					if (d[next] == 0) {
						q.Enqueue(next);
					}
				}
			}

			long m = cs.Sum() - cs[0];
			Console.WriteLine(m);
			string ans = string.Join(" ", d.Select(x => x.ToString()));
			Console.WriteLine(ans);
		}
	}


	public class Scanner2
	{
		private readonly char[] delimiter_ = new char[] { ' ' };
		private readonly string filePath_;
		private string[] buf_;
		private int index_;
		Func<string> reader_;

		public Scanner2(string file = "")
		{
			if (string.IsNullOrWhiteSpace(file)) {
				reader_ = Console.ReadLine;
			} else {
				filePath_ = file;
				var fs = new StreamReader(file);
				reader_ = fs.ReadLine;
			}
			buf_ = new string[0];
			index_ = 0;
		}

		public string Next()
		{
			if (index_ < buf_.Length) {
				return buf_[index_++];
			}

			string st = reader_();
			while (st == "") {
				st = reader_();
			}

			buf_ = st.Split(delimiter_, StringSplitOptions.RemoveEmptyEntries);
			if (buf_.Length == 0) {
				return Next();
			}

			index_ = 0;
			return buf_[index_++];
		}

		public int Int() => int.Parse(Next());
		public long Long() => long.Parse(Next());
		public double Double() => double.Parse(Next());

		public int[] ArrayInt(int N, int add = 0)
		{
			int[] Array = new int[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Int() + add;
			}
			return Array;
		}

		public long[] ArrayLong(int N, long add = 0)
		{
			long[] Array = new long[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Long() + add;
			}
			return Array;
		}

		public double[] ArrayDouble(int N, double add = 0)
		{
			double[] Array = new double[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Double() + add;
			}
			return Array;
		}

		public void Save(string text)
		{
			if (string.IsNullOrWhiteSpace(filePath_)) {
				return;
			}

			File.WriteAllText(filePath_ + "_output.txt", text);
		}
	}
}

Measured memory_bytes: 16736
#include <stdio.h>

int main(){
	int S;
	scanf("%d", &S);
	int a = S / 3600;
	int A = S % 3600;
	int b = A / 60;
	int B = A % 60;
	printf("%d:", a);
	printf("%d:", b);
	printf("%d\n",B );
	return 0;
}

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

int main() {
    int n;
    int taro = 0, hana = 0;
    string T,H;
    
    cin >> n;
    
    for(int i=0;i<n;i++){
        cin >> T >> H;
        
        if(T > H){
            taro += 3;
        }else if(H > T){
            hana += 3;
        }else{
            taro += 1;
            hana += 1;
        }
    }
    
    cout << taro << " " << hana << endl;
}


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

l = []

for i in range(-1, 102, 1):
    if i not in p:
        l.append(i)

ans = []

for i in l:
    ans.append(abs(X-i))

ind = ans.index(min(ans))

print(l[ind])


Measured memory_bytes: 9184
/**
 *  author: Behradm
 *  Created: 2020.07.25 16:19:18
 *  In The Name Of God
**/
#include <bits/stdc++.h>

using namespace std;

int main() {   
  ios::sync_with_stdio(false);
  cin.tie(0);
  int r, g, b;
  int k;
  cin >> r >> g >> b;
  cin >> k;
  int d = 0;
  while (g <= r) {
    g *= 2;
    d++;
  }
  while (b <= g) {
    b *= 2;
    d++;
  }
  cout << (d <= k ? "Yes" : "No") << '\n';
  return 0;
}


Measured memory_bytes: 3648
#include <iostream>
#include <fstream>
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <iomanip>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <sstream>
#include <string>
#include <vector>
using namespace std;

#pragma comment(linker, "/STACK:400000000")

#define EPS 1e-9
#define INF MOD
#define MOD 1000000007LL
#define fir first
#define foreach(it,X) for(it=X.begin();it!=X.end();it++)
#define iss istringstream
#define ite iterator
#define ll long long
#define mp make_pair
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<n;i++)
#define pi pair<int,int>
#define pb push_back
#define sec second
#define sst stringstream
#define sz size()
#define vc vector
typedef vc<int> vi;
typedef vc<ll> vl;
typedef vc<string> vs;

int N;
string mark[10010];
int used[10010],nex[10010];
map<string,int> M;
vi ans;

void read(int cur){
	if(used[cur])return;
	ans.pb(cur);
	used[cur]=1;
	if(nex[cur]!=-1)read(nex[cur]);
}

int main(){
	while(cin>>N && N){
		rep(i,N)cin>>mark[i];
		fill(used,used+10010,0);
		fill(nex,nex+10010,-1);
		M.clear();
		ans.clear();
		
		rep(i,N){
			if(mark[i]=="-"){
				read(i);
			}else if(mark[i]=="v"){
				nex[i+1]=i;
			}else{
				string type;
				int number=0;
				int x=0;
				while(islower(mark[i][x])){
					type+=mark[i][x];
					x++;
				}
				while(x<mark[i].sz && isdigit(mark[i][x])){
					number=number*10+mark[i][x]-'0';
					x++;
				}
				if(M.find(type)!=M.end()){
					nex[i]=M[type];
				}
				if(number>1)M[type]=i;
				else M.erase(type);
				if(x<mark[i].sz)nex[i+1]=i;
				else if(number==1)read(i);
			}
		}
		
		rep(i,N)cout<<ans[i]+1<<endl;
	}
}

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

#define BUF_SIZE 60
int main(void) {
  FILE *fp = stdin;
  char line[BUF_SIZE];
  if(!fgets(line, BUF_SIZE, fp)) return 0;

  long a, b, x;
  sscanf(line, "%ld %ld %ld", &a, &b, &x);
  long a_roundup = (a+x-1)/x;
  long b_rounddown = b/x;
  printf("%ld\n", b_rounddown - a_roundup+1);
  return 0;
}

Measured memory_bytes: 128
import java.util.*;

public class Main {
	static final long INF = 1000000000;
	
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		
		// GET INPUT
		int N = sc.nextInt();
		int M = sc.nextInt();
		int R = sc.nextInt();
		ArrayList<Long> rl = new ArrayList<Long>();
		for(int i=0; i<R; i++) {
			rl.add(sc.nextLong());
		}
		long[][] d = new long[N][N];
		for(int i=0; i<N; i++) {
			for(int j=0; j<N; j++) {
				d[i][j] = INF;
			}
		}
		for(int i=0; i<M; i++) {
			int A = sc.nextInt();
			int B = sc.nextInt();
			int C = sc.nextInt();
			d[A-1][B-1] = C;
			d[B-1][A-1] = C;
		}
		
		
		// GET INPUT END
		
		sc.close();
		
		// shori
		for(int k=0; k<N; k++) {
			for(int i=0; i<N; i++) {
				for(int j=0; j<N; j++) {
					if(d[i][j] > d[i][k] + d[k][j]) {
						d[i][j] = d[i][k] + d[k][j];
						d[j][i] = d[i][j];
					}
				}
			}
		}
		long min = INF;
		for(int i=0; i<1344000; i++) {
			long temp = 0;
			Collections.shuffle(rl);
			for(int j=0; j<rl.size()-1; j++) {
				temp += d[(int) (rl.get(j)-1)][(int) (rl.get(j+1)-1)];
			}
			if(temp < min) {
				min = temp;
			}
		}
		System.out.println(min);
		
	}

}

Measured memory_bytes: 48764
import random
import time

def down_score(d, c, last_d, score):
    sum = 0
    for i in range(26):
        sum = sum + c[i]*(d-last_d[i])
        
    return int(score - sum)


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

    c = list(map(int, input().split()))

    s = [list(map(int, input().split())) for i in range(D)]

    start = time.time()
    
    last_d = [0 for i in range(26)]
    
    ans = []
    
    score1 = 0
    
    for i in range(D):
        max = 0
        idx = 0
        for j in range(26):
            if max < (s[i][j] + c[j] * (i-last_d[j])*(i-last_d[j]+1)/2) and c[j] != 0:
                max = s[i][j] + c[j] * (i-last_d[j])*(i-last_d[j]+1)/2
                idx = j
            elif max == (s[i][j] + c[j] * (i-last_d[j])*(i-last_d[j]+1)/2) and c[j] * (i-last_d[j])*(i-last_d[j]+1)/2 > c[idx]* (i-last_d[idx])*(i-last_d[idx]+1)/2:
                idx = j
            
        last_d[idx] = i+1
        score1 += s[i][j]
        score1 = down_score(i+1,c,last_d,score1)
        
        ans.append(idx)


    while time.time() - start < 1.9:
        idx = random.randint(0,25)
        d = random.randint(0,D-1)
        if c[idx] == 0 or ans[d-1] == idx:
            continue
        tmp = ans[d]
        ans[d] = idx
        last_d = [0 for i in range(26)]
        score2 = 0    
        for i in range(D):
            score2 += s[i][ans[i]-1]
            last_d[ans[i]-1] = i+1
            score2 = down_score(i+1, c, last_d, score2)
        
        if score1 > score2:
            ans[d] = tmp
    
    for i in range(D):
        print(ans[i]+1)  

if __name__ == "__main__":
    main()


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

public class Hello
{
    private const ulong MOD9 = 1000000007;

    public static void Main()
    {
        // var nq = Console.ReadLine().Split(' ');
        var n = int.Parse(Console.ReadLine());
        var s = new System.Text.StringBuilder(Console.ReadLine());
        var k = int.Parse(Console.ReadLine());

        var c = s[k - 1];

        for (int i = 0, count = s.Length; i < count; ++i)
        {
            if (s[i] != c)
                s[i] = '*';
        }

        Console.WriteLine(s);
    }
}


Measured memory_bytes: 13140
#include <stdio.h>
  
int  main() {
    int N;
    scanf("%d", &N);

    int C[502], S[502], F[502];
    for (int i = 0; i < N - 1; i++)
        scanf("%d %d %d", &C[i], &S[i], &F[i]);

    for (int i = 0; i < N; i++) {
        int t = 0;
        for (int j = i; j < N - 1; j++) {
            if (t < S[j])
                t = S[j];
            else if (t % F[j] > 0)
                t = t + F[j] - t % F[j];

            t += C[j];
        }
        printf("%d\n", t);
    }

    return 0;
}


Measured memory_bytes: 128
n, tmax = list(map(int, input().split()))
cmin = 10000

for i in range(0, n):
    c, t = list(map(int, input().split()))
    if t <= tmax:
        cmin = min(cmin, c)

if cmin == 10000:
    print('TLE')
else:
    print(cmin)

Measured memory_bytes: 3060