akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <queue>
#include <cassert>
#include <iomanip>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const int iINF = 1001001001;
const long long llINF = 1LL << 60;
int main()
{
    int n, k; cin >> n >> k;
    vector<int> p(n), c(n);
    rep(i, n) cin >> p[i];
    rep(i, n) cin >> c[i];
    rep(i, n) p[i]--;
    ll ans = -llINF;
    rep(si, n) {
        int x = si;
        vector<int> s;
        ll tot = 0;
        while (1) {
            x = p[x];
            s.push_back(c[x]);
            tot += c[x];
            if (si == x) break;
        }
        int l = s.size();
        ll now = 0;
        rep(i, l) {
            now += s[i];
            if (i >= k) break;
            if (0 < tot) {
                ll e = (k - i - 1) / l;
                ans = max(ans, now + tot * e);
            }
            else ans = max(ans, now);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3696
/*
filename:4_D-Allocation.c
created on 19.9.2015 by charis
last edited on 19.9.2015 by charis
*/

#include<iostream>
using namespace std;

bool pack(int A[], int n, int k, int p){
	int B[k] ;
	for (int j=0; j<k; j++){
		B[j] = 0 ;
	}
	/*
	for(int i=0; i<n; i++){
		for (int j=0; j<k; j++){
			B[j] += A[i] ;
			if (B[j] > p) {		
				if (j+1 == k) return false ;	
				else B[j] -= A[i] ;
			}
			else break ;
		}
	}
	*/
	int j=0; 	
	for (int i=0; i<n; i++){
		B[j] += A[i] ;
		if (B[j] > p){
			if (j+1 == k) return false ;
			else {
				B[j] -= A[i] ;
				j++ ;
				B[j] += A[i] ;
			}
		}
	}
	return true ;
}

int main(){
	int n, k, p;
	cin >> n >> k ;
	int A[n], sum=0, Max=0;
	for(int j=0; j<n; j++){
		int x ;
		cin >> x ;
		sum += x;
		A[j]=x;
		if (x > Max) Max = x;
	}
	if (Max > (sum/k + 1) ) p = Max ; 
	else {
		if (sum%k == 0) p = sum/k ;
		else p = sum/k +1 ;
	}
	
	while(1){
		if( pack(A, n, k, p) ) {
			cout << p <<endl ;
			break ;
		}
		else p++;
	}
	
	return 0;
}

Measured memory_bytes: 1940
#include<iostream>
#include<set>
#include <bitset>
#include<queue>
#include<vector>
#include<map>
#include<stack>
#include <cstdio>
#include<algorithm>
#include <sstream>
#include<string>
#include<string.h>
#include <cmath>
#include <iomanip>
#include <string>
#include<list>
#include <limits>
#include <numeric>
#include <type_traits>
#define int long long
#define ll long long
#define mod  1000000007
#define MOD  1000000007
#define inf 1e17
#define rep(i,j,n) for(int i=j;i<n;i++)
#define P pair<int,int>
#define ps push_back
#define all(x) x.begin(),x.end()
double pi = 3.141592653589793;
using namespace std;
//ここから始めよう
int n,m;
vector<int>v[114514];
int dp[114514];
int dfs(int k){
    if(dp[k]>=0)return dp[k];
    int ret=0;
    for(auto e:v[k]){
        ret=max(dfs(e)+1,ret);
    }
    dp[k]=ret;
    return ret;
}
signed main(){
    cin>>n>>m;
    rep(i,0,m){
        int a,b;cin>>a>>b;
        v[a-1].ps(b-1);
    }
    rep(i,0,n)dp[i]=-1;
    int ans=-1;
    rep(i,0,n){
        ans=max(ans,dfs(i));
    }
    cout<<ans<<endl;return 0;
}

Measured memory_bytes: 8832
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<cstdio>
#include<set>
#include<map>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repn(i, n) for(int i = 1; i <= n; i++) 
#define lint long long
#define all(x) (x).begin(), (x).end()

inline void logger(){ cout << endl; }
template<typename A, typename... B>
void logger(const A& a, const B&... b){
    cout << a << " , ";
    logger(b...);
}

int main(){
    int N; string S; cin >> N >> S;
    string ans = "";
    rep(i, S.size()){
        char c = S[i]; char d;
        if ('Z' - c >= N) d = c + N;
        else d = c + N - 26;
        ans += d;
    }
    cout<<ans<<endl;
}

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

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

typedef long long ll;
using namespace std;
int mod = 1000000007;

int main(void){
    ll ans = 0;
    int N; cin >> N;
    rep(i, N){
        ll a; cin >> a;
        while(a % 2 == 0){
            a/=2;
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#include <math.h>
#include <time.h>
using namespace std;
const long long mod = 1000000007;
#define dump(x)                             \
    if (dbg) {                              \
        cout << #x << " = " << (x) << endl; \
    }
bool dbg = false;
long long gcd(long long a, long long b){
   if (a % b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a % b));
   }
}
long long lcm(long long a, long long b){
   return (a / gcd(a, b))* b;
}
//---------------------------------------------------------------------------------------------------
/*ここからいじる*/
//---------------------------------------------------------------------------------------------------

void solve(){
}
int main(){
    long long n;
    cin >> n;
    long long ans = n;
    for(long long i = 1; i < sqrt(n) + 1; i++){
        if(n % i == 0){
            ans = min(ans, max(i, n / i));
        }
    }
    int cnt = 0;
    while (ans > 0){
        ans /= 10;
        cnt++;
    }
    cout << cnt << endl;
    return 0;
}



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

#define ll long long

int main() {
	ll n;
	scanf ("%lld", &n);
	ll A[n + 1], B[n];
	for (int i = 0; i < n + 1; i++) {
		scanf ("%lld", A + i);
	}
	for (int i = 0; i < n; i++) {
		scanf ("%lld", B + i);
	}
	ll ans = 0, extra = 0;
	for (int i = 0; i < n; i++) {
		if (B[i] + extra >= A[i]) {
			extra = B[i] + extra - A[i];
			extra = min(extra, B[i]);
			ans += A[i];
		}
		else {
			ans += (B[i] + extra);
			extra = 0;
		}
	}
	if (extra > 0) {
		ans += min (extra, A[n]);
	}
	printf("%lld\n", ans);
	return 0;
}

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

template<typename T>
void mdisp(vector<vector<T> > &x) {
    for (int i = 0; i < x.size(); i++)
    {
        for (int j = 0; j < x[0].size(); j++)
            cout << x[i][j] << " ";
        cout << endl;
    }
}

int main()
{
    int r, c;
    cin >> r >> c;
    vector<vector<int> > a(r + 1, vector<int>(c + 1));
    int sum = 0;
    for(int i = 0 ; i < r ; i++)
        for(int j = 0 ; j < c ; j++) {
            cin >> a[i][j];
            sum += a[i][j];
        }
    
    for(int i = 0 ; i < r ; i++)
        for(int j = 0 ; j < c ; j++)
            a[i][c] += a[i][j];
    for (int j = 0; j < c; j++)
        for (int i = 0; i < r; i++)
            a[r][j] += a[i][j];
    a[r][c] = sum;
    for (int i = 0; i < a.size(); i++)
    {
        for (int j = 0; j < a[0].size(); j++) {
            cout << a[i][j];
            if(j < a[0].size() - 1)
                cout << " ";
        }

            cout << endl;
    }

    return 0;
}


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

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<string> vs;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vll = vector<vl>;
using vpll = vector<pll>;
struct Edge {
	ll to;
	ll cost;
};
using Graph = vector<vector<Edge>>;

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define ALL(a) (a).begin(), (a).end()
/***** define constant start *******/
const ll MOD = 1000000007;
const double PI = 2.0 * asin(1.0);
const ll INF = 1L<<60;
string abc = "abcdefghijklmnopqrstuvwxyz";
string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const ll MAX = 10000000;
/****** define constant end ********/
/****** define variable start ******/
ll n, m;
vl h;
vll G;
/******* define variable end *******/
int solve() {
	cin >> n >> m;
	h.resize(n);
	G.resize(n);
	REP(i, n){
		cin >> h[i];
	}
	REP(i, m){
		ll a, b;
		cin >> a >> b;
		G[a-1].push_back(b-1);
		G[b-1].push_back(a-1);
	}
	ll ans = 0;
	REP(v, n){
		ll count = 0;
		for(auto next_v : G[v]){
			if(h[v] <= h[next_v]) continue;
			count++;
		}
		if(count == G[v].size()){
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

int main() {
	//clock_t start = clock();
	cout << std::fixed << std::setprecision(10);
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int end_solve = solve();
	/*
	clock_t end = clock();
	const double time = static_cast<double>(end - start) / CLOCKS_PER_SEC *
	1000.0; printf("time %lf[ms]\n", time);
	*/

	return end_solve;
}


Measured memory_bytes: 9776
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<ii> vii;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define fr(be, en) for(int i = be; i <= en; i++) 
int main()
{
	ios_base::sync_with_stdio(false);
	cout.tie(NULL);
	cin.tie(NULL);
	int k;
	ll ans = 0;
	cin >> k;
	for(int i = 1; i <= k; i++)
	{
		for(int j = 1; j <= k; j++)
		{
			for(int l = 1; l <= k; l++)
			{
				int curr = __gcd(i, j);
				curr = __gcd(curr, l);
				ans += curr;
			}
		}
	}
	cout << ans;
}

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


#define FOR(i, start, end) for(uint64_t i=start; i<end; i++)
#define REP(i, n) FOR(i, 0, n)

// 最大公約数gcd
// 最小公倍数lcm=m*n/gcd
uint64_t gcd(uint64_t m, uint64_t n) {
  uint64_t temp;
  while (m % n != 0){
    temp = n;
    n = m % n;
    m = temp;
  }
  return n;
}

uint64_t lcm(uint64_t m, uint64_t n) {
  return (m*n)/gcd(m,n);
}

void comb(vector<vector <uint64_t> > &v){
  for(uint64_t i = 0;i <v.size(); i++){
    v[i][0]=1;
    v[i][i]=1;
  }
  for(uint64_t k = 1;k <v.size();k++){
    for(uint64_t j = 1;j<k;j++){
      v[k][j]=(v[k-1][j-1]+v[k-1][j]);
    }
  }
}

// 掛け算オーバーフロー判定
bool is_product_overflow(uint64_t a, uint64_t b) {

	uint64_t prod = a * b;
	
	return (prod / b != a);
}

//素因数分解
void primeFactorization(uint64_t a, list<uint64_t> &factors){ //素因数分解を出力するプログラム
  long i,sq;
  if(a%2==0){ //偶数の場合
    factors.push_back(2);
    primeFactorization(a/2,factors); //2で割った値で再帰
    return;
  }
  sq = sqrt(a);
  for(i=3;i<=sq;i+=2){ //3以上√a以下の奇数の場合
	if(a%i==0){
	  factors.push_back(i);
      primeFactorization(a/i,factors); //割れた値で再帰
      return;
	}
  }
  //偶数でも3以上√a以下の奇数の場合でも割り切れない場合
  if(a!=1){ //aが1でないなら、a自身は素数
    factors.push_back(a);
  }
}

// 円周率
// M_PI

// #include <iomanip> // setprecisionを使用するのに必要
// cout << std::fixed << std::setprecision(15) << y << endl;

// 昇順
// priority_queue<int, vector<int>, greater<int> > queue;

signed main() {
  int64_t n;
  
  while(true){
    cin >> n;
    if(n==0) break;
    int s[n];
    double avg = 0;
    for(int i=0;i<n;i++){
        cin >> s[i];
        avg += s[i];
    }
    avg /= (double)n;
    double stdDev = 0.0;
    for(int i=0;i<n;i++){
        stdDev += (avg-(double)s[i])*(avg-(double)s[i]);
    }
    stdDev /= (double)n;
    
    cout << fixed << setprecision(5) << sqrt(stdDev) << endl;
  }
 
  return 0;
}


Measured memory_bytes: 3224
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fi(i,a,b) for(ll i=a-1;i>=b;i--)
#define endl '\n'
#define spc " "
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define pi 3.14159265358979323
#define sz(a) (int)((a).size())
#define len(a) (int)(a.length())
#define FOR(i,j,k,l) for(ll i=j;i<k;i+=l)
#define CC(x) cout<<x<<endl


void Fast_IO() {
   ios::sync_with_stdio(0);
   cin.tie(0);
   #ifndef ONLINE_JUDGE
   freopen("input.in","r",stdin);
   freopen("output.out","w",stdout); 
   #endif
} 

int main(){
   Fast_IO();
   ll n;
   cin>>n;
   vector<ll>v;
   ll ans=0;
   f(i,0,n){
      ll x;
      cin>>x;
      v.pb(x);
   }
   f(i,0,n){
      if((i+1)%2!=0 && v[i]%2!=0) ans++;
   }
   CC(ans);
}



Measured memory_bytes: 3656
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
 
int64_t solve(char *begin, char *end);
 
int main(int argc, char const* argv[])
{
  char buf[32];
  char *next;
  int64_t N, Q;
  fgets(buf, sizeof(buf), stdin);
  N = strtol(buf, &next, 10);
  Q = strtol(next + 1, NULL, 10);
  // fprintf(stderr, "N = %ld, Q = %ld\n", N, Q);
  
  char *S = malloc((size_t)N + 1);
  fgets(S, N + 1, stdin);
  S[N] = '\0';
  // tolerate '\n'
  getchar();
 
  int64_t R[N];
  memset(R, 0, 8 * N);
  for (int i = 0; i < N - 1; i++) {
    R[i + 1] = R[i] + (((S[i] == 'A') && (S[i + 1] == 'C')) ? 1 : 0);
  }
 
  int64_t l, r, res;
 
  for (int i = 0; i < Q; i++) {
    memset(buf, 0, sizeof(buf));
    fgets(buf, sizeof(buf), stdin);
    l = strtol(buf, &next, 10);
    r = strtol(next + 1, NULL, 10);
    res = R[r - 1] - R[l - 1];
    printf("%lu\n", res);
  }
 
  /*
  for (int i = 0; i < Q; i++) {
    memset(buf, 0, sizeof(buf));
    fgets(buf, sizeof(buf), stdin);
    l = strtol(buf, &next, 10);
    r = strtol(next + 1, NULL, 10);
    res = solve(S + l - 1, S + r - 1);
    printf("%lu\n", res);
 
  }
  */
  free(S);
  return 0;
}
 
int64_t solve(char *begin, char *end) {
  int64_t res = 0;
  for (; begin < end; begin++) {
    if ((begin[0] == 'A') && (begin[1] == 'C')) {
      res++;
      begin++;
    }
  }
  return res;
}
 

Measured memory_bytes: 1664
/// sultanov

#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
     
#define x first
#define y second
#define pb push_back
#define sz(x) (int) x.size()
 
using namespace std;
using namespace __gnu_pbds;

template<typename T> 
using ordered_set = tree<T, null_type,   
less<T>, rb_tree_tag,
tree_order_statistics_node_update>;

using ll = long long;
using pii = pair<int, int>;                                   

const int MOD = 1e9 + 7;
const int INF32 = 1e9 + 1e2;

vector<bool> d(10, 0);

bool f(int x) {
    while (x) {
        if (d[x % 10])
            return false;
        x /= 10;
    }
    return true;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);                
    int n, k;
    cin >> n >> k;
    for (int x; k--;)
        cin >> x, d[x] = 1;
    while (!f(n)) 
        n++;
    cout << n;
    return false;                                                       
}

Measured memory_bytes: 256
from itertools import product

A = int(input())
B = int(input())
C = int(input())
X = int(input())

ans = 0

for a, b, c in product(range(A + 1), range(B + 1), range(C + 1)):
    if 500 * a + 100 * b + 50 * c == X:
        ans += 1

print(ans)


Measured memory_bytes: 3060
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;

int main()
{
	long long n;
	cin >> n;
	string s;
	cin >> s;
	string buf;
	buf.push_back(s[0]);
	for (long long i = 1; i < s.size(); i++)
	{
		if (s[i] != s[i - 1])
			buf.push_back(s[i]);
	}

	cout << buf.size() << endl;
}


Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main(){
	int X,Y;
	cin>>X>>Y;
	if((Y-2*X)%2==0 && (4*X-Y)%2==0){
		if(Y-2*X>=0 && 4*X-Y>=0){
			cout<<"Yes";
			return 0;
		}
	}
	cout<<"No";
	return 0;
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}


template<typename F>
struct FixPoint : F{
  FixPoint(F&& f):F(forward<F>(f)){}
  template<typename... Args>
  decltype(auto) operator()(Args&&... args) const{
    return F::operator()(*this,forward<Args>(args)...);
  }
};
template<typename F>
inline decltype(auto) MFP(F&& f){
  return FixPoint<F>{forward<F>(f)};
}

//INSERT ABOVE HERE
signed main(){
  int n;
  cin>>n;

  vector< vector<int> > G(n);
  for(int i=1;i<n;i++){
    int p,q;
    cin>>p>>q;
    p--;q--;
    G[p].emplace_back(q);
    G[q].emplace_back(p);
  }

  vector<int> dp1(n,0),dp2(n,0),dp3(n,0);
  int ans=0;
  MFP([&](auto dfs,int v,int p)->void{
        int sum=0;
        vector<int> vs,mx;
        for(int u:G[v]){
          if(u==p) continue;
          dfs(u,v);
          sum+=dp2[u];
          mx.emplace_back(dp1[u]);
          vs.emplace_back(dp1[u]-dp2[u]);
        }
        if(vs.empty()){
          dp1[v]=1;
          dp2[v]=1;
          dp3[v]=1;
          return;
        }
        while(vs.size()<2) vs.emplace_back(0);
        while(mx.size()<2) mx.emplace_back(0);
        sort(vs.rbegin(),vs.rend());
        sort(mx.rbegin(),mx.rend());

        // c1 -> v -> c2, not take v
        chmax(dp3[v],sum+vs[0]+vs[1]);
        chmax(dp3[v],mx[0]+mx[1]);

        for(int u:G[v]){
          if(u==p) continue;
          chmax(dp3[v],sum-dp2[u]+dp3[u]);
          chmax(ans,dp3[u]+1);
        }

        // c1 -> v, take v
        chmax(dp1[v],mx[0]+1);

        // c1 -> v, not take v
        chmax(dp1[v],sum+vs[0]);

        // not take v
        chmax(dp2[v],sum);

        // c1 -> v -> c2, take v
        chmax(ans,mx[0]+1+mx[1]);
        chmax(ans,dp1[v]);
        chmax(ans,dp2[v]);
        chmax(ans,dp3[v]);

        return;
        cout<<v;
        cout<<", dp1[v] = "<<dp1[v];
        cout<<", dp2[v] = "<<dp2[v];
        cout<<", dp3[v] = "<<dp3[v]<<endl;
      })(0,-1);

  cout<<ans<<endl;
  return 0;
}


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

int main() {
  long long n;
  int cnt=0,l;
  cin >> n;
  vector<int>a(1000010,0);

  for (int i = 2; i < 1000010; i++) {
    while (n % i == 0) {
      a.at(i)++;
      n = n/i;
    }
  }
  if (n >= 1000010) cnt++;
  for (int i = 0; i < 1000010; i++) {
    if (a.at(i) == 0) continue;
    else {
      l=1;
      while (a.at(i) >= 0) {
        a.at(i) -= l;
        cnt++;
        l++;
      }
      cnt--;
    }
  }
  cout << cnt << endl;
}



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

int main() {
  int N, K, R, S, P;
  cin >> N >> K >> R >> S >> P;
  string T;
  cin >> T;
  vector<bool> W(N);
  int ans = 0;
  rep(i, K) {
    if (T[i] == 'r')
      ans += P;
    else if (T[i] == 's')
      ans += R;
    else
      ans += S;
    W[i] = true;
  }
  for (int i = K; i < N; i++) {
    if (T[i - K] == T[i] && W[i - K]) {
      continue;
    } else {
      if (T[i] == 'r')
        ans += P;
      else if (T[i] == 's')
        ans += R;
      else
        ans += S;
      W[i] = true;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3796
N = int(input())
A = list(map(int, input().split()))
A.sort()
B = [0] * N
B[0] = A[0]
for i in range(1, N):
    B[i] = B[i - 1] + A[i]

ans = 1
for i in range(N - 2, -1, -1):
    if A[i + 1] <= 2 * B[i]:
        ans += 1
    else:
        break

print(ans)


Measured memory_bytes: 20376
#include <stdio.h>
#include <stdlib.h>

int L[500000], R[500000];
int num = 0;

void merge(int A[], int left, int mid, int right) {
	int i, j, k, n1, n2;
	n1 = mid - left;
	n2 = right - mid;
	
	for (i = 0; i < n1; i++) {
		L[i] = A[left + i];
	}
	for (i = 0; i < n2; i++) {
		R[i] = A[mid + i];
	}

	L[n1] = 1000000000;
	R[n2] = 1000000000;
	i = 0; 
	j = 0;

	for (k = left; k < right; k++) {
		num++;
		if (L[i] <= R[j]) {
			A[k] = L[i];
			i = i + 1;
		}
		else {
			A[k] = R[j];
			j = j + 1;
		}
	}
}

void mergeSort(int A[], int left, int right) {
	int mid;
	
	if ((left + 1) < right) {
		mid = (left + right) / 2;
		mergeSort(A, left, mid);
		mergeSort(A, mid, right);
		merge(A, left, mid, right);
	}
}

int main(void)
{
	int n, i;
	int a[550000];

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

	mergeSort(a, 0, n);

	for (i = 0; i < n; i++) {
		printf("%d", a[i]);

		if (i != (n - 1)) {
			putchar(' ');
		}
		else {
			putchar('\n');
		}
	}

	printf("%d\n", num);

	return 0;	
}



Measured memory_bytes: 5632
#include<stdio.h>
#define MOD 1000000007

int main(){
	long long n,k;
	scanf("%lld%lld",&n,&k);
	long long ans=0;
	for(;k<=n+1;k++){
		long long sita=k*(k-1)/2;
		long long ue=(n+n-k+1)*k/2;
		ans+=(ue-sita+1)%MOD;
	}
	printf("%lld",ans%MOD);
}

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

#define ll long long
#define rep(i,N) for(ll i=0; i<N; i++)
const int mx = 2e5;

int main(void){
  ll N;
  cin >> N;
  ll A[N];
  ll bitnum1[61], bitnum0[61];
  rep(i,61){
    bitnum1[i]=0;
    bitnum0[i]=0;
  }
  rep(i,N){
    cin >> A[i];
    rep(j,61){
      if((A[i] >> j)&1 == 1) bitnum1[j]++;
      else bitnum0[j]++;
    }
  }
  ll ans = 0;
  rep(i,61){
    ll point = pow(2,i);
    point %= 1000000007;
    point *= bitnum1[i];
    point %= 1000000007;
    point *= bitnum0[i];
    ans += point;
    ans %= 1000000007;
  }
  
  cout << ans;
  
  return 0;
}


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

int main(){
    ll n;cin>>n;
    vvi v(n,vi(n));
    int a=0;
    rep(i,n){
        string s;cin>>s;
        rep(j,n){
            if(s[j]=='#')v[i][j]++;
            else a++;
        }
    }
    if(a==0)dame(0);
    if(a==n*n)dame(-1);
    ll mi=inf;
    rep(i,n){
        ll res=0;
        bool b=false;
        rep(j,n)if(v[j][i])b=true;
        if(!b)res++;
        rep(j,n)if(!v[i][j])res++;
        chmin(mi,res);
    }
    ll ans=mi+n;
    rep(i,n){
        bool b=true;
        rep(j,n)if(!v[j][i])b=false;
        if(b)ans--;
    }
    out(ans);
}

Measured memory_bytes: 2176
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int n,k;
	cin>>n>>k;
	string s;
	cin>>s;
	int ans=0;
	int blockCount = 0;
	char last=0;
	for(int i=0;i<n;i++)
	{
		if (s[i] != last) {
			last = s[i];
			blockCount++;
		}
		if (s[i] == 'L' && i > 0 && s[i-1] == 'L') ans++;
		if (s[i] == 'R' && i < n-1 && s[i+1] == 'R') ans++;
	}
	int half = (blockCount-1)/2;
 
	if (k > half) {
		ans = n-1;
	} 
	else {
		ans += 2*k;
	}
 
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 512
/*
AizuOnline A1295
Title Cubist Artwork
*/
#include <stdio.h>
#define max(x,y) (((x)>(y))?(x):(y))

//Global data section
int w,d;
int hist[21];
int hist2[21];
//
main()
{
        int i,j,x,sum;

        while(EOF!=scanf("%d %d",&w,&d) && (w || d))
        {
                for(i=1;i<=20;i++)
                        hist[i]=hist2[i]=0;

                for(i=0;i<w;i++)
                {
                        scanf("%d",&x);
                        hist[x]++;
                }
                for(i=0;i<d;i++)
                {
                        scanf("%d",&x);
                        hist2[x]++;
                }
                 
                sum=0;
                for(i=1;i<=20;i++)
                        sum += (i*max(hist[i],hist2[i]));
                printf("%d\n",sum);
        }
return(0);
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
#define F first
#define S second
#define MP make_pair
#define pb push_back
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair< int, int > P;
typedef pair< LL, LL > LP;
typedef pair< int, P > iP;
typedef pair< P, P > PP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    string a, b;
    cin >> a;
    cin >> b;
    if( a[0] == b[2] && a[2] == b[0] && a[1] == b[1] ) cout << "YES";
    else cout << "NO";
    cout << endl;
    return 0;
}


Measured memory_bytes: 764
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author alireza_kaviani
 */

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;

#define all(x)                      (x).begin(),(x).end()
#define Sort(x)                     sort(all((x)))
#define X                           first
#define Y                           second
#define sep                         ' '
#define endl                        '\n'
#define SZ(x)                       ll(x.size())

ll poww(ll a, ll b, ll md) {
    return (!b ? 1 : (b & 1 ? a * poww(a * a % md, b / 2, md) % md : poww(a * a % md, b / 2, md) % md));
}

const ll MAXN = 3e3 + 10;
const ll LOG = 22;
const ll INF = 8e18;
const ll MOD = 998244353; // 998244353; // 1e9 + 9;

ll n , s , ans , A[MAXN] , dp[MAXN][MAXN];

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

    cin >> n >> s;
    for(ll i = 1 ; i <= n ; i++)    cin >> A[i];

    for(ll i = 1 ; i <= n ; i++){
        for(ll j = 0 ; j < MAXN ; j++)  dp[i][j] = dp[i - 1][j];
        dp[i][A[i]] = (dp[i][A[i]] + i) % MOD;
        for(ll j = A[i] ; j < MAXN ; j++)   dp[i][j] = (dp[i][j] + dp[i - 1][j - A[i]]) % MOD;
        //cout << i << sep << dp[i][s] << endl;
        ans += ((dp[i][s] - dp[i - 1][s] + MOD) * (n - i + 1)) % MOD;
    }
    cout << ans % MOD << endl;

    return 0;
}
/*

*/


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

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int i, n, bc = 0, bp, tp, tcnt = 1;
		n = sc.nextInt();
		int[] tcal = new int[n];
		bp = sc.nextInt();
		tp = sc.nextInt();
		bc = sc.nextInt();
		for(i = 0; i < n; i++) tcal[i] = sc.nextInt();
		int sump = bp; int sumc = bc;
		int best = sumc / sump;
		Arrays.sort(tcal);
		for(i = n-1; i >= 0; i--) {
			sumc += tcal[i];
			sump = bp + tp*tcnt;
			tcnt++;
			int dpc = sumc / sump;
			if(best < dpc) best = dpc; 
		}
		System.out.println(best);
	}
}

Measured memory_bytes: 18148
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Diagnostics;



namespace free
{
    class Program4
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int cnt = 0;
            for (int i = 0; i < n; i++)
            {
                int num = int.Parse(Console.ReadLine());

                if (IsPrime(num))
                {
                    cnt++;
                }
            }

            Console.WriteLine(cnt);
        }

        static bool IsPrime(int num)
        {
            int limit = (int)Math.Sqrt(num);
            if (num == 2) return true;
            if (num % 2 == 0) return false;
            for (int i = 3; i <= limit; i += 2)
            {
                if (num % i == 0) return false;
            }

            return true;
        }
    }



}


Measured memory_bytes: 15940
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
const int maxn=1e5+10;
const int inf=0x3f3f3f3f;
int n,m,num[maxn];
int main(){
	int i,j;
	while(scanf("%d%d",&n,&m)!=EOF){
		for(i=0;i<n;i++){
			scanf("%d",&num[i]);
		}
		int ans=inf;
		int l,r;
		for(i=0;i<=n-m;i++){
			l=num[i],r=num[i+m-1];
			if(l<=0){
				if(r<=0) ans=min(ans,-l);
				else ans=min(ans,min(-2*l+r,2*r-l));
			}
			else{
				ans=min(ans,r);
			}
		}
		printf("%d\n",ans);
	}
	return 0;
} 

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

int main(int argc, char *argv[]) {
  int n, k;
  std::cin >> n >> k;
  std::vector<int> h(n);
  for (int i = 0; i < n; ++i)
    std::cin >> h.at(i);

  std::sort(h.begin(), h.end());
  int d = h.at(k - 1) - h.at(0);
  int min = d;
  for (int i = k; i < n; ++i) {
    d = h.at(i) - h.at(i - k + 1);
    min = std::min(d, min);
  }
  std::cout << min << std::endl;
}


Measured memory_bytes: 640
from collections import defaultdict

n=int(input())
a= list(map(int, input().split()))
r=[0]*n
l=[0]*n

for i,x in enumerate(a):
    l[i]=i+x
    r[i]=i-x

d=defaultdict(int)
ans=0
for i in range(n):
    d[l[i]]+=1
    ans+=d[r[i]]
print(ans)

Measured memory_bytes: 141696
#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <set>
#include <utility>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>
#include <cstdio>
#include <map>

using namespace std;

using ll = long long;
using P = pair<ll,ll>;

#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define rrep(i,x) for(ll i = ((ll)(x) - 1); i >= 0; i--)

#define _upgrade ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define all(x) (x).begin(), (x).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

//ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
//ll lcm(ll x, ll y) {return x / gcd(x, y) * y;}

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

const ll mod = 1e9 + 7;
const ll IMF = 1LL << 60;
const double PI = 3.14159265358979323846;


// ****************************************CODE***************************************//





const int max_n = 110;
const int max_v = 100100;

int N;
ll W, weight[max_n], value[max_n];

ll dp[max_n][max_v];

int main(){
        cin >> N >> W;
        for(int i = 0; i < N; i++) cin >> weight[i] >> value[i];

        for(int i = 0; i < max_n; i++) for(int j = 0; j < max_v; j++) dp[i][j] = IMF;

        dp[0][0] = 0;

        for(int i = 0; i < N; i++){
                for(int sum_v = 0; sum_v < max_v; sum_v++){
                        if(sum_v - value[i] >= 0){
                                chmin(dp[i+1][sum_v], dp[i][sum_v-value[i]]+weight[i]);
                        }

                        chmin(dp[i+1][sum_v], dp[i][sum_v]);
                }
        }

        ll res = 0;
        for(int sum_v = 0; sum_v < max_v; sum_v++){
                if(dp[N][sum_v] <= W) res = sum_v;
        }

        cout << res << endl;
        return 0;
}














































Measured memory_bytes: 86272
#include <bits/stdc++.h>
#include <fstream>
#include <utility>
#include "unistd.h"
using namespace std;
 
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define pvec(v) rep(i,v.size()){cout << v[i] << " ";};cout<<endl;
#define pb push_back
#define pf push_front
#define mod 1e9+7
#define m_p make_pair
 
typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<int,int> pr;
typedef vector<pr> vpr;
typedef vector<vector<int>> vvi;
const double pi = acos(-1.0);
 
ll gcd(ll x, ll y) { return (y == 0) ? x : gcd(y, x % y); }
ll lcm(ll x, ll y) { return x * y / gcd(x, y); }

bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }
    return true;
}

int main()
{
    ll n,k;
    cin >> n >> k;
    cout << n-k+1 << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <map>
#include <queue>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long

int main() {
  int n;
  cin >> n;
  vector<ll>a(n);
  int zero = 0;
  rep(i, n) {
    cin >> a[i];
    if(a[i] == 0) {zero++;}
  }
  if(zero) {cout << 0 << endl;return 0;}
  ll prod = 1;
  rep(i, n) {
    if(a[i] <= 1000000000000000000/prod) {
      prod *= a[i];
    }
    else {
      cout << -1 << endl;
      return 0;
    }
  }
  cout << prod << endl;
}

Measured memory_bytes: 3988
S = input()
T = input()
ls = len(S)
lt = len(T)

ans = 10000
for i in range(ls - lt + 1):
    S1 = S[i: i+lt]
    same = 0
    for j in range(lt):
        if S1[j] == T[j]:
            same += 1
    ans = min(ans, lt-same)

print(ans)

Measured memory_bytes: 9052
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define SIZE 100005

int N;
int num_row[SIZE],num_col[SIZE];
int COL[SIZE],ROW[SIZE];

int main(){

	scanf("%d",&N);

	for(int i = 0; i < N; i++){

		num_row[i] = 0;
		num_col[i] = 0;
	}

	int row,col;

	bool FLG = true;

	for(int loop = 0; loop < N; loop++){

		scanf("%d %d",&row,&col);
		row--;
		col--;

		if(!FLG)continue;

		num_row[row]++;
		if(num_row[row] >= 2){

			FLG = false;
		}


		num_col[col]++;
		if(num_col[col] >= 2){

			FLG = false;
		}

		ROW[row] = col; //indexがrowで、値がどの列にあるか
		COL[col] = row; //indexがcolで、値がどの行にあるか
	}

	if(!FLG){

		printf("-1\n");
		return 0;
	}

	int ans = 0;

	for(int i = 0; i < N; i++){

		if(ROW[i] == i)continue;

		int k = ROW[i]; //i行目の石がk列にある
		int p = COL[i]; //i列目の石がp行目にある

		//p行目とi行目を交換する
		ROW[i] = i;
		COL[i] = i;

		ROW[p] = k;
		COL[k] = p;

		ans++;
	}

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

	return 0;
}



Measured memory_bytes: 4788
import scala.io.Source

object Main{
  def main(args: Array[String]){
    val line =
      for{
        in <- Source.stdin.getLines.toList
      } yield in.split(" ").map(_.toInt).toList

    boc(line.flatten)
  }

  def boc(a: List[Int])={
    if(a.sorted == a && a.distinct == a) println("Yes")
    else println("No")
  }
}

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

sys.setrecursionlimit(150000)

def gdp(n, dp, G):
    if dp[n]!=-1:
        return dp[n]

    if G[n]==[]:
        dp[n]=0
        return 0

    for i in G[n]:
        ll=gdp(i, dp, G)
        if dp[n]<ll+1:
            dp[n]=ll+1

    return dp[n]

def solve(N: int, M: int, x: "List[int]", y: "List[int]"):
    G=[[] for _ in range(N)]
    for i in range(M):
        G[x[i]-1].append(y[i]-1)

    dp=[-1]*N

    print(max(gdp(i, dp, G) for i in range(N)))

    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    x = [int()] * (M)  # type: "List[int]"
    y = [int()] * (M)  # type: "List[int]"
    for i in range(M):
        x[i] = int(next(tokens))
        y[i] = int(next(tokens))
    solve(N, M, x, y)

if __name__ == '__main__':
    main()


Measured memory_bytes: 131080
var n,t,a,h,ans,id,i:Longint;begin read(n,t,a);ans:=1000000000;t:=(t-a)*1000;for i:=1 to n do begin read(h);h:=t-h*6;if h<0 then h:=-h;if ans>h then begin ans:=h;id:=i;end;end;writeln(id)end.

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl "\n"
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define pb push_back
#define F first
#define S second
#define um map <ll,ll>
#define rep(i,z,n)  for(int i=z;i<n;i++)
#define repi(i,z,n) for(int i=z;i<=n;i++)
#define repn(i,z,n) for(int i=n-1;i>=z;i--)
#define vec vector<ll>
#define vecp vector<pair<ll,ll>>
#define pi (double)3.14159265358979323846
#define ld long double
#define all(z) z.begin(),z.end()

ll power(ll a, ll b, ll m) { ll ans = 1; a = a % m; if (a == 0) return 0; while (b) { if (b & 1) ans = (ans * a) % m; b /= 2; a = (a * a) % m; } return ans; }
ll modInverse(ll a, ll m) {return power(a, m - 2, m);}
ll binpow(ll a, ll b) {ll res = 1; while (b > 0) {if (b & 1)res = res * a; a = a * a; b >>= 1;} return res;}
ll binlog2(ll n) {ll logValue = -1; while (n) {logValue++; n >>= 1;} return logValue;}
void print(vec a) {rep(i, 0, a.size())cout << a[i] << " "; cout << endl;}
const ll mod = 1e9 + 7;
const ll N = 3e3 + 5;
const ll inf = 2e18;
string s, t;
ll dp[N][N];

ll recur(int i, int j) {
    if (i <= 0 || j <= 0)
        return 0;
    if (dp[i][j] != -1)
        return dp[i][j];
    if (s[i - 1] == t[j - 1])
        return dp[i][j] = 1 + recur(i - 1, j - 1);
    else return dp[i][j] = max(recur(i - 1, j), recur(i, j - 1));
}


void solve() {
    cin >> s >> t;
    int n, m;
    n = s.size();
    m = t.size();
    memset(dp, -1, sizeof(dp));
    recur(n, m);
    string ans;
    int i = n, j = m;
    while (i > 0 && j > 0) {
        if (s[i - 1] == t[j - 1]) {
            ans += s[i - 1];
            i--; j--;
        }
        else if (dp[i - 1][j] > dp[i][j - 1])
            i--;
        else
            j--;
    }

    reverse(all(ans));
    cout << ans << endl;
}





int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    speed;
    int test = 1;
    // cin >> test;
    while (test--) {
        // cout << "Case #" << t1 << ": ";
        solve();
    }
    return 0;
}

Measured memory_bytes: 74484
using System;

namespace ITP_1_D{
    class Program{
        static void Main(){
            string testString = Console.ReadLine();
            int time = int.Parse(testString);
            int hour = 0;
            int minute = 0;

            if (time >= 3600 ) {
                hour = time / 3600;
                time = time - hour*3600;
            }
            if (time >= 60){
                minute = time / 60;
                time = time - minute*60;
            }
            Console.WriteLine(hour+":"+minute+":"+time);
        }
    }
}

Measured memory_bytes: 9220
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb(x) push_back(x)
#define vi vector<int>
#define vs vector<string>
#define vll vector<long long>
#define vc vector<char>
#define vs vector<string>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define pil pair<int, long long>
#define pli pair<long long, int>
#define pcc pair<char, char>
#define pdd pair<double, double>
#define mll map<long long, long long>
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(), (v).end()
#define flsh fflush(stdout)
#define gcd __gcd
#define clr(x) memset(x, 0, sizeof(x))
#define mod 1000000007LL
#define INF 1000000000007
 

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;


void solve()
{
    ll k;
    cin>>k;
    string s;
    cin>>s;
    ll n=s.length();
    if(n<=k)
    {
        cout<<s<<"\n";
        return;
    }
    ll i;
    for(i=0;i<k;i++)
    {
        cout<<s[i];
    }
    cout<<"...\n";

}


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


if (fopen("input.txt","r" ))
  {
     freopen("input.txt", "r", stdin);
     freopen("output.txt", "w", stdout);
  }
cout<<setprecision(20);


ll t=1;


// cin>>t;


while(t--)
{
solve();
} 


return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h> 
#define int long long
#define quickie ios_base::sync_with_stdio(false); cin.tie(NULL);
#define rep(i, a, b) for(int i=a; i<b; i++)
#define rep1(i, a, b) for(int i=a; i<=b; i++)
#define repp(i, a, b) for(int i=b-1; i>=a; i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define bn begin()
#define en end()
#define SZ(x) ((int)(x).size())
#define db double
#define mi map<int, int>
#define vi vector<int>
#define qi queue<int>
#define MI(x) power(x, mod-2)
#define test int t; cin >> t;
#define mod 1000000007LL
#define pi 3.141592653589
using namespace std;

int power(int x, int y) ;
int gcd(int a, int b) ;

signed main() {
    quickie
    int a[5] ;
    rep(i, 0, 5) cin >> a[i] ;
    rep(i, 0, 5) {
        if(a[i] == 0) {
            cout << i +1 << "\n" ;
            return 0 ;
        }
    }

}

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

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


Measured memory_bytes: 3600
# https://atcoder.jp/contests/abc128/tasks/abc128_c

MOD = 2

N, M = gets.split.map(&:to_i)
bulbs_with_switches = []
M.times do
  bulbs_with_switches << gets.split.map(&:to_i)
end
ps = gets.split.map(&:to_i)

ans = 0
(0..(2 ** N - 1)).each do |i|
  on_off_list = format("%0#{N}d", i.to_s(2)).chars

  off_switch_ids = []
  on_off_list.each_with_index do |flg, idx|
    off_switch_ids << idx + 1 if flg == '0'
  end

  all_lighting = true
  bulbs_with_switches.each_with_index do |bulb_with_switches, idx|
    unless (bulb_with_switches[1..-1] - off_switch_ids).size % 2 == ps[idx]
      all_lighting = false
      break
    end
  end

  ans += 1 if all_lighting
end

puts ans


Measured memory_bytes: 3836
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define se second
typedef  pair< int , int > pii;
#define ms(x,y) memset(x,y,sizeof(x))
const int mxn = 1<<12;
int dp[mxn],n,m,x,y,k;

pii e[mxn];

void inti()
{
	for(int i = 0;i<=m;i++)e[i].fs = e[i].se = 0;
	ms(dp,0x3f);
}
int main()
{
	while(~scanf("%d%d",&n,&m))
	{
		inti();
		int num = (1<<n);
		for(int i = 1;i<=m;i++)
		{
			scanf("%d%d",&x,&y);
			e[i].fs = x;
			
			for(int j = 1;j<=y;j++)scanf("%d",&k),e[i].se |= (1<<(k-1));
		}
		dp[0] = 0;
		for(int i  =1;i<=m;i++)
		{
			for(int j = 0;j<num;j++)
			{
				dp[j | e[i].se] = min(dp[j | e[i].se], dp[j] + e[i].fs);
			}
		}
		if(dp[num-1] == 0x3f3f3f3f)printf("-1\n");
		else printf("%d\n",dp[num-1]);
	}
	return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;

#define all(a) (a).begin(), (a).end()

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

vector<ll> sum(410);
vector<vector<ll>> dp(410, vector<ll>(410));

ll solve(int l, int r){
    if(dp[l][r] != 0) return dp[l][r];
    if(r - l == 1) return 0;

    ll ans = INF;
    for(int i=l+1; i<r; i++){
        ll cost = sum[r] - sum[l];
        chmin(ans, solve(l, i) + solve(i, r) + cost);
    }

    return dp[l][r] = ans;
}

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

    int n; cin>>n;
    vector<int> a(n);
    for(int i=0; i<n; i++) cin>>a[i];

    for(int i=0; i<n; i++) sum[i+1] = sum[i] + a[i];

    cout << solve(0, n) << endl;

    return 0;
}

Measured memory_bytes: 1664
def knapSack(W, wt, val, n): 
    K = [[0 for x in range(W+1)] for x in range(n+1)] 
  
    # Build table K[][] in bottom up manner 
    for i in range(n+1): 
        for w in range(W+1): 
            if i==0 or w==0: 
                K[i][w] = 0
            elif wt[i-1] <= w: 
                K[i][w] = max(val[i-1] + K[i-1][w-wt[i-1]],  K[i-1][w]) 
            else: 
                K[i][w] = K[i-1][w] 
  
    return K[n][W] 
n,w=map(int,input().split())

wt = []
val = []

for i in range(n):
    wtt,vall=map(int,input().split())
    wt.append(wtt)
    val.append(vall)
ans = knapSack(w,wt,val,n)
print(ans)

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

int main() {
  int N, X; 
  cin >> N >> X;
  
  vector<int> D(N + 1);
  D[0] = 0;
  for (int i = 0; i < N; ++i) {
    int x; 
    cin >> x;
    D[i + 1] = D[i] + x;
  }
  
  int result = 0;
  for (int i = 0; i <= N; ++i) {
    if (D[i] <= X) {
    result++;
  }
}
  cout << result << endl;
}

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

vector<long long> dp(100, 0);

/*
long long lucas(long long n){
    if(n == 0) return 2;
    else if(n == 1) return 1;
    else return lucas(n-1) + lucas(n-2);
}
*/

void solve(long long N){
    for(long long i = 0; i <= N; ++i){
        if(i == 0) dp[i] = 2;
        else if(i == 1) dp[i] = 1;
        else dp[i] = dp[i-1] + dp[i-2];
    }
    cout << dp[N] << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    solve(N);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>

using namespace std;

int main(void) {
    int N, M , Q;
    cin >> N >> M >> Q;
    vector<int> L(M+1);
    vector<int> R(M+1);
    vector<int> p(Q+1);
    vector<int> q(Q+1);
    for(int i=0; i<M; i++) {
        cin >> L[i] >> R[i];
    }
    for(int j=0; j<Q; j++) {
        cin >> p[j] >> q[j];
    }

    int imos[N][N];
    for(int i=0;i<N; i++) {
        for(int j=0; j<N; j++) {
            imos[i][j] = 0;
        }
    }
    for(int i=0; i<M; i++) {
        imos[0][R[i]-1]++;
        imos[L[i]+1-1][R[i]-1]--;
    }
    for(int i=1;i<N; i++) {
        for(int j=0; j<N; j++) {
            imos[i][j] += imos[i-1][j];
        }
    }
    for(int i=0;i<N; i++) {
        for(int j=1; j<N; j++) {
            imos[i][j] += imos[i][j-1];
        }
    }

    for(int j=0; j<Q; j++) {
        cout << imos[p[j]-1][q[j]-1] << endl;
    }
    return 0;
}


Measured memory_bytes: 4224
//2018.09.21 25min giveup
//

#include <iostream>
using namespace std;


int main() {

    long n,m;
    cin >> n >> m;

    long ans=0;

    if(n>1&&m>1)ans = (n-2)*(m-2);
    else if(n==1 && m==1) ans = 1;
    else if(n>m) ans = n-2;
    else if(m>n) ans = m-2;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256