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

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repr(i, n) for(int i = (n-1); i >= 0; --i)

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

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

const int MAX = 200005;
const int INF = 1001001001;
const int MOD = 1000000007;

int main(){
    ll X, K, D;
    cin >> X >> K >> D;

    if (X < 0) X = -X;

    if (K < X / D) {
        cout << X - D * K << endl;
        return 0;
    }

    if (X % D == 0) {
        ll N = X / D;
        K -= N;
        if (K % 2 == 0) {
            cout << 0 << endl;
            return 0;
        } else {
            cout << D << endl;
            return 0;
        }
    } else {
        ll N = X / D;
        K -= N;
        if (K % 2 == 0) {
            cout << X % D << endl;
            return 0;
        } else {
            cout << D - X % D << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 3616
#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>
#define chmin(a, b) ((a)=min((a), (b)))
#define chmax(a, b) ((a)=max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

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

const ll MOD=1e9+7;
const ll INF=1e18;
const double pi=acos(-1);
const double eps=1e-10;

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

vector<vector<int>> g(100010);
vector<vector<int>> memo(100010, vector<int>(20, 0));

int func(int v, int d, int c){
    if(memo[v][d] != 0) return memo[v][d];
    else memo[v][d] = c;

    if(d == 0){
        return memo[v][d] = c;
    }

    func(v, d-1, c);

    for(auto nv:g[v]){
        func(nv, d-1, c);
    }
}

int main(){
    int n, m; cin>>n>>m;
    for(int i=0; i<m; i++){
        int a, b; cin>>a>>b;
        a--, b--;
        g[a].eb(b);
        g[b].eb(a);
    }

    int q; cin>>q;
    vector<int> v(q), d(q), c(q);
    for(int i=0; i<q; i++){
        cin>>v[i]>>d[i]>>c[i];
        v[i]--;
    }

    for(int i=q-1; i>=0; i--){
        func(v[i], d[i], c[i]);
    }

    for(int i=0; i<n; i++){
        cout << memo[i][0] << endl;
    }
}

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

int main()
{
    int a,b,c,d;
    while(~scanf("%d %d %d %d",&a,&b,&c,&d))
    {
        if(a*b>=c*d)
            printf("%d\n",a*b);
        else if(c*d>=a*b)
            printf("%d\n",c*d);
    }
}


Measured memory_bytes: 128
#include<stdio.h>

int main()
{
   int n, i, j, v;
   int minj;
   int c = 0;
   int flag = 1;
   int a[1000];

   scanf("%d", &n);
   
   for(i = 0; i < n; i++){
      scanf("%d", &a[i]);
   }
 
   for(i = 0; i <= n-1; i++){
	minj = i;
	for(j = i; j <= n-1; j++){
		if(a[j] < a[minj]){
			minj = j;
		}
	}
	
	if(a[i] > a[minj]){	
	   v = a[i];
	   a[i] = a[minj];
	   a[minj] = v;
	   c = c + 1;
	}
}

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

         if(i != n-1){
            printf(" ");
         } else if(i == n-1){
            printf("\n");
         }
      }
      
      printf("%d\n", c);

return 0;

}
 





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

using namespace std;

template<typename T>void read(T&x){x=0;int fl=1;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')
fl=-1;ch=getchar();}while(ch>='0'&&ch<='9'){x=(x<<1)+(x<<3)+ch-'0';ch=getchar();}x*=fl;}
template<typename T,typename...Args>inline void read(T&t,Args&...args){read(t);read(args...);}

typedef long long LL;
typedef pair<int, int> pii;
#define mp(x, y) make_pair(x, y)
#define pb(x) emplace_back(x)

int k;
queue<LL> q;

int main(){
	read(k);
	for(int i = 1; i <= 9; i++)	q.push(i);
	LL cur;
	while(k--){
		cur = q.front(); q.pop();
		if(cur % 10 != 0)
			q.push(cur * 10 + cur % 10 - 1);
		q.push(cur * 10 + cur % 10);
		if(cur % 10 != 9)
			q.push(cur * 10 + cur % 10 + 1);
	}
	printf("%lld\n", cur);
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  char c = '7';
  cin >> s;
  for(int i = 0; i < s.size(); i++) {
    if(s.at(i) == c) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 3600
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
#define rep(i,a,b) for (int i = (a); i < (b); i++)
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef complex<double> com;
const int mod = 1e9 + 7;
const int MOD = 998244353;
const int inf = 2e9;



int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n; cin >> n;
	vector<int> s(n);
	rep(i, 0, n) cin >> s[i];
	ll ans = 0;
	rep(i, 1, n) {
		int l = i, r = n - 1 - i;
		vector<ll> dp(n / i); dp[0] = 0;
		int idx = 1;
		while (l != r && l != r + i)
		{
			dp[idx] = dp[idx - 1] + s[l] + s[r];
			ans = max(ans, dp[idx]);
			idx++; l += i; r -= i;
			if (r <= 0 || r <= i) break;
		}
	}
	printf("%lld", ans);
	return 0;
}


Measured memory_bytes: 1408
#include<iostream>

using namespace std;

int main(){
    int N;
    string str1;
    int K;
    
    cin>>N>>str1>>K;
    for(int i = 0; i < N;i++){
        //置き換える
        if(str1.at(i) != str1.at(K-1)){
            cout<<"*";
        }
        //置き換えない
        else{
            cout<<str1.at(i);
        }
    }
    cout<<endl;
    return 0;
    }


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

using namespace std;

#define INF 1000000000
#define INFLL 0x3f3f3f3f3f3f3f3fLL 
#define EPS 10e-9
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define st first
#define nd second
#define sz(v) int(v.size())
#define all(X) (X).begin(), (X).end()
#define FOR(I, A, B) for(int I = A; I < B; I++)
#define RFOR(I, A, B) for(int I = A; I >= B; I--)

typedef long long ll;
typedef pair<int,int> ii;
typedef pair<int,ii> iii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<vii> vvii;
typedef vector<iii> viii;
typedef vector<ll> vll;

string s;
int d,n;

ll PD[100100][110][3];

ll pd(int i, int r, int up){
	if(i == n){
		return r != 0 ? 0 : 1;
	}
	int dig = s[i]-'0', lim = 10;
	ll &ans=PD[i][r][up];
	if(ans!=-1){
		return ans;
	}
	ans = 0;
	if(up){
		lim = dig;
		ans+=pd(i+1,(r+dig)%d, 1);
		ans%=MOD;
	}
	for(int j = 0; j < lim; j++){
		ans+=pd(i+1, (r+j)%d, 0);
		ans%=MOD;
	}
	return ans;
}

int main(){
	cin >> s;
	cin >> d;
	n = sz(s);
	memset(&PD, -1, sizeof PD);
	ll ans = pd(0, 0, 1);
	ans--;
	if(ans == -1){
		ans+=MOD;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 259072
#include<bits/stdc++.h>
using namespace std;
int main(){
	long long a,b,n;
	cin>>n>>a>>b;
	if(a<b)swap(a,b);
	if((a-b)%2==0){
		cout<<(a-b)/2;
		return 0;
	}
	cout<<min((a+b-1)/2,(n-a+n-b+1)/2);
} 

Measured memory_bytes: 256
#include <stdio.h>
int a, b, c;
int d = 0;
int main()
{
    scanf("%d %d %d", &a, &b, &c);
   for(a;a<=b;a++){
       if(c%a==0){
           d++;
       }
   }
   printf("%d\n",d);
}


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

int F[102][102];
int xg, yg;

bool DFS(int Y, int X, int C)
{
  if(F[Y][X]!=C)
    return false;
  else if(Y == yg && X == xg)
    return true;

  F[Y][X] = 0;

  bool tmp = 0;
  tmp += DFS(Y-1, X, C);
  tmp += DFS(Y+1, X, C);
  tmp += DFS(Y, X-1, C);
  tmp += DFS(Y, X+1, C);
  return tmp;
}

int main()
{
  while(1){
    F[102][102] = {};

    int w=0, h=0;
    cin >> w >> h;

    if(w == 0 && h == 0)
      return 0;

    int xs, ys;
    cin >> xs >> ys;

    cin >> xg >> yg;

    int n;
    cin >> n;

    int c, d, x, y;
    for(int i=0; i<n; i++){
      cin >> c >> d >> x >> y;
      if(d == 0)
        for(int j=0; j<2; j++)
          for(int k=0; k<4; k++)
            F[y+j][x+k] = c;
      else
        for(int j=0; j<4; j++)
          for(int k=0; k<2; k++)
            F[y+j][x+k] = c;
    }

    bool res = DFS(ys, xs, F[ys][xs]);

    if(res)
      cout << "OK" << endl;
    else
      cout << "NG" << endl;
  }
}



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

using ll = long long;
#define double long double
#define rep(i, n) for (long long i = 0; i < (n); ++i)
#define repr(i, a, b) for (auto i = (a); i < (b); ++i)
#define itr(x, c) for (auto&& x : (c))
#define updatemax(t, v) ((t) = std::max((t), (v)))
#define updatemin(t, v) ((t) = std::min((t), (v)))
#define endl _endl
const char _endl = (cin.tie(0), cout.tie(0), ios::sync_with_stdio(0), cout.precision(16), '\n');

int main() {
  ll H, W, m;
  cin >> H >> W >> m;
  vector<ll> h(m), w(m), hs(H), ws(W);
  rep(i, m) {
    cin >> h[i] >> w[i];
    --h[i];
    --w[i];
    ++hs[h[i]];
    ++ws[w[i]];
  }
  using pll = pair<ll, ll>;
  set<pll> s;
  rep(i, m) s.emplace(h[i], w[i]);
  ll hsmax = -1, wsmax = -1;
  itr(x, hs) updatemax(hsmax, x);
  itr(x, ws) updatemax(wsmax, x);
  vector<ll> hsmaxi, wsmaxi;
  rep(i, H) if (hs[i] == hsmax) hsmaxi.push_back(i);
  rep(i, W) if (ws[i] == wsmax) wsmaxi.push_back(i);
  ll ans = hsmax + wsmax;
  if (hsmaxi.size() * wsmaxi.size() <= m) {
    itr(hi, hsmaxi) itr(wi, wsmaxi) {
      if (s.find(pll(hi, wi)) == s.end()) goto end;
    }
    --ans;
  }
end:
  cout << ans << endl;
}


Measured memory_bytes: 39708
#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	long long n, a, b, ans;
  	cin >> n >> a >> b;
  	if((b - a)%2==0){
  		ans = (b-a)/2;
	}else{
		ans = min(((b-a-1)/2)+a, ((b-a-1)/2)+n-b+1);
	}
	
	cout << ans <<endl;
}



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

#define                           int                         long long
#define                           fi                          first
#define                           si                          second
#define                           mp                          make_pair
#define                           pb                          push_back
#define                           pi                          pair<int,int>
#define                           f(i,l,r)                    for(int i=l;i<=r;i++)
#define                           rf(i,r,l)                   for(int i=r;i>=l;i--)
#define                           done(i)                     cout<<"done = "<<i<<endl;
#define                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);




using namespace std;

const int inf=1e18;
const int mod=1e9+7;
const int M=100009;

inline int bigmod(int B,int P){int R=1;while(P>0){if(P&1){R=(R*B)%mod;}P>>=1;B=(B*B)%mod;}return R;}
inline int ad(int x,int y){int ret=(x%mod+y%mod)%mod;if(ret<0){ret+=mod,ret=ret%mod;}return ret;}
inline int sub(int x,int y){int ret=((x%mod)-(y%mod)+mod)%mod;if(ret<0){ret+=mod,ret=ret%mod;}return ret;}
inline int gun(int x,int y){int ret=((x%mod)*(y%mod))%mod;if(ret<0){ret+=mod,ret=ret%mod;}return ret;}


 main()

{
    fast
    int k;
    cin>>k;
    string s;
    cin>>s;
    if(s.size()<=k)
    {
        cout<<s<<endl;
        return 0;
    }
    s=s.substr(0,k);
    s+="...";
    cout<<s<<endl;
    return 0;

}





































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

int const N = (1 << 18) + 7;

struct Node
{
	int value;
	int weigh;
};

Node ar[N];
int dp[512][100001];

int solve(int vertex, int Limit)
{
	if (vertex < 512)
		return dp[vertex][Limit];

	if (Limit < ar[vertex].weigh)
		return solve(vertex / 2, Limit);
	return max(solve(vertex / 2, Limit), ar[vertex].value + solve(vertex / 2, Limit - ar[vertex].weigh));
}

int main()
{
	int n, q;
	int v, w;
	scanf("%d", &n);

	for (int i = 1; i <= n; ++i)
		scanf("%d %d", &ar[i].value, &ar[i].weigh);


	//Fill dp
	for (int i = 0; i <= 1e5; ++i)
	{
		if (i < ar[1].weigh) dp[1][i] = 0;
		else dp[1][i] = ar[1].value;
	}

	for (int i = 2; i <= min(511, n); ++i)
	{
		for (int j = 0; j <= 1e5; ++j)
		{
			if (j < ar[i].weigh) dp[i][j] = dp[i/2][j];
			else dp[i][j] = max(dp[i/2][j], ar[i].value + dp[i/2][j - ar[i].weigh]);
		}
	}


	scanf("%d", &q);
	for (int i = 1; i <= q; ++i)
	{
		scanf("%d %d", &v, &w);
		printf("%d\n", solve(v, w));
	}
	return 0;
}

Measured memory_bytes: 205464
import std.stdio;
import std.range;
import std.array;
import std.functional;
import std.algorithm;
import std.conv;
import std.container;
import std.math;
import std.numeric;
import std.string;

class Matrix {
    int[][] v;
    size_t y, x;
    this(size_t y, size_t x) {
        this.y = y;
        this.x = x;
        this.v = new int[][](y, x);
    }
    this(int[][] v) {
        this.y = v.length;
        this.x = v[0].length;
        this.v = new int[][y];
        foreach (i; 0 .. y) {
            this.v[i] = v[i].dup;
        }
    }
    Matrix map(int function(int) f) {
        foreach (i; 0 .. y) {
            foreach (j; 0 .. x) {
                v[i][j] = f(v[i][j]);
            }
        }
        return this;
    }
    Matrix opBinary(string op)(Matrix m) if (op == "*") {
        if (x != m.y) throw new Error("?");
        Matrix ret = new Matrix(y, m.x);
        foreach (i; 0 .. y) {
            foreach (j; 0 .. m.x) {
                foreach (k; 0 .. x) {
                    ret.v[i][j] += v[i][k] * m.v[k][j];
                }
            }
        }
        return ret;
    }
    Matrix opBinary(string op)(int M) if (op == "%") {
        Matrix ret = new Matrix(v);
        foreach (i; 0 .. y) {
            foreach (j; 0 .. x) {
                ret.v[i][j] %= M;
            }
        }
        return ret;
    }
    Matrix identity() {
        Matrix ret = new Matrix(y, x);
        foreach (i; 0 .. y) {
            ret.v[i][i] = 1;
        }
        return ret;
    }
    Matrix transpose() {
        //"transpose".writeln;
        Matrix ret = new Matrix(x, y);
        foreach (i; 0 .. y) {
            foreach (j; 0 .. x) {
                ret.v[j][i] = v[i][j];
            }
        }
        return ret;
    }
    override string toString() {
        return v.map!(l => l.map!(to!string).join(" ")).join("\n");
    }

    static Matrix modPow(Matrix m, int t, int M) {
        //writeln("Matrix.modPow ", t);
        if (t == 0) return m.identity;
        if (m.v.length != m.v[0].length) throw new Error("?");
        if (t == 1) return m;
        if (t % 2 == 0) return modPow((m * m) % M, t / 2, M); 
        return (modPow((m * m) % M, t / 2, M) * m) % M;
    }
}

void main() {
    int N, M, A, B, C, T;
    while (readf("%d %d %d %d %d %d\n", &N, &M, &A, &B, &C, &T), N || M || A || B || C || T) {
        Matrix S = new Matrix([readln.chomp.split(" ").map!(to!int).array]);
        Matrix m = new Matrix(N, N);
        foreach (i; 0 .. N) {
            if (i - 1 >= 0) m.v[i][i - 1] = A;
            m.v[i][i] = B;
            if (i + 1 < N) m.v[i][i + 1] = C;
        }
        writeln((Matrix.modPow(m, T, M) * (S.transpose) % M).transpose);
    }
}

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

int main() {
	int r,g,b;
	cin >> r >> g >> b;
	if((100*r + 10*g + b) % 4 == 0){
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
/****************************************************************
*	Author: huhao
*	Email: 826538400@qq.com
*	Create time: 2020-02-02 09:45:14
****************************************************************/
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#define fr(i,a,b) for(int i=(a),end_##i=(b);i<=end_##i;i++)
#define fd(i,a,b) for(int i=(a),end_##i=(b);i>=end_##i;i--)
int read()
{
	int r=0,t=1,c=getchar();
	while(c<'0'||c>'9')
	{
		t=c=='-'?-1:1;
		c=getchar();
	}
	while(c>='0'&&c<='9')
	{
		r=(r<<3)+(r<<1)+(c^48);
		c=getchar();
	}
	return r*t;
}
#define i64 long long
#include<map>
#define mp(a,b,c,d) std::make_pair(std::make_pair(a,b),std::make_pair(c,d))
const int N=20,M=666;
const i64 inf=1ll<<60;
i64 f[N][N][M][M];
i64 n,a[N];
std::map<std::pair<std::pair<int,int>,std::pair<i64,i64> >,i64> F;
i64 solve(int l,int r,i64 cl,i64 cr)
{
	if(l==r-1) return 0;
	if(cl<M&&cr<M){ if(f[l][r][cl][cr]!=-1) return f[l][r][cl][cr]; }
	else{ if(F.count(mp(l,r,cl,cr))) return F[mp(l,r,cl,cr)]; }
//	static int cnt; cnt++;
//	printf("%d %d %I64d %I64d  %d\n",l,r,cl,cr,cnt);
	i64 ans=inf;
	fr(i,l+1,r-1) ans=std::min(ans,solve(l,i,cl,cl+cr)+solve(i,r,cl+cr,cr)+(cl+cr)*a[i]);
	if(cl<M&&cr<M) return f[l][r][cl][cr]=ans;
	else return F[mp(l,r,cl,cr)]=ans;
}// 260717 status
int main()
{
	n=read();
	fr(i,1,n) fr(j,i,n) fr(k,0,M-1) fr(l,0,M-1) f[i][j][k][l]=-1;
	fr(i,1,n) a[i]=read();
	printf("%lld\n",solve(1,n,1,1)+a[1]+a[n]);
	return 0;
}

Measured memory_bytes: 630144
import numpy as np

n = int(input())
a = np.array(input().split(), dtype=int)

ans = 0
MOD = 10**9+7

k = max(a)
j = 0
while k:
    bits = (a>>j)&1
    one = np.count_nonzero(bits)
    ans += (one%MOD)*((n-one)%MOD)*pow(2,j,MOD)
    ans %= MOD
    j += 1
    k >>= 1

print(ans)

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

using namespace std;

#define mod 1000000007
#define sz(c)  (int) c.size()
#define all(c) c.begin(), c.end()
#define tr(container,it) for(__typeof(container.begin()) it = container.begin();it != container.end(); it++)
#define present(s,x) s.find(x) != s.end()
#define cpresent(c,x) find(all(c),x) != c.end()
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,a,b) for(int i=a; i<b;i++)
#define ini(n) scanf("%d",&n)
#define opn printf("\n")

 
#define TRACE
 
#ifdef TRACE
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;
 
#else
 
#define trace1(x)
#define trace2(x, y)
#define trace3(x, y, z)
#define trace4(a, b, c, d)    
#define trace5(a, b, c, d, e)
#define trace6(a, b, c, d, e, f)

#endif 

typedef pair<int,int> pi;
typedef vector<pi> vp;
typedef vector<vp> vvp;
typedef vector<int> vi;
typedef unsigned long long int ull;
typedef long long int ll;
typedef vector<ll> vl;
typedef vector< vi > vvi;
typedef priority_queue<int> pq;
typedef priority_queue<int, vi , greater<int> >minpq;
typedef priority_queue<pi,vp,greater<pi> > mpq;

int a[300002];
int b[300002];
int main(){
	ios_base::sync_with_stdio(false);cin.tie(NULL);
	int n;
	cin>>n;
	string s;
	cin>>s;
	
	repn(i,1,n+1){
		if(s[i-1] == 'E'){
			a[i] = a[i-1] + 1;
			b[i] = b[i-1];
 		}
 		else{
			a[i] = a[i-1] ;
			b[i] = b[i-1]+1;
		}
			
	}
	int ans = 1e8;
	for(int i=1; i <= n;i++){
		int tmp =0;
		tmp += (b[i-1] + a[n]-a[i]) ;
		ans = min(tmp,ans);
	}
	cout<<ans<<endl;
}

	

	



Measured memory_bytes: 2964
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); i++)
using ll = long long;
#define PQ priority_queue<vector<ll>,vector<vector<ll>>,greater<vector<ll>>>
const ll INF = 1e18;
const ll MAXS = 3000;
 
vector<vector<ll>> dijkstra(ll f,ll n,ll s,vector<vector<vector<ll>>>& edge){
    s=min(s,MAXS);
    vector<vector<ll>> confirm(n, vector<ll>(MAXS+1,false));
    vector<vector<ll>> mincost(n, vector<ll>(MAXS+1,INF));
    mincost[f][s]=0;
    PQ pq; pq.push({mincost[f][s],f,s});
  
    while(!pq.empty()){
        vector<ll> now=pq.top(); pq.pop();
 
        if(confirm[now[1]][now[2]]) continue;
         confirm[now[1]][now[2]]=true;
 
        vector<vector<ll>>& v=edge[now[1]];
        int l =v.size();
        rep(i, l){
            ll nextS=min(now[2]+v[i][1],MAXS);
            if(nextS<0) continue;
            if(mincost[v[i][0]][nextS] <= now[0]+v[i][2]) continue;
          
            mincost[v[i][0]][nextS] = now[0]+v[i][2];
            pq.push({mincost[v[i][0]][nextS], v[i][0], nextS});
        }
    }
    return mincost;
}
 
int main(){
    ll n,m,s; cin >> n >> m >> s;
 
    vector<vector<vector<ll>>> edge(n);
    rep(i, m){
        ll u, v, a, b;
        cin >> u >> v >> a >> b;
        u--, v--;
        edge[u].push_back({v,-a,b});
        edge[v].push_back({u,-a,b});
    }
    rep(i, n){
        ll c, d; cin >> c >> d;
        edge[i].push_back({i,c,d});
    }
    
  vector<vector<ll>> mincost = dijkstra(0, n, s, edge);
    
  rep(i, n){
    if(i == 0) continue; 
     cout << *min_element(mincost[i].begin(), mincost[i].end()) << endl;
  }

   return 0;
}

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


int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
 	
	long long n, k, x, y, ans = 0;
	cin >> n >> k >> x >> y;

	ans = min(n, k) *x;
	ans += max(0LL, n-k) * y;
	cout << ans << '\n';

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n, m;
	cin >> n >> m;
	vector<int> a(m);
	vector<int> b(m);
	vector<int> c(n + 1 , 0);

	for(int i = 0; i < m; i++) {
		cin >> a[i] >> b[i];
		if(a[i] == 1) {
			c[b[i]] = 1;
		}
	}
	int flag = 0;
	for(int i = 0; i < m; i++) {
		if((b[i] == n)&&(c[a[i]] == 1)) {
			flag++;
			break;
		}
	}
	if(flag) {
		cout << "POSSIBLE" << endl;
	} else {
		cout << "IMPOSSIBLE" << endl;
	}

	return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vs = vector<string>;
using vll = vector<long long>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
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 (b<a) {a=b; return 1;} return 0;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int h, w;
    cin >> h >> w;
    vvc a(h, vc(w));
    int cnt = 0;
    rep(i, h) rep(j, w) {
        cin >> a[i][j];
        if (a[i][j] == '#') cnt++;
    }
    if (cnt == h + w - 1) cout << "Possible" << endl;
    else cout << "Impossible" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> ii;
typedef vector<int> vi;

typedef long long ll;
#define rep(i,l,r) for(int i=l;i<=r;i++)
#define REP(i,l,r) for(int i=l;i>=r;i--)
#define fi first
#define se second
#define eb emplace_back
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

#define int ll
const int mod = 1e9+7 ;
const int mn = 100000;
int n,m,a,b;
int fft[(mn+mn-2+1)], fft_sz = 1;
int fact(const int& n){
	for(;n > fft_sz; ++fft_sz) fft[fft_sz+1] = (fft[fft_sz]*(fft_sz+1)) % mod;
	return fft[n];
}
int mul (const int& a, const int& b){
	return a * b %mod;
}
int mi(const int& a, const int& b){
	int ans = (a-b) % mod;
	return (ans < 0 ? ans + mod : ans);
}
int binpow(int a, int b){
	int res = 1;
	while(b){
		if (b & 1) res = mul(res,a);
		a = mul(a,a), b >>= 1;
	}
	return res;
}
int divide(const int& a, const int& b){
	assert(b > 0);
	return mul(a,binpow(b,mod-2)); 
}
int c(const int& a, const int& b){
	assert(b >= a);
	return divide(fact(b), mul(fact(a), fact(b-a)));
}
int path0(const int& n, const int& m){
	return c(n-1, n+m-2);
}
int path(const int& r, const int& c, const int& row, const int& col){
	return path0(row-r+1, col-c+1);
}

signed main() {
	fastio ;
	fft[0] = fft[1] = 1LL;
	cin >> n >> m >> a >> b;
	int ans = path0(n,m);
	for(int i = 0, r = n, c = b; i < a; ++i, --r){
		ans = mi(ans, mul(path(1,1 ,r,c), path(r,c+1, n,m)));
	}
	cout << (ans % mod) << endl;
}



Measured memory_bytes: 5204
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <stdlib.h>
#include <math.h>

int main(void)
{
	int a, b;
	int n, m;
	int i, j;
	int work;
	int l[100000], r[100000];
	int l_max = 1, r_min = 100000;
	
	scanf("%d%d", &n, &m);
	
	for(i = 0; i < m; i++) {
		scanf("%d%d", &l[i], &r[i]);
		if(l_max < l[i]) {
			l_max = l[i];
		}
		if(r_min > r[i]) {
			r_min = r[i];
		}
	}
	if(l_max > r_min) {
		printf("0\n");
	} else {
		printf("%d\n", r_min - l_max + 1);
	}
	
	return 0;
}

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

int main(){
    int a;
    cin >> a;
    vint A(a);
    rep(i,a) cin >> A[i];
    bool ok = true;
    int judge = A[0];
    for(int i = 1;i<a;i++){
        if(judge < A[i]) judge = A[i] -1;
        else if(judge > A[i]){
            ok = false;
            break;
        }
    }

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


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
string arr;
long long mod=1e9+7;
int dp[100001][30];
long long getsum(int ind,int sum){
	if(ind==arr.size()) return (sum%13==5?1:0);
	if(dp[ind][sum]!=-1) return dp[ind][sum];
	int limit=9;
	
	long long res=0;
	
	
		if(arr[ind]=='?'){
			for(int i=0;i<=limit;i++){
			res+=getsum(ind+1,(sum*10+i)%13);
			res%=mod;
			
		}
		}
		else res+=getsum(ind+1,(sum*10+(arr[ind]-'0'))%13), res%=mod;
	
	dp[ind][sum]=res;
	return res;
	
	
}
int main() {

    cin>>arr;
    memset(dp,-1,sizeof(dp));
    cout<<getsum(0,0)<<endl;

	return 0;
}

Measured memory_bytes: 23252
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef pair<ll, ll> LP;
typedef vector<int> vec;
typedef vector<string> svec;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-8;

void to_unique(vector<int> &v) {
	sort(v.begin(), v.end());
	v.erase(unique(v.begin(), v.end()), v.end());
}

int n; ld l;
void solve() {
	vector<P> v;
	int cur = 0;
	rep(i, n) {
		int s, t; cin >> s >> t;
		int u; cin >> u;
		v.push_back({ s - cur,0 });
		v.push_back({ t - s,u });
		cur = t;
	}
	v.push_back({ 86400 - cur,0 });
	ld le = 0, ri = 1000003;
	rep(aa, 100) {
		ld mid = (le + ri) / 2.0;
		ld s = l;
		bool f = true;
		rep(i, v.size()) {
			ld dif = mid - v[i].second;
			s += dif * v[i].first;
			if (s < 0) {
				f = false; break;
			}
			if (s > l)s = l;
		}
		ld memo = s;
		rep(i, v.size()) {
			ld dif = mid - v[i].second;
			s += dif * v[i].first;
			if (s < 0) {
				f = false; break;
			}
			if (s > l)s = l;
		}
		if (s < memo)f = false;
		if (f)ri = mid;
		else le = mid;
	}
	cout << ri << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(10);
	//init();
	while (cin >> n>>l, n) {
		solve();
	}
	//solve();
	//stop
	return 0;
}


Measured memory_bytes: 6476
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <string>
#include <map>
#include <cmath>
#include <cstring>

#define fi first
#define se second
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for (int i = 1; i < (n); ++i)
#define drep(i,n) for (int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define all(x) (x).begin(), (x).end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define pb push_back
#define sz(x) (int)(x).size()
#define PQ(T) priority_queue<T, v(T), greater<T> >

using namespace std;
typedef long long ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;

const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;

const int mod = 1000000007;

const ll SMX = 405;

ll dp[SMX][SMX];
int main() {
    int n; cin >> n;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    rep(i,SMX)rep(j,SMX) dp[i][j] = LINF;
    rep(i,n) dp[i][i] = 0;
    
    vector<ll> s(n+1, 0);
    rep(i,n) s[i+1] = s[i] + a[i];

    int sz = 1;
    while (sz < n) {
        rep(i,n) {
            if (i + sz >= n) break;
            rep(j,sz) {
                dp[i][i+sz] = min(dp[i][i+j]+dp[i+j+1][i+sz] + (s[i+j+1]-s[i]) + (s[i+sz+1]-s[i+j+1]), dp[i][i+sz]);
                //cout << "i: " << i << " j: " << (i+sz) << " : " << dp[i][i+sz] << endl;
            }

        }
        ++sz;
    }
    cout << dp[0][n-1] << endl;

    return 0;
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
#define ALL(A) (A).begin(),(A).end()
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)

const ll mod = 1e9+7;
const ll INF = 2*1e18;
const int inf = 1e9+7;

using namespace std;

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	cin >> s;
	int n = s.size();
	vector<int> cnt(3);
	for(int i=0;i<n;i++){
		if(s[i]=='a')cnt[0]++;
		else if(s[i]=='b')cnt[1]++;
		else cnt[2]++;
	}
	sort(ALL(cnt));
	if(cnt[2]-cnt[0] <2)cout << "YES" << endl;
	else cout << "NO" << endl;
}

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

typedef long long int Long;
typedef long double Double;
const int MAXN = 55;

int n, a[MAXN],
	mxP = -1, mxN = -1,
	isP = 0, isN = 0;
vector<pair<int, int>> v;

int main() {
	scanf("%d", &n);
	for(int i = 0; i < n; ++i) {
		scanf("%d", a + i);
		if(a[i] > 0) {
			isP = 1;
			if(mxP == -1) mxP = i;
			else if(a[i] > a[mxP]) mxP = i;
		} else if(a[i] < 0) {
			isN = 1;
			if(mxN == -1) mxN = i;
			else if(a[i] < a[mxN]) mxN = i;
		}
	}

	if(isP && isN) {
		if(a[mxP] > -a[mxN]) {
			for(int i = 0; i < n; ++i)
				if(i != mxP)
					v.emplace_back(mxP + 1, i + 1);
			for(int i = 0; i + 1 < n; ++i)
				v.emplace_back(i + 1, i + 2);
		} else {
			for(int i = 0; i < n; ++i)
				if(i != mxN)
					v.emplace_back(mxN + 1, i + 1);
			for(int i = n - 1; i > 0; --i)
				v.emplace_back(i + 1, i);
		}
	} else if(isP) {
		for(int i = 0; i + 1 < n; ++i)
			v.emplace_back(i + 1, i + 2);
	} else if(isN) {
		for(int i = n - 1; i > 0; --i)
			v.emplace_back(i + 1, i);
	}

	printf("%d\n", (int) v.size());
	for(auto &p : v)
		printf("%d %d\n", p.first, p.second);

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define forr(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define ALL(a) (a.begin()),(a.end())
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll, ll> LP;
const ll LINF = 1LL<<60;
const int INF = 1001001001;
const int MOD = 1000000007;

/* --------------------------------------------------- */


int main() {
    int n, x, y;
    cin >> n >> x >> y;
    x--; y--;
    
    vector<int> ans(n, 0);
    rep(i, n - 1) {
        forr(j, i + 1, n) {
            int l = min(abs(j - i), abs(x - i) + abs(y - j) + 1);
            l = min(l, abs(y - i) + abs(x - j) + 1);
            ans[l]++;
        }
    }
    rep(i, n) {
        if(i == 0) continue;
        cout << ans[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cstring>

using namespace std;

const int MAXM = 100010;
const int MAXN = 110;
const int INF  = 0x3f3f3f3f;

int n, m, c[MAXN], w[MAXN];
long long f[MAXM];

int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)
		scanf("%d%d",&c[i],&w[i]);
	memset(f, INF, sizeof(f));
	f[0] = 0;
	for(int i=1;i<=n;i++)
		for(int j=MAXM;j>=w[i];j--)
			f[j] = min(f[j], f[j-w[i]] + c[i]);
	for(int i=MAXM;i>=0;i--)
		if(f[i] && f[i] <= m){
			printf("%d\n",i);
			break;
		}
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define mod 1e9+7
#define cr7 ios_base::sync_with_stdio(false);cin.tie(NULL);
using namespace std;
typedef long long ll;
int main(){
	cr7
    string s;
    cin >> s;
    //int t=count(s.begin(),s.end(),'7');
	/*if(t!=0)
    	cout<<"YES\n";
    else
		cout<<"NO\n";*/
		bool flag=0;
		for(int i=0;i<3;i++)
		{
			if(s[i]=='7')
				{
					flag=1;break;
				}
			}
		if(flag==1)
			cout<<"Yes\n";
		else cout<<"No\n";			
    return 0;
}

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


int main()
{
    int N, sum;

    while(std::scanf("%d", &N) != EOF) {
        if (N > 36) std::printf("%d\n", 0);
        else {
            sum = 0;
            for (int i = 0; i <=9; i++) {
                if (i > N) break;
                for (int j = 0; j <= 9; j++) {
                    if (i + j > N) break;
                    for (int k = 0; k <= 9; k++) {
                        if (i + j + k > N) break;
                        for (int l = 0; l <= 9; l++) {
                            if (i + j + k + l > N) break;
                            if (i + j + k + l == N) sum++;
                        }
                    }
                }
            }
            std::printf("%d\n", sum);
        }
    }

    return 0;
}



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

using namespace std;

int sum[maxn << 2];
#define ls(x) (x << 1)
#define rs(x) (x << 1 | 1)

inline void up(int x){
	sum[x] = max(sum[ls(x)], sum[rs(x)]);
}

void modify(int x, int l, int r, int pos, int d){
	if(l == r){
		sum[x] = d;
		return;
	}
	int mid = l + r >> 1;
	if(mid >= pos) modify(ls(x), l, mid, pos, d);
	else modify(rs(x), mid + 1, r, pos, d);
	up(x);
}

int query(int x, int l, int r, int ll, int rr){
	if(ll <= l && r <= rr) return sum[x];
	int mid = l + r >> 1, ans = 0;
	if(mid >= ll) ans = max(ans, query(ls(x), l, mid, ll, rr));
	if(mid < rr) ans = max(ans, query(rs(x), mid + 1, r, ll, rr));
	return ans;
}

int n, k, m = 3e5;
int x, f[maxn];
int ans;

int main(){
	scanf("%d%d", &n, &k);
	for(int i = 1;i <= n;i++){
		scanf("%d", &x);
		modify(1, 1, m, x, query(1, 1, m, x - k, x + k) + 1);
	}
	printf("%d", sum[1]);
}

Measured memory_bytes: 7900
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << endl;
#define CFYN(n) cout << ( (n) ? "YES":"NO") << endl;
#define OUT(n) cout << (n) << endl;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;

int main(void)
{
    IOS
    while(true) {
        int h, w;
        cin >> h >> w;
        if (h == 0) break;
        string s(w,'#');
        string s2 = "#" + string(w-2,'.') + "#";
        cout << s << endl;
        REP(i,h-2) cout << s2 << endl;
        cout << s << endl;
        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 3136
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			int p = sc.nextInt();
			int q = sc.nextInt();
			int r = sc.nextInt();

			if (q <= p && r <= p) {
				System.out.println(q + r);
			} else if(p <= q && r <= q) {
				System.out.println(p + r);
			} else if(p <= r && q <= r) {
				System.out.println(p + q);
			}
		}
	}
}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for(int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

vector<pair<ll, int>> fac;
void PrimeFactorInit(ll x){ // 素因数と個数のペアを返す.
    if(x >= 2){
        for(ll i = 2; i <= x; i++){
            if(i * i > x)break;
            if(x % i == 0){
                int cnt = 0;
                while(x % i == 0){
                    cnt++;
                    x /= i;
                }
                pair<ll, int> p;
                p.first = i;
                p.second = cnt;
                fac.push_back(p);
            }
        }
        if(x > 1){
            pair<ll, int> p;
            p.first = x;
            p.second = 1;
            fac.push_back(p);
        }
    }
}

// ax + by = gcd(a, b) となるような (x, y) を求める
// a と b は互いに素として ax + by = 1 となる (x, y) を求める
long long extGCD(long long a, long long b, long long &x, long long &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    long long d = extGCD(b, a%b, y, x); // 再帰
    y -= a / b * x;
    return d;
}


// 負の数に対応した mod
inline long long mod(long long a, long long m) {
    return (a % m + m) % m;
}


// 逆元計算 (a と m が互いに素であることが必要)
long long modinv(long long a, long long m) {
    long long x, y;
    extGCD(a, m, x, y);
    return mod(x, m); // x % m だが、x が負かもしれないので
}

ll cnt[1001001] = {};

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

    ll a[n];
    rep(i,n)cin >> a[i];

    ll MOD = 1000000007;

    

    rep(i,n){
        fac.clear();
        PrimeFactorInit(a[i]);
        rep(j,fac.size()){
            cnt[fac[j].first] = max(cnt[fac[j].first], (ll)fac[j].second);
        }
    }

    ll ans = 0;

    ll mul = 1;
    rep(i,1001001){
        if(cnt[i] == 0)continue;
        rep(j,cnt[i]){
            mul = mul * i % MOD;
        }
    }

    rep(i,n){
        ans += mul * modinv(a[i], MOD) % MOD;
        ans %= MOD;
    }

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




Measured memory_bytes: 7392
N,M = map(int,input().split())
A = [list(map(int,input().split())) for _ in range(N)]
A.sort()
ans = 0
for i in range(len(A)):
    if A[i][1] >= M:
        ans += M*A[i][0]
        break
    ans += A[i][1]*A[i][0]
    M -= A[i][1]
print(ans)

Measured memory_bytes: 27356
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
int main()
{
  int n;cin >> n;
  vector<int> b(n-1);
  rep(i,n-1) cin >> b[i];
  int res = 0;
  rep(i,n-2){
    res += min(b[i] , b[i+1]);
  }
  res += b[0] + b[n-2];
  cout << res << "\n";
  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
int x[2000003],p[10003],n;
int main(){
	scanf("%d",&n);getchar_unlocked();
	for(int i = 0; i < n; i++){
		while(true){
			char c = getchar_unlocked();
			if('0' <= c && c <= '9'){
				x[i] = x[i] * 10 + (c - '0');
			}
			else{break;}
		}
		p[x[i]]++;
	}
	int c=0;
	for(int i=0;i<10001;i++){
		for(int j=0;j<p[i];j++){
			if(c)printf(" ");c++;
			printf("%d",i);
		}
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 10420
N = int(input())
ABC = [list(map(int, input().split())) for _ in range(N)]
dp = [[0] * 3 for i in range(N)]

# dp[i][0] := i日目に0をやった時で最大の幸福度
# 0: a, 1: b, 2: c
# dp[i][0] = max(dp[i - 1][1], dp[i - 1][2])

dp[0][0] = ABC[0][0]
dp[0][1] = ABC[0][1]
dp[0][2] = ABC[0][2]
for i in range(1, N):
    dp[i][0] = max(dp[i - 1][1], dp[i - 1][2]) + ABC[i][0]
    dp[i][1] = max(dp[i - 1][2], dp[i - 1][0]) + ABC[i][1]
    dp[i][2] = max(dp[i - 1][0], dp[i - 1][1]) + ABC[i][2]

# print('dp', dp)
ans = max(dp[-1])
print(ans)


Measured memory_bytes: 47280
#include <iostream>
#include <string>

using namespace std;

int main() {

  int n, m, k, p, a = 0;
  cin >> n >> k;
  for(int i = 1;i <= n;i++){
    cin >> m;
    if(m >= k){
      a++;
    }
  }
  cout << a;
  return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
using P = pair<int, int>;
#define chmin(i, j) i = min(i, j);
#define chmax(i, j) i = max(i, j);
int main() {
  int n, C;
  cin >> n >> C;
  vector<vector<int>> d(C, vector<int>(C));
  for(int i=0;i<C;i++) for(int j=0;j<C;j++) cin >> d[i][j];
  vector<vector<int>> c(n, vector<int>(n));
  for(int i=0;i<n;i++) for(int j=0;j<n;j++) {
    cin >> c[i][j];
    c[i][j]--;
  }
  vector<vector<int>> modColor(3, vector<int>(C));
  for(int i=0;i<n;i++) for(int j=0;j<n;j++) {
    int r = (i + j) % 3;
    modColor[r][c[i][j]]++;
  }
  vector<vector<long long>> cost(3, vector<long long>(C));
  for(int i=0;i<3;i++) {
    for(int j=0;j<C;j++) {
      long long total = 0;
      for(int k=0;k<C;k++) {
        total += d[k][j] * modColor[i][k];
      }
      cost[i][j] = total;
    }
  }
  long long ans = 100100100100100100;
  for(int i=0;i<C;i++) {
    for(int j=i+1;j<C;j++) {
      for(int k=j+1;k<C;k++) {
        vector<int> v({i, j, k});
        sort(v.begin(), v.end());
        do {
          chmin(ans, cost[0][v[0]] + cost[1][v[1]] + cost[2][v[2]]);
        } while(next_permutation(v.begin(), v.end()));
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 1280
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
void solve()
{
    ll M,N;
    cin>>N>>M;
    if(N==M){
        cout<<"Yes";return;
    }
    cout<<"No";return;
}
int main()
{
    solve();
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
         
typedef long long ll;
using namespace std;
        
#define F first
#define S second
#define sqr(x) x*x
#define pb push_back
#define mp make_pair
#define sz(x) ((int) (x).size())
#define all(x) (x).begin(), (x).end()
#define allr(x) (x).rbegin(), (x).rend()
#define repit(i, n) for(auto it = n.begin(); it != n.end(); ++it)
       
const ll mod=1000000007;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0);for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b){if(b==0)return a;else return gcd(b,a%b);}
int lcm(int a,int b){return abs(a*b)/gcd(a,b);}
     
int main(){ios_base::sync_with_stdio(0);cin.tie(0);
    string s1,s2,s3;
    cin >> s1 >> s2 >> s3;
    char c = 'a';
    while(true){
    if(c == 'a'){
        if(sz(s1) == 0){
            cout << "A";
            exit(0);
        }
        c = s1[0];
        s1.erase(0,1);
    }else if(c == 'b'){
        
        if(sz(s2) == 0){
            cout << "B";
            exit(0);
        }
        c = s2[0];
        s2.erase(0,1);
    }else{
        
        if(sz(s3) == 0){
            cout << "C";
            exit(0);
        }
        c = s3[0];
        s3.erase(0, 1); 
    }
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <unordered_map>
#include <map>
#include <algorithm>
#include <set>
#include <unordered_set>
#include <deque>
#include <cmath>
#include <stack>
#include <queue>
#include <string>
#include <iomanip>
#include <cstring>
#include <climits>
#include <cstdio>

#define nl '\n'

using namespace std;
 
int a;

int main(){

    set<int> s;

    for(int i = 0; i < 3; i++){
        cin >> a;
        s.insert(a);
    }

    if(s.size() == 2){
        cout << "Yes";
    } else{
        cout << "No";
    }


 

 
}
 
//g++ -std=c++14 comp.cpp -o b; ./b.exe
//g++ -std=c++14 comp.cpp && ./a.out

Measured memory_bytes: 256
cards = [[False for i in range(13)] for ii in range(4)]
sort_name = ["S", "H", "C", "D"]
n = int(input())
for i in range(n):
    sort , rank = input().split()
    if sort == "S":
        cards[0][int(rank)-1] = True
    elif sort == "H":
        cards[1][int(rank)-1] = True
    elif sort == "C":
        cards[2][int(rank)-1] = True
    else:
        cards[3][int(rank)-1] = True
for i in range(4):
    for ii in range(13):
        if not cards[i][ii]:
            print(sort_name[i], ii+1)


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

typedef long long LL;
int n,m;
LL ans;

LL calc(int l,int r){
	return 1LL*(l+r)*(r-l+1)/2;
}

void solve(){
	ans=0;
	if(m==0){
		printf("%lld\n",1LL*n*n);
		return;
	}
	int last;
	int val=n-m;
	for(int i=m+1;i<=n;i=last+1){
		last=n/(n/i);
		//div
		ans+=1LL*(n/i)*calc(i-m,last-m);
		//mod
		int r=val/(n/i);
		if(r<i)continue;
		r=min(r,last);
		ans+=1LL*(r-i+1)*(val+1)-1LL*(n/i)*calc(i,r);
	}
	printf("%lld\n",ans);
}

int main(){
		scanf("%d%d",&n,&m);
		solve();
	return 0;
}

Measured memory_bytes: 128
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <map>
#include <set>
using namespace std;

#define INF (1ll<<60)


long long M = 1000000007;


int main(int argc, char const *argv[]) {
    long long n,m;cin>>n>>m;
    vector<long long> w(n),v(n);
    for(int i=0;i<n;++i){
        cin>>w[i];
        cin>>v[i];
    }
    long long s = n*1000;
    vector<long long> dp(s+1,1ll<<62);
    dp[0] = 0;
    long long res = 0;
    for(int i=0;i<n;++i){
        for(long long k=s;k>0;--k){
            if(k-v[i]>-1&&dp[k-v[i]]!=1ll<<62){
                dp[k] = min(dp[k], dp[k-v[i]]+w[i]);
                if(dp[k]<=m)res = max(res,k);
            }
        }
    }
    cout<<res<<endl;
    return 0;
}

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

const long long inf = 1e9;

inline long long read(){
    char c=getchar();long long x=0,f=1;
    while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
    while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
    return x*f;
}

long long s, a, b;

int main()
{
    //freopen("C:/Users/MACHENIKE/Desktop/data.in","r",stdin);
    s = read();
    if (s <= inf) {printf("0 0 0 1 %lld 0", s); return 0;}
    a = floor(sqrt(s));
    if (a * a == s) {printf("0 0 %lld 0 0 %lld", a, a); return 0;}
    a++;
    b = a  * a - s;
    printf("0 0 %lld %lld 1 %lld", a, b, a);
    return 0;
}


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

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String[] info=sc.nextLine().split(" ");
		List<String> dic=new ArrayList<String>();
		while(sc.hasNextLine()){
			dic.add(sc.nextLine());
		}
		dic.stream().sorted().forEachOrdered(System.out::print);
		System.out.println();
	}
}

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

int m[52];
int b[52][52]; //boat
bool t[52][52]; //graph

int main(){
  int n, k, r;

  while(cin >> n >> k){
    for(int i = 0; i < k; i++){
      cin >> m[i];

      for(int j = 0; j < m[i]; j++){
        cin >> b[i][j];
      }
    }

    memset(t, 0, sizeof(t));
    cin >> r;

    for(int i = 0; i < r; i++){
      int p, q;
      cin >> p >> q;
      t[p][q] = t[q][p] = true;
    }

    int ans = 0;

    for(int i = 0; i < k; i++){
      for(int j = 0; j < m[i]; j++){
        int from = b[i][j];

        for(int k = 0; k < m[i]; k++){
          int to = b[i][k];

          if(t[from][to]){
            ans++;
            break;
          }
        }
      }
    }

    cout << ans << endl;
  }
}

Measured memory_bytes: 1172