akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
char a[100005];
int main()
{
	char ori='@';
    int total=0,n;
    cin>>n;
	for (int i=1;i<=n;i++)
	{
		cin>>a[i];
		if (a[i]!=ori)
		{
			total++;
			ori=a[i];
		}
	}
	cout<<total<<endl;
	return 0;
}

Measured memory_bytes: 384
fun main(args: Array<String>) {
    abc049b()
}

fun abc049b() {
    val (h, w) = readLine()!!.split(" ").map { it.toInt() }
    val cList = (1..h).map { readLine()!! }

    val answer = cList.map { c -> (1..2).map { c } }.flatten().joinToString(System.lineSeparator())

    println(answer)
}


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

int main(){
    int rank[2]={};
    scanf("%d %d", &rank[0], &rank[1]);
    int code = rank[0];
    int device = rank[1];
    int award = 0;

    if(code==1 && device == 1){
        award = 1000000;
    }else{
        if(code == 1){
            award += 300000;
        }else if(code == 2){
            award += 200000;
        }else if(code == 3){
            award += 100000;
        }

        if(device == 1){
            award += 300000;
        }else if(device == 2){
            award += 200000;
        }else if(device == 3){
            award += 100000;
        }
    }
    printf("%d\n",award);
    
    return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using pi = pair<int, int>;
const ll INF = 1LL << 60;

int main() {
	ll x, y;
	cin >> x >> y;
	if (x == y) {
		cout << -1 << endl;
		return 0;
	}
	REP(i, 100000) {
		if ((x * i) % y != 0) {
			cout << x*i << endl;
			return 0;
		}
	}
	cout << -1 << endl;
	return 0;
}



Measured memory_bytes: 3568
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxx = 2e5 + 7;
const int Inf = 1 << 30;
const ll INF = 1ll << 60;
int n, m;

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
                     
#define int             long long
#define ld              long double
#define mp              make_pair
#define ff              first
#define ss              second
#define pb              push_back
#define fo(i,n)         for(i=0;i<n;i++)
#define fo1(i,n)        for(i=1;i<=n;i++)
#define FO(i,k,n)       for(i=k;k<=n?i<=n:i>=n;k<=n?i++:i--)
#define all(c)          c.begin(),c.end()
#define rall(c)         c.rbegin(),c.rend()
#define si              set<int>
#define vi              vector<int>
#define mii             map<int,int>
#define pii             pair<int,int>
#define vpii            vector<pii>
#define vvi             vector<vi>
#define usi             unordered_set<int>
#define umii            unordered_map<int,int>
#define pqmx            priority_queue<int>
#define pqmn            priority_queue<int,vi,greater<int> >
#define sp(x)           cout<<setprecision(x)<<fixed;
#define setbits(x)      __builtin_popcountll(x)
#define zerobits(x)     __builtin_ctzll(x)
#define in(a,n)         vi a(n);fo(i,n)cin>>a[i];
#define in1(a,n)        vi a(n+1);fo1(i,n)cin>>a[i];
#define w(t)            int t;cin>>t;while(t--)
#define gcd             __gcd
#define lcm(x,y)        x*(y/gcd(x,y))
#define endl            '\n'
#define PI              3.14159265358979323846
#define inf             1e18
#define mod             1000000007
void __p(int x) {cout<<x;}
void __p(int32_t x){cout<<x;}
void __p(float x){cout<<x;}
void __p(double x){cout<<x;}
void __p(ld x) {cout<<x;}
void __p(char x){cout <<'\''<<x<<'\'';}
void __p(const char *x){cout <<'\"' <<x<<'\"';}
void __p(const string &x) {cout<<'\"'<<x<<'\"';}
void __p(bool x) {cout<<(x?"true":"false");}
void _p() {cout << "]\n";}
template<typename T,typename V>     void __p(const pair<T,V> &x) {cout<<'{';__p(x.first);cout<<',';__p(x.second);cout<<'}';}
template<typename T>                void __p(const T &x) {int f = 0; cout << '{'; for (auto &i: x) cout << (f++ ? "," : ""), __p(i); cout << "}";}
template <typename T,typename... V> void _p(T t, V... v) {__p(t);if(sizeof...(v))cout<<", ";_p(v...);}
int po(int x,int p,int m = inf) {int ans=1;x%=m;while(p>0){if(p&1)ans=(ans*x)%m;p=p>>1;x=(x*x)%m;}return ans;}
int inv(int x,int m=mod){return po(x,m-2,m)%m;}
#ifndef ONLINE_JUDGE
#define dbg(x...) cout<<"["<<#x<<"]=[";_p(x)
#else 
#define dbg(x...)
#endif
//=================================================================================




const int N=1e6+6;
int n,m,k,x,y,z,a,b,c,d,i,j,l,r;








void sol()
{   
    cin>>n>>m;
    
    
    
    
    cout<< n*m <<endl;
}





int32_t main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    //sp(10);
    // w(t)
    sol();
    return 0;
}

Measured memory_bytes: 3640
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int n = sc.nextInt();
		int x = sc.nextInt();
		int[] m = new int[n];
		int min = Integer.MAX_VALUE;
		int sum = 0;
		for(int i = 0; i < n; i++){
		    m[i] = sc.nextInt();
		    sum += m[i];
		    min = min(min, m[i]);
		}

		// 計算
		int result = n;
		result += (x - sum)/min;
		
		// 出力
		System.out.println(result);
	}
}



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

using namespace std;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define INF (1e9)
#define MOD (1000 * 1000 * 1000 + 7)
#define maxn 200111

typedef long long ll;
typedef long double ld;

char str[maxn];
set<int> s[33];
pair<int, int> dp[maxn];
int from[maxn];

int main(){
	scanf("%s", str);
	int n = strlen(str);
	
	for(int i = 0; i < n; i++)
		s[str[i] - 'a'].insert(i);


	for(int i = n - 1; i >= 0; i--){
		dp[i] = mp(INF, INF);
		from[i] = INF;
		for(int j = 0; j < 26; j++){
			auto pos = s[j].lower_bound(i);
			pair<int, int> cur;
			cur.se = j;
			if(pos != s[j].end())
				cur.fi = dp[*pos + 1].fi + 1;
			else
				cur.fi = 0;

			if(cur < dp[i]){
				dp[i] = cur;
				from[i] = (pos != s[j].end() ? *pos + 1 : n);
			}
		}
	}	
	
	string ans;
	int x = 0;
	while(x != n){
		ans += dp[x].se + 'a';
		x = from[x];
	}

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

Measured memory_bytes: 13312
#define fi first
#define se second
#define mp make_pair
#define pb push_back

#define LOCAL 1

#include<bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#define dbg(...) cout<<#__VA_ARGS__ ": ["; for(auto e: __VA_ARGS__){cout<<e<<", ";} cout<<"]\n"
#define dbg1(...) cout<<#__VA_ARGS__ " "<< __VA_ARGS__ 
#else
#define dbg(...) 1;
#define dbg1(...) 1;
#endif

typedef long long ll;
typedef unsigned long long ull;
constexpr int R=5e6+69, INF=2e9+6969;

int qq;
ll n,k,sum,p,licz;

int main()
{
	scanf("%lld", &n);
	sum = 1;
	p = 1;
	while(sum<=n)
	{
		p*=26;
		sum += p;
		++licz;
	}
	sum -= p;
	n = n-sum;
	string ans = "";
	for(int i=0;i<licz;++i) ans=ans+"a";
	licz--;
	while(n>0)
	{
		ll r = n%26;
		ans[licz] = (char)(r+'a');
		n/=26;
		licz--;
	}
	cout << ans <<"\n";
	return 0;
}


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

import os
import sys
import itertools
import math
from collections import Counter, defaultdict

class Main(object):
    
    def __init__(self):
        pass

    def solve(self):
        '''
        insert your code
        '''
        while True:
            n, m, a = map(int, raw_input().split())
            if n == 0 and m == 0 and a == 0:
                break
            adj = []
            for i in range(m):
                h, p, q = map(int, raw_input().split())
                adj.append((h, p, q))
            adj.sort(reverse=True)
            # print adj
            for h, p, q in adj:
                if p == a:
                    a = q
                elif q == a:
                    a = p
            print a
        return None

if __name__ == '__main__':
    m = Main()
    m.solve()

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

#define M_PI       3.14159265358979323846

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }
inline int readInt() { int x; scanf("%d", &x); return x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;


//container util

//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a)*(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)


struct Edge {
    int to, from;
    ll cost;
    Edge(int from, int to, ll cost): from(from), to(to), cost(cost) {}
};

typedef vector<vector<Edge>> AdjList;
AdjList graph;

ll a[4010];
ll tet[2010];
ll tet2[2010];
int main() {
    //cin.tie(0);
    //ios::sync_with_stdio(false);
    //cout << fixed << setprecision(10);

    
    ll N, K; cin >> N >> K;

    REP(i, N) cin >> a[i];


    ll t=0, x=0;

    for(int i=0; i<N; ++i){
        for(int j=i+1; j<N; ++j){
            if(a[i] > a[j]) t++;
            if(a[i] < a[j]) x++;
        }
    }
    cout << (K*(K+1)/2%MOD*t%MOD + K*(K-1)/2%MOD*x%MOD)%MOD << endl;
    return 0;

}

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

using namespace std;

const int N = 3010; 
bool wat[N], sug[N];
void solve() {
    int a,b,c,d,e,f;
    cin >> a >> b >> c >> d >> e >> f;
    a*=100; b*=100;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N && j*a<=i; j++) {
            if ((i-j*a)%b == 0) wat[i] = true;
        }
    }
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N && j*c<=i; j++) {
            if ((i-j*c)%d == 0) sug[i] = true;
        }
    }
    int x=0,y=1;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            if (i+j > f) break;
            if (!sug[i] || !wat[j]) continue;
            if (i*100 > e*j) continue;
            if (i*y >= x*j) {
                x = i;
                y = j;
            }
        }
    }
    cout << (x+y) << ' ' << x;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    cout << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <cstring>
#include <climits>
#include <string.h>
#include <stdio.h>
#define LL long long
#define all(x) (x).begin(),(x).end()
#define pii pair<int,int>
#define piii pair<int, pii >
#define REP(i,n) for (int (i)=0;(i)<(n);(i)++)
#define vi vector<int>
#define vpi vector< pii >
#define INF 2147483647
#define big 19260817
#define pb push_back
#define mp make_pair
using namespace std;
const int Maxk=1005;
string mul(string a,string b){
	int res[Maxk];
	memset(res,0,sizeof(res));
	reverse(a.begin(),a.end());
	reverse(b.begin(),b.end());
	for (int i=0;i<a.length();i++){
		for (int j=0;j<b.length();j++){
			res[i+j]+=(a[i]-'0')*(b[j]-'0');
		}
	}
	for (int i=0;i<Maxk;i++){
		if (res[i]>=10) {
			res[i+1]+=(res[i]/10);
			res[i]%=10;
		}
	}
	string ret;
	bool flag=false;
	for (int i=Maxk-1;i>=0;i--){
		if (flag || res[i]){
			flag=true;
			ret=ret+(char)(res[i]+'0');
		}
	}
	if (ret=="") ret="0";
	return ret;
}
string add(string a,string b){
	if (a.length()<b.length()) swap(a,b);
	while (a.length()!=b.length()){
		b='0'+b;
	}
	for (int i=a.length()-1;i>=0;i--){
		a[i]+=(b[i]-'0');
		if (a[i]>'9' && i){
			a[i]-=10;
			a[i-1]++;
		}
	}
	if (a[0]>'9'){
		a[0]-=10;
		a='1'+a;
	}
	return a;
}
// cf IO: I64d
// atcoder IO: ｌｌｄ
int main(){
	int x;
	scanf("%d",&x);
	for (int i=1;;i++){
		if (i*(i+1)/2>=x){
			printf("%d\n",i);
			return 0;
		}
	}
	return 0;
}


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

signed main(){
    int x;cin>>x;
    int k=x/100;
    int s=x%100;
    if(s<=k*5)cout<<1<<endl;
    else cout<<0<<endl;
}


Measured memory_bytes: 256
N,K = map(int,input().split())

def count(i,K):
    sum = 0
    cnt = 0
    while sum < K:
        if cnt == 0:
            sum = i*2
            cnt += 1
        else:
            sum = sum*2
            cnt += 1
    return cnt

if N >= K:
    prob = (N-K+1)/N
else:
    prob = 0

for i in range(1,N+1):
    if i <= K-1:
        prob += (1/N)*((1/2)**count(i,K))
    else:
        break

print(prob)

Measured memory_bytes: 3064
import os, sys, re, math

N = int(input())
honest = []
liar = []

for i in range(N):
    a = int(input())
    h = []
    l = []
    for j in range(a):
        (x, y) = [int(n) for n in input().split()]
        if y == 1:
            h.append(x)
        else:
            l.append(x)
    honest.append(h)
    liar.append(l)

for i in range(2 ** N - 1, -1, -1):
    b = ('{:0%db}' % N).format(i)
    truth = True
    for j in range(N):
        if b[j] == '1':
            for h in honest[j]:
                if b[h - 1] != '1':
                    truth = False
                    break
            if not truth:
                break
            for l in liar[j]:
                if b[l - 1] != '0':
                    truth = False
                    break
        if not truth:
            break
    if truth:
        break

if truth:
    print(len(b.replace('0', '')))


Measured memory_bytes: 9860
#include <bits/stdc++.h>
 
#define rep(i,n) for(ll i=0;i<n;++i)
#define ALL(a) (a).begin(),(a).end()
 
using namespace std;
using ll  = long long;
using pll = pair<ll, ll>;
 
const ll MOD  = 1e9+7;
const ll LINF = 1LL << 60;
const int INF = 1e9 + 7;

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

    int a[n];
    rep(i, n)cin >> a[i];

    int q;
    cin >> q;

    int m[q];
    rep(i, q)cin >> m[i];


    set<ll> scores;
    rep(i, (2<<n)){
        ll scr = 0;
        rep(j, n)if(i&(1<<j))scr+=a[j];
        scores.insert(scr);
    }
    
    rep(i, q){
        if(scores.count(m[i]))cout << "yes\n";
        else cout << "no\n";
    }
}



Measured memory_bytes: 3128
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define Clear(a) a = decltype(a)();
typedef long long ll;
typedef pair<int,int> p;
ll max(ll x,ll y){
if(x>y)return x;
else return y;
}
ll min(ll x,ll y){
if(x<y)return x;
else return y;
}
const ll big=998244353;
const ll bbig=1000000007;
ll exp(ll x,ll y){
    if(y==0)return 1;//0^0=1
    if(x==1||x==0)return x;
    if(y%2==1)return (exp(x,y-1)*x)%bbig;
    ll t=exp(x,y/2);
    return (t*t)%bbig;
}
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
ll in(ll x){
    return exp(x,bbig-2);
}
/*ll com(ll x,ll y){
    ll ans=1;
    rep(i,y){ans*=x-i;ans%=bbig;}
    rep(i,y){ans*=in(i+1);ans%=bbig;}
    return ans;
}*/

int main(){
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    cout << fixed << setprecision(0);
    /*--------------------------------*/
    
    string s;cin >> s;
    string t;cin >> t;
    int cnt=0;
    rep(i,s.size()){
        if(s[i]!=t[i])cnt++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 3892
def resolve():
    BTC = 380000.0
    N = int(input())
    sumA = 0
    for _ in range(N):
        x, u = input().split()
        if u == "JPY":
            sumA += int(x)
        else:
            sumA += float(x) * BTC
    print(sumA)


resolve()


Measured memory_bytes: 2940
#include <iostream>

using namespace std;
using ll = long long;

ll mod = 1000000007;

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

  ll a = 1;
  for (ll i = 0; i < n; ++i)
    a = a * 10 % mod;

  ll b = 1;
  for (ll i = 0; i < n; ++i)
    b = b * 9 % mod;


  ll c = 1;
  for (ll i = 0; i < n; ++i)
    c = c * 8 % mod;

  ll d = a;
  d = (d - b) % mod;
  if (d < 0)
    d += mod;
  d = (d - b) % mod;
  if (d < 0)
    d += mod;
  d = (d + c) % mod;

  cout << d << endl;
}


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

#define rep(i,n) for(ll i=0;i<n;i++)
#define REP(i,a,n) for(ll i=a;i<n;i++)

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> tiii;
typedef pair<ll, ll> pll;

const int INF = 100000000;
const ll LINF = 1e18+5;

const ll M = 1000000007; // modの値

vector<ll> fac(10000000); // n! mod M
vector<ll> ifac(10000000); // k^{M-2} mod M

ll mpow(ll x, ll n){ // x^n(modM)
    ll ans = 1;
    while (n!=0) {
        if(n&1) ans = ans*x % M;
        x = x*x % M;
        n= n>>1;
    }
    return ans;
}

ll comb(ll a, ll b) { // aCb mod M
    if (a==0 && b==0) return 1;
    if (a<b || a<0) return 0;
    ll tmp = ifac[a-b] * ifac[b] % M;
    return tmp * fac[a] % M;
}

void init_comb() {
    fac[0] = 1;
    ifac[0] = 1;
    for (ll i=0;i<10000000;i++) {
        fac[i+1] = fac[i]*(i+1) % M; // n!(mod M)
        ifac[i+1] = ifac[i] * mpow(i+1, M-2) % M; // k^{M-2} mod M
    }
}

int main() {
    init_comb();
    ll N;
    vector<ll> C;
    cin >> N;
    rep(i,N){
        ll a;
        cin >> a;
        C.push_back(a);
    }
    sort(C.begin(), C.end(), greater<ll>());
    ll num[200000] = {};
    num[0] = 1;
    REP(i,1,N) {
        num[i] = num[i-1]*2 + mpow(2,i-1);
        num[i] = num[i] % M;
    }
    ll ans = 0;
    rep(i,N) {
        ll tmp = num[i] * mpow(2, N-1-i);
        tmp %= M;
        ans += tmp * C[i];
        ans %= M;
    }
    cout << (ans * mpow(2,N)) % M << endl;

    return 0;
}

Measured memory_bytes: 159728
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int MAXN=1e5+10;
int pre[MAXN],num[MAXN],ranks[MAXN];
int m,n;
void inint() {
	for(int i=1; i<=n; i++) {
		pre[i]=i;
		num[i]=1;
		ranks[i]=0;
	}
}
int Get(int x) {
	if(x==pre[x]) return x;
	else return pre[x]=Get(pre[x]);
}
bool same(int a,int b) {
	return Get(a)==Get(b);
}
void Init(int a,int b) {
	int x=Get(a);
	int y=Get(b);
	if(x==y) return ;
	if(ranks[x]<ranks[y]) {
		pre[x]=y;
		num[y]+=num[x];
	} else {
		pre[y]=x;
		num[x]+=num[y];
		if(ranks[x]==ranks[y]) ranks[x]++;
	}
	return ;
}
int a[MAXN];
int b[MAXN];
int ans[MAXN];
signed main() {
	ios_base::sync_with_stdio(false);
	cin>>n>>m;
	inint();
	for(int i=0; i<m; i++) cin>>a[i]>>b[i];
	ans[m-1]=(long long)n*(n-1)/2;
	for(int i=m-1; i>=1; i--) {
		ans[i-1]=ans[i];
		if(!same(a[i],b[i])) {
			ans[i-1]-=num[Get(a[i])]*num[Get(b[i])];
			Init(a[i],b[i]);
		}
	}
	for(int i=0; i<m; i++) cout<<ans[i]<<endl;
	return 0;
}

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

#define rep(i,N) for(int i=0;i<N;i++)
#define rep2(i,N) for(int i=1;i<=N;i++)
using namespace std;
long long  INF=1e18;
long long mod=1e9+7;

vector<int>places[200010];
long long dp[200010];
void add(long long &a,long long b){
    a+=b;
    if(a>=mod)a-=mod;
    return;
}
//status unsolved

int main(){
    int n;
    cin>>n;
    int color[n];
    rep(i,n)cin>>color[i];
    
    rep(i,n)places[i].clear();
    
    //places[i]:=(c[j]=iとなるjの集まり)
    rep(i,n)places[color[i]].push_back(i);

    //もっとも左で区切る=何もしない時
    dp[0]=1;
    for(int i=1;i<=n;i++){

        //何もしない時
        add(dp[i],dp[i-1]);

        int col=color[i-1];
        //同じ色で現在地より左にあるものの番号を取得
        int it=lower_bound(places[col].begin(),places[col].end(),i-1)
        -places[col].begin();

        if(it>0){
            
            int j=places[col][it-1];
            //cout<<i<<" "<<j<<" ";
            //同じ色が並んでいたら何もしない
            //(現在見ている石:=i-1番目の石)
            if(j>=i-2)continue;

            add(dp[i],dp[j+1]);
        }
        //cout<<dp[i]<<" "<<endl;;
    }
    //cout<<endl;
    cout<<dp[n]<<endl;

    return 0;

}
/*


*/


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

int main()
{
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)cin>>a[i];
    sort(a,a+n);
    int sum=0;
    for(int i=0;i<n-1;i++)sum+=a[i];
    cout<<sum+(a[n-1]/2)<<endl;
}



Measured memory_bytes: 256
s = list(str(input()))
l = len(s)
ans = 0
for i in range(l-1):
    if s[i] == s[i+1]:
        if s[i] == '0':
            s[i+1] = '1'
            ans += 1
        else:
            s[i+1] = '0'
            ans += 1
    else:
        continue

print(ans)

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

using namespace std;

int main(){
    while(1){
        int n,m;
        cin >> n >> m;
        if(n==0 && m==0){
            break;
        }

        int a[1000];
        for(int i=0; i<n; i++){
            cin >> a[i];
        }

        int ans=-1;

        for(int i=0; i<n; i++){
            for(int j=i+1; j<n; j++){
                if(a[i]+a[j]<=m){
                  ans = max(ans,a[i]+a[j]);
                }
            }
        }
        if(ans==-1){
            cout<<"NONE"<<endl;
        }else{
            cout<<ans<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3076
import java.util.*;
 
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] a = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 
        2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
        
        System.out.println(a[N-1]);
    }
}

Measured memory_bytes: 35656
#include <iostream>
#include<string>
#include<cmath>
#include<ciso646>
#include<cstring>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<utility>
#include<map>
#include<math.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
using ll = long long;
int Max = 10000000;
int main()
{
	int n; cin >> n;
	
	vector<int> seki(81);
	int cnt = 0;
	for(int i=1;i<=9;i++) {
		for (int j = 1;j <= 9;j++) {
			seki[cnt] = i * j;
			cnt++;
		}
	}
	rep(i, 81) {
		if (seki[i] == n) {
			cout << "Yes";
			return 0;
		}
	}
	cout << "No";
}


Measured memory_bytes: 3548
# coding: utf-8
N = int(input())
a = list(map(int, input().split()))
ans = 0
tmp = 0
for i in range(N-1):
    if a[i] != a[i+1]:
        ans += (tmp + 1) // 2
        tmp = 0
    else:
        tmp += 1
ans += (tmp + 1) // 2
print(ans)

Measured memory_bytes: 3064
#include <cstdio>
#include <cstring>
#include <iostream>

int now, ans, sum[1 << 26], tot;

int main()
{
	char ch = getchar();
	memset(sum, 0x3f, sizeof sum);
	sum[0] = 0;
	while (ch >= 'a' && ch <= 'z')
	{
		now ^= 1 << (ch - 97);
		ans = sum[now];
		for (int i = 0; i < 26; ++i)
			ans = std::min(ans, sum[now ^ (1 << i)]);
		++ans;
		sum[now] = std::min(sum[now], ans);
		ch = getchar();
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 262528
import sys
input = sys.stdin.readline

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n
    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x
    def size(self, x):
        return -self.parents[self.find(x)]
    def same(self, x, y):
        return self.find(x) == self.find(y)

N = int(input())
town = [list(map(int,input().split()))+[i] for i in range(N)]

townx = sorted(town)
towny = sorted(town,key = lambda t : t[1])

road = []

for i in range(N-1):
    road.append([abs(townx[i][0]-townx[i+1][0]),townx[i][2],townx[i+1][2]])
    road.append([abs(towny[i][1]-towny[i+1][1]),towny[i][2],towny[i+1][2]])

road.sort()

uf = UnionFind(N)
ans = 0

for r in road:
    cost,t1,t2 = r
    if uf.same(t1,t2):
        continue
    uf.union(t1,t2)
    ans += cost
    
print(ans)

Measured memory_bytes: 127512
#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include<cstring>
#include<map>
#include<set>
#include<cstdlib>
#include<bitset> 
using namespace std;
typedef long long ll;
int main(void)
{
	string s,t;
	cin>>s>>t;
	for(ll i=0;i<s.size();i++)
	{
		if(s[i]!=t[i])
		{
			printf("No");
			return 0;
		}
	 } 
	 printf("Yes");
}

Measured memory_bytes: 3720
#include<iostream>
#include<string>
#include<vector>
#include <iostream>
#include <vector>
#include<cmath>
#include <algorithm>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;



int main() {
	int H, N;
	cin >> H >> N;
	vector<int> A(N), B(N);
	for (int i = 0; i < N; ++i) cin >> A[i] >> B[i];

	vector<vector<long long>> dp(N + 1, vector<long long>(H + 1, INF));
	dp[0][0] = 0;
	for (int i = 0; i < N; ++i) {
		for (int j = 0; j <= H; ++j) {
			chmin(dp[i + 1][j], dp[i][j]);
			chmin(dp[i + 1][min(j + A[i], H)], dp[i + 1][j] + B[i]);
		}
	}
	cout << dp[N][H] << endl;

}

Measured memory_bytes: 78592
// ref: https://qiita.com/tubo28/items/e6076e9040da57368845
use std::io::{stdin, Read};
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n: i32 = read();
    let t: Vec<i32> = (0..n).map(|_| read()).collect();
    let sum: i32 = t.iter().sum();

    let m: i32 = read();
    for _ in 0..m {
        let p: usize = read::<usize>() - 1;
        let x: i32 = read();
        let ans = sum - t[p] + x;
        println!("{}", ans);
    }
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
int main(){
  string sa, sb, sc;
  cin >> sa >> sb >> sc;
  int idx_a=0, idx_b=0, idx_c=0, a=sa.size(), b=sb.size(), c=sc.size();
  char f = 'a';
  while (1) {
    if (f == 'a') {
      if (idx_a == a) {
        cout << 'A' << endl;
        break;
      }
      f = sa[idx_a];
      idx_a++;
    }
    else if (f == 'b') {
      if (idx_b == b) {
        cout << 'B' << endl;
        break;
      }
      f = sb[idx_b];
      idx_b++;
    }
    else if (f == 'c') {
      if (idx_c == c) {
        cout << 'C' << endl;
        break;
      }
      f = sc[idx_c];
      idx_c++;
    }
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#include <fstream>
#include <chrono>
#include <random>
#include <bitset>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(x) ((int)(x).size())
#define pb push_back
#define mod 1000000007
using ll = long long;
using namespace std;
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 main(){
  int K,X; cin >> K >> X;
  if(500*K>=X) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main(){
	long long a,b,k;
	cin>>a>>b>>k;
	a-=k;
	if(a<0){
		b-=(-a);a=0;
	}
	if(b<0)b=0;
	cout<<a<<" "<<b<<endl;
	return 0;
} 

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <queue>

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

using namespace std;

string s;
string d[7] = { "SUN","MON","TUE","WED","THU","FRI","SAT" };
int ans = 0;
int main() {
	cin >> s;
	for (int i = 0; i < 7; i++) {
		if (s == d[i]) ans = 7 - i;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(void){
    // Your code here!
    string s;
    cin >> s;
    
    int a = s.size() - 1;
    int b = s.at(a);
    
    if( b == 's'){
        cout << s << "es" << endl;
    }
    else{
        cout << s << 's' << endl;
    }
}

Measured memory_bytes: 3108
//#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
 
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define endl '\n'
#define ll long long int
#define ld long double
#define vec vector
#define forn(a) for(ll a=0; a<n; a++)
#define all(x) x.begin(), x.end()
#define deb(x) cerr<<#x<<" = "<<x<<endl
 
using namespace std;
 
int main() {
    IOS;    

    ll n; cin>>n;
    cout<< ((n-1LL)*n)/2LL <<endl;

    return 0;
}

Measured memory_bytes: 256
a=input().split()
a=[int(x) for x in a]
W=a[0]
H=a[1]
x=a[2]
y=a[3]
r=a[4]
if x - r >= 0 and x + r <= W and y - r >= 0 and y + r <= H:
  print('Yes')
else:
  print('No')

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

const int INF = 1e9;
const int mod = 1e9+7;
const double EPS = 1e-10;
const double PI = acos(-1.0);

int main()
{
    ll n,k;
    cin >> n >> k;
    vector<ll> a(n);
    for(int i = 0; i < n; i++) cin >> a[i];
    ll ans = 0;
    for(int i = 50; i >= -1; i--){
        ll zzz = (1LL<<i);
        if(i == -1 || k&zzz){
            ll sub = 0;
            for(int j = 50; j >= 0; j--){
                ll cnt = 0;
                ll mask = (1LL<<j);
                for(int l = 0; l < n; l++){
                    if(mask&a[l]) cnt++;
                }
                if(zzz < mask){
                    if(k&mask) sub += mask*(n-cnt);
                    else sub += mask*cnt;
                }
                if(zzz == mask) sub += cnt*mask;
                if(zzz > mask) sub += max(cnt,n-cnt)*mask;
            }
            ans = max(ans,sub);
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define me(a,x) memset(a,x,sizeof(a))
#define sc scanf
#define itn int
using namespace std;
const int N=1e6;
const long long mod=1e9+7;
const int oo=0x7fffffff;
const int sup=0x80000000;
typedef long long ll;
typedef unsigned long long ull;
template <typename it>void db(it *begin,it *end){while(begin!=end)cout<<(*begin++)<<" ";puts("");}
template <typename it>
string to_str(it n){string s="";while(n)s+=n%10+'0',n/=10;reverse(s.begin(),s.end());return s;}
template <typename it>int o(it a){cout<<a<<endl;return 0;}
ll mul(ll a,ll b,ll c){ll ans=0;for(;b;b>>=1,a=(a+a)%c)if(b&1)ans=(ans+a)%c;return ans;}
ll ksm(ll a,ll b,ll c){ll ans=1;for(;b;b>>=1,a=mul(a,a,c))if(b&1)ans=mul(ans,a,c);return ans;}
int main(){
	int n;
	int p[50];
	cin>>n;
	for(int i=1;i<=n;i++)cin>>p[i];
	int ans=0;
	for(int i=2;i<=n-1;i++){
		int ma=max(p[i-1],p[i+1]);
		int mi=min(p[i-1],p[i+1]);
		if(p[i]>mi&&p[i]<ma)ans++;
	}
	o(ans);
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <cmath>
#include <utility>
using namespace std;
#define fol(i,n) for (int i=0;i<n;i++)

int main(){
    int a,b,c,d;
    cin >>a>>b>>c>>d;
    if (a<b)cout << c*a<<endl;
    else cout << c*b+(a-b)*d<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <vector>
#include <tuple>
using namespace std;

#include <sys/mman.h>
static char *_in_buf = 
(char*)mmap(NULL, 1 << 26, PROT_READ, MAP_PRIVATE, fileno(stdin), 0);
inline int read() {
  int p = 0, v = 0;
  while (*_in_buf < 48) (*_in_buf ++ == 45) && (v = 1);
  while (*_in_buf > 47 && *_in_buf < 58) p = p * 10 + *_in_buf ++ - 48;
  return v ? -p : p;
}

static char out_buf[100000];
static char *outf = out_buf;
inline void flush() {
  if (outf != out_buf)
    fwrite(out_buf, outf - out_buf, 1, stdout), outf = out_buf;
}
inline void Putchar(char x) {
  *outf ++ = x;
  (outf == out_buf + 100000) && (flush(), 0);
}

int n, q, ans[100005], dis[100005];
vector <tuple <int, int, int> > g[100005];

int par[100005], sz[100005];
int son[100005], dep[100005];
int ind[100005], top[100005], indx;
void dfs1(int u, int parent, int depth) {
  dep[u] = depth, par[u] = parent, sz[u] = 1;
  for (int i = 0; i < (int)g[u].size(); ++ i) {
    int v = get <0> (g[u][i]);
    if (v == parent) continue;
    dfs1(v, u, depth + 1), sz[u] += sz[v];
    if (sz[v] > sz[son[u]]) son[u] = v;
  }
}
void dfs2(int u, int topv) {
  top[u] = topv, ind[u] = ++ indx;
  if (son[u]) dfs2(son[u], topv);
  for (int i = 0; i < (int)g[u].size(); ++ i) {
    int v = get <0> (g[u][i]);
    if (v == par[u] || v == son[u]) continue;
    dfs2(v, v);
  }
}
inline int get_lca(int u, int v) {
  while (top[u] != top[v]) {
    if (dep[top[u]] < dep[top[v]])
      swap(u, v);
    u = par[top[u]];
  }
  if (dep[u] < dep[v]) return u;
  return v;
}

int dist[100005];
void dfs3(int u, int parent) {
  for (int i = 0; i < (int)g[u].size(); ++ i) {
    int v = get <0>(g[u][i]), w = get <2>(g[u][i]);
    if (v == parent) continue;
    dist[v] = dist[u] + w, dfs3(v, u);
  }
}

vector <tuple <int, int, int> > qry[100005];
int d[100005], cnt[100005];
void dfs4(int u, int parent) {
  for (int i = 0; i < (int)g[u].size(); ++ i) {
    int v = get <0>(g[u][i]), c = get <1> (g[u][i]), w = get <2>(g[u][i]);
    if (v == parent) continue;
    d[c] += w, cnt[c] ++;
    dfs4(v, u);
    d[c] -= w, cnt[c] --;
  }
  for (int i = 0; i < (int)qry[u].size(); ++ i) {
    int id = get <0>(qry[u][i]), c = get <1>(qry[u][i]);
    int t = get <2>(qry[u][i]), nowd = dis[id];
    int x = d[c], y = nowd * cnt[c];
    ans[id] += (y - x) * t;
  }
}

int main() {
  n = read(), q = read();
  register int i, u, c, v, d;
  for (i = 1; i < n; ++ i) {
    u = read(), v = read();
    c = read(), d = read();
    g[u].emplace_back(v, c, d);
    g[v].emplace_back(u, c, d);
  }
  dfs1(1, 0, 1);
  dfs2(1, 1);
  dfs3(1, 0);
  for (i = 1; i <= q; ++ i) {
    c = read(); dis[i] = read();
    u = read(), v = read();
    int lca = get_lca(u, v);
    ans[i] = dist[u] + dist[v] - 2 * dist[lca];
    qry[u].emplace_back(i, c, 1);
    qry[v].emplace_back(i, c, 1);
    qry[lca].emplace_back(i, c, -2);
  }
  dfs4(1, 0);
  for (i = 1; i <= q; ++ i) {
    register char stk[20], top = 0;
    while (ans[i]) stk[top ++] = ans[i] % 10, ans[i] /= 10;
    while (top --) Putchar(stk[top] + 48);
    Putchar('\n');
  }
  flush();
}

Measured memory_bytes: 25400
#include "bits/stdc++.h"
#define ALL(x) x.begin(), x.end()
#define LEN(x) (int)x.size()
#define iostreamBooster() do{ cin.tie(nullptr); ios_base::sync_with_stdio(false); }while(0)
using namespace std;
typedef int64_t i64;
typedef pair<int,int> pii;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF = 0x3f3f3f3f;

signed main()
{
  int n, x, y;
  cin >> n >> x >> y;
  cout << min(x,y) << ' ' << max(0, x - (n-y)) << endl;

  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

const int N = 1e5 + 5;

int32_t main()
{
	IOS;
	int s, w;
	cin >> s >> w;
	if(w >= s)
		cout << "unsafe";
	else
		cout << "safe";
	return 0;
}

Measured memory_bytes: 3596
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      	int n = sc.nextInt();
      	int k = sc.nextInt();
      	int[] have = new int[n];
      	int a, d;
      	for(int i = 0; i < k; i++){
        	d = sc.nextInt();
          	for(int j = 0; j < d; j++){
            	a = sc.nextInt();
              	have[a-1]++;
            }
        }
      	int count = 0;
      	for(int i = 0; i < n; i++){
        	if(have[i] == 0) count++;
        }
      	System.out.println(count++);
    }
}

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

#define int long long

#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define FORR(i,m,n) for(int i=m;i>=n;i--)
#define pb(x) push_back(x) 
#define SORT(x) sort((x).begin(),(x).end())
#define INF 99999999999
 
using namespace std;

int32_t main(){
    int n;
    cin >> n;
    vector<int> a(n), b(n);
    REP(i, n){
        cin >> a[i] >> b[i];
    }

    int ans=0;
    for(int i=n-1; i>=0; i--){
        a[i]+=ans;
        if(a[i]%b[i]!=0) ans+=b[i]-(a[i]%b[i]);
    }

    cout << ans << endl;
}

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

int main(void){
int a, b; 
cin >> a >> b;
if(a>0 && b>0){
    cout << "Positive" << endl;    
}else if(a<=0 && b>=0){
    cout << "Zero" << endl;
}else if((b-a+1)%2==1){
    cout << "Negative" << endl;
}else{
    cout << "Positive" << endl;
}
}

Measured memory_bytes: 256
// clang-format

#include <bits/stdc++.h>
#define rep(i, n) for (lli i = 0; i < (n); i++)
#define rrep(i, n) for (lli i = (n)-1; i >= 0; i--)
using namespace std;

using lli = long long int;
void solve(long long N, long long K, long long S) {
  vector<lli> ans;
  lli unit = S < 1000000000 ? S + 1 : 1;
  rep(i, N) cout << (i < K ? S : unit) << " ";
  cout << endl;
}

int main() {
  long long N;
  scanf("%lld", &N);
  long long K;
  scanf("%lld", &K);
  long long S;
  scanf("%lld", &S);
  solve(N, K, S);
  return 0;
}


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

int main() {
  int q; cin >> q;
  deque<int> n;
  for (int i = 0; i < q; i++) {
    int query; cin >> query;
    if (query == 0) {
      int d, x; cin >> d >> x;
      if (d == 0) n.push_front(x);
      else n.push_back(x);
    }
    if (query == 1) {
      int p; cin >> p;
      cout << n[p] << endl;
    }
    if (query == 2) {
      int d; cin >> d;
      if (d == 0) n.pop_front();
      else n.pop_back();
    }
  }
}


Measured memory_bytes: 4532
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		Scanner s = new Scanner(System.in);

		int n = s.nextInt();
		String[] U = new String[n];
		for (int x = 0; x < n; x++) {
			U[x] = s.next();
		}

		int m = s.nextInt();
		String[] T = new String[m];
		for (int x = 0; x < m; x++) {
			T[x] = s.next();
		}

		int kagi=0;
		String user;

		for (int j = 0; j < m; j++) {
			user = T[j];
			for (int i = 0; i < n; i++) {
				if (user.equals(U[i])) {
					if (kagi == 0) {
						System.out.println("Opened by " + user);
						kagi = 1;
						user = "";
					} else {
						System.out.println("Closed by " + user);
						kagi = 0;
						user = "";
					}
					break;
				}
			}
			if (!(user.isEmpty()))
				System.out.println("Unknown " + user);
		}

		s.close();
	}
}

Measured memory_bytes: 21272
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<queue>
#include<stack>
#include<set>
#include<algorithm>
#include<utility>
#include<map>
using namespace std;
typedef long long ll;
const int mod = 1000000007;
const int INF = 1001001001;

ll pow_mod(ll p, ll n, ll m) {
	if (n == 0) return 1;
	else if (n == 1) return p % m;
	else if (n % 2 == 1) return p * pow_mod(p, n - 1, m) % m;
	else {
		ll tmp = pow_mod(p, n / 2, m);
		return (tmp * tmp) % m;
	}
}

ll gcd(ll x, ll y) {
	if (y == 0) {
		return x;
	}
	return gcd(y, x % y);
}

ll com_mod(ll n, ll k, ll m) {
	if (k == 0) return 1;
	else {
		ll x = 1;
		ll y = 1;
		for (ll i = 0; i < k; i++) {
			x = (x * (n - i)) % m;
			y = (y * (i + 1)) % m;
		}
		ll res = (x * pow_mod(y, m - 2, m)) % m;
		return res;
	}
}

int main() {
	int n, i; cin >> n >> i;
	cout << n - i + 1 << endl;
	return 0;
}

Measured memory_bytes: 3620
import math
l1 = input().split()
n = int(l1[0])
d = int(l1[1])

x = []
y = []
for i in range(n):
    lis = input().split()
    x.append(int(lis[0]))
    y.append(int(lis[1]))

count = 0
for i in range(n):
    dist = math.sqrt((x[i])**2 + (y[i])**2)
    if dist <= d:
        count += 1

print(count)

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

using namespace std;
typedef complex<double> P;
typedef vector<P> Polygon;

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

#define prev(G, i) ( G[(i-1 + G.size()) % G.size()] )
#define curr(G, i) ( G[i] )
#define next(G, i) ( G[(i+1) % G.size()] )

double cross(P const& a, P const& b) {
  return imag(conj(a)*b);
}

double area(Polygon const& G) {
  double A = 0;
  for (int i=0; i<(int)G.size(); i++) 
    A += cross(curr(G, i), next(G, i));
  return A/2.;
}

int main() {
  
  int N; cin >> N;
  Polygon G(N);
  rep(i, N) cin >> G[i].real() >> G[i].imag();
  printf("%.1f\n", area(G));
  
  return 0;
}

Measured memory_bytes: 1248
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>
#include<stack>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<string> vstring;
typedef vector<pint> vpint;
typedef stringstream SS;

struct Edge{int to,from,cost;};

#ifdef DEBUG
#define debug cout
#else
SS ss;
#define debug ss
#endif

template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

#define rep(i,n) for(int i=0;i<(n);++i)
#define repn(i,m,n) for(int i=(m);i<(n);++i)
#define repd(i,n) for(int i=(n)-1;i>=0;--i)
#define repnd(i,m,n) for(int i=(n)-1;i>=(m);--i)
#define rep0(i,n) for(i=0;i<(n);++i)
#define repn0(i,m,n) for(i=(m);i<(n);++i)
#define repd0(i,n) for(i=(n)-1;i>=0;--i)
#define repnd0(i,m,n) for(i=(n)-1;i>=(m);--i)
#define repc(i,n) for(int i=0;i<=(n);++i)
#define repcn(i,m,n) for(int i=(m);i<=(n);++i)
#define repcd(i,n) for(int i=(n);i>=0;--i)
#define repcnd(i,m,n) for(int i=(n);i>=(m);--i)
#define repc0(i,n) for(i=0;i<=(n);++i)
#define repcn0(i,m,n) for(i=(m);i<=(n);++i)
#define repcd0(i,n) for(i=(n);i>=0;--i)
#define repcnd0(i,m,n) for(i=(n);i>=(m);--i)
#define all(n) n.begin(),n.end()
#define sz(n) ((int)(n).size())
#define IL for(;;)
#define MP make_pair
#define PB push_back
#define X second
#define Y first
#define p_queue(n) priority_queue<n,vector<n>,greater<n> >
#define PUTLINE debug<<"LINE:"<<__LINE__<<endl;

const int INF = 2147483647/3;
const double EPS = 1e-10;
const double PI = acos(-1.0);


double d,px,py,dx,dy;

void output(double dd){
	if(dd<=d)printf("%.12lf\n",dd);
	else cout<<"impossible"<<endl;
}

int main() {
	IL{
		cin>>d;
		if(d==0)break;
		cin>>px>>py>>dx>>dy;
		if(dx==0){
			if(px!=0){
				cout<<"impossible"<<endl;
				continue;
			}else{
				if(dy==0){
					if(py!=0){
						cout<<"impossible"<<endl;
						continue;
					}else{
						cout<<0<<endl;
						continue;
					}
				}else{
					if(py/dy<=0)output(abs(py));
					else output(2-abs(py));
					continue;
				}
			}
		}
		if(dy==0){
			if(py!=0){
				cout<<"impossible"<<endl;
				continue;
			}
			if(px/dx<=0)output(abs(px));
			else output(2-abs(px));
			continue;
		}
		if(px/dx-EPS<=py/dy&&py/dy<=px/dx+EPS){
			if(px/dx<=0)output(sqrt(px*px+py*py));
			else output(2-sqrt(px*px+py*py));
		}else{
			cout<<"impossible"<<endl;
			continue;
		}
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <algorithm>
#include <utility> 
#include <unordered_set>
#include <vector>
#include <list> 
#include <string>
#include <iterator> 
#include <deque>
#include <array>
#include <forward_list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <climits>
#include <bitset>
#include <numeric>
using namespace std;


const long double PI = 3.14159265358979323846264338327950;
const int N = 1e5+5;

template <class T>
T gcd(T a, T b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}


int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	
	int n, x, y, m;
	cin >> n;
	vector<int> p(n), q(n);
	vector<int> arr(n);
	for (int i = 0; i < n; ++i)
		cin >> p[i];
	for (int i = 0; i < n; ++i) {
		cin >> q[i];
		arr[i] = i + 1;
	}
	
	x = y = -1;
	m = 1;
	do {
		if (x == -1 && arr == p) {
			x = m;
		}

		if (y == -1 && arr == q) {
			y = m;
		}

		if (x > 0 && y > 0)
			break;
		++m;
	} while (next_permutation(arr.begin(), arr.end()));

	cout << abs(x - y) << '\n';
}
		

Measured memory_bytes: 3628
#include <iostream>
#include <vector>

int main(){
	int n;
	int c;
	bool flag = true;

	std::cin >> n;
	
	std::vector<int> a(n);
	for(int i = 0; i < n; ++i){
		std::cin >> a.at(i);
	}

	for(int i = 0; flag; ++i){
		for(int &num : a){
			if(num % 2 == 0){
				num /= 2;
			}
			else{
				flag = false;
				break;
			}
		}
		c = i;
	}

	std::cout << c << std::endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define __ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pi acos(-1)
#define N 100005
#define mod 1000000007 
#define bitscount 32

using namespace std;

struct stuc{
int x;
int y;
};

bool cmpForStruct(stuc a, stuc b)
{
return a.x < b.x;
}

bool cmp(const pair <int,int> &a , const pair <int , int > &b)
{
return a.second<b.second;
}

int  main()
{

int n;

cin >> n;

vector < pair < int , int > > vp ;

for(int v,i=1;i<=n;i++)
{
cin >> v;
vp.emplace_back(i,v);
}

sort(vp.begin(),vp.end(),cmp);

for(int i=0;i<n;i++) cout << vp[i].first << ' ';

return 0;
}

Measured memory_bytes: 1780
#include<iostream>
#include<queue>

using namespace std;
typedef unsigned long long ll;

int main() {
    ll k;
    cin >> k;
    queue<ll> q;
    for (int i = 1; i < 10; i++)
    {
        q.push(i);
    }
    ll x;
    for (int i = 0; i < k; i++)
    {
        x = q.front();
        q.pop();
        if (x % 10 != 0)
        {
            q.push(10 * x + x % 10 - 1);
        }
        q.push(10 * x + x % 10);
        if (x % 10 != 9)
        {
            q.push(10 * x + x % 10 + 1);
        }
    }
    cout << x << endl;
    return 0;
}

Measured memory_bytes: 1792
n=int(input())
S = [list(map(int, input().split())) for i in range(n)]
A=[]
for i in range(n):
  if S[i][0]==0:
    A.append(S[i][1])
  elif S[i][0]==1:
    try:
      print(A[S[i][1]])
    except AttributeError:
      pass
  elif S[i][0]==2:
    try:
      A.pop()
    except AttributeError:
      pass


Measured memory_bytes: 35636