akhauriyash/Code-Regression huggingface dataset:
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


n,k = map(int, input().split())
a = list(map(int, input().split()))

dp = [[0]*(k+1) for _ in range(n+1)]
cum = [1]*(k+2)
M = 10**9+7
for i in range(n+1):
    dp[i][0] = 1
cum[0] = 0
for i in range(1,n+1):
    current = [0]*(k+2)
    for j in range(k+1):
#         print(i,j,k,a[i])
        dp[i][j] = (cum[j+1] - cum[max(0, j-min(k,a[i-1]))]) % M
        current[j+1] = (current[j] + dp[i][j])%M
    cum = current
print(dp[n][k])

Measured memory_bytes: 219160
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <unordered_map>
#include <stack>
#include <queue>
#include <utility>

#include <cassert>
#include <cmath>
#include <cstdio>

using namespace std;

#define fi first
#define se second
#define mkp make_pair
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define FOR(i,a,b) for(ll i=(a); i < (b); i++)
#define RFOR(i,a,b) for(ll i=(b)-1; i >= (a); i--)
#define rep(i,n) FOR(i,0,(n))
#define rrep(i,n) RFOR(i,0,(n))

vector<vector<pii> > comb;
vector<pii> tempv;
bool f[15];

int H, W;
vector<string> S;

void foo() {
	int a = -1;
	rep(i,W) {
		if(!f[i]) {
			a = i;
			f[i] = true;
			break;
		}
	}
	if(a < 0) {
		comb.push_back(tempv);
		return;
	}
	FOR(i,a+1,W) {
		if(!f[i]) {
			tempv.push_back(pii(a,i));
			f[i] = true;
			foo();
			tempv.pop_back();
			f[i] = false;
		}
	}
	f[a] = false;
}

bool check(int c, const vector<pii> & p) {
	for(int i = 0; i < (H%2 ? H : 1); i++) {
		vector<int> v;
		rep(k,H) v.push_back(k);
		if(H%2) {
			bool center_f = true;
			swap(v[0], v[i]);
			rep(k,p.size()) {
				if(S[i][p[k].fi] != S[i][p[k].se]) {
					center_f = false;
				}
			}
			if(!center_f) continue;
		}

		bool res = true;
		for(int j = H%2; j < H && res; j += 2) {
			bool found = false;
			for(int j_ = j+1; j_ < H && res; j_++) {
				bool flg = true;
				for(int k = 0; k < p.size(); k++) {
					if(S[v[j]][p[k].fi] != S[v[j_]][p[k].se]
							|| S[v[j]][p[k].se] != S[v[j_]][p[k].fi]) {
						flg = false;
					}
				}
				if(flg && (c < 0 || S[v[j]][c] == S[v[j_]][c])) {
					swap(v[j+1], v[j_]);
					found = true;
					break;
				}
			}
			if(!found) res = false;
		}
		if(res) return true;
	}
	return false;
}

int main() {
	cin >> H >> W;
	S.resize(H);
	rep(i,H) {
		cin >> S[i];
	}
	for(int i = 0; i < (W%2 ? W : 1); i++) {
		comb.clear();
		if(W%2) f[i] = true;
		foo();
		if(W%2) f[i] = false;
		rep(j,comb.size()) {
			if(check(W%2 ? i : -1, comb[j])) {
				cout << "YES" << endl;
				return 0;
			}
		}
	}
	cout << "NO" << endl;
	return 0;
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
#include <math.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = 0; i <= (n); i++)
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
const ll INF = 1LL<<60;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using Graph = vector<vector<int>>;

int main(){
    string S, T; cin >> S >> T;

    bool isOK = true;
    rep(i,S.size()){
        if (S[i] != T[i]) isOK=false;
    }

    if ((int)S.size() + 1 != (int)T.size()){
        isOK=false;
    }

    if (isOK) cout << "Yes" << endl;
    else cout << "No" << endl;

}

Measured memory_bytes: 3596
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <unordered_map>
#include <climits>
#include <set>
#include <unordered_set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <complex>
#include <regex>
#include <locale>
#include <random>
#include <type_traits>

using namespace std;

#define SHOW_VECTOR(v) {std::cerr << #v << "\t:";for(const auto& xxx : v){std::cerr << xxx << " ";}std::cerr << "\n";}
#define SHOW_MAP(v){std::cerr << #v << endl; for(const auto& xxx: v){std::cerr << xxx.first << " " << xxx.second << "\n";}}

using LL = long long;

//~~~~~~~~~~~~~~~~~~~~~_(＾～＾ ｣ ∠)_~~~~~~~~~~~~~~~~~~~~~

constexpr LL INF = 1e10;

int main() {

    int N;
    cin >> N;

    vector<LL> A(N);
    for (int i = 0; i < N; i++) cin >> A[i];

    reverse(A.begin(), A.end());

    vector<LL> dp(N, INF);

    for (int i = 0; i < N; i++) {
        auto it = lower_bound(dp.begin(), dp.end(), A[i] + 1);
        *it = A[i];
    }

    cout << lower_bound(dp.begin(), dp.end(), INF) - dp.begin();

}

































Measured memory_bytes: 1792
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        n: usize
    }
    println!("{}", n * n);
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n[100100];
    int N;
    cin >> N;
    int i = 1;
    while(N --)
    {
        cin >> n[i];
        i ++;
    }
    int m;
    cin >> m;
    while(m --)
    {
        int p, x;
        cin >> p >> x;
        int c;
        c = n[p];
        n[p] = x;
        int sum = 0;
        for(int j = 1; j < i; j ++)
        {
            sum += n[j];
        }
        cout << sum <<endl;
        n[p] = c;
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
using namespace std;
int main(){
    int N,M=0,sum=0;
    cin >> N;
    vector<int> a(N);
    for(int i=0;i<N;i++){
        cin >> a[i];
        M=max(a[i],M);
        sum+=a[i];
    }
    cout << sum-(M/2) << endl;
    return 0;
}

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

using namespace std;

#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define REPO(i,n) for(int (i)=1; (i)<=(int)(n); (i)++)
#define SZ(v) ((int)(v).size())
#define ALL(v) (v).begin(),(v).end()
#define one first
#define two second
typedef long long ll;
typedef pair<int, int> pi;
const int INF = 0x3f2f1f0f;
const ll LINF = 1ll * INF * INF;

const int MAX_N = 1e5 + 100, MOD = 1e9 + 7;

int N, M, F[MAX_N];
int main() {
	cin >> N >> M;
	if(N > M) swap(N, M);
	if(N+1 < M) {
		printf("0\n");
	} else {
		F[0] = 1;
		for(int i=1; i<=M; i++) F[i] = 1ll * F[i-1] * i % MOD;
		int ans = 1ll * F[M] * F[N] % MOD;
		if(N == M) ans = 1ll * 2 * ans % MOD;
		printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 640
#include <stdio.h>
int main(void){
    
    int a,b,c;
    scanf("%d %d %d",&a,&b,&c);
    
    int ans=0,temp;
    
    temp = a*10+b+c;
    if(temp > ans) ans = temp;
    
    temp = a+b*10+c;
    if(temp > ans) ans = temp;
    
    temp = a+b+c*10;
    if(temp > ans) ans = temp;
    
    printf("%d",ans);
    
    
    return 0;
}


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

int main() {
  int n;
  cin >> n;
  
  vector<int> vec(n);
  
  for(int i = 0; i < n; i++) {
    cin >> vec.at(i);
  }

  int S = 0;
  int A = 1;
  while(S < n) {
    A = vec.at(A-1);

    S++;
    if(A == 2){
      break;
    }
  }
  if(A != 2){
    cout << -1 << endl;
  }
  else{
    cout << S << endl;
  }
}


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

using namespace std;

using ll = long long;

int main() {
  ll n, k;
  cin >> n >> k;
  ll a = n / k;
  ll ans = a * a * a;
  if (k % 2) {
    cout << ans << endl;
  } else {
    ll b = a + (n % k >= k / 2);
    cout << ans + b * b * b << endl;
  }
}

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

    

int main(){
  ll N,ans=0;
  cin >> N;
  vector<vector<ll>> dp(10, vector<ll>(10,0));
  rep(i,N){
    ll x,y;
    y=(i+1)%10;
    if((i+1)/100000>0){
      x=(i+1)/100000;
    }else if((i+1)/10000>0){
      x=(i+1)/10000;
    }else if((i+1)/1000>0){
      x=(i+1)/1000;
    }else if((i+1)/100>0){
      x=(i+1)/100;
    }else if((i+1)/10>0){
      x=(i+1)/10;
    }else{
      x=i+1;
    }
    dp.at(x).at(y)++;
  }
  for(ll i=1;i<10;i++){
    for(ll j=1;j<10;j++){
      ans+=dp.at(i).at(j)*dp.at(j).at(i);
    }
  }
  cout << ans << endl;
    
  
}


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

bool check(char* a,char* b);

int main(){
    int N,M;
    char s[100][11],t[100][11];
    cin >> N;
    for(int i=0; i<N; i++)
    cin >> s[i];
    cin >> M;
    for(int i=0; i<M; i++)
    cin >> t[i];

    int ans=0;
    for(int i=0; i<N; i++){
        int tmp=0;
        for(int blue=0; blue<N; blue++){
            int j=check(s[i],s[blue]);
            tmp+=j;
        }
        for(int red=0; red<M; red++){
            int j=check(s[i],t[red]);
            tmp-=j;
        }
        if(tmp>ans)
        ans=tmp;
    }

    cout << ans << "\n";
    return 0;
}

bool check(char* a,char* b){
    int count=0;
    for(int i=0; count!=2; i++){
        if(*(a+i)!=*(b+i))
        return false;
        if(*(a+i)=='\0')
        count++;
        if(*(b+i)=='\0')
        count++;
    }
    return true;
}

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

typedef long lint;
typedef long long llint;
typedef pair<int, int> pint;
typedef pair<long long, long long> pllint;

// static const int MAX = 1e6;
// static const int NIL = -1;
// static const llint INF = 1<<21;
// static const llint MOD = 1e9 + 7;

bool compPair(const pint& arg1, const pint& arg2) { return arg1.first > arg2.first; }
template<class T> void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> void chmin(T& a, T b) { if (a > b) { a = b; } }

int main(void) {
    int x, y, z;
    cin >> x >> y >> z;

    if(x<2*y+3*z) cout << 1 << endl;
    else {
        int ans = 1;
        int l = 2*y+3*z;
        bool flg = true;
        while(flg) {
            ans++;
            l += y + z;
            if(x<l) flg = false;
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 256
from itertools import product

N=int(input())
datas=[]
for i in range(N):
    A=int(input())
    for j in range(A):
        x,y=map(int,input().split())
        datas.append((i,x-1,y))

#print(datas)

ans=0
for i in product([0,1],repeat=N):
    ok=True
    for j in datas:
        if (i[j[0]]==1 and i[j[1]]!=j[2]):
            ok=False
            break
    if ok:
        ans=sum(i)
print(ans)

Measured memory_bytes: 9076
N = int(input())
a = list(map(int, input().split()))
ans = 0
dic = {}

for i in range(N):
    if a[i] in dic:
        dic[a[i]] += 1
    else:
        dic[a[i]] = 1

for key, value in dic.items():
    if key > value:
        ans += value
    if key < value:
        ans += value - key

print(ans)


Measured memory_bytes: 17780
n=int(input())
s=[]
for i in range(n):
        s.append(input())
m=int(input())
t=[]
for i in range(m):
        t.append(input())

ans=0
for w in s:
    now=0
    for blue in s:
        if w==blue:
            now+=1

    for red in t:
        if w==red:
            now-=1
    ans=max(ans,now)
print(ans)

Measured memory_bytes: 38896
#include <bits/stdc++.h>
#define IO_OP std::ios::sync_with_stdio(0); std::cin.tie(0);
#define F first
#define S second
#define V vector
#define PB push_back
#define MP make_pair
#define EB emplace_back
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << #x << " is " << x << endl

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
typedef V<int> vi;

const int INF = 1e9 + 7;

V<pi> v[16];

signed main()
{
	IO_OP;
	
	int n;
	cin >> n;
	for(int i=0;i<n;i++) {
		int t;
		cin >> t;
		for(int j=0;j<t;j++) {
			int x, y;
			cin >> x >> y;
			v[i].EB(x-1, y);
		}
	}
	int ans = 0;
	for(int i=0;i<(1<<n);i++) {
		bool ok = true;
		for(int j=0;j<n;j++) {
			if(i >> j & 1) {
				for(pi p:v[j]) {
					int x = p.F, y = p.S;
					if((i >> x & 1) != y) {
						ok = false;
					}
				}
			}
		}
		if(ok) ans = max(ans, __builtin_popcount(i));
	}
	cout << ans << endl;

}



	

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())//vectorの降順ソート
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;
typedef tuple<ll, ll, ll> T;

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s,t;
    cin>>s>>t;
    vector<string> S;
    for(int i=0;i<s.size()-t.size()+1;i++){
        string x = s;
        bool flg=true;
        for(int j=0;j<t.size();j++){
            if(x[i+j]!='?' && x[i+j]!=t[j]){
                flg=false;
                break;
            }
        }
        if(flg){
            for(int j=0;j<t.size();j++) x[i+j]=t[j];
            replace(x.begin(),x.end(),'?','a');
            S.push_back(x);
        }
    }
    if(!S.size()) cout<<"UNRESTORABLE"<<endl;
    else{
        string ans = S[0];
        for(int i=1;i<S.size();i++){
            if(ans>S[i]) ans=S[i];
        }
        cout<<ans<<endl;
    }
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {
  public static void main(String[] args) {
    Scanner stdInt = new Scanner(System.in);

  String[] ans = new String[50];
  int x = 0;
    while(true) {
      int m, f, r;
      m = stdInt.nextInt();
      f = stdInt.nextInt();
      r = stdInt.nextInt();
      if (m == -1 && f == -1 && r == -1) break;
      if (m == -1 || f == -1) {
        ans[x] = "F";
      } else if (m + f >= 80) {
        ans[x] = "A";
      } else if (m + f >= 65) {
        ans[x] = "B";
      } else if (m + f >= 50) {
        ans[x] = "C";
      } else if (m + f >= 30 && r >= 50) {
        ans[x] = "C";
      } else if (m + f >= 30 && r < 50) {
        ans[x] = "D";
      } else {
        ans[x] = "F";
      }
     x++;
    }

    for (int i = 0; i < x; i++) {
      System.out.println(ans[i]);
    }

  }
}


Measured memory_bytes: 26344
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "math.h"
#include "utility"
#include "string"
#include "map"
#include "unordered_map"
#include "iomanip"
#include "random"

using namespace std;
const long long int MOD = 1000000007;

int N;
int num[200000];
int ans = 1;
int up=-1;

int main(){
	cin >> N;
	for (int i = 0; i < N; i++)cin >> num[i];
	for (int i = 0; i < N - 1; i++) {
		if (up == -1) {
			if (num[i] < num[i + 1])up = 1;
			if (num[i] > num[i + 1])up = 0;
		}
		else if (up==1) {
			if (num[i] > num[i + 1]) {
				ans++;
				up = -1;
			}
		}
		else if(up==0) {
			if (num[i] < num[i + 1]) {
				ans++;
				up = -1;
			}
		}
	}
	cout << ans << endl;
	return 0;
}


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

using namespace std;

#define G getline
#define SZ size()
#define C clear()
#define B begin()
#define F front()
#define T top()
#define E end()
#define EM empty()
#define V vector
#define Q queue
#define DQ deque
#define PQ priority_queue
#define ST stack
#define FI first
#define SE second
#define PI acos(-1)
#define PS push
#define PP pop()
#define PSF push_front
#define PSB push_back
#define PPF pop_front()
#define PPB pop_back()
#define LL long long
#define ULL unsigned long long
#define PII pair<int,int>
#define PSI pair<string,int>
#define PIS pair<int,string>
#define PLI pair<LL,int>
#define PLL pair<LL,LL>
#define MII map<int,int>
#define MSI map<string,int>
#define MIS map<int,string>
#define MLI map<LL,int>
#define FAST() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)





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






int main()
{
    FAST();
    int ans=0;
    string s,t;
    cin >> s >> t;
    for(int i=0;i<s.size();i++)
    {
        if(s[i] != t[i])++ans;
    }
    cout << ans;
    return 0;
}


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

/*
dp[i][j]:コインをj枚投げた時、そのうちi枚が表になる確率
dp[1][1]=p1
dp[0][1]=1-p1

dp[i][j] = dp[i-1][j-1]*pi + dp[i][j-1]*(1-pi)
ただしdp[0][j]=dp[0][j-1]*(1-pi)
dp[j][j]=dp[j-1][j-1]*pj
*/

void solve(){
    int n;
    cin >> n;
    double p[n+10];
    rep(i,n){
        cin >> p[i]; 
    }

    double dp[n+10][n+10];
    dp[1][1]=p[0];
    dp[0][1]=1-p[0];
    for(int j=2; j<=n+1; j++){
        for(int i=0; i<=j; i++){
            if(i==0) dp[i][j]=dp[0][j-1]*(1-p[j-1]);
            else if (i==j) dp[i][j]=dp[j-1][j-1]*p[j-1];
            else dp[i][j] = dp[i-1][j-1]*p[j-1] + dp[i][j-1]*(1-p[j-1]);
        }
    }

    double ans = 0;
    for(int i=(n+1)/2; i<=n; i++){
        ans += dp[i][n];
    }
    cout << setprecision(10) << ans << endl;
}

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


Measured memory_bytes: 70656
n=int(input())
a=26
b=1
import math
import string
array=list(string.ascii_lowercase)
while n>a:
  b+=1
  a+=26**b
if b==1:
  print(array[n-1])
else:
  c=b-1
  d=n-a
  brray=[0]
  crray=[d]
  for i in range(c):
    brray.append(math.ceil(crray[i]/(26**(c-i))))
    crray.append(crray[i]%(26**(c-i)))
  ans=array[brray[1]-1]
  if c>1:
    for j in range(2,b):
      ans=ans+array[brray[j]-1]
  ans=ans+array[crray[c]-1]
  print(ans)

Measured memory_bytes: 9912
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
typedef pair<ll, ll> PLL;
typedef vector<int> VI;
typedef vector<char> VC;
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<ll> VLL;
typedef vector<PLL> VP;
const static int INF = 1000000000;
const static int MOD = 1000000007;
const int dx[4]={1, 0, -1, 0};
const int dy[4]={0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define rep(i,n) for (ll i=0; i<(ll)(n); i++)
#define repd(i,n) for (ll i=n-1; i>=0; i--)
#define rept(i,m,n) for(ll i=m; i<n; i++)
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define PF push_front
#define PB push_back
#define SORT(V) sort((V).begin(), (V).end())
#define RVERSE(V) reverse((V).begin(), (V).end())
#define paired make_pair
#define PRINT(V) for(auto v : (V)) cout << v << " "
//charを整数に
int ctoi(char c) { if (c >= '0' && c <= '9') { return c - '0'; } return 0; }
// 累積和 for (int i = 0; i < N; ++i) s[i+1] = s[i] + a[i]; 
void cum_sum(int N,vector<double> a, vector<double> &s){ for(int i=0; i<N; i++){ s[i+1]=s[i]+a[i];}}
//ユークリッドの控除法
ll gcd(ll a,ll b){
    if(b == 0) return a;
    return gcd(b,a%b);
}
//最小公倍数
ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b; // Be careful not to overflow
}
//素数判定
bool is_prime(long long n) {
    if (n <= 1) return false;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p == 0) return false;
    }
    return true;
}
int getdigit(ll num){
    unsigned digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}
//空白文字も入力 getline(cin, S);
//桁数指定 setprecision

int main()
{
    ll N, M;
    cin >> N >> M;
    VLL A(N);
    rep(i,N){
        cin >> A[i];
    }
    vector<pair<ll,ll>> F;
    ll res=0;
    rep(i,M){
        ll b, c;
        cin >> b >> c;
        res+=b;
        F.PB(make_pair(c,b));
    }
    if(res<=N){
        res=res;
    }
    else{
        res=N;
    }
    sort(all(F));
    reverse(all(F));
    VLL S;
    bool judge=false;
    while(1){
        for(int i=0; i<M; i++){
            for(int j=0; j<F[i].S; j++){
                S.PB(F[i].F);
                if(S.size()==res){
                    judge=true;
                    break;
                }
            }
            if(judge) break;
        }
        if(judge) break;
    }
    //cout << S.size() << endl;
    sort(all(A));
    reverse(all(A));
    ll counter_a=0;
    ll counter_s=0;
    ll sum=0;
    rep(i,N){
        if(A[counter_a]>=S[counter_s]){
            sum+=A[counter_a];
            counter_a++;
            continue;
        }
        if(A[counter_a]<=S[counter_s] && counter_s<S.size()){
            sum+=S[counter_s];
            counter_s++;
            continue;
        }
    }
    cout << sum << endl;
}

Measured memory_bytes: 7420
#include<iostream>
int main(){
  int n;
  std::cin>>n;
  std::cout<<(n%10==2||n%10==4||n%10==5||n%10==7||n%10==9?"hon"
             :n%10==0||n%10==1||n%10==6||n%10==8?"pon"
             :"bon")<<std::endl;
}

Measured memory_bytes: 3592
#include <iostream>
using namespace std;
int main(void){
    int h,w;
    while(true){
        cin >> h>>w;
        if(h==0&&w==0)break;
        if(h<1||w<1)continue;
        
        for(int c=0;c<h;c++){
            for(int r=0;r<w;r++){
                if((r+c)%2==0){
                    cout << "#";
                }else{
                    cout << ".";
                }
            }
            cout << endl;
        }
        cout << endl;
    }
    return 0;
}

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

bool check(string &s, string &t){

    int n = s.length();

    int m = 0;
    int j = 0;
    for(int i = 0; i < n; ++i){
        if(s[i] == t[0]){
            m = max(m, 1);
            for(int k = 0; k < n; ++k){
                if(s[i + k] != t[k]) break;
                m = max(m, 1 + k);
            }
        }
    }

   // cout << m << endl;
    cout << n + n - m << endl;

    return true;
}


int main(){
    string s,t;
    int n;
    cin >> n;
    cin >> s >> t;
    check(s,t);
    return 0;
}





Measured memory_bytes: 384
#include <iostream>
using namespace std;
int main(){
    int n, k;
    cin >> n >> k;
    int d, a[n], b, t;
    t = 0;
    for(int i=0;i<n;i++){
        a[i] = 0;
    }
    for(int i=0;i<k;i++){
        cin >> d;
        for(int j=0;j<d;j++){
            cin >> b;
            a[b-1]++;
        }
    }
    for(int i=0;i<n;i++){
        if(a[i] == 0){
            t++;
        }
    }
    cout << t;

    return 0;
}

Measured memory_bytes: 3636
# -*- coding: utf-8 -*-
n = int(input())
txy = []
for i in range(n):
    txy.append([int(i) for i in input().split()])

ans = "Yes"
bx = 0
by = 0
bt = 0
for i in range(n):
    tmp = ((txy[i][1] - bx) + (txy[i][2] - by))
    if tmp % 2 != (txy[i][0] - bt) % 2 or tmp > (txy[i][0] - bt):
        ans = "No"
    bx = txy[i][1]
    by = txy[i][2]
    bt = txy[i][0]
print(ans)


Measured memory_bytes: 21108
#include <bits/stdc++.h>
using namespace std;
 int n;
 int a[100000],dp[100000];
 
int func(int ind)
{
    if(ind==n-1)
    return 0;
    if(ind>=n)
    return INT_MAX;
    if(dp[ind]!=-1)
    return dp[ind];
    int left=abs(a[ind]-a[ind+1])+func(ind+1);
    int right=INT_MAX;
    if(ind+2<n)
    right=abs(a[ind]-a[ind+2])+func(ind+2);
    return dp[ind]=min(left,right);
}
int main() 
{
    cin>>n;
    int i;
    memset(dp,-1,sizeof(dp));
    for(i=0;i<n;i++)
    cin>>a[i];
    cout<<func(0);
}


Measured memory_bytes: 4096
"use strict";
    
const main = arg => {
    const packs = arg.split("\n")[0].split(" ").map(n=>parseInt(n)).sort((a,b)=>b-a);
	console.log(packs[0] === packs[1] + packs[2] ? "Yes" : "No");
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 7372
n, m = gets.split.map(&:to_i)
edges = []
(n - 1).times { edges << gets.split.map(&:to_i) }
graph = Array.new(n + 1) { Array.new }
# 無向グラフなので両始点のグラフに入れる
edges.each do |f, t|
  graph[f] << [f, t]
  graph[t] << [t, f]
end
counts = Array.new(n, 0)
m.times do
  node, count = gets.split.map(&:to_i)
  counts[node - 1] += count
end

ans = []
# from, to, count
queue = [[1, 1, 0]]
until queue.empty?
  from, to, count = queue.shift
  count += counts[to - 1]
  ans[to - 1] = count
  graph[to].each do |f, t, w|
    # 逆流しないようにする（両方のグラフに入れているので必ず1つ該当する）
    next if t == from
    queue << [f, t, count]
  end
end
puts ans.join(" ")


Measured memory_bytes: 85524
// Problem : E - Red Scarf
// Contest : AtCoder - AtCoder Beginner Contest 171
// URL : https://atcoder.jp/contests/abc171/tasks/abc171_e
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define eb emplace_back
#define pb push_back
#define size(s) (int)s.size()
#define int long long
#define vi vector<int>
#define vs vector<string>
#define vv vector<vector<int>>
#define pii pair<int,int>
#define m_p(x,y) make_pair(x,y)
#define vp vector<pair<int,int>>
#define setbits(x) __builtin_popcountll(x)
#define f first
#define se second
#define inc(v,n,x) v.assign(n,x)
#define incd(v,n) v.resize(n)
#define iniz(n) memset(n,0,sizeof(n))
#define inin(n) memset(n,-1,sizeof(n))
#define inimi(n) memset(n,0xc0,sizeof(n))
#define inima(n) memset(n,0x3f,sizeof(n))
#define all(v) (v).begin(),(v).end()

using namespace std;

template<typename T1,typename T2>istream &operator>>(istream &is, vector<pair<T1,T2>> &v) { for (pair<T1,T2> &t : v) is >> t.f>>t.se; return is; }
template<typename T>istream &operator>>(istream &is, vector<T> &v) { for (T &t : v) is >> t; return is; }
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &t : v) {os << t <<" ";} os << '\n'; return os; }

const int N=200001;
double pi=acos(-1.0);
int md=1e9+7;
const int INF=1e15;
int dx1[]={0,0,-1,1};
int dy1[]={1,-1,0,0};

template<class T>
T abst(T a)
{return a<0?-a:a;}

template<class T>
T max2(T a,T b){return a>b?a:b;}
template<class T>
T min2(T a,T b){return a<b?a:b;}

void solve()
{
int n;cin>>n;
vi v(n);cin>>v;
int su=0;
for(int i:v)
su^=i;
for(int i=0;i<n;i++)
cout<<(su^v[i])<<" ";
}

int32_t main(){
ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
int t=1;
//cin>>t;
for(int i=1;i<=t;i++)
{
    solve();
}
return 0;
}


Measured memory_bytes: 4692
#include <iostream>

using namespace std;
using ll = long long;

int main() {
    ll x;
    cin >> x;
    ll a = 100;
    ll count = 0;
    while(a < x){
        count++;
        a *= 1.01;
        if(a >= x) break;
    }
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 3636
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<string>
#include<iostream>
#include<algorithm>
#include<map>
using namespace std;
int main(){
	int n,a[105][105],sum[105][105];
	scanf("%d",&n);
	sum[1][0]=0;
	sum[2][0]=0;
	for(int i=1;i<=2;i++){
		for(int j=1;j<=n;j++){
			scanf("%d",&a[i][j]);
			if(i==1) sum[i][j]=sum[i][j-1]+a[i][j];
			else sum[i][j]=sum[i][j-1]+a[i][j];
		}
	}
	int Max=0;
	for(int i=1;i<=n;i++){
		if(sum[1][i]+sum[2][n]-sum[2][i-1]>Max) Max=sum[1][i]+sum[2][n]-sum[2][i-1];
	}
	printf("%d\n",Max);
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        int A = sc.nextInt();
        int X = sc.nextInt();
        
        if(A < X){
            System.out.println("0");
        } else {
            System.out.println("10");
        }
        
        sc.close();
        
    }
}


Measured memory_bytes: 22868
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
typedef long long ll;
#define N 3030
const ll mod=998244353;
inline int read(){
    int x=0,f=1;
    char c=getchar();
    while(c<'0'||c>'9'){
        if(c=='-')f=-1;
        c=getchar();
    }
    while(c>='0'&&c<='9'){
        x=(x<<3)+(x<<1)+c-'0';
        c=getchar();
    }
    return x*f;
}
int n,a[N],S;
ll dp[N],ans;
int main(){
	n=read(),S=read();
	for(int i=1;i<=n;++i){
		a[i]=read();
	}
	for(int i=1;i<=n;++i){
		for(int j=S;j>a[i];--j){
			dp[j]=(dp[j]+dp[j-a[i]])%mod;
		}
		dp[a[i]]=(dp[a[i]]+i)%mod;
		ans=(ans+dp[S]*(n-i+1)%mod)%mod;
		dp[S]=0;
	}
	printf("%lld\n",ans);
	return 0;
}

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

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

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

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

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

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

vector<vector<ll>> dijkstra(int s, int sil, vector<vector<T>> &G, vector<int> &c, vector<int> &d){
    int n = G.size();
    sil = min(sil, 5500);
    vector<vector<ll>> dist(55, vector<ll>(6000, INF));
    priority_queue<T, vector<T>, greater<T>> que;
    dist[s][sil] = 0;
    que.emplace(0, s, sil);

    set<int> visited;

    while(que.size()){
        ll ctime, cv, csil;
        tie(ctime, cv, csil) = que.top(); que.pop();

        // cout << ctime << " " << cv << " " << csil << endl;

        visited.emplace(cv);

        if(visited.size() == n) break;

        if(dist[cv][csil] < ctime) continue;

        for(auto nxt : G[cv]){
            int nv, ncost, ntime;
            tie(nv, ncost, ntime) = nxt;
            
            // i 回両替する
            for(ll i=0; ; i++){

                if(ncost <= csil + i * c[cv] && dist[cv][csil] + i * d[cv] + ntime < dist[nv][min(5500LL, csil + i * c[cv]) - ncost]){
                    dist[nv][min(5500LL, csil + i * c[cv]) - ncost] = dist[cv][csil] + i * d[cv] + ntime;
                    que.emplace(dist[nv][min(5500LL, csil + i * c[cv]) - ncost], nv, min(5500LL, csil + i * c[cv]) - ncost);
                }
            
                if(5500 < csil + i * c[cv]) break;
            }
        }
    }

    return dist;
}

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

    int n, m, s; cin>>n>>m>>s;
    vector<vector<T>> G(n);
    for(int i=0; i<m; i++){
        int u, v, a, b; cin>>u>>v>>a>>b;
        u--, v--;
        G[u].emplace_back(v, a, b);
        G[v].emplace_back(u, a, b);
    }

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

    vector<vector<ll>> dist = dijkstra(0, s, G, c, d);

    for(int i=1; i<n; i++){
        ll ans = INF;
        for(int j=0; j<6000; j++) chmin(ans, dist[i][j]);
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 104376
using System;
using System.Collections.Generic;
using static System.Math;
using System.Linq;
 
class Atest {
    static void Main(string[] args) {
        String n = Console.ReadLine();
        switch(n)
        {
            case "a":
                Console.WriteLine("b");
                break;
            case "b":
                Console.WriteLine("c");
                break;
            case "c":
                Console.WriteLine("d");
                break;
            case "d":
                Console.WriteLine("e");
                break;
            case "e":
                Console.WriteLine("f");
                break;
            case "f":
                Console.WriteLine("g");
                break;
            case "g":
                Console.WriteLine("h");
                break;
            case "h":
                Console.WriteLine("i");
                break;
            case "i":
                Console.WriteLine("j");
                break;
            case "j":
                Console.WriteLine("k");
                break;
            case "k":
                Console.WriteLine("l");
                break;
            case "l":
                Console.WriteLine("m");
                break;
            case "m":
                Console.WriteLine("n");
                break;
            case "n":
                Console.WriteLine("o");
                break;
            case "o":
                Console.WriteLine("p");
                break;
            case "p":
                Console.WriteLine("q");
                break;
            case "q":
                Console.WriteLine("r");
                break;
            case "r":
                Console.WriteLine("s");
                break;
            case "s":
                Console.WriteLine("t");
                break;
            case "t":
                Console.WriteLine("u");
                break;
            case "u":
                Console.WriteLine("v");
                break;
            case "v":
                Console.WriteLine("w");
                break;
            case "w":
                Console.WriteLine("x");
                break;
            case "x":
                Console.WriteLine("y");
                break;
            case "y":
                Console.WriteLine("z");
                break;
        }
    }
}

Measured memory_bytes: 11104
# coding: utf-8

import sys
def input(): return sys.stdin.readline().strip()

# N = int(input())
# L = [int(x) for x in input().split()]
N, L = map(int, input().split())
# S = input()

apple = [x + L - 1 for x in range(1, N + 1)]
apple.sort(key=lambda x : abs(x))
print(sum(apple[1:]))


Measured memory_bytes: 38384
#include <iostream>			//std::cout, std::cin
#include <string>			//std::string,std::to_string(C++11)
#include <vector>			//std::vector
#include <valarray>			//std::valarray
#include <algorithm>		//std::sort
#include <ctime>			//localtime_s
#include <cstdlib>			//abs
#include <cmath>			//abs,std::pow,sqrt,sin,cos,round,floor,ceil
#include <fstream>			//std::ifstream,std::ofstream
#include <iomanip>			//std::setprecision,std::setw,std::setfill
#include <random>			//std::random(C++11)
#include <numeric>			//std::accumulate
#include <functional>		//std::greater
#include <chrono>			//std::chrono(C++11)
#include <bitset>			//std::bitset
#include <queue>			//std::queue

const static double	de_PI	= 3.14159265358979323846;
const static int	de_MOD	= 1000000007;
const static int	de_MAX	= 999999999;

int main(void) {

	//std::ifstream in("123.txt");	std::cin.rdbuf(in.rdbuf());
	//std::ofstream ofs("456.csv");
	//std::chrono::system_clock::time_point t_st = std::chrono::system_clock::now();

	std::string str;
	std::cin >> str;

	for (int i = str.length() - 1; i >= 0; i--) {
		std::cout << str[i];
	}
	std::cout << std::endl;

	//std::chrono::system_clock::time_point t_ed = std::chrono::system_clock::now();
	//std::cout << std::chrono::duration_cast<std::chrono::milliseconds>(t_ed - t_st).count() << "ms" << std::endl;

}

Measured memory_bytes: 3124
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,x,n) for(int i=x;i<n;i++)
#define pb push_back
#define MAX 100005
#define int long long
using namespace std;
const int MOD=1000000007;
const int INF=1000000009;



signed main(){
  int W,N;
  int c=1;
  while(cin>>W,W){
    cin>>N;
    vector<int> v(N),w(N);
    char x;
    vector<vector<int> > dp(N+1,vector<int>(W+1));
    rep(i,N)cin>>v[i]>>x>>w[i];
    loop(i,1,N+1){
      rep(j,W+1){
        if(j-w[i-1]>=0){
          dp[i][j]=max(dp[i-1][j-w[i-1]]+v[i-1],dp[i-1][j]);
        }else{
          dp[i][j]=dp[i-1][j];
        }
      }
    }
    int val=dp[N][W],wei;
    rep(i,W+1){
      if(dp[N][i]==val){
        wei=i;
        break;
      }
    }
    cout<<"Case "<<c<<':'<<endl;
    cout<<val<<endl;
    cout<<wei<<endl;
    c++;
  }

  return 0;
}

Measured memory_bytes: 10656
#include<bits/stdc++.h>
using namespace std;
using ll  = long long;
using vl  = vector<ll>;
using vi  = vector<int>;
#define _GLIBCXX_DEBUG
#define IO_STREAM cin.tie(0);ios::sync_with_stdio(false)
#define all(x) x.begin(),x.end()
#define rep(i,sta,end) for(ll i=sta;i<end;++i)
#define lcm(a,b) (a)/__gcd((a),(b))*(b)
#define pb push_back
#define INF 1000000000000000LL
const ll MOD = 1000000007;
const double PI = acos(-1);
//||
#define DBG(a,b,c,d) //cout<<a<<" "<<b<<" "<<c<<" "<<d<<" "<<endl

signed main(){
	IO_STREAM;
	int n;
	cin>>n;
	string S;
	int cnt[26]={0};
	rep(i,0,n){
		cin>>S;
		int tmp_cnt[26]={0};
		rep(j,0,S.size()){
			if(i==0){
				cnt[S[j]-'a']++;
			}
			else{
				if(cnt[S[j]-'a']>0){
					tmp_cnt[S[j]-'a']++;
				}
			}
		}
		if(i==0) continue;
		rep(k,0,26){
			if(cnt[k]>0){
				cnt[k]=min(cnt[k],tmp_cnt[k]);
			}
		}
	}
	string ans;
	rep(i,0,26){
		rep(j,0,cnt[i]){
			ans+=i+'a';
		}
	}
	DBG("","","","");
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
using ll = long long;
typedef pair<ll, ll> P;
ll Mod = 1000000007;
int main() {
  ll N,M;
  cin >> N >> M;
  vector<P> D(N);
  ll ans = 0;
  for (int i = 0; i < N; i++) {
    cin >> D[i].F >> D[i].S;
  }
  sort(D.begin(),D.end());
  for (int i = 0; i < N; i++) {
    if (M >= D[i].S) {
      ans += D[i].S * D[i].F;
      M -= D[i].S;
    } else {
      ans += D[i].F * M;
      M = 0;
    }
  }
  cout << ans << endl;
  return 0;
}

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

int main()
{
	int N;
	cin >> N;
	int f = 0;
	int n = N;
	while (1) {
		f += N % 10;
		N = (int)(N / 10);
		if (N == 0) break;
	}
	if (n%f == 0) cout << "Yes" << endl;
	else cout << "No" << endl;
    return 0;
}



Measured memory_bytes: 256
macro_rules! debug {
    ( $x:ident [ $i:expr ] ) => {
        if cfg!(debug_assertions) {
            println!("{}[{}] = {}", stringify!($x), $i, $x[$i]);
        }
    };
    ( $x:ident [ $i:expr ][ $j:expr ] ) => {
        if cfg!(debug_assertions) {
            println!("{}[{}][{}] = {}", stringify!($x), $i, $j, $x[$i][$j]);
        }
    };
    ( $x:expr ) => {
        if cfg!(debug_assertions) {
            println!("{}:{} {} = {:?}", line!(), column!(), stringify!($x), $x);
        }
    };
}

fn main() {
    let stdin = std::io::stdin();
    let mut stdin = my::io::InputReader::new(stdin.lock());

    let S: String = stdin.read();

    let mut result = 0;
    let mut stack = Vec::<u8>::new();
    for &c in S.as_bytes() {
        if stack.is_empty() || stack[stack.len() - 1] == c {
            stack.push(c);
        } else {
            stack.pop();
            result += 2;
        }
    }
    println!("{}", result);
}

mod my {
    pub mod io {
        use std::io::{BufRead, ErrorKind, Result};
        use std::str::{FromStr, from_utf8};
        use std::fmt::Debug;

        pub fn read_word<R: BufRead>(r: &mut R, buf: &mut Vec<u8>)
                                              -> Result<usize> {
            let mut read = 0;
            loop {
                let (done, used) = {
                    let available = match r.fill_buf() {
                        Ok(n) => n,
                        Err(ref e) if e.kind() == ErrorKind::Interrupted => continue,
                        Err(e) => return Err(e)
                    };
                    match available.iter().position(|&x| x == b'\n' || x == b' ') {
                        Some(i) => {
                            buf.extend_from_slice(&available[..i]);
                            (true, i + 1)
                        }
                        None => {
                            buf.extend_from_slice(available);
                            (false, available.len())
                        }
                    }
                };
                r.consume(used);
                read += used;
                if done || used == 0 {
                    return Ok(read);
                }
            }
        }

        pub struct InputReader<R: BufRead> {
            reader: R,
            buf: Vec<u8>,
        }

        impl<R: BufRead> InputReader<R> {
            pub fn new(reader: R) -> InputReader<R> {
                InputReader {
                    reader: reader,
                    buf: Vec::<u8>::new(),
                }
            }

            pub fn read_word(&mut self) {
                read_word(&mut self.reader, &mut self.buf);
            }
            
            pub fn read<T>(&mut self) -> T
                where T: FromStr,
                      T::Err: Debug
            {
                self.buf.clear();
                self.read_word();
                from_utf8(&self.buf).unwrap().trim().parse().unwrap()
            }
        }
    }
}

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

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

    if (a>b) {
        for (int i=0; i<a; i++){
            ans += to_string(b);
        }
    } else {
        for (int i=0; i<b; i++){
            ans += to_string(a);
        }
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
def main():
    n, m, *x = map(int, open(0).read().split())
    if n >= m:
        print(0)
        return
    x.sort()
    a = [x[i + 1] - x[i] for i in range(m - 1)]
    a.sort()
    if n == 1:
        print(sum(a))
        return
    ans = sum(a) - sum(a[-n+1:])
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 13964
#include "bits/stdc++.h"
 
typedef long long ll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr<<#x<<": "<<x<<endl
#define debug_vec(v) cerr<<#v<<":";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
using namespace std;
int MOD = 1000000007;

signed main(){
    int n;
    cin >> n;
    vector<int> a(n);
    vector<int> b(n);
    rep(i,n){
        cin >> a[i];
        b[i] = a[i];
    }
    SORT(a);

    rep(i,n){
        if(a[n-1] == b[i] && a[n-2] != b[i]){
            cout << a[n-2] << endl;
        }else{
            cout << a[n-1] << endl;
        }
    }
    

    return 0;
}

// g++ -std=c++14 code1.cpp
// rm -r -f test;oj dl https://cf17-final-open.contest.atcoder.jp/tasks/cf17_final_a
// rm -r -f test;oj dl http://abc134.contest.atcoder.jp/tasks/abc134_b

Measured memory_bytes: 4736
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define pb push_back
using namespace std;
using ll = long long;
const char E = '\n';
const int N = 1005;
const ll mod = 1e9+7;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(); cout.tie(0);
    int n, m, k, ans;
    cin >> n >> m >> k;
    int a[n+1][m+1], sum[n+1][m+1];
    ans = n-1+m-1;
    for (int i=0; i<=n; i++) {
        for (int j=0; j<=m; j++) {
            a[i][j] = sum[i][j] = 0;
        }
    }
    for (int i=1; i<=n; i++) {
        for (int j=1; j<=m; j++) {
            char b;
            cin >> b;
            a[i][j] = b-'0';
            sum[i][j] = sum[i][j-1]+sum[i-1][j]-sum[i-1][j-1]+a[i][j];
        }
    }
    for (int i=0; i<=(1<<(n-1))-1; i++) {
        int res = 0, ii = i, in = 1;
        bool z = 0;
        vector <int> dil;
        for (int j=1; j<=n-1; j++) {
            if (((ii>>(j-1))&1)) {
                dil.pb (j);
                res ++;
                //cout << j << " ";
            }
        }
        //cout << E;
        dil.pb (n);
        for (int j=1; j<=m; j++) {
            int p = 1;
            for (int x=0; x<dil.size(); x++) {
                int T = dil[x];
                if (sum[T][j]-sum[T][j-1]-sum[p-1][j]+sum[p-1][j-1] > k) {
                    //cout << j << E;
                    z = 1;
                }
                p = dil[x]+1;
            }
        }
        if (z) continue;
        for (int j=2; j<=m; j++) {
            bool f = 0;
            int last = 1;
            for (int x=0; x<dil.size(); x++) {
                int nw = dil[x];
                int ts = sum[nw][j]-sum[nw][in-1]-sum[last-1][j]+sum[last-1][in-1];
                if (ts > k) {
                    f = 1;
                }
                last = dil[x]+1;
            }
            if (f) {
                res ++;
                in = j;
            }
        }
        if (!z) {
            ans = min(ans, res);
        }
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

int main(){
  ll X;
  cin >> X;
  ll a = X / 500;
  ll b = X % 500;
  cout << a * 1000 + b / 5 * 5 << endl;
  return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int n;
string s;

int main(){
	cin>>n>>s;
	cout<<(n>=3200?s:"red")<<endl;
}

Measured memory_bytes: 256