akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
*this << "[";
for (auto it = d.b; it != d.e; ++it)
*this << ", " + 2 * (it == d.b) << *it;
ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define cool ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int  long long int
#define pb push_back
#define fe first
#define lb lower_bound 
#define ub upper_bound
#define pii pair<pair<int,int>,pair<int,int> >
#define se second
#define endl "\n"
#define pi pair<int, int>
#define mi          map<int,int>
#define mii         map<pi,int>
#define vi vector<int> 
#define vvi vector<vi>
#define bs   binary_search
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rep1(i,a,b) for(int i=a;i<=b;i++)	
#define all(c) (c).begin(),(c).end()
#define sz(x)       (int)x.size() 
#define PI 3.14159265358979323846

 const int N=1e6+5;

 int mod= 1e9+7;
 int dx[4]={0,0,+1,-1};
 int dy[4]={+1,-1,0,0};  
 
 
int po(int a, int b) {
	a %= mod;
	int res = 1;
	while (b > 0) {
		if (b & 1)
			res = (res * a) % mod;
		a =(a*a) % mod;
		b >>= 1;
	}
	 return res;	
  }
  
 	
void solve() {
      int x,k,d;
      cin>>x>>k>>d;
      x=abs(x);
      int td=x/d;
      int ans=0;
      if(k<=td) {
		     ans=x-(k*d);
		     cout<<ans<<endl;
		     return;
		  }
	  else {
		    k-=td;
		    x-=td*d;
		    if(k%2==0) {
				  cout<<x<<endl;
				}
			else {
				   int vl1=abs(x-d);
				   int vl2=abs(x+d);
				   ans=min(vl1,vl2);
				   cout<<ans<<endl;	   
				}	
		  }	  
     
                       
}

    
int32_t main() {
	cool;
	int t=1;	
  
	//cin>>t;
	while(t--)
	  solve();

  return 0;	   
}


Measured memory_bytes: 3664
n = int(input())
q = list(map(int,input().split()))
ans = 0
count = 0
for i in q:
    if i%2 == 0:
        alm = i
        count += 1
        if alm%3 == 0 or alm%5 == 0:
            ans += 1
if ans == count:
    print("APPROVED")
else:
    print("DENIED")

Measured memory_bytes: 9128
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;


int main(){
  ll K;
  cin >> K;

  ll a = (K + 50 - 1) / 50;
  vector<ll> v;
  rep(i,50) v.push_back(50+a-i-1);
  if(K%50 != 0){
    rep(i,50-(K%50)){
      v[i] -= 50;
      rep(j,50){
        if(i!=j) v[j]++;
      }
    }
  }

  cout << 50 << endl;
  rep(i,50){
    if(i!=0) cout << " ";
    cout << v[i];
  }
  cout << endl;
  
  return 0;
}


Measured memory_bytes: 256
/* 
	Author: ankrypt
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int
#define ff first
#define ss second
#define all(x) x.begin(), x.end() 
#define ub upper_bound
#define lb lower_bound
#define MAX_INT 15
#define fi(a, b, c, d) for(int a = b; i < c; i += d)
#define fl(a, b, c, d) for(ll a = b; i < c; i += d)

ll N, M, A, B, C;
ll arr[MAX_INT], arr1[MAX_INT], data[MAX_INT];
vector<ll> V;


int main() {
	scanf("%lld %lld", &N, &M);
	if(!(N % M)) {
		printf("0\n");
	}
	else {
		printf("1\n");
	}
}
/*
	Powered by Buggy Plugin
*/




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

int H, W;
char S[2020][2020];
int L[2020][2020];
int R[2020][2020];
int U[2020][2020];
int D[2020][2020];

int main(void){
    cin >> H >> W;
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            cin >> S[i][j];
        }
    }
    
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            if(S[i][j] == '#') {
                L[i][j] = 0;
            } else {
                if(j==0) L[i][j] = 1;
                else L[i][j] = L[i][j-1] + 1;
            }
        }
        
        for(int j = W-1; j >= 0; j--){
            if(S[i][j] == '#') {
                R[i][j] = 0;
            } else{
                if(j==W-1) R[i][j] = 1;
                else R[i][j] = R[i][j+1] + 1;
            }
        }
    }
    
    
    for(int j = 0; j < W; j++){
        for(int i = 0; i < H; i++){
            if(S[i][j] == '#') D[i][j] = 0;
            else {
                if(i==0) D[i][j] = 1;
                else D[i][j] = D[i-1][j] + 1;
            }
        }
        
        for(int i = H-1; i >= 0; i--){
            if(S[i][j] == '#') U[i][j] = 0;
            else {
                if(i==H-1) U[i][j] = 1;
                else U[i][j] = U[i+1][j] + 1;
            }
        }
    }
    
    int ans = 0;
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            if(S[i][j] == '#') continue;
            ans = max(ans, L[i][j] + R[i][j] + U[i][j] + D[i][j] - 3);
        }
    }
    
    cout << ans << endl;
}


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

int main(){
    int rahul;
    cin>>rahul;
    
    int arr[rahul];
    for (int i = 0; i < rahul; i++) {
        /* code */
        cin>>arr[i];
    }
    int count=0,count1=0;
    for (int i = 0; i < rahul; i++) {
        /* code */
        if(arr[i]%2==0){
            count++;
            if(arr[i]%3==0  or arr[i]%5==0){
               // cout<<"DENIED"<<endl;
                count1++;
            }
        }
        
    }
   if(count!=count1){
       cout<<"DENIED"<<endl;
   }
   else{
       cout<<"APPROVED"<<endl;
   }
}

Measured memory_bytes: 256
#include <iostream>

#include <vector>

#include <algorithm>

#include <cstdio>

#include <cmath>

#include <cstdlib>

#include <ctime>

#include <cctype>

#include <cstring>

#include <utility>

#include <map>

using namespace std;

typedef pair<int,int> P;

typedef long long ll;

int main()

{

    int n,k;

    cin>>n>>k;

    string s;

    cin>>s;

    int cnt=0;

    for(int i=0;i<n-1;i++)

    {

        if(s[i]==s[i+1])

            cnt++;

    }

 

    cout<<min(cnt+2*k,n-1)<<endl;

    return 0;

}

Measured memory_bytes: 512
import java.util.Scanner;

class Main{
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int ninzu=sc.nextInt();
		int[] march_count=new int[5];
		String moji="";
		for(int i=0; i<ninzu; i++) {
			moji=sc.next();
			if(moji.charAt(0)=='M') {
				march_count[0]++;
			}
			else if(moji.charAt(0)=='A') {
				march_count[1]++;
			}
			else if(moji.charAt(0)=='R') {
				march_count[2]++;
			}
			else if(moji.charAt(0)=='C') {
				march_count[3]++;
			}
			else if(moji.charAt(0)=='H') {
				march_count[4]++;
			}
		}
		//MARCHから選ぶとおりは5C3
		int[] sets=new int[10];
		int ks=0;
		for(int i=0; i<32; i++) {
			int counter=0;
			int tmp=i;
			while(tmp>0) {
				if(tmp%2==1) {
					counter++;
				}
				tmp=tmp/2;
			}
			if(counter==3) {
				sets[ks]=i;
				ks++;
			}
		}

		long toori=0l;
		long toori_tmp=0l;
		long[] aa=new long[5];
		long[] waru= {16,8,4,2,1};

		for(int i=0; i<10; i++) {
			toori_tmp=1l;
			for(int j=0; j<5; j++) {
				aa[j]=((sets[i]/waru[j])%2)*march_count[j];
				if((sets[i]/waru[j])%2==1) {
					toori_tmp*=aa[j];
				}
			}
			toori+=toori_tmp;
		}
		System.out.println(toori);
	}
}

Measured memory_bytes: 46460
s = input()
count1 = 0
count2 = 0
for i in range(0, len(s)):
    if(i%2 == 0):
        if(s[i] == "0"):
            count1 += 1
    if(i%2 == 1):
        if(s[i] == "1"):
            count1 += 1

for i in range(0, len(s)):
    if(i%2 == 0):
        if(s[i] == "1"):
            count2 += 1
    if(i%2 == 1):
        if(s[i] == "0"):
            count2 += 1    
print(min(count1,count2))

Measured memory_bytes: 3188
// D - Semi Common Multiple
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vl = vector<ll>;
#define rp(i,s,e) for(int i=(s);i<(e);++i)

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

ll f(ll x){
	ll c;
	for(c=0; !(x&1L); c++) x>>=1;
	return c;
}

ll solve(ll N, ll M, vl &A){

	// a/2 -> a'
	rp(i, 0, N){
		if(A[i]%2) return 0;
		A[i] /= 2;
	}

	// a'>>T -> a'' (T=f(a'_0))
	ll T = f(A[0]);
	for(int i=0; i<N; ++i){
		if(f(A[i]) != T) return 0;
		A[i] >>= T;
	}

	M >>= T;
	ll L = 1;
	for(ll a:A){
		L = lcm(L, a);
		if(L > M) return 0;
	}

	return (M/L+2-1)/2;//round up
}

int main(){
	ll N,M; cin>>N>>M;
	vl A(N); rp(i, 0, N) cin>>A[i];
	cout<< solve(N,M,A) <<endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template <typename Q_type>
using smaller_queue = priority_queue<Q_type, vector<Q_type>, greater<Q_type>>;

const int MOD_TYPE = 1;
const ll MOD = (MOD_TYPE == 1 ? (ll)(1e9 + 7) : 998244353);
const int INF = (int)1e9;
const ll LINF = (ll)4e18;
const double PI = acos(-1.0);

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define possible(n) cout << ((n) ? "possible" : "impossible") << endl
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << endl;

vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(50) << setiosflags(ios::fixed);
  int q;
  cin >> q;
  set<int> st;
  rep(qi, q)
  {
    int type;
    cin >> type;
    if (type == 0)
    {
      int x;
      cin >> x;
      st.insert(x);
      cout << st.size() << endl;
    }
    else
    {
      int x;
      cin >> x;
      cout << st.count(x) << endl;
    }
  }
  return 0;
}



Measured memory_bytes: 12492
import java.util.*;

public class Main {

  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int m = sc.nextInt();
    int count1 = 0;
    int count2 = 0;

    if (n>=2) {
      count1 = (n*(n-1)) / 2 ;
    }

    if (m>=2) {
      count2 = (m*(m-1)) / 2 ;
    }

    System.out.println(count1 + count2);

  }
}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mod 1000000007
#define MAX 100000
void inarray(int a[], int n){
    for(int i = 0; i < n; i++) cin >> a[i];
}

int main(){
    string a,b; cin >> a >> b;
    int x = stoi(a+b);
    if((int)sqrt(x)*(int)sqrt(x) == x) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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

using namespace std;

int main(void){

  int card[5];
  char ten;

  while( cin >> card[0] ){
    cin >> ten >> card[1] >> ten >> card[2] >> ten >> card[3] >> ten >> card[4];

    sort( card , card + 5 );

    if( card[4] == card[1] || card[3] == card[0] ){// four card
      cout << "four card" << endl;
      goto end;
    }

    if( (card[0] == card[2] && card[3] == card[4]) || (card[0] == card[1] && card[2] == card[4] ) ){
      cout << "full house" << endl;
      goto end;
    }

    int cnt;
    int r;
    cnt = 0;
    r = card[0];
    for( int i = 1 ; i < 5 ; i++ ){// straight
      if( r + 1 == card[i] ){
	cnt++;
	r = card[i];
      }
      else r = card[i];
    }
    if( cnt == 4 ){
      cout << "straight" << endl;
      goto end;
    }
    else if( card[0] == 1  && card[1] == 10 && card[2] == 11 && card[3] == 12 && card[4] == 13 ){
      cout << "straight" << endl;
      goto end;
    }

    if( card[0] == card[2] || card[1] == card[3] || card[2] == card[4] ){// three card
      cout << "three card" << endl;
      goto end;
    }

    if( card[0] == card[1] && card[2] == card[3] ){// two pair
      cout << "two pair" << endl;
      goto end;
    }
    else if( card[0] == card[1] && card[3] == card[4] ){
      cout << "two pair" << endl;
      goto end;
    }
    else if( card[1] == card[2] && card[3] == card[4] ){
      cout << "two pair" << endl;
      goto end;
    }

    for( int i = 0 ; i < 4 ; i++ ){// two card
      if( card[i] == card[i+1] ){
	cout << "one pair" << endl;
	goto end;
      }
     }

      cout << "null" << endl;

  end:;
  }
  return 0;
}

Measured memory_bytes: 1176
#include<bits/stdc++.h>
#pragma GCC optimize ("O3")
#define endl '\n'
using namespace std;
typedef long long int ll ;
const ll mod =1000000007;
ll pre[200005];
int main()
{
   ll a,b,c;
   cin>>a>>b>>c;
   a=a-b;
   cout<<max(0LL,c-a);
    
    
}

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

namespace AOJ
{
    class Program
    {
        static void Main(string[] args)
        {
            var lines = int.Parse(Console.ReadLine());
            var rots = int.Parse(Console.ReadLine());
            var dict = new Dictionary<int, int>();
            for (int i = 0; i < lines; i++)
            {
                dict[i] = i;
            }
            for (int i = 0; i < rots; i++)
            {
                string[] sa = Console.ReadLine().Split(',');
                int a = int.Parse(sa[0]) - 1;
                int b = int.Parse(sa[1]) - 1;

                var tmp = dict[a]; //swap
                dict[a] = dict[b];
                dict[b] = tmp;
            }
            for (int i = 0; i < lines; i++)
            {
                Console.WriteLine(dict[i]+1);
            }
        }
    }
}

Measured memory_bytes: 6124
#include<iostream>
#include<cstdio>
#include<complex>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;
typedef complex<double> point;

int main(){
	int n,cnt=0;
	double x,y;
	while(cin>>n,n){
		cnt++;
		point start,p[n-1];
		rep(i,n){
			cin>>x>>y;
			if(i==0)start=point(x,y);
			else p[i-1]=point(x,y)-start;
		}
		double sum=0;
		rep(i,n-2){
			sum+=imag(conj(p[i+1])*p[i])/2;
		}
		printf("%d %.1f\n",cnt,abs(sum));
	}
	return 0;
}

Measured memory_bytes: 1248
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
#include <stdio.h>
#include <string.h>
using ll = long long;

//LLONG_MAX
#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define LOWER_BOUND(v,a) (lower_bound((v).begin(), (v).end(), (a)))
#define UPPER_BOUND(v,a) (upper_bound((v).begin(), (v).end(), (a)))
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()
using namespace std;

int H, W, K;

int work[101][300][8];
bool flg[300];

const int O = 1000000007;
int add(int a, int b)
{
	return (a + b) % O;
}

void swap(int* a, int *b)
{
	int temp = *b;
	*b = *a;
	*a = temp;
}

signed main()
{
	cin >> H >> W >> K;

	int max = (1 << (W - 1));

	REP(i, max)
	{
		int a = i;
		int b = (i << 1);
		int c = (i >> 1);
		if (((a ^ b) == (a | b)) && ((a ^ c) == (a | c)))
		{
			flg[i] = true;
		}
	}

	work[0][0][0] = 1;

	for (int h = 1; h <= H; h++)
	{
		for (int j = 0; j < max; j++)
		{
			if (flg[j])
			{
				int w[8] = {};
				for (int k = 0; k < max; k++)
				{
					for (int l = 0; l < 8; l++)
					{
						w[l] = add(w[l], work[h - 1][k][l]);
					}
				}
				for (int m = 0; m < 7; m++)
				{
					if ((j & (1 << m)) > 0)
					{
						swap(w[m], w[m + 1]);
					}
				}
				for (int m = 0; m < 8; m++)
				{
					work[h][j][m] = add(w[m], work[h][j][m]);
				}
			}
		}
	}

	int ans = 0;
	for (int j = 0; j < max; j++)
	{
		ans = add(ans, work[H][j][K - 1]);
	}
	cout << ans << endl;
}








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

#define F first
#define S second
#define int long long
#define pb push_back
#define endl '\n'

using namespace std;

const int maxn = 1e+9 ; 
int n , W , w[101] , v[101] , dp[100001] , sum_value ; 
int32_t main()
{
	ios_base :: sync_with_stdio(false) ;
	cin.tie(0); cout.tie(0) ;
	cin >> n >> W ;
	for(int i = 0 ; i < n ; i++){
		cin >> w[i] >> v[i] ; 
		sum_value += v[i] ;
	}
	fill_n(dp , 100001 , maxn) ; 
	
	dp[0] = 0 ; 
	for(int i = 0 ; i < n ; i++){
		int weight = w[i] ;
		int value = v[i] ;
		for(int j = sum_value ; j >= value ; j--){
			dp[j] = min(dp[j] , dp[j - value] + weight) ; 
		}
	}

	for(int i = sum_value ; i >= 0 ; i--){
		if(dp[i] <= W){
			cout << i << endl ;
			return 0 ; 
		}
	}
	return 0 ;
		
}



Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define MAX 1000000007
using namespace std;

int main(void){
	int n;
	cin>>n;
	int ans=0;
	if(n/100 == 1)ans+=900;
	else ans+=100;
	
	if((n%100)/10 == 1)ans+=90;
	else ans+=10;

	if((n%10) == 1)ans+=9;
	else ans+=1;

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


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
  int i, j;
  int k, a, b;
  scanf("%d%d%d", &k, &a, &b);
  for(i = a; i <= b;i++){
    if(i % k == 0){
      printf("OK\n");
      return 0;
    }
  }
  printf("NG\n");
  
  return 0;
}

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

int main() {
  int n;
  cin>>n;
  vector<int> h(n), dp(n, 0);
  for(auto &e: h) cin>>e;
  dp[1] = abs(h[0] - h[1]);
  for(int i = 2; i<n; i++) {
    dp[i] = min(dp[i-1] + abs(h[i]-h[i-1]), dp[i-2] + abs(h[i] - h[i-2]));
  }
  cout<<dp[n-1]<<"\n";
}


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

using namespace std;

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

    vector<int> res(4, 0);
    for(int i=0; i<N; i++){
        string s;
        cin >> s;
        if(s == "AC")res.at(0)++;
        else if(s == "WA")res.at(1)++;
        else if(s == "TLE")res.at(2)++;
        else res.at(3)++;
    }

    cout << "AC x " << res.at(0) << endl;
    cout << "WA x " << res.at(1) << endl;
    cout << "TLE x " << res.at(2) << endl;
    cout << "RE x " << res.at(3) << endl;
}

Measured memory_bytes: 3624
n, k = [int(i) for i in input().split()]
a = [int(i)-1 for i in input().split()]

if k <= n:
    i = 0
    for _ in range(k):
        i = a[i]
    print(i + 1)
    exit()

visit = [False] * n
visit[0] = True
lon = [0] * n

i = 0
l = 0
while True:
    i = a[i]
    l += 1
    if visit[i]:
        break
    visit[i] = True
    lon[i] = l

kk = (k - lon[i]) % (l - lon[i])
for _ in range(kk):
    i = a[i]
print(i+1)


Measured memory_bytes: 32352
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(x) (x).begin(),(x).end()

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

typedef long long ll;

using namespace std;

template <class T>
struct dijkstra
{
  using P=pair<T,int>;
  priority_queue<P,vector<P>,greater<P>> q;
  vector<vector<P>>edge;
  vector<T>dist;
  int sz;
  dijkstra(int size){
    sz=size;
    edge.resize(size);
  }
  void reset(){
    dist.assign(sz,-1);
    q=priority_queue<P,vector<P>,greater<P>>();
  }
  void ae(int to,int from,T cost){
    edge[to].push_back({cost,from});
  }
  T cal(int start,int end){
    reset();
    q.push({0,start});
    while(!q.empty()){
      P tp=q.top();q.pop();
      if(dist[tp.second]!=-1)continue;
      dist[tp.second]=tp.first;
      for(P nn:edge[tp.second]){
        if(dist[nn.second]!=-1)continue;
        q.push({nn.first+tp.first,nn.second});
      }
    }
    return dist[end];
  }
  T getd(int end){
    return dist[end];
  }
};
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int x,y,xx,yy,n;
  cin>>x>>y>>xx>>yy>>n;
  using cd=complex<double>;
  using p=pair<cd,double>;

  cd s(x,y),t(xx,yy);
  dijkstra<double> dj(n+2);
  vector<p> cir(n+2);
  cir[0]={s,0};
  cir[n+1]={t,0};
  rep(i,n)
  {
    double x,y,r;
    cin>>x>>y>>r;
    cir[i+1]={(cd){x,y},r};
  }
  rep(i,n+2)repi(j,i+1,n+2)
  {
    double d;
    dj.ae(i,j,d=max(0.0,abs(cir[i].first-cir[j].first)-cir[i].second-cir[j].second));
    dj.ae(j,i,d);
  }
  cout<<setprecision(12)<<dj.cal(0,n+1)<<endl;

  return 0;

}


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

int main() {
	int n;
	cin >> n;
	int ans = 0;
	vector<int> fib = { 1,1 };
	if (n == 0) {
		cout << 1 << endl;
		return 0;
	}
	else if (n == 1) {
		cout << 1 << endl;
		return 0;
	}
	for (int i = 2; i <= n; i++) {
		fib.push_back(fib.at(i - 1) + fib.at(i - 2));
	}

	cout << fib.at(n) << endl;
}



Measured memory_bytes: 3156
#include <cstdio>
#include <algorithm>
#include <cstring>

using namespace std;

int main() {
  int i;
  int N, T;
  int A[100010], expensive[100010], diff[100010];
  scanf("%d %d", &N, &T);
  for (i = 0; i < N; i++) {
    scanf("%d", &A[i]);
  }
  expensive[N-1] = A[N-1];
  for (i = N-2; i >= 0; i--) {
    expensive[i] = max(expensive[i+1], A[i]);
  }
  int diffmax = 0;
  for (i = 0; i < N; i++) {
    diff[i] = expensive[i] - A[i];
  }
  sort(diff, diff + N);
  /*for (i = 0; i < N; i ++) {
    printf("%d ", diff[i]);
  }
  printf("\n");
  for (i = 0; i < N; i ++) {
    printf("%d ", expensive[i]);
    }*/
  diffmax = diff[N-1];
  int ans = 0;
  for (i = N-1; i >= 0; i--) {
    if (diff[i] == diffmax) {
      ans += 1;
    } else {
      break;
    }
  }
  printf("%d", ans); 
  return 0;
}


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

public class MainClass
{
	public const long Giri = 1000000007;
	
	public static void Main(string[] args)
	{
		var p = Input();
		var h = p[0].ToLong();
		var n = p[1].ToInt();
		var a = Input().ToInt();
		long wa = 0;
		for(int i = 0; i < n; i++)
		{
			wa += a[i];
		}
		Console.WriteLine(h - wa > 0 ? "No" : "Yes");
	}


	static long GCD(long a, long b)
	{
		var v = new[] { a, b };
		while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; }
		return v[0];
	}
	public static string[] Input() { return Console.ReadLine().Split(' '); }
	public static int Clamp(int val, int max, int min = 0) { return Math.Min(max, Math.Max(min, val)); }
}

public static class Smarter
{
	public static int ToInt(this string str) { return int.Parse(str); }
	public static long ToLong(this string str) { return long.Parse(str); }
	public static int[] ToInt(this string[] str)
	{
		var r = new int[str.Length];
		for(int i = 0; i < str.Length; i++) r[i] = str[i].ToInt();
		return r;
	 }
}


Measured memory_bytes: 15584
# AOJ 0160 Delivery Fee
# Python3 2018.6.18 bal4u


tbl = [ 600, 800, 1000, 1200, 1400, 1600 ]

while True:
	n = int(input())
	if n == 0: break
	fee = 0
	for i in range(n):
		x, y, h, w = list(map(int, input().split()))
		s = x+y+h
		if s <= 160 and w <= 25:
			k1 = k2 = 0
			if s <= 60: k1 = 0
			else: k1 = (s-61)//20 + 1
			if w <= 2: k2 = 0;
			else: k2 = (w-1)//5 + 1
			if k1 < k2: k1 = k2
			fee += tbl[k1]
	print(fee)


Measured memory_bytes: 5612
object Main {
  def main(args: Array[String]): Unit = {
    val s = new Main()
    s.solve()
    s.out.flush()
  }
}

class Main {
  import java.io._
  import java.util.StringTokenizer

  import scala.collection.mutable
  import scala.util.Sorting
  import math.{abs, max, min}
  import mutable.{ArrayBuffer, ListBuffer}
  import scala.reflect.ClassTag

  val MOD = 1000000007
  val out = new PrintWriter(System.out)

  def solve(): Unit = {
    val N, P = nl()

    var ans = 1L
    factorize(P) foreach { case (n, i) =>
      val d = (i / N).toInt
      REP(d) { _ =>
        ans *= n
      }
    }
    out.println(ans)
  }

  /**
    * *注意* IntをLongにして使わないこと
    */
  def factorize(n: Long): mutable.Map[Long, Int] = {
    import scala.collection.mutable
    val res = mutable.Map[Long, Int]() withDefaultValue 0

    def minFactor(n0: Long, rt: Int, i: Int): Long = {
      if (i > rt) n0 // √n まで見つからなかったら n0は素数か1
      else if (n0 % i == 0) i
      else minFactor(n0, rt, i + 1)
    }

    def step(n0: Long): Unit = {
      minFactor(n0, math.sqrt(n0).toInt, 2) match {
        case 1 =>
        case f =>
          res(f) = res(f) + 1
          step(n0 / f)
      }
    }

    step(n)
    res
  }

  class InputReader(val stream: InputStream) {
    private val reader = new BufferedReader(new InputStreamReader(stream), 32768)
    private var tokenizer: StringTokenizer = _

    def next(): String = {
      while (tokenizer == null || !tokenizer.hasMoreTokens)
        tokenizer = new StringTokenizer(reader.readLine)
      tokenizer.nextToken
    }

    def nextInt(): Int = next().toInt
    def nextLong(): Long = next().toLong
    def nextChar(): Char = next().charAt(0)
  }
  val sc = new InputReader(System.in)
  def ni(): Int = sc.nextInt()
  def nl(): Long = sc.nextLong()
  def nc(): Char = sc.nextChar()
  def ns(): String = sc.next()
  def ns(n: Int): Array[Char] = ns().toCharArray
  def na(n: Int, offset: Int = 0): Array[Int] = map(n)(_ => ni() + offset)
  def na2(n: Int, offset: Int = 0): (Array[Int], Array[Int]) = {
    val A1, A2 = Array.ofDim[Int](n)
    REP(n) { i =>
      A1(i) = ni() + offset
      A2(i) = ni() + offset
    }
    (A1, A2)
  }
  def nm(n: Int, m: Int): Array[Array[Int]] = {
    val A = Array.ofDim[Int](n, m)
    REP(n) { i =>
      REP(m) { j =>
        A(i)(j) = ni()
      }
    }
    A
  }
  def nal(n: Int): Array[Long] = map(n)(_ => nl())
  def nm_c(n: Int, m: Int): Array[Array[Char]] = map(n) (_ => ns(m))
  def REP(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {
    var i = offset
    val N = n + offset
    while(i < N) { f(i); i += 1 }
  }
  def REP_r(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {
    var i = n - 1 + offset
    while(i >= offset) { f(i); i -= 1 }
  }

  def map[A: ClassTag](n: Int, offset: Int = 0)(f: Int => A): Array[A] = {
    val res = Array.ofDim[A](n)
    REP(n)(i => res(i) = f(i + offset))
    res
  }


  def sumL(as: Array[Int]): Long = {
    var s = 0L
    REP(as.length)(i => s += as(i))
    s
  }

  def cumSum(as: Array[Int]) = {
    val cum = Array.ofDim[Long](as.length + 1)
    REP(as.length) { i =>
      cum(i + 1) = cum(i) + as(i)
    }
    cum
  }
}

Measured memory_bytes: 27056
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<n;++i)
#define rep1(i,n) for(ll i=1;i<=n;++i)
int main(){
  int a,b;
  cin>>a>>b;
  if(a<10&&b<10){
    cout<<a*b<<endl;
  }
  else{
    cout<<"-1"<<endl;
  }
  return 0;
}


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

int mtoi(string s){
	int sum=0;
	int co=1;
	for(int i=0;i<s.length();i++){
		if('1'<=s[i] && s[i]<='9'){co=s[i]-'0';}
		else if(s[i]=='m'){sum+=1000*co;co=1;}
		else if(s[i]=='c'){sum+= 100*co;co=1;}
		else if(s[i]=='x'){sum+=  10*co;co=1;}
		else if(s[i]=='i'){sum+=   1*co;co=1;}
	}
	return sum;
}

string itom(int m){
	string result="";
	int co;
	
	co=m/1000;
	if(co>=1){
		if(co!=1)result+=(co+'0');
		result+="m";
		m-=co*1000;
	}
	
	co=m/100;
	if(co>=1){
		if(co!=1)result+=(co+'0');
		result+="c";
		m-=co*100;
	}
	
	co=m/10;
	if(co>=1){
		if(co!=1)result+=(co+'0');
		result+="x";
		m-=co*10;
	}
	
	co=m;
	if(co>=1){
		if(co!=1)result+=(co+'0');
		result+="i";
		m-=co*1;
	}
	return result;
}

int main() {
	
	int n;
	scanf("%d",&n);
	
	for(int i=0;i<n;i++){
		string s1,s2;
		cin >> s1 >> s2;
		cout << itom(mtoi(s1)+mtoi(s2)) << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1236
#-*-coding:utf-8-*-
import sys
input=sys.stdin.readline

def ngram(numbers,n):
    return list([numbers[i:i+n] for i in range(len(numbers)-2)])

def main():
    numbers=[]
    n,m = map(int,input().split())
    [numbers.append(int(input())) for _ in range(n)]
    numbers.sort()
    print(min(numbers[i+m-1] - numbers[i] for i in range(n-m+1)))

if __name__=="__main__":
    main()

Measured memory_bytes: 13700
#include<stdio.h>
int main(void) {
	int n, m, i, j, player[1000] = {0}, count, num;

	while (1) {
		scanf("%d %d",&n,&m);
		if (n == 0 && m == 0) break;
		
		num = 0;
		count = 0;

		for (i = 0; i < n; i++)
			player[i] = i+1;

		i = 0;
			while(i<n){
			if (player[i] != 0)
				count++;

			if (count == m) {
				player[i] = 0;
				num++;
				count = 0;
			}
			if (num != n - 1) {
				if (i == n - 1)
					i = 0;
				else
					i++;
			}
			else
				break;
		}
			for (i = 0; i < n; i++) {
				if (player[i] != 0)
					printf("%d\n",player[i]);
			}
	}
	return 0;
}

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

using namespace std;

int main(int argc, char const *argv[])
{
	int n[4];
	vector<int> num = {1,9,7,4};
	cin >> n[0] >> n[1] >> n[2] >> n[3];

	for (int i = 0; i < 4; ++i) {
		num.erase(remove(num.begin(), num.end(), n[i]), num.end());
	}

	if (num.size()==0) cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pt;
#define x first
#define y second

pt operator+ (pt a, pt b) {
  return {a.x + b.x, a.y + b.y};
}

pt operator- (pt a) {
  return {-a.x, -a.y};
}

pt operator- (pt a, pt b) {
  return a + (-b);
}

ll dot (pt a, pt b) {
  return a.x * b.x + a.y * b.y;
}

ll cross (pt a, pt b) {
  return a.x * b.y - a.y * b.x;
}

ld norm (pt u) {
  return sqrt((ld) dot(u, u));
}

ld angle (pt a, pt o, pt b) {
  pt u = a - o;
  pt v = b - o;
  ld cosa = dot(u, v) / (norm(u) * norm(v));
  return acos(cosa);
}

bool cw (pt a, pt b, pt c) {
  return cross(b - a, c - a) < 0;
}

template<typename T>
T preback (const vector<T> &v) {
  return *next(v.rbegin());
}

const int MAX_N = 105;

ld ans [MAX_N];

int main () {
  ios::sync_with_stdio(false);

  int n;
  cin >> n;

  vector<pair<pt, int>> pts (n);
  for (int i = 0; i < n; i++) {
    cin >> pts[i].x.x >> pts[i].x.y;
    pts[i].y = i;
  }

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

  vector<pair<pt, int>> upper;
  for (int i = 0; i < n; i++) {
    while ((int) upper.size() >= 2 && !cw(preback(upper).x, upper.back().x, pts[i].x)) {
      upper.pop_back();
    }
    upper.push_back(pts[i]);
  }

  reverse(pts.begin(), pts.end());

  vector<pair<pt, int>> lower;
  for (int i = 0; i < n; i++) {
    while ((int) lower.size() >= 2 && !cw(preback(lower).x, lower.back().x, pts[i].x)) {
      lower.pop_back();
    }
    lower.push_back(pts[i]);
  }

  if (upper.back().y == lower[0].y) upper.pop_back();
  for (auto pr : lower) {
    upper.push_back(pr);
  }
  if (upper.back().y == upper[0].y) upper.pop_back();

  // upper is now the convex hull
  int k = upper.size();
  if (k == 2) {
    ans[upper[0].y] = 0.5;
    ans[upper[1].y] = 0.5;
  } else {
    for (int i = 0; i < k; i++) {
      ans[upper[i].y] = angle(upper[(i + k - 1) % k].x, upper[i].x, upper[(i + 1) % k].x);
      ans[upper[i].y] = (M_PI - ans[upper[i].y]) / (2 * M_PI);
    }
  }

  for (int i = 0; i < n; i++) {
    cout << fixed << setprecision(12) << ans[i] << '\n';
  }
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#define MAX 22

int main(void)
{
	int i, len;
	char temp[MAX];
	scanf("%s",temp);
	len = strlen(temp);
	for(i=len-1;i>=0;i--)
	{
		printf("%c",temp[i]);
	}
	printf("\n");
	return 0;
}

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

typedef vector<int> vi;
typedef pair<int,int> pii;
#define For(i,n) for(int i = 0; i < (int) n; ++i)
#define Rep(i,n) for(int i = 1; i <= (int) n; ++i)
#define ll long long
#define lld long double
#define F first
#define S second
#define pb push_back
#define endl "\n"
#define ar array
#define INF 1e18;
#define all(v) (v).begin(),(v).end()
const int N=2e5+1;


void solve(){
    string s,t;
    cin>>s>>t;
    int n=s.size();
    int n2=t.size();
    int ans=n2;
    for(int i=0;i<=n-n2;i++){
        int cur=0;
        for(int j=0;j<n2;j++){
            if(s[i+j]!=t[j]){
                cur+=1;
            }
        }
        ans=min(ans,cur);
    }
    cout<<ans<<endl;
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    int t;
    t=1;
    while(t--){
        //cout<<"Case #"<<a<<": ";
        solve();
        //a+=1;
    }
}


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

int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	int ans = 0;
	for (int i = 0;i <= 100;i++) {
		bool A = (a < i&&i <= b), B = (c < i&&i <= d);
		if (A&&B)ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#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 int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define VIN(v) for(auto&elem_: (v) )cin>>elem_
#define VOUT(v, sep) for(_loop_int idx=0; idx<(_loop_int)v.size(); idx++) {cout<<v[idx]; if(idx<v.size()-1) cout<<sep;} cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG2(x,y) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(debugidx,v.size())cout<<" "<<v[debugidx];cout<<endl
#define DEBUG_ARR(v,n) cout<<#v<<":";REP(debugidx,n)cout<<" "<<v[debugidx];cout<<endl

const ll MOD = 1000000007ll;
const int IINF = numeric_limits<int>::max()/2-1;
const ll LINF = numeric_limits<ll>::max()/2-1;

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

#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}

int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    int x,y;
    cin>>x>>y;
    int l = x*2;
    int r = x*4;
    for(; l<=r; l+=2){
        if(l==y){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    
    cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define PI 3.14159265358979

using namespace std;

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

  if ((n & 0x01) == 0)
    printf("0.5000000000\n");
  else
    printf("%.7lf\n", 1.0*(n + 1)/2/n);

  return 0;
}


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



using namespace std;

typedef vector<int> VI;
typedef vector<string> VS;


//container util
#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)



int main(void){

	int N; cin >> N;
	vector<int> x(N);
	vector<int> y(N);
	vector<int> h(N);
	REP(i,N) cin >> x[i] >> y[i] >> h[i];

	int MAX = 100;
	for(int posY = 0; posY <= MAX; posY++){
		for(int posX = 0; posX <= MAX; posX++){
			int needH = -1;

			REP(i,N){
				if(h[i] > 0){
					int tmp = h[i] + abs(posY - y[i]) + abs(posX - x[i]);
					if(needH == -1) needH = tmp;
					else{
						if(needH != tmp){
							needH = -2;
							break;
						}
					}
				}
			}

			if(needH == -2) continue;
			REP(i,N){
				if(h[i] == 0){
					int dist = abs(posY - y[i]) + abs(posX - x[i]);
					if(needH > dist){
						needH = -2;
						break;
					}

				}

			}
			if(needH == -2) continue;
			cout << posX << " " << posY << " " <<  needH << endl;

		}
	}



	return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}
#ifdef __LOCAL
#define debug(x) cerr << __LINE__ << ": " << #x << " = " << x << endl
#define debugArray(x, n)                           \
  cerr << __LINE__ << ": " << #x << " = {";        \
  for (long long hoge = 0; (hoge) < (n); ++(hoge)) \
    cerr << ((hoge) ? "," : "") << x[hoge];        \
  cerr << "}" << endl
#else
#define debug(x) (void(0))
#define debugArray(x, n) (void(0))
#endif

template <typename T>
struct BinaryIndexedTree {
  vector<T> dat;
  BinaryIndexedTree(int n) : dat(n + 1, 0) {}
  BinaryIndexedTree(int n, T a) : BinaryIndexedTree(vector<T>(n, a)) {}
  BinaryIndexedTree(vector<T> y) : dat(y.size() + 1) {
    for (int i = 0; i < y.size(); ++i) dat[i + 1] = y[i];
    for (int i = 1; i + (i & -i) < dat.size(); ++i) dat[i + (i & -i)] += dat[i];
  }
  void add(int i, T a = 1) {
    for (++i; i < (int)dat.size(); i += i & -i) dat[i] += a;
  }
  T sum(int i) {  // sum [0,i)
    T s = 0;
    for (; i > 0; i &= i - 1) s += dat[i];
    return s;
  }
  // min { i : sum(i+1) > k } -> kth element(0-indexed)
  int find(T k) const {
    int i = 0;
    for (int p = 1 << (__lg(dat.size() - 1) + 1); p > 0; p >>= 1)
      if (i + p < (int)dat.size() && dat[i + p] <= k) k -= dat[i += p];
    return i + 1 == (int)dat.size() ? -1 : i;  // -1 -> no solutions
  }
};

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  int X[N];
  for (int i = 0; i < N; i++) cin >> X[i];
  vector<int> v(X, X + N);
  sort(v.begin(), v.end());
  v.erase(unique(v.begin(), v.end()), v.end());
  auto id
      = [&](int x) { return lower_bound(v.begin(), v.end(), x) - v.begin(); };
  for (int i = 0; i < N; i++) X[i] = id(X[i]);
  BinaryIndexedTree<int> S(N);
  for (int i = 0; i < N; i++) S.add(X[i], 1);
  for (int i = 0; i < N; i++) {
    S.add(X[i], -1);
    cout << v[S.find(N / 2 - 1)] << '\n';
    S.add(X[i], 1);
  }
  return 0;
}


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

int main() {
    string s;
    int a, z;
    cin >> s;
    a = s.find('A');
    reverse(all(s));
    z = s.find('Z');
    int ans = (s.size() - z - a);
    printf("%d\n", ans);
    return 0;
}

//agarai3氏から ありがとう

Measured memory_bytes: 640
N = int(input())
A = [int(x) for x in input().split()]

dic = {}

for v in A:
  if v in dic: dic[v] += 1
  else: dic[v] = 1

P = 0
for v in dic.values():
  P += v*(v-1)//2

for x in A: print(P-dic[x]+1)


Measured memory_bytes: 26268
#include <stdio.h>
    #include <stdlib.h>
    #include <string.h>
     
    #include <iostream>
    #include <string>
    #include <vector>
    #include <map>
    #include <unordered_map>
    #include <queue>
    #include <algorithm>
     
    #include <bits/stdc++.h>
    #include <cmath>
    #include <limits>
     
    using namespace std;
     
    int main(int argc, char* argv[]){
    	cin.tie(0);
    	ios::sync_with_stdio(false);
     
    	long long A;
    	string S;
    	cin >> A >> S;
    	const char *s = S.c_str();
    	char *p = (char*) s;
    	p[1] = '\0';
    	int b1 = atoi(p);
    	p++; p++;
    	int b2 = atoi(p);
     
    	long long ans = A*b1;
    	ans += (A*b2)/100;
    	cout << ans << endl;
    	return 0;
    }

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

using namespace std;

#define YES cout << "YES" << endl;
#define NO  cout << "NO"  << endl;
#define Yes cout << "Yes" << endl;
#define No  cout << "No"  << endl;
 
#define INF INT_MAX
#define MOD 1000000007
#define PI  acos(-1)

using ll  = long long;
using ull = unsigned long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rrep(i, n) for (ll i = (n)-1; i >= 0; i--)

int main(int argc, char *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    int N, R;
    cin >> N >> R;

    if (N < 10) {
        cout << R + (10-N)*100 << endl;
    } else {
        cout << R << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <valarray>
#include <vector>

#define EPS 1e-9
#define INF 1070000000LL
#define MOD 1000000007LL
#define fir first
#define foreach(it,X) for(__typeof((X).begin()) it=(X).begin();it!=(X).end();it++)
#define ite iterator
#define mp make_pair
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define pb push_back
#define sec second
#define sz(x) ((int)x.size())

using namespace std;

struct timer{
	time_t start;
	timer(){start=clock();}
	~timer(){cerr<<1.*(clock()-start)/CLOCKS_PER_SEC<<" secs"<<endl;}
};

typedef istringstream iss;
typedef long long ll;
typedef pair<int,int> pi;
typedef stringstream sst;
typedef vector<int> vi;

string p;
int to0[]={1,-1,5,4,1,3};
int to1[]={4,2,3,1,-1,4};

int main(){
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	
	while(cin>>p && p!="#"){
		int cur=0;
		rep(i,sz(p)){
			if(p[i]=='0')cur=to0[cur];
			else cur=to1[cur];
			if(cur==-1)break;
		}
		cout<<(cur==3?"Yes":"No")<<endl;
	}
}

Measured memory_bytes: 1184
#include <stdio.h>
int main(){

  int n, i;
  int minv, maxv;
  int R[200000];

  scanf("%d",&n);

  for(i=0 ; i<n ; i++){
    scanf("%d",&R[i]);
  }
      
  maxv=R[1]-R[0];
  minv=R[0];
	
  for(i=1 ; i<n ; i++){
    if(R[i]-minv>maxv) maxv=R[i]-minv;
    if(R[i]<minv) minv=R[i];
  }
	 
  printf("%d\n",maxv);
	 
  return 0;
  
}



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

int main() {
    int N;
    long a;
    int min = log2(pow(10,9)) + 1;
    int i;
    int counter = 0;
    cin >> N;
    cin >> a;
    while(a % 2 == 0 && a > 0){
        counter += 1;
        a /= 2;
    }
    min = counter;
    for(i = 0;i < N - 1;i++) {
        counter = 0;
        cin >> a;
        while(a % 2 == 0 && a > 0){
            counter += 1;
            a /= 2;
        }
        if(counter < min) {
            min = counter;
        }
    }
    cout << min << endl;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() { 
  ios::sync_with_stdio(false); cin.tie(0);
  int n;
  cin >> n;
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    ans += x - 1;
  }
  cout << ans << endl;
  return 0;
}

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

using namespace std;

int main(){
    int n;
    cin >> n;
    vector<pair<string,int>> p(n);
    for(int i=0;i<n;i++){
        cin >> p[i].first >> p[i].second;
    }
    string x;
    cin >> x;
    int num=-1;
    for(int i=0;i<n;i++){
        if(p[i].first==x){
            num=i;
        }
    }
    if(num==n-1){
        cout << 0 << endl;
        return 0;
    }
    int ans=0;
    for(int i=num+1;i<n;i++){
        ans+=p[i].second;
    }
    cout << ans << endl;
}

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

int main(){
  int n,m,p;
  while(cin>>n>>m>>p && (n||m||p)){
    int c=0,w,x;
    for(int i=1;i<=n;i++){
      cin>>x;
      if(i==m) w=x;
      c+=x;
    }
    if(w==0) cout<<0<<endl;
    else cout<<c*(100-p)/w<<endl;
  }

  return 0;
}

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

int main(void){
    int H1, M1, H2, M2, K;
    cin >> H1 >> M1 >> H2 >> M2 >> K;
    int Hsa = H2-H1;
    int Msa = M2-M1;
    if (Msa < 0) {
        Msa = 60+Msa;
        Hsa--;
    }
    
    int t = Hsa * 60 + Msa;
    cout << t-K << endl;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = (int)(n); i >= 0; i--)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

ll N, n,m , M, K,a;

vector<ll> v,w;
int main(){
    cin >> N;
    vector<vector<int>> c(10);
    for(int i = 0; i <= 9; ++i){
      c[i].resize(10);
        for(int j = 0; j <= 9; ++j){
            for(int n = 1; n <= N;++n){
                if(n%10 == j && (int)(n / pow(10, (int)log10(n))) ==i) c[i][j] +=1;
            }
        }
    }
    int ans = 0;
    for(int i = 0; i <= 9; ++i){
        for(int j = 0; j <=9; ++j){
            ans +=c[i][j]*c[j][i];
        }
    }
    cout << ans;
    return 0;
}



Measured memory_bytes: 256
//
// Created by 李青坪 on 2018/11/4.
//

#include <cstdio>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>

#define MAXN 100001
#define NIL -1
using namespace std;

vector<int > compo[MAXN];
int group[MAXN];
queue<int> queue1;

void init(int n){
    fill(group, group+n, NIL);
    queue1 = queue<int>();
}

void query(int node, int color){
    queue1.push(node);
    group[node] = color;
    int ex;
    while (!queue1.empty()){
        ex = queue1.front();
        queue1.pop();
        for (auto comp: compo[ex]){
            if (group[comp] != NIL) continue;
            group[comp] = color;
            queue1.push(comp);
        }
    }
}

void partitionGroup(int n){
    int c = 0;
    for (int i = 0; i < n; ++i) {
        queue1 = queue<int>();
        if (group[i] == NIL) query(i, c++);
    }
}

int main(){
    int n, m;
    scanf("%d %d", &n, &m);
    int s, t;
    for (int i = 0; i < m; ++i) {
        scanf("%d %d", &s, &t);
        compo[s].push_back(t);
        compo[t].push_back(s);
    }
    init(n);
    partitionGroup(n);
    int q;
    scanf("%d", &q);
    for (int j = 0; j < q; ++j) {
        scanf("%d %d", &s, &t);
//        printf("%d", group[s]);
        if (group[s] == group[t]) printf("yes\n");
        else printf("no\n");
    }
}
/*
10 5
0 1
1 2
2 9
3 4
6 7
12
0 1
0 2
0 9
3 4
6 7
7 6
0 5
0 6
3 7
3 5
5 8
8 5
 */


Measured memory_bytes: 8432
//https://atcoder.jp/contests/abc161/tasks/abc161_a

import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int tmp;
		//箱に入っている整数の読み込み
		int box_a = sc.nextInt();
		int box_b = sc.nextInt();
		int box_c = sc.nextInt();
		
		tmp = box_a;
		box_a = box_b;
		box_b = tmp;
		
		tmp = box_a;
		box_a = box_c;
		box_c = tmp;
		
		System.out.println(box_a + " " + box_b + " " + box_c);
	}
	
	
// プリミティブ型の入れ替えの方法わからん。。。
// 	private static void _swap(Integer i1, Integer i2) {
// 		int tmp;
// 		
// 		tmp = i1.intValue();
// 		i1 = i2;
// 		i2 = tmp;
// 	}
}


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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; string S; cin >> N >> S;
    vector<int> a(N);
    int one=0,ans=0;
    for (int i=0;i<N;++i){
        a[i]=S[i]-'1';
        one|=(a[i]==1);
    }
    for (int i=0;i<N;++i) if (((N-1)&i)==i) ans^=(one?a[i]%2:a[i]/2);
    cout << ans*(one?1:2) << '\n';
}

Measured memory_bytes: 5276
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>

#define MOD 1000000007
#define INF (1ll<<60)
typedef long long ll;
using namespace std;

int x_1, y_1, x_2, y_2;

int main(){
    cin >> x_1 >> y_1 >> x_2 >> y_2;
    int x_3 = x_2 - (y_2-y_1);
    int y_3 = y_2 + (x_2-x_1);
    int x_4 = x_3 - (y_3-y_2);
    int y_4 = y_3 + (x_3 -x_2);
    cout << x_3  << " "<< y_3 << " " <<  x_4 << " "<< y_4 << endl;
}


Measured memory_bytes: 256