akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <array>
#include <algorithm>
#include <map>
#include <vector>
#include <list>
#include <cmath>
#include <stack>
#include <queue>

#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using namespace std;

const int mod = 1000000007;
struct mint {
	ll x; // typedef long long ll;
	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;
	}

	// for prime mod
	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) {
		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];
	}
} comb(2000005);

mint g(int r, int c) {
	return comb(r + c + 2, r + 1) - 1;
}

int main()
{
	int n;
	cin >> n;
	int a[100];
	int b[100];
	for (int i = 0; i < n - 1; i++)
	{
		cin >> b[i];
	}
	a[0] = b[0];
	for (int i = 1; i < n - 1; i++)
	{
		a[i] = min(b[i - 1], b[i]);
	}
	a[n - 1] = b[n - 2];
	long sum = 0;
	for (int i = 0; i < n; i++)
	{
		sum += a[i];
	}
	cout << sum;
}


Measured memory_bytes: 31488
//        ★★ ASHWINI SHARMA ★★ 
#include <bits/stdc++.h>
using namespace std;

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define fr(i,a,b) for (int i = (a), _b = (b); i <= _b; i++)
#define frr(i,a,b) for (int i = (a), _b = (b); i >= _b; i--)
#define rep(i,n) for (int i = 0, _n = (n); i < _n; i++)
#define repr(i,n) for (long long i = (n) - 1; i >= 0; i--)
#define foreach(it,ar) for ( typeof(ar.begin()) it = ar.begin(); it != ar.end(); it++ )
#define debug(x) cout<<#x<<": "<<x<<endl
#define ull unsigned long long int
#define ll long long int
#define ld double
#define ui unsigned int
#define pb push_back
#define mp make_pair
#define ff first
#define ss second 


#define PI 3.1415926535897932385
#define INF 1e18
#define EPS 1e-7
#define MAXN 1000005
#define MOD 1000000007
                                  //          ★★ ASHWINI SHARMA ★★      
ll gcd(ll a, ll b) 
{ 
    if (a == 0) 
        return b; 
    return gcd(b % a, a); 
} 
ll exp(ll x, ll y, ll p)
{
    ll res = 1;   
    x = x % p;  
    while (y > 0)
    {
        if (y & 1)    
            res = (res*x) % p;
        y = y>>1;     
        x = (x*x) % p; 
    }
    return res;
}
ll num(ll a, ll b, ll c)
{
    ll cc = a/c;
    ll cb = b/c;
    ll x = cb-cc;
    if(a % c == 0)
        x++;
    return x;
}
ll lcm(ll a, ll b)
{
    ll y = (a*b)/gcd(a, b);
    return y;
}



int main() {
   
    fastio;
    
    int n;
    cin >> n;
    vector<pair<ll, ll> > x;
    ll a[n], b[n];
    rep(i, n)
    {
        cin >> a[i] >> b[i];
        x.pb(mp(b[i], a[i]));
    }
    sort(x.begin(), x.end());
    bool ans = true;
    ll sum = 0;
    rep(i, n)
    {
        sum += x[i].ss;
        if(sum > x[i].ff)
            ans = false;
    }
    if(ans)
        cout << "Yes";
    else
        cout << "No";
    return 0; 
}

Measured memory_bytes: 9200
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(), x.end()
#define rsort(x) sort(x.rbegin(), x.rend())
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define fio(x) ios::sync_with_stdio(x), cin.tie(x), cout.tie(x);
#define znit(x) memset(x, 0, sizeof(x))
#define mnit(x) memset(x, -1, sizeof(x))
typedef long long ll;
typedef double db;
typedef long double ldb;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef pair<ll, ll> pll;
typedef pair<db, db> pdd;
const int dr[] = {1, 0, -1, 0, 1, 1, -1, -1};
const int dc[] = {0, 1, 0, -1, 1, -1, 1, -1};
const int inf = 0x3f3f3f3f;
const ll linf = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db EPS = 1e-7;

const ll mod = 1e9 + 7;
const ll mod2 = 1e9 + 9;
ll mypow(ll x, ll y, ll p){ll ret = 1;while(y){if(y & 1) ret = (ret * x) % p;x = (x * x) % p; y /= 2;}return ret;}
ll inv(ll x, ll p){return mypow(x, p - 2, p);}
ll gcd(ll x, ll y){return y ? gcd(y, x % y) : x;}

const int MAX = 2e5 + 3;

int A, B;

int main(){
	cin >> A >> B;
	cout << A * B - A - B + 1 << endl;
	return 0;
}

Measured memory_bytes: 768
N = int(input())
h = list(map(int, input().split()))
count = 0

while any(h):
    for i in range(N):
        if i+1 >= N:
            if h[i] > 0:
                count += 1
                h[i] -= 1
                break
        if h[i] > 0 and h[i+1] == 0:
            count += 1
        if h[i] > 0:
            h[i] -= 1

print(count)


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

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

    string str;
    cin >> str;
    for(int i=0; i<4; i++) cout << str[i];
    cout << " ";
    for(int i=4; i<12; i++) cout << str[i];
    cout << endl;


	return 0;
}


Measured memory_bytes: 256
/*
Author : N_o_o_B
Created : March 01 2020 17:30:19 
*/
#include <bits/stdc++.h>
using namespace std;
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
*/
#define TRACE
#ifdef TRACE
#define trace(...) { cerr<<"[ "; __trace__(#__VA_ARGS__, __VA_ARGS__);}
#undef endl
template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const pair<Arg1,Arg2> &x) {
    return out<<"("<<x.first<<","<<x.second<<")";
}
 
template <typename Arg1>
ostream& operator << (ostream& out, const vector<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1>
ostream& operator << (ostream& out, const set<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const map<Arg1,Arg2> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1>
void __trace__(const string name, Arg1&& arg1){
    cerr << name << " : " << arg1 << " ] " << endl;
}
 
template <typename Arg1, typename... Args>
void __trace__(const string names, Arg1&& arg1, Args&&... args){
    const string name = names.substr(0,names.find(','));
    cerr<<name<<" : "<<arg1<<" | ";
    __trace__(names.substr(1+(int)name.size()), args...);
}
#else
    #define trace(args...)
#endif
 
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pair<int,int>> vii;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<pair<ll,ll>> vll;
typedef vector<vl> vvl;
//typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> oset;
#define fori(i,n) for(int i=0;i<n;i++)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repd(i,a,b) for(int i=a;i>=b;i--)
#define ford(i,n)  for(int i=n-1;i>=0;i--)
#define trav(x,a) for(auto& x:a)
#define all(x) x.begin(),x.end()
#define pb push_back
#define endl '\n'
#define sz(a) (int)a.size()
#define fi first
#define se second
clock_t time_p=clock();
void time_taken()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
//const ll mod=998244353;
const ll mod=1e9+7;
const ll INF=1e18;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    cout.precision(12);cout << fixed;


    int n;
    cin >> n;
    cout << (n+1)/2 << endl;


    time_taken();
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

#define MAX 100000000

struct NODE {
    int distance;
    int state;
} vertex[11][101];

int W[101][101];
int c, V, n, s, d;

int min(int a, int b) {
    return (a > b ? b : a);
}

void dijkstra(int start) {
    int i, x, p, step;
    for (i = 0; i <= c; i++) {
	for (x = 1; x <= V; x++) {
	    vertex[i][x].distance = MAX; vertex[i][x].state = 0;
	}
	vertex[i][start].distance = 0; 
    }
    for (i = 0; i <= c; i++) {
	for (step = 1; step <= V; step++) {
	    int minimum = MAX;
	    for (x = 1; x <= V; x++)
		if (vertex[i][x].state == 0 && vertex[i][x].distance < minimum) {
		    p = x; minimum = vertex[i][x].distance;
		}
	    vertex[i][p].state = 1;
	    for (x = 1 ; x <= V; x++)
		if (vertex[i][x].state == 0) {
		    if (i == 0)
			vertex[i][x].distance = min(vertex[i][x].distance, 
						    vertex[i][p].distance+W[p][x]);
		    else
			vertex[i][x].distance = min(vertex[i][x].distance, 
						    min(vertex[i][p].distance+W[p][x],
							vertex[i-1][p].distance+W[p][x]/2));
		}
	}
    }
}

int main(void) {
    int i, j;
    int from, to, m;
     
    while (1) {
	scanf("%d%d%d%d%d", &c, &V, &n, &s, &d);
        if (c + V + n + s + d == 0) break;
         
        for (i = 0; i <= V; i++)
            for (j = 0; j <= V; j++)
                W[i][j] = MAX;
         
	for (i = 0; i < n; i++) {
            scanf("%d%d%d", &from, &to, &m);
            W[from][to] = m;
	    W[to][from] = m;
        }
         
        dijkstra(s);
	printf("%d\n", vertex[c][d].distance);
    }
    return 0;
}

Measured memory_bytes: 648
a, b, c, x, y = gets.chop.split.map(&:to_i)

ans = 0

if 2 * c < a + b
  num_c = [x, y].min * 2
  ans += c * num_c 
  x -= num_c / 2
  y -= num_c / 2
end

ans += x * [a, 2 * c].min + y * [b, 2 * c].min
puts ans

Measured memory_bytes: 1788
n = int(input())
b = [int(i) for i in input().split()]
a = []
if n == 2:
    print(b[0] + b[0])
    exit(0)
for i in range(n):
    if i == 0:
        a += [b[0]]
    elif i == n - 1:
        a += [b[-1]]
    else:
        a += [min(b[i - 1], b[i])]
print(sum(a))


Measured memory_bytes: 3064
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
  
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
  
using namespace std;
  
typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;
  
const int INF=1<<29;
const double EPS=1e-9;
  
const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};


int main() {
  ll N, M;
  cin >> N >> M;
  if (N == 1 && M == 1) {
    cout << 1 << endl;
    return 0;
  }

  if (N == 1 || M == 1) {
    cout << max(N, M) - 2 << endl;
    return 0;
  }

  cout << (N - 2) * (M - 2) << endl;
  return 0;
}

Measured memory_bytes: 256
# coding: utf-8
# Your code here!

import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline #文字列入力のときは注意

#n = int(input())
n,q = [int(i) for i in readline().split()]

g = [[] for _ in range(n)]
for i in range(n-1):
    a,b = [int(i) for i in readline().split()]
    g[a-1].append(b-1)
    g[b-1].append(a-1)

add = [0]*n
for _ in range(q):
    p,x = [int(i) for i in readline().split()]
    add[p-1] += x

ans = [0]*n
#ans[0] = add[0]

def dfs(v,p,value): #p: parent of v
    value += add[v]
    ans[v] = value
    for c in g[v]:
        if c == p: continue
        dfs(c,v,value)

dfs(0,-1,0)

#print(add)

print(*ans)






Measured memory_bytes: 236920
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <numeric>
#include <cassert>
#include <random>
using namespace std;
using ll = long long;

int main() {
	int n; cin >> n;
	cout << (n + 1) / 2 << endl;
	return 0;
}


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

int main(){
  long long n, ans=0; cin>>n;
  
  for(int i=1;i<=n;i++){
    if(i%3==0 || i%5==0)continue;
    ans+=i;
  }
  
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3548
import java.util.*;
 
public class Main {
    public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		long[] begin = new long[n+1];
		long[] end = new long[n+1];
		for(int i=1; i<n+1; i++){
			begin[i] = begin[i-1]+i;
		}
		end[0] = n;
		int count = 1;
		for(int i=n-1; count<n+1; i--){
			end[count] = end[count-1]+i;
			count++;
		}
		long total = 0;
		long mod = 1_000_000_007;
		for(int i=k-1; i<begin.length; i++){
			total = (total+end[i]-begin[i]+1)%mod;
		}
		System.out.println(total);

	}
}


Measured memory_bytes: 30264
#include <bits/stdc++.h>
 #define mod 1000000007
 #define f first
 #define se second
 #define pb push_back
 #define int long long int
using namespace std;
 signed main()
 {
     ios_base::sync_with_stdio(false);
     cin.tie(NULL);cout.tie(NULL);
     
   

         int mini = INT_MAX;
         for(int i=0;i<2019;i++)
         {
            for(int j =0;j<2019;j++)
            {
                mini = min(mini,(i*j)%2019);
            }
         }

         int l,r;
         cin>>l>>r;

         if(r-l+1>=2019)
         {
            cout<<mini<<"\n";
            return 0;
         }

         int mini1  = INT_MAX;
         for(int i = l;i<=r;i++)
         {
            for(int j= i+1;j<=r;j++)
            {
                mini1 = min(mini1,(i*j)%2019);
            }
         }
         cout<<mini1<<"\n";



 }


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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>  // Including tree_order_statistics_node_update

using namespace __gnu_pbds;
using namespace std;

#define sz(a) int((a).size())
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(), (c).end()
#define tr(c, i) for (__typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define present(c, x) ((c).find(x) != (c).end())
#define cpresent(c, x) (find(all(c), x) != (c).end())
#define minei(x) min_element(x.begin(), x.end()) - (x).begin()
#define maxei(x) max_element(x.begin(), x.end()) - (x).begin()
#define LSOne(S) (S & (-S))

#define uns(v) sort((v).begin(), (v).end()), v.erase(unique(v.begin(), v.end()), v.end())
#define acusum(x) accumulate(x.begin(), x.end(), 0)
#define acumul(x) accumulate(x.begin(), x.end(), 1, multiplies<int>());
#define bits(x) __builtin_popcount(x)
#define oo INT_MAX
#define inf 1000000000
#define MAXN 100007
#define MOD 1000000007

const double pi = acos(-1.0);
const double eps = 1e-11;

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

int main() {
    std::ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, q, t, indx, l, r;
    char ch;
    string s;
    cin >> n >> s >> q;
    map<int, set<int> > cache;
    for (int i = 0; i < n; i++) {
        cache[s[i] - 'a'].insert(i);
    }
    while (q--) {
        cin >> t;
        if (t == 1) {
            cin >> indx >> ch;
            indx--;
            if (s[indx] == ch) continue;
            cache[s[indx] - 'a'].erase(indx);
            s[indx] = ch;
            cache[ch - 'a'].insert(indx);
        } else {
            cin >> l >> r;
            l--, r--;
            int res = 0;
            for (int c = 0; c < 26; c++) {
                auto iter = cache[c].lower_bound(l);
                if (iter == cache[c].end()) continue;
                if (*iter <= r) res++;
            }
            cout << res << '\n';
        }
    }

    return 0;
}


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

using namespace std;
using ll = long long;


int main()
{
    int n, m, x; cin >> n >> m >> x;
    vector<int> cost(n);
    vector<vector<int>> a(n, vector<int>(m));
    for(int i = 0; i < n; i++) {
        cin >> cost[i];
        for(int j = 0; j < m; j++) cin >> a[i][j];
    }
    int ans = 1000000000;
    for(int bit = 0; bit < (1 << n); bit++) {
        vector<int> alg(m);
        int cur = 0;
        for(int i = 0; i < n; i++) {
            if(bit & (1 << i)) {
                cur += cost[i];
                for(int j = 0; j < m; j++) {
                    alg[j] += a[i][j];
                }
            }
        }
        bool res = true;
        for(int j = 0; j < m; j++)if(alg[j] < x)res = false;
        if(res) {
            ans = min(cur, ans);
        }
    }
    cout << (ans == 1000000000 ? -1 : ans) << endl;
}

Measured memory_bytes: 3628
// AOJ GRL_6_A Maximum Flow
// 2018.4.26 bal4u

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

/*******************************************/
/* Dinic's Max Flow Algorithm 
/*******************************************/

#define INF 0x01010101
#define VMAX 110
typedef struct { int to; int cap; int rev; } EDGE;
EDGE *edge[VMAX]; int hi[VMAX], lim[VMAX];
int V;				// 頂点数
int level[VMAX], iter[VMAX];
int queue[2*VMAX], qtop;

void check_lim(int a)
{
	if (hi[a] < lim[a]) return;
	if (lim[a] == 0) {
		lim[a] = 16, hi[a] = 0;
		edge[a] = malloc(sizeof(EDGE) *lim[a]);
	} else if (hi[a] == lim[a]) {
		int k = lim[a];
		if (k > 256) k = 256;
		lim[a] += k;
		edge[a] = realloc(edge[a], sizeof(EDGE) *lim[a]);
	}
}

void add_edge(int from, int to, int cap)
{
	int f, t;
	EDGE *e;

	check_lim(from), check_lim(to);
	f = hi[from]++, t = hi[to]++;
	e = &edge[from][f], e->to = to, e->cap = cap, e->rev = t; 
	e = &edge[to][t], e->to = from, e->cap = 0, e->rev = f;
}

#if 0
void init()
{
	memset(lim, 0, sizeof(lim));
	memset(hi, 0, sizeof(hi));
}
#endif

void bfs(int s)
{
	int i, v;
	EDGE *e;
	
	memset(level, -1, V << 2);
	level[s] = 0;
	queue[0] = s, qtop =1;
	while (qtop) {
		v = queue[--qtop];
		for (i = 0; i < hi[v]; i++) {
			e = &edge[v][i];
			if (e->cap > 0 && level[e->to] < 0) {
				level[e->to] = level[v] + 1;
				queue[qtop++] = e->to;
			}
		}
	}
}
 
int dfs(int v, int t, int f)
{
	int *i, d;
	EDGE *e;
	
	if (v == t) return f;
	for (i = &iter[v]; *i < hi[v]; (*i)++) {
		e = &edge[v][*i];
		if (e->cap > 0 && level[v] < level[e->to]) {
			d = dfs(e->to, t, f <= e->cap? f: e->cap);
			if (d > 0) {
				e->cap -= d;
				edge[e->to][e->rev].cap += d;
				return d;
			}
		}
	}
	return 0;
}
 
int maxFlow(int s, int t)
{
	int f, flow = 0;
	while (1) {
		bfs(s);
		if (level[t] < 0) break;
		memset(iter, 0, V << 2);
		while ((f = dfs(s, t, INF)) > 0) flow += f;
	}
	return flow;
}

//#define getchar_unlocked()  getchar()
int in()
{
	int n = 0;
	int c = getchar_unlocked();
	do n = (n<<3)+(n<<1) + (c & 0xf), c = getchar_unlocked();
	while (c >= '0');
	return n;
}

int main()
{
	int E, u, v, c;
	int source, sink;

	V = in(), E = in();
	source = 0, sink = V-1;
	while (E--) {
		u = in(), v = in(), c = in();
		add_edge(u, v, c);
	}
	printf("%d\n", maxFlow(source, sink));
	return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<pair<int,int>> vpii;

#define F first
#define S second
#define PU push
#define PUF push_front
#define PUB push_back
#define PO pop
#define POF pop_front
#define POB pop_back

#define REP(i,a,b) for(int i=a; i<=b; i++)

#define MOD 1000000007

void solve(int test_case) {
	string s;
	cin>>s;
	cout<<s[0]<<s.length()-2<<s[s.length()-1];
}

int main() {
	
	////// FILE BASED IO////
	//freopen("in", "r", stdin);
	//freopen("out", "w", stdout);
	///////////////
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	//cin>>t;
	REP(i,1,t) {
		solve(i);
	}
}	


Measured memory_bytes: 3536
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cassert>
#define InfL 1000000000
#define InfLL 1000000000000000000LL
#define mod 1000000007
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rrep(i,n) for(int (i)=(n-1);(i)>=(0);(i)--)
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<db> vd;

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

	int ans = (N + 1) / 2;

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

Measured memory_bytes: 256
#include<stdio.h>
main(){
  int x=0,y=0,a,b,r=0,count=0;
 
 while(1){
   count=0;   
 scanf("%d %d",&a,&b);
    if( b==0&&a==0){break;}
    if(a<b){
      x=b;
      y=a;
    }
    else{
      x=a;
      y=b;
    }

    while(1){
      x%=y;
      r=x;
      x=y;
      y=r;
      count++; 

 if(y==0){break;}
    } 
 printf("%d %d\n",x,count); 
 } 

  return 0;
}

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

int main() {
	ll n; cin >> n;
	vector<ll> a(n); rep(i, 0, n) cin >> a[i];
	
	ll ans = 0;
	rep(i, 0, n) {
		ans += a[i] - 1;
	}
	
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
n,m = map(int,input().split())
A = list(map(int,input().split()))
A.sort()
bc = [list(map(int,input().split())) for _ in range(m)]

bc.sort(key=lambda x:x[1],reverse=1)

i = 0#bcの添え字
j = 0#Aの添え字
while 1:
	if i >= m or j >= n:
		#print('iかjが超えた！')
		break
	if bc[i][1] < A[j]:
		#print('Aでっか')
		break
	for k in range(bc[i][0]):
		#print(i,j,k)
		A[j] = bc[i][1]
		j+=1
		if j >= n:
			#print('for文内、jが超えた')
			break
		if A[j] > bc[i][1]:
			#print('for文内、Aでっか')
			break
	i+=1
# print(A)
print(sum(A))

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

#define faster      ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pi          acos(-1.0)
#define nl          '\n'

///Library
#define mem(a,b)    memset(a,b,sizeof(a))
#define all(a)      a.begin(),a.end()
#define Sort(x)     sort(x.begin(),x.end())
#define Reverse(x)  reverse(x.begin(),x.end())
#define SortA(ar,s) sort(ar,ar+s)
#define SortD(ar,s) sort(ar,ar+s,greater<int>())
#define gcd(a,b)    __gcd(a,b)
#define lcm(a,b)    (a*(b/gcd(a,b)))
#define sq(x)       (x)*(x)

#define min3(a,b,c)        min(a,min(b,c))
#define min4(a,b,c,d)      min(a,min(b,min(c,d)))
#define max3(a,b,c)        max(a,max(b,c))
#define max4(a,b,c,d)      max(a,max(b,max(c,d)))
#define ABS(x)             ((x)<0?-(x):(x))
#define pb                 push_back
#define mod                1000000007
#define end                printf("\n")
#define yes                printf("YES\n")
#define no                 printf("NO\n")

///data type
typedef long long int ll;
typedef unsigned long long int  llu;

int main()
{
    string s;
    int c=0,mx=0;
    cin>>s;
    for(int i=0; i<s.size(); i++)
    {
        if(s[i]=='R')
            c++;
        else c=0;
        mx=max(c,mx);
    }
    cout<<mx<<nl;
    return 0;
}


Measured memory_bytes: 3624
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<deque>
#include<stack>
#include<cmath>
using namespace std;
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define All(v) (v).begin(),(v).end()
using ll = long long;
const ll mod = 1000000007;
const ll INF = 100000000000000000LL;
int main(){
    int n;
    cin >> n;
    string s;
    cin >> s;
    int res = 0;
    int tmp = 0;
    rep(i, n)
    {
        if(s[i]=='I')
            tmp++;
        else
            tmp--;
        res = max(res, tmp);
    }
    cout << res << endl;
}

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

int main(){
    int a, b, c;
    cin >> a >> b >> c;
    if (a == b && a == c) cout << 1 << endl;
    else if (a == b || a == c || b == c) cout << 2 << endl;
    else cout << 3 << endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Math;

class MainClass : Scanner
{
    static void Main()
    {
        string S = RString();
        string T = RString();
        int q = RInt();

        var DS = new long[S.Length + 1];
        for (int i = 0; i < S.Length; i++)
        {
            DS[i + 1] = DS[i] + (S[i] == 'A' ? 1 : 2);
        }
        var DT = new long[T.Length + 1];
        for (int i = 0; i < T.Length; i++)
        {
            DT[i + 1] = DT[i] + (T[i] == 'A' ? 1 : 2);
        }

        string[] ans = new string[q];
        for (int i = 0; i < q; i++)
        {
            var r = ReadTuple<int,int,int,int>();
            long s = DS[r.Item2] - DS[r.Item1 - 1];
            long t = DT[r.Item4] - DT[r.Item3-1];
            long dif = Abs(s - t);
            ans[i] = dif % 3 == 0 ? "YES" : "NO";
        }
        WriteLine(string.Join(Environment.NewLine,ans));
    }
}



class Scanner
{
    public static string RString() => Console.ReadLine();
    public static int RInt() => ReadTuple<int>();
    public static long RLong() => ReadTuple<long>();
    public static double RDouble() => ReadTuple<double>();

    public static string[] RStrings() => Console.ReadLine().Split();
    public static int[] RInts() => Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
    public static long[] RLongs() => Array.ConvertAll(Console.ReadLine().Split(), long.Parse);
    public static double[] RDoubles() => Array.ConvertAll(Console.ReadLine().Split(), double.Parse);
    public static int[] RInts(Func<string, int> func) => Console.ReadLine().Split().Select(func).ToArray();
    public static long[] RLongs(Func<string, long> func) => Console.ReadLine().Split().Select(func).ToArray();
    public static double[] RDoubles(Func<string, double> func) => Console.ReadLine().Split().Select(func).ToArray();
    //public static string[] RStrings(Func<string, string> func) => Console.ReadLine().Split().Select(func).ToArray();

    public static T1 ReadTuple<T1>()
    {
        var r = RString();
        var r1 = (T1)Convert.ChangeType(r, typeof(T1));
        return r1;
    }
    public static (T1, T2) ReadTuple<T1, T2>()
    {
        var r = RStrings();
        var r1 = (T1)Convert.ChangeType(r[0], typeof(T1));
        var r2 = (T2)Convert.ChangeType(r[1], typeof(T2));
        return (r1, r2);
    }
    public static (T1, T2, T3) ReadTuple<T1, T2, T3>()
    {
        var r = RStrings();
        var r1 = (T1)Convert.ChangeType(r[0], typeof(T1));
        var r2 = (T2)Convert.ChangeType(r[1], typeof(T2));
        var r3 = (T3)Convert.ChangeType(r[2], typeof(T3));
        return (r1, r2, r3);
    }
    public static (T1, T2, T3, T4) ReadTuple<T1, T2, T3, T4>()
    {
        var r = RStrings();
        var r1 = (T1)Convert.ChangeType(r[0], typeof(T1));
        var r2 = (T2)Convert.ChangeType(r[1], typeof(T2));
        var r3 = (T3)Convert.ChangeType(r[2], typeof(T3));
        var r4 = (T4)Convert.ChangeType(r[3], typeof(T4));
        return (r1, r2, r3, r4);
    }
}


Measured memory_bytes: 49472
macro_rules! input_inner { ( $ iter : expr ) => { } ; ( $ iter : expr , ) => { } ; ( $ iter : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ iter , $ t ) ; input_inner ! { $ iter $ ( $ r ) * } } ; }
macro_rules! read_value { ( $ iter : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ iter , $ t ) ) ,* ) } ; ( $ iter : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ iter , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ iter : expr , chars ) => { read_value ! ( $ iter , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ iter : expr , usize1 ) => { read_value ! ( $ iter , usize ) - 1 } ; ( $ iter : expr , $ t : ty ) => { $ iter . next ( ) . unwrap ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }
macro_rules! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; input_inner ! { iter , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let s = { use std :: io :: Read ; let mut s = String :: new ( ) ; std :: io :: stdin ( ) . read_to_string ( & mut s ) . unwrap ( ) ; s } ; let mut iter = s . split_whitespace ( ) ; input_inner ! { iter , $ ( $ r ) * } } ; }

fn main() {
    input! {
        s: String,
        t: String,
    }

    println!("{}{}", t, s);
}


Measured memory_bytes: 4352
#include <iostream>
#define FOR(i,a,b) for(int i=a;i<b;i++)
using namespace std;

int main() {
	// your code goes her
	int n;cin>>n;
	int a[n][3],dp[n][3];
	FOR(i,0,n){
		cin>>a[i][0]>>a[i][1]>>a[i][2];
		dp[i][0]=a[i][0];
		dp[i][1]=a[i][1];
		dp[i][2]=a[i][2];
	}
	
	FOR(i,0,n){
		FOR(j,0,3){
			if(i==0){
				dp[i][j]=a[i][j];
			}else{
				int xx=-1;
				FOR(k,0,3){
					if(k==j)continue;
					xx=max(xx,dp[i-1][k]);
				}
				dp[i][j]+=xx;
			}
		}
	}
/*	FOR(i,0,n){
		FOR(j,0,3){
			cout<<dp[i][j]<<" ";
		}cout<<endl;
	}
*/	cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]))<<endl;
	
	return 0;
}

Measured memory_bytes: 5868
fn read_stdin() -> String {
    use std::io::Read;
    let mut input = String::new();
    std::io::stdin().read_to_string(&mut input).unwrap();
    input
}

fn scan<'a, I: Iterator<Item = &'a str>, T: std::str::FromStr>(tokens: &mut I) -> T {
    tokens.next().unwrap().parse().ok().unwrap()
}

fn vec<T, F: FnMut(usize) -> T>(n: usize, mut f: F) -> Vec<T> {
    (0..n).map(|i| f(i)).collect()
}

fn main() {
    use std::collections::HashMap;
    let input = read_stdin();
    let tokens = &mut input.split_whitespace();
    let n: usize = scan(tokens);
    let a: Vec<usize> = vec(n, |_| scan(tokens));
    let m: usize = a.iter().max().unwrap() + 1;
    let divisor: Vec<usize> = {
        let mut divisor: Vec<usize> = (0..m).collect();
        let mut i = 2;
        while i * i < m {
            if divisor[i] == i {
                let mut j = i * i;
                while j < m {
                    divisor[j] = i;
                    j += i;
                }
            }
            i += 1;
        }
        divisor
    };
    let lcm: F = {
        let mut max_count: HashMap<usize, usize> = HashMap::new();
        for &ai in &a {
            let mut count = HashMap::new();
            let mut x = ai;
            while x != 1 {
                let d = divisor[x];
                *count.entry(d).or_insert(0) += 1;
                x /= d;
            }
            for (p, e) in count {
                let f = max_count.entry(p).or_insert(0);
                *f = std::cmp::max(*f, e);
            }
        }
        let mut lcm = F(1);
        for (p, e) in max_count {
            lcm = lcm * F(p).pow(e);
        }
        lcm
    };
    let mut ans = F(0);
    for i in 0..n {
        ans = ans + lcm / F(a[i]);
    }
    println!("{}", ans.value());
}

const MODULO: usize = 1_000_000_007;

#[derive(Clone, Copy, Debug, Eq, PartialEq)]
struct F(usize);

impl F {
    fn value(self) -> usize {
        self.0
    }
    fn pow(self, e: usize) -> F {
        let mut a = F(1);
        let mut b = self;
        let mut e = e;
        while e != 0 {
            if e & 1 != 0 {
                a = a * b;
            }
            b = b * b;
            e >>= 1;
        }
        a
    }
    fn inverse(self) -> F {
        self.pow(MODULO - 2)
    }
}

impl std::ops::Add for F {
    type Output = F;
    fn add(self, other: F) -> F {
        F((self.value() + other.value()) % MODULO)
    }
}

impl std::ops::Sub for F {
    type Output = F;
    fn sub(self, other: F) -> F {
        F((self.value() + MODULO - other.value()) % MODULO)
    }
}

impl std::ops::Mul for F {
    type Output = F;
    fn mul(self, other: F) -> F {
        F((self.value() * other.value()) % MODULO)
    }
}

impl std::ops::Div for F {
    type Output = F;
    fn div(self, other: F) -> F {
        self * other.inverse()
    }
}


Measured memory_bytes: 12540
#include<stdio.h>
#define min(a,b) (((a)<(b))?(a):(b))
int main(int argc, char const *argv[]){
	long long h,w,ans,i,a,b,c;
	scanf("%lld %lld",&h,&w);
	if(h%3==0 || w%3==0){
		printf("0\n");
	}else{
		ans=h*w;
		if(h>=3) ans=w;
		if(w>=3) ans=min(ans,h);
		for(i=1;i<w;i++){
			a=i*h;
			b=(w-i)*(h/2);
			c=(w-i)*(h/2+h%2);
			if(a<b){
				ans=min(ans,c-a);
			}else{
				if(a>c){
					ans=min(ans,a-b);
				}else{
					ans=min(ans,c-b);
				}
			}
		}
		for(i=1;i<h;i++){
			a=i*w;
			b=(h-i)*(w/2);
			c=(h-i)*(w/2+w%2);
			if(a<b){
				ans=min(ans,c-a);
			}else{
				if(a>c){
					ans=min(ans,a-b);
				}else{
					ans=min(ans,c-b);
				}
			}
		}
		printf("%lld\n",ans);
	}
	return 0;
}

Measured memory_bytes: 128
//============================================================================
//Everyone has a different way of thinking, so God Created us
//   Hope You Respect My Way..,Thank You ):
// Author      : Murad
// Name        : Codeforces.cpp & Atcoder.cpp
// Description : Problem name
//============================================================================
#include<bits/stdc++.h>
#include<unordered_map>
#include<unordered_set>
using namespace std;
#define pi 3.1415926536
#define forn(i,a,b)for(int i=a;i<b;i++)
#define LL long long
#define ULL unsigned long long
#define MP make_pair
#define SZ(c) int(c.size())
#define ff first
#define ss second
#define INF INT32_MAX
#define _INF INT32_MIN
#define PQ priority_queue
#define MM multimap
#define PB push_back
#define vii vector<int>
#define ipair pair<int,int>
#define lpair pair<LL,LL>
#define MAXN 100004
#define El3zba ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define modd 1000000007
#define sfll1(v) scanf("%I64d",&v);
#define sfll2(v1,v2) scanf("%I64d %I64d",&v1,&v2)
#define sfll3(v1,v2,v3) scanf("%I64d %I64d %I64d",&v1,&v2,&v3)
#define endl '\n'
//std::transform(s1.begin(), s1.end(), s1.begin(),::tolower);
char alphz[27] = { 'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z' };
int main() {
	El3zba;
	int n,m;
	cin>>n>>m;
	map<LL ,LL>mpp;
	for(int i=0;i<n;i++)
	{
		int a,b;
		cin>>a>>b;
		mpp[a]+=b;
	}
	LL ans=0;
	for(auto i=mpp.begin();i!=mpp.end()&&m>0;i++)
	{
		if(i->ss>=m)
		{
			ans+=i->ff*m;
			m-=i->ss;
		}
		else
		{
			ans+=i->ff*i->ss;
			m-=i->ss;
		}
	}
	cout<<ans<<endl;
	return 0;
}


















Measured memory_bytes: 6528
/**
 *    author:  tourist
 *    created: 02.01.2020 23:41:00       
**/
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long n, a, b;
  cin >> n >> a >> b;
  if (n == 1) {
    cout << (a == b) << '\n';
  } else {
    if (a > b) {
      cout << 0 << '\n';
    } else {
      cout << (b - a) * (n - 2) + 1 << '\n';
    }
  }
  return 0;
}


Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var n, y int
	fmt.Scan(&n, &y)
	c10k, c5k, c1k := -1, -1, -1

	for i := 0; i <= n; i++ { // 10000yen
		for j := 0; j <= n-i; j++ { // 5000yen
			k := n - i - j // 1000yen
			total := i*10000 + j*5000 + k*1000
			if total == y && i+j+k == n {
				c10k, c5k, c1k = i, j, k
				break
			}
		}
		if c10k != -1 && c5k != -1 && c1k != -1 {
			break
		}
	}
	fmt.Printf("%v %v %v", c10k, c5k, c1k)
}


Measured memory_bytes: 512
#pragma GCC optimize ("Ofast")
#include "bits/stdc++.h"
	
#define PI 3.141592653589793
#define FAST ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
// Use for file I/O;
#define FIN string _fname = ""; \
			string _is = _fname + ".in", _os = _fname + ".out"; \
			freopen(_is.c_str(), "r", stdin); \
			freopen(_os.c_str(), "w", stdout);
typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;

using namespace std;

const ll INF = 1e9 + 10;
const ll INF2 = 1e18 + 10;
const int MOD = 1e9 + 7;
const ld EPS = 1e-4;

const int LOGN = 19;
const int MAXN = 2e5;

struct Line {
	mutable ll k, m, p;
	bool operator<(const Line& o) const { return k < o.k; }
	bool operator<(ll x) const { return p < x; }
};

struct LineContainer : multiset<Line, less<>> {
	// (for doubles, use inf = 1/.0, div(a,b) = a/b)
	const ll inf = LLONG_MAX;

	ll div(ll a, ll b) { // floored division
		return a / b; }

	bool isect(iterator x, iterator y) {
		if (y == end()) { x->p = inf; return false; }
		if (x->k == y->k) x->p = x->m > y->m ? inf : -inf;
		else x->p = div(y->m - x->m, x->k - y->k);
		return x->p >= y->p;
	}

	// kx + m
	void add(ll k, ll m) {
		auto z = insert({k, m, 0}), y = z++, x = y;
		while (isect(y, z)) z = erase(z);
		if (x != begin() && isect(--x, y)) isect(x, y = erase(y));
		while ((y = x) != begin() && (--x)->p >= y->p)
			isect(x, erase(y));
	}

	ll query(ll x) {
		assert(!empty());
		auto l = *lower_bound(x);
		return l.k * x + l.m;
	}
};


int main() {
	FAST;

	int n;
	ll c;
	cin >> n >> c;

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

	LineContainer s;
	vector<ll> dp(n);

	for (int i = 1; i < n; i++) {
		s.add(2 * a[i - 1], -a[i - 1] * a[i - 1] - dp[i - 1]);
		dp[i] = -s.query(a[i]) + c + a[i] * a[i];
	}

	cout << dp[n - 1];
}



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

int cmpnum(const void * n1, const void * n2) {
	if (*(long *)n1 > *(long *)n2)
	{
		return 1;
	}
	else if (*(long *)n1 < *(long *)n2)
	{
		return -1;
	}
	else
	{
		return 0;
	}
}

int main(void) {

  long n,k;
  scanf("%ld %ld", &n, &k);
  long p[n];
  for (long i = 0; i < n; i++) {
    scanf("%ld", &p[i]);
  }
  qsort(p, n, sizeof(long), cmpnum);
  long sum = 0;
  for (long i = 0; i < k; i++) {
    sum += p[i];
  }
  printf("%ld\n", sum);

  return 0;
}

Measured memory_bytes: 1732
#include <bits/stdc++.h>
using namespace std;
int main(){
	int a,b;
	cin >>a>>b;
	int x;
	x = a*b;

	if(x%2==0){
		cout <<"Even"<<endl;
	}
	else if (x%2==1){
		cout <<"Odd"<<endl;
	}

}



Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int x,y,z;
	string s1,s2,s3;
	cin>>s1>>s2>>s3;
	x=(int)s1[0]-32;
	y=(int) s2[0]-32;
	z=(int) s3[0]-32;
	cout<<(char)x<<(char)y<<(char)z; 
}

Measured memory_bytes: 256
#include<algorithm>//sort(all(変数),greater<型名>())で降順に、*max_element(all(変数))で最大値を獲得
#include<bits/stdc++.h>
#include<cmath>//切り上げceil(値)
#include<deque>
#include<iomanip>//setprecision(数字)
#include<iostream>
#include<list>
#include<map>
#include<numeric>
//xとyのgcdは__gcd(x,y),xとyのlcmは(x*y)/__gcd、accumulate(all(変数),0)で要素の全加算
#include<queue>//priority_queue<型名> 変数
#include<set>
#include<stack>
#include<string>
#include<vector>
#define rep(i,n)  for(ll i=0; i<n; i++)
#define rrep(i,n) for(ll i=n-1; 0<=i; i--)
#define vll vector<ll>
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define INF 1e18
using ll = long long;
using namespace std;
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; }

int main(){
  int n,m; cin >> n >> m;
  if(n == 1 and m == 1) cout << 1;
  else if(n == 1) cout << m-2;
  else if(m == 1) cout << n-2;
  else cout << (ll)(m-2)*(n-2);
  return 0;
}


Measured memory_bytes: 256
s=input()
t=input()
dp=[[0]*(len(s)+1) for i in range(len(t)+1)]
for i in range(1,len(t)+1):
  for j in range(1,len(s)+1):
    if s[j-1]==t[i-1]:
      dp[i][j]=max(dp[i-1][j-1]+1,dp[i-1][j],dp[i][j-1])
    else:
      dp[i][j]=max(dp[i-1][j],dp[i][j-1])
ans=[]
a=dp[len(t)][len(s)]
i=len(t)
j=len(s)
while i>0 and j>0:
  if s[j-1]==t[i-1]:
    ans.append(s[j-1])
    i=i-1
    j=j-1
  else:
    if dp[i][j]==dp[i][j-1]:
      j=j-1
    else:
      i=i-1
ans=ans[::-1]
for i in range(len(ans)):
  print(ans[i],end="")
print()

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

#define rep(i, n) for(int i = 0; i < n; ++i)
#define rrep(i, n) for(int i = n - 1; i > -1; --i)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
using namespace std;
const long long INF = 1000000000;
const int MOD = 1000000007;
typedef long long ll;
typedef pair<int, int> P;

int main() {
    int n;
    cin >> n;
    vector<pair<ll, ll>> ab(n, pair<ll, ll>());
    ll a, b;
    rep(i, n){
        cin >> a >> b;
        ab[i] = make_pair(b, a);
    }
    sort(all(ab));
    vector<ll> lis(n + 1);
    lis[0] = 0;
    int f = 0;
    rep(i, n){
        lis[i + 1] = lis[i] + ab[i].second;
        if(lis[i + 1] > ab[i].first){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
 
#define fast { ios :: sync_with_stdio(false); cin.tie(0); cout.tie(0); }
#define pb push_back
#define ll long long
 
#define vi vector<int>
#define vl vector<long>
#define vll vector<long long>
 
#define infi INT_MAX
#define infl LONG_LONG_MAX
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fi(i,a,b) for(ll i=(b-1);i>=a;i--)
#define F first
#define S second
#define G(a,b) get<a>(b)
#define MP make_pair
#define MT make_tuple
#define pll pair<ll,ll> 
#define endl "\n"



void func()
{
  ll arr[]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  ll k;
  cin>>k;
  cout<<arr[k-1]<<endl;
}
 
int main() 
{
    fast
    //freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
    
    ll ntc=1;
    //cin>>ntc;
 
    while(ntc)
    {
      func();
      ntc--;
    }
 
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
vector<int>moji(3);
  for(int i=0;i<3;i++){
  cin>>moji.at(i);
  }
  sort(moji.begin(),moji.end());
if(moji.at(0)+moji.at(1) == moji.at(2)){
cout<<"Yes"<<endl;
}
  else{
  cout<<"No"<<endl;
  }
}

Measured memory_bytes: 256
(function(stdin) {
  // Define Function
  function ascendByNumber(a, b) {
    return a - b;
  }
  // Declare Variable
  const inputs  = stdin.toString().trim().split('\n');
  const cols = inputs[0].split(' ').map(Number);

  // Main Procedure
  const result = (function(a, b, c) {

    const sort = [a, b, c].sort(ascendByNumber).join(' ');

    return sort;

  }(cols[0], cols[1], cols[2]));

  // Display
  console.log(result);

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

Measured memory_bytes: 15560
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std;
const long long int INF = 1e18;
const long long int mod = 1e9+7;

typedef pair<ll, ll> pairs;
typedef vector<pairs> p;

struct Edge{
    ll to, weight;
    Edge(ll t, ll w) : to(t), weight(w){}
};
using graph = vector<vector<ll>>;
using Graph = vector<vector<Edge>>;


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

ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}

ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

// 回文
bool kai(string S){
    bool flag = true;
    for(ll i=0;i<S.size()/2;++i){
        if(S[i] != S[S.size()-i-1]){
            flag = false;
            break;
        }
    }
    return flag;
}
// ---------------------------------------------

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

    queue<ll> que;
    que.push(0);
    vector<ll> done(n, -1);
    done[0] = 0;
    ll flag = 0;
    ll ans[n];
    while(!que.empty()){
        ll p = que.front();
        que.pop();
        for(auto val : g[p]){
            if(done[val] == -1){
                done[val] = flag+1;
                que.push(val);
                ans[val] = p+1;
            }
        }
        flag++;
    }

    bool fl = true;
    for(ll i=0;i<n;++i){
        if(done[i] == -1){
            fl = false;
        }
    }
    if(fl){
        cout<<"Yes"<<endl;
        for(ll i=1;i<n;++i){
            cout<<ans[i]<<endl;
        }
    }else{
        cout<<"No"<<endl;
    }

    return 0;
}

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

int main() {
    ll n, k;
    cin >> n >> k;
    map<ll, ll> m;
    for (ll i = 0; i < n; i++) {
        ll mm;
        cin >> mm;
        m[i] = --mm;
    }

    // k <= n のときは素直に探索しても間に合う。
    if (k <= n) {
        ll machi = 0;
        for (ll i = 0; i < k; i++) {
            machi = m[machi];
        }
        machi++;
        cout << machi << endl;
        return 0;
    }

    // k > n のとき
    // ループまでの回数とループ内の回数を出す

    // ループを探す
    ll mcnt[n];
    fill(mcnt, mcnt + n, 0);
    mcnt[0]++;
    ll loop = 0;
    ll idx = 0;
    for (ll i = 0; i < n; i++) {
        idx = m[idx];
        mcnt[idx]++;
        if (mcnt[idx] >= 2) {
            loop = idx;
            break;
        }
    }

    // ループまでの回数を計算
    ll noloop_cnt = 0;
    ll idx2 = 0;
    for (ll i = 0; i < n; i++) {
        idx2 = m[idx2];
        noloop_cnt++;
        if (idx2 == loop) {
            break;
        }
    }

    // ループ内の回数を計算(loopからloopまで)
    ll loop_cnt = 0;
    ll idx3 = loop;
    for (ll i = 0; i < n; i++) {
        idx3 = m[idx3];
        loop_cnt++;
        if (idx3 == loop) {
            break;
        }
    }

    if (k <= noloop_cnt) {
        ll machi = 0;
        for (ll i = 0; i < k; i++) {
            machi = m[machi];
        }
        machi++;
        cout << machi << endl;
        return 0;
    } else {
        ll machi = loop;
        ll cnt = (k - noloop_cnt) % loop_cnt;
        for (ll i = 0; i < cnt; i++) {
            machi = m[machi];
        }
        machi++;
        cout << machi << endl;
        return 0;
    }
}

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

#define IOS 			ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ld			long double
#define ll 			long long
#define ull			unsigned long long
#define pb			push_back
#define mp			make_pair
#define F			first
#define S			second
#define lb			lower_bound
#define ub			upper_bound
#define deb(x)			cout<<"#x "<<x<<"\n";
#define trace(x,y)		cout<<"#x "<<x<<" #y "<<y<<"\n";
#define cn			cout<<"\n";
#define mod			1000000007

bool SBF(const pair<int,int>& a, const pair<int,int>& b){return a.F < b.F;}
bool SBS(const pair<int,int>& a, const pair<int,int>& b){return a.S < b.S;}

void solve(){
	int n , x , t;
	cin >> n >> x >> t;
	long long ans = (n+x-1)/x;
	ans *= t;
	cout<<ans<<"\n";
}
int main(){
	solve();
}


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

typedef long long ll;

int main() {
    int N, C; cin >> N >> C;
    vector<vector<int>> D(C, vector<int>(C));
    for (int i = 0; i < C; i++) {
        for (int j = 0; j < C; j++) {
            cin >> D[i][j];
        }
    }
    vector<vector<int>> c(N, vector<int>(N));
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            cin >> c[i][j];
            c[i][j]--;
        }
    }
    map<int, int> zero;
    map<int, int> one;
    map<int, int> two;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            if ((i + j) % 3 == 0) zero[c[i][j]]++;
            if ((i + j) % 3 == 1) one[c[i][j]]++;
            if ((i + j) % 3 == 2) two[c[i][j]]++;
        }
    }
    ll ans = 1e12;
    for (int i = 0; i < C; i++) {
        for (int j = 0; j < C; j++) {
            for (int k = 0; k < C; k++) {
                if (i == j || j == k || k == i) continue;
                ll tans = 0;
                for (auto x : zero) tans += D[x.first][i] * x.second;
                for (auto x : one) tans += D[x.first][j] * x.second;
                for (auto x : two) tans += D[x.first][k] * x.second;
                ans = min(tans, ans);
            }
        }
    }
    cout << ans << endl;
}


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

int main() {
    int N; cin >> N;
    string S; cin >> S;

    int ans = 0;
    for(char a = '0'; a<='9'; ++a) {
        for(char b = '0'; b<='9'; ++b) {
            for(char c = '0'; c<='9'; ++c) {
                auto it = find(S.begin(), S.end(), a);
                if(it == S.end()) continue;
                it = find(++it, S.end(), b);
                if(it == S.end()) continue;
                it = find(++it, S.end(), c);
                if(it == S.end()) continue;
                ++ans;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256