akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <regex>
using namespace std;
using pii  = pair<int,int>;
using ll=long long;
using ld=long double;
#define pb push_back
#define mp make_pair
#define sc second
#define fr first
#define stpr setprecision
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,n) for(ll i=0;i<(n);++i)
#define Rep(i,a,b) for(ll i=(a);i<(b);++i)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rRep(i,a,b) for(int i=a;i>=b;i--)
#define crep(i) for(char i='a';i<='z';++i)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define ALL(x) (x).begin(),(x).end()
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define endl '\n'
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
ll gcd(ll a,ll b){return (b == 0 ? a : gcd(b, a%b));}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll MOD=1000000007;
constexpr ll INF=1000000011;
constexpr ll MOD2=998244353;
constexpr ll LINF = 1001002003004005006ll;
constexpr ld EPS=10e-8;
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; }
template<typename T> istream& operator>>(istream& is,vector<T>& v){for(auto&& x:v)is >> x;return is;}
template<typename T,typename U> istream& operator>>(istream& is, pair<T,U>& p){ is >> p.first; is >> p.second; return is;}
template<typename T,typename U> ostream& operator>>(ostream& os, const pair<T,U>& p){ os << p.first << ' ' << p.second; return os;}
template<class T> ostream& operator<<(ostream& os, vector<T>& v){
  for(auto i=begin(v); i != end(v); ++i){
    if(i !=begin(v)) os << ' ';
    os << *i;
  }
  return os;
}

int main(){
  ll N,A[100007],r=0,g=0,b=0,c=1;
  cin >> N ;
  rep(i,N){
    cin >> A[i];
    if(r==A[i]){
      if(r==b && r==g){
        c*=3;
        c%=MOD;
      }
      else{
        if(r==b || r==g){
          c*=2;
          c%=MOD;
        }
      }
      r++;
    }
    else if(b==A[i]){
      if(b==g){
        c*=2;
        c%=MOD;
      }
      b++;
    }
    else if(g == A[i]){
      g++;
    }
    else{
      cout << 0 << endl;
      return 0;
    }
  }
  cout << c%MOD <<  endl;
}

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

public class Hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var n = int.Parse(line[0]);
        var g = int.Parse(line[1]);
        var a = new int[n, 2];
        for (int i = 0; i < n; i++)
        {
            line = Console.ReadLine().Trim().Split(' ');
            a[i, 0] = int.Parse(line[0]);
            a[i, 1] = int.Parse(line[1]);
        }
        var ans = new List<int>();
        var imax = 1 << n;
        for (int i = 0; i < imax; i++)
        {
            var used = new bool[n];
            var p = 0;
            var count = 0;
            for (int j = 0; j < n; j++)
            {
                if (((i >> j) & 1) == 1)
                {
                    used[j] = true;
                    p += ((j + 1) * 100 * a[j, 0] + a[j, 1]);
                    count += a[j, 0];
                }
            }
            if (p >= g)  ans.Add(count); 
            else
            {
                var diff = g - p;
                for (int j = n - 1; j >= 0; j--)
                {
                    if (!used[j])
                    {
                        var pc = (diff + (j + 1) * 100 - 1) / ((j + 1) * 100);
                        if (pc < a[j, 0]) ans.Add(count + pc);
                        break;
                    }
                }
            }
        }
        Console.WriteLine(ans.Min());
    }
}


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

#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pb push_back
#define fi first
#define se second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mii map<int,int>
#define mll map<ll,ll>
#define all(x) (x).begin(),(x).end()
#define S(x) (int)(x).size()
#define L(x) (int)(x).length()

#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int , null_type , less<int> , rb_tree_tag , tree_order_statistics_node_update> ordered_set;

const int mod = 1e9+7;
const ll infl = 0x3f3f3f3f3f3f3f3fLL;
const int infi = 0x3f3f3f3f;

int cnt[100009];

void solve()
{
	int n,i;
	cin>>n;
	ll sum=0;
	for(i=0;i<n;i++)
	{
		int t;
		cin>>t;
		cnt[t]++;
		sum+=t;
	}
	int q;
	cin>>q;
	while(q--)
	{
		int b,c;
		cin>>b>>c;
		sum += 1LL*(c-b)*cnt[b];
		cnt[c]+= cnt[b];
		cnt[b]=0;
		cout<<sum<<'\n';
	}
}

int main()
{
	IOS
	int t=1;
	//cin>>t;
	while(t--)
	{
		solve();
	}
}


Measured memory_bytes: 3988
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

// c++11
#include <array>
#include <tuple>
#include <unordered_map>
#include <unordered_set>

#define mp make_pair
#define mt make_tuple
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;

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

const int INF = 1 << 29;
const ll LL_INF = 1LL << 60;
const double EPS = 1e-9;
const ll MOD = 1000000007;

const int dx[] = {1, 0, -1, 0}, dy[] = {0, -1, 0, 1};
char a, b;
int main()
{
    cin >> a >> b;
    if (a < b)
    {
        cout << '<' << endl;
    }
    else if (a > b)
    {
        cout << '>' << endl;
    }
    else
    {
        cout << '=' << endl;
    }
    return 0;
}


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

using namespace std;
using namespace __gnu_pbds;

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

#define all(v)			((v).begin()), ((v).end())
#define SZ(v)			((int)((v).size()))
#define clr(v, d)		memset(v, d, sizeof(v))
#define has(c,i) 		((c).find(i) != end(c))
#define has_str(s, c)	((s).find(c) != string::npos)
typedef long long ll;
int main() {
#ifdef LOCAL
    //freopen("input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    string a, b;
    cin >> a >> b;
    int n = SZ(a), m = SZ(b);
    vector<vector<int>> dp((n+1), vector<int>(m+1,0));
    for(int i = 1; i <= n; ++i) {
        for(int j = 1; j <= m; ++j) {
            if(a[i-1] == b[j-1]) {
                dp[i][j] = 1 + dp[i-1][j-1];
            } else {
                dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
            }
        }
    }
//    cout << dp[n][m];
    int i = n, j = m;
    string lcs = "";
    while (i > 0 && j > 0) {
        if(a[i-1] == b[j-1]) {
            lcs += a[i-1];
            --i;
            --j;
        } else {
            if(dp[i-1][j] > dp[i][j-1])
                --i;
            else
                --j;
        }
    }
    reverse(all(lcs));
    cout << lcs << endl;
    return 0;
}

Measured memory_bytes: 38524
from collections import Counter
n = int(input())
s = input()
counter = Counter(s[0::2])
counter2 = Counter(counter.values())
ans = 0
for k, v in counter2.items():
  if k == 1:
    ans += 2 * v
  else:
    if v == 1:
      ans += 4
    else:
      ans += 4 + v * 2
print(ans - 1)



Measured memory_bytes: 5996
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>

bool p[5000+1][5000+1];
int x[3000], y[3000];

int main()
{
  int n;
  while (~scanf("%d", &n)) {
    if (n == 0)
      break;

    memset(p, false, sizeof(p));
    for (int i = 0; i < n; ++i) {
      scanf("%d %d", &x[i], &y[i]);
      p[y[i]][x[i]] = true;
    }

    int ans = 0;
    for (int i = 0; i < n; ++i) {
      for (int j = i+1; j < n; ++j) {
	int dx = x[j] - x[i];
	int dy = y[j] - y[i];

	int x1 = x[i] + dy, y1 = y[i] - dx;
	int x2 = x[j] + dy, y2 = y[j] - dx;
	if (x1 < 0 || 5000 < x1 || y1 < 0 || 5000 < y1 ||
	    x2 < 0 || 5000 < x2 || y2 < 0 || 5000 < y2)
	  continue;

	if (p[y1][x1] && p[y2][x2])
	  ans = std::max(ans, dx*dx+dy*dy);
      }
    }

    printf("%d\n", ans);
  }
  return 0;
}

Measured memory_bytes: 24000
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll, ll> Pll;
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
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; }

const int MOD = 1000000007;
const int INF = 1e9;

const int mod = 1000000007;
const int inf = 1e9;
#define PI acos(-1);
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};


int main(){
    int n;
    ll a, b, c, d;
    cin >> n >> a >> b >> c >> d;
    bool ok = false;
    ll u = b-a;
    for(int i = 0; i < n; i++) {
        if(c*(n-1-i)-d*i <= u && u <= -c*i+d*(n-1-i)) ok = true;
    }
    if(ok) cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int mod=1e9+7;
int main() {
  int N;
  cin>>N;
  vector<int>A(N);
  for(int i=0;i<N;i++){
    cin>>A[i];
  }
  vector<int>hat(1000005);
  hat[0]=3;
  int64_t sum=1;
  for(int i=0;i<N;i++){
    (sum*=hat[A[i]])%=mod;
    hat[A[i]]--;
    hat[A[i]+1]++;
  }
  cout<<sum<<endl;
  return 0;  
}

Measured memory_bytes: 7456
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int MOD = 1000000007;

int main(void){
    int X; cin >> X;
    
    int num = X-1;
    while(1){
        num++;
        bool flag = true;
        for(int i = 2; i * i <= X; i++){
            if (num % i == 0){
                flag = false;
            }
        }
        if(!flag) continue;
        cout << num << endl;
        break;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cmath>
using namespace std;

int main(void) {
	int n;
	double x, y;
	double a, b, c; //3角形の3辺の長さ
	double sin, cos;
	
	while(cin >> n) {
		if(n == -1) break;
		
		x = 1;
		y = 0;
		for(int i = 0; i < n - 1; ++i) {
			a = sqrt(x*x + y*y); //現在地の井戸からの距離
			b = sqrt(a*a + 1*1); //移動後の井戸からの距離
			c = 1; //移動距離
			cos = (a*a + b*b - c*c) / (2*b*a); //余弦定理
			sin = sqrt(1 - cos*cos);
			double X = (x*cos - y*sin) * (b / a);
			double Y = (x*sin + y*cos) * (b / a);
			x = X;
			y = Y;
		}
		
		printf("%.2lf\n%.2lf\n", x, y);
	}
	
	return 0;
}


Measured memory_bytes: 3036
#include "bits/stdc++.h"
using namespace std;

#define mp make_pair
typedef pair<int,int> pii;
int h, w, cx, cy, dx, dy;
const int N=1001;
bool vis[N][N];
int depth[N][N];

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

    cin >> h >> w >> cx >> cy >> dx >> dy;

    string s[h+1];

    for(int i=1;i<=h;i++)cin >>s[i];
    deque<pii> q;
    q.push_back(mp(cx,cy));
    
    for(int i=0;i<N;i++)
        for(int j=0;j<N;j++)depth[i][j]=1e8;

    depth[cx][cy]=0;
    vis[cx][cy]=true;

    while(!q.empty()){
        auto N=q.front();
        q.pop_front();
        int x=N.first ,y =N.second;
        if(x==dx && y==dy){
            cout<<depth[x][y]<<endl;
            return 0;
        }

        for(int i=-2;i<3;i++)
            for(int j=-2;j<3;j++){
                int nx=x+i,ny=y+j;
                if(nx>0 &&  nx<=h && ny>0 && ny<=w && s[nx][ny-1]=='.' && !vis[nx][ny] ){

                    if(abs(i)+abs(j)<2){
                        vis[nx][ny]=true;
                        depth[nx][ny]=depth[x][y];
                        q.push_front(mp(nx,ny));
                    }

                    if(depth[nx][ny]>depth[x][y]+1){
                        depth[nx][ny]=depth[x][y]+1;
                        q.push_back(mp(nx,ny));
                    }
                }
            }
    }
    cout<<-1<<endl;
}



Measured memory_bytes: 9604
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
//    String s=sc.next();
    int x=sc.nextInt();
    int a=sc.nextInt();
//    int b=sc.nextInt();
    System.out.println(x%500<=a?"Yes":"No");
  }
}

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

#define mp make_pair

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

//int ExtendedGCD(int a,int b,int& x,int& y)
//{
//	if(b==0){
//		x=1,y=0;
//		return a;
//	}
//	else{
//		int g=ExtendedGCD(b,a%b,x,y);
//		tie(x,y)=make_tuple(y,x-a/b*y);
//		return g;
//	}
//}

int ExtendedGCD(int a,int b,int& x,int& y)
{
	x=1,y=0;
	for(int u=0,v=1;b;){
		ll t=a/b;
		swap(a-=b*t,b);
		swap(x-=u*t,u);
		swap(y-=v*t,v);
	}
	return a;
}

int main()
{
	for(int a,b;cin>>a>>b && a|b;){
		int x,y;
		for(int i=0;i<1000000;i++)
			ExtendedGCD(a,b,x,y);
		cout<<x<<' '<<y<<endl;;
	}
}

Measured memory_bytes: 1164
# 素因数分解
# http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=NTL_1_A&lang=ja

import math
from collections import Counter
n = int(input())
origin = n
ans = []

i = 2
while i <= math.sqrt(n):
    if n % i == 0:
        n //= i
        ans.append(str(i))
    else:
        i += 1

if n != 1:
    ans.append(str(n))
# print(Counter(ans))
f_ans = 0
for x, y in Counter(ans).items():
    cnt = 0
    for i in range(1, y+1):
        cnt += i
        if cnt == y:
            f_ans += i
            break
        if cnt > y:
            f_ans += (i - 1)
            break


print(f_ans)


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

typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 28;

// ====================================================================

int main() {
  long double a, b, c;
  cin >> a >> b >> c;
  if (sqrtl(4 * a * b) + LDBL_EPSILON < c - b - a)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <numeric>
#include <random>
#include <bitset>
#include <chrono>

using namespace std;

#define pb push_back
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;

#ifndef ONLINE_JUDGE
// #include "debug.h"
#else
// #define debug(...) 42
#endif

const int M = 1e5+5;
const int MD= 1e9+7;


int main() {
	fast_cin();
	int t=1;
	// cin>>t;
	while(t--)
	{
		int k,su=0;
		cin>>k;
		for(int i=1;i<=k;i++){
			for(int j=1;j<=k;j++){
				for(int l=1;l<=k;l++){
					su+=__gcd(i,__gcd(j,l));
				}
			}
		}
		cout<<su<<endl;
	}	
	return 0;
}

Measured memory_bytes: 3640
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using vch=vector<char>;
using vvch=vector<vector<char>>;
using vbo=vector<bool>;
using vvbo=vector<vector<bool>>;
using vpii=vector<pair<int,int>>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define mp make_pair
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i,s,n) for(ll i=(s);i<(ll)(n);i++)
#define all(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
const int inf=1e9+7;
const ll INF=1e18;

ll lcd(ll a,ll b){
    ll g=__gcd(a,b);
    a/=g;
    return a*b;
}

int main(){
    int n;cin>>n;
    ll l;
    vll t(n);
    rep(i,n){
        cin>>t[i];
        if(i==0)l=t[i];
        l=lcd(l,t[i]);
    }
    cout<<l<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
		int d,g;
		scanf("%d%d",&d,&g);
		int p[d][2],i,j,test[10],temp=0,point=0,mini=0;
		for(i=0;i<d;i++){
				scanf("%d%d",&p[i][0],&p[i][1]);
				mini+=p[i][0];
		}
		for(test[0]=0;test[0]<2;test[0]++){
		for(test[1]=0;test[1]<2;test[1]++){
		for(test[2]=0;test[2]<2;test[2]++){
		for(test[3]=0;test[3]<2;test[3]++){
		for(test[4]=0;test[4]<2;test[4]++){
		for(test[5]=0;test[5]<2;test[5]++){
		for(test[6]=0;test[6]<2;test[6]++){
		for(test[7]=0;test[7]<2;test[7]++){
		for(test[8]=0;test[8]<2;test[8]++){
		for(test[9]=0;test[9]<2;test[9]++){
				temp=0;point=0;i=0;
				while(i<d){
						if(test[i]==1){
								temp+=p[i][0];
								point+=p[i][1];
								point+=(p[i][0]*(i+1)*100);
						}
						i++;
				}i=d-1;
				while(g>point){
					if(test[i]==0){
							for(j=0;j<p[i][0];j++){
									point+=(i+1)*100;
									temp++;
									if(g<=point)break;
							}
							if(j==p[i][0]-1)point+=p[i][1];
					}
					i--;
				}
				if(temp<mini)mini=temp;
		}
		}
		}
		}
		}
		}
		}
		}
		}
		}
		printf("%d\n",mini);
		return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <string>

using namespace std;

long long fact[15];

vector< vector<int> > digits;

void search(vector<int>& v, int cur, int rest){
	if(cur == 9){
		v[cur] = rest;
		digits.push_back(v);
		return;
	}
	for(int i=0;i<=rest;i++){
		v[cur] = i;
		search(v, cur+1, rest-i);
	}
}

long long perm(const vector<int>& v){
	int sum = 0;
	for(int i=0;i<10;++i) sum += v[i];
	long long res = fact[sum];
	for(int i=0;i<10;i++) res /= fact[v[i]];
	return res;
}

int main(){
	fact[0] = 1;
	for(int i=1;i<=14;i++) fact[i] = i * fact[i-1];
	string S;
	while(cin >> S){
		int n = S.size();
		digits.clear();
		vector<int> v(10, 0);
		search(v, 0, n);
		int sum = 0;
		long long prod = 1;
		for(int i=0;i<n;i++){
			sum += S[i] - '0';
			prod *= S[i] - '0' + 1;
		}
		long long res = 0;
		for(const vector<int>& dig : digits){
			v = dig;
			int s = 0;
			long long p = 1;
			for(int i=0;i<10;i++){
				s += i*v[i];
				for(int j=0;j<v[i];j++) p *= i+1;
			}
			if(s < sum || (s == sum && p < prod)){
				res += perm(v);
			} else if(s == sum && p == prod) {
				for(int i=0;i<n;i++){
					for(int j=0;j<S[i]-'0';j++){
						if(v[j] == 0) continue;
						--v[j];
						res += perm(v);
						++v[j];
					}
					if(v[S[i]-'0'] == 0) break;
					--v[S[i]-'0'];
				}
			}
		}
		cout << res << endl;
	}
}

Measured memory_bytes: 60516
#include <iostream>
#include <stdio.h>
#include <cmath>
using namespace std;

int main(){
    
    int a;
    cin>>a;
    long min=1000001,max=-1000001,ans=0;
    for(int i=0;i<a;i++){
        int b;
        cin>>b;
        if(min>b)min=b;
        if(max<b)max=b;
        ans+=b;
        
    }
    cout<<min<<' '<<max<<' '<<ans<<endl;
}



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

typedef long long ll;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define is(a, b) a == b
#define len(v) ll(v.size())

int dfs(int d,int g,vector<int> p,vector<int> sum){
    //問題d以下の中からg以下にする必要問題数
    if(d<=0){
        return pow(10,9);
    }
    int n=min(g/(100*d),p[d-1]);
    int s=100*d*n;
    if(n==p[d-1]){
        s=sum[d-1];
    }
    if(g>s){
        n+=dfs(d-1,g-s,p,sum);
    }
    return min(n,dfs(d-1,g,p,sum));
}

int main(){
    int d,g;
    cin>>d>>g;
    vector<int> p(d);
    vector<int> c(d);
    vector<int> sum(d);
    for(int i=0;i<d;i++){
        cin>>p[i]>>c[i];
        sum[i]=c[i]+p[i]*(i+1)*100;
    }
    cout<<dfs(d,g,p,sum)<<endl;
}

Measured memory_bytes: 256
/*input
TesT
*/

use std::ascii::AsciiExt;
fn read_line() -> String {
    let mut return_ = format!("");
    std::io::stdin().read_line(&mut return_).ok();
    return_.pop();
    return_
}

fn main() {
    let s = read_line();
    let out = s
        .chars()
        .map(|mut x| match x {
            'a'...'z' => {
                x.make_ascii_uppercase();
                x
            }
            'A'...'Z' => {
                x.make_ascii_lowercase();
                x
            }
            _ => x,
        })
        .collect::<String>();
    println!("{}", out);
}



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


def II(): return int(sys.stdin.readline())


def MI(): return map(int, sys.stdin.readline().split())


def LI(): return list(map(int, sys.stdin.readline().split()))


def main():
    L, R, d = MI()
    ans = 0
    for i in range(L,R+1):
        if i % d == 0:
            ans+=1
    print(ans)
            


# oj t -c "pypy3 main.py"
# acc s main.py -- --guess-python-interpreter pypy
main()


Measured memory_bytes: 61736
#include <iostream>
#include <string>
using namespace std;
typedef long long LL;

int main() {
    int H1,M1,H2,M2,K;
    cin >> H1 >> M1 >> H2 >> M2 >> K;
    
        cout << (((M2-M1)+(H2-H1)*60) - K) << "\n";
}



Measured memory_bytes: 3184
#include <bits/stdc++.h>
using namespace std;
using pp=pair<int,int>;
using ll=long long;

int main() {
  int N, M=0;
  cin >> N;
  vector<int> V(N);
  for (int i=0; i<N; i++) {
    cin >> V[i];
  }
  int m=1000000001, mi;
  while(true) {
    for (int i=0; i<N; i++) {
      if (V[i]==0) {continue;}
      if (m>V[i]) {
        m=V[i];
        mi=i;
      }
    }
    if (m==M) {break;}
    M=m;
    
    for (int i=0; i<N; i++) {
      if (i==mi) {continue;}
      V[i]%=m;
    }
  }
  cout << M << endl;
}

Measured memory_bytes: 3704
#include <iostream>

using namespace std;

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

	for(int i = 0; i <= Y/1000; ++i){
		if(i > N) break;
		for(int j = 0; j <= Y/5000; ++j){
			if(i+j > N) break;
			for(int k = 0; k <= Y/10000; ++k){
				if(i+j+k > N) break;
				if(k * 10000 + j * 5000 + i * 1000 == Y && i+j+k == N){
					cout << k << " " << j << " " << i << endl;
					return 0;
				}
			}
		}
	}

	cout << "-1 -1 -1" << endl;

	return 0;
}


Measured memory_bytes: 256
a = []
a.append(int(input()))
a.append(int(input()))
a.append(int(input()))
a.append(int(input()))
a.append(int(input()))

a = list(reversed(sorted(a, key=lambda x: 100 if x % 10 == 0 else x % 10)))
# print(a)

ans = 0
for i in range(5):
    ans += a[i]
    if ans % 10 != 0 and i != 4:
        ans += 10 - (ans % 10)


print(ans)


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

int res = 0;
vector<int> colors;
vector<vector<pair<int,int>>> g;

void dfs(int v, int p, int pc) {
    int c = 0;
    for (auto e : g[v]) {
        if (e.first == p) {
            continue;
        }
        c++;
        if (pc == c) c++;
        colors[e.second] = c;
        dfs(e.first, v, c);
    }
    res = max(res,c);
}

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

    int n;
    cin >> n;

    colors.resize(n - 1);
    g.resize(n + 1);
    for(int i = 0; i < n - 1; i++){
        int a,b;
        cin >> a >> b;
        g[a].push_back({b,i});
        g[b].push_back({a,i});
    }
    dfs(1, -1, -1);
    cout << res << endl;
    for(int i = 0; i < n - 1; i++) {
        cout << colors[i] << endl;
    }
}


Measured memory_bytes: 7424
#include<stdio.h>

int main(void)
{
  int W,H,x,y,r;

  scanf("%d",&W);
  scanf("%d",&H);
  scanf("%d",&x);
  scanf("%d",&y);
  scanf("%d",&r);

  if(x <= 0 || W <= x || y <= 0 || H <= y) {
    printf("No\n");
  } else if (x < r || y < r || W-x < r || H-y < r) {
    printf("No\n");
  } else {
    printf("Yes\n");
  } 

  return 0;
}

Measured memory_bytes: 584
N = input()
A = list(input().split())
A = list(map(int,A))
A = sorted(A,reverse = True)
a = 0
b = 0
try :
  while len(A) != 0 :
    a += A.pop(0)
    b += A.pop(0)
  print(a-b)
except IndexError :
  print(a-b)



Measured memory_bytes: 9092
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm>
#include<sstream>
#include<complex>
#include<functional>
#include<vector>
#include<map>
#include<queue>
#include<deque>
#include<stack>
#include<set>

using namespace std;
#define endl '\n'
#define eb emplace_back
#define fst first
#define scd second
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define YES(n) cout << ((n) ? "YES" : "NO" ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No" ) << endl

constexpr int MOD = 1000000007;

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

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }

// value
ll N, M;
vi X;

void solve() {

	cin >> N >> M;

	ll shortage = M - N;

	if (shortage <= 0) {
		cout << 0 << endl;
		return;
	}

	X.resize(M);
	vi dis;
	for (int i = 0; i < M; i++) {
		cin >> X[i];
	}
	sort(X.begin(), X.end());
	for (int i = 1; i < M; i++) {
		dis.eb(X[i] - X[i - 1]);
	}

	sort(dis.begin(), dis.end());

	int ans = 0;

	for (int i = 0; i < shortage; i++) {
		ans += dis[i];
	}

	cout << ans << endl;

	return;

}

int main() {

	cin.tie(0);
	ios::sync_with_stdio(false);

	solve();

	return 0;

}

Measured memory_bytes: 1276
// ITP1_9_C Card Game
import java.io.*;

class Main {

   public static void main(String[] args) {
      BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
      int taro = 0;
      int hanako = 0;
      try {
         int n = Integer.parseInt(br.readLine());
         for (int i = 0; i < n; i++) {
            String[] cards = br.readLine().split(" ");
            int compare = cards[0].compareTo(cards[1]);
            if (compare > 0) {
               taro += 3;
            } else if (compare == 0) {
               taro += 1;
               hanako += 1;
            } else if (compare < 0) {
               hanako += 3;
            }
         }
         System.out.println(taro + " " + hanako);
      }
      catch (Exception e) {
         System.err.println(e);
      }
   }
}

Measured memory_bytes: 20188
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps=1e-9;

//// < "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\a.txt" > "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\b.answer"
int main() {
	while (1) {
		int N; cin >> N;
		if (!N)break;
		vector<int>ns(N);
		for (int i = 0; i < N; ++i) {
			string st; cin >> st;
			ns[i] = st.size();
		}
		vector<int>ls(5);
		ls[0] = 5;
		ls[1] = 7;
		ls[2] = 5;
		ls[3] = 7;
		ls[4] = 7;
		for (int i = 0; i < N; ++i) {
			int now = 0;
			int num = 0;
			bool ok = false;
			for (int j = i; j < N; ++j) {
				num += ns[j];
				if (num > ls[now]) {
					ok = false;
					break;
				}
				else if (num == ls[now]) {
					now++;
					if (now == 5) {
						ok = true;
						break;
					}
					else {
						num = 0;
					}
				}
			}
			if (ok) {
				cout << i + 1 << endl;
				break;
			}
		}
	}
	return 0;
}

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

using namespace std;
#define _for(i,j,N) for(int i = (j); i < (N);i++)
#define ALL(x) x.begin(),x.end()
#define LL long long

const int maxd = 100000000;

int d[205][205];

int N,M,R;
vector<int> vr;

void init(){
    _for(i,0,205){
        _for(j,0,205){
            d[i][j] = maxd;
        }
    }
}

int get_int(){
    int x;scanf("%d",&x);return x;
}

int cal(){
    int ret_val = 0;
    _for(i,0,R-1){
        int v = vr[i];
        int w = vr[i+1];
        if(d[v][w] >= maxd) return maxd;
        ret_val += d[v][w];
    }
    return ret_val;
}

int main()
{
    scanf("%d %d %d",&N,&M,&R);
    _for(i,0,R){
        vr.push_back(get_int());
    }

    init();

    _for(i,0,M){
        int v,w,dis;
        v = get_int();w = get_int();dis = get_int();
        d[v][w] = dis;
        d[w][v] = dis;
    }
    _for(k,1,N+1){
        _for(i,1,N+1){
            _for(j,1,N+1){
                d[i][j] = min(d[i][j],d[i][k]+ d[k][j]);
            }
        }
    }

    /*
    _for(i,1,4){
        _for(j,1,4){
            printf("%d ",d[i][j]);
        }
        printf("\n");
    }
    */

    int res = maxd;
    sort(ALL(vr));

    do{
        res = min(res,cal());
    }while(next_permutation(ALL(vr)));


    printf("%d\n",res);
    return 0;
}


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

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

    int n;
    cin >> n;
    int sum = 0;
    for(int i=1; i<=n; i++) sum += i;
    
    cout << sum << endl;

    return 0;
}

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

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

using namespace std;


int main(){
	char x;
	cin>>x;
	x++;
	cout<<x<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.*;
import java.io.IOException;
import java.io.InputStream;
import java.util.StringTokenizer;

public class  Main {

	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		System.out.println(6-sc.nextInt()-sc.nextInt());
	}
	  static class Scanner {
	        StringTokenizer st;
	        BufferedReader br;
	 
	        public Scanner(FileReader r) {
	            br = new BufferedReader(r);
	        }
	 
	        public Scanner(InputStream s) {
	            br = new BufferedReader(new InputStreamReader(s));
	        }
	 
	        public String next() throws IOException {
	            while (st == null || !st.hasMoreTokens())
	                st = new StringTokenizer(br.readLine());
	            return st.nextToken();
	        }
	 
	        public int nextInt() throws IOException {
	            return Integer.parseInt(next());
	        }
	 
	        public long nextLong() throws IOException {
	            return Long.parseLong(next());
	        }
	 
	        public String nextLine() throws IOException {
	            return br.readLine();
	        }
	 
	        public double nextDouble() throws IOException {
	            String x = next();
	            StringBuilder sb = new StringBuilder("0");
	            double res = 0, f = 1;
	            boolean dec = false, neg = false;
	            int start = 0;
	            if (x.charAt(0) == '-') {
	                neg = true;
	                start++;
	            }
	            for (int i = start; i < x.length(); i++)
	                if (x.charAt(i) == '.') {
	                    res = Long.parseLong(sb.toString());
	                    sb = new StringBuilder("0");
	                    dec = true;
	                } else {
	                    sb.append(x.charAt(i));
	                    if (dec)
	                        f *= 10;
	                }
	            res += Long.parseLong(sb.toString()) / f;
	            return res * (neg ? -1 : 1);
	        }
	 
	        public boolean ready() throws IOException {
	            return br.ready();
	        }
	    }
}


Measured memory_bytes: 21076
import sys
## io
IS = lambda: sys.stdin.readline().rstrip()
II = lambda: int(IS())
MII = lambda: list(map(int, IS().split()))
MIIZ = lambda: list(map(lambda x: x-1, MII()))
## dp
INIT_VAL = 0
DP2 = lambda d1, d2: [[INIT_VAL]*d2 for _ in range(d1)]
DP3 = lambda d1, d2, d3: [[[INIT_VAL]*d3 for _ in range(d2)] for _ in range(d1)]
## math
DIVC = lambda x, y: -(-x//y)
DIVF = lambda x, y: x//y

def main():
    x = II(); a = II(); b = II()
    x -= a
    x -= (x//b)*b
    print(x)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include<iostream>
#include<vector>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
using ll = long long;
using P = pair<int, int>;
#include<algorithm>
#include<math.h>
#include<map>

int main() {
	int k, n;
	cin >> k >> n;
	vector<int>a(n);
	rep(i, n) {
		cin >> a[i];
	}
	vector<int>b(n);
	rep(i, n) {
		if (i == n - 1) {
			b[i] = k - a[i] + a[0];
		}
		else {
			b[i] = a[i + 1] - a[i];

		}
	}
	int buffer = b[0];
	rep(i, n) {
		buffer = max(buffer, b[i]);
	}
	//cout << buffer;
	cout << k - buffer;

	return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
signed main(){
  ll n,k,tmp,num;
  cin >> n;
  tmp=1;
  num=1;
  while(num<n){
    tmp++;
    num = (tmp*(tmp+1))/2;
  }
  if(num!=n){
    cout << "No\n";
    return 0;
  }
  cout << "Yes\n";
  set<ll> ans[tmp+1];
  k = tmp+1;
  num = n;
  while(tmp!=0){
    for(ll i=0;i<tmp;i++){
      ans[tmp].insert(num-i);
      ans[tmp-1-i].insert(num-i);
    }
    tmp--;
    num = (tmp*(tmp+1))/2;
  }
  cout << k << endl;
  for(int i=0;i<k;i++){
    cout << k-1 <<" ";
    for(auto it=ans[i].begin();it!=ans[i].end();it++){
      cout << *it<<" ";
    }
    cout << endl;
  }
}


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

int main(){
    int n, k, a[100000];
    while( true ){
        cin >> n >> k;
        if( n == 0 && k == 0 ) break;
        for(int i = 0; i < n; i++){
            cin >> a[i];
        }
        int s = 0, max;
        for(int i = 0; i < k; i++){
            s += a[i];
        }
        max = s;
        for(int i = k; i < n; i++){
            s += ( -a[i-k] + a[i]);
            if( s > max ) max = s;
        }
        cout << max << endl;
    }
    return 0;
}

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

const int N = 100005;
const int mod = 1e9 + 7;

int n, x[N];
int cnt[N];

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    cin >> n;
    for (int i = 1; i <= n; ++i) cin >> x[i];

    int cannot = 0;
    for (int i = 1; i <= n; ++i) {
        cnt[cannot]++;
        // update cannot
        if (x[i] < 2 * (i - cannot) - 1) ++cannot;
    }

    int cur = 0;
    int res = 1;
    for (int i = 0; i < n; ++i) {
        cur += cnt[i];
        res = 1LL * res * (cur - i) % mod;
    }

    cout << res << endl;
}

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

using namespace std;

#define f first
#define s second
#define pub push_back
#define pob pop_back

typedef vector<int> vi;
typedef vector<vi> graf;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<vii> wgraf;

typedef vector<double> vd;
typedef pair<double,double> dd;
typedef vector<dd> vdd;

typedef uint64_t ui64;

int main(){

	int n;
	cin >> n;

	vi h(n);
	for(auto &x: h)
		cin >> x;

	int max_times = -1;
	int times = 0;

	for(int i = 0; i < n-1; i++){

		if(h[i] >= h[i+1]){
			times++;
		}else{
			max_times = max(max_times,times);
			times = 0;
		}

	}

	max_times = max(max_times, times);

	cout << max_times << endl;

	return 0;
}


Measured memory_bytes: 640
#include <stdio.h>
int main (){

//SEÇÃO DE DECLARAÇÃO
int A;
int B;

//SEÇÃO DE COMANDOS 
scanf ("%d %d",&A,&B);

if (A>8 || B>8){
    printf (":(");
    return 0;
}

printf ("Yay!");

return 0;
}

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

using namespace std;

#define lli unsigned long long int
#define REP(i,s,l) for(lli i=s;i<l;i++)
#define DEBUG 0
#define INF (1LL<<50)
#define MOD 1000000007

signed main(){

	string str;
	cin>>str;

	lli mae = (str.at(0)-'0')*10 + (str.at(1)-'0');
	lli usiro = (str.at(2)-'0')*10 + (str.at(3)-'0');

	/*maeがYYの可能性をなくす*/
	if(mae == 0 || mae > 12){
		/*usiroもYYではないとありえない*/
		if(usiro == 0 || usiro > 12)cout<<"NA"<<endl;
		else {/*usrioがYYならMMYY*/
			cout<<"YYMM"<<endl;
		}
	}
	else{/*maeがYYの可能性がある*/
		/*usiroがYYではないならYYMM*/
		if(usiro == 0 || usiro>12)cout<<"MMYY"<<endl;
		else cout<<"AMBIGUOUS"<<endl;
	}
	return 0;
}

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

#ifdef HOME
#define db(x) cerr << #x << " = " << x << endl
#define db3(x, y, z) cerr << "(" << #x << ", " << #y << ", " << #z << ") = (" << x << ", " << y << ", " << z << ")" << endl
#define db2(x, y) cerr << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")" << endl
#define dbv(a) cerr << #a << " = "; for (auto xxx: a) cerr << xxx  << " "; cerr << endl
#else
#define db(x) ;
#define db3(x, y, z) ;
#define db2(x, y) ;
#define dbv(a) ;
#endif

using namespace std;
typedef long long ll;
typedef double dbl;


const int INF = 1.01e9;

int subsolve(vector<int> a) {
    multiset<int> st;
    for (int x : a) st.insert(x);

    int ans = 0;
    while (!st.empty()) {
        int x = *st.rbegin();
        st.erase(st.find(x));
        int pw = 1;
        while (pw <= x) pw *= 2;
        int y = pw - x;

        auto it = st.find(y);
        if (it != st.end()) {
            st.erase(it);
            ans++;
        }
    }
    return ans;
}

int solve(vector<int> a) {
    vector<vector<int>> b(50);
    for (int x : a) {
        int y = 0;
        while (x % 2 == 0) {
            x /= 2;
            y++;
        }
        b[y].push_back(x);
    }
    int ans = 0;
    for (auto v : b) ans += subsolve(v);
    return ans;
}

int main() {
#ifdef HOME
    assert(freopen("in", "r", stdin));
#endif

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

        printf("%d\n", solve(a));
    }

#ifdef HOME
    cerr << "time: " << clock() * 1.0 / CLOCKS_PER_SEC << endl;
#endif
}


Measured memory_bytes: 13560
#pragma comment(linker, "/STACK:500000000")
#define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <set>
#include <stack>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <string.h>
#include <time.h>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;

#define y0 y0ChloeGraceMoretz
#define y1 y1ChloeGraceMoretz
typedef long long ll;
typedef unsigned long long ull;
int nextInt() { int n; scanf("%d", &n); return n; }
ll nextLong() { ll n; scanf("%lld", &n); return n; }
const double PI = acos(-1.0);
const double EPS = 1e-9;
const int INF = (int)2e9;
const int MOD = (int)1e9 + 7;

int a[(int)1e5 + 9];

int main() {
	//freopen("in.txt", "rt", stdin);
	//freopen("out.txt", "wt", stdout);
	int n;
	scanf("%d", &n);
	for (int i = 1; i <= n; ++i) {
		scanf("%d", &a[i]);
	}
	int res = 0;
	for (int i = 1; i <= n; ++i) {
		if (i < a[i] && a[a[i]] == i) {
			++res;
		}
	}
	printf("%d\n", res);
	return 0;
}

Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+10;
char s[N];
int main()
{
    int n,Zero , One ;
    Zero = One = 0;
    scanf("%s",s);
    n=strlen(s);
    for(int i=0;i<n;i++){
        if(s[i]=='1'){
            One ++;
        }else {
            Zero ++;
        }
    }
    int ans=min(One,Zero);
    printf("%d\n",ans*2);
    return 0;
}


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

int main(void){
	stack<int> a;
	int n;
	string b;
	cin>>n;
while(n--){
	cin>>b;
	if(b=="A"){
		a.push(1);
	}else{
		if(a.empty()){
			cout<<"NO"<<endl;
			return 0;
		}else a.pop();
	}
}
	if(a.empty())cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
	return 0;
}

Measured memory_bytes: 3164
use proconio::*;
use std::cmp::max;
use std::collections::BinaryHeap;

#[fastout]
fn main() {
    input! {
        d: usize,
        c: [i64; 26],
        s: [[i64; 26]; d],
    };

    let mut lasts = [-1; 26];
    let mut t = vec![26; d];
    let depth = 13;
    for i in 0..d {
        let mut max_score = -10000000;
        for j in 0..26 {
            let tmp = search(i, j, &c, &s, &mut lasts, depth, d, 0, 7);
            if tmp > max_score {
                max_score = tmp;
                t[i] = j;
            }
        }
        lasts[t[i]] = i as i64;
    }

    for &a in &t {
        println!("{}", a + 1);
    }
}

fn calc_score(i: usize, j: usize, c: &Vec<i64>, s: &Vec<Vec<i64>>, lasts: &mut [i64; 26]) -> i64 {
    let mut res = s[i][j];
    let tmp = lasts[j];
    lasts[j] = i as i64;

    for j in 0..26 {
        let i = i as i64;
        let last = lasts[j];
        res -= c[j] * (i - last);
    }

    lasts[j] = tmp;
    res
}

fn search(
    i: usize,
    t: usize,
    c: &Vec<i64>,
    s: &Vec<Vec<i64>>,
    lasts: &mut [i64; 26],
    depth: usize,
    d: usize,
    cscore: i64,
    l: usize,
) -> i64 {
    if depth == 0 || i == d - 1 {
        return calc_score(i, t, &c, &s, lasts) + cscore;
    }

    let l = max(1, l - 1);
    let mut max_score = -1000000;
    let tmp_last = lasts[t];
    lasts[t] = i as i64;
    let tmp_score = calc_score(i, t, &c, &s, lasts);
    let mut cands = BinaryHeap::new();
    cands.reserve(26);
    for j in 0..26 {
        let tmp_score = calc_score(i + 1, j, &c, &s, lasts);
        cands.push((tmp_score, j));
    }
    let w = if l > 1 { 2 } else { 1 };
    for &(_, j) in cands.iter().take(w) {
        let tmp = search(i + 1, j, &c, &s, lasts, depth - 1, d, cscore + tmp_score, l);

        if tmp > max_score {
            max_score = tmp;
        }
    }

    lasts[t] = tmp_last;
    max_score + cscore
}


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

int main() {
  int s;
  bool is_yymm,is_mmyy;
  cin >> s;
  is_yymm=s%100>0&&s%100<13; 
  is_mmyy=s/100>0&&s/100<13;
  if(is_yymm&&is_mmyy) cout << "AMBIGUOUS" << endl;
  else if(is_yymm) cout << "YYMM" << endl;
  else if(is_mmyy) cout << "MMYY" << endl;
  else cout << "NA" << endl;
}

Measured memory_bytes: 256
N, K = map(int, input().split())

def sigma(N, k):
  a = (k*(k+1)*(2*k+1)//6)%(10**9+7)
  b = (k*(k+1)//2)%(10**9+7)
  c = k
  return -a + (N+1)*b + c

print((sigma(N,N+1)-sigma(N, K-1))%(10**9+7))

Measured memory_bytes: 9132
#include <bits/stdc++.h>
#include <variant>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/adaptor/indexed.hpp>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x) begin(x),end(x)

using namespace std;
using namespace boost::adaptors;
using namespace std::string_literals;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;
using boost::irange;

ll solve(ll n, ll a, ll b, ll c, ll d, unordered_map<ll,ll>& memo) {
  if (memo.count(n)) return memo.at(n);
  if (n == 0) return 0;
  if (n == 1) return d;
  ll ans = 3e12;
  ll div[3] = {2,3,5};
  ll cst[3] = {a,b,c};
  REP(i,3) {
    ll r = n % div[i];
    ans = min(ans, solve(n / div[i], a, b, c, d, memo) + d * r + cst[i]);
    r = div[i] - r;
    ll nx = n / div[i] + 1;
    if (nx >= n) continue;
    ans = min(ans, solve(n / div[i] + 1, a, b, c, d, memo) + d * r + cst[i]);
  }
  if (n <= 3e9) {
    ans = min(ans, d * n);
  }
  memo[n] = ans;
  return ans;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int t;
  cin>>t;
  REP(casenum,t) {
    ll n,a,b,c,d;
    cin>>n>>a>>b>>c>>d;
    unordered_map<ll,ll> memo;
    ll ans = solve(n, a, b, c, d, memo);
    cout<<ans<<endl;
  }
  return 0;
}


Measured memory_bytes: 4440
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<map>
#include<tuple>


#define MOD 1000000007
#define rep(i,k,N) for(int i=k;i<N;i++)
#define MP make_pair
#define MT make_tuple //tie,make_tuple は別物
#define PB push_back

typedef long long ll;

using namespace std;

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

int main(){
    priority_queue<ll> P;
    ll N,M;
    cin>>N>>M;
    vector<ll> A(N);
    rep(i,0,N){
        cin>>A[i];
        P.push(A[i]);
    }

    rep(i,0,M){
        P.push(P.top()/2);
        P.pop();
    }

    ll ans=0;
    rep(i,0,N){
        ans+=P.top();
        P.pop();
    }

    cout<<ans<<endl;


    return 0;
}

Measured memory_bytes: 2168
#include <bits/stdc++.h>
#define pi 3.14159
using namespace std;

int main()
 {
 	int i,n;
 	string s,t;
 	cin>>s;
 	n=s.length();
 	for(i=0;i<n;i++)
 	{
 		if(s[i]=='0')
 			t.push_back('0');
 		if(s[i]=='1')
 			t.push_back('1');
 		
 		if(s[i]=='B')
 			{
 				if(t.length()>0)
				 		
 				t.pop_back();
			 }
	 }
	 cout<<t<<endl;
 }

Measured memory_bytes: 3600
/*


*/
#include <cstdio>
#include <cctype>
#include <algorithm>
#define gc() getchar()
#define MAXIN 300000
typedef long long LL;
const int N=2e5+5;

char IN[MAXIN],*SS=IN,*TT=IN;

inline int read()
{
	int now=0;register char c=gc();
	for(;!isdigit(c);c=gc());
	for(;isdigit(c);now=now*10+c-48,c=gc());
	return now;
}

int main()
{
	int n=read(); LL f[5]={0};
	for(int i=1; i<=n; ++i)
	{
		int ai=read();
		LL mn=f[0]; f[0]=f[0]+ai;
		mn=std::min(mn,f[1]), f[1]=mn+(ai?ai&1:2);
		mn=std::min(mn,f[2]), f[2]=mn+(ai?ai+1&1:1);
		mn=std::min(mn,f[3]), f[3]=mn+(ai?ai&1:2);
		mn=std::min(mn,f[4]), f[4]=mn+ai;
	}
	printf("%lld\n",std::min(f[2],std::min(f[3],f[4])));

	return 0;
}

Measured memory_bytes: 128
// 失敗するからこそ そこから立ち向かって行く強さがあってそんな強さが本当の強さだと私は思うから
// ぜったいあきらめない
#include<bits/stdc++.h>
using namespace std;

#if defined(DAIJOBU)
#include "/home/ichigo/debug.hpp"
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define deb(x...)
#endif

#define fi first
#define se second
#define FIO {ios::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);}
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef long double ld;

const int mod = 1000000007;
struct mint {
    ll x;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    mint inv() const {
        return pow(mod-2);
    }
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res/=a;
    }
};
struct combination {
    vector<mint> fact, ifact;
    combination(int n):fact(n+1),ifact(n+1) {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
    }
    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n]*ifact[k]*ifact[n-k];
    }
};

int main(){
	FIO
	
	int n;cin >> n;
	vector<int> nums;
	forn(i, n){int x;cin >> x;nums.emplace_back(x);}
	sort(all(nums));
	long long diff = LLONG_MAX;
	int el, req = nums[n -1] / 2;
	forn(i, n - 1){
		if(abs(req - nums[i]) < diff){
			diff = abs(req - nums[i]);
			el = nums[i];
		}
	}
	req= nums[n - 1] / 2 + 1;
	forn(i, n - 1){
		if(abs(req - nums[i]) < diff){
			diff = abs(req - nums[i]);
			el = nums[i];
		}
	}
	cout << nums[n - 1] << " " << el;
	return 0;
}


Measured memory_bytes: 892