akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define range(i,a,n) for(int i=(a);i<(n);i++)

#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

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

template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S acm(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}

ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,q;
	string s;
	cin>>n>>q>>s;
	char tin,din;
	vector<char> t(q);
	vb d(q);
	int l=-1,r=n;
	rrep(i,q){
		cin>>tin>>din;
		d[i]=(din=='R');
		t[i]=tin;
	}
	rep(i,q){
		if(!(l+1<=r))continue;
		else if(d[i]){
			if(r>0&&r<=n&&s[r-1]==t[i])r--;
			if(l>=0&&l<n&&s[l]==t[i])l--;
		}
		else{
			if(l>=-1&&l<n-1&&s[l+1]==t[i])l++;
			if(r<n&&r>=0&&s[r]==t[i])r++;
		}
	}
	cout<<(r-l-1)<<endl;
}


Measured memory_bytes: 788
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10000000)
INF = 1<<32


def solve(N: int, K: int):
    ans = 0
    while N > 0:
        N = N//K
        ans += 1

    print(ans)
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    solve(N, K)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define ll long long
using namespace std;
struct node{
	node *pre,*nxt;
	char ch;
}head,tail;
unordered_set<node*> S[5][2];
int sum[110];
char Flag;
void chk(node *x,int tag){
	sum[x->ch-'A']+=tag;
	if(x==&head||x==&tail||x->ch=='A') return;
	if(x->pre->ch=='A'&&x->nxt->ch=='A'){
		if(tag>0) S[x->ch-'A'][0].insert(x);
		else S[x->ch-'A'][0].erase(x);
	}
	if(x->pre->ch!=x->nxt->ch){
		if(tag>0) S[x->ch-'A'][1].insert(x);
		else S[x->ch-'A'][1].erase(x);
	}
}
void insert(node*x,char ch){
	chk(x,-1);chk(x->pre,-1);
	node* p =new node;
	p->ch=ch;
	p->nxt=x;
	p->pre=x->pre;
	x->pre=p->pre->nxt=p;
	chk(p,1);chk(p->pre,1);chk(p->nxt,1);
}
void erase(node*x){
	chk(x,-1);chk(x->pre,-1);chk(x->nxt,-1);
	x->pre->nxt=x->nxt;
	x->nxt->pre=x->pre;
	chk(x->pre,1);chk(x->nxt,1);
	if(x->pre->ch==x->nxt->ch) erase(x->nxt);
}
void init(){
	string s,t;
	ios::sync_with_stdio(0);
	cin>>s;
	int sum[3]={};
	for(int i=0;i<s.length();i++)
		if(i==0||s[i]!=s[i-1]){
			t+=s[i];sum[s[i]-'A']++;
		}
	Flag='A';
	if(sum[1]<sum[2]&&sum[1]<sum[0]) Flag='B';
	else if(sum[2]<sum[0]) Flag='C';
	for(int i=0;i<t.length();i++)
		if(t[i]=='A') t[i]=Flag;
		else if(t[i]==Flag) t[i]='A';
	head.nxt=&tail;head.ch='D';
	tail.pre=&head;tail.ch='E';
	for(int i=0;i<t.length();i++)
		insert(&tail,t[i]);
}
int main(){
	init();
	while(1){
		int k1=1,k2=2;
		if(sum[k1]>sum[k2]) swap(k1,k2);
		if(sum[k1]<sum[k2]-S[k2][1].size()){
			int d=sum[k2]-S[k2][1].size()-sum[k1];
			vector<node*> v;
			for(auto&x:S[k2][0]){
				v.push_back(x);
				if(--d==0) break;
			}
			for(auto&x:v) erase(x);
		}
		else{
			int d=sum[k2]-sum[k1];
			vector<node*> v;
			if(d)
			for(auto&x:S[k2][1]){
				v.push_back(x);
				if(--d==0) break;
			}
			for(auto&x:v) erase(x);
		}
		if(sum[k1]==sum[k2]){
			break;
		}
	}
	int d=sum[1]-sum[0];
	char lst='D';
	for(node*p=head.nxt;p!=&tail;p=p->nxt){
		int flag=1;
		if(d&&(p->ch)+(p->nxt->ch)=='B'+'C')
			if(lst!='A'||p->nxt->nxt->ch!='A')
				flag=0,p=p->nxt,d--;
		if(flag){
			lst=p->ch;
			if(p->ch==Flag) putchar('A');
			else if(p->ch=='A') putchar(Flag);
			else putchar(p->ch);
		}
	}
	return 0;
}


Measured memory_bytes: 62396
#include <bits/stdc++.h>
using namespace std;
long long num[26] = {0},c = 0;
char pr[5] = {'A','C','H','M','R'};
int main()
{
    string s;
    int n;
    cin>>n;
    for(int i = 0;i < n;i ++)
    {
        cin>>s;
        num[s[0] - 'A'] ++;
    }
    for(int i = 0;i < 3;i ++)
    {
        for(int j = i + 1;j < 4;j ++)
        {
            for(int k = j + 1;k < 5;k ++)
            {
                c += num[pr[i] - 'A'] * num[pr[j] - 'A'] * num[pr[k] - 'A'];
            }
        }
    }
    cout<<c;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iterator>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
	int H, W;
	cin >> H >> W;

	vector<vector<char>> a(H, vector<char>(W));
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			cin >> a[i][j];
		}
	}

	for (int i = 0; i < H + 2; i++) {
		for (int j = 0; j < W + 2; j++) {
			if (i == 0 || i == H + 1 || j == 0 || j == W + 1) {
				cout << '#';
				if (j == W + 1) {
					cout << endl;
				}
			}
			else {
				cout << a[i - 1][j - 1];
			}
		}
	}

	return 0;
}

Measured memory_bytes: 256
#include<algorithm>
#include<algorithm>     //sort,二分探索,など
#include<bitset>        //固定長bit集合
#include<cmath>         //pow,logなど
#include<complex>       //複素数
#include<deque>         //両端アクセスのキュー
#include<functional>    //sortのgreater
#include<iomanip>       //setprecision(浮動小数点の出力の誤差)
#include<iostream>      //入出力
#include<iterator>      //集合演算(積集合,和集合,差集合など)
#include<map>           //map(辞書)
#include<numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include<queue>         //キュー
#include<set>           //集合
#include<stack>         //スタック
#include<string>        //文字列
#include<unordered_map> //イテレータあるけど順序保持しないmap
#include<unordered_set> //イテレータあるけど順序保持しないset
#include<utility>       //pair
#include<vector>        //可変長配列

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef vector<vector<ld>> vvld;
typedef vector<vector<string>> vvs;
typedef vector<vector<bool>> vvb;
const ll MOD = 1000000007;
const ll INF = 1000000000000000000;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,s,e) for(int i=s;i<e;i++)
#define reple(i,s,e) for(int i=s;i<=e;i++)
#define revrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int N;
int c[3];
ld dp[301][301][301];

ld rec(int x, int y, int z)
{
    if (x < 0) return 0;
    if (y < 0) return 0;
    if (z < 0) return 0;
    if (x + y + z == 0) return 0;

    if (dp[x][y][z] != -1) return dp[x][y][z];

    //4種類の遷移
    dp[x][y][z] = 0;
    dp[x][y][z] += rec(x - 1, y    , z    ) * (ld)x;
    dp[x][y][z] += rec(x + 1, y - 1, z    ) * (ld)y;
    dp[x][y][z] += rec(x    , y + 1, z - 1) * (ld)z;
    dp[x][y][z] += N;
    dp[x][y][z] *= 1.0 / (x + y + z);

    return dp[x][y][z];
}

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

    cin >> N;

    rep(i, N)
    {
        int a;
        cin >> a;
        c[--a]++;
    }

    rep(x, 301)
    {
        rep(y, 301)
        {
            rep(z, 301)
            {
                dp[x][y][z] = -1;
            }
        }
    }

    cout << setprecision(10) << setiosflags(ios::fixed);
    cout << rec(c[0], c[1], c[2]) << endl;

    return 0;
}

Measured memory_bytes: 426368
#define fast ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define all(x) begin(x),end(x)
#define msi map<string,int>
#define pii pair<int,int>
#include <bits/stdc++.h>
#define pll pair<ll,ll>
#define vll vector<ll>
#define vi vector<int>
#define ld long double
#define ll long long
#define sh short int
#define pb push_back
#define mid (l+r)/2
#define S second
#define F first
using namespace std;
const ll inf = 1e18;
const int mod = 1e9+7;
const int shift = 2e6;
string s;
ll dp[1000009][9];
ll bt(int id,int z){
    if(id == s.size()) return (!z?z:inf);
    ll &ret = dp[id][z];
    if(ret != -1) return ret;
    int num = s[id] - '0';
    ret = inf;
    if(z){
        ret = min(ret,bt(id+1,0)+10-num);
        ret = min(ret,bt(id+1,1)+9-num);
    }
    else{
        ret = min(ret,bt(id+1,0)+num);
        ret = min(ret,bt(id+1,1)+num+1);
    }
    return ret;
}
int main(){
    fast,cin>>s;
    memset(dp,-1,sizeof(dp));
    cout<<min(bt(0,0),bt(0,1)+1)<<endl;
}


Measured memory_bytes: 118684
A, B = map(int, input().split())

ansArray = []
i_str = ''
for i in range(B+1):
  i_str = str(i)
  i_str_zfilled = i_str.zfill(5)
  if i_str_zfilled[0] == i_str_zfilled[4] and i_str_zfilled[1] == i_str_zfilled[3]:
    ansArray.append(i)

count = 0
for ans in ansArray:
  if A <= ans <= B:
    count += 1

print(count)


Measured memory_bytes: 3188
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>

typedef long long ll;
typedef unsigned long long ull;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i = 0;(i) < ((int)(n));++(i))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define test(a) cout<<"line:"<<__LINE__<<"["<<(#a)<<": "<<(a)<<"]"<<endl

const int INF = 1e9+7;
const ll INFL = 9*1e18;

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

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

#define SUM(vec) accumulate(all(vec),0LL) // 配列の中身を全部足す
template<typename T>void print(T&& x){cout<<x<<endl;}// 改行付き出力
ll inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;} // 桁数
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);} // 最大公約数
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;} // 最小公倍数
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;} // 累乗
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; }
int ctoi(char c){return c-'0';}

// TODO: write
int main() {
  int n,m;cin>>n>>m;
  if(n <= m)print("unsafe");
  else print("safe");
  return 0; 
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

#define INF 2147483600
#define long long long

bool solve(){
  int n;
  cin>>n;
  int odd=0;
  int even=0;
  rep(i,n){
    int d;
    cin>>d;
    if(d%2==0) even++;
    else odd++;
  }
  if(n==1) return true;
  even += odd/2;
  odd %=2;
  if(odd==1) return even==0;
  if(odd==0) return even>0;
}

int main(){
  if(solve()) cout<<"YES"<<endl;
  else cout<<"NO"<<endl;

  return 0;
}


Measured memory_bytes: 384
INF = 10 ** 9
import sys
sys.setrecursionlimit(100000000)
dy = (-1,0,1,0)
dx = (0,1,0,-1)
from  collections import deque

def main():
    n,m = map(int,input().split())
    a  = list(map(int,input().split()))
    x  =sum(a)
    if x > n:
        print(-1)
    else:
        print(n - x)
if __name__ == '__main__':
    main()

Measured memory_bytes: 9980
## abc070d: Transit Tree Path

from collections import deque

n = int(input())

T = [{} for _ in range(n)]
for _ in range(n-1):
    v1,v2,d = map(int, input().split())
    T[v1-1][v2-1] = d
    T[v2-1][v1-1] = d

q,k = map(int, input().split())

visit = [False]*n
depth = [0]*n
que = deque([[-1,k-1,0]])
while que:
    p,c,d = que.popleft()
    if visit[c]: continue
    visit[c] = True
    depth[c] = d
    if p>=0: depth[c] += depth[p]
    for cc in T[c].keys():
        if not visit[cc]: que.append([c,cc,T[c][cc]])

for _ in range(q):
    v1,v2 = map(int, input().split())
    print(depth[v1-1]+depth[v2-1])

Measured memory_bytes: 59488
#include<cstdio>
#include<vector>
#include<cmath>
#include<string>
#include<map>
#include<string.h>
#include<iostream>
#include<algorithm>
#define PI acos(-1.0)
#define pb push_back
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int N=3e5+5;
const int MOD=1e9+7;
template <class T>
bool sf(T &ret){ //Faster Input
    char c; int sgn; T bit=0.1;
    if(c=getchar(),c==EOF) return 0;
    while(c!='-'&&c!='.'&&(c<'0'||c>'9')) c=getchar();
    sgn=(c=='-')?-1:1;
    ret=(c=='-')?0:(c-'0');
    while(c=getchar(),c>='0'&&c<='9') ret=ret*10+(c-'0');
    if(c==' '||c=='\n'){ ret*=sgn; return 1; }
    while(c=getchar(),c>='0'&&c<='9') ret+=(c-'0')*bit,bit/=10;
    ret*=sgn;
    return 1;
}
int sign(int x){
    return abs(x)<1e-7?0:x<0?-1:1;
}
int a[N];
int main(void){
    ll n,k;
    sf(n);sf(k);
    for(int i=1;i<=n;i++)   sf(a[i]);
    n++;
    a[n]=0;
    sort(a+1,a+1+n);
    int index;
    for(int i=1;i<=n;i++){
        if(a[i]==0){
            index=i;
            break;
        }
    }
//    cout <<"index="<<index<<endl;
    ll ans=1e18;
    for(int i=max(1ll,index-k);i<=index;++i){
        ll l=i,r=i+k;
//        cout <<l<<"~"<<r<<endl;
        if(r>n) break;
        if(a[l]<0){
            ll t=a[r]-a[l]+min(a[r],abs(a[l]));
//            cout <<i<<" -> "<<t<<endl;
            ans=min(ans,t);
        }
        else{
            ll t=a[r];
//                        cout <<i<<" -> "<<t<<endl;

            ans=min(t,ans);
        }
    }
    cout <<ans << endl;

    return 0;

}


Measured memory_bytes: 640
# include <iostream>
# include <string>
# include <vector>


using namespace std;


int main() {
    int n, k; cin >> n >> k;
    string s; cin >> s;
    vector<int> spans;

    int ans = 0;
    for (int i=1; i<n; i++) {
        if (s[i-1] == s[i]) ans++;
    }

    cout << min(ans+2*k, n-1) << endl;
    return 0;
}



Measured memory_bytes: 512
import sys
import itertools


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    n = int(readline())
    xy = [list(map(int, readline().split())) for _ in range(n)]
    mt = 0
    cnt = 0
    for v in itertools.permutations([i for i in range(n)], n):
        cnt += 1
        for i in range(1, n):
            mt += ((xy[v[i]][0] - xy[v[i-1]][0]) ** 2 + (xy[v[i]][1] - xy[v[i-1]][1]) ** 2) ** 0.5
    print(mt / cnt)


if __name__ == '__main__':
    solve()


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

int main(){
  
  int R;
  double Enshuu;
  cin >> R;
  
  Enshuu = (double) 2 * 3.141592653 * (double) R;
  cout << Enshuu << endl;
  
  return 0;
}


Measured memory_bytes: 3788
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main{
  public static void main(String[] args) throws IOException{
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    
    String[] line = br.readLine().split(" ");
    int n = Integer.parseInt(line[0]);
    int d = Integer.parseInt(line[1]);
    System.out.println(n/(2*d+1) + (n%(2*d+1) == 0 ? 0 : 1));
  }
}


Measured memory_bytes: 22484
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main() {
    int n, m;
    cin >> n >> m;
    VI c(m);
    REP(i,n){
        int k = in();
        REP(j,k){
            c[in() - 1]++;
        }
    }
    int ans = 0;
    REP(i,m) if (c[i] == n) ans++;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
import sys

N, W = map(int, input().split())
WV = [list(map(int, sys.stdin.readline().split())) for i in range(N)]

INF = 10**10 + 1
dp = [[INF]*(N+1) for i in range(1000*N+2)]

for i in range(N+1):
        dp[0][i]=0

i = 1

#while(True):
for j in range(1, N+1):
        for i in range(1, 1000*N+2):
#for i in range(1, 1000*N+2):
        #for j in range(1, N+1):
                if i-WV[j-1][1]>=0:
                        dp[i][j] = min(dp[i-WV[j-1][1]][j-1]+WV[j-1][0], dp[i][j-1])
                else:
                        dp[i][j] = min(dp[i][j-1], WV[j-1][0])
        #print(i, dp[i][N])
        #if dp[i-1][N] <= W and dp[i][N] > W:
                #break
        #i += 1

for i in range(1000*N+2):
        if dp[i][N] > W:
                print(i-1)
                exit()

Measured memory_bytes: 130652
import sys
def getmax():
    max = 0
    for i in p:
        if i > max:
            max = i
    return max
def getmin():
    min = p[0]
    for i in p:
        if i < min:
            min = i
    return min
X,N = map(int,input().split())
if N ==0:
    print(X)
    sys.exit()
if N == 1:
    p = int(input())
    print(p-1)
    sys.exit()
p = list(map(int,input().split()))  #
MIN = 101   #
minnum = 0
for i in range(-101,102):
    if not i in p:
        if abs(i-X) < MIN:
            MIN = abs(i-X)
            minnum = i
print(minnum)


Measured memory_bytes: 9112
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)


def main():
    s = input()
    s = s.strip()
    n = len(s)
    a = s[0:(n-1)//2]
    b = s[(n+3)//2-1:n]

    for i in range(n//2):
        if s[i] != s[n-i-1]:
            print('No')
            return

    for i in range(len(a)//2):
        if a[i] != a[len(a)-i-1]:
            print('No')
            return

    for i in range(len(b)//2):
        if b[i] != b[len(b)-i-1]:
            print('No')
            return

    print('Yes')


main()


Measured memory_bytes: 38528
#include <iostream>
#include <math.h>
#include <algorithm>
#include <cstring>
#include <vector>
#include <fstream>
#include <stack>
#include <string>

using namespace std;

typedef long long ll;

int N;
const int MAX = 10001;
ll dp[MAX];
int max_dep = 0;

ll solve(string n_str, int dep){
    max_dep = max(dep, max_dep);
    vector<string> strs;
    string str = "";
    stack<char> st;
    for(int i=0; i<n_str.size(); i++){
        if(st.size() >= 1){
            str = str + n_str[i];
        }
        if(n_str[i] == '['){
            st.push(n_str[i]);
        }
        else if(n_str[i] == ']'){
            st.pop();
        }
        if(st.size() == 0){
            if(!str.empty())
                strs.push_back(str.substr(0, str.size()-1));
            str = "";
        }
    }


    // for(string u : strs){
    //     cout << u << endl;
    // }

    vector<int> vec;
    for(int i=0; i<strs.size(); i++){
        if(isdigit(strs[i][0])){
            vec.push_back(stoi(strs[i]));
        }
        else{
            ll tmp = solve(strs[i], dep+1);
            vec.push_back(tmp);
        }
    }
    sort(vec.begin(), vec.end());
    ll res = 0;
    for(int i=0; i<vec.size()/2 + 1; i++){
        if(dep == max_dep)
            res += vec[i]/2+1;
        else{
            res += vec[i];
        }
    }
    // cout << dep << ":" << res<< endl;
    return res;
}
int main(){
    cin >> N;
    for(int i=0; i<N; i++){
        string str;
        cin >> str;
        // cout << str << endl;
        max_dep = 0;
        // for(int k=0; k<str.size(); k++){
        //     if(k) cout << " ";
        //     cout << dp[k];
        // }
        // cout << endl;
        cout << solve(str.substr(1, str.size()-2), 0) << endl;
    }
    return 0;
}


Measured memory_bytes: 3312
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <string>
#include <cmath>
#include <limits>
#include <algorithm>

int main()
{
  int N, M;
  std::cin >> N >> M;
  std::vector<std::pair<long long, long long>> vec(N);
  for (auto& val: vec)
    std::cin >> val.first >> val.second;

  std::sort(begin(vec), end(vec));
  long long ans = 0;
  for (auto& val: vec)
  {
    if (M - val.second <= 0)
    {
      ans += val.first * M;
      break;
    }
    else
    {
      M -= val.second;
      ans += val.first * val.second;
    }
  }
  std::cout << ans << std::endl;
  return 0;
}



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

//float inf = std::numeric_limits<float>::infinity();
#define INF 100000000

using namespace std;

typedef struct UnionFind_ {
  vector<int> p;
  vector<int> r;
  vector<int> diff_weight;

  UnionFind_(int n = 1){
    init(n);
  }

  void init(int n = 1){
    p.resize(n);
    r.resize(n);
    diff_weight.resize(n);
    for(int i = 0; i < n; ++i){
      p[i] = i;
      r[i] = 0;
      diff_weight[i] = 0;
    }
  }

  int findSet(int x){
    int tmp;
    if(x != p[x]){
      tmp = findSet(p[x]);
      diff_weight[x] += diff_weight[p[x]];
      p[x] = tmp;
    }
    return p[x];
  }

  bool issame(int x, int y){
    return findSet(x) == findSet(y);
  }

  int weight(int x){
    findSet(x);
    return diff_weight[x];
  }

  int diff(int x, int y){
    if(!issame(x, y)) return INF;
    return weight(y) - weight(x);
  }

  bool merge(int x, int y, int w){
    w += weight(x);
    w -= weight(y);

    x = findSet(x);
    y = findSet(y);
    if(x == y) return false;

    if(r[x] < r[y]){
      swap(x, y);
      w = -w;
    }

    if(r[x] == r[y]) ++r[x];
    p[y] = x;


    diff_weight[y] = w;

    return true;
  }

} UnionFind;


int main(){
  int n, q;
  int com, x, y, z;
  int count = 0;

  cin >> n >> q;
  UnionFind uf(n);
  int judge[q];


  for(int i = 0; i < q; ++i){
    cin >> com;
    if(com == 0){
    cin >> x >> y >> z;
    uf.merge(x, y, z);
    }

    else{
      cin >> x >> y;
      judge[count++] = uf.diff(x, y);
    }
  }

  for(int i = 0; i < count; ++i){
    if(judge[i] >= INF) cout << "?" << endl;
    else cout << judge[i] << endl;
  }


  return 0;
}



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

template <
    typename TYPE,
    std::size_t SIZE>
std::size_t a_len(const TYPE (&array)[SIZE])
{
    return SIZE;
}

using namespace std;
using ll = long long int;
using vi = vector<ll>;

#define REPS(a, i, n) for (ll(i) = a; (i) < (n); ++(i))
#define REP(i, n) REPS(0, i, n)
#define ALL(x) (x).begin(), (x).end()

const ll INF = 912345678;

int n;

int main()
{
    cin >> n;
    REP(i, n)
    {
        REP(j, n)
        {
            if (i * 4 + j * 7 == n)
            {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
 int a,b,c;
 int tmp,i,j;
 scanf("%d %d %d",&a,&b,&c);

 if(a>b){
 tmp=a;
 a=b;
 b=tmp;
}
 if(a>c){
 tmp=a;
 a=c;
 c=tmp;
}
 if(b>c){
 tmp=b;
 b=c;
 c=tmp;
}
 
 printf("%d %d %d\n",a,b,c);
 return 0;
}

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

class Program
{
    class P
    {
        public int index;
        public List<int> ad;
        public P(int index)
        {
            this.index = index;
            ad = new List<int>();
        }
    }
    static void Main(string[] args)
    {
        var nm = Array.ConvertAll(ReadLine().Split(' '), int.Parse);
        var ps = new P[nm[0]];
        for (var i = 0; i < nm[0]; i++)
            ps[i] = new P(i);
        for(var i = 0; i < nm[1]; i++)
        {
            var input = Array.ConvertAll(ReadLine().Split(' '), int.Parse);
            ps[input[0] - 1].ad.Add(input[1] - 1);
        }
        var isGoal = false;
        dfs(ps, nm[0], 0, 0,ref isGoal, new HashSet<int>());
        WriteLine(isGoal ? "POSSIBLE" : "IMPOSSIBLE");
    }
    private static void dfs(P[] ps,int num,int index,int depth,ref bool isGoal,HashSet<int> set)
    {
        if (index == num - 1) { isGoal = true; return; }
        else if (depth == 2) return;

        foreach(var p in ps[index].ad)
        {
            if (!set.Contains(p) && !isGoal)
                dfs(ps, num, p, depth+1,ref isGoal, set);
        }
    }
    private const string ALFA = "abcdefghijklmnopqrstuvwxyz";
    private const int MOD = 1000000007;
}


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

const ll mx = 1e18;

int main(){
	int n;
	cin >> n; 	
  	ll ans = 1;
  	bool over = false;
  
   	rep(i, n){
    	ll a;
      	cin >> a;
      
      	if(a == 0){
        	cout << 0 << endl;
          	return 0;
        }
      
      	if(over || __int128(ans)*a > mx){
			over = true;
        }
      
      	ans *= a;
    }
  
  	if(over) ans = -1;
  	cout << ans << endl;
}

Measured memory_bytes: 3624
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i = 0; i < (n); i++)
#define divup(a,b) ( ( (a) + ( (b) - 1u) ) / (b) ) // a/b の余り切り上げ
// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;
ll mod = 1000000007;

signed main(){
    ll a[1000009];
    ll ab[1000009];
    ll ac[1000009];
    rep(i,1000009){
        a[i]=0;
        ab[i]=0;
        ac[i]=0;
    }
    ll ss;
    string s;
    cin>>s;
    ss = s.size();
    rep(i,ss){
        a[i] = s[ss-1-i]-'0';
        ab[i] = a[i];
    }
    rep(i,ss+2){
        if(a[i]>=10){
            a[i] -= 10;
            a[i+1]++;
        }else if(a[i]>=6){
            a[i]=0;
            a[i+1]++;
        }else if(a[i]==5&&a[i+1]>=5){
            a[i]=0;
            a[i+1]++;
        }
    }
    ll ans=0;
    rep(i,ss+2){
        ans += a[i];
    }
    rep(i,ss+2){
        if(a[i]-ab[i]>=0){
            ac[i] = 0;
        }else{
            ac[i] = a[i]+10-ab[i];
            a[i+1]--;
        }
    }
    rep(i,ss+2){
        ans += ac[i];
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 24836
n = int(input())
L = list(map(int, input().split()))

ans = 0

for i in range(n):
    for j in range(i+1, n):
        for k in range(j+1, n):
            if abs(L[i]-L[j]) < L[k] < L[i]+L[j] and L[i]!=L[j] and L[j]!=L[k] and L[k]!=L[i]:
                ans += 1

print(ans)

Measured memory_bytes: 9192
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <functional>
#include <numeric>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <bitset>
#include <queue>
#include <unordered_set>
#include <unordered_map>

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;

#define rep(i, n) for(int i = 0;i < n;i++)
const int INF = 1LL << 30;

int MOD = 1000000007;

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

    int n; cin >> n;
    std::vector<ll> a(n);
    rep(i,n) cin >> a[i];

    int cnt = 0;

    rep(bit,60){
        int zero_cnt = 0;
        int one_cnt = 0;

        rep(j,n){
            if(a[j] & (1ll << bit)) one_cnt++;
            else zero_cnt++;
        }
        ll toadd = (1ll<<bit)%MOD*one_cnt%MOD*zero_cnt%MOD;
        cnt = (ll(cnt)+toadd) % MOD;
        
    }

    cout << cnt << endl;


    return 0;
}

Measured memory_bytes: 2560
S = input()
N = len(S)

bw = ''
wb = ''
for n in range(N):
    bw += str(n % 2)
    wb += str((n+1) % 2)

diff_bw = 0
diff_wb = 0
for n in range(N):
    if S[n] != bw[n]:
        diff_bw += 1
    if S[n] != wb[n]:
        diff_wb += 1

print(min(diff_bw, diff_wb))

Measured memory_bytes: 3316
N = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
kai = set()
ans = 0
for m in range(N):
  for i in range(50,0,-1):
    kai.add(i)
  amari = [] 
  for i in kai:
    are = a[m] % i
    amari.append(are)
  for k in range(len(amari)):
    for i in kai:
      are = amari[k] % i
      amari.append(are)
  if b[m] in amari:
    ann = 0
  else:
    ans = -1

for p in range(50,0,-1):
  kai.remove(p)
  for j in range(N):
    amari = [] 
    for i in kai:
      are = a[j] % i
      amari.append(are)
    for k in range(len(amari)):
      for i in kai:
        are = amari[k] % i
        amari.append(are)
    if b[j] in amari:
      ann = 0
    else:
      kai.add(p)
if ans == -1:
   print(-1)
elif a == b:
  print(0)
else:
  ans = 0
  for i in kai:
    ans += 2 ** i
  print(ans)

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

class Program {
    internal static void Main(string[] args) {
        var N = int.Parse(ReadLine());
        var a = ReadLine().Split(' ').Select(s => int.Parse(s)).ToList();
        var ans = 0;

        while (true) {
            if (a.Count(i => i % 2 == 1) == 0) {
                a = a.Select(i => i / 2).ToList();
                ans++;
            } else {
                break;
            }
        }
        WriteLine(ans);
    }
}

Measured memory_bytes: 13396
PRIME = 10 ** 9 + 7
s = int(input())
N = s * 2
fact = [1, 1]
factinv = [1, 1]
inv = [0, 1]

for i in range(2, N + 1):
    fact.append((fact[-1] * i) % PRIME)
    inv.append((-inv[PRIME % i] * (PRIME // i)) % PRIME)
    factinv.append((factinv[-1] * inv[-1]) % PRIME)

def cmb(n, r):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % PRIME

ans = 0
for i in range(1, s // 3 + 1):
  ans += cmb(s + i - 1 - 3 * i, i - 1)
  ans %= PRIME

print(ans)

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

int main()
{
	int H, W;
	cin >> H >> W;
	int a[510][510];
	for (int i = 0; i < H; i++)
	{
		for (int j = 0; j < W; j++)
		{
			cin >> a[i][j];
		}
	}
	vector<int> x0;
	vector<int> x1;
	vector<int> y0;
	vector<int> y1;
	int N = 0;
	for (int i = 0; i < H; i++)
	{
		for (int j = 0; j < W; j++)
		{
			if (a[i][j] % 2 == 1)
			{
				if (i != H - 1)
				{
					a[i + 1][j]++;
					y0.push_back(i + 1);
					x0.push_back(j + 1);
					y1.push_back(i + 2);
					x1.push_back(j + 1);
					N++;
				}
				else
				{
					if (j == W - 1)
						continue;
					a[i][j + 1]++;
					y0.push_back(i + 1);
					x0.push_back(j + 1);
					y1.push_back(i + 1);
					x1.push_back(j + 2);
					N++;
				}
			}
		}
	}
	cout << N << endl;
	for (int i = 0; i < N; i++)
	{
		cout << y0[i] << " " << x0[i] << " " << 
			y1[i] << " " << x1[i] <<endl;
	}
	return 0;
}

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

using namespace std;
using ll =long long;
using db = double;
using vll = vector<long long>;

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
#define che(a,string) cout<<"//"<<string <<"=="<<(a)<<"//" <<endl;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define leftunique(a) {SORT(a);(a).erase(unique((a).begin(),(a).end()),(a).end());}
//leftuniqueは配列から同じ要素のものを取り除く 例 4 6 2 1 3 4 1 2 なら 1 2 3 4 6 になる
#define debug(x)  cout << #x << " = " << (x) << endl;
bool IsInt(double a){int b = a/1;if(a==b){return true;}else {return false;}}
bool coY() {cout <<"Yes"<<endl;}
bool coN(){cout <<"No"<<endl;}
const int mod = 1e9 + 7;
const ll INF = 1LL << 60;
// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
//グラフ用
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};	
//ここから書き始める

int main()
{
	cout <<setprecision(10);
	ll x , y;
	cin >> x >> y;
	ll a , b , c, d;
	//none,none
	a = y - x;
	if(a<0) a= INF;
	// none , rev;
	b = -y -x +1 ;
	if(b<=0) b= INF;
	//rev, none;
	c = y + x +1;
	if(c<=0) c= INF;
	//rev,rev;
	d = -y + x + 2;
	if(d<=0) d= INF;
	ll ans = min({a,b,c,d});
	cout << ans << endl;

}


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



int main(){
	int a,b;
	cin >> a >> b;
	if(a > 8 || b > 8) cout << ":(";
	else cout << "Yay!";
	return 0;
} 

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

struct Node {
  char suit;
  int number;
  int pri;
  bool operator <(const Node &rhs) const {
    return number < rhs.number;
  }
};

int main() {
  int N; cin >> N;
  vector<Node> vec;
  for(int i = 0; i < N; i++) {
    string s; cin >> s;
    vec.push_back((Node){ s[0], s[1] - '0', i});
  }
  vector<Node> v2 = vec;
  for(int i = 0; i < (int)v2.size(); i++) {
    for(int j = v2.size() - 1; j > i; j--) {
      if(v2[j - 1].number > v2[j].number) {
        swap(v2[j - 1], v2[j]);
      }
    }
  }
  bool isStable = true;
  for(int i = 0; i < (int)v2.size() - 1; i++) {
    if(v2[i].number == v2[i + 1].number && v2[i].pri > v2[i+1].pri) isStable = false;
  }
  for(int i = 0; i < (int)v2.size(); i++) {
    cout << v2[i].suit << v2[i].number << " \n"[i+1 == v2.size()];
  }
  cout << (isStable ? "Stable" : "Not stable") << endl;

  v2 = vec;
  for(int i = 0; i < (int)v2.size(); i++) {
    int mini = i;
    for(int j = i + 1; j < (int)v2.size(); j++) {
      if(v2[j].number < v2[mini].number) {
        mini = j;
      }
    }
    swap(v2[i], v2[mini]);
  }
  isStable = true;
  for(int i = 0; i < (int)v2.size() - 1; i++) {
    if(v2[i].number == v2[i + 1].number && v2[i].pri > v2[i+1].pri) isStable = false;
  }
  for(int i = 0; i < (int)v2.size(); i++) {
    cout << v2[i].suit << v2[i].number << " \n"[i+1 == v2.size()];
  }
  cout << (isStable ? "Stable" : "Not stable") << endl;
}

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

const int coin[] = {100, 500, 1000};

int main(){
  while(true){
    int price, pay;
    cin >> price >> pay;
    if(price == 0 && pay == 0) break;

    int rem = pay - price;
    int ans[3] = {};

    for(int i = 2; i >= 0; i--){
      ans[i] = rem / coin[i];
      rem -= ans[i] * coin[i];
    }
    for(int i = 0; i < 3; i++){
      if(i != 0) cout << " ";
      cout << ans[i];
    }
    cout << endl;
  }
}

Measured memory_bytes: 1164
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <numeric>
#include <ctime>
#include <complex>
#include <bitset>
#include <random>

using namespace std;

typedef long long ll;
typedef long double ld;

//#define int ll
#define double ld
#define loop(i, n) for(int i = 0; i < (int)n; ++i)
#define loop1(i, n) for(int i = 1; i <= (int)n; ++i)
#define F first
#define S second
#define pb push_back
#define pi pair <int, int>
#define all(x) begin(x), end(x)
#define ti tuple <int, int, int, int>
#define Point Vect
#define no {cout << "0\n"; return;}
#define mkp make_pair
#define cerr if (0) cerr

const int N = 2e5 + 7, INF = 1e9 + 7;

int c[N];
vector <int> g[N];
int seq[N], ans[N];

void dfs (int v, int p) {
    int pos = lower_bound(seq, seq + N, c[v]) - seq;
    int lst = seq[pos];
    seq[pos] = c[v];
    ans[v] = lower_bound(seq, seq + N, INF) - seq - 1;
    for (int u : g[v])
        if (u != p)
            dfs(u, v);
    seq[pos] = lst;
}

void solve() {
    loop1(i, N - 1)
        seq[i] = INF;
    int n; cin >> n;
    loop1(i, n)
        cin >> c[i];
    loop(i, n - 1) {
        int u, v;
        cin >> u >> v;
        g[u].pb(v);
        g[v].pb(u);
    }
    dfs(1, 1);
    loop1(i, n)
        cout << ans[i] << "\n";
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    solve();
    return 0;
}

Measured memory_bytes: 31180
using System;
using System.IO;
using System.Text;
using System.Linq;
namespace A___Strings
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Trim().Split(' ');
            StringBuilder sb = new StringBuilder();
            sb.Append(input[1]).Append(input[0]);
            Console.WriteLine(sb.ToString());
        }
    }
}


Measured memory_bytes: 11092
import sys
from copy import deepcopy as copy
input = sys.stdin.readline

def main():
  n, c = map(int, input().split())
  sushi = [[0, 0]]+[[int(x) for x in input().split()] for _ in range(n)]

  order = [0]*(n+1)
  reverse = [0]*(n+1)

  for i in range(n):
    order[i+1] = order[i]+sushi[i+1][1]
    reverse[i+1] = reverse[i]+sushi[n-i][1]

  order_index = [i for i in range(n+1)]
  reverse_index = [-i for i in range(n+1)]
  for i in range(n):
    order[i+1] -= sushi[i+1][0]
    if order[i+1] <= order[i]:
      order[i+1] = order[i]
      order_index[i+1] = order_index[i]
    reverse[i+1] -= c-sushi[n-i][0]
    if reverse[i+1] <= reverse[i]:
      reverse[i+1] = reverse[i]
      reverse_index[i+1] = reverse_index[i]

  order_back = copy(order)
  reverse_back = copy(reverse)
  for i in range(n+1):
    order_back[i] -= sushi[order_index[i]][0]
    if i != 0 and order_back[i] < order_back[i-1]:
      order_back[i] = order_back[i-1]
    reverse_back[i] -= (c-sushi[reverse_index[i]][0])%c
    if i != 0 and reverse_back[i] < reverse_back[i-1]:
      reverse_back[i] < reverse_back[i-1]

  ans = 0
  for i in range(n+1):
    sub = max(order[i]+reverse_back[n-i], order_back[i]+reverse[n-i])
    if ans < sub:
      ans = sub

  print(ans)

if __name__ == "__main__":
  main()

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

using namespace std;

#define MOD 1000000007
#define N 100005
#define M 30
#define ll long long 
#define ld long double
#define pb push_back
#define ff first
#define ss second

int main(){
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	int k; cin>>k;
	string s; cin>>s;
	int i, l = s.length();
	if(l <= k){
		cout<<s;
	}
	else{
		for(i=0; i<k; i++){
			cout<<s[i];
		}
		cout<<"...";
	}
	return 0;
}

Measured memory_bytes: 3492
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define int long long
#define double long double
#define stp setprecision
#define pb push_back
#define ppb pop_back
#define emb emplace_back
#define vi vector<int>
#define rep(i,n) for(int i=0;i<n;i++)
#define ren(i,n) for(int i=n-1;i>=0;i--)
#define iter(it,v) for(auto it:v)
#define iterp(it,v) for(auto it=v.begin(),it!=v.end();it++)
#define itern(it,v) for(auto it=v.rbegin();it!=v.rend();it++)
#define forp(i,a,b) for(int i=a;i<=b;i++)
#define forn(i,a,b) for(int i=a;i>=b;i--)
#define sc(a) scanf("%d",&a)
#define pf(a) printf("%d",a)
#define init(a,r) for(auto&i:a) i=r;
#define initi(a,r) memset(a,r,sizeof(a))
#define inp(a) for(auto&i:a) cin>>i;
#define debug(a) cout<<#a<<": ";for(auto i:a)cout<<i<<" ";cout<<'\n';
#define ub upper_bound
#define lb lower_bound
#define bs binary_search
#define bi back_inserter
#define all(v) v.begin(),v.end()
#define bitc __builtin_popcount
#define fst ios::sync_with_stdio(false); cin.tie(0),cout.tie(0);
#define pq priority_queue
#define pii pair<int,int>
#define mpii map<int,int>
#define cs(a) cout<<a<<' '
#define cn(a) cout<<a<<'\n'
#define deb(a,b) cout<<a<<' '<<b<<endl;
#define yy "YES"
#define nn "NO"
#define ff first
#define ss second
#define matrix vector<vector<int>>
#define mxe *max_element
#define mne *min_element
typedef long long ll;
const int mod=1e9+7,mod1=998244353;
const int N=2e5+7;
void a_b_l(){
    int n;
    cin>>n;
    int ans=1;
    ans%=mod;
    for(int i=0;i<n;i++){
        ans*=10;
        ans%=mod;
    }
    int ans1=1;
    for(int i=0;i<n;i++){
        ans1*=9;
        ans1%=mod;
    }
    ans1*=2;
    ans1%=mod;
    int ans2=1;
    for(int i=0;i<n;i++){
        ans2*=8;
        ans2%=mod;
    }
    ans=(ans-ans1+ans2+mod)%mod;
    cn(ans);
}
signed main(){
    fst;
    int t=1;
    //cin>>t;
    while(t--)
    	a_b_l();
}

Measured memory_bytes: 3632
#include<iostream>
#include<set>
using namespace std;
int main(){
	set<int>S;
	int q;
	cin>>q;
	while(q--){
		int c,x;
		cin>>c>>x;
		if(c==0){
			S.insert(x);
			cout<<S.size()<<endl;
		}
		else if(c==1){
			if(S.find(x)==S.end())
				cout<<0<<endl;
			else
				cout<<1<<endl;
		}
		else{
			S.erase(x);
		}
	}
	return 0;
}


Measured memory_bytes: 12444
n, k = map(int, input().split())
p = list(map(int, input().split()))

p_exp = [(p[i] + 1)/2 for i in range(n)]

s = [0]
for i in range(n):
    s.append(s[i] + p_exp[i])

ans = -1

for i in range(0, n-k+1):
    k_start = i
    k_end = i + k
    
    sum_exp = s[k_end] - s[k_start]
    
    ans = max(sum_exp, ans)

print(ans)

Measured memory_bytes: 78984
#include <iostream>

int main(){
  int given_number_a, given_number_b;
  int area_square, area_length;
  std::cin >> given_number_a >> given_number_b;
  area_square = given_number_a * given_number_b;
  area_length = (given_number_a + given_number_b) * 2;
  std::cout << area_square << ' ' << area_length << std::endl;
  return 0;
}

Measured memory_bytes: 3076
#include <stdio.h>
 
int main(void) {
  int i,x,y,ans,turu,kame;
  i=0;
  x=0;
  y=0;
  kame=0;
  turu=0;
  ans=0;
  scanf("%d",&x);
  scanf("%d",&y);
  kame=(y-2*x)*4/2;
  turu=(4*x-y)*2/2;
  if(x*2==y||x*4==y)
  {
    printf("Yes");
  }
  else if(4*x<y||2*x>y)
  {
    printf("No");
  }
  else if(turu%2==0&&kame%4==0)
  {
    printf("Yes");
  }
  else
  {
    printf("No");
  }
  return 0;
}

Measured memory_bytes: 1712
#include <bits/stdc++.h>
using namespace std;
int main (){
  long long int n;
  cin>>n;
  long long int c=0;
  if(n%2==1);
  else{
    while(n%10!=0)
      n-=2;
    n/=2;
    long long int g = 5;
    while(n>=g){
      c+=n/g;
      n/=g;
    }
  }
  cout<<c;
  return 0;
}

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

int main() {
  int len, numQ;
  cin >> len >> numQ;
  string str;
  cin >> str;
  
  vector<int> numACs(len-1);
  int cnt = 0;
  for(int i=0; i<len-1; ++i) {
    if(str[i] == 'A' && str[i+1] == 'C') {
      numACs[i] = ++cnt;
    }
    else {
      numACs[i] = cnt;
    }
  }
  
  for(int i=0; i<numQ; ++i) {
    int start, end;
    cin >> start >> end;
    int ans = numACs[end-2] - numACs[start-2];
    cout << ans << endl;
  }
  
}


Measured memory_bytes: 1408
#include<iostream>
#include<string>
#include<stdio.h>
using namespace std;
int main(){
  string s;
  cin >> s;
  int i=0,cnt=0;
  for(;i<s.size();i++){
    cnt+=(s[i]=='x');
  }
  puts(cnt<8?"YES":"NO");
}

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

int main(void) {
  int N;
  long long sum = 0;
  cin >> N;
  for (int i = 1; i <= N; ++i) {
  	if(i%3 != 0 && i%5 != 0) sum += i;
  }
  cout << sum << "\n";
  return 0;
}

Measured memory_bytes: 3600
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
#from fractions import gcd
#from itertools import combinations # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
n = I()
b = readInts()
ans = []
for i in range(n):
    pivot = -1
    for j in range(len(b)-1,-1,-1):
        if b[j] == j+1:
            pivot = j
            break
    if pivot == -1:
        print(-1)
        exit()
    ans.append(pivot+1)
    b.pop(pivot)
print(*ans[::-1],sep='\n')


Measured memory_bytes: 3316
n = int(input())
songList = [0] * n
timeList = [0] * n
for i in range(n):
    songList[i], timeList[i] = input().split()
x = input()

timeList = [int(time) for time in timeList]

sleepIndex = -1
for i, song in enumerate(songList):
  if song == x:
    sleepIndex = i
    break

print(sum(timeList[i+1:]))


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define pb push_back
#define f first
#define s second
int fun(int x,int n,int m)
{
    int ans=1;
    while(n>0)
    {
        if(1&n)
            ans=(ans*x)%m;
        n=n>>1;
        x=(x*x)%m;
    }
    return ans;
}

signed main()
{
  int n,p1=0,p2=0;


  string s;
  cin>>n>>s;
  int k=count(s.begin(),s.end(),'1');
    if(k>1)
    for(int i=0;i<n;i++)
    {
        if(s[i]=='1')
            p1+=fun(2,n-i-1,k-1);
    }
    int arr[n]={0};
    for(int i=0;i<n;i++)
    {
        if(s[i]=='1')
            p2+=fun(2,n-i-1,k+1);
    }

        for(int i=0;i<n;i++)
    {
        int p;int ans=1;
        if(s[i]=='1' && k>1)
        {
              p=(p1-fun(2,n-i-1,k-1)+(k-1))%(k-1);

              while(p>0)
              {
                  int q=0,r=p;
                  while(r>0)
                  {
                      if(1&r)
                      q++;
                      r=r>>1;
                  }
                  p=p%q;
                  ans++;
              }
              arr[i]=ans;

        }
        else if(s[i]=='0')
        {
             p=(p2+fun(2,n-i-1,k+1))%(k+1);
             while(p>0)
              {
                  int q=0,r=p;
                  while(r>0)
                  {
                      if(1&r)
                      q++;
                      r=r>>1;
                  }
                  p=p%q;
                  ans++;
              }
              arr[i]=ans;
        }

    }
    for(int i=0;i<n;i++)
        cout<<arr[i]<<endl;

}




























































































































































































































Measured memory_bytes: 5324