akhauriyash/Code-Regression huggingface dataset:
// In the name of God

#include <iostream>
#include <algorithm>
#include <fstream>
#include <vector>
#include <deque>
#include <assert.h>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <stdio.h>
#include <string.h>
#include <utility>
#include <math.h>
#include <bitset>
#include <iomanip>
#include <complex>

using namespace std;

#define rep(i, a, b) for (int i = (a), i##_end_ = (b); i < i##_end_; ++i)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define mp make_pair
#define x first
#define y second
#define pb push_back
#define SZ(x) (int((x).size()))
#define ALL(x) (x).begin(), (x).end()

template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }
template<typename T> inline bool smin(T &a, const T &b)   { return a > b ? a = b : a;    }
template<typename T> inline bool smax(T &a, const T &b)   { return a < b ? a = b : a;    }

typedef long long LL;

const int N = (int) 1 << 21, mod = (int) 0;
int odp[N][2], dp[N][2], cnt[N];
int main() {
	int n, k;
	cin >> n >> k;
	for (int j = 0; j < n + 1; ++j) {
		string s;
		cin >> s;
		int code = 1 << j;
		for (int mask = 0; mask < (1 << j); ++mask) {
			cnt[code | mask] += s[mask] - '0';	
		}
	}
	for (int mask = 0; mask < N; ++mask) dp[mask][0] = dp[mask][1] = cnt[mask];
	memset(cnt, 0, sizeof cnt);
	for (int sz = 1; sz <= n; ++sz) {
		memcpy(odp, dp, sizeof dp);
		memset(dp, 0, sizeof dp);
		for (int mask = 1; mask < (1 << n + 1); ++mask) {
			for (int nxt = 0; nxt <= 1; ++nxt) if (odp[mask][nxt]) {
				int x = mask >> (sz - 1), o = mask & ((1 << (sz - 1)) - 1);
				if (!x) continue;
				int h = 0;
				for (int j = n; j >= 0; --j) if (x >> j & 1) {
					h = j;
					break;
				}
				int move = -1;
				for (int j = h - 1; j >= 0; --j) {
					if ((x >> j & 1) == nxt) {
						move = x & ((1 << j) - 1);
						move |= 1 << j;
						break;
					}
				}
				if (move >= 1) {
					for (int i = 0; i <= 1; ++i)
						dp[(move << sz) | (o << 1 | nxt)][i] += odp[mask][nxt];
				}
			}
		}
		for (int mask = 1; mask < (1 << n + 1); ++mask) {
			int x = mask >> sz, o = mask & ((1 << sz) - 1);
			if (x >= 1) {
				o |= 1 << sz;
				cnt[o] += dp[mask][0];
			}
		}
	}
	
	int mx = 0;
	string res = "";
	/*for (int mask = 1; mask < (1 << n + 1); ++mask) {
		for (int omask = (1 << n + 1) - 1; omask >= 1; --omask) {
			int sz = 0, m0 = omask;
			for (int i = 0; i <= n; ++i) {
				if ((m0 & 1) == (mask >> i & 1)) {
					++sz;
					m0 >>= 1;
					if (!m0) break;
				}
			}
			if (!m0) cnt[omask] += cnt[mask];
		}
	}
	*/
	for (int mask = (1 << n + 1) - 1; mask >= 1; --mask) {
		string s = "";
		int h = 0;
		for (int j = n; j >= 0; --j) if (mask >> j & 1) {
			h = j;
			break;
		}
		for (int j = h - 1; j >= 0; --j)
			s += char('0' + (mask >> j & 1));
		if (cnt[mask] >= k) {
			if (h > mx) {
				mx = h;
				res = s;
			} else if (h == mx) {
				res = min(res, s);
			}
		}
	}
	cout << res << endl;
}











Measured memory_bytes: 41408
#include <iostream>
#include <sstream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <bitset>
#include <assert.h>
#include <deque>
using namespace std;

typedef unsigned long long UL;
typedef long long LL;
#define LP(i, a, b) for (int i = int(a); i < int(b); i++)
#define LPE(i, a, b) for (int i = int(a); i <= int(b); i++)
typedef pair<int, int> PII;
//typedef vector<vector<PII> > WAL;
typedef vector<vector<int> > SAL;
#define Ep 1e-7

#define INF 1e9

/*
consider the min number, is it possible to use that?
try to grow as large, as it can be, while maitaining its own color,
can use that color iff, it can grow to final with that scheme
conversely, everything on the path of it can maintain the color, just do the reverse merge and then forward

good start = i
if curSize can merge the next
	keep going, update curSize
else
reset goodstart and curSize

final ans is n -good start + 1


 */

int const MaxSize = 100000;

LL n, a[MaxSize];

int main() {

	ios_base::sync_with_stdio(false);
	//freopen("/Users/george/A_1.in", "r", stdin);
	cin >> n;

	LP(i, 0,n)
		cin >> a[i];

	sort(a, a+n);

	int goodStart = 0;
	LL curSize = a[0];

	LP(i, 1, n){
		LL nextSize = a[i];
		if(nextSize <=  2 * curSize){
		}else{
			goodStart = i;
		}

		curSize += nextSize;
	}

	cout << n - goodStart << endl;
	return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>
#define NLI NULL

int H[500000];
int left(int i){
  return i * 2;
}

int right(int i){
  return i * 2 + 1;
}

int parent(int i){
  return i / 2;
}

void maxHeapify(int H[], int i, int n){
  int l, r, largest, x;

  l = left(i);
  r = right(i);

  if(l <= n && H[l] > H[i])
    largest = l;
  else
    largest = i;

  if(r <= n && H[r] > H[largest])
    largest = r;

  if(largest != i){
    x = H[i];
    H[i] = H[largest];
    H[largest] = x;
    maxHeapify(H, largest, n);
  }
}

void buildMaxHeap(int H[], int n){
  int i;
  for(i = n / 2; i >= 1; i--)
    maxHeapify(H, i, n);
}

int main(){
  int n, i, k;

  scanf("%d", &n);

  for(i = 1; i < n + 1; i++){
    scanf("%d", &k);
    H[i] = k;
  }

  buildMaxHeap(H, n);

  for(i = 1; i < n + 1; i++)
    printf(" %d",H[i]);

  printf("\n");

  return 0;
}



Measured memory_bytes: 3752
H,W,M=map(int,input().split())
A=[0 for i in range(H+1)]
B=[0 for i in range(W+1)]
N=[]
for i in range(M):
    h,w=map(int,input().split())
    A[h]+=1
    B[w]+=1
    N.append([h,w])
max_A=[]
max_value_A=0
for i in range(1,len(A)):
    if A[i]>max_value_A:
        max_value_A=A[i]
        max_A=[i]                   
    elif A[i]==max_value_A:
        max_A.append(i)
maxA=[0 for i in range(len(A))]
for i in max_A:
    maxA[i]+=1
max_B=[]
max_value_B=0
for j in range(1,len(B)):
    if B[j]>max_value_B:
        max_value_B=B[j]
        max_B=[j]
    elif B[j]==max_value_B:
        max_B.append(j)
maxB=[0 for i in range(len(B))]
for j in max_B:
    maxB[j]+=1
count=0
for i,j in N:
    if maxA[i]==1 and maxB[j]==1:
        count+=1
flag=0
if count==len(max_A)*len(max_B):
    flag=1
print(max_value_A+max_value_B-flag)

Measured memory_bytes: 190640
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define pii pair<int,int>
#define vi  vector<int>
#define vii vector<pair<int,int>>
#define vll vector<lli>
#define pb  push_back
#define mp  make_pair
#define ss  second
#define ff  first
#define all(x) x.begin(),x.end()
const lli mod = 1000000007;

lli p2(lli n){lli ans=0;while(n>=1){n=n/2;ans++;}return ans;}
lli b_ex(lli n,lli a){lli res=1;while(n){if(n%2==1)res*=a;n>>=1;a=a*a;}return res;}
lli ncr(lli n,lli k){lli ans=1;if(k>n-k)k=n-k;for(lli i=1;i<=k;i++){ans*=(n-i+1),ans=ans/i;}return ans;}
lli add(lli a,lli b){return(a+b)%mod;}
lli mul(lli a,lli b){return (a*b)%mod;}
lli power(lli a , lli n){lli ans = 1;while(n){if(n % 2)ans = (ans * a) % mod;n /= 2;a = (a * a) % mod;}return ans;}
lli lcm(lli a,lli b)
{
    lli ans=(a*b)/(__gcd(a,b));
    return ans;
}
///------------------ALWAYS lli-----TEMP TSF99--------------------------------------------------------------------------------------///
const int inf=1e9+7;
void solve()
{
    int n;cin>>n;
    vector<int>order(n),fuel(n);
    int mx=0;
    for(int i=0;i<n;i++)
    {
        cin>>order[i];
        mx=max(order[i],mx);
    }
    for(int i=0;i<n;i++)cin>>fuel[i];
    lli dp[2*mx+1];
    for(int i=0;i<2*mx+1;i++)dp[i]=inf;
    dp[0]=0;
    for(int i=0;i<n;i++)
    {
        for(int j=fuel[i];j<2*mx+1;j++)
        {
            if(dp[j]>dp[j-fuel[i]]+1)dp[j]=dp[j-fuel[i]]+1;
        }
    }
    lli res=0;
    for(int i=0;i<n;i++)
    {
        res+=dp[2*order[i]];
    }
    cout<<res<<endl;
}
int main()
{
    int x;cin>>x;
    if(x<30)cout<<"No\n";
    else cout<<"Yes\n";
}


Measured memory_bytes: 3612
// finish date: 2018/01/20
#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <algorithm>
#include <stack>
#include <map>
#include <climits>

using namespace std;

#define FOR(i, a, b) for(int (i)=a;(i)<(b);(i)++)
#define rep(i, n)  FOR(i,0,n)
#define ll long long
#define bigmod 1000000007
#define INF 500000000


int main() {
    string C1, C2;
    cin >> C1 >> C2;
    string C3 = C1, C4 = C2;
    reverse(C3.begin(), C3.end());
    reverse(C4.begin(), C4.end());
    if (C2 == C3 && C1 == C4) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int uli;
vector<pair<int,int> >e;
void solve(int l,int r){
  if(l>r)return;
  if((r-l+1)%2==1){
    for(int x=l;x<r;x++)e.push_back({r,x});
    solve(l,r-1);
    return;
  }
  for(int x=l+1;x<r;x++){
    e.push_back({r,x});
    e.push_back({l,x});
  }
  solve(l+1,r-1);
}
int main(){
  int n;
  cin>>n;
  solve(1,n);
  cout<<e.size()<<endl;
  for(auto p:e)cout<<p.first<<" "<<p.second<<endl;
  return 0;
}


Measured memory_bytes: 384
#include "bits/stdc++.h"

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
constexpr double EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr int MOD = 1e9 + 7;

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

    string s;cin>>s;
    if(s.length()==2) cout<<s<<endl;
    else{
        reverse(s.begin(),s.end());
        cout<<s<<endl;
    }
}


Measured memory_bytes: 256
#include <iostream>

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

    int count = 0;
    for (int i = 0; i < N; i++) {
        int x;
        std::cin >> x;

        if (K - x < x) {
            count += (K - x) * 2;
        } else {
            count += x * 2;
        }
    }

    std::cout << count << std::endl;

    return 0;
}

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

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

    int ans = 0;
    rep(k, 1000) {
        ll d[3] = {k / 100, k / 10 % 10, k % 10};
        int idx = 0;
        rep(i, s.size()) {
            if (s[i] - '0' == d[idx])
                idx++;

            if (idx == 3) {
                ans++;
                break;
            }
        }
    }

    cout << ans << endl;

    return 0;
}

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

using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

int main() {

    int n; cin >> n;
    string s; cin >> s;

    int ans = 0;

    for (int i = 0; i < n-2; ++i) {
        if (s[i] == 'A' && s[i+1] == 'B' && s[i+2] == 'C') {
            ++ans;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
import math
import queue
import bisect
import heapq
import time
import itertools

mod = int(1e9+7)

def swap(a,b):
    return (b,a)

def gcd(a,b): #最大公約数
    if (a<b):
        a,b = swap(a,b)
    if (b==0):
        return a
    else:
        return gcd(b,a%b)

def lcm(a,b): #最小公倍数
    return a/gcd(a,b)*b

def divisors(a): # 約数列挙
    divisors = []
    for i in range(1,int(a**0.5)+1):
        if a%i==0:
            divisors.append(i)
            if i!=a//i:
                divisors.append(a//i)
    return divisors

def is_prime(a): #素数判定
    if a<2:
        return False
    elif a==2:
        return True
    elif a%2==0:
        return False
    sqrt_num = int(a**0.5)
    for i in range(3,sqrt_num+1,2):
        if a%i==0:
            return False
    return True

def prime_num(a): #素数列挙
    pn = [2]
    for i in range(3,int(a**0.5),2):
        prime = True
        for j in pn:
            if i%j==0:
                prime = False
                break
        if prime:
            pn.append(i)
    return pn

def prime_fact(a): #素因数分解
    sqrt = math.sqrt(a)
    res = []
    i = 2
    if is_prime(a):
        res.append(a)
    else:
        while a!=1:
            while a%i==0:
                res.append(i)
                a //= i
            i += 1
    return res

def main():
    s = input()
    t = []
    for i in range(19):
        if i==5 or i==13:
            t.append(' ')
        else:
            t.append(s[i])
    print(''.join(t))
    return

if __name__=='__main__':
    main()


Measured memory_bytes: 38508
#include <iostream>
#include <cstdio>
#include <string>
#include <cmath>
#include <algorithm>
#include <cctype>
using namespace std;

int main() {
    int n, p[20],ans=0;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> p[i];
    }
    for (int i = 1;i < n - 1;i++) {
        if (p[i - 1] < p[i] && p[i] < p[i + 1] || p[i + 1] < p[i] && p[i] < p[i - 1]) ans++;
    }
    cout << ans << endl;
}

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

using namespace __gnu_pbds;
using namespace std;

#define mod 1000000007

#define ft first
#define sd second
#define pb push_back
#define all(x) x.begin(),x.end()
#define ll long long int
#define db long double
#define vlli vector<long long int >
#define mp make_pair
#define ms(x, v) memset(x, v, sizeof x)
#define cnl cout<<"\n";
#define fr(i,b) for(ll i=0; i<=b; i++)
#define frr(i,b) for(ll i=0;i<b;i++)
#define fb(i,b) for(ll i=b-1; i>=0; i--)
#define PI 3.14159265



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

 bool comp(pair<long int ,long int>v1,pair<long int ,long int>v2){
          if(v1.ft==v2.ft) return v1.sd>v2.sd;
          else return v1<v2;
 }


 

int main(){
    ll r; cin>>r;
    cout<<3*r*r<<endl;





return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

char judge(int hand[5]);
void sort(int *hand);

int main(void)
{
	int hand[5];
	char rank;
	int OF;
	while (scanf(" %d,", &OF) != EOF){
		hand[0] = OF;
		
	scanf("%d,%d,%d,%d", &hand[1], &hand[2]
							  , &hand[3], &hand[4]);
	
	sort(hand);
	rank = judge(hand);
	
	switch (rank){
		
		case ('S'):
		printf("four card\n");
		break;
		
		case ('A'):
		printf("full house\n");
		break;
		
		case ('B'):
		printf("straight\n");
		break;
		
		case ('C'):
		printf("three card\n");
		break;
		
		case ('D'):
		printf("two pair\n");
		break;
		
		case ('E'):
		printf("one pair\n");
		break;
		
		case ('F'):
		printf("null\n");
		break;
	}
	}
	return (0);
}

void sort(int *hand)
{
	int i, j;
	int tmp;
	for (i = 0; i < 5; i++){
		for (j = 0; j < 5; j++){
			if (hand[i] < hand[j]){
				tmp = hand[i];
				hand[i] = hand[j];
				hand[j] = tmp;
			}
		}
	}
}

char judge(int hand[5])
{
	int pair = 0;
	int card_3 = 0, card_4 = 0;
	char rank;
	int straight = 0;
	int i;
	int sum = 0;
	
	for (i = 0; i < 5; i++){
		sum += hand[i];
		if (hand[i] == hand[i + 1]){
			pair++;
			if (hand[i] == hand[i + 2]){
				pair--;
				card_3++;
				if (hand[i] == hand[i + 3]){
					card_3--;
					card_4++;
					i++;
					i++;
				}
				else {
					i++;
				}
			}
		}
		if (hand[i] + 1 == hand[i + 1]){
			straight++;
		}
	}
	
	if (card_4 == 1){
		rank = 'S';
	}
	else if (card_3 == 1 && pair == 1){
		rank = 'A';
	}
	else if (straight == 4){
		rank = 'B';
	}
	else if (straight == 3 && sum == 47){
		rank = 'B';
	}
	
	else if (card_3 == 1){
		rank = 'C';
	}
	else if (pair == 2){
		rank = 'D';
	}
	else if (pair == 1){
		rank = 'E';
	}
	else {
		rank = 'F';
	}
	
	return (rank);
}

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

int main()
{
	int r,c;
	int i,j;
	
	cin >> r >> c;

	int sheet[r + 1][c + 1];
	
	for(i = 0; i <= r; i++)
	{
		for(j = 0; j <= c; j++)
		{
			sheet[i][j] = 0;
		}
	}
	
	for(i = 0; i < r; i++)
	{
		for(j = 0; j < c; j++)
		{
			cin >> sheet[i][j];
		}
	}
	
	for(i = 0; i < r; i++)
	{
		for(j = 0; j < c; j++)
		{
			sheet[r][j] += sheet[i][j];
			sheet[i][c] += sheet[i][j];
			sheet[r][c] += sheet[i][j];
		}
	}
	
	for(i = 0; i <= r; i++)
	{
		for(j = 0; j <= c; j++)
		{
			cout << sheet[i][j];
			if(j < c)
			{
				 cout << " " ;
			}
		}
		cout << endl;
	}
}


Measured memory_bytes: 3132
a_list = []
for i in range(3):
    for j in list(map(int, input().split())):
        a_list.append(j)

N = int(input())

b_list = []
for i in range(N):
    b_list.append(int(input()))    
        
for b in b_list:
    if b in a_list:
        a_list[a_list.index(b)] = 0
# 123
# 456
# 789
# とした場合のビンゴラインごとのリスト
line_list = [
    a_list[:3],    # 123
    a_list[3:6],   # 456
    a_list[6:9],   # 789
    a_list[::3],   # 147
    a_list[1::3],  # 258
    a_list[2::3],  # 369
    a_list[::4],   # 159
    a_list[2:7:2], # 357    
]
line_sum_list = list(map(sum, line_list))
if 0 in line_sum_list:
    print('Yes')
else:
    print('No') 

Measured memory_bytes: 3064
// clang-format off
#include <bits/stdc++.h>

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define forn1(i,n) for (int i = 1; i <= int(n); i++)
#define popcnt __builtin_popcount
#define ffs __builtin_ffs
#define ctz __builtin_ctz
#define clz __builtin_clz
#define all(a) (a).begin(), (a).end()
 
using namespace std;

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
using pil = pair<int,ll>;
using pll = pair<ll,ll>;
template <typename T> using vec = vector<T>;
using vi = vec<int>;
using vl = vec<ll>;
template <typename T> using que = queue<T>;
template <typename T> using deq = deque<T>;

template <typename T> T id(T b) {return b;};
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}
template <typename S, typename K> bool contains(S &s, K k) { return s.find(k) != s.end(); }
void fastio() { ios_base::sync_with_stdio(false); cin.tie(nullptr); }
constexpr ll TEN(int n) { if (n == 0) return 1LL; else return 10LL*TEN(n-1); }
// clang-format on

string s;

int main() {
    fastio();

    cin >> s;
    int q;
    cin >> q;

    deq<char> ans(all(s));

    bool rev = false;
    while (q--) {
        int t;
        cin >> t;
        if (t == 1) {
            rev = !rev;
        } else {
            int f;
            char c;
            cin >> f >> c;
            if ((f == 1 && !rev) || (f == 2 && rev)) {
                ans.push_front(c);
            } else {
                ans.push_back(c);
            }
        }
    }

    if (rev) reverse(all(ans));

    for (char c : ans) {
        cout << c;
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 976
#include <iostream>

using namespace std;

int main(int argc, char **argv)
{
	double max, min, tmp;
	
	cin >> max;
	min = max;
	
	while(cin >> tmp){
		if(max < tmp){
			max = tmp;
		} else if(tmp < min){
			min = tmp;
		}
	}
	
	cout << (double)(max - min) << endl;
	
	return 0;
}

Measured memory_bytes: 0
from collections import defaultdict
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline


class UnionFind:
    def __init__(self, N):
        self.parent = [i for i in range(N)]
        self.size = [1 for _ in range(N)]

    def find(self, x):
        if self.parent[x] == x:
            return x
        else:
            return self.find(self.parent[x])

    def union(self, x, y):
        px = self.find(x)
        py = self.find(y)
        if px == py:
            return
        if self.size[px] < self.size[py]:
            self.parent[px] = py
            self.size[py] += self.size[px]
        else:
            self.parent[py] = px
            self.size[px] += self.size[py]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def connectedNum(self, x):
        return self.size[self.find(x)]


N, M = map(int, input().split())
Un = UnionFind(N)  # 会話できる人をつなげる
D = defaultdict(lambda: [])
for i in range(N):
    _, *L = map(lambda x: int(x)-1, input().split())
    for l in L:
        D[l].append(i)
for i in range(M):
    if len(D[i]) > 1:
        t = D[i]
        for d in t[1:]:
            Un.union(t[0], d)
print("YES" if Un.connectedNum(0) == N else "NO")


Measured memory_bytes: 27428
#include<bits/stdc++.h>
#define ll long long int
#define pb push_back
#define mpr make_pair
#define mt make_tuple
 
using namespace std;
 
const ll N = 3010;
const ll mod = 1e9 + 7;
ll power(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 dp[N][N];
 
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,m;
    string s,t;
    vector<char> res;
    cin>>s>>t;
    memset(dp, 0 , sizeof(dp));
    n = s.size();
    m = t.size();
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            if(s[i-1] == t[j-1])    dp[i][j] = 1 + dp[i-1][j-1];
            else    dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
        }
    }
    while(n > 0 && m > 0){
        if(s[n-1] == t[m-1]){
            res.pb(s[n-1]);
            n--; m--;
        }
        else{
            if(dp[n-1][m] > dp[n][m-1]) n--;
            else    m--;
        }
    }
    reverse(res.begin(), res.end());
    for(int i=0;i<res.size();i++)   cout<<res[i];
    cout<<endl;
    return 0;
}

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

class Dice{
public: 
    int n[6];
    const int N[4] = {0, 1, 5, 4};
    const int S[4] = {0, 4, 5, 1};
    const int E[4] = {0, 3, 5, 2};
    const int W[4] = {0, 2, 5, 3};
    const int Y_r[4] = {1, 2, 4, 3};
    const int Y_l[4] = {1, 3, 4, 2};
    
    void roll(char dir);
};

void Dice::roll(char dir){
    const int *r_dir;
    int temp;
    
    if(dir == 'N') r_dir = N;
    else if(dir == 'S') r_dir = S;
    else if(dir == 'E') r_dir = E;
    else r_dir = W;
    
    temp = n[r_dir[0]];
    for(int i = 0; i < 4; i++){
        if(i == 3) n[r_dir[i]] = temp;
        else n[r_dir[i]] = n[r_dir[i + 1]];
    }
}

int main(){
    Dice dice;
    int n, q1, q2;
    
    for(int i = 0; i < 6; i++){
        cin >> dice.n[i];
    }
    
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> q1 >> q2;
        
        for(int j = 0; j < 4; j++){
            if(dice.n[dice.N[j]] == q1 && dice.n[dice.N[(j+1) % 4]] == q2){
                cout << dice.n[dice.W[1]] << endl;
                break;
            }
            else if(dice.n[dice.S[j]] == q1 && dice.n[dice.S[(j+1) % 4]] == q2){
                cout << dice.n[dice.E[1]] << endl;
                break;
            }
            else if(dice.n[dice.E[j]] == q1 && dice.n[dice.E[(j+1) % 4]] == q2){
                cout << dice.n[dice.N[1]] << endl;
                break;
            }
            else if(dice.n[dice.W[j]] == q1 && dice.n[dice.W[(j+1) % 4]] == q2){
                cout << dice.n[dice.S[1]] << endl;
                break;
            }
            else if(dice.n[dice.Y_r[j]] == q1 && dice.n[dice.Y_r[(j+1) % 4]] == q2){
                cout << dice.n[dice.N[0]] << endl;
                break;
            }
            else if(dice.n[dice.Y_l[j]] == q1 && dice.n[dice.Y_l[(j+1) % 4]] == q2){
                cout << dice.n[dice.N[2]] << endl;
                break;
            }
        }
        
    }
    
    return 0;
}


Measured memory_bytes: 3084
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int mod=998244353;
int a[405][405],b[405][405];
int x[405],y[405],p[405][405];
int fac[405],ifac[405];
inline int pow(int x,int y){
	int z=1;
	while(y){
		if(y&1)z=1ll*z*x%mod;
		x=1ll*x*x%mod;
		y>>=1;
	}
	return z;
}
int main(){
	int n;
	scanf("%d",&n);
	int Sa=0,Sb=0;
	for(int i=1;i<=n;i++)scanf("%d%d",&x[i],&y[i]),Sa+=x[i],Sb+=y[i];
	int invSa=pow(Sa,mod-2);
	for(int i=1;i<=n;i++){
		p[i][0]=1;
		p[i][1]=1ll*x[i]*invSa%mod;
		for(int j=2;j<=400;j++)p[i][j]=1ll*p[i][j-1]*p[i][1]%mod;
	}
	fac[0]=1;
	for(int i=1;i<=400;i++)fac[i]=1ll*fac[i-1]*i%mod;
	ifac[400]=pow(fac[400],mod-2);
	for(int i=400;i>0;i--)ifac[i-1]=1ll*ifac[i]*i%mod;
	a[0][0]=1;
	for(int i=1;i<=n;i++){
		memset(b,0,sizeof(b));
		for(int j=0;j<Sa;j++)
			for(int k=0;k<Sb;k++){
				b[j][k]=(j>=x[i]?a[j-x[i]][k]:0);
				for(int l=0;l<=min(y[i]-1,k);l++)
					b[j][k]=(b[j][k]-1ll*a[j][k-l]*ifac[l]%mod*p[i][l]%mod+mod)%mod;
			}
		swap(a,b);
	}
	int ans=0;
	for(int i=0;i<Sa;i++)
		for(int j=0;j<Sb;j++){
			ans=(ans+1ll*a[i][j]*fac[j]%mod*pow(pow((1-1ll*i*invSa%mod+mod)%mod,j+1),mod-2)%mod)%mod;
		}
	printf("%d\n",mod-ans);
	return 0;
}

Measured memory_bytes: 2048
//tt89 ;)
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL);
void testcase(int t) { cout<<"Case #"<<t<<": "; }
void online() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif //ONLINE_JUDGE
}
const int mod= 1e9+7;

int main() {
    fastIO;
    int n; cin>>n;
    vector<int> arr(n);
    for(int i=0;i<n;i++) cin>>arr[i];
    int q; cin>>q;
    map<int,int> m;
    ll sum=0;
    for(auto i:arr) { sum+=i; m[i]++; }

    while(q--) {
        int a,b; cin>>a>>b;
        m[b]+=m[a];
        sum+= m[a]*(b-a);
        m.erase(a);

        cout<<sum<<endl;
    }

    return 0;
}

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

int main(){
    char s[200001] = {};
    int a = -1;
    int b = 0;
    cin >> s;
    for(int i = 0; i < sizeof(s); i++)
    {
        if(s[i] == 'A' && a==-1)
        {
            a = i;
        }
        if(a != -1 && s[i] == 'Z')
        {
            b = i;
        }
    }
    cout<< b-a+1 <<endl;
}

Measured memory_bytes: 384
#include<stdio.h>

int main(){

  int N,A[100];
  int i,j=0;
  int v;
  
  scanf("%d",&N);

  for(i=0;i<N;i++){
    
    scanf("%d",&A[i]);
  }
  for(i=0;i<N-1;i++){
    
    printf("%d ",A[i]);
  }

  printf("%d\n",A[N-1]);
  
  for(j=0;j<N;j++){
  for(i=1;i<N;i++){
    
    v = A[i];
    j = i - 1;
    
      
      while(j>=0 && A[j]>v){
	
	A[j+1] = A[j];
	j--;
	A[j+1] = v;
      }
      
      for(j=0;j<N-1;j++){
	
	printf("%d ",A[j]);
      }
      printf("%d\n",A[N-1]);
    }
  }
  
  return 0;
}


    



Measured memory_bytes: 2128
//   _/                _/                 _/_/_/   _/
//_/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
// _/     _/    _/   _/     _/    _/  _/_/_/     _/
//_/     _/    _/   _/     _/    _/  _/    _/   _/
// _/_/   _/_/       _/_/   _/_/      _/_/     _/
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const double pi=3.14159265358979323846;
const int inf=2e9;
const ll INF=9e18;
typedef pair<int,int> P;
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  while(true) {
    int n,x,cnt=0,ans=0;
    cin >> n >> x;
    if(n==0) {
      return 0;
    }
    for(int i=1; i<=n; i++) {
      for(int j=i+1; j<=n; j++) {
        for(int k=j+1; k<=n; k++) {
          cnt+=i+j+k;
          if(cnt==x) {
            ans++;
          }
          cnt=0;
        }
      }
    }
    cout << ans << endl;
  }
}


Measured memory_bytes: 3128
# coding: utf-8
# Your code here!
N = int(input())
ans = 0
for i in range(N):
    a = []
    a = input().split(" ")
    y = float(a[0])
    
    if a[1]=="BTC":
        k =y*380000
        ans +=k
    else:
        ans +=y
print(ans)

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

#define ll long long
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll,ll>
#define ff first
#define ss second

using namespace std;

const double pi = acos(-1);
const int N = 1e6 + 6, mod = 998244353, M = 1e7 + 7;
const ll MAX = 5e18;

int r;

int main()
{
    cin >> r;
    cout << fixed << setprecision(12) << 2 * pi * r;

    return 0;
}


Measured memory_bytes: 3788
N, Q = map(int, input().split())
S = str(input())
count = [0]*(N+1)
lists = []
for i in range(1, N):
    if S[i-1] == "A" and S[i] == "C":
        count[i] = count[i-1] + 1
    else:
        count[i] = count[i-1]
for i in range(Q):
    l, r = map(int, input().split())
    ans = count[r-1] - count[l-1]
    lists.append(ans)
for i in range(len(lists)):
    print(lists[i])


Measured memory_bytes: 10208
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using vi = vector<int>;
using vvi = vector<vi>;
#define ote(x) cout<<(x)<<endl
#define all(x) (x).begin(),(x).end()
#define rp(i,s,e) for(int i=(s);i<(e);++i)
#define rpz(i,e) rp(i,0,e)

int main(){
	int N; cin>>N;
	string S; cin>>S;
	string T; cin>>T;
	string ans = "";
	rp(i,0,N){
		ans = ans + S[i]+T[i];
	}
	ote(ans);
}


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

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)n; ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
struct Cir{
	int x,y,r,c;
	Cir(int x,int y,int r,int c):
		x(x), y(y), r(r), c(c) {}
};
bool ontop(Cir c,Cir d){
	int x = c.x - d.x;
	int y = c.y - d.y;
	int dis = x*x+y*y;
	if(dis < (c.r + d.r)*(c.r+d.r)) return true;
	else return false;
}
/*
vector<Cir> cir;
map<int,int> memo;
int dfs(int S){
	cout<<memo.size()<<endl;
	if(memo.count(S))return memo[S];
	int n = cir.size();
	bool onthe[25]={};
	REP(i,n) FOR(j,i+1,n){
		if((S | 1<<i) == S) continue;
		if(ontop(cir[i],cir[j])) {
			onthe[j] = true;
		}
	}
	int ret = 0;
	REP(i,n) {
		FOR(j,i+1,n){
			if(cir[i].c == cir[j].c && !onthe[i] && !onthe[j] && (S | 1<<i) != S && (S | 1<<j) != S){
				ret = max(ret, dfs(S | 1<<i | 1<<j)+2);
			}
		}
	}
	return memo[S] = ret;
}

int main(){
	int n;
	while(cin>>n,n){
		cir.clear();
		memo.clear();
		REP(i,n){
			int x,y,r,c;
			cin>>x>>y>>r>>c;
			cir.push_back(Cir(x,y,r,c));
		}
		cout<<dfs(0)<<endl;
	}
	return 0;
}
*/
char dp[1<<24]={};
int main(){
	int n;
	while(cin>>n,n){
		vector<Cir> cir;
		REP(i,n){
			int x,y,r,c;
			cin>>x>>y>>r>>c;
			cir.push_back(Cir(x,y,r,c));
		}
		bool on[24][24] = {};
		REP(i,n)REP(j,n)on[i][j] = ontop(cir[i],cir[j]);
		memset(dp,-1,sizeof(dp));
		dp[0] = 0;
		int ans = 0;
		for(int S = 0; S < 1<<n; S++){
			if(dp[S]==-1)continue;
			ans = max((int)dp[S],ans);
			bool notuseable[24] = {};
			REP(i,n)notuseable[i] = S>>i&1;
			bool over[24] = {};
			REP(i,n)REP(j,i)if(!notuseable[j]&&on[i][j])over[i] = true;
			REP(i,n)if(!notuseable[i]&&!over[i]){
				FOR(j,i+1,n)if(!notuseable[j]&&!over[j]){
					if(cir[i].c == cir[j].c) dp[S|1<<i|1<<j] = dp[S] + 2;
				}
			}
		}
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 16000
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		String org = "keyence";
		String s = sc.next();
		int idx = 0;
		for (int i = 0; i < s.length(); i++) {
			if (org.charAt(i) != s.charAt(i)) {
				break;
			}
			idx++;
			if (idx == org.length()) {
				System.out.println("YES");
				return;
			}
		}
		for (int i = 0; i < s.length(); i++) {
			if (org.charAt(org.length() - i - 1) != s.charAt(s.length() - i - 1)) {
				break;
			}
			idx++;
			if (idx == org.length()) {
				System.out.println("YES");
				return;
			}
		}
		System.out.println("NO");
	}
}


Measured memory_bytes: 23764
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<math.h>
using namespace std;
int main() {
	int N;	cin >> N;
	vector<int> l(N), r(N);
	int ans = 0;
	for (int i = 0; i < N; ++i) {
		cin >> l[i] >> r[i];
	}
	for (int i = 0; i < N; ++i) {
		ans += r[i] - l[i] + 1;
	}
	cout << ans << endl;
	cin >> N;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		while(true) {
			int n = stdIn.nextInt();
			int p = stdIn.nextInt();
			if(n == 0 && p == 0) break;
			int[] tmp = new int[n];
			int nowp = 0;
			int nowc = p;
			while(true) {
				if(nowc > 1) {
					nowc--;
					tmp[nowp++]++;
				}
				else if(nowc == 0){
					nowc = tmp[nowp];
					tmp[nowp++] = 0;
				}
				else {
					boolean cont = true;
					for(int i = 0; i < n; i++) {
						if(i == nowp) continue;
						if(tmp[i] != 0) {
							cont = false;
							break;
						}
					}
					if(cont) {
						break;
					}
					nowc--;
					tmp[nowp++]++;
				}
				if(nowp >= n) {
					nowp = 0;
				}
			}
			System.out.println(nowp);
			
		}
	}

}

Measured memory_bytes: 20268
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <array>
#include <tuple>
#include <random>

using namespace std;
typedef long long int ll;

#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = int(a); i < int(b); i++)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep,)(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()

#define const INF 10000000000

ll a, b, c, n, x, y, z, w, h, ans = 0, cnt = 0, max = 0;
string s;

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

    cin >> n;
    if(n < 105){
        cout << 0 << endl;
    }else{
        rep(i, 104, n){
            i++;
            cnt = 2;
            rep(j, 2, i / 3 + 1){
                j++;
                if(i % j == 0){
                    cnt++;
                }
            }
            if(cnt == 8){
                ans++;
            }
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;


#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define PSET(x,y) fixed<<setprecision(y)<<x
#define pb push_back
#define pii pair<int,int>
#define pf push_front
#define mp make_pair
#define vi vector<int>
#define vip vector<pair<int,int> >
#define ff first
#define ss second
#define int long long
#define mod 1000000007
#define BIG 998244353
#define s(t) scanf("%lld",&t)
#define p(t) printf("%lld\n",t)
#define mii map<int,int>
#define MSET(table,i) memset(table, i, sizeof(table))
#define endl '\n'
#define tc int t;cin>>t;while(t--)
#define pi  3.1415926358
#define bits(x) __builtin_popcount(x)
#define minimum(a,n) min_element(a,a+n)-a
#define maximum(a,n) max_element(a,a+n)-a
#define pqbig priority_queue<pii>
#define pqsmall priority_queue<pair<int,pii>,vector<pair<int,pii> >,greater<pair<int,pii> > >
#define all(v) v.begin(),v.end()
#define sitr set<int>:: iterator
#define spitr set<pii>:: iterator
#define mitr map<string,int>:: iterator

int toint(const string &s) {stringstream ss; ss << s; int x; ss >> x; return x;}
string tostring ( int number ) {stringstream ss; ss << number; return ss.str();}

typedef tree<pii, null_type, less<pii>, rb_tree_tag,
        tree_order_statistics_node_update>
        new_data_set;

#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl


int32_t main()
{
    fast;
    int n,m;cin>>n>>m;
    int *arr=new int[n];
    int sum=0;
    for(int i=0;i<n;i++)
        cin>>arr[i],sum+=arr[i];

    int cnt=0;
    for(int i=0;i<n;i++)
    {
        if(arr[i]*4*m>=sum)
            cnt++;
    }
    if(cnt>=m)
        cout<<"Yes";
    else
        cout<<"No";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
using namespace std;

int main() {
  int n;
  string s;
  cin >> n >> s;
  int ans=1;
  REP(i, s.size()-1)if(s[i] != s[i-1])ans++;
  cout << ans;
}

Measured memory_bytes: 512
#!/usr/bin/env python
# -*- coding: utf-8 -*-

char_list = list(map(chr,range(ord('a'),ord('z')+1)))
char_list += list(map(chr,range(ord('A'),ord('Z')+1)))
while True:
    n = int(input())
    if n == 0:
        break
    keys = list(map(int,input().split(" ")))
    sentence = input()
    for i in range(len(sentence)):
        if sentence[i].isupper():
            j = ord(sentence[i]) - ord('A') + 26
        else:
            j = ord(sentence[i]) - ord('a')
        print(char_list[j-keys[i%len(keys)]],end="")
    print()

Measured memory_bytes: 6724
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {

	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		int N = sc.nextInt();
		int M = sc.nextInt();
		int[] L = new int[M + 1];
		int[] R = new int[M + 1];
		int a = 0;
		int b = N;
		for (int i = 1; i <= M; i++) {
			L[i] = sc.nextInt();
			a = Math.max(a, L[i]);
			R[i] = sc.nextInt();
			b = Math.min(b, R[i]);
		}

		System.out.println(Math.max(0,b - a + 1));

	}
}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}


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

int main() {
    int n; cin >> n;
    long long sum = 0;
    for(int i = 0; i < n; ++i) {
        int a; cin >> a;
        sum += a;
    }
    
    if(sum % 2 == 0) cout << "YES" << endl;
    else cout << "NO" << endl;;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int a,ans ,d;
    char b;

    while(cin>>a>>d>>b>>ans){
        d= d*100 + ans;
        ans = a*d;


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


Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>
#include <queue>
#include <tuple>
#include <cmath>
#include <map>
#include <bitset>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
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; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+" ";
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
constexpr const ll INF = 1e15;
constexpr const ll MOD = 1000000007;
constexpr int nx[4] = {1,0,-1,0};
constexpr int ny[4] = {0,1,0,-1};
typedef pair<ll,ll> P;
vector<ll> dp(100,-1);
ll ans(ll n){
    if (dp[n] != -1) return dp[n];
    if (n == 0) return 2;
    if (n == 1) return 1;
    return dp[n] = ans(n-1)+ans(n-2);
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    PRINT(ans(n));
}


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

int main(){
    int n;
    cin >> n;
    vector<int> p(n);
    for(int tsumugi = 0; tsumugi < n; tsumugi++){
        cin >> p[tsumugi];
    }

    int leftMin = p[0];
    int ans = 1;    //一番左は必ず条件を満たす
    for(int i = 1; i < n; i++){
        leftMin = min(leftMin, p[i - 1]);
        if(leftMin >= p[i]){
            ans++;
        }
    }

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

Measured memory_bytes: 1024
// https://atcoder.jp/contests/abc172/tasks/abc172_d
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define DIV(a, b) ((a - 1) / b + 1)

// 二乗法によるべき乗
int ipow(int base, int exp) {
    int result = 1;
    while (exp) {
        if (exp & 1)
            result *= base;
        exp >>= 1;
        base *= base;
    }

    return result;
}

// 等比数列の和(a=初項、r=公比、項数=n)
int sumOfTouhi(int a, int r, int n) { return a * ipow(r, n) - a / (r - 1); }

// 等差数列の和(a=初項、d=公差、項数=n)
int sumOfTousa(int a, int d, int n) { return n * (2 * a + (n - 1) * d) / 2; }

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    cin >> N;
    // １の倍数＋２の倍数＋３の倍数＋・・・
    int ans = 0;
    FOR(i, 1, N + 1) { ans += sumOfTousa(i, i, N / i); }
    cout << ans << endl;
    return 0;
}


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

int main()
{
    int n;
    while(cin >> n){
        if(n==0)
            break;
         int s[2][12];
         for(int i=0;i<n;i++){
             cin >> s[0][i];
         }
         int dif,cycle=0;
         do{
             dif = 0;
             for(int i=0;i<n;i++){
                 int a = 0;
                 for(int k=0;k<n;k++){
                     if(s[0][i]==s[0][k])
                         a++;
                 }
                 s[1][i] = a;
             }
             
             for(int i=0;i<n;i++){
                 if(s[0][i]!=s[1][i])
                     dif++;
                 s[0][i] = s[1][i];
             }
             cycle++;
         }while(dif != 0);
         
         cout << --cycle << endl;
         for(int i=0;i<n;i++){
             if(i!=0)
                 cout << " ";
             cout << s[0][i];
         }
         cout << endl;
     }
     return 0;
 }

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

int main(){
  vector<int> a;
  
  for(int i = 0; i < 3; i++){
	int b;
    cin >> b;
    a.push_back(b);
  }
  sort(a.begin(), a.end());
  
  int sum = 0;
  for(int i = 1; i > -1; i--){
	sum += abs(a[i] - a[i+1]);
  }
  
  cout << sum << endl;
  return 0;
}
    

Measured memory_bytes: 256
// #include {{{
#include <iostream>
#include <cassert>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <ctime>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <string>
#include <bitset>
#include <vector>
#include <complex>
#include <algorithm>
using namespace std;
// }}}
// #define {{{
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define per(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
// }}}

const int N = 1e5 + 10;
int n , K , a[N] , b[N];

int main(){
    cin >> n >> K;
    rep(i,0,n) cin >> a[i] >> b[i];
    ll ans = 0;
    rep(i,0,31) {
        ll tmp = 0;
        rep(j,0,n) {
            int Kl = K >> i;
            int al = a[j] >> i;
            if((al & Kl) == al) {
                if(i == 0 || (K >> (i - 1) & 1) > (a[j] >> (i - 1) & 1))
                    tmp += b[j];
            }
        }
        ans = max(ans , tmp);
    }
    cout << ans << endl;
    return 0;
}


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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<pdd> vdd;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mem(a,b) memset(a, b, sizeof(a) )
#define all(x) (x).begin(),(x).end()
#define INF 1000000000000
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

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

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

int main(){
    int n,m,k;
    cin>>n>>m>>k;
    vector<vector<char>>a(n,vector<char>(m));
    vvi b(n,vi(m));
    rep(i,n){
        rep(j,m)cin>>a[i][j];
    }
    int l=1,x,y;
    rep(i,n){
        for(int j=0;j<m;++j){
            if(a[i][j]=='#'&&l<=k){
                b[i][j]=l;
                l++;}
        }
    }
    rep(i,n){
        int l=0;
        rep(j,m){
            if(b[i][j]!=0){
                l=b[i][j];
                break;
            }
        }
        rep(j,m){
            if(b[i][j]==0){
                b[i][j]=l;
            }
            else l=b[i][j];
        }
    }
    rep(i,m){
        int l=0;
        rep(j,n){
            if(b[j][i]!=0){
                l=b[j][i];
                break;
            }
        }
        rep(j,n){
            if(b[j][i]==0){
                b[j][i]=l;
            }
            else l=b[j][i];
        }
    }
    rep(i,n){
        rep(j,m){
            if(j!=m-1)cout<<b[i][j]<<" ";
            else cout<<b[i][j]<<endl;
        }
    }
}


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

int main() {
  int n,m;
  cin>>n>>m;
  int d[m+2];
  memset(d,0,sizeof(d));
  for(int i=0,x,y;i<n;i++){
    cin>>x>>y;
    d[x+1]++;
    d[y+1]--;
  }
  int ans=0;
  for(int i=1;i<=m;i++){
    d[i]+=d[i-1];
    ans=max(ans,d[i]);
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3496