akhauriyash/Code-Regression huggingface dataset:
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

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();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//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 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,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

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

int main(){
    int N; 
    cin >> N;
    int n = N;
    //桁数を調べる
    int keta = 0;
    while(n != 0){
        n /= 10;
        keta++;
    }
    //分類
    int ans = 0;
    if(keta == 1){
        ans = N;
    }else if(keta == 2){
        ans = 9;
    }else if(keta == 3){
        ans = N-90;
    }else if(keta == 4){
        ans = 909;
    }else if(keta == 5){
        ans = N-9090;
    }else if(keta == 6){
        ans = 90909;
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
  int A, B, C, X, Y;
  cin >> A >> B >> C >> X >> Y;
  
  int m = min(X,Y);
  
  int ans = 0;
  
  //1st step
  int firstSumA = A * m;
  int firstSumB = B * m;
  int firstSumAB = firstSumA + firstSumB;
  int firstSumHalf = C * 2 * m;
  
  if (firstSumAB >= firstSumHalf){
    if ( A * (X - m) + B * (Y - m) >= C * 2 * (X + Y - 2 * m)) {
      ans = C * 2 * (X + Y - m);
    }
    else {
      ans = firstSumHalf + A * (X - m) + B * (Y - m);
    }
  }
  else { 
    if ( A * (X - m) + B * (Y - m) >= C * 2 * (X + Y - 2 * m)){
      ans = firstSumAB + C * 2 * (X + Y - 2 * m);
    }
    else {
      ans = firstSumAB + A * (X - m) + B * (Y - m);
    }
  }
  
  cout << ans << endl;
  
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <numeric>
const int MOD = 1000000007;
int N, M, K, D, f[4000][2001];
inline int add(int x, int y)
{
	return x + y < MOD ? x + y : x + y - MOD;
}
inline int mns(int x, int y)
{
	return x < y ? x - y + MOD : x - y;
}
int main()
{
	scanf("%d%d%d", &N, &M, &K);
	D = (N + M - 1) / (K - 1);
	f[0][0] = 1;
	for (int i = 1; i <= D; i++)
	{
		static int p[2001];
		p[0] = f[i - 1][0];
		for (int j = 1; j <= M; j++)
			p[j] = add(p[j - 1], f[i - 1][j]);
		std::copy(p, p + K, f[i]);
		for (int j = K; j <= M; j++)
			f[i][j] = mns(p[j], p[j - K]);
	}
	int O = 0;
	for (int i = 1; i <= D; i++)
	{
		int T = (K - 1) * (i - 1) + K;
		for (int j = 0; j <= M; j++)
			if ((M - j) % (K - 1) == 0 && T - j <= N)
				O = add(O, mns(f[i][j], f[i - 1][j]));
	}
	printf("%d\n", O);
	return 0;
}


Measured memory_bytes: 31488
n, m = map(int, raw_input().split())
X = map(int, raw_input().split())
X.sort()
P = [[] for i in xrange(m)]
S = {}
T = [0]*m
for e in X:
    P[e%m].append(e)
    S[e] = S.get(e, 0) + 1
for e in S:
    T[e%m] += S[e]/2
ans = 0
for i in xrange(1, (m-1)/2+1):
    r = min(len(P[i]), len(P[m-i]))
    ans += r
    rest = len(P[i]) - r
    ans += min(T[i], rest/2)
    rest = len(P[m-i]) - r
    ans += min(T[m-i], rest/2)
if m%2 == 0:
    ans += len(P[m/2])/2
ans += len(P[0])/2
print ans




Measured memory_bytes: 27720
#include <bits/stdc++.h>
using namespace std;
#define MAX 1000010
#define mod 1000000007
typedef long long ll;
int n,f[MAX],ad;

int main()
{
    scanf("%d",&n);
    f[n]=n;
    f[n-1]=(ll)n*n%mod;
    for(int i=n-2;i>=1;--i)
    {
        ad=(ad+f[i+3])%mod;
        f[i]=f[i+1];
        f[i]=(f[i]+(ll)(n-1)*(n-1)%mod)%mod;
        f[i]=(f[i]+ad)%mod;
        f[i]=(f[i]+i+1)%mod;
    }
    printf("%d\n",f[1]);
}

Measured memory_bytes: 4096
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

typedef struct node{
    char elem;
    struct node *next;
}node;

void push(node **first,char elem){
    node *new=calloc(1,sizeof(node));
    if(new==NULL)exit(1);
    new->elem=elem;
    new->next=*first;
    *first=new;
}

char pop(node **first){
    char elem;
    node *tmp=*first;
    if(tmp==NULL){
        printf("stackend\n");
        return 'a';   
    }
    elem=tmp->elem;
    *first=tmp->next;
    free(tmp);
    return elem;
}
void printStack(node *first){
    node *tmp=first;
    char ret[12]={'\0'};
    int len,pt=0;
    while(tmp!=NULL){
        ret[pt++]=tmp->elem;
        tmp=tmp->next;
    }
    for(int i=pt;i>=0;i--){
        printf("%c",ret[i]);
    }
    printf("\n");
}

int main(void){
    char inseq[100001];
    node *first=NULL;
    int stlen,ans=0;
    char dmp;
    scanf("%s",inseq);
    stlen=strlen(inseq);
    for(int i=0;i<stlen;i++){
        if(first==NULL){
            push(&first,inseq[i]);
        }else{
            if(first->elem==inseq[i]){
                push(&first,inseq[i]);
            }else{
                dmp=pop(&first);
                ans+=2;
            }
        }
    }
    while(first!=NULL){
        dmp=pop(&first);
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 4892
A, B = list(map(int, input().split()))
min_ = max(A/0.08, B/0.1)
max_ = min(int((A+1)/0.08),int((B+1)/0.1))

if min_%1!=0:
    min_ = int(min_)+1
else:
    min_ = int(min_)

if min_>=max_:
    print(-1)
else:
    print(min_)


Measured memory_bytes: 3060
// Gaurav Aggarwal
 
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii > vii;
typedef vector<pll > vll;
#define pb push_back
#define mp make_pair 
#define mod 1000000007
#define F first
#define S second
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define For(i, a, b) for(__typeof (a) i=a; i<=b; i++)
#define inp_arr(a,n) for(__typeof (n) i=0; i<n; ++i) {cin>>a[i];}
#define debug_arr(a,n) {{for(__typeof (n) i=0; i<n; ++i) {cout<<a[i]<<" ";}cout<<"\n";}}
 
ll power(ll x, ll y) 
{ 
    ll res = 1;   
    while (y > 0) { 
        if (y & 1) 
            res = (res*x)%mod; 
        y = y>>1;
        x = (x*x)%mod;
    } 
    return res%mod; 
}

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

    // #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin);
    // freopen("out.txt", "w", stdout); 
    // #endif  

    string s;
    cin>>s;
    int n = s.size();
    int dist[n] = {0};
    int a[n] = {0};
    int an = 0;
    int dist2[n] = {0};
    for(int i=n-1;i>=0;--i) {
        if(s[i] == 'L') {
            an = 0;
        }
        else {
            an += 1;
        }
        a[i] = 1;
        dist[i] = an;
    }
    an = 0;
    for(int i=0;i<n;++i) {
        if(s[i] == 'R') {
            an = 0;
        }
        else
            an += 1;
        dist2[i] = an;
    }

    // debug_arr(dist2,n);
    int ans[n] = {0};

    for(int i=0;i<n;++i) {
        if(dist[i] > 0) {
            int indiL = i + dist[i];
            if(dist[i] & 1) {
                ans[indiL - 1] += a[i];
            }
            else {
                ans[indiL] += a[i];
            }
        }
    }

    for(int i=0;i<n;++i) {
        if(dist2[i] > 0) {
            int indiR = i - dist2[i];
            if(dist2[i] & 1) {
                ans[indiR + 1] += a[i];
            }
            else {
                ans[indiR] += a[i];
            }
        }
    }

    debug_arr(ans,n);
    return 0;
}

Measured memory_bytes: 2256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0;i < (n);i++)
using ll = long long;
const ll MOD=1000000007;
const long long INF = 1LL << 60;
const double pi=acos(-1.0);

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; }



int main() 
{
  ll N,D; cin>>N>>D;
  ll ans=0;
  rep(i,N){
    ll X,Y; cin>>X>>Y;
    if(X*X+Y*Y<=D*D) ans++;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3632
#include <stdio.h>

int main(void){
    char sta[4];
    int i;

    scanf("%s", sta);
    for ( i = 0; i < 2; i++) {
        if(!(sta[i]==sta[i+1])){
            printf("Yes\n");
            return 0;
        }
    }printf("No\n");
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#define ll long long
#define MAXN (ll)1e15
#define V 305
using namespace std;
ll g[V][V], G[V][V];
ll n;
bool vst[V][V];

int main() {
	ll sum = 0;
	cin >> n;
	for(int i = 1; i <= n; i++) 
		for(int j = 1; j <= n; j++) {
			cin >> g[i][j];
			G[i][j] = g[i][j];
		}
		
	
	for(int k = 1; k <= n; k++) 
		for(int i = 1; i <= n; i++) 
			for(int j = 1; j <= n; j++) 
				g[i][j] = min(g[i][j], g[i][k] + g[k][j]);

	for(int i = 1; i <= n; i++) 
		for(int j = 1; j <= n; j++) 
			if(g[i][j] != G[i][j]) {
				cout << "-1\n";
				return 0;
			}
	for(int k = 1; k <= n; k++) 
		for(int i = 1; i <= n; i++) 
			for(int j = 1; j <= n; j++)	
				if(i!=j && i!=k && j!=k)
					if(g[i][j] == g[i][k] + g[k][j])
						vst[i][j] = 1;
	for(int i = 1; i <= n; i++) {
		for(int j = 1; j <= n; j++)
			if(!vst[i][j])
				sum += g[i][j];
	}
	cout << sum/2 << "\n";
	return 0;
}

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

int main() {
  LL n, t;
  cin >> n >> t;
  vector<LL> a(n);
  for (int i = 0; i < n; i ++) {
    cin >> a.at(i);
  }

  LL sum = 0;
  for (int i = 1; i < n; i ++) {
    if (a.at(i) - a.at(i - 1) <= t) {
      sum += a.at(i) - a.at(i - 1);
    } else {
      sum += t;
    }
  }
  sum += t;

  cout << sum << endl;
}


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

using namespace std;

const int maxn = 102;

int n, a[maxn], ans, x;

int main() {
	ios::sync_with_stdio(false);
	cin >> n >> x;
	for (int i = 1; i <= n; i++) cin >> a[i];
	sort(a + 1, a + n + 1);
	for (int i = 1; i <= n; i++) {
		if (x >= a[i]) x -= a[i], ans++;
		else { x = 0; break; }
	}
	if (x > 0) cout << ans - 1 << endl;
	else cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) REP(i, 0, n)
#define rrep(i, n) for (int i = (int)(n-1); i >= 0; i--)
#define sz(x) int(x.size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define INF 2e9
#define LINF 1e18
template<class T> inline bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> P;


int main() {
    int n; cin >> n;
    vector<int> l(n);
    rep(i, n) cin >> l[i];
    sort(all(l));
    int mx = l[n-1];
    int sum = 0;
    rep(i, n-1) {
        sum += l[i];
    }
    if (mx < sum) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <cmath>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <functional>
#include <queue>
#include <iostream>
#include <string.h>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <cstdint>
#include <climits>
#include <unordered_set>
#include <unordered_map>
#include <sstream>
#include <stack>

using namespace std;

typedef long long int ll;
typedef pair<char,char> pcc;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> t3;

int main(void) {
    ll n, m;
    vector<ll> vs;
    cin >> n >> m;
    vs.resize(n, 0);
    for(int i = 0;i < n;i++) cin >> vs[i];
    sort(vs.begin(), vs.end());
    vector<ll> sums(n+1,0);
    for(int i = 1;i <= n;i++) sums[i] = sums[i-1]+vs[i-1];

    ll left = 0;
    ll right = 3e5;
    map<ll, P> memo;
    while(right - left > 1){
        ll middle = left + right; // hand1 + hand2 >= middle となるペア
        middle /= 2;
        ll sum = 0;
        ll countSum = 0;
        for(int i = 0; i < n;i++){
            auto x = lower_bound(vs.begin(), vs.end(), middle - vs[i]);
            auto count = vs.end() - x;
            countSum += count;
            sum += count * vs[i];
            sum += sums[n] - sums[n-count];
        }
        if(countSum >= m){
            left = middle;
        }
        else{
            right = middle;
        }
        memo[middle] = {sum, countSum};
    }
    ll prev = 0;
    ll s = 0;
    ll c = 0;
    for(auto e : memo){
        if(e.second.second < m){
            s = e.second.first;
            c = e.second.second;
            break;
        }
        prev = e.first;
    }
    s += (m-c) * prev;
    cout << s << endl;
    return 0;
}



Measured memory_bytes: 1792
import java.util.HashMap;
import java.util.Scanner;

public class Main {

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

		int N = sc.nextInt();

		HashMap<String, Integer> cards = new HashMap<String, Integer>();
		for (int i = 0; i < N; i++) {
			String S = sc.next();
			if (cards.containsKey(S)) {
				int value = cards.get(S);
				cards.put(S, ++value);
			} else {
				cards.put(S, 1);
			}
		}

		int M = sc.nextInt();
		for (int i = 0; i < M; i++) {
			String S = sc.next();
			if (cards.containsKey(S)) {
				int value = cards.get(S);
				cards.put(S, --value);
			}
		}

		int MAX =0;
		for (String str : cards.keySet()) {
			MAX=Math.max(cards.get(str),MAX);
		}

		System.out.println(MAX);

	}
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define MAXN 100010
int n,m,a[MAXN],ans[MAXN],res[MAXN],tmp[MAXN];
long long k;
int main(){
    scanf("%d",&n);
    for(int i=1;i<=n;++i)scanf("%d",a+i);
    for(int i=1;i<n;++i)ans[i]=i;
    scanf("%d%lld",&m,&k);
    for(int i=1;i<=m;++i){
        int x;
        scanf("%d",&x);
        swap(ans[x],ans[x-1]);
    }
    for(int i=1;i<n;++i)res[i]=i;
    while(k){
        if(k&1)
            for(int i=1;i<n;++i)res[i]=ans[res[i]];
        for(int i=1;i<n;++i)tmp[i]=ans[ans[i]];
        for(int i=1;i<n;++i)ans[i]=tmp[i];
        k>>=1;
    }
    long long sum=a[1];
    for(int i=1;i<=n;++i){
        printf("%lld.0\n",sum);
        sum+=a[res[i]+1]-a[res[i]];
    }
}

Measured memory_bytes: 3072
#include<iostream>
#include<cstdio>
#include<cstring>
#define N 500010
using namespace std;
int len;
char str[N],suf[N];
void make_nxt(int nxt[],char s[])
{
	nxt[0]=-1;
	int f=0;
	for(int i=1;i<len;i++)
	{
		while(f && s[i]!=s[f]) f=nxt[f];
		if(s[i]==s[f]) nxt[i+1]=++f;
		else nxt[i+1]=0;
	}
}
bool no_rep(int nxt[],int p){return nxt[p]==0 || p%(p-nxt[p]);}
int pre[N],nxt[N];
int main()
{
	scanf("%s",str);
	len=strlen(str);
	for(int i=0;i<len;i++) suf[i]=str[len-i-1];
	suf[len]='\0';
	make_nxt(pre,str);
	make_nxt(nxt,suf);
	if(no_rep(pre,len)){puts("1\n1");return 0;}
	bool same=true;
	for(int i=1;i<len;i++) if(str[i]!=str[i-1]) same=false;
	if(same){printf("%d\n1\n",len);return 0;}
	puts("2");
	int ans=0;
	for(int i=0;i<len;i++)
	if(no_rep(pre,i+1) && no_rep(nxt,len-i-1))ans++;
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 5120
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 1000000010
#define EPS 1e-9
#define fst first
#define scd second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  int a,b;
  int ans[3]={1,1,1};
  cin>>a>>b;
  ans[a-1]=0;
  ans[b-1]=0;
  rep(i,3){
    if(ans[i]==1) cout<<i+1<<endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

struct Node {
    int key;
    Node *left;
    Node *right;
};

Node *root, *NIL;

Node* newNode(int key) {
    Node *node = new Node();
    node->key = key;
    node->left = NIL;
    node->right = NIL;
    return node;
}

void insert(int key) {
    Node *x = root, *y = NIL;
    while (x != NIL) {
        y = x;
        if (key < x->key)
            x = x->left;
        else
            x = x->right;
    }
    Node *z = newNode(key);
    if (y == NIL)
        root = z;
    else if (key < y->key)
        y->left = z;
    else
        y->right = z;
}

void inorder(Node *t) {
    if (t == NIL)
        return;
    inorder(t->left);
    cout << " " << t->key;
    inorder(t->right);
}

void preorder(Node *t) {
    if (t == NIL)
        return;
    cout << " " << t->key;
    preorder(t->left);
    preorder(t->right);
}

int main() {
    int n, v;
    string s;
    root = NIL;
    cin >> n;
    while (n--) {
        cin >> s;
        if (s == "insert") {
            cin >> v;
            insert(v);
        }
        if (s == "print") {
            inorder(root);
            cout << endl;
            preorder(root);
            cout << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 18744
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cassert>
#define InfL 1000000000
#define InfLL 1000000000000000000LL
#define mod 1000000007
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rrep(i,n) for(int (i)=(n-1);(i)>=(0);(i)--)
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<db> vd;

int main() {
	int N;
	cin >> N;
	vl A(N + 1);
	rep(i, N + 1) {
		cin >> A[i];
	}
	vl Atop(N + 1);
	vl Abottom(N + 1);
	Atop[0] = 1;
	Abottom[N] = A[N];
	rep(i, N) {
		Atop[i + 1] = (Atop[i] - A[i]) * 2;
		Atop[i + 1] = min(Atop[i + 1], InfLL);
	}
	rrep(i, N) {
		Abottom[i] = Abottom[i + 1] + A[i];
	}
	ll ans = 0;
	ll cnt = A[N];
	bool b2 = true;
	rrep(i, N) {
		if (cnt % 2 == 1)
			b2 = false;
		cnt /= 2;
		cnt += A[i];
	}
	if (cnt > 1 || (cnt == 1 && !b2)) {
		ans = -1;
	}
	else {
		rep(i, N + 1) {
			ans += min(Atop[i], Abottom[i]);
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 5636
#include<bits/stdc++.h>
#define endl '\n'
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define mod 10000007
#define FASTIO ios::sync_with_stdio(0); cin.tie(0);
#define REP(i,a,b) for(ll i=a;i<b;i++)

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;

int main() {
    FASTIO
    int n,ans;
    cin>>n;
    ans=n%1000;
    if(ans==0) cout<<0<<endl;
    else cout<<1000-ans<<endl;
    return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define mod 1000000007
#define pb emplace_back
#define mp make_pair
#define fi first
#define sec second
typedef long long ll;
typedef long double  ld;
#define pii pair<ll,ll> 
#define vi vector< ll > 
#define vvi vector< vi > 
#define vpi vector< pii > 
#define vvpi vector< vpi > 
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define test(t) ll t;cin>>t;while(t--)
#define mem(a,b) memset(a,b,sizeof(a))
#define inn freopen("input.txt", "r", stdin)
#define outt freopen("output.txt", "w", stdout)
#define all(arr) arr.begin(),arr.end()
#define fr(i,n) for(ll i=0;i<(n);++i)
#define rep(i,a,b) for(ll i=a;i<=b;++i)
#define per(i,a,b) for(ll i=a;i>=b;i--)
#define remin(a,b) (a=min((a),(b)))
#define remax(a,b) (a=max((a),(b)))
#ifndef ONLINE_JUDGE
#define debarr(a,n)cerr<<#a<<":";for(int i=0;i<n;i++)cerr<<a[i]<<" ";cerr<<endl;
#define debmat(mat,row,col)cerr<<#mat<<":\n";for(int i=0;i<row;i++){for(int j=0;j<col;j++)cerr<<mat[i][j]<<" ";cerr<<endl;}
#define pr(...)dbs(#__VA_ARGS__,__VA_ARGS__)
template<class S,class T>ostream &operator<<(ostream &os,const pair<S,T> &p){return os<<"("<<p.first<<","<<p.second<<")";}
template<class T>ostream &operator<<(ostream &os,const vector<T> &p){os<<"[";for(auto&it:p)os<<it<<" ";return os<<"]";}
template<class T>ostream &operator<<(ostream &os,const set<T>&p){os<<"[";for(auto&it:p)os<<it<<" ";return os<<"]";}
template<class T>ostream &operator<<(ostream &os,const multiset<T>&p){os<<"[";for(auto&it:p)os<<it<<" ";return os<<"]";}
template<class S,class T>ostream &operator<<(ostream &os,const map<S,T>&p){os<<"[";for(auto&it:p)os<<it<<" ";return os<<"]";}
template<class T>void dbs(string str,T t){cerr<<str<<":"<<t<<"\n";}
template<class T,class...S>void dbs(string str,T t,S... s){int idx=str.find(',');cerr<<str.substr(0,idx)<<":"<<t<<",";dbs(str.substr(idx+1),s...);}
#else
#define pr(...){}
#define debarr(a,n){}
#define debmat(mat,row,col){}
#endif
ll power(ll x,ll y){ll res = 1;while(y){if(y&1) res = (res*x)%mod;y=y/2,x=(x*x)%mod;}return res%mod;}
signed main()
{
    fast;
    ll k,x;
    cin>>k>>x;
    if(k*500>=x)
        cout<<"Yes";
    else
        cout<<"No";
    
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <array>
#include <math.h>
#include <sstream>
typedef long long ll;
using namespace std;

int main(int argc, char const *argv[])
{
    string s;
    std::cin >> s;
    for (int i = 0; i < s.length()-1; i++) {
        if (s[i] == 'A' && s[i+1] == 'C') {
            std::cout << "Yes" << std::endl;
            return 0;
        }
    }
    std::cout << "No" << std::endl;
    return 0;
}

Measured memory_bytes: 256
import fractions
from functools import reduce

def gcd_list(num):
  return reduce(fractions.gcd,num)
  
n = int(input())
a = list(map(int,input().split()))
count = 0

gcd = gcd_list(a)
while gcd % 2 == 0:
  gcd = gcd / 2
  count += 1
print(count)

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

int cmpnum(const void*n1,const void*n2)
{
  return *(int*)n2-*(int*)n1;
}

int main()
{
  int n;
  int i,j;
  long long a[300001];
  long long t,sum=0;
  scanf("%d",&n);
  for(i=0;i<3*n;i++){
    scanf("%lld",&a[i]);
  }
  /*for(i=0;i<3*n;i++){
    for(j=i+1;j<3*n;j++){
      t=a[i];
      if(a[i]<a[j]){
        a[i]=a[j];
        a[j]=t;
      }
    }
  }*/
  qsort(a,3*n,sizeof(long long),cmpnum);
  for(i=0;i<2*n;i++){
    if(i%2==1){
      sum+=a[i];
    }
  }
  printf("%lld",sum);
  return 0;
}


Measured memory_bytes: 6248
#include <bits/stdc++.h>
#include <string>
#include <algorithm>
#include <string.h>
#include <ctype.h>
#include <math.h>
using namespace std;
 
int main(){
    
    int N,ans,y;
    string A,B,C;

    ans = 0;
    cin >> N>>A>>B>>C;

    for(int i=0;i<N;i++){
        y=0;
        if(B[i]!=A[i]){
            y+=1;
        }
        if(C[i]!=A[i]&&C[i]!=B[i]){
                y+=1;
        }
        ans+=y;
    }

    cout << ans;

    return 0;

}

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

int a[100001][3];
int dp[100001][3];

int main() {
	// your code goes here
	int n;
	cin>>n;
	//int a[n][3];
	for(int i = 0; i < n; i++)
	{
		for(int j = 0; j < 3; j++)
		{
			cin>>a[i][j];
		}
	}
	
	dp[0][0] = a[0][0];
	dp[0][1] = a[0][1];
	dp[0][2] = a[0][2];
	
	for(int day = 1 ; day < n; day++)
	{
		dp[day][0] =  a[day][0] + max(dp[day - 1][1], dp[day - 1][2]);
		dp[day][1] =  a[day][1] + max(dp[day - 1][0], dp[day - 1][2]);
		dp[day][2] =  a[day][2] + max(dp[day - 1][0], dp[day - 1][1]);
	}
	
	int answer = max(max(dp[n - 1][0], dp[n - 1][1]),dp[n - 1][2]);
	
	cout<<answer<<endl;
	
	return 0;
}

Measured memory_bytes: 5924
#include<stdio.h>
int main(void){
  int r,D,x,i;
  fscanf(stdin,"%d%d%d",&r,&D,&x);
  for(i=1;i<10;i++){
  	x=r*x-D;
    printf("%d\n",x);
  }
  x=r*x-D;
  printf("%d",x);
  return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<climits>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<numeric>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i = m; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a)  (a).rbegin(),(a).rend()
#define LL long long
template<class T> inline void chmax(T & a, T b) { if (a < b) { a = b; } }
template<class T> inline void chmin(T& a, T b) { if (a > b) { a = b; } }
template<class T> void print_vector(vector<T> vec) {
	cout << "[ ";
	for (int i = 0; i < vec.size(); i++) {
		cout << vec[i] << " ";
	}
	cout << "]" << endl;
}
template<class T> void print_pair_vector(vector<pair<T, T> > vec) {
	cout << "[ ";
	for (int i = 0; i < vec.size(); i++) {
		cout << "(" << vec[i].first << "," << vec[i].second << ") ";
	}
	cout << "]" << endl;
}

const LL LLINF = 1LL << 60;

int main(void) {
	LL N;
	cin >> N;
	LL max = 0;
	LL min = LLINF;

	for (int i = 0; i < N; i++){
		LL A;
		cin >> A;
		chmax(max, A);
		chmin(min, A);
	}

	cout << max - min << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
int main() {
	int d[4][3][10] = { 0 };
	int m, b, f, r, v, j, k, i;
	scanf("%d", &m);
	for (i = 0; i<m; i++) {
		scanf("%d %d %d %d", &b, &f, &r, &v);
		d[b-1][f-1][r-1] += v;
	}
	for (i = 0; i<4; i++) {
		for (j = 0; j<3; j++) {
			for (k = 0; k<10; k++)
				printf(" %d", d[i][j][k]);
			printf("\n");
		}
		if (i<3)
			printf("####################\n");
	}
}


Measured memory_bytes: 2072
main :: IO()
main = do
  inputs <- getContents
  let specs = takeWhile (/= [0, 0]) $ [ map (\x -> read x ::Int) ws | ws <- map words $ lines inputs]
  mapM_ drawCheck specs


drawCheck :: [Int] -> IO ()
drawCheck [h, w] = do
  mapM_ (\x -> drawNthLine x w) [1..h]
  putStrLn ""

drawNthLine :: Int -> Int-> IO ()
drawNthLine n w = do
  let [e, o] = case even n of {True -> ['.', '#']; False -> ['#','.']}
  putStrLn $ map (\x -> case even x of {True -> o; False -> e}) [1..w]

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

int main() {
	vector<int> vec(3);
	for (int i = 0; i < 3; i++)
		cin >> vec.at(i);
	sort(vec.begin(), vec.end());
	if (vec.at(0) == vec.at(1) || vec.at(1) == vec.at(2)) {
		if (vec.at(0) == vec.at(2))
			cout << "No" << endl;
		else
			cout << "Yes" << endl;
	}
	else
		cout << "No" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h> 
#define REP(i, b) for(int i = 0; i < (b); i++)
#define REPS(i, b) for(int i = 1; i <= (b); i++)
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vb = vector<bool>;
const int INF = 1e9;
const ll MOD = 1e9+7;

ll modpow(ll a, ll n)
{
    ll res = 1;
    while(n > 0)
    {
        if(1 & n)
        {
            res *= a;
            res %= MOD;
        }
        n >>= 1;
        a *= a;
        a %= MOD;
    }
    return res % MOD;
}

signed main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    
    const ll MAX = 2*100010;
    ll n, a, b; cin >> n >> a >> b; 
    if(n == 2)
    {
        cout << 0 << endl;
        return 0;
    }
    vl fac(MAX+1); fac[0] = fac[1] = 1;
    vl finv(MAX+1); finv[0] = finv[1] = 1;
    vl inv(MAX+1); inv[1] = 1;
    for(ll i = 2; i <= MAX; i++) 
    {
        fac[i] = i * fac[i-1] % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i-1] * inv[i] % MOD;
    }
    ll t1 = 1, t2 = 1;
    for(ll i = n-a+1; i <= n; i++) t1 = (t1 * i) % MOD; t1 = (t1 * finv[a]) % MOD;
    for(ll i = n-b+1; i <= n; i++) t2 = (t2 * i) % MOD; t2 = (t2 * finv[b]) % MOD;
    ll ans = modpow(2, n) % MOD - 1 - t1 % MOD - t2 % MOD;
    ans %= MOD;
    if(ans < 0) cout << ans + MOD << endl;
    else cout << ans << endl;
}


Measured memory_bytes: 4992
#include<bits/stdc++.h>
//#include <boost/algorithm/string.hpp> 
using namespace std;
#define ll long long
#define ull unsigned long long
#define V vector<int>
#define VLL vector<ll>
#define VV vector<vector<ll>>
#define vec vector
#define P pair
#define scan(a) scanf("%d",&a)
#define print(a) printf("%d",a)
#define be(x) begin(x),end(x)
#define For(a) for(int i=0;i<a;i++)
#define Forin(j,a,b) for(int j=a;j<b;j++)
#define len(a) a.size()
#define pb push_back 
#define mp make_pair
#define Um unordered_map
#define Us unordered_set
#define F first
#define S second
#define mod 1000000007

void solve();
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie();
   
    
    solve();
    cout<<"\n";
return 0;
}
void solve()
{
    ll n;
    int b=0;
    cin>>n;
    int c=0;
    For(n){
        int x,y;
        cin>>x>>y;
        if(x==y)
            c++;
        else{
            c=0;
        }
        if(c==3)
            b=1;
            
    }
    if(b==1)    cout<<"Yes";
    else cout<<"No";
}

Measured memory_bytes: 3648
import java.util.*;
import static java.lang.Integer.*;
//import static java.lang.Long.*;
//import static java.lang.Math.*;
import static java.lang.System.*;

import java.io.PrintWriter;

public class Main {
	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(in);
		int h = parseInt(sc.next());
		int w = parseInt(sc.next());
		char[][] s = new char[h][w];
		for(i=0;i<h;i++) {
			s[i] = sc.next().toCharArray();
		}
		sc.close();
		char[][] a = new char[h+2][w+2];
		for(i=1;i< h+1;i++) {
			for (j = 1; j < w+1; j++) {
				a[i][j] = '0';
			}
		}
		for(i=1;i< h+1;i++) {
			for (j = 1; j < w+1; j++) {
				if(s[i-1][j-1]=='#') {
					a[i-1][j-1]++;
					a[i-1][j  ]++;
					a[i-1][j+1]++;
					a[i  ][j-1]++;
					a[i  ][j+1]++;
					a[i+1][j-1]++;
					a[i+1][j  ]++;
					a[i+1][j+1]++;
				}
			}
		}
		PrintWriter pw = new PrintWriter(out);
		for(i=1;i< h+1;i++) {
			for (j = 1; j < w+1; j++) {
				if(s[i-1][j-1]=='#') {
					pw.print('#');
				} else {
					pw.print(a[i][j]);
				}
			}
			pw.println();
		}
		pw.flush();
	}
}


Measured memory_bytes: 21076
// Template {{{
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0; i<(int)(n); ++i)
using namespace std;
typedef long long LL;

#ifdef LOCAL
#include "contest.h"
#else
#define dump(x) 
#endif

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
inline bool valid(int x, int w) { return 0 <= x && x < w; }

void iostream_init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.setf(ios::fixed);
    cout.precision(12);
}
//}}}

int main(){
    iostream_init();
    double a, b;
    cin >> a >> b;
    double c = 1.0/(1.0/a + 1.0/b);
    cout << c << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin >> s;
  int i;
  if(s=="SUN")i=7;
  if(s=="MON")i=6;
  if(s=="TUE")i=5;
  if(s=="WED")i=4;
  if(s=="THU")i=3;
  if(s=="FRI")i=2;
  if(s=="SAT")i=1;
  cout << i;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int GCD(int a, int b){
  return b?GCD(b,a%b):a;
}
int main(){
  int n;
  cin >> n;
  vector<int> x(n+1);
  for(int i=0;i<=n;i++){
    cin >> x[i];
  }
  sort(x.begin(),x.end());
  int ans=x[1]-x[0];
  for(int i=1;i<n;i++){
    ans=GCD(ans,x[i+1]-x[i]);
  }
  cout << ans << endl;
}

Measured memory_bytes: 640
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <iostream>
#include <utility>
#include <vector>
#include <list>
#include <algorithm>
using namespace std;

#define ll long long

int main()
{
    ll N;
    scanf("%lld", &N);
    vector<ll> L(N * 2);
    vector<ll> diff(N * 2, 0);
    for (ll i = 0; i < N * 2; i++)
        scanf("%lld", &L[i]);

    sort(L.begin(), L.end());

    ll sum1 = 0, sum2 = L[0];
    for (ll i = 1; i < N * 2; i++)
    {
        diff[i] = L[i] - L[i - 1];
        if (i % 2 == 1)
        {
            sum1 += L[i - 1];
        }
        else
        {
            sum2 += L[i - 1];
        }
    }
    ll ans = 0;

    printf("%lld\n", max(sum1, sum2));
}


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

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define repLRE(i, l, r) for (ll i = (l); i <= (r); ++i)
#define rrepLRE(i, l, r) for (ll i = (l); i >= (r); --i)
#define Sort(v) sort(v.begin(), v.end())
#define rSort(v) sort(v.rbegin(), v.rend())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

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

/* Macros reg. ends here */

const ll INF = 1LL << 50;

int main() {
  // ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);

  ll n, u, v;
  cin >> n >> u >> v;
  u--, v--;

  vvll to(n);
  rep(i, n - 1) {
    ll a, b;
    cin >> a >> b;
    a--, b--;
    to[a].emplace_back(b);
    to[b].emplace_back(a);
  }

  vll du(n, -1), dv(n, -1);
  queue<ll> que;
  que.push(u), du[u] = 0;
  while (!que.empty()) {
    ll x = que.front();
    que.pop();
    for (ll y : to[x]) {
      if (du[y] == -1) {
        du[y] = du[x] + 1;
        que.push(y);
      }
    }
  }
  que.push(v), dv[v] = 0;
  while (!que.empty()) {
    ll x = que.front();
    que.pop();
    for (ll y : to[x]) {
      if (dv[y] == -1) {
        dv[y] = dv[x] + 1;
        que.push(y);
      }
    }
  }

  ll tchbn = 0;
  rep(i, n) {
    if (dv[i] > du[i]) {
      chmax(tchbn, dv[i] - 1);
    }
  }
  cout << tchbn << endl;

  return 0;
}


Measured memory_bytes: 10908
# -*- coding: utf-8 -*-

N =int(input())
A = {}
for i in range(N):
    val = int(input())
    if val in A:
        A[val] += 1
    else:
        A[val] = 1

ans = 0
for k, v in A.items():
    if v % 2 != 0:
        ans += 1

print(ans)

Measured memory_bytes: 19292
#include <cstdio>
    #include <algorithm>
    #include <vector>
    using namespace std;
    vector<int> vec;
    int ar[200005],ans1,ans2;
    int main(){
    int n;
    scanf("%d",&n);
    for(int a=1;a<=n;++a){
        scanf("%d",&ar[a]);
        vec.push_back(ar[a]);
    }
    sort(vec.begin(),vec.end());
        int mid=n/2;
        ans1=vec[mid-1];
        ans2=vec[mid];
    for(int a=1;a<=n;++a){
        if(ar[a]<=ans1){
            printf("%d\n",ans2);
        }else{
            printf("%d\n",ans1);
        }
    }
    return 0;}


Measured memory_bytes: 3828
#include <bits/stdc++.h>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
 
using namespace std;
using vecint = vector<int>;

int main(){
    int x,a,b;
    cin >> x>> a>>b;
    cout << (x - a) % b << endl;
    
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC137A
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] AB = Console.ReadLine().Split(' ');
            int A = int.Parse(AB[0]);
            int B = int.Parse(AB[1]);
            Console.WriteLine(Math.Max(Math.Max(A + B, A - B), A * B));
        }
    }
}


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

using namespace std;
typedef long long ll;


int main()
{
	ll a,b;cin>>a>>b;
	
	
 	char c;cin>>c;
  int d;cin>>d;
  b*=100;b+=d;
  ll ans{a*b};
  ans/=100;
  cout<<ans<<"\n";
    return 0;
}

Measured memory_bytes: 3644
# ===========================素数判定 1:2以上の素数　,0：倍数    
def isPrime(x):
    if x < 2:
        return 0
    elif x == 2:
        return 1
    if x%2 == 0:
        return 0
    ir=int(x**(0.5))+1
    for i  in range(3,ir,2) :
        if x%i == 0:
            return 0
    return 1

x=int(input())

for i in range(x,10**5+4,1):
    if isPrime(i):
        print(i)
        break
    

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

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

    bool judge = true;
    if ( s.at(0) != 'A' ) judge = false;
    if ( s.find('C') != s.rfind('C') || !( s.find('C') >=2 && s.find('C') <= s.size()-2) ){
        judge = false;
    }
    int cnt = 0;
    for ( int i = 0 ; i < s.size(); i++ ){
        if ( islower(s.at(i))) cnt++;
    }
    if (cnt != s.size()-2 ) judge = false;

    string ans;
    if( judge ) ans = "AC";
    else ans = "WA";

    cout << ans << endl;
}


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

#define      pb    push_back
#define      ff    first
#define      ss    second
#define      ll    long long int
#define      endl  "\n"
#define      FASTIO        ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define      TEST    ll t ; cin >> t ; while( t -- )


//------------------------------------------------------------------------//

#define sc(a) scanf("%d",&a)
#define sc2(a,b) scanf("%d%d",&a,&b)
#define sc3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define sc4(a,b,c,d) scanf("%d%d%d%d",&a,&b,&c,&d)

//------------------------------------------------------------------------//

const ll big = 10e15 ;

int  main (  ) {

    FASTIO ;

    ll  n, k ;

    cin >> n >> k ;

    vector < ll > v( n + 2 ) ;

    for( int i = 1 ; i <= n ; i++ )
        cin >>  v[ i ] ;

    map < ll, int > mp ;

    ll step = 0, loop ;

    int p = 1 ;

    while( step < k ) {
        if( !mp[ p ] ) {
            step ++ ;
            mp[ p ] = step ;

            p = v[ p ] ;
        } else {
            loop = step - ( mp[ p ] - 1 ) ;
            break ;
        }
    }

   // cout << step << " " << p << " " << loop << endl ;

    if( step == k - 1 )
        cout << p ;
    else {

        k -= step ;

        ll baki = ( k % loop ) ;

       // cout << baki << endl ;

        step = 0 ;

        while( step < baki ) {
            p = v[ p ] ;
            step ++ ;
        }

        cout << p ;
    }


    return  0 ;
}


Measured memory_bytes: 14816
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<string>
#include<cstring>
#include<climits>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#include<list>
#include<unordered_map>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define lb lower_bound
#define pb push_back
#define mp make_pair
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define INF (1 << 30) - 1
#define LLINF (1LL << 61) - 1
// #define int ll
using namespace std;
const int MOD = 1000000007;
const int MAX = 510000;

int main(){
    ll n,m,p[100010],y[100010],a[100010];
    vector<pll> v[100010];
    cin>>n>>m;
    rep(i,m){
        cin>>p[i]>>y[i];
        v[p[i]].pb(pll(y[i],i));
    }
    rep(i,n+1){
        sort(all(v[i]));
    }
    rep(i,n+1){
        if(!v[i].empty()){
            rep(j,(ll)v[i].size()){
                a[v[i][j].second]=j+1;
            }
        }
    }
    rep(i,m){
        printf("%06lld%06lld\n",p[i],a[i]);
    }
    return 0;
}

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

#define REP(i,num) for(int i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

class ConnectNodeInfo{
	vector<vector<pair<ll,ll>>> graph;
public:
	ConnectNodeInfo(int node_num){
		graph.resize(node_num);
	}
	void AddNonDirectionalConnection(ll u,ll v,ll w){
		graph[u].emplace_back(v,w);
		graph[v].emplace_back(u,w);
	}
	void AddDirectionalConnection(ll u,ll v,ll w){
		graph[u].emplace_back(v,w);
	}
	vector<pair<ll,ll>>& operator[](ll index){
		return graph[index];
	}
	size_t size(){return graph.size();}
};

class WarshallFloyd{
	vector<vector<ll>> dist;
public:
	vector<vector<ll>> next;
	void CalcShortestPath(ConnectNodeInfo& connect){
		int V = connect.size();
		dist.resize(V,vector<ll>(V,1LL<<60));
		next.resize(V,vector<ll>(V,1LL<<60));

		REP(i,V){
			dist[i][i]=0;
			int U = connect[i].size();
			REP(j,U){
				dist[i][connect[i][j].first] = connect[i][j].second;
			}
			REP(j,V){
				next[i][j]=j;
			}
		}

		REP(k,V){
			REP(i,V){
				REP(j,V){
					if(dist[i][k]!=(1LL<<60) && dist[k][j]!=(1LL<<60)){
						if(dist[i][j]>dist[i][k] + dist[k][j]){
							dist[i][j] = dist[i][k] + dist[k][j];
							next[i][j] = next[i][k];
						}
					}
				}
			}
		}
	}
	bool HasNegativeLoop(){
		bool flag = false;
		for(int i=0,ei=dist.size();i<ei;i++){
			if(dist[i][i]<0){
				flag = true;
				break;
			}
		}
		return flag;
	}
	ll CalcDiameter(){
		ll diameter = -(1LL<<60);
		int V = dist.size();
		REP(i,V){
			REP(j,V){
				if(dist[i][j]<1LL<<60){
					diameter = max(diameter,dist[i][j]);
				}
			}
		}
		return diameter;
	}
	ll GetDistance(int i,int j){
		return dist[i][j];
	}
};

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	ll N=in(),M=in();
	ConnectNodeInfo connect(N);
	REP(i,M){
		ll u=in()-1,v=in()-1,w=in();
		connect.AddNonDirectionalConnection(u,v,w);
	}

	WarshallFloyd WF;
	WF.CalcShortestPath(connect);

	set<pair<int,int>> S;
	for(int i=0;i<N;i++){
		for(int j=0;j<N;j++){
			if(i==j) continue;
			for (int cur = i; cur != j; cur = WF.next[cur][j]){
				int u=cur,v=WF.next[cur][j];
				if(u>v) swap(u,v);
				S.emplace(u,v);
			}
		}
	}
	out(M-S.size());

	return 0;
}


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

long long K, N, r;

int main()
{
    cin>>K;
    if(K == 0){
        cout<<2<<endl<<1<<" "<<1<<endl;
    }
    else if(K % 50 == 0){
        N = K / 50;
        cout<<50<<endl;
        for(int i = 0; i < 50; i++) cout<<i + N<<" ";
    }
    else{
        N = K / 50;
        r = K % 50;
        cout<<50<<endl;
        for(int i = 0; i < 50 - r; i++) cout<<i + N<<" ";
        for(int i = 50 - r ; i < 50 - 1; i++) cout<<i + N + 1<<" "; cout<<N + 50<<endl;
    }
    return 0;
}


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

using namespace std;

using ll = long long;

int imos[201010];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, C;
    cin >> N >> C;
    for (int i = 0; i< N; i++) {
        int s, t, c;
        cin >> s >> t >> c;
        c--;
        s *= 2;
        t *= 2;
        imos[s - 1] ^= (1 << c);
        imos[t] ^= (1 << c);
    }

    int ans = __builtin_popcount(imos[0]);
    for (int i = 1; i <= 200500; i++) {
        imos[i] ^= imos[i - 1];
        ans = max(ans, __builtin_popcount(imos[i]));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1152
#!/usr/bin/env python3
from collections import Counter

d = {'AC': 0, 'WA': 0, 'TLE': 0, 'RE': 0}

N = int(input())
for _ in range(N):
    S = input()
    d[S] += 1

for k, v in d.items():
    print(f"{k} x {v}")


Measured memory_bytes: 9504
// AtCoder.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

// AtCoder.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//


#define _USE_MATH_DEFINES
#include<math.h>

//#include<cmath>

#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
#include<memory>



//#include "Ants.h"
using namespace std;
typedef long long ll;
#define rad_to_deg(rad) (((rad)/2/M_PI)*360)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i,n) for(int i=0;i<n;i++)
#define show(s) cout<<s<<endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define LINF (1000000000000000000ll)

//typedef pair < int, int> P;
ll gcd(ll a, ll b) {//最大公約数を求める///最大公倍数a*b/gcd(a,b)
	if (b == 0) return a;
	return gcd(b, a % b);
}

ll lcd(ll a, ll b) {//最小公倍数を求める　b=0のときaを返す
	if (b == 0) return a;
	return (a / gcd(a, b)) * b;
}
vector<int> calc(ll num) {
	int dig;
	vector<int>p;
	while (num) {
		dig = num % 10;
		p.push_back(dig);
		num /= 10;
	}
	return p;
}
int A[100000];
int N;
int main()
{
	cin >> N;
	bool flag = true;
	rep(i, N) {
		cin >> A[i];

		if (A[i] % 2 == 0) {
			if (A[i] % 3 == 0 || A[i] % 5 == 0) {

			}
			else {
				flag = false;
			}
		}
	}
	if (flag) {
		cout << "APPROVED" << endl;
	}
	else {
		cout << "DENIED" << endl;
	}
}

Measured memory_bytes: 256