akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

static const ll INF = 1e18;

int main(){
  int N, X;
  cin >> N >> X;
  vector<int> v;
  rep(i,N){
    int a;
    cin >> a;
    v.push_back(a);
  }
  reverse(ALLOF(v));

  vector<ll> sum(N+1);
  sum[0] = 0;
  rep(i,N){
    sum[i+1] = sum[i] + v[i];
  }

  vector<ll> base;
  {
    ll cnt = 3;
    rep(i,N){
      base.push_back(cnt);
      cnt += 2;
    }
    base[0] = 5;
  }

  ll ret = INF;
  for(int i=1; i<=N; i++){
    ll tmp = (N+i) * (ll)X;
    double dtmp = 0;
    for(int j=0,k=0; j<N; j+=i,k++){
      ll a = sum[(j+i<N?j+i:N)] - sum[j];
      ll b = base[k];
      ll c = a * b;
      tmp += a * b;
      dtmp += a * (double)b;
    }
    if(dtmp > INF) tmp = INF;
    ret = min(ret, tmp);
  }

  cout << ret << endl;
  return 0;
}



Measured memory_bytes: 4724
#include<iostream>
using namespace std;
int main(){
    int n,m,l;
    long long A[100][100],B[100][100],C[100][100];
    cin >> n >> m >> l;
    for (int i = 0;i < n;i++)
        for (int j = 0;j < m;j++) cin >> A[i][j];
    for (int i = 0;i < m;i++)
        for (int j = 0;j < l;j++) cin >> B[i][j];
    for (int i = 0;i < n;i++){
        for (int j = 0;j < l;j++){
            C[i][j] = 0;
            for (int k = 0;k < m;k++){
                C[i][j] += A[i][k]*B[k][j];
            }
        }
    }
    for (int i = 0;i < n;i++){
        for (int j = 0;j < l;j++){
            if (j) cout << " ";
            cout << C[i][j];
        }
        cout << endl;
    }
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef long double ld;

const ll INF = 1e18;
const ll mod = 1e9+7;
const ll maxn = 1000 * 1001;

vector<ll> g[maxn] , he[maxn] , v;
ll h[maxn] , par[maxn];
ll mark[maxn] , d[maxn] , p[maxn];
ll n , m , k;

void dfs(ll u)
{
    he[h[u]].push_back(u);
    mark[u] = 1;
    for(ll i = 0; i < g[u].size(); i++)
        if(mark[g[u][i]] == 0)
        {
            par[g[u][i]] = u;
            h[g[u][i]] = h[u] + 1;
            dfs(g[u][i]);
        }
}

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

    cin>> n;
    for(ll i = 1; i < n; i++)
    {
        ll u , v;
        cin>> u >> v;
        g[v].push_back(u);
        g[u].push_back(v);
    }

    dfs(1);
    for(ll ii = n; ii >= 0; ii--)
        for(ll j = 0; j < he[ii].size(); j++)
        {
            ll v = he[ii][j];
            if(g[v].size() == 1 && v != 1)
            {
                d[v] = 1;
                p[v] = 1;
                continue;
            }
            d[v] = 1;
            p[v] = 1;
            for(ll i = 0; i < g[v].size(); i++)
                if(g[v][i] != par[v])
                {
                    ll u = g[v][i];
                    d[v] = (((d[u] + p[u]) % mod) * d[v]) % mod;
                    p[v] = (d[u] * p[v]) % mod;
                }
        }
    cout<< (d[1] + p[1]) % mod;
}










Measured memory_bytes: 69120
#include <iostream>
#include<vector>
using namespace std;
int main() {

  int N;cin>> N;
  
  vector <int> V(N);
  for(int i = 0; i < N; ++i) {
    cin  >> V[i];}
  
  vector <int> C(N);
  for(int i = 0; i < N; ++i) {
    cin  >> C[i];}
  int sum=0;
  for (int i=0;i<N;++i){

  	if (V[i]>C[i]){
		
		sum+=V[i]-C[i];}
 
 
    }

  
 cout<<sum<<endl;
  
	return 0;
}
  
   

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int size;
    cin >> size;
    char* box = new char[size];
    int* check = new int[size];
    int count = 0;
    cin >> box;

    for(int i=1;i<size;i++){
        if(box[i]!='W')
            count++;
    }
    int ret=count;
    if(box[0]=='W')
        count++;
    for(int i=1;i<size;i++){
        if(box[i]=='E')
            count--;
        if(ret>count)
            ret=count;
        if(box[i]=='W')
            count++;
    }
    cout << ret;
}

Measured memory_bytes: 512
HW = list(map(int, input().split()))
H = HW[0]
W = HW[1]
a = []
ans = []

for i in range(H):
  a.append(list(map(int, input().split())))
  
for i in range(H):
  for j in range(W):
    if a[i][j] % 2 == 1:
      if j+1 < W:
        a[i][j] -= 1
        a[i][j+1] += 1
        ans.append((i, j, i, j+1))
      elif i+1 < H:
        a[i][j] -= 1
        a[i+1][j] += 1
        ans.append((i, j, i+1, j))

print(len(ans))
for (y1, x1, y2, x2) in ans:
  print("%d %d %d %d" % (y1+1, x1+1, y2+1, x2+1))

Measured memory_bytes: 22416
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <cstring>
#include <algorithm>
#include <vector>
//#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <map>
#include <numeric>
using namespace std;
#define fin << '\n'
#define finl << '\n';
#define finn cout << '\n'
#define unless(flg) if(!(flg))
#define alles(obj) obj.begin(), obj.end()
// bashise
#define elif else if
#define echo cout <<
#define read cin >>
// javaise
#define bash push_back
#define makePair make_pair
#define isEmpty empty
// germanise
#define drucken(obj) cout << obj << '\n'
#define lesen(obj) cin >> obj
#define fur for
#define wenn if
#define sonst else
#define Zahl int
// type-define
#define String string
#define Stack stack
#define Queue queue
#define pQueue priority_queue
#define Vector vector
#define Pair pair
#define Map map
typedef long long llong;
typedef bool boolean;
typedef Pair<int,int> Pii;
typedef Vector<int> Vi;
// utils
const int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
const int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
boolean isMovable(int x,int y,int w,int h){return (x>=0&&y>=0&&x<w&&y<h);};
const int INF = 1 << 29;

#define int long long

Vi vi;
int sum = 0;

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

    int n;
    read n;
    for ( int i = 0; i < 3*n; i++ ) {
        int a; read a;
        vi.bash(a);
    }
    sort(alles(vi));
    reverse(alles(vi));
    for ( int i = 1; i < n*2; i += 2 ) {
        sum += vi[i];
    }

    echo sum fin;

    return 0;
}


Measured memory_bytes: 2420
#include <bits/stdc++.h>
#define INF 0x3f3f3f3f
#define rep(i, a, n) for (int i=(a); i<(n); i++)
#define per(i, a, n) for (int i=(a); i>(n); i--)
typedef long long ll;
const int maxn = 2e5+5;
const int mod = 1e9+7;
using namespace std;


int main()
{
	ll a,b;
	cin >> a >> b;
	cout << a*b << '\n';
	return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <iomanip>
#include <cassert>

#include <vector>
#include <algorithm>
using namespace std;

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

void Main()
{
	int N;
	cin >> N;

	int k = 1;
	do {
		if (k << 1 > N) break;
		k <<= 1;
	} while (true);

	cout << k << endl;
}

int main()
{
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);

	Main();
	return 0;
}

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

int main()
{
    int a, b, c, d; cin >> a >> b >> c >> d;
    if (abs(a - c) <= d || (abs(a - b) <= d && abs(b - c) <= d)) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

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

#define ll long long
#define ld long double
#define db double
#define str string
#define pb push_back
#define nl '\n'
#define X first
#define Y second
#define nimble ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define all(v) (v).begin(),(v).end()
#define selp(a) for(auto i:a)cout<<i<<" ";cout<<nl;
#define mod(x,m) ((((x)%(m))+(m))%(m))
#define _sz(x) (int)x.size()
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repv(v) for(int i=0;i<_sz(v);i++)
#define rep1(i,b,a) for(int i=b;i>=a;i--)
#define preci(x) fixed<<setprecision(x)
#define tc int tt=1;cin>>tt;while(tt--)

#define TRACE
#ifdef TRACE
#define see(...) __f(#__VA_ARGS__,__VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr<<name<<" : "<<arg1<<nl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma=strchr(names+1,',');cerr.write(names,comma-names)<<" : "<<arg1<<" | ";__f(comma+1, args...);
}
#else
#endif

int inf=0x3f3f3f3f;
ll infl=0x3f3f3f3f3f3f3f3fLL;
ld infd=1.0/0.0;
const ll MOD=1e9+7;// 998244353 // = (119<<23)+1
const db pi=2*acos(0.0);

int main(){
    nimble
    string s;
    cin>>s;
    if(s=="ABC")cout<<"ARC";
    else cout<<"ABC";
    return 0;
}


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

int main() {
    
    int n, k, a[100000];
    cin>>n>>k;
    
    int sum = 0;
    for(int i = 0; i < n; i++) {
        cin>>a[i];
        sum += a[i];
    }
    
    int ave = sum / k;
    
    int m, cnt, i;
    while(1) {
        cnt = 1;
        m = 0;
        for(i = 0; i < n; i++) {
            if(cnt > k) break;
            if(m+a[i] <= ave) {
                m += a[i];
            } else {
                if(ave < a[i]) break;
                m = a[i];
                cnt++;
            }
        }
        if(i == n && cnt <= k) {
            cout<<ave<<endl;
            return 0;
        }
        ave++;
    }
    
    return 0;
}


Measured memory_bytes: 3496
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <complex>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << #x << " = " << (x) << endl;


#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 100010

ll factorial(int n,int M){
  ll ret=1;
  if(n<=1) return 1;
  
  for(int i=1;i<=n;i++){
    ret = (ret*i)%M;
  }
  
  return ret;
}

ll power(int k,int n,int M){
  if(n==0) return 1;
  if(n==1) return (ll)k;
  
  ll ret = power(k,n/2,M);
  
  ret=(ret*ret)%M;
  
  if(n%2==1)
    ret=(ret*k)%M;
  
  return ret;
}


//nCm nPm nHm (mod M)

/*Combination*/
int C(int n,int m,int M){
  if(n<m) return 0;
  if(m==0 || n==m) return 1;
  
  ll chi = factorial(n,M);
  ll mot = (factorial(m,M) * factorial(n-m,M))%M;
  
  mot = power((int)mot,M-2,M);
  
  ll ret = (chi*mot)%M;
  
  return (int)ret;
}
/*Permutation*/
int P(int n,int m,int M){
  if(n<m) return 0;
  if(m==0) return 1;
  
  ll chi = factorial(n,M);
  ll mot = factorial(n-m,M);
  
  
  mot = power((int)mot, M-2,M);
  
  ll ret = (chi*mot)%M;
  
  return (int)ret;
}
/*Combination with Repetitions*/
int H(int n,int m,int M){
  if(n==0 && m==0) return 1;
  return C(n+m-1,m,M);
}




int main(){
  int n,m;

  cin >> n >> m;

  if(abs(n-m) >= 2){
    puts("0");
    return 0;
  }

  ll ans = ((ll)P(n,n,mod) * P(m,m,mod))%mod;
  
  if(abs(n-m) == 0){
    ans = (ans * 2)%mod;
  }

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


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
    int n, m, l;
    long long all;
    cin >> n >> m >> l;
    int A[n][m], B[m][l];
    long long C[n][l];
    for (int i=0; i<n; i++){
        for (int j=0; j<m; j++){
            cin >> A[i][j];
        }
    }for (int i=0; i<m; i++){
        for (int j=0; j<l; j++){
            cin >> B[i][j];
        }
    }for (int i=0; i<n; i++){
        for (int j=0; j<l; j++){
            all = 0;
            for (int k=0; k<m; k++){
                all += A[i][k]*B[k][j];
            }C[i][j] = all;
            cout << C[i][j];
            if (j!=l-1) cout << " "; 
        }cout << endl;
    }return 0;
}


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

using namespace std;

int main(){
    int M, K;
    cin >> M >> K;
    if(K == 0){
        for(int i = 0; i < (1<<M); ++i){
            cout << i << " " << i;
            if(i+1 == (1<<M)){
                cout << endl;
            }else{
                cout << " ";
            }
        }
        return 0;
    }
    vector<int> a;
    int v = 0;
    for(int i = 0; i < (1<<M); ++i){
        if(i == K) continue;
        v = v ^ i;
        a.push_back(i);
    }
    if(v != K){
        cout << -1 << endl;
        return 0;
    }
    for(int a_val: a){
        cout << a_val << " ";
    }
    cout << K << " ";
    reverse(a.begin(), a.end());
    for(int a_val: a){
        cout << a_val << " ";
    }
    cout << K << endl;
    return 0;
}



Measured memory_bytes: 2424
#include <iostream>
#include <string>
#include <set>

#define setter(v, vx, vy, vz) { v.x = vx; v.y = vy; v.z = vz; }

using namespace std;

struct Vector3 {
	short x;
	short y;
	short z;
};

bool operator<( const Vector3& a, const Vector3& b )
{
	if(a.x < b.x) return true;
	if(a.x > b.x) return false;
	if(a.y < b.y) return true;
	if(a.y > b.y) return false;
	if(a.z < b.z) return true;
	if(a.z > b.z) return false;
	else return false;
}

int main( void )
{
	int n, h;
	while(cin >> n >> h, n | h) {
		string c;
		short a, b;
		int count = 0;
		set<Vector3> pos;
		Vector3 pp;
		for(int i=0; i < h; ++i) {
			cin >> c >> a >> b;
			--a; --b;
			if(c == "xy") {
				for(int j=0; j < n; ++j) { setter(pp, a, b, j); pos.insert(pp); }
			}
			else if(c == "xz") {
				for(int j=0; j < n; ++j) { setter(pp, a, j, b); pos.insert(pp); }
			}
			else if(c == "yz") {
				for(int j=0; j < n; ++j) { setter(pp, j, a, b); pos.insert(pp); }
			}
		}
		cout << n*n*n - pos.size() << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include<iostream>
using namespace std;
int main()
{
    int a,b,c,x,y,z;
    cin>>a>>b>>c;

    x=a+b;y=b+c;z=a+c;

    if(y<x&&y<z)
       {
           cout<<y<<endl;
       }
    else if(x<y&&x<z)
        {
            cout<<x;
        }
    else
    {
        cout<<z<<endl;
    }
   cout<<endl;





    return 0;
}


Measured memory_bytes: 3636
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
#include <random>
#include <unordered_set>
#include <complex>
using namespace std;
 
#define rep(i, N) for (int i = 0; i < N; i++)
#define pb push_back
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };
// typedef complex<double> C;
 
ll MOD = 1000000007;
ll _MOD = 1000000009;
int INF = INT_MAX / 2;
double EPS = 1e-10;

template <int M>
struct ModInt {
	int x;
	ModInt() : x(0) {}
	ModInt(int _x) { if ((x = _x % M) < 0) x += M; }
	int operator () () const { return x; }
	ModInt operator - () const { ModInt a = *this; if (a.x) a.x = M - a.x; return a; }
	ModInt& operator += (const ModInt &a) { if ((x += a.x) >= M) x -= M; return *this; }
	ModInt& operator -= (const ModInt &a) { if ((x -= a.x) < M) x += M; return *this; }
	ModInt& operator *= (const ModInt &a) { x = (ll)x * a.x % M; return *this; }
	ModInt operator + (const ModInt &a) const { return ModInt(*this) += a; }
	ModInt operator - (const ModInt &a) const { return ModInt(*this) -= a; }
	ModInt operator * (const ModInt &a) const { return ModInt(*this) *= a; }
};
typedef ModInt<1000000007> mint;

int main() {
	int N; cin >> N;
	vector<i_i> p;
	rep(i, N) {
		int x; scanf("%d", &x);
		p.pb(i_i(x, 1));
	}
	rep(i, N) {
		int x; scanf("%d", &x);
		p.pb(i_i(x, 2));
	}
	sort(p.begin(), p.end());
	int A = 0, B = 0;
	mint ans = 1;
	for (i_i z: p) {
		int x = z.first, t = z.second;
		if (t == 1) {
			if (B) ans *= B, B--;
			else A++;
		}
		if (t == 2) {
			if (A) ans *= A, A--;
			else B++;
		}
	}
	cout << ans() << endl;
}


Measured memory_bytes: 2420
function Main(input){
  var inp = input.split('\n');
  var inp0 = inp[0].split(' ');
  var A = parseInt(inp0[0]);
  var B = parseInt(inp0[1]);

  var S = inp[1];

  var isResult = true;

  var arrayS = S.split('-');
  if(!(arrayS[0].length === A && arrayS[1].length === B)){
    isResult = false;
  }

  var arraySS = arrayS.reduce((a, b) => { return a + b; });

  for(var i of arraySS){
    if(!(i * 0 === 0)){
      isResult = false;
    }
  }

  isResult ? console.log('Yes') : console.log('No');
}

Main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

using namespace std;


int main() {
  int N;
  string S,T;

  cin >> N >> S >> T;

  for (int i = 0; i < N; i++)
  {
    cout << S[i] << T[i];
  } cout << endl;
  

  return 0;
}

Measured memory_bytes: 888
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m;
    cin >> n >> m;
    vector<string> a(n),b(m);
    REP(i,n) cin >> a[i];
    REP(i,m) cin >> b[i];
    for(int i=0;i+m<=n;++i){
        for(int j=0;j+m<=n;++j){
            bool f = true;
            REP(k,m){
                if(a[i+k].substr(j,m)==b[k]){

                }else{
                    f = false;
                    break;
                }
            }
            if(f){
                puts("Yes");
                return 0;
            }
        }
    }
    puts("No");

    return 0;
}

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

int main(){
    int n;
    cin >> n;
    int ue[n],sita[n];
    rep(i,n) cin >> ue[i];
    rep(i,n) cin >> sita[i];
    vector<int> ans(n);
    for(int i = 0;i < n-1;i++){
        for(int j = 0;j < n-1;j++){
            if(i<=j) ans[i] += sita[j];
            else ans[i] += ue[j+1];
        }
    }
    sort(ans.begin(),ans.end());
    cout << ue[0]+sita[n-1]+ans[n-1] << endl;
    return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include "bits/stdc++.h"
#define REP(i,a,b) for(i=a;i<b;++i)
#define rep(i,n) REP(i,0,n)
#define ll long long
#define ull unsigned ll
typedef long double ld;
#define ALL(a) (a).begin(),(a).end()
#define ifnot(a) if(not a)
#define dump(x)  cerr << #x << " = " << (x) << endl
using namespace std;

void reader(int &a) { scanf("%d", &a); }
void reader(double &a) { scanf("%lf", &a); }
void reader(char a[]) { scanf("%s", a); }
void reader(char &a) { scanf(" %c", &a); }
void reader(ll &a) { scanf("%lld", &a); }
void reader(ull &a) { scanf("%llu", &a); }
// void reader(string& a){cin >> a;};
template<class T, class U> void reader(T& t, U& u) { reader(t); reader(u); }
template<class T, class U, class V> void reader(T& t, U& u, V& v) { reader(t); reader(u); reader(v); }

void writer(const int a, char c) { printf("%d", a); putchar(c); }
void writer(const ll a, char c) { printf("%lld", a); putchar(c); }
void writer(const ull a, char c) { printf("%llu", a); putchar(c); }
void writer(const double a, char c) { printf("%.20lf", a); putchar(c); }
void writer(const char a[]) { printf("%s", a); };
void writer(const char a[], char c) { printf("%s", a); putchar(c); };
void writer(const char a, char c) { putchar(a); putchar(c); };
template<class T> void writerLn(T t) { writer(t, '\n'); }
template<class T, class U> void writerLn(T t, U u) { writer(t, ' '); writer(u, '\n'); }
template<class T, class U, class V> void writerLn(T t, U u, V v) { writer(t, ' '); writer(u, ' '); writer(v, '\n'); }
template<class T> void writerArr(T x[], int n) { int i; if (!n) { putchar('\n'); return; }rep(i, n - 1) writer(x[i], ' '); writer(x[n - 1], '\n'); }
template<class T> void writerVec(vector<T> x) { int n = x.size(); int i; if (!n) { putchar('\n'); return; }rep(i, n - 1) writer(x[i], ' '); writer(x[n - 1], '\n'); }

vector<string> split(const string &str, char sep) { vector<string> v; stringstream ss(str); string buffer; while (getline(ss, buffer, sep)) { v.push_back(buffer); }return v; }
// #define int ll
bool test = 0;
int dx[] = { 0,1,0,-1 };
int dy[] = { 1,0,-1,0 };
#define INF (1 << 28)
ull mod = (int)1e9 + 7;
//.....................
#define MAX (int)1e6 + 5

signed main(void)
{
	ll i, j, k, l;
	int n;
	cin >> n;
	vector<char> v(n);
	rep(i, n) reader(v[i]);

	string s;
	rep(i, n) s += v[i];

	//dump(s.size());
	rep(i, 1e9) {
		string i_s = to_string(i);
		rep(j, n - i_s.size() + 1) {
			if (i_s == s.substr(j, i_s.size())) {
				break;
			}
		}
		if (j == n - i_s.size() + 1) break;
	}

	cout << i << endl;
	return 0;
}

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

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

bool isWar(vector<int> vec_x, vector<int> vec_y) {
    return *max_element(vec_x.begin(), vec_x.end()) >= *min_element(vec_y.begin(), vec_y.end());
}

int main(void) {
    int n, m;
    
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n >> m;
    
    vector<int> vec_x(n + 1), vec_y(m + 1);
    cin >> vec_x[0] >> vec_y[0];
    REP(i, n) {
        cin >> vec_x[i + 1];
    }
    REP(i, m) {
        cin >> vec_y[i + 1];
    }
    
    cout << (isWar(vec_x, vec_y)? "War" : "No War") << "\n";
    return 0;
}


Measured memory_bytes: 256
N,M = map(int,input().split())
AB = [tuple(map(int,input().split())) for i in range(N)]
from collections import defaultdict
d = defaultdict(lambda: [])
for a,b in AB:
    d[a].append(b)

import heapq
class Heapq:
    def __init__(self, arr, desc=False):
        if desc:
            arr = [-a for a in arr]
        self.sign = -1 if desc else 1
        self.hq = arr
        heapq.heapify(self.hq)

    def pop(self):
        return heapq.heappop(self.hq) * self.sign

    def push(self, a):
        heapq.heappush(self.hq, a * self.sign)

    def top(self):
        return self.hq[0] * self.sign

    def size(self):
        return len(self.hq)

q = Heapq([], True)

ans = 0
for m in range(1,M+1):
    for a in d[m]:
        q.push(a)
    if q.size():
        ans += q.pop()
print(ans)

Measured memory_bytes: 38072
#include <stdio.h>
int main(void)
{
  long int A,B,tmp;
  long int N=1;
  scanf("%ld %ld",&A,&B);
  if(A>=B) 
  {
    tmp = A;
    A = B;
    B = tmp;
  }
  
  while((A*N)%B != 0)
  {
    N++;
  }
  printf("%ld\n",A*N);
  return 0;  
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int a[150];
int n,p,k;

double sum,s;
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);cout.tie(0);
cin>>n;
for(int i=0;i<n;i++){
    cin>>a[i];
    s+=a[i];
}
sort(a,a+n);
sum = round(s/n);
for(int i=0;i<n;i++){
    k=abs(a[i]-sum);
    p+=pow(k,2);
}
cout<<p;

return 0;}



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

int main(){
	int a,c;
	string b;
	cin >> a >> b >> c;
	if(b=="+"){
		cout << a+c << endl;
	}else if(b=="-"){
		cout << a-c << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
bool check (long long a )
{
  if (a == 0 or a < 0 )
  {
    return true;
  }
  else return false;
}
int main()
{
  long long tasHealth, tasStrength, aikHealth, aikStrength ;
  cin >> tasHealth >> tasStrength >> aikHealth >>aikStrength ;
  char ch ;
  while(1){
    aikHealth -= tasStrength;

    if(check(aikHealth))
    {
      ch = 't' ;

      break;
    }

    tasHealth -= aikStrength;

    if(check(tasHealth)) {
      ch = 'a' ;
      break;
    }
  }

  // cout << tasHealth << " " << aikHealth << endl ;
  if(ch == 'a') {
    cout << "No\n";
  }
  else cout <<"Yes\n";
}


Measured memory_bytes: 3608
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define PF push_front
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double
#define pii pair<int,int>
#define pll pair<LL,LL>
#define vi vector<int>
#define vii vector<vi>

const double pi = 3.14159265358979323846264;
const int mod=1000000007;

int main(){
	 //cin.tie(0);
	//ios::sync_with_stdio(false);
	//std::cout << std::fixed;
	//std::cout << std::setprecision(12);
	//std::cout << std::defaultfloat;
	int n,k,ans=0;
	cin>>n>>k;
	FOR(i,0,n){
		int a;
		cin>>a;
		if(k<=a)ans++;
	}
	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <tuple>
#include <utility>
#include <set>
using namespace std;


int main(int argc, char *argv[])
{
    // VARIABLES
    int N, Q;
    vector<tuple<int, int, int>> L;
    set<tuple<int, int>> D;

    // INPUT
    cin >> N >> Q;
    for (int i=0; i<N; i++){
        int s,t,x;
        cin >> s >> t >> x;
        L.emplace_back(s-x, t-x, x);
    }

    for (int i=0; i<Q; i++){
        int d;
        cin >> d;
        D.insert(make_tuple(d, i));
    }
   

    // PROC
    sort(L.begin(), L.end(), [](tuple<int, int, int> left, tuple<int, int, int> right) {
        if (get<2>(left) != get<2>(right)) {
            return get<2>(left) <= get<2>(right);
        } else if ((get<0>(left) != get<0>(right))) {
            return get<0>(left) <= get<0>(right);
        } else {
            return get<1>(left) <= get<1>(right);
        }

    });

    vector<int> DD(Q, -1);
    for (auto l : L){
        int s, t, x;
        tie(s, t, x) = l;

        auto it = D.lower_bound(make_tuple(s, -1));
        while (it != D.end()) {
            int d = get<0>(*it);
            int idx = get<1>(*it);

            if (d >= t) {
                break;
            }

            DD[idx] = x;
            D.erase(it++);
        }
    }

    // OUTPUT
    for (auto d : DD) {
        cout << d << endl;
    }
    
    return 0;   
}

Measured memory_bytes: 14320
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)

typedef int long long ll;
using namespace std;
typedef pair<int,int> P;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const ll MOD=1e9+7;
static const int MAX = 100;
static const int INF = (1<<23);
template<class T> T gcd(T a, T b){return b? gcd(b,a%b) : a;}
template<class T> T lcm(T a,T b){return a / gcd(a,b)*b;}

int main(){
    ll n;
    cin>>n;
    vector<ll> v(n,0);
    rep(i,n){
        cin>>v[i];
    }
    sort(v.rbegin(),v.rend());
    ll ans = v[0];
    int nowp = 1;
    for(int i=2;i<n;i++){

        for(int j=0;j<2;j++){
            if(i>=n)break;
            ans+=v[nowp];
            i++;
        }
        i--;
        nowp++;
    }
    cout<<ans<<endl;


    
return 0;
}


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

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

	if( a < b )
	{
		cout << "a" << " < " << "b" << endl ;
	}
	else if( a > b )
	{
		cout << "a" << " > " << "b" << endl ;
	}
	else if( a == b )
	{
		cout << "a" << " == " << "b" << endl ;
	}
}

Measured memory_bytes: 1156
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(i64 (i) = (s);(i) < (e);(i)++)
#define rev(i,s,e) for(i64 (i) = (s);(i) --> (e);)
#define all(x) x.begin(),x.end()

template<class T>
static inline std::vector<T> ndvec(size_t&& n, T val) noexcept {
  return std::vector<T>(n, std::forward<T>(val));
}

template<class... Tail>
static inline auto ndvec(size_t&& n, Tail&&... tail) noexcept {
  return std::vector<decltype(ndvec(std::forward<Tail>(tail)...))>(n, ndvec(std::forward<Tail>(tail)...));
}

int main() {
  string s, t;
  cin >> s >> t;
  int a, b;
  cin >> a >> b;
  string u;
  cin >> u;
  if(s == u) {
    cout << a - 1 << " " << b << endl;
  }
  else {
    cout << a << " " << b - 1 << endl;
  }
}


Measured memory_bytes: 764
object Main extends App {
    val k = scala.io.StdIn.readInt
    var output = 0
    for(count1 <- 1 to k){
        for(count2 <- 1 to k){
            for(count3 <- 1 to k){
                output = output + gcd(count1, gcd(count2, count3))
            }
        }
    }
    println(output)
    def gcd(x: Int, y: Int): Int = {
        if(y == 0) x
        else gcd(y, (x % y))
    }
}

Measured memory_bytes: 54872
#include"bits/stdc++.h"
#include<iostream>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
#define rep(i, c) for(int i = 0; i < (int)c; i++)
const ll inf = ll(1e18)+1;

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

	if (k<=599) {
		cout << 8 << endl;
	}
	else if (k <= 799) {
		cout << 7 << endl;
	}
	else if (k <= 999) {
		cout << 6 << endl;
	}
	else if (k <= 1199) {
		cout << 5 << endl;
	}
	else if (k <= 1399) {
		cout << 4 << endl;
	}
	else if (k <= 1599) {
		cout << 3 << endl;
	}
	else if (k <= 1799) {
		cout << 2 << endl;
	}
	else {
		cout << 1 << endl;
	}
	


	return 0;
}

Measured memory_bytes: 3668
import std.stdio, std.conv, std.string, std.array, std.math, std.regex, std.range, std.ascii, std.numeric, std.random;
import std.typecons, std.functional, std.traits,std.concurrency;
import std.algorithm, std.container;
import core.bitop, core.time, core.memory;
import std.bitmanip;
import std.regex;

enum INF = long.max/3;
enum MOD = 10L^^9+7;

//辞書順順列はiota(1,N),nextPermituionを使う


void end(T)(T v)
if(isIntegral!T||isSomeString!T||isSomeChar!T)
{
    import core.stdc.stdlib;
    writeln(v);
    exit(0);
}

T[] scanArray(T = long)()
{
    static char[] scanBuf;
    readln(scanBuf);
    return scanBuf.split.to!(T[]);
}

dchar scanChar()
{
    int c = ' ';
    while (isWhite(c) && c != -1)
    {
        c = getchar;
    }
    return cast(dchar)c;
}

T scanElem(T = long)()
{
    import core.stdc.stdlib;
    static auto scanBuf = appender!(char[])([]);

    scanBuf.clear;

    int c = ' ';
    while (isWhite(c) && c != -1)
    {
        c = getchar;
    }
    while (!isWhite(c) && c != -1)
    {
        scanBuf ~= cast(char) c;
        c = getchar;
    }
    return scanBuf.data.to!T;
}

dchar[] scanString(){
    return scanElem!(dchar[]);
}


void main()
{
  auto list = [0,1,3,1,2,1,2,1,1,2,1,2,1];
  if(list[scanElem]==list[scanElem])end("Yes");end("No");
}


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

int main(){
    int D, G, p[11], c[11];
    cin >> D >> G;
    for(int i = 0; i < D; ++i){
        cin >> p[i] >> c[i];
    }
 
    int ans = 1e9;
    rep(tmp, 1<<D){
      int scr = 0, num = 0, max_id = -1;
      rep(i,D){
        if((tmp>>i) & 1){
          scr += 100 * (i+1) * p[i] + c[i];
          num += p[i];
        }else{
          max_id = i;
        }
      }
      if(scr < G){
        int sum = 100 * (max_id + 1);
        int rmn = (G - scr + sum - 1) / sum;
        if(rmn >= p[max_id]){
          continue;
        }
        num += rmn;
      }
      ans = min(ans, num);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define fup(i,a,b) for(int i=a;i<=b;++i)
#define fdw(i,a,b) for(int i=a;i>=b;--i)
#define sync ios::sync_with_stdio(false);cin.tie(0)
#define cl(a) memset(a,0,sizeof(a))
#define gcd __gcd
#pragma GCC optimize(2)
using namespace std;
typedef long long ll;
//ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
//ll ksm(ll a,ll b,ll mod){ll ans=1;a%=mod;for(;b;b>>=1){if(b&1) ans=ans*a%mod;a=a*a%mod;}return ans;}
//ll oula(ll n){ ll res=n;for(ll i=2;i*i<=n;i++){if(n%i==0){ res=res-res/i;while(n%i==0) n/=i;}}if(n>1) res=res-res/n;return res;}
//bool MRT(ll x){if(x==2)return true;fup(i,1,30){ll now=rand()%(x-2)+2;if(ksm(now,x-1,x)!=1)return false;}return true;}
//void shai(int n)fup(i,2,n){if(isprime[i]){v.push_back(i);for(int j=2*i;j<=10000;j+=i)isprime[j]=0;}}//"埃氏筛筛选素数"
const int mod=1e9+7;
const int inf=0x3f3f3f3f;
const int N = 2e5 + 10 ;
ll dp[102][2][5];
string s;
int k, n;
ll f(int i, bool b, int c) {
    if (c == 0) return 1;
    if (i == n) return 0;
    if (dp[i][b][c] > 0) return dp[i][b][c];
    int d = s[i] - '0';
    ll res = 0;
    if (b) {
        if (d == 0) {
            res = f(i + 1, true, c);
        } else {
            res = f(i + 1, true, c - 1) + (d - 1) * f(i + 1, false, c - 1) + f(i + 1, false, c);
        }
    } else {
        res = 9 * f(i + 1, false, c - 1) + f(i + 1, false, c);
    }
    return dp[i][b][c] = res;
}

int main() 
{
    cin >> s >> k;
    n = s.size();
    ll ans = f(0, true, k);
    cout << ans << endl;
    return 0;
}


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

#define ln '\n'
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define FOR(i, a, b) for (int i = (a); i <= (int)(b); ++i)
#define FORR(i, a, b) for (int i = (a); i >= (int)(b); --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef vector<P> VP;
typedef vector<PL> VPL;
typedef vector<string> VS;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    s += 'R';
    int n = s.size();
    VI ans(n - 1, 0);

    int target_i = -1;
    int r_count = 0;
    int l_count = 0;
    REP(i, n - 1) {
        if (s[i] == 'R')
            r_count++;
        else
            l_count++;

        if (s.substr(i, 2) == "RL") {
            target_i = i;
        } else if (s.substr(i, 2) == "LR") {
            ans[target_i] = (r_count + 1) / 2 + l_count / 2;
            ans[target_i + 1] = r_count / 2 + (l_count + 1) / 2;
            r_count = 0;
            l_count = 0;
        }
    }

    REP(i, ans.size()) {
        if (i == (int)ans.size() - 1)
            cout << ans[i] << ln;
        else
            cout << ans[i] << " ";
    }

    return 0;
}


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

int main() {
	multiset<int, greater<int>> ms; int temp;
	for (int i = 0; i < 10; i++) { cin >> temp; ms.insert(temp); }
	auto itr = ms.begin();
	for (int i = 0; i < 3; i++) { cout << *itr << endl; itr++; }
	return 0;
}


Measured memory_bytes: 3096
def read_int():
    return int(input().strip())


def read_ints():
    return list(map(int, input().strip().split(' ')))


def solve():
    """
    a = H|D atcodeer is honest/dishonest
    b = H|D atcodeer is saying topcodeer is honest/dishonest
    H H H
    D H D
    D D H
    H D D
    """
    l = input()
    return {
        'H H': 'H',
        'D H': 'D',
        'D D': 'H',
        'H D': 'D'
    }[l]


if __name__ == '__main__':
    print(solve())


Measured memory_bytes: 61856
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
#define rep(i, n) for(int i=0; i<(int)(n); ++i)
#define all(v) v.begin(),v.end()
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  int n;
  cin >> n;
  vector<int> v(n, 0);
  for (int i = 1; i < n; ++i) {
    int a;
    cin >> a;
    v[a-1]++;
  }
  for (int i = 0; i < n; ++i) {
    cout << v[i] << " \n"[i == n-1];
  }
}

Measured memory_bytes: 3972
#include <stdio.h>

int main(void){
        int n, i;
        scanf("%d", &n);
        int k[n], p[n];
        for(i=0;i<n;i++){
                scanf("%d %d", &k[i], &p[i]);
        }
        for(i=0;i<n;i++){
                if(k[i]%p[i]==0)
                        printf("%d\n", p[i]);
                else
                        printf("%d\n", k[i] % p[i]);
        }
        return 0;
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define int long long
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
signed main(){
	cout << fixed << setprecision(10);
	ll n,k;
	cin >> n >> k;
	vector<pair<int,ll>> v;
	rep(i,n){
		int a,b;
		cin >> a >> b;
		v.push_back({a,b});
	}
	sort(v.begin(),v.end());
	ll cnt = 0;
	rep(i,n){
		if(cnt + v[i].second >= k){
			cout << v[i].first << endl;
			return 0;
		}
		cnt += v[i].second;
	}
	return 0;
}

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

int main(){
    int d, second, m, sum = 0;
    cin >> d;
    vector<int> c(26);
    vector<vector<int>> s(d, vector<int>(26));
    vector<int> t(d);
    for(auto &&n : c) cin >> n;
    for(auto &&n1 : s) for(auto &&n2 : n1) cin >> n2;

    vector<int> l(26);
    vector<int> v(26);
    
    rep(i, d){
        rep(j, 26){
            v[j] = s[i][j];
            v[j] -= c[j] * (++l[j]);
        }
        m = 0;
        for(int j=1; j<26; ++j) if(v[j] > v[m]) m = j;
        cout(m+1);

        sum += s[i][m];
        l[m] = 0;

        rep(j, 26) sum -= c[j] * l[j];
    }
}


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

int main(){
int A,B;
cin >> A >> B;  
if(A>B)
  cout << 2*A-1 << endl;
if(A==B)
  cout << 2*A << endl;
if 
  (A<B)
  cout << 2*B-1 << endl;
}  

Measured memory_bytes: 256
local mma = math.max
local n = io.read("*n")
local edge = {}
local num = {}
local len = {}
local ccnt, c2cnt, parent = {}, {}, {}
local lim = {}
lim[1] = math.ceil(n / 3)
lim[2] = math.ceil((n - 1) / 3)
lim[3] = math.floor(n / 3)

for i = 1, n do
  edge[i] = {}
  num[i] = 0
  len[i] = -1
  ccnt[i] = 0
  c2cnt[i] = 0
  parent[i] = 0
end
for i = 1, n - 1 do
  local a, b = io.read("*n", "*n")
  table.insert(edge[a], b)
  table.insert(edge[b], a)
end
local tasks = {1}
len[1] = 0
for i = 1, n do
  local src = tasks[i]
  for it = 1, #edge[src] do
    local dst = edge[src][it]
    if len[dst] == -1 then
      len[dst] = len[src] + 1
      parent[dst] = src
      ccnt[src] = ccnt[src] + 1
      c2cnt[src] = c2cnt[src] + #edge[dst] - 1
      table.insert(tasks, dst)
    end
  end
end
local oddcnt = 0
for i = 1, n do
  if len[i] % 2 == 1 then
    oddcnt = oddcnt + 1
  end
end
local use = {0, 0, 0}
if oddcnt < lim[1] then
  for i = 1, n do
    if len[i] % 2 == 1 then
      use[3] = use[3] + 1
      num[i] = use[3] * 3
    end
  end
  for i = 1, n do
    if len[i] % 2 == 0 then
      if use[3] < lim[3] then
        use[3] = use[3] + 1
        num[i] = use[3] * 3
      elseif use[2] < lim[2] then
        use[2] = use[2] + 1
        num[i] = use[2] * 3 - 1
      else
        use[1] = use[1] + 1
        num[i] = use[1] * 3 - 2
      end
    end
  end
elseif (n - oddcnt) < lim[2] then
  for i = 1, n do
    if len[i] % 2 == 0 then
      use[3] = use[3] + 1
      num[i] = use[3] * 3
    end
  end
  for i = 1, n do
    if len[i] % 2 == 1 then
      if use[3] < lim[3] then
        use[3] = use[3] + 1
        num[i] = use[3] * 3
      elseif use[2] < lim[2] then
        use[2] = use[2] + 1
        num[i] = use[2] * 3 - 1
      else
        use[1] = use[1] + 1
        num[i] = use[1] * 3 - 2
      end
    end
  end
else
  for i = 1, n do
    if len[i] % 2 == 1 then
      if use[1] < lim[1] then
        use[1] = use[1] + 1
        num[i] = use[1] * 3 - 2
      else
        use[3] = use[3] + 1
        num[i] = use[3] * 3
      end
    else
      if use[2] < lim[2] then
        use[2] = use[2] + 1
        num[i] = use[2] * 3 - 1
      else
        use[3] = use[3] + 1
        num[i] = use[3] * 3
      end
    end
  end
end
print(table.concat(num, " "))


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

namespace ConsoleApp18
{
    class Program
    {
        static void Main(string[] args)
        {

            int n = int.Parse(Console.ReadLine());

            string line = Console.ReadLine();
            string[] array = line.Split(' ');

            int[] arr = new int[n];
            for (int index = 0; index < n; index++)
            {
               int num = int.Parse(array[index]);
                arr[index] = num;

            }

            int m = arr.Max();

            int sum = 0;

            for (int i = 0; i < arr.Length; i++)
            {
                sum += arr[i];
            }

            if (m < sum - m)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }

            int[] numbers = new int[n];

            }
        }
    } 

Measured memory_bytes: 27964
#include <bits/stdc++.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++)
int main(){
    int n, cnt = 1;
    string s;
    cin >> n >> s;
    REP(i,1,n)if(s[i] != s[i-1])cnt++;
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef tuple<int,int,int>T;
typedef vector<T>VT;
int main(void){
	int n,m;
	int i,j;
	bool flg[100001];
	int box[100002];
	int cnt;
	int MAX;
	int f,b,c;
	int x,y;
	int flgf,flgb;
	int a,d;
	VT v;
	while(1){
		cin>>n>>m;
		clock_t start=clock();
		if(n==0&&m==0)	break;
		for(i=0;i<m;i++)	cin>>box[i];
		for(i=0;i<100001;i++)	flg[i]=false;
		box[m]=n+2;
		sort(box,box+m);
		MAX=-1;
		if(box[0]==0){
			f=box[1];
			c=1;
			for(i=1;i<m;i++){
				if(box[i]+1==box[i+1])	c++;
				else{
					b=box[i];
					v.push_back(make_tuple(f,b,c));
					c=1;
					f=box[i+1];
				}
			}
			//for(i=0;i<v.size();i++)	cout<<get<0>(v[i])<<" "<<get<1>(v[i])<<" "<<get<2>(v[i])<<endl;
			for(i=1;i<m;i++)	flg[box[i]]=true;
			x=box[1];	y=box[m-1];
			
			for(i=x+1;i<y;i++){
				if(!flg[i]){
					cnt=0;
					flgf=0;	flgb=0;
					for(j=0;j<v.size();j++){
						if(i-1==get<1>(v[j])){
							flgf=1;
							a=j;
						}
						if(i+1==get<0>(v[j])){
							flgb=1;
							d=j;
						}
						if(i+1<get<1>(v[j]))	break;
					}
					if(flgf==1&&flgb==1)	cnt=get<2>(v[a])+get<2>(v[d])+1;
					if(flgf==0&&flgb==1)	cnt=get<2>(v[d])+1;
					if(flgf==1&&flgb==0)	cnt=get<2>(v[a])+1;
					MAX=max(MAX,cnt);
				}
			}
		}
		else{//box[0]!=0
			cnt=1;
			for(i=0;i<m;i++){
				if(box[i+1]==box[i]+1)	cnt++;
				else{
					MAX=max(MAX,cnt);
					cnt=1;
				}
			}
		}
		cout<<MAX<<endl;
		clock_t end=clock();
		//cout<<(double)(end-start)/CLOCKS_PER_SEC<<endl;
	}
	return 0;
}


Measured memory_bytes: 3636
use std::io;

fn main() {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    let t: usize = s.trim().parse().unwrap();
    let h = t / 3600;
    let m = (t - h * 3600) / 60;
    let s = t - h * 3600 - m * 60;
    println!("{}:{}:{}", h, m, s);
}



Measured memory_bytes: 5036
program atcoder_contest_scheduling
  implicit none
  integer, parameter :: maxday = 365, maxtype = 26
  integer :: d, c(maxtype), s(maxtype, maxday), t(maxday), u(maxday)
  integer :: m, n, p, i, j
  logical :: f
  real(8) :: t1, t2
  call cpu_time(t1)
  call random_seed_clock()
  read(*,*) d
  read(*,*) c
  read(*,*) (s(:, i), i = 1, d)
  t = (/(maxloc(s(:, i), 1), i = 1, d)/)
  m = score()
  u = t
  do
    do i = 1, d
      f = .true.
      do j = 1, maxtype
        t(i) = j
        n = score()
        if (m < n) then
          m = n
          u(i) = j
          f = .false.
        end if
        call cpu_time(t2)
        if (t2 - t1 > 1.979d0) goto 100
      end do
      if (f) t(i) = u(i)
    end do
  end do
  100 write(*,'(i0)') (u(i), i = 1, d)
contains
  integer function score() result(res)
    integer :: last(maxtype), i
    last = 0
    res = 0
    do i = 1, d
      last(t(i)) = i
      res = res + s(t(i), i) + dot_product(c, last - i)
    end do
  end
  subroutine random_seed_clock()
    integer :: nseed, clock, seed(1000)
    call system_clock(clock)
    call random_seed(size = nseed)
    seed(1:nseed) = clock
    call random_seed(put = seed(1:nseed))
  end
  integer function next_int(m) result(res)
    integer, intent(in)  :: m
    real(8) :: r
    call random_number(r)
    res = int(m * r) + 1
  end
end program atcoder_contest_scheduling

Measured memory_bytes: 3028
#define _USE_MATH_DEFINES
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<climits>
#include<string>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<cmath>
#include<queue>
#include<cstring>
#include<stack>
using namespace std;
#define EPS 1e-10
 
struct Point{
    double x,y;
    Point(){}
    Point(double _x,double _y){
        x=_x; y=_y;
    }
    Point operator +(const Point p)const{
        return Point(x+p.x,y+p.y);
    }
    Point operator -(const Point p)const{
        return Point(x-p.x,y-p.y);
    }
    Point operator *(const double d)const{
        return Point(x*d,y*d);
    }
    bool operator <(const Point &p)const{
        if(x==p.x) return y<p.y;
        return x<p.x;
    }
    double norm(){
        return x*x+y*y;
    }
	bool input(){
		if(cin>>x>>y) return true;
		return false;
	}
};
 
struct Line{
    Point a,b;
    Line(){}
    Line(Point _a,Point _b){
        a=_a; b=_b;
    }
	bool input(){
		if(a.input() && b.input()) return true;
		return false;
	}
};
 
struct Circle{
    Point c;
    double r;
    Circle(){}
    Circle(Point _c,double _r){
        c=_c; r=_r;
    }
};

typedef vector<Point> Polygon;

double dot(Point p,Point q){
    return p.x*q.x+p.y*q.y;
}
 
double cross(Point p,Point q){
    return p.x*q.y-q.x*p.y;
}
 
int ccw(Point a,Point b,Point c){ //a,b,c,は全て異なる
	Point v1 = Point(b-a);
	Point v2 = Point(c-a);
    if(cross(v1,v2)>EPS) return +1; //a->b->c が反時計回り
    if(cross(v1,v2)<-EPS) return -1; //a->b->c が時計回り
	if(dot(v1,v2)<-EPS) return +2; //cがa-bより後ろ c<-a->b
	if(v1.norm()<v2.norm()) return -2; //cがa-bより前 a->b->c
    return 0; //cがa-b上 a->c->b
}
 
bool intersect_ss(Line l,Line m) {
    return ccw(l.a,l.b,m.a)*ccw(l.a,l.b,m.b)<=0 && ccw(m.a,m.b,l.a)*ccw(m.a,m.b,l.b)<=0;
}
 
bool crosspoint_ll(Line l,Line m,Point &p){
    Point a1,a2,b1,b2;
    a1 = l.b-l.a; a2 = m.b-m.a;
    b1 = m.a-l.a; b2 = l.a-m.b;
    double s1,s2;
    s1 = cross(a1,b1)/2; s2 = cross(a1,b2)/2;
    if(abs(s1)<EPS && abs(s2)<EPS) return false;
    p = Point(m.a.x+a2.x*s1/(s1+s2),m.a.y+a2.y*s1/(s1+s2));
    return true;
}
 
bool crosspoint_ss(Line l,Line m,Point &p){
    if(intersect_ss(l,m)==false) return false;
    return crosspoint_ll(l,m,p);
}
 
int crosspoint_cc(Circle c1,Circle c2,Point &p1,Point &p2){
    double d,a,t;
    d = sqrt((c2.c-c1.c).norm());
    if(d<abs(c1.r-c2.r) || c1.r+c2.r<d) return 0;
    a = acos((c1.r*c1.r+d*d-c2.r*c2.r)/(2*c1.r*d));
    t = atan2(c2.c.y-c1.c.y,c2.c.x-c1.c.x);
    p1 = Point(c1.c.x+c1.r*cos(t+a),c1.c.y+c1.r*sin(t+a));
    p2 = Point(c1.c.x+c1.r*cos(t-a),c1.c.y+c1.r*sin(t-a));
    if(abs(p1.x-p2.x)<EPS && abs(p1.y-p2.y)<EPS) return 1;
    return 2;
}

int contains(Polygon g,Point p){
	for(int i=0;i<g.size();i++){
		
	}
}
 
int main(){
	Line l,m;
	int Q;
	cin>>Q;
	for(int i=0;i<Q;i++){
		l.input(); m.input();
		if(intersect_ss(l,m)==true) puts("1");
		else puts("0");
	}
}

Measured memory_bytes: 1188