akhauriyash/Code-Regression huggingface dataset:
/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
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;
vll_t a,b;
int solve(string s,int n,int part){
	int diff=0;
	map<char,int>mp1,mp2;
	for(int i=0;i<26;i++){
		mp1[i+'a']=false;
		mp2[i+'a']=false;
	}
	for(int i=0;i<=part;i++){
		mp1[s[i]]=true;
	}
	for(int i=part+1;i<n;i++){
		mp2[s[i]]=true;
	}
	for(int i=0;i<26;i++){
		if(mp1[i+'a']&&mp2[i+'a']){
			diff++;
		}
	}
	return diff;
}
int  main(){
	// #ifndef ONLINE_JUDGE
 //    // for getting input from input.txt
 //    freopen("input.txt", "r", stdin);
 //    // for writing output to output.txt
 //    freopen("output.txt", "w", stdout);
	// #endif
	int n;string s;cin>>n>>s;
	int ans=0;
	for(int i=0;i<=n-2;i++){
		ans=max(solve(s,n,i),ans);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <bitset>

#include <queue>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <ctime>
////
//#include <random>//
/////////
#define R(i,n) for(int i=0;i<(n);++i)
/////////
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;

////定数
const int INF = (int)1e9 + 10;
const LL MOD = (LL)1e9 + 7;
const LL LINF = (LL)4e18 + 20;
const LD PI = acos(-1.0);
const double EPS = 1e-9; 
/////////
using namespace::std;
template<typename T>
void chmax(T& a, T b) {
	a = max(a, b);
}

template<typename T>
void chmin(T& a, T b) {
	a = min(a, b);
}

template<typename T>
void IN(vector<T> &A,int N=-1) {
	if (N == -1) {
		N = A.size();
	}
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
	}
}

template<typename T>
void SO(vector<T> &A,bool F=false) {
	sort(A.begin(), A.end());
	if (F) {
		reverse(A.begin(), A.end());
	}
}
//////////////

void solve() {
	int N;
	cin >> N;
	vector<int> A(N);
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
		A[i]--;
	}
	int ans = 0;
	int now = 0;
	for (int i = 0; i < N * 2; ++i) {
		++ans;
		now = A[now];
		if (now == 1) {
			cout << ans << endl;
			return;
		}
	}
	cout << -1 << endl;
}

signed main(void) {
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}

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

int main() {
    long long N;
    cin >> N;
    string ans;
    while (N > 0) {
        N--;
        ans = char ('a' + (N % 26)) + ans;
        N /= 26;
    }
    cout << ans << endl;
}

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

int main() {
int N, F;
  cin >> N;
  F=(N/10000000)
    +(N%10000000)/(1000000)
    +(N%1000000)/(100000)
    +(N%100000)/(10000)
    +(N%10000)/(1000)
    +(N%1000)/(100)
    +(N%100)/(10)
    +(N%10);

  if (N%F==0){
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

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

int compare_int(const void *a, const void *b)
{
    return *(int*)a - *(int*)b;
}
int main(void) {
    int n,i,j;
    scanf("%d",&n);
    int arr[n];
    for(i=0;i<n;i++)
        scanf("%d",&arr[i]);

    int tmp[n];
    for(i=0;i<n;i++)
        tmp[i] = arr[i];
    qsort(tmp, n, sizeof(int), compare_int);
    int count = 0;
    for(i=0;i<n;i++) {
        if(tmp[i]!=arr[i])
            count++;
    }
    if(count==2 || count==0)
        printf("YES\n");
    else
        printf("NO\n");

    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,a[1000];
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  int x;
  cin>>x;
  for(int i=0;i<x;i++){
    int y,z,ans;
    cin>>y>>z;
    reverse(a+y,a+z);
  }
  for(int i=0;i<n;i++){
    if(i!=0) cout<<" ";
    cout<<a[i];
  }
  cout<<endl;
  return 0;
}


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

int main(void) {
    int N;cin>>N;
    bool flg = false;
    for (int i = 0; i <= 25; i++) {
        for (int j = 0; j <= 25; j++) {
            if (N == 4 * i + 7 * j) flg = true;
        }
    }
    if (flg) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
def main():
    import sys
    input = sys.stdin.readline
    a, b, k = list(map(int, input().rstrip('\n').split()))
    ls = []
    for i in range(a, min(a + k, b)):
        if i not in ls:
            ls.append(i)
    for i in range(b, max(b - k, a - 1), -1):
        if i not in ls:
            ls.append(i)
    ls.sort()
    for i in ls:
        print(i)


if __name__ == '__main__':
    main()


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

int main () {
    int N = 0;
    int Y = 0;
    cin >> N >> Y;

    int ret1 = -1;
    int ret2 = -1;
    int ret3 = -1;

    for (int i = 0; i <= N; ++i) {
        for (int j = 0; j+i <= N; ++j) {
            int k = N - i - j;
            int total = 10000*i + 5000*j + 1000*(k);
            if (total == Y) {
                ret1 = i;
                ret2 = j;
                ret3 = k;
            }
        }
    }
    
    cout << ret1 << " " << ret2 << " " << ret3 << endl;
}


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

#include <string>
#include <vector>


int main()
{
	string s1;
	cin >> s1;


	int cnt = 0;
	int i1 = 0, i2 = s1.size() -1;


	while( i1 < i2 )
	{
		if( s1[ i1 ] != s1[ i2 ] )
		{
			cnt++;
		}

		i1++;
		i2--;
	}




	cout << cnt << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;

long long pow_mod(long long x, long long n){
    long long ans = 1;
    while(n != 0){
        if(n&1) ans = ans*x % mod;
        x = x*x % mod;
        n = n >> 1;
    }
    return ans;
}

int main(){
    int n;
    cin >> n;
    long long a[n];
    for(int i=0; i<n; i++){
        cin >> a[i];
    }
    long long posd[62];
    fill(posd,posd+62,0);
    for(int i=0; i<n; i++){
        long long b = a[i];
        for(int j=0; j<62 && b>0; j++){
            posd[j] += b%2;
            b /= 2;
        }
    }
    long long ans = 0;
    for(int i=0; i<62; i++){
        long long p = pow_mod(2,i);
        ans += ((posd[i]*(n-posd[i])%mod)*p);
        ans %= mod;
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

const int MAX = 1010000;
long long fac[MAX], finv[MAX], inv[MAX];
bool initialized = false;

/**
 * @fn
 * This function must be called at first.
 */
void combination_init() {
    initialized = true;
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++) {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

/**
 * @fn
 * Calculates the combination  ( nCK % p: N choose K mod p).
 *
 * @brief constraint: 1 ≤ k ≤ n ≤ 10^7
 * @return nCK % MOD
 */
long long combination(int n, int k) {
    assert(initialized);
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

/**
 * @fn
 * Calculates the factorial of the number.
 *
 * @return N! % MOD
 */
long long factorial(int n) {
    assert(initialized);
    if (n < 0) return 0;
    return fac[n] % MOD;
}

/**
 * @fn
 * Calculates the combination ( nCK % p: N choose K mod p).
 *
 * @brief constraint: 1 ≤ k ≤ 10^7 and 1 ≤ n ≤ 10^9
 * @return nCK % MOD
 */
long long combination2(int n, int k) {
    assert(initialized);
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    ll res = 1;
    k = min(k, n - k);
    for (long long x = 1; x <= k; x++) {
        res *= (n - x + 1);
        res %= MOD;
        res *= inv[x];
        res %= MOD;
    }
    return res;
}


void solve() {
    ll N;
    cin >> N;
    N++;
    vector<ll> A(N);
    rep(i, N) cin >> A[i];
    ll d = 0;
    vector<ll> cnt(N, 0);
    rep(i, N) {
        cnt[A[i]]++;
    }
    rep(i, N) {
        if (cnt[i] == 2) {
            d = i;
        }
    }
    ll xy = 0;
    bool ok = true;
    rep(i, N) {
        ll a = A[i];
        if (a == d) {
            ok ^= true;
        }
        if (a != d && ok) {
            xy++;
        }
    }
    combination_init();
    rep2(k, 1, N + 1) {
        ll m = combination(xy, k - 1);
        ll ans = combination(N, k) - m;
        if (ans < 0) ans += MOD;
        cout << ans << '\n';
    }
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    return 0;
}


Measured memory_bytes: 26496
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int n; cin >> n;
  VV<> a(n, V<>(n));

  auto fn = [&](const auto& fn, int s, int l, int r) -> void {
    if (r - l == 1) return;
    if (r - l == 2) {
      a[l][l + 1] = s;
      return;
    }
    int m = l + r >> 1;
    for (int i = l; i < m; ++i) for (int j = m; j < r; ++j) {
      a[i][j] = s;
    }
    fn(fn, s + 1, l, m);
    fn(fn, s + 1, m, r);
  };
  fn(fn, 1, 0, n);

  for (int i = 0; i < n - 1; ++i) {
    for (int j = i + 1; j < n; ++j) {
      cout << a[i][j] << " \n"[j == n - 1];
    }
  }
}

Measured memory_bytes: 1536
n = int(input())
a = list(map(int, input().split()))
mod = 10**9+7

cur = 0
res = 0
for i in range(n-1):
    cur = (cur + a[n-1-i]) % mod
    tmp = (a[n-2-i] * cur) % mod
    res = (res + tmp) % mod

print(res)

Measured memory_bytes: 31652
N,X=map(int, raw_input().split())

p=[1]
a=[1]
for i in range(N):
	p.append( p[-1]*2+1 )
	a.append( a[-1]*2+3 )

#print "p:::",p
#print "a::::",a

X-=1

def f(N,X):
#	print "f (",N ," , ", X ," ) " ,ans

	if X<0:
		return 0		
	elif N==0:
		return 1
	elif X>=a[N]/2:
		X-=(a[N-1]+2)
		return p[N-1]+1+f(N-1,X)
	else:
		X-=1
		return f(N-1,X)

print f(N,X)



Measured memory_bytes: 28396
import queue

H, W = map(int, input().split())
S = [input() for i in range(H)]
q = queue.Queue()
longest_path = 0
for i in range(H):
    for j in range(W):
        if S[i][j] == '.':
            g = [[0 if S[k][l] == '.' else -1 for l in range(W)] for k in range(H)]
            q.put((i,j))
            g[i][j] = 0
            while not(q.empty()):
                x, y = q.get()
                for nx, ny in [(x+1, y),(x-1, y),(x, y+1),(x, y-1)]:
                    if nx < 0 or nx > H-1 or ny < 0 or ny > W-1: continue
                    if g[nx][ny] != 0: continue
                    if nx == i and ny == j: continue
                    g[nx][ny] = g[x][y] + 1
                    q.put((nx,ny))
            longest_path = max(longest_path, max(map(max, g)))
print(longest_path)


Measured memory_bytes: 3952
#include <bits/stdc++.h>
#include <assert.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define PB push_back
#define MP make_pair
#define MOD 1000000007LL
#define endl "\n"
#define fst first
#define snd second
const ll UNDEF = -1;
const ll INF=1e18;
template<typename T> inline bool chkmax(T &aa, T bb) { return aa < bb ? aa = bb, true : false; }
template<typename T> inline bool chkmin(T &aa, T bb) { return aa > bb ? aa = bb, true : false; }
typedef pair<ll,ll> pll;
typedef vector<ll> vll;

void solve(long long N, long long P, vector<long long> A){
	int odd=0,even=0;
	for (auto &w:A) {
		if (w&1) odd++; else even++;
	}
	ll ans;
	if (P==0) {
		ans=1LL<<(max(0,odd-1)+even);
	}
	else {
		if (odd==0) ans=0;
		else ans=1LL<<(max(0,odd-1)+even);
	}
	printf("%lld\n",ans);
}

int main(){	
	ios_base::sync_with_stdio(false); cin.tie(0);
	long long P;
	long long N;
	scanf("%lld",&N);
	vector<long long> A(N-1+1);
	scanf("%lld",&P);
	for(int i = 0 ; i <= N-1 ; i++){
		scanf("%lld",&A[i]);
	}
	solve(N, P, A);
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define rep(i,b) FOR(i,0,b)
#define INF 1e9

int a[]={1,3,5,7,8,10,12};
int b[]={4,6,9,11};
int main(){
  int x,y;
  cin>>x>>y;

  int af=0;
  int bf=0;
  for(int i=0;i<7;i++){
    if(a[i]==x)af=1;
    if(a[i]==y)bf=1;
  }

  for(int i=0;i<4;i++){
    if(b[i]==x)af=2;
    if(b[i]==y)bf=2;
  }

  if(x==2)af=3;
  if(y==2)bf=3;

  if(af==bf){cout<<"Yes"<<endl;}else{
    cout<<"No"<<endl;
  }
}


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

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

    string a, b, c;
    cin >> a >> b >> c;

    if(a[a.length()-1] == b[0] && b[b.length()-1] == c[0]) puts("YES");
    else puts("NO");
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  int i=1;
  while(i<=3)
  {
    if(n%10==7)
    {
      cout<<"Yes";
      return 0;
    }
    i++;n/=10;
  }
  cout<<"No";
  return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
const int N=200005;
int tot,fi[N],zz[N],ne[N],n,m,x,y,vis[N],flag[N],flag2[N],l[N],r[N],v[N];
void jb(int x,int y){
	ne[++tot]=fi[x];
	fi[x]=tot;
	zz[tot]=y;
}
void GG(){
	puts("No");
	exit(0);
}
void dfs1(int x,int y){
	flag2[x]=flag[x];
	l[x]=-1e9,r[x]=1e9;
	for (int i=fi[x];i;i=ne[i])
		if (zz[i]!=y){
			dfs1(zz[i],x);
			if (flag2[zz[i]]){
				flag2[x]=1;
				if (vis[zz[i]]*vis[x]==1)GG();
				vis[x]=-vis[zz[i]];
				l[x]=max(l[x],l[zz[i]]-1);
				r[x]=min(r[x],r[zz[i]]+1);
			}
		}
	if (vis[x]*(flag[x]==1?(v[x]&1?-1:1):0)==-1)GG();
	if (flag[x])vis[x]=v[x]&1?-1:1,l[x]=max(l[x],v[x]),r[x]=min(r[x],v[x]);
	if (l[x]>r[x])GG();
}
void dfs2(int x,int y){
	if (!flag[x]){
		if (!y)v[x]=l[x];
		else if (!flag2[x])v[x]=v[y]-1;
		else {
			if (v[y]-1>=l[x]&&v[y]-1<=r[x])v[x]=v[y]-1;
			else v[x]=v[y]+1;
		}
	}
	for (int i=fi[x];i;i=ne[i])
		if (zz[i]!=y)dfs2(zz[i],x);
}
int main(){
	scanf("%d",&n);
	for (int i=1;i<n;i++){
		scanf("%d%d",&x,&y);
		jb(x,y);jb(y,x);
	}
	scanf("%d",&m);
	while (m--){
		scanf("%d%d",&x,&y);
		flag[x]=1;
		v[x]=y;
	}
	dfs1(1,0);
	dfs2(1,0);
	puts("Yes");
	for (int i=1;i<=n;i++)printf("%d\n",v[i]);
}


Measured memory_bytes: 11392
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		String s = scanner.next();
		int ans = 0;
		for (char c: s.toCharArray()) {
			if (c=='+'){
				ans++;
			}else{
				ans--;
			}
		}
		System.out.println(ans);
	}
}

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

#ifdef RUBICK
#include "dbg.h"
#else
#define dbg(exp) /* nop; */
#endif

// F cin/cout
#define cin nullptr
#define cout nullptr

using namespace std;
using namespace __gnu_pbds;

template<class T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

using ll = long long;
using ld = long double;

int main() {
    int n;
    scanf("%d", &n);

    set<int> s;
    while (n--) {
        int x;
        scanf("%d", &x);
        if (s.count(x) == 0)
            s.insert(x);
        else
            s.erase(x);
    }

    printf("%u\n", s.size());

    return 0;
}



Measured memory_bytes: 8412
N = int(input())
S = input()
R = []
G = []
B = []
for i in range(N):
    if S[i] == 'R':
        R.append(i)
    elif S[i] == 'G':
        G.append(i)
    elif S[i] == 'B':
        B.append(i)
ans = len(R)*len(G)*len(B)
for i in range(1,(N+1)//2):
    for j in range(i,N-i):
        if S[j] != S[j-i] and S[j] != S[j+i] and S[j-i] != S[j+i]:
            ans -= 1
print(ans)

Measured memory_bytes: 9236
#include <string.h>
#include <stdio.h>
#include <iostream>
#include <string>
#include <cstring>
#include <math.h>
#include <set>
#include <vector>
#include <algorithm>
#include <map>

using namespace std;

typedef long long ll;
#define INF 0x3f3f3f3f
#define ESP 1e-8
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
const double PI = acos(-1.0);

int main(){
    // FILE *fp = freopen("out.txt", "w", stdout);
    // freopen("in.txt", "r", stdin);
    int x, y;
    while(scanf("%d%d", &x, &y) != EOF){
        printf("%d\n", x+y/2);
    }

    // fclose(fp);
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main()
{
	string s;
	cin>>s;
	int len=s.length(),t=1;
	for(int i=0;i<len;i++)
	{
		//cout<<"t:"<<t<<" S:"<<s[i]<<endl;
		if(t%2==1&&s[i]=='L')
		{
			cout<<"No"<<endl;
			return 0;
		}
		else if(t%2==0&&s[i]=='R')
		{
			cout<<"No"<<endl;
			return 0;
		}
		t++;
	}
	cout<<"Yes"<<endl;
}

Measured memory_bytes: 256
from collections import*
(n,m),*d=[list(map(int,o.split()))for o in open(0)]
r=range(a:=n)
for _ in[0]*m:
 k=[]
 for i in r:k+=d[i][0],
 I,w=Counter(k).most_common()[0];a=min(a,w)
 for j in r:d[j].remove(I)
print(a)

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

int main()
{
    string o, e;
    cin >> o >> e;
    for (int i = 0; i < o.size() + e.size(); i++)
    {
        if (i % 2 == 0)
        {
            cout << o.at(i / 2);
        }
        else
        {
            cout << e.at(i / 2);
        }
    }
    cout << endl;
}

Measured memory_bytes: 3588
# 解答コピー
N, M = map(int, input().split())
H = list(map(int, input().split()))

A = [0] * N # Aの要素は各展望台に繋がっている別の展望台の最大の標高が入る
for i in range(M):
    a, b = map(int, input().split())
    A[a-1] = max(A[a-1], H[b-1])
    A[b-1] = max(A[b-1], H[a-1])

# print(A) # Aには各展望台から行くことが可能な展望台の中で最も高いものの高さを収納
good = sum([H[i] > A[i] for i in range(N)])
print(good)

Measured memory_bytes: 20112
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define irep(i, n) for (int i = (n); i >= 0; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1 << 25;
const int MOD = 1e9+7;
 
int main() {
  int n,x,t;
  cin >>n>>x>>t;
  if (n%x == 0) cout << n/x*t << endl;
  else cout << (n/x+1) * t << endl;
  return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define ll long long int
#define mod 10000000007
#define mod2 998244353
#define pb push_back
#define ru(i,n) for(int i=0;i<n;i++)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repb(i,a,b) for(int i=a;i>=b;i--)
#define vi vector<int>
#define mp make_pair
#define inp(a,n) ru(i,n){cin>>a[i];}
#define sv(v) sort(v.begin(),v.end())
#define sa(a) sort(a,a+size(a)/size(a[0]))
using namespace std;

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

const int mw=1e9+10;
ll dp[3010][3010];

string a,b;



void solve(int m,int n)
{
	 ru(i,m+1)
	 ru(j,n+1)
	 {
		 if(j==0||i==0)
		 dp[i][j]=0;
		 else if(a[i-1]==b[j-1])
		 dp[i][j]=dp[i-1][j-1]+1;
		 else
		 dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
	 }
}
string ans(int m,int n)
{
	string an="";
	int i=m,j=n;
	while(i&&j)
	{
		if(a[i-1]==b[j-1])
		{
			an=a[i-1]+an;
			i--;j--;
		}
		else if(dp[i-1][j]>=dp[i][j-1])
		{
			i--;
		}
		else
		j--;
	}
	return an;
}
int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
	int t=1;
	//cin>>t;
	while(t--)
	{
		memset(dp,0,sizeof(dp));
		cin>>a>>b;
		int m=a.size(),n=b.size();
		//cout<<
		solve(m,n);
		//cout<<dp[m][n]<<"\n";
		cout<<ans(m,n);
	}
return 0;
}


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

using ll = long long;

int op(int a, int b){return max(a,b);}
int e(){return 0;}
const int MAX_A = 300005;
#include <atcoder/all>
using namespace atcoder;

int main(){
  int N,K;
  cin >> N >> K;
  vector<int> A(N);
  rep(i,N){cin >> A[i];}

  // Aをi番目まで見た時の最後の数字がjである時のBの長さをdp[i][j]に格納(解説放送より)
    /* dp遷移は
      dp[i][j] = dp[i-1][j] <選ばない場合>
      dp[i][Ai] = max(dp[i-1][Ai-K~Ai+K]) + 1 <選ぶ>

      ただこのままだとdp配列が確保できないのでiを消去
      <選ばない場合>はdp[j]の基本変化なし
      dp[Ai] = max(dp[Ai], max(dp[Ai-K ~ Ai+K]) <選ぶ>

      maxdpの部分では区間の最大値を取るのでO(NK)になり間に合わない
       → segtreeを使用(解説略された…)(蟻本)
    */
  
  // 以下、解説放送の写経 // 上記のop,e,MAX_A及びatcoderライブラリも含む

  segtree<int, op, e> dp(MAX_A);
  // op … 加算などの演算を表す　
  // e … 上記演算における単位元
  rep(i,N){
    int x = A[i];
    int l = x-K, r = x+K+1;// prodの範囲は半開区間なのでrには+1が必要
    l = max(l,0); r = min(r,MAX_A);
    int now = dp.prod(l,r) + 1;
    dp.set(x, now);
  }
  int ans = dp.prod(0,MAX_A);
  cout << ans << endl;
}


/*
サンプルでは貪欲でイケるけど貪欲で取るとだめな例がある
(ex)K=3のとき(1,4,0,0,0,0,0,0)など

取る場合と取らない場合を両方考慮する必要があるのでdpっぽい
ぽいけど…最長共通部分列問題と違って保持する最後の数字が変化する・複数の可能性があるから実装がわからん…

ので解説放送をみた！dpは合ってたけど二次元dpっぽい

ACLという競プロライブラリ実装記念のコンテストなので
想定解はライブラリ使って殴ることらしい。(が、わからん)
*/

Measured memory_bytes: 9608
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<map>
#include<iomanip>
#define rip(i,n) for(int i=0;i<n;i++)
#define ll long long
#define ld long double
#define set setprecision　//小数点以下何位まで知りたいか
#define mod 1000000007
#define pi 3.14159265
#include<numeric>
using namespace std;
int gcd(int a, int b)//最大公約数
{
	if (a % b == 0)	return(b);
	else return(gcd(b, a % b));
}
int lcm(int a, int b)//最小公倍数
{
	return a * b / gcd(a, b);
}
ll pow(ll a, ll b) {
	ll k = b % 30000, h = b / 30000, s = 1;
	rip(i, 30000)s = (s * a) % 2019; ll j = 1;
	if (h != 0)rip(i, h)j = j * s % 2019;
	if (k != 0)rip(i, k)j = j * a % 2019;
	return(j);
}
int main() {
	int n, m;
	cin >> n >> m;
	vector<int>h(n);
	rip(i, n)cin >> h[i];
	vector<int>a(m);
	vector<int>b(m);
	vector<int>c(n,10);
	rip(i, m) {
		cin >> a[i] >> b[i];
		a[i] = a[i] - 1;
		b[i] = b[i] - 1;
		if (h[a[i]] == h[b[i]])c[a[i]] = 0, c[b[i]] = 0;
		else if (h[a[i]] > h[b[i]])c[b[i]] = 0;
		else c[a[i]] = 0;
	}
	int count = 0;
	rip(i, n)if (c[i] != 0)count++;
	cout << count << endl;
}

Measured memory_bytes: 4840
import sys
n, a = map(int, sys.stdin.readline().split())
x = list(map(int, sys.stdin.readline().split()))
dp = [[[0 for s in range(n*50 +1)] for k in range(n+1)] for j in range(n+1)]
from pprint import pprint
# pprint(dp)

for k in range(n+1):
    for s in range(n*50+1):
        dp[0][k][s] = 0

dp[0][0][0] = 1
for j in range(1,n+1):
    for k in range(n+1):
        for s in range(n*50+1):
            # print(j, k, s)
            if 1 <= j and s < x[j-1]:
                dp[j][k][s] = dp[j-1][k][s]
            elif 1 <= j and 1 <= k and x[j-1] <= s:
                dp[j][k][s] = dp[j-1][k][s] + dp[j-1][k-1][s-x[j-1]]
            else:
                dp[j][k][s] = 0
sum = 0
for k in range(1,n+1):
    sum += dp[n][k][k*a]
print(sum)


Measured memory_bytes: 97116
#define ll long long int
#include <bits/stdc++.h>
//#include <fstream>
using namespace std;
 
#define         ff               first
#define         ss               second
#define         mp               make_pair
#define         pb               push_back
#define         pf               push_front
#define         vi               vector<ll>
#define         pii              pair<ll,ll>
#define         qi               queue<ll>
#define         mem(a,b)         memset(a,b,sizeof(a))
#define         print(a)         cout<<a<<'\n'
#define         sorted(arr)      sort(arr.begin(),arr.end())
#define         gcd(a,b)         gcd((a),(b))
#define         lcm(a,b)         ((a)*(b))/gcd((a),(b))
#define         all(v)           v.begin(),v.end()
#define         read(a)          scanf("%d", &a)
#define         f(a,n)           for(ll i=a;i<n;i++)
#define         in2(n,m,arr)     for(ll i=0;i<n;i++){for(ll j=0;j<m;j++)cin>>arr[i][j];}
#define         debug(a)         cerr<<a<<" ";
#define         debug1(a)        cerr<<a<<'\n'
 
/*typedef tree<int, null_type, less<int>, rb_tree_tag , tree_order_statistics_node_update> Set;*/
 
 
const unsigned ll mod = 1e9 + 7 ;
const ll inf = (ll)1e18 + 2;
const ll N = (ll)1e5 + 2;
//
//template<typename... T>
//void write(T&... args)
//{
//    ((cout << args << ' '), ...);
//}
//ll power ( ll x , ll y)
//{
//    ll res = 1;
//    while (y > 0)
//    {
//        if (y & 1)
//            res = (res * x) ;
//        y = y >> 1;
//        x = (x * x) ;
//    }
//    return res  ;
//}
//
//struct node{
//    ll x , y , z;
//};
//map<pair<ll, ll>,ll> c;
//vector<set<ll>> tree;
//vector<ll> ar ;
//set<ll> s;
//ll get(ll x)
//{
//    if(x == ar[x])
//        return x;
//    return ar[x] = get(ar[x]);
//}
//void merge(ll a ,ll b)
//{
//    a = get(a);
//    b = get(b);
//    if(a == b)
//    {
//        return ;
//    }
//    ar[b] = ar[a];
// }
//
//ll sev[100006];
//vector<ll> pri;
//void seive()
//{
//    for(ll i = 2 ; i < 100006 ; i ++)
//    {
//        if(!sev[i])
//        {
//            for(ll j = i ; j < 100006 ; j += i)
//            {
//                if(!sev[j])
//                    sev[j] = i;
//            }
//        }
//        if(sev[i] == i)
//            pri.pb(i);
//    }
//}

void solve()
{
    ll n ;
    cin >> n;
    ll arr[n];
    for(ll i = 0 ; i < n ; i ++)
        cin >> arr[i];
    ll fi = INT_MAX;
    for(ll i = 1 ; i <= 100 ; i ++)
    {
        ll ans = 0;
        for(ll j = 0 ; j < n ; j ++)
        {
            ans += ((i - arr[j])*(i - arr[j]));
        }
        fi = min(fi , ans);
    }
    print(fi);
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll t ;
    t = 1;
    //cin >> t;
    //seive();
    while(t --)
    {
        solve();
    }
    cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
    return 0;
}
 


Measured memory_bytes: 256
using System;
using System.Linq;

namespace abc058
{
    class Program
    {
        static void Main(string[] args)
        {
            // 入力行数
            var n = int.Parse(Console.ReadLine());
            // 文字列を取得
            string[] lines = new string[n];
            for (int i = 0; i < n; i++)
            {
                lines[i] = Console.ReadLine();
            }

            // 各文字列のアルファベットの数を数える
            int[,] charArray = new int[n, 26];
            for (int i = 0; i < n; i++)
            {
                for (int j = 0; j < 26; j++)
                {
                    charArray[i, j] = lines[i].Count(x => x == (char)(j + 97));
                }
            }
            
            // すべての文字列で共通に使われているアルファベットの数を数えながら文字列を生成
            string answer = string.Empty;
            // アルファベット毎に集計していく
            for (int i = 0; i < 26; i++)
            {
                // 各文字列を縦断して集計
                int[] buff = new int[n];
                for (int j = 0; j < n; j++)
                {
                    buff[j] = charArray[j,i];
                }
                // 0が含まれていれば次のアルファベットに移る
                var count = 0;
                if (buff.Any(x => x == 0))
                {
                    continue;
                }
                // すべての文字列の中で1回以上使用されている場合は最小回数を取得して文字列を生成
                else
                {
                    count = buff.Min();
                    answer += new string((char)(i+97), count);
                }
            }

            // 出力
            Console.WriteLine(answer);
            //Console.ReadLine();
        }
    }
}

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

bool dislike[10];

bool isLiked(int n) {
	while (n > 0) {
		if (dislike[n % 10]) return false;
		n /= 10;
	}
	return true;
}

int main() {
	int N, K; cin >> N >> K;
	for (int i = 0; i < 10; i++)
		dislike[i] = false;
	for (int i = 0; i < K; i++) {
		int a; cin >> a;
		dislike[a] = true;
	}
	for (int i = N;; i++) {
		if (isLiked(i)) {
			cout << i << endl;
			break;
		}
	}
	return 0;
}

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



int main()
{
	int64_t N, D, count = 0;
	cin >> N >> D;
	for (int i = 0; i < N; i++)
	{
		int64_t x, y;
		cin >> x >> y;

		if (sqrt(x * x + y * y)<=D) {
			count++;
		}
	}
	cout << count << endl;
}

Measured memory_bytes: 3580
N, P = map(int, input().split())
A = list(map(int, input().split()))

dp = [[0, 0] for i in range(N)]

dp[0][0] = 1
dp[0][A[0] % 2] += 1

for i in range(1, N):
    dp[i][0] = dp[i - 1][0]
    dp[i][1] = dp[i - 1][1]
    dp[i][A[i] % 2] += dp[i - 1][0]
    dp[i][(A[i] + 1) % 2] += dp[i - 1][1]

print(dp[N - 1][P])

Measured memory_bytes: 3064
#include<iostream>
#include<stdio.h>

#define PI 3.14159265358979

using namespace std;

int main() {
	double r;
	double s, l;

	cin >> r;

	s = r*r*PI;
	l = 2 * r*PI;

	printf("%f %f\n", s, l);

	return 0;
}

Measured memory_bytes: 1232
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s1;
	getline(cin,s1);
	long long k;
	cin>>k;
	if(s1.length()==1){
		cout<<k/2<<endl;
		return 0;
	}
	
	int flag=1;
	int len=s1.length();
	for(int i=1;i<len;i++){
		if(s1[i]!=s1[i-1]){
			flag=0;
			break;
		}
	}
	if(flag){
		cout<<len*k/2<<endl;
		return 0;
	}
	
	//ababababa ababababa  5 4
	//7 6
	long long cnt=0;
	for(int i=1;i<s1.length();i++){
		if(s1[i]==s1[i-1])
			cnt++,i++;
	}
//	long long cnt1=0;
//	string s2=s1+s1;
//	for(int i=1;i<s2.length();i++){
//		if(s2[i]==s2[i-1])
//			cnt1++,i++;
//	}
	
	if(s1[0]==s1[s1.length()-1]){
		flag=1;
	}else{
		flag=0;
	}
	if(flag){
		int a=1,b=1;
		for(int i=1;i<s1.length();i++){
			if(s1[i]!=s1[i-1]) break;
			a++;
		}
		for(int i=s1.length()-2;i>=0;i--){
			if(s1[i]!=s1[i+1]) break;
			b++;
		}
		cout<<cnt*k-((a/2+b/2)-(a+b)/2)*(k-1)<<endl;
	}else{
		cout<<cnt*k<<endl;
	}
//	cout<<cnt<<" "<<cnt1<<endl;
//	cout<<k/2<<endl;

//	if(cnt==(cnt1-cnt)){
//		cout<<cnt*k<<endl;
//	}	
//	else{
//		if(flag){
//			if(k%2==0)
//				cout<<cnt1*(k/2)+(cnt1-cnt)*(k/2-1)<<endl;
//			else
//				cout<<cnt+(cnt1-cnt)*(k-1)<<endl;
//		}else{
//			if(k%2==0)
//				cout<<cnt1*(k/2)<<endl;
//			else
//				cout<<(cnt1-cnt)+cnt1*(k/2)<<endl;
//		}
		
//	}
	return 0;
}


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

int main(){
	int n;
	cin>>n;
	map<int,int> mp;
	vector<int> x;
	
	for(int i=0;i<n;i++){
		int a;
		cin>>a;
		x.push_back(a);
		mp[x[i]]++;
	}
	
	//cout<<mp.size()<<endl;
	
	if(mp.size()%2==0){
		cout<<mp.size()-1<<endl;
	}else{
		cout<<mp.size()<<endl;
	}
	return 0;
}

Measured memory_bytes: 5368
#include<iostream>
#include<bits/stdc++.h>
#include<algorithm>
#include<string.h>
#include<math.h>
#include <cstdlib>
#include <stdlib.h>
#define FasterIO     ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define PI acos(-1)
#define all(a) a.begin(),a.end()
#define f first
#define s second
#define pb push_back
#define ppb pop_back
#define pf push_front
#define ppf pop_front
#define mp make_pair
#define f0(i,n) for(i=0;i<n;i++)
#define f1(i,n) for(i=1;i<n;i++)
#define f1n(i,n) for(i=1;i<=n;i++)
#define szf sizeof()
#define sz size()
#define ln length()
#define MOD 1000000007
using namespace std;
using ll=long long;
int cnt,element;
int main()
{
    FasterIO
    ll a,b,n,rafi=0,fl;
    cin>>a>>b>>n;
    fl=b-1;
    if(fl>n)
    {
        fl=n;
    }
    rafi=floor(((a*fl)/b)-(a*(fl/b)));
    cout<<rafi<<endl;
    return 0;
}


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

int main(void){
    int H,W;
    cin >>H>>W;
    string S;
    
    rep(i,H){
        cin >>S;
        cout<<S<<endl<<S<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
import math

K = int(input())

g = [[0] * 201 for i in range(201)]

for i in range(201):

    for j in range(201):

        g[i][j] = math.gcd(i,j)

ans = 0

for i in range(1,K+1):

    for j in range(1,K+1):

        for x in range(1,K+1):

            ans += g[g[i][j]][x]

            #print (i,j,x,g[g[i][j]][x])

print (ans)


Measured memory_bytes: 68272
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	N := ReadInt()
	A := ReadInts(N)
	trace(A)
	insertionSort(N, A)
}

// 挿入ソート
func insertionSort(N int, A []int) {
	for i := 1; i < N; i++ {
		v := A[i]
		j := i - 1
		for ; j >= 0 && A[j] > v; j-- {
			A[j+1] = A[j]
		}
		A[j+1] = v
		trace(A)
	}
}

func trace(A []int) {
	fmt.Printf("%d", A[0])
	for _, v := range A[1:] {
		fmt.Printf(" %d", v)
	}
	fmt.Println()
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int) { Scan(&i); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}



Measured memory_bytes: 1192
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{
   long long int c[10][10]={0},sum=0;
   long long int n;
    cin>>n;
    for(long long int i=1;i<=n;i++){
       long long int a=i;
        long long int b=a%10;
        while(a>=10){
            a/=10;
        }
        c[a][b]++;
    }
    for(long long int i=0;i<=9;i++){
        for(long long int j=0;j<=9;j++){
            sum+=(c[i][j]*c[j][i]);
        }
    }
    cout<<sum<<endl;
}


Measured memory_bytes: 3632
#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 = 100010;
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 n, k;
ll arr[110], dp[110][N];

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>n>>k;
    memset(dp, 0, sizeof(dp));
    for(int i=0;i<n;i++)    cin>>arr[i];
    for(int i=0;i<=k;i++)   dp[n][i] = 1;
    for(int i=n-1;i>=0;i--){
        for(int j=0;j<=k;j++){
            dp[i][j] = (dp[i+1][j] - ((arr[i] < j) ? dp[i+1][j-arr[i]-1] : 0) + mod)%mod;
            dp[i][j] += ((j > 0) ? dp[i][j-1] : 0);
            dp[i][j] = (dp[i][j] + mod)%mod;
        }
    }
    cout<<((k > 0) ? (dp[0][k] - dp[0][k-1] + mod)%mod : dp[0][k])<<endl;
    return 0;
}

Measured memory_bytes: 86144
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author yassin
 */

#include <fstream>

#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstdlib>
#include <tuple>
#include <queue>
#include <functional>
#include <stack>
#include <numeric>
#include <cassert>

using namespace std;

constexpr int INF = 1000 * 1000 * 1000;

class AGC_A {
public:
    void solve(istream& in, ostream& out) {
        int N;
        in >> N;
        vector<int> A(N);
        for (int i = 0; i < N; ++i) {
            in >> A[i];
        }
        if (N == 1) {
            out << 1 << "\n";
            return;
        }
        
        vector<pair<int, int>> dp(N, {INF, INF});
        dp[0].first = dp[0].second = 1;
        for (int i = 1; i < N; ++i) {
            if (A[i] >= A[i-1]) {
                dp[i].first = min(dp[i].first, dp[i-1].first);
                dp[i].first = min(dp[i].first, (i-2 >= 0 ? dp[i-2].second : 0) + 1);
                dp[i].first = min(dp[i].first, (i-2 >= 0 ? dp[i-2].first : 0) + 1);
            }
            if (A[i] <= A[i-1]) {
                dp[i].second = min(dp[i].second, dp[i-1].second);
                //dp[i].second = min(dp[i].second, dp[i-1].first + 1);
                dp[i].second = min(dp[i].second, (i-2 >= 0 ? dp[i-2].first : 0) + 1);
                dp[i].second = min(dp[i].second, (i-2 >= 0 ? dp[i-2].second : 0) + 1);
            }
        }
        
        out << min(dp[N-1].first, dp[N-1].second) << "\n";
    }
};


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

	AGC_A solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 1408
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split();
            int n = int.Parse(str[0]);
            int k = int.Parse(str[1]);

            int[] sunuke = new int[n + 1];

            for (int i = 0; i < k; ++i)
            {
                int d = int.Parse(Console.ReadLine());
                str = Console.ReadLine().Split();
                for (int j = 0; j < d; ++j)
                {
                    int a = int.Parse(str[j]);
                    sunuke[a] = 1;
                }
            }

            int sum = 0;
            for (int i = 0; i < n + 1; ++i)
            {
                sum += sunuke[i];
            }
            Console.WriteLine(n - sum);
        }
    }
}


Measured memory_bytes: 27640
#include <iostream>
#include <string>
#include <algorithm>
#include <cassert>
#include <limits>
#include <numeric>
#include <type_traits>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <functional>
#include <utility>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <complex>
#include <climits>
#include <queue>

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef pair<ll, ll> P;
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)
const double PI = 3.1415926535897932;
/******define variable start******/
ll x;
/*******define variable end*******/
ll solve(){
    cin >> x;
    bool prime[x + 1000000];
    REP(i,x + 1000000) prime[i] = 1;
    prime[0] = prime[1] = 0;
    REP(i,x + 1000000){
        if(prime[i]){
            for(int j = i + i; j < x + 1000000; j+=i){
                prime[j] = 0;
            }
        }
        if(i >= x && prime[i]){
            cout << i << endl;
            return 0;
        }
    }
    return 0;
}
int main(){
    //clock_t start = clock();
    cout << std::fixed << std::setprecision(10);
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll end_solve = solve();
    /*
    clock_t end = clock();
    const double time = static_cast<double>(end - start) / CLOCKS_PER_SEC * 1000.0;
    printf("time %lf[ms]\n", time);
    */
    return (int)end_solve;
}


Measured memory_bytes: 1280
// include
// ------------------------------------------------
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

// func
// ------------------------------------------------
int CalcSumOfDigit(int n);      // 各桁の和を計算する。
string upper(string str);       // 英字を大文字に変換する。
string lower(string str);       // 英字を小文字に変換する。

// define
// ------------------------------------------------
#define all(a)        (a).begin(),(a).end()
#define rall(a)       (a).rbegin(),(a).rend()
#define pb            push_back
#define sz(a)         int((a).size())
#define rep(i,n)      for(int(i)=0;(i)<(n);(i)++)
#define repe(i,n)     for(int(i)=0;(i)<=(n);(i)++)
#define vsort(v)      sort((v).begin(),(v).end())
#define rvsort(v)     sort(rall((v)))
#define vi            vector<int>
#define GCD(a,b)      __gcd((a),(b))
#define LCM(a,b)      (a)/GCD((a),(b))*(b)
#define kiriage(a,b)  ((a)+(b)-1)/(b)

const int INF = 1e9;

// code
// ------------------------------------------------
int main() {

  int n;
  cin >> n;

  double btc = 0;
  double yen = 0;

  rep(i,n)
  {
    string s;
    double x;

    cin >> x >> s;

    if(s == "BTC")
      btc += x;
    else
    {
      yen += x;
    }
  }

  double sum = yen + btc * 380000.0;

  cout << sum << endl;
  return 0;
}
// funcの実体
// ------------------------------------------------
int CalcSumOfDigit(int n)
{
  int s = 0;
  while(n)
  {
    s += n % 10;
    n = n / 10;
  }
  return s;
}

string upper(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(97 <= *itr && *itr <= 122)
    {
      *itr = *itr - 32;
    }
  }
  return str;
}

string lower(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(65 <= *itr && *itr <= 90)
    {
      *itr = *itr + 32;
    }
  }
  return str;
}


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

A = list(map(int, input().split()))

n=0

for i in range(N):
    a=A[i]
    if a%2==0 and a%3!=0:
        if a%5!=0:
            n+=1

if n==0:
    print("APPROVED")
else:
    print("DENIED")

Measured memory_bytes: 3060
N, M, C  = map(int, input().split())
B = list(map(int, input().split()))
ans = 0
for _ in range(N):
    A = list(map(int, input().split()))
    sumab = 0
    for i in range(M):
        sumab += A[i] * B[i]
        if i == M - 1:
            if  sumab  + C > 0:
                ans += 1
print(ans)


Measured memory_bytes: 3060
X=int(input())
if 400 <= X and X <=599:
    print(8)
elif 600 <= X and X <=799:
    print(7)
elif 800 <= X and X <=999:
    print(6)
elif 1000 <= X and X <=1199:
    print(5)
elif 1200 <= X and X <=1399:
    print(4)
elif 1400 <= X and X <=1599:
    print(3)
elif 1600 <= X and X <=1799:
    print(2)
else:
    print(1)

Measured memory_bytes: 9184
#include <bits/stdc++.h>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> void pr_vec(vector<T> &v, char ep=' '){int n=v.size();REP(ni,n){cout<<v[ni];if(ni!=n-1)cout<<ep;}cout<<endl;};
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

int main(void)
{
    ll N;
    cin >> N;
    vector<int> a;
    REP(i, 15){
        a.pb((N-1)%26);
        N /= 26;
        // if((ll)pow(26, i)==)
        if(a.back()==25) N--;
        if(N==0) break;
    }
    reverse(ALL(a));
    for(auto&& ai : a){
        printf("%c", 'a'+ai);
    }
    printf("\n");
}

Measured memory_bytes: 3616
#line 1 "abc159_a.cpp"
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define coutd(n) cout << fixed << setprecision(n)
#define ll long long int
#define vl vector<ll>
#define vi vector<int>
using P = std::pair<int, int>;
const int INF = 2147483647;
const ll MOD = 1000000007;

using namespace std;

int main() {
  int n, m;
  cin >> n >> m;
  cout << n * (n - 1) / 2 + m * (m - 1) / 2 << endl;
}


Measured memory_bytes: 256
#include<set>
#include<map>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<math.h>
#include<time.h>
#include<vector>
#include<bitset>
#include<memory>
#include<utility>
#include<fstream>
#include<stdio.h>
#include<sstream>
#include<iostream>
#include<stdlib.h>
#include<string.h>
#include<algorithm>
using namespace std;
int main()
{
    #ifdef absi2011
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    string a;
    cin>>a;
    if (a.length()==26)
    {
        int i;
        for (i=25;i>=0;i--)
        {
            for (;;)
            {
                a[i]++;
                if (a[i]>'z') break;
                int j;
                for (j=0;j<i;j++)
                {
                    if (a[i]==a[j]) break;
                }
                if (i==j) break;
            }
            if (a[i]<='z') break;
        }
        if (i==-1)
        {
            puts("-1");
            return 0;
        }
        cout<<a.substr(0,i+1);
    }
    else
    {
        cout<<a;
        int i;
        for (i='a';i<='z';i++)
        {
            int j;
            for (j=0;j<(int)a.length();j++)
            {
                if (a[j]==i) break;
            }
            if (j==(int)a.length())
            {
                cout<<(char)i<<endl;
                return 0;
            }
        }
    }
    return 0;
} 


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

int main() {
	int n;
	cin >> n;
	int ans;
	for(int i = 1;; i *= 2){
		if(i > n){
			break;
		}
		ans = i;
	}
	
	cout << ans << endl;
}

Measured memory_bytes: 3644
#include <iostream>
#include <vector>
#include <algorithm>

bool check(std::vector<char> seq, int offset, std::string s){
    for(unsigned int i = 0; i < s.size(); i++){
        if(seq.at(i+offset) != s.at(i)) return false;
    }
    return true;
}

int main(int argc, char **argv)
{
    std::string S, T("");
    std::cin >> S;

    std::vector<char> SEQ(S.begin(), S.end());
    std::reverse(SEQ.begin(), SEQ.end());
    std::string A = "maerd";
    std::string B = "remaerd";
    std::string C = "esare";
    std::string D = "resare";

    unsigned int offset = 0;
    while(offset < SEQ.size()-1){
        if(offset + B.size() <= SEQ.size() && check(SEQ, offset, B)){
            offset += B.size();
        }else if(offset + A.size() <= SEQ.size() && check(SEQ, offset, A)){
            offset += A.size();
        }else if(offset + D.size() <= SEQ.size() && check(SEQ, offset, D)){
            offset += D.size();
        }else if(offset + C.size() <= SEQ.size() && check(SEQ, offset, C)){
            offset += C.size();
        }else{
            std::cout << "NO" << std::endl;
            return 0;
        }
        if(offset == SEQ.size()){
            std::cout << "YES" << std::endl;
            return 0;
        }
    }
    std::cout << "NO" << std::endl;
    

}


Measured memory_bytes: 512
n, m= map(int, input().split())
high = list(map(int, input().split()))
ans = [0]*n
 
for i in range(m):
    a,b = map(int, input().split())
    if high[a-1] > high[b-1]:
        if ans[a-1] == 0:
            ans[a-1] = 1
        ans[b-1] = -1
    elif high[a-1] < high[b-1]:
        if ans[b-1] == 0:
            ans[b-1] = 1
        ans[a-1] = -1
    else:
        ans[b-1] = -1
        ans[a-1] = -1
print(ans.count(0) + ans.count(1))

Measured memory_bytes: 20052
x1, y1, x2, y2 = gets.chomp.split.map(&:to_i)
x3, y3 = [(y1 - y2) + x2, (x1 - x2) * (-1) + y2]
x4, y4 = [(y2 - y1) * (-1) + x1, (x2 - x1) + y1]
puts "#{x3} #{y3} #{x4} #{y4}"


Measured memory_bytes: 14348
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;

public class Main {

    public static String solution(String n){
        for (int i = 1; i < 4; i++){
            if (n.charAt(i) == n.charAt(i-1)) return "Bad";
        }
        return "Good";
    }

    public static void main(String[] args){
        Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        String n = in.next();
        System.out.println(solution(n));

    }
}

Measured memory_bytes: 21972
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <algorithm>
#include <iterator>
#include <utility>
#include <iomanip>
#include <cmath>
#include <climits>
#include <cassert>
#include <stdio.h>
#include <string.h>

using namespace std;

void solve() {
  long long k, a, b;
  cin >> k >> a >> b;
  
  long long ret = 0;
  if ((b - a <= 2) || a > k) {
    ret = k+1;
  } else {
    ret = a + ((k - a+1) /2) * (b-a) + ((k - a+1)%2);
  }

  std::cout << ret << std::endl;
}

int main(int argc, char *argv[])
{
  solve();
  return 0;
}


Measured memory_bytes: 256