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

using namespace std;

using ll = int_fast64_t;
constexpr ll llmax = INT_FAST64_MAX; // std::numeric_limits<int_fast64_t>::max()
constexpr ll llmin = INT_FAST64_MIN; // std::numeric_limits<int_fast64_t>::min()
using ull = uint_fast64_t;
constexpr ull ullmax = UINT_FAST64_MAX; // std::numeric_limits<uint_fast64_t>::max()

#define FOR(i, b, e) for (int i = (b); i < (e); ++i)
#define RFOR(i, b, e) for (int i = ((e) - 1); (b) <= i; --i)
#define REP(i, N) for (int i = 0; i < (N); ++i)
#define RREP(i, N) for (int i = ((N) - 1); 0 <= i; --i)
#define scanInt(x) int x; scanf("%d", &(x)); getchar();
#define scanLLInt(x) ll x; scanf("%lld", &(x)); getchar();
#define scanVecInt(A, N) vector<int> A(N); REP(i, N){scanf("%d", &(A[i])); getchar();}
#define scanVecLLInt(A, N) vector<ll> A(N); REP(i, N){scanf("%lld", &(A[i])); getchar();}

class UnionFind {
  private:
    vector<int> unumber; // 子ノードの場合は親ノードの番号、根ノードの場合は木のノード数*(-1)
  public:
    UnionFind(int N) : unumber(N, -1){} // 各ノードを全て親ノードとして初期化
    int findRoot(int x){ // 根ノードを見つけて返す
        if (unumber[x] < 0) return x;
        return unumber[x] = findRoot(unumber[x]); // 根を張り替えながら再帰的に根ノードを探す
    }
    int unite(int x, int y){ // xとyが含まれる木を結合して、新しい根ノードを返す
        x = findRoot(x);
        y = findRoot(y);
        if (x == y) return x; // 既に同じ木に属しているなら何もしない
        if (unumber[y] < unumber[x]) swap(x, y); // xの木がyの木よりも大きくなるようにする（unumberは負であることに注意）
        // xがyの親ノードになるように連結する
        unumber[x] += unumber[y];
        unumber[y] = x;
        return x;
    }
    bool isSame(int x, int y){return findRoot(x) == findRoot(y);}
    int getSize(int x){return -unumber[findRoot(x)];} // xが含まれる木の大きさを返す
};

int main()
{
    scanInt(N);
    scanInt(M);
    UnionFind uf(N);
    REP(m, M){
        scanInt(Xi); --Xi;
        scanInt(Yi); --Yi;
        scanInt(Zi);
        uf.unite(Xi, Yi);
    }
    int result = 0;
    REP(n, N){
        if (uf.findRoot(n) == n) ++result;
    }
    cout << result << endl;
}


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

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

int main() {
    int n;
    cin >> n;
    string s, t, u;
    int q = 0;

    cin >> s >> t;

    rep(i,n*2){
        u[q] = s[i];
        q++;
        u[q] = t[i];
        q++;
    }

    rep(i,n*2){
        cout << u[i];
    }
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
https://beta.atcoder.jp/contests/abc043/tasks/abc043_a

"""
import sys
from sys import stdin
input = stdin.readline


def solve(N):
    return (1 + N) * N // 2


def main(args):
    N = int(input())
    ans = solve(N)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])
    


Measured memory_bytes: 2940
#include<iostream>
using namespace std;
int main(){
    int n;
    cin>>n;
    int prev=0;
    int count=0;
    bool no=true;
    while(n!=0)
    {
        int element=n%10;
        n/=10;
        if(prev==-1)
        {
            prev=element;
            count=1;
        }
        else
        if(prev==element)
        {
            count++;
            if(count==3)
            {
                no=false;
                break;
            }
        }
        else
        {
            prev=element;
            count=1;
        }
    }
    if(!no)
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
}

Measured memory_bytes: 3644
import sys
input=sys.stdin.readline
#from collections import defaultdict
#d = defaultdict(int)
#import fractions
#import math
#import collections
#from collections import deque
#from bisect import bisect_left
#from bisect import insort_left
#N = int(input())
#A = list(map(int,input().split()))
#S = list(input())
#S.remove("\n")
#N,M = map(int,input().split())
#S,T = map(str,input().split())
#A = [int(input()) for _ in range(N)]
#S = [input() for _ in range(N)]
#A = [list(map(int,input().split())) for _ in range(N)]
#import itertools
#import heapq
#import numpy as np
def rle(s):#計算量N
    c = 0
    tmp, count, ans = s[0], 1, []
    for i in range(1,len(s)):
        if tmp == s[i]:
            count += 1
        else:
            ans.append((-1)*count)
            c += count-1
            count = 1
            tmp = s[i]
    if count > 1:
        ans.append(count*(-1))
        c += count-1
    return ans,c #最大2N文字
N,K = map(int,input().split())
S = input()
ans,c = rle(S)
n = len(ans)
import heapq
heapq.heapify(ans)
MIN = min(n,K)
for i in range(MIN):

    a = heapq.heappop(ans)
    c += 2
if c >= N:
    c = N-1
print(c)


Measured memory_bytes: 53100
#include <cstdio>
#include <algorithm>
#include <vector>

const int MAXN = 200000 + 10;

int pre[MAXN], to[MAXN], head[MAXN], wcnt;
int id[MAXN], bl[MAXN], br[MAXN], idcnt;
int n, m1, m2;

int fa[MAXN], size[MAXN];

void init() {
	int i;
	for(i=1; i<=n; i++) {
		fa[i] = i;
		size[i] = 1;
	}
}
int gf(int x) { return (x ^ fa[x]) ? (fa[x] = gf(fa[x])) : x; }
void merge(int x, int y) {
	x = gf(x);
	y = gf(y);
	if(x ^ y) {
		if(size[x] < size[y])
			std::swap(x, y);
		size[x] += size[y];
		fa[y] = x;
	}
}

std::vector<int> pos[MAXN];

inline void addedge(int u, int v) {
	wcnt++;
	pre[wcnt] = head[u];
	head[u] = wcnt;
	to[wcnt] = v;
}

int main() {
	int i, u, v, l, r;
	
	scanf("%d %d %d", &n, &m1, &m2);
	
	init();
	
	for(i=1; i<=m1; i++) {
		scanf("%d %d", &u, &v);
		merge(u, v);
	}
	for(i=1; i<=n; i++)
		addedge(gf(i), i);
	
	for(u=1; u<=n; u++) {
		l = idcnt + 1;
		for(i=head[u]; i; i=pre[i]) {
			idcnt++;
			id[to[i]] = idcnt;
		}
		r = idcnt;
		for(i=head[u]; i; i=pre[i]) {
			bl[to[i]] = l;
			br[to[i]] = r;
		}
	}
	
	init();
	
	for(i=1; i<=m2; i++) {
		scanf("%d %d", &u, &v);
		merge(id[u], id[v]);
	}
	
	for(i=1; i<=n; i++)
		if(gf(i) == i)
			pos[i].resize(size[i]);
			
	for(i=1; i<=n; i++)
		pos[gf(i)].push_back(i);
		
	for(i=1; i<=n; i++)
		if(gf(i) == i)
			std::sort(pos[i].begin(), pos[i].end());
	
	for(i=1; i<=n; i++) {
		u = gf(id[i]);
		printf("%d ", std::upper_bound(pos[u].begin(), pos[u].end(), br[i]) - std::lower_bound(pos[u].begin(), pos[u].end(), bl[i]));
	}
	putchar('\n');
	return 0;
}

Measured memory_bytes: 17280
#include <algorithm>
#include <iostream>

using namespace std;

const int MD = 1000000007;

int power(int n, int k) {
	if (k == 0)
		return 1;
	int p = power(n, k >> 1);
	p = (long long) p * p % MD;
	if (k & 1)
		p = (long long) p * n % MD;
	return p;
}

int main() {
	int n; cin >> n;
	cout << ((power(10, n) - power(9, n) - power(9, n) + power(8, n)) % MD + MD) % MD << '\n';
	return 0;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    float a,b,c;
    cin>>a>>b>>c;

    bool flag=false;
    if(max(a,max(b,c))==a+b+c-max(a,max(b,c))){
        flag=true;
    }

    flag ? cout << "Yes" << endl:cout << "No" << endl ;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(n) begin(n), end(n)
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts)
{
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }

template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v)
{
    for (auto &e : t)
        fill_v(e, v);
}
int main()
{
    int H, W, K;
    cin >> H >> W >> K;
    auto c = make_v<char>(H, W);
    ll ans = 0;
    for (size_t i = 0; i < H; i++)
    {
        for (size_t k = 0; k < W; k++)
        {
            cin >> c[i][k];
        }
    }

    for (int hbit = 0; hbit < (1 << H); hbit++)
    {

        for (int wbit = 0; wbit < (1 << W); wbit++)
        {
            auto tmp = c;
            for (int i = 0; i < H; i++)
            {
                if (hbit & (1 << i))
                {
                    for (int j = 0; j < W; j++)
                    {
                        tmp[i][j] = 'R';
                    }
                }
            }
            for (int j = 0; j < W; j++)
            {
                if (wbit & (1 << j))
                {
                    for (int k = 0; k < H; k++)
                    {
                        tmp[k][j] = 'R';
                    }
                }
            }
            int cnt = 0;
            for (size_t h = 0; h < H; h++)
            {
                for (size_t w = 0; w < W; w++)
                {
                    if (tmp[h][w] == '#')
                        cnt++;
                }
            }
            if (cnt == K)
                ans++;
        }
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 3628
K, N = map(int, input().split())
Alist = list(map(int, input().split()))

# print(K, N)
# print(Alist)

gaps = []
for i in range(N):
    if i==0:
        gap = Alist[0] + (K - Alist[N-1])
        gaps.append(gap)
    else:
        gap = Alist[i] - Alist[i-1]
        gaps.append(gap)

gapmax = 0

for i, gap in enumerate(gaps):
    # if gapmax < gap:
    gapmax = max(gapmax, gap)
print(K - gapmax)



Measured memory_bytes: 26444
#include <iostream>
#include <utility>
#include <vector>
#include <algorithm>
#define mp make_pair
#define mpp(AA, BB, CC) mp( mp(BB, CC) , AA )
#define F first
#define S second

using namespace std;

int main()
{
    int n, a, p;
    cin >> n;
    vector < int > v;
    int s = 0;
    while(n--){
        cin >> a;
        s += a;
        v.push_back(a);
    }
    cin >> n;
    while(n--){
        cin >> p >> a;
        cout << s + a - v[p-1] << endl;
    }
    return 0;
}










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

#define null                ""
#define all(dat)            dat.begin(), dat.end()
#define over(msg)           puts(msg), exit(0);
#define loop(i, to)         for (int i = 0; i < to; ++i)
#define cont(i, to)         for (int i = 1; i <= to; ++i)
#define forever             for (;;)
#define foreach(i, dat)     for (__typeof(dat.begin()) i = dat.begin(); i != dat.end(); ++i)

typedef long long           num;

using namespace std;

int n, l, q, to = 20, pos[100005], dis[25][100005], ans;

int main() {
	
	scanf("%d", &n);
	
	cont (i, n) {
		
		scanf("%d", pos + i);
		
	}
	
	scanf("%d %d", &l, &q);
	
	cont (i, n) {
		
		dis[0][i] = (int) (upper_bound(pos + 1, pos + n + 1, pos[i] + l) - (pos + 1));
		
	}
	
	cont (i, to) {
		
		cont (j, n) {
			
			dis[i][j] = dis[i - 1][dis[i - 1][j]];
			
		}
		
	}
	
	cont (i, q) {
		
		int a, b;
		
		ans = 0;
		
		scanf("%d %d", &a, &b);
		
		if (a > b) {
			
			swap(a, b);
			
		}
		
		for (int i = to; i >= 0; --i) {
			
			if (dis[i][a] < b) {
				
				ans += 1 << i;
				
				a = dis[i][a];
				
			}
			
		}
		
		ans += a < b ? 1 : 0;
		
		printf("%d\n", ans);
		
	}
	
}


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

#define ARC(i, a, b) for(int i = (a); i < (b); ++i)
#define RC(i, n) ARC(i, 0, n)
#define ARCH(i, a, b) for(int i = (a) - 1; i >= (b); --i)
#define RCH(i, n) ARCH(i, n, 0)

template<typename T> T ant(const T &a, const T &b){ return a > b ? a : b; }
template<typename T> T ont(const T &a, const T &b){ return a < b ? a : b; }
template<typename T> T anti(const T &a, const T &b){ return a == -1 || b == -1 ? -1 : ant(a, b); }
template<typename T> T onti(const T &a, const T &b){ return a == -1 ? b : b == -1 ? a : ont(a, b); }
template<typename T> T rng(const T &a, const T &b){ return a > b ? a - b : b - a; }
template<typename T> T &th(T &a, const T &b, T (*f)(const T &l, const T &r)){ return a = f(a, b); }
#define ANTH(a, b) th(a, b, ant)
#define ONTH(a, b) th(a, b, ont)

template<typename T> T make_v(T val){ return val; }
template<typename... Ts> auto make_v(size_t n, Ts... ts){ return std::vector<decltype(make_v(ts...))>(n, make_v(ts...)); }

int main(){
	int n;
	char S[212345];
	scanf("%d%s", &n, &S);

	int count = 0;
	for(int i = 0; i < n; ++i) count += S[i] == '.';

	int ans = count;
	for(int i = 0; i < n; ++i){
		if(S[i] == '#') ++count;
		else --count;
		ONTH(ans, count);
	}

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


Measured memory_bytes: 512
#include <iostream>
using namespace std;
 
int main() {
  int a, b;
  string op;
  while (true) {
    cin >> a >> op >> b;
    
    if (op == "?") break;
 
    if (op == "+") {
      cout << a + b << endl;
    } else if (op == "-") {
      cout << a - b << endl;
    } else if (op == "*") {
      cout << a * b << endl;
    } else if (op == "/") {
      cout << a / b << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1208
n, k = map(int, input().split())
p = list(map(int, input().split()))
exp_list = []
for i in p:
    expect = (i+1)/2
    exp_list.append(expect)
s = sum(exp_list[0:k])
ans = s
for j in range(n-k):
    s -= exp_list[j]
    s += exp_list[j+k]
    if s > ans :
        ans = s
print(ans)


Measured memory_bytes: 77448
const stdin = require('fs').readFileSync('/dev/stdin', 'utf8')

const [x1, y1, x2, y2] = stdin
  .split('\n')[0]
  .split(' ')
  .map(Number)

const x3 = x2 - (y2 - y1)
const y3 = y2 + (x2 - x1)

const x4 = x1 - (y2 - y1)
const y4 = y1 + (x2 - x1)

console.log(x3, y3, x4, y4)


Measured memory_bytes: 7372
def main():
    year, month, day = map(int, input().split('/'))
    print(solve(year, month, day))

def solve(year, month, day):
    s = 'Heisei'
    t = 'TBD'

    if year > 2019:
        return t
    if year == 2019 and month >= 5:
        return t
    return s

main()


Measured memory_bytes: 2940
#include<iostream>
#include<algorithm>
#include<set>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;
typedef long long ll;

const int MOD=1e9+7;

ll pow(ll a,int p,int m){
	if(p==0)return 1;
	if(p%2==0)return pow(a*a%m,p/2,m)%m;
	else return a*pow(a,p-1,m)%m;
}

int main(){
	int n;
	cin>>n;
	int a[n],tmp[n];
	rep(i,n)cin>>a[i];
	sort(a,a+n);
	if(n%2==0)for(int i=0;i<n;i+=2)tmp[i]=tmp[i+1]=i+1;
	else{
		tmp[0]=0;
		for(int i=1;i<n;i+=2)tmp[i]=tmp[i+1]=i+1;
	}
	bool check=false;
	rep(i,n){
		if(a[i]!=tmp[i]){check=true;break;}
	}
	if(check)cout<<0<<endl;
	else{
		ll ans=pow(2,n/2,MOD);
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+5;
int a[N],n,i,j;
long long f[N][5],x;
int main(){
	scanf("%d",&n);
	f[0][1]=f[0][2]=f[0][3]=f[0][4]=1ll<<60;
	for(i=1;i<=n;++i){
		scanf("%d",a+i);
		f[i][0]=f[i-1][0]+a[i];
		f[i][1]=min(f[i-1][0],f[i-1][1])+(a[i]?a[i]%2:2);
		f[i][2]=min(f[i-1][0],min(f[i-1][1],f[i-1][2]))+1-a[i]%2;
		f[i][3]=min(min(f[i-1][0],f[i-1][1]),min(f[i-1][2],f[i-1][3]))+(a[i]?a[i]%2:2);
		f[i][4]=min(min(min(f[i-1][0],f[i-1][1]),min(f[i-1][2],f[i-1][3])),f[i-1][4])+a[i];
	}
	x=1ll<<60;
	for(j=0;j<5;++j)x=min(x,f[n][j]);
	cout<<x<<endl;
	return 0;
}

Measured memory_bytes: 8832
#include <iostream>

using namespace std;
const int MAX = 10001;
const int QMAX = 501;

bool search(int *a, int n, int key) {
    int i = 0;
    a[n] = key;
    while( a[i] != key) i++;
    return i != n;
}

int main() {
    int n;
    cin >> n;
    int S[MAX];
    for (int i = 0; i < n; i++) {
        cin >> S[i];
    }
    int q;
    cin >> q;
    int T[QMAX];
    for (int i = 0; i < q; i++) {
        cin >> T[i];
    }
    int count = 0;
    for (int i = 0; i < q; i++) {
        int c = T[i];
        if (search(S, n, c)) count++;
    }
    cout << count << endl;
}



Measured memory_bytes: 3120
import bisect
import math
N, H = map(int, input().split())
a, b = [], []
for i in range(N):
    ta, tb = map(int, input().split())
    a.append(ta)
    b.append(tb)
ma = max(a)
b.sort()
b = list(reversed(b[bisect.bisect_left(b, ma):]))
ans = 0
for i in range(len(b)):
    ans += 1
    H -= b[i]
    if H <= 0:
        print(ans)
        exit()
print(ans + math.ceil(H / ma))


Measured memory_bytes: 12624
/**
 *COYG, 14 FA Cups we are back baby
 */
#include <bits/stdc++.h>
using namespace std;
#define mod 		1000000007
#define ll 		long long
#define mp 		make_pair
#define pb 		push_back
#define forn(i,n) 	for(int i=0;i<n;i++)
#define for1(i,n) 	for(int i=1;i<n;i++)
#define ford(i,n) 	for(int i=n-1;i>=0;i--)
#define vi 		vector<int>
#define vl 		vector<ll>
#define pii 		pair<int,int>
#define pll 		pair<ll,ll>
#define vpi 		vector<pair<int,int> >
#define vpl		vector<pair<ll,ll> >
#define vvi 		vector<vector<int> >
#define vvl 		vector<vector<ll> >
#define ull 		unsigned long long
#define IOS 		ios_base::sync_with_stdio(false);
#define PI 		3.1415926535897932384626
#define ff 		first
#define ss 		second
#define char2Int(c) 	(c-'0')
#define FOREACH(i,t) 	for (auto i=t.begin(); i!=t.end(); i++)
#define clr(a,x) 	memset(a,x,sizeof(a)) //set elements of array to some value
#define all(x)		(x).begin(),(x).end()//cout<<"Case #"<<zzz<<": ";
#define plll pair<ll,pll >
ll n;vl a;
ll dp[101][100001];
void solve()
{
    cin>>n;ll k;cin>>k;a.resize(n);forn(i,n)cin>>a[i];
    for(int i=0;i<=n;i++)for(int j=0;j<=k;j++)dp[i][j]=0;
    for(int i=0;i<=k;i++)dp[n][i]=1;
    for(int i=n-1;i>0;i--)
    {
        ll curr=0;
        for(int rem=0;rem<=k;rem++)
        {
            if(a[i]>=rem)curr=(curr+dp[i+1][rem])%mod;
            else
            {
                curr=(curr+(dp[i+1][rem]-dp[i+1][rem-a[i]-1]))%mod;
            }
            dp[i][rem]=curr;
        }
    }
    ll ans;
    if(a[0]==k)
    {
        ans=dp[1][k];
    }
    else
    {
        ans=(dp[1][k]-dp[1][k-a[0]-1]+mod)%mod;
    }
    cout<<ans<<endl;
}
int main()
{
    IOS;cin.tie(NULL);
    ll zz;zz=1;
    //cin>>zz;
    for(int zzz=1;zzz<=zz;zzz++)
    {
        solve();
    }
    return 0;
}


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

Measured memory_bytes: 580
#include <cstdio>
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>

#define ll long long

#define reps(i, s, n) for (int i = s; i < (n); i++)
#define rep(i, n) reps(i, 0, n)

using namespace std;

void init()
{
}

void solve()
{
	int k;
	string s;
	cin >> k >> s;

	if (s.size() <= k)
	{
		cout << s << endl;
		return;
	}

	cout << s.substr(0, k) << "..." << endl;
}

int main()
{
	init();
	solve();
}


Measured memory_bytes: 3136
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <list>
#include <string>
#include <math.h>
#include <set>
#include <string>
#include <numeric>
#include <malloc.h>
using namespace std;

bool StringCompare(string A,string B)
{
	if(A.length()>B.length())
	{
		return true;
	}
	else if(A.length()<B.length())
	{
		return false;
	}
	else
	{
		if(A.compare(B)>=0)
		{
			return true;
		}
		else
		{
			return false;
		}
	}
}
int main()
{
	int N,M;
	cin>>N>>M;
	int cost[] = {2,5,5,4,5,6,3,7,6};
	vector<int> A;
	A.resize(M);
	for(int i=0; i<M; i++)
	{
		cin>>A[i];
	}

	vector<string> result;
	result.resize(N+1);
	for(int i=0; i<=N; i++)
	{
		result[i] = "";
	}
	//配るDPを構築
	for(int i=0; i<N; i++)
	{
		for(int j=0; j<M; j++)
		{
			if(result[i]=="" && i>0)
			{
				break;
			}
			if(i+cost[A[j]-1]>N)
			{
				continue;
			}
			if(StringCompare(result[i]+to_string(A[j]),result[i+cost[A[j]-1]]))
			{
				result[i+cost[A[j]-1]]=result[i]+to_string(A[j]);
			}
			
		}
	}
	cout<<result[N]<<endl;
	return 0;
}

Measured memory_bytes: 32896
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (ll i=0; i<(n); ++i)
typedef long long ll;
bool debug=false;
string yes = "Yes";
string no = "No";
ll mod = 1000000007;
int main(){
  ll n; cin >> n;
  vector<ll> a(n);
  ll sum = 0;
  vector<ll> sm(n,0), la(n,0);
  sm[0]=0;
  sm[1]=0;
  rep(i,n){
    cin >> a[i];
    sum+=a[i];
    if(i<n-2){
      sm[i+2]+=sm[i]+a[i];   
    }
  }
  la[n-1]=0;
  la[n-2]=a[n-1];
  for(ll j=n-1; j>=2; j--){
    if(j>1){
      la[j-2]+=la[j]+a[j-1];
    }
  }
  rep(i,n){
    cout << sum-2*(sm[i]+la[i]) << " " ;
  }
  return 0;
}




Measured memory_bytes: 3712
#include <iostream>
#include<bits/stdc++.h>
#define ll long long
using namespace std;
 
 
int main()
{
	int i, j;
	ll n;
	scanf("%lld", &n);
	if (n % 2ll == 1ll) printf("0");
	else {
		ll cnt = 0ll;
		ll temp = n/2ll;
		while (temp) {
			cnt += temp / 5ll;
			temp /= 5ll;
		}
		printf("%lld", cnt);
	}
	return 0;
}

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

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

int main(){
  int K;
  cin >> K;
  int sum = 0;
  for(int i =1; i <= K;i++){
    for(int j = 1; j <= K; j++){
      for(int k = 1; k <=K; k++){
        int  l =gcd(i,j);
        sum +=gcd(k,l);
      }
    }
  }
  cout << sum << endl;

}


Measured memory_bytes: 3676
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=100010;
const ll mod=1e9+7;

struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%mod+mod)%mod){}
    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; }
};

int main(){
  int n;
  ll k;
  cin >> n >> k;
  vector<ll> a(n);
  rep(i,n){
    cin >> a[i];
  }
  mint ans = 0;
  mint rr = k*(k-1)/2;
  rep(i,n){
    ll cnt = 0;
    rep(j,n){
      if(a[i]>a[j]) cnt++;
    }
    ans += rr * cnt;

    cnt = 0;
    REP(j,i,n){
      if(a[i]>a[j]) cnt++;
    }
    ans += k * cnt;
  }
  cout << ans.x << endl;
  return 0;  
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#define int long long
using namespace std;
int ar[114514], l = 0;
void f(int t) {
	ar[l] = t; l++;
}
int ans[450][450];
void g(int k) {
	cout << "Yes\n" << k + 1 << endl;
	int cnt = 1;
	for (int p = 0; p < k; p++) {
		for (int j = 0; j < k - p; j++) {
			ans[p][j + p] = cnt;
			ans[j + p + 1][p] = cnt;
			cnt++;
		}
	}
	for (int p = 0; p < k + 1; p++) {
		cout << k;
		for (int q = 0; q < k; q++) {
			cout << ' ' << ans[p][q];
		}
		cout << endl;
	}
}
signed main() {
	int cnt = 0;
	for (int i = 1; cnt <= 100000; i++) {
		cnt += i;
		f(cnt);
	}
	int n; cin >> n;
	for (int i = 0; i < l; i++) {
		if (ar[i] == n) {
			g(i + 1);
			return 0;
		}
	}
	cout << "No\n";
}

Measured memory_bytes: 2944
#include <iostream>

int main()
{
    int A, B, C, X;
    std::cin >> A >> B >> C >> X;

    int ans = 0;
    for (int i = 0; i <= A; i++) {
        for (int j = 0; j <= B; j++) {
            for (int k = 0; k <= C; k++) {
                if (i == 0 && j == 0 && k == 0) continue;
                if (500 * i + 100 * j + 50 * k == X) ans++;
            }
        }
    }

    std::cout << ans << std::endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	static Scanner scanner;

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

	    int A=gi();
	    int B=gi();
	    int C=gi();
	    int K=gi();


        //System.out.print(c);
        if (K<A) {
        	System.out.println(K);
        }else if(K<A+B){
        	System.out.println(A);
        } else {
        	System.out.print(A-(K-A-B));
        }
	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}

	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

Measured memory_bytes: 35640
#include<iostream>
using namespace std;
int main() {
    int N, res;
    int num[150];
    cin >> N;
    for(int i = 0; i < N; i++) {
        cin >> num[i];
    }
    for(int i = 0 ; i < N ; i++) {
        int minIndex = i;
        for(int j = i; j < N; j++) {
            if(num[j] < num[minIndex]) {
                minIndex = j;
            }
        }
        if(minIndex != i) {
            num[i] ^= num[minIndex];
            num[minIndex] ^= num[i];
            num[i] ^= num[minIndex];
            res++;
        }
    }
    for(int i = 0; i < N; i++) {
        cout << num[i];
        if(i < N - 1) cout << ' ';
    }
    cout << "\n" << res << endl;
    return 0;
}


Measured memory_bytes: 3100
h = Array.new(4){ Array.new(3){ Array.new(10,0) } }
n = gets.to_i
n.times do
  a,b,c,d = gets.split.map(&:to_i)
  h[a-1][b-1][c-1] += d
end

for i in 0...4
  puts "#"*20 if i>0
  for j in 0...3
    puts " "+h[i][j].join(" ")     
  end
end

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
//const ull mod = 1e9 + 7;
const ll mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

// debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}
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 (a>b) { a=b; return 1; } return 0; }

// conversion number to bit
string num2bit(ll num, ll len){
  string bit = "";
  REP(i, len){
    bit += char('0'+(num>>i & 1));
  }
  return bit;
}

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

    ll N, M;
    cin >> N >> M;
    vector<ll> cnt(M, 0);
    REP(i, N){
    	ll K;
    	cin >> K;
    	REP(j, K){
    		ll A;
    		cin >> A;
    		A--;
    		cnt[A]++;
    	}
    }

    ll res = 0;
    REP(i, M) if(cnt[i]==N) res++;
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vll = vector<ll>;
using vpii = vector<pii>;
using vpll = vector<pll>;
using vs = vector<string>;
template <typename T>
using ost = tree<T, null_type, less<T>, rb_tree_tag,
    tree_order_statistics_node_update>;
#define forn(i,n) for(int i=0; i<int(n); ++i)
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define ff first
#define ss second

int main() {
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    map<ll, ll> cnt;
    cnt[0]=1;
    ll ans=0, sum=0;
    for (ll x; cin >> x;) {
        sum += x;
        ans += cnt[sum];
        cnt[sum]++;
    }
    cout << ans << '\n';
}


Measured memory_bytes: 12800
#include <iostream>
#include <queue>
#define PII pair<int, int>
#define F first
#define S second
using namespace std;
int n, v[100005];
PII k;
deque<PII> dq;

int main() {
	cin>>n;
	dq.push_back(PII(1, 1));
	while(1) {
		k = dq.front(); dq.pop_front();
		if(v[k.F]) continue;
		v[k.F] = 1;
		if(!k.F) break;
		dq.push_front(PII(k.F*10 % n, k.S));
		dq.push_back(PII((k.F*10+1) % n, k.S+1));
	}
	cout<<k.S;
	return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
 
using namespace std;
#define ll long long
#define ld long double
 
int main()
{
    ios_base::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL);
    int n;
    cin >> n;
    n *= 2;
    int a[n];
    for(int i=0;i<n;i++) {
        cin >> a[i];
    }
    sort(a, a + n);
    int sum = 0;
    for(int i=0;i<n;i+=2) {
        sum += a[i];
    }
    cout << sum;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define Would
#define you
#define all(n)  n.begin(),n.end()
#define rall(n) n.rbegin(),n.rend()
typedef long long ll;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
const double EPS = 1e-10;
const double pi = acos(-1);//3.1415926535897932384626433832795028...
const ll SIZE = 1 << 17;
int dx[] = { 1,0,-1,0 }, dy[] = { 0,1,0,-1 }, alp[30];
ll fac[200005], finv[200005], inv[200005];
vector<ll>dij;
struct edge { ll to, cost; };
vector<vector<edge> >G;

ll mod_pow(ll a, ll b) {
	ll res = 1, mul = a;
	for (int i = 0; i < 31; ++i) {
		if (b >> i & 1) {
			res *= mul;
			res %= MOD;
		}
		mul = (mul * mul) % MOD;
	}
	return res;
}

void addedge(int from, int to, int cost) {
	G[from].push_back({ to,cost });
	G[to].push_back({ from,cost });
}

template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}

template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T & t, const V & v) { t = v; }

template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T & t, const V & v) {
	for (auto& e : t) fill_v(e, v);
}

template<typename T>
void outp(vector<T>v) {
	for (int i = 0; i < v.size(); ++i) {
		cout << v[i];
		if (i != v.size() - 1) { cout << " "; }
	}
}

double add(double a, double b) {
	if (abs(a + b) < EPS * (abs(a) + abs(b))) { return 0; }
	return a + b;
}

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

	for (int i = 1; i <= 9; ++i) {
		for (int j = 1; j <= 9; ++j) {
			if (i * j == n) { cout << "Yes" << endl; return 0; }
		}
	}
	cout << "No" << endl;

}


Measured memory_bytes: 256
import sys
import math
import numpy as np
stdin = sys.stdin
 
ni = lambda: int(ns())
na = lambda: list(map(int, input().split()))
ns = lambda: input()
MOD = 998244353
N = ni()
a = np.array([int(input()) for i in range(N)])
sum_a = np.sum(a)
dp = np.zeros((N+1, sum_a+1), dtype=np.int64)
dp[0,0] = 1
 
for i in range(1, N+1):
    #print(dp)
    a_i = a[i-1]
    dp[i,a_i:] += dp[i-1,:-a_i]
    #print(dp[i,:])
    #print("========")
    dp[i,:] += dp[i-1,:]*2
    dp[i,:] %= MOD
#print(dp)
ex = np.sum(dp[N,(sum_a+1)//2:])%MOD

res = 3**N%MOD -ex*3

if sum_a%2 == 0:
    dp = np.zeros((N+1, sum_a+1), dtype=np.int64)
    dp[0,0] = 1
    for i in range(1, N+1):
        a_i = a[i-1]
        dp[i,a_i:] += dp[i-1,:-a_i]
        dp[i,:] += dp[i-1,:]
        dp[i,:] %= MOD
    res += dp[N, sum_a//2] * 3
print(res%MOD)




Measured memory_bytes: 223696
#include <bits/stdc++.h>
//---------------------------
using namespace std;
//---------------------------
#define REP(i,n) for(int i = 0; i < (n); i++)
#define P(x) cout << (x) << "\n"
#define fcout cout << fixed << setprecision(18)

#define MOD 1000000007 // 1e9+7
#define PI 3.1415926535
/*
3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679
*/
#define ll long long int // 10^18
#define INF 1000000001 // 1e9+1
#define LINF 1000000000000000001 // 1e18+1

int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};
//---------------------------
ll a[200];
int main(){
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  // ifstream in("input.txt");
  // cin.rdbuf(in.rdbuf());

  int n;cin>>n;
  REP(i,n){
    cin>>a[i];
  }
  ll maxn=0;
  REP(i,n){
    REP(j,n){
      maxn=max(maxn, abs(a[i] - a[j]));
    }
  }
  P(maxn);
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

//Maximum Sum
public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true){
			int n = sc.nextInt();
			int k = sc.nextInt();
			if(n==0&&k==0)break;
			int a[] = new int[n];
			for(int i=0;i<n;i++)a[i]=sc.nextInt();
			int s = 0;
			int t = 0;
			int tmp = 0;
			while(t < k){
				tmp += a[t];
				t++;
			}
			int max = tmp;
			while(t < n){
				tmp -= a[s++];
				tmp += a[t++];
				max = Math.max(max, tmp);
			}
			System.out.println(max);
		}
	}
}

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

#define rep(i, N) for (ll i = 0; i < N; i++)
#define rep1(i, N) for (ll i = 1; i <= N; i++)
#define repr(i, N) for (ll i = N-1; i >= 0; i--)
#define repr1(i, N) for (ll i = N; i > 0; i--)

#define MOD 1000000007

using ll = long long;
using namespace std;

typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<P> vpi;


int main() {
    ll N,M,ans = 0,num = 0;
    cin >> N >> M;
    
    if(abs(N - M) > 1)
        ans = 0;
    else{
        ans = 1;
        rep1(i,N){
            ans *= i;
            ans %= MOD;
        }
        rep1(i,M){
            ans *= i;
            ans %= MOD;
        }
        if(abs(N - M) == 0)
            ans = (ans * 2) % MOD;
    }

    cout << ans;
    //printf("%.15lf", ans);
    cout << "\n";
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
const double PI=3.14159265358979323846;
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "

int keta(int n){
    int ans = 0;
    while(n>0){
        ans++;
        n/=10;
    }
    return ans;
}


int main(void){
    int n;cin>>n;
    int ans=0;
    rep1(i,n){
        if(keta(i)%2==1)ans++;
    }
    co(ans);
}




Measured memory_bytes: 256
def main():
    s = input()
    kazu = len(s)
    onelen = 0
    zerolen = 0
    
    for i in range(kazu):
        if s[i] == "1":
            onelen += 1
        else:
            zerolen += 1
    
    print(min(onelen, zerolen) * 2)


if __name__ == "__main__":
    main()

Measured memory_bytes: 65216
n,y=map(int,input().split())

gosen=-1
for itiman in range(n+1):
    tmp=y-itiman*10**4
    if(tmp<0):
        break
    tmp-=1000*(n-itiman)
    if(tmp%4000==0 and 0<=tmp//4000 <=n-itiman):
        gosen=tmp//4000
        break


if(gosen==-1):
    print("-1 -1 -1")
else:
    print("{} {} {}".format(itiman,gosen,n-itiman-gosen))

Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<algorithm>
#include<map>
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;



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


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#include<unordered_map>
using namespace std;
//<DEFINE>
void Fast() {
	ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
}
void File() {
#ifndef ONLINE_JUDGE
	freopen("Input.txt", "r", stdin);
	freopen("Output.txt", "w", stdout);
#endif
}
#ifdef _MSC_VER
#include <intrin.h>
#define __builtin_popcount __popcnt
#ifdef _WIN64
#define __builtin_popcountll __popcnt64
#else
inline int __builtin_popcountll(__int64 a) {
	return __builtin_popcount((unsigned int)a) + __builtin_popcount(a >> 32);
}
#endif
#endif
using ll = long long;
using ull = unsigned long long;
#define mod 1000000007
ll gcd(ll a, ll b) {
	return!b ? a : gcd(b, a % b);
}
#define fix(n) cout << fixed << setprecision(n);
#define all(a) a.begin(), a.end()
#define skip continue
#define stop(n) return cout<<n,0
#define pi  acos(-1)
#define endl "\n"
#define ceil(x,y) (x+y-1)/y//be careful from the multiplication while using this define 
#define TC int t;cin>>t;while(t--)
//</DEFINE>
int n, m;
vector<vector<int>>v;
//<FUNCTIONS>
//</FUNCTIONS>	
int main() {
	Fast(), File();
	int n, cpcty;
	cin >> n >> cpcty;
	vector<vector<ll>>dp(n, vector<ll>(cpcty + 1));
	vector<pair<ll, ll>>v(n);
	for (int i = 0; i < n; i++)cin >> v[i].first >> v[i].second;
	for (int i = v[n - 1].first; i <= cpcty; i++)dp[n - 1][i] = v[n - 1].second;
	for (int i = n - 2; i >= 0; i--) {
		for (int j = 1; j <= cpcty; j++) {
			if (j >= v[i].first)dp[i][j] = max(dp[i + 1][j - v[i].first] + v[i].second, dp[i + 1][j]);
			else dp[i][j] = dp[i + 1][j];
		}
	}
	cout << dp[0][cpcty] << endl;
}

Measured memory_bytes: 82264
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>

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

    std::vector<int> a;
    for(int i=0; i<N; i++){
        int ai;
        std::cin >> ai;
        a.push_back(ai);
    }

    sort(a.begin(), a.end(), std::greater<int>());

    int alice = 0;
    int bob = 0;
    for(int i=0; i<N; i=i+2){
        alice = alice + a[i];
    }
    for(int i=1; i<N; i=i+2){
        bob = bob + a[i];
    }

    std::cout << alice - bob;

    return 0;
}


Measured memory_bytes: 256
/**
 * File    : D2.cpp
 * Author  : Kazune Takahashi
 * Created : 2018-2-11 15:47:35
 */

#include <iostream>
#include <iomanip>   // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple>
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set>
#include <random> // random_device rd; mt19937 mt(rd());
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;

#define DEBUG 0 // change 0 -> 1 if we need debug.

typedef long long ll;

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

// const int C = 1e6+10;
// const ll M = 1000000007;

string S;

int main()
{
  cin >> S;
  char x;
  int lb, ub;
  if (S.size() % 2 == 0)
  {
    x = S[S.size() / 2];
    lb = S.size() / 2 - 1;
    ub = lb + 1;
  }
  else
  {
    x = S[S.size() / 2];
    lb = S.size() / 2 - 1;
    ub = lb + 2;
  }
  while (0 <= lb && ub < (int)S.size())
  {
    if (S[lb] == x && S[ub] == x)
    {
      lb--;
      ub++;
    }
    else
    {
      break;
    }
  }
  cout << ub << endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pi atan(1.0)*4
#define pb(x) push_back(x)
#define in(x) insert(x)
#define fl(x,y) for(ll i=x;i<y;i++)
int main()
{
    ll t,n,k,p,q,r,sum,ct=0,flag=0;
    string s,s1,s2,s3;
    set<ll>st;
    map<ll,ll>mp;
    vector<ll>v;
      cin>>n>>k;
      
      cout<<n*k<<endl;
}





Measured memory_bytes: 3624
/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Code author: Saurabh Singhal
Code copy karne vaale tera muh kaala
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/

#include<bits/stdc++.h>
#define mp(a,b) make_pair(a,b)
#define pb push_back
#define ppb pop_back

using namespace std;
typedef long long int ll;
typedef vector<int> vi_t;
typedef vector<ll> vll_t;
int t=1,n,m,k;
vll_t a,b;

int main(){
	//scanf("%d",&t);
	while(t--){
		int n,q;
		cin>>n>>q;
		string s;
		cin>>s;
		vector<int>dp(n+1,0);
		dp[0]=0;
		dp[1]=0;
		for(int i=2;i<=n;i++){
			if(s[i-1]=='C'&&s[i-2]=='A'){
				dp[i]=dp[i-1]+1;
			}
			else{
				dp[i]=dp[i-1];
			}
		}
		// for(int i=1;i<=n;i++){
		// 	cout<<dp[i]<<" ";
		// }
		cout<<endl;
		for(int i=0;i<q;i++){
			int l,r;
			cin>>l>>r;
			cout<<dp[r]-dp[l]<<endl;
		}
	}
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#include <math.h>
#include <vector>
#include <queue>
#include <iomanip>
#include <string>
#include <algorithm>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep_1 (i,j,n) for(int i=j;i<n;i++)
typedef long long ll;
typedef long l;
const ll l_INF = 1010101010101010;
const int INF = 1010101010;
const int dx[4] = {-1,0,1,0};
const int dy[4] = {0,-1,0,1};
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vi>;
using vvll = vector<vll>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(){
  int n; cin>>n;
  string s; cin>>s;
  set<int> ans;
  int cnt=0;
  rep(i,10){
    rep(j,10){
      rep(k,10){
        bool judge1=false,judge2=false,judge3=false;
        rep(x,n){
          if(!judge1&&i==s[x]-'0') judge1=true;
          else if(!judge2&&!judge3&&judge1&&s[x]-'0'==j) judge2=true;
          else if(!judge3&&judge2&&s[x]-'0'==k) judge3=true;
        }
        if(judge3){
          cnt++;
          //cout<<i*100+j*10+k<<" ";
        }
      }
    }
  }
  //cout<<endl;
  cout<<cnt;
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define leadinz zero str.erase(0, min(str.find_first_not_of('0'), str.size()-1));
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
string text="abcdefghijklmnopqrstuvwxyz";
const int maxn=1e6+7;
//        .--------------.
//        | Try First One|
//        '--------------'
//                |     .--------------.
//                |     |              |
//                V     V              |
//              .--------------.       |
//              |      AC.     |<---.  |
//              '--------------'    |  |
//              (True)|  |(False)   |  |
//           .--------'  |          |  |
//           |           V          |  |
//           |  .--------------.    |  |
//           |  |   Try Again  |----'  |
//           |  '--------------'       |
//           |                         |
//           |  .--------------.       |
//           '->| Try Next One |-------'
//              '--------------'
ll bin_pow(ll a,ll b,ll m)
{
    ll res=1;
    a%=m;
    while(b>0){
        if(b&1)res=res*a%m;
        b>>=1;
        a=a*a%m;
    }
    return res;
}
bool miller_rabin(ll d,ll n)
{
    ll a=2+rand()%(n-4);
    ll x=bin_pow(a,d,n);
    if(x==1 || x==n-1)return true;
    while(d!=n-1){
        x=(x*x)%n;
        d*=2;
        if(x==1)return false;
        if(x==n-1)return true;
    }
    return false;
}
bool prime(ll n,ll k)
{
    if(n==1 || n==4)return false;
    if(n<=3)return true;
    ll d=n-1;
    while(d%2==0)d/=2;
    for(int i=0;i<k;i++){
        if(!miller_rabin(d,n))return false;
    }
    return true;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,k;
    cin>>n>>k;
    int a[n+3];
    for(int i=1;i<=n;i++)cin>>a[i];
    if(k==1)return cout<<n<<endl,0;
    k--;
    //sort(a+1,a+1+n,[](int i,int j){return i<j;});
    int cnt=0;
    for(int i=1;i<n;i+=k){
        cnt++;
    }
    cout<<cnt<<endl;
}


Measured memory_bytes: 640
N = int(input())

ans = 0
if 1<=N and N<10:
    ans = 0+N
elif 10<=N and N<100:
    ans = 9
elif 100<=N and N<1000:
    ans += 9+N-99
elif 1000<=N and N<10000:
    ans = 909
elif 10000<=N and N<100000:
    ans += 909+N-9999
else:
    ans = 90909
print(ans)

#9 #1 2 3 4 5 6 7 8 9
#0 #    10
#900 #100 101 102 ... 999
#0 #    1000
#90000 #10000 10001 ... 99999
#0 #    100000


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

YES = "Yes"  # type: str


def solve(N: int, M: int, A: "List[int]", B: "List[int]"):
    visited = set()
    visited.add(1)
    res = [0 for _ in range(N+1)]
    To = {}
    for a, b in zip(A, B):
        if a in To:
            To[a].add(b)
        else:
            To[a] = set()
            To[a].add(b)
        if b in To:
            To[b].add(a)
        else:
            To[b] = set()
            To[b].add(a)
    crt = set()
    crt.add(1)
    crt2 = set()
    while(len(visited) < N):
        for i in crt:
            for j in To[i]:
                if j not in visited:
                    res[j] = i
                    visited.add(j)
                    crt2.add(j)
        crt = set(crt2)
        crt2.clear()

    print(YES)
    for i in range(2, N+1):
        print(res[i])
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    A = [int()] * (M)  # type: "List[int]"
    B = [int()] * (M)  # type: "List[int]"
    for i in range(M):
        A[i] = int(next(tokens))
        B[i] = int(next(tokens))
    solve(N, M, A, B)

if __name__ == '__main__':
    main()

Measured memory_bytes: 139236
str_num, a,b,c = 1, 0, 0, 0
for i in input():
    if i == 'A':
        a += str_num
    elif i == 'B':
        b += a
    elif i == 'C':
        c += b
    else:
        str_num, a,b,c = (3*str_num) % (10**9+7), (3*a+str_num) % (10**9+7), (a+3*b) % (10**9+7), (b+3*c) % (10**9+7)
print(c % (10**9+7))

Measured memory_bytes: 3188
import itertools


n = int(input())
a = [int(i) for i in input().split()]
q = int(input())
m = [int(i) for i in input().split()]
total = set()

for bits in itertools.product([0, 1], repeat=n):
    total.add(sum([i * j for (i, j) in zip(a, bits)]))

ans = ["yes" if x in total else "no" for x in m]
print(*ans, sep="\n")



Measured memory_bytes: 5724
#include<stdio.h>
#include<string.h>
#define N 1001
int c[N][N];
char X[N],Y[N];
int LCSLength(){
  int i,j,m,n;

  m = strlen(X);
  n = strlen(Y);
  for(i=1;i<=m;i++)
    c[i][0]=0;
  for(j=0;j<=n;j++)
    c[0][j]=0;
  for(i=1;i<=m;i++){
    for(j=1;j<=n;j++){
      if(X[i-1]==Y[j-1])
	c[i][j]=c[i-1][j-1]+1;
      else if(c[i-1][j]>=c[i][j-1])
	c[i][j]=c[i-1][j];
      else
	c[i][j]=c[i][j-1];
    }
  }
  return c[i-1][j-1];  
}
int main(){
  int i,j,p,x;
  scanf("%d",&p);
  for(i=0;i<p;i++){
    scanf("%s",&X);
    scanf("%s",&Y);
    x=LCSLength();
    printf("%d\n",x);
  }
  return 0;
}

Measured memory_bytes: 4516
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define ms(arr) memset(arr, 0, sizeof(arr))
const int inf = 0x3f3f3f3f;
ll a,b,c;
int main() 
{
    cin>>a>>b>>c;
    if(a%2==0||b%2==0||c%2==0) {
        cout<<0;
        return 0;
    }
    cout<<min(min(a*b,a*c),b*c)<<endl;

}

Measured memory_bytes: 256