akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int s[] = new int[n];
		for (int i = 0; i < s.length; i++) {
			s[i] = scan.nextInt();
		}
		scan.close();
		float ans = 0;
		for (int i = 0; i < s.length; i++) {
			ans += 1 / (float) s[i];
		}
		
		System.out.println(1/ans);

	}
}

Measured memory_bytes: 21844
S=[input() for i in range(3)]
turn = 0
card=[0 for i in range(3)]
full=[len(S[i]) for i in range(3)]
while(True):
    if card[turn]==full[turn]:
        print(chr(turn+65))
        break
    t=S[turn][card[turn]]
    card[turn]+=1
    turn=ord(t)-97


Measured memory_bytes: 3060
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
#include <deque>
#include <numeric>

using namespace std;

#define mod 1000000007

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

Measured memory_bytes: 640
#include <iostream>

using namespace std;

int main(void)
{
    char num[4];
    int count = 0;

    cin >> num;

    for(int i = 0; i < 4; i++){
        if(num[i] == '2'){
            count++;
        }
    }

    cout << count << endl;

    return 0;
}


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

int main(){
    int n;
    cin >> n;
    ve<int> a(n),b(n),c(n);
    rep(i,n) cin >> a[i];
    rep(i,n) cin >> b[i];
    rep(i,n) cin >> c[i];
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    sort(c.begin(), c.end());
    ll ans=0;
    rep(i,n){
        ll memo;
        memo = lower_bound(a.begin(), a.end(), b[i]) - a.begin();
        memo *= n-(upper_bound(c.begin(), c.end(), b[i])-c.begin());
        ans += memo;
    }
    cout << ans << endl;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define ll unsigned long long
using namespace std;
int main(){
    int N;cin>>N;
    double ans=0;
    REP(i,N){
        int a;cin>>a;
        ans+=1.0/a;
    }
    printf("%0.10f",1.0/ans);
}

Measured memory_bytes: 256
n = int(input());
ac=wa=tle=re = 0;
for i in range(n) :
    s = input();
    if s == 'AC' :
        ac += 1;
    elif s == 'WA' :
        wa += 1;
    elif s == 'TLE' :
        tle += 1;
    else :
        re += 1;

print("AC x ",ac);
print("WA x ",wa);
print("TLE x ",tle);
print("RE x ",re);

Measured memory_bytes: 9212
def dfs(i, sum, count, nokori):
    global ans
    if i == d:
        if sum < g:
            use = max(nokori)

            n = min(pc[use - 1][0], -(-(g - sum) // (use * 100)))
            count += n
            sum += n * use * 100

        if sum >= g:
            ans = min(ans, count)
            
    else:
        dfs(i+1, sum, count, nokori)
        dfs(i+1, sum + pc[i][0] * (i+1) * 100 + pc[i][1], count + pc[i][0], nokori - {i + 1})


d, g = map(int, input().split())
pc = [list(map(int, input().split())) for i in range(d)]

ans = float("inf")

dfs(0, 0, 0, set(range(1, d+1)))
print(ans)

Measured memory_bytes: 9180
#pragma region
#include <bits/stdc++.h>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define reps(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; --i)
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define eb emplace_back
#define debug(x) cerr << #x << ": " << x << '\n'
#define INF 1e9
using namespace std;
template <class T = int>
T in()
{
  T x;
  cin >> x;
  return (x);
}

typedef long long ll;
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;
}

#pragma endregion

int main()
{
  int k = in();
  string s = in<string>();

  int sub = s.length() - k;
  if (sub <= 0)
  {
    cout << s << endl;
  }
  else
  {
    string ans = s.substr(0, k);
    string dots = "...";
    cout << ans << dots << endl;
  }
  return 0;
}


Measured memory_bytes: 3600
#include<stdio.h>
int main(){
    int A[3];
    int sum=0;
    for(int i=0;i<3;i++){
        scanf("%d",&A[i]);
    }
    for(int i=0;i<3;i++){
        sum=sum+A[i];
    }
    if(22<=sum){
        printf("bust\n");
    }else if(sum<=21){
        printf("win\n");
    }
}

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


int main(void){
    int n;
    cin >> n;
    vector<vector<pair<int, int>>> Graph(n+1);          // edgeId, adjacentVertexNo
    vector<int> edgeColor(n, -1);
    for (int i = 1; i <= n-1; i++){
        int a, b;
        cin >> a >> b;
        Graph.at(a).push_back(make_pair(i, b));
        Graph.at(b).push_back(make_pair(i, a));
    }
    
    int nUsedColors = 0;
    queue<int> searchVertex;
    vector<bool> isSearched(n+1, false);
    searchVertex.push(1);
    while( searchVertex.size() != 0 ) {
        int now = searchVertex.front();     searchVertex.pop();
        // 探索済みの頂点を除く
        if( isSearched.at(now) ){
            continue;
        }
        int nEdge = Graph.at(now).size();
        set<int> unusedColor;
        for (int i = 1; i <= nEdge; i++){
            unusedColor.insert(i);
        }
        // 既に使われている色を探す
        for( auto next : Graph.at(now) ){
            if ( edgeColor.at(next.first) != -1 ){
                unusedColor.erase( edgeColor.at(next.first) );
            }
        }
        // 着色
        for( auto next : Graph.at(now) ){
            if ( edgeColor.at(next.first) == -1 ){
                auto itr = unusedColor.begin();
                edgeColor.at(next.first) = *itr;
                unusedColor.erase(itr);
                searchVertex.push(next.second);
            }
        }
        nUsedColors = max(nUsedColors, nEdge);
        isSearched.at(now) = true;
    }

    cout << nUsedColors << endl;
    auto itr = edgeColor.begin();
    for ( itr++; itr != edgeColor.end(); itr++){
        cout << *itr << endl;
    }
    

    return 0;
}



Measured memory_bytes: 9780
#include<cstdio>
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;

string s[105];

int main(){
	int n,m;cin >> n >> m;
	for(int i = 1 ; i <= n ; i++)
		cin >> s[i];
	sort(s+1,s+1+n);
	for(int i = 1 ; i <= n ; i++)cout << s[i];
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define Khela ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long int
#define llu long long unsigned int
#define pf printf
#define sf scanf
#define f first
#define s second
#define pb push_back
#define mk make_pair
#define pii pair<int ,int>

int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[] = {0, 0, 1, -1};
int dy4[] = {1, -1, 0, 0};

typedef tree<pair<int,int>,null_type,less<pair<int,int>>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
int Set(int N,int pos){return N=N | (1<<pos);}
int reset(int N,int pos){return N= N & ~(1<<pos);}
bool check(int N,int pos){return (bool)(N & (1<<pos));}
const int Max=1e9+100;
const int sz=2e5+100;
int main()
{
    Khela
    int a,b,c,i,j,k,q,p,x,y,ct,ct1,m,l,r,x1,y1,mn,h,sum1,in,z,mid,n,mx;
    char ch;
    double d;
    string str1,str2,str;
    int t,cs;
    while(cin>>n)
    {
        ct=0;
        cin>>str;
        ++ct;
        for(i=1;i<n;i++){
            if(str[i]  != str[i-1]) ++ct;
        }
        cout<<ct<<endl;
    }


}


Measured memory_bytes: 512
#include <stdio.h>

int main(void)
{
  int a,b;
  scanf("%d %d", &a, &b);
  if (a + b == 15){
    printf("+");
  } else if (a * b == 15){
    printf("*");
  } else {
    printf("x");
  }
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <cstring>
#include <algorithm>

using namespace std;

bool dp[81][350][350];

int main(){
	int T;
	cin >> T;
	while(T--){
		int n;
		cin >> n;
		vector<int> e(n);
		for(int i = 0; i < n; ++i){ cin >> e[i]; }
		if(n <= 2){
			cout << e.back() << endl;
			continue;
		}
		memset(dp, 0, sizeof(dp));
		dp[1][e[0]][e[1]] = true;
		for(int i = 1; i + 1 < n; ++i){
			for(int j = 0; j < 350; ++j){
				for(int k = 0; k < 350; ++k){
					if(!dp[i][j][k]){ continue; }
					dp[i + 1][k][e[i + 1]] = true;
					if(k >= 1){
						dp[i + 1][k - 1][e[i + 1] + j] = true;
					}
				}
			}
		}
		int answer = 0;
		for(int i = 0; i < 350; ++i){
			for(int j = 0; j < 350; ++j){
				if(dp[n - 1][i][j]){ answer = max(answer, j); }
			}
		}
		cout << answer << endl;
	}
	return 0;
}

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

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

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef vector<vector<long long>> VVL;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

#define en "\n"

constexpr double EPS = 1e-9;
constexpr double PI  = 3.141592653589793238462643383279;
constexpr int INF = 2147483647;
constexpr long long LINF = 1LL<<60;
constexpr long long MOD = 1000000007; // 998244353

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

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

bool comp(P a, P b){
    if(a.first == b.first) return a.second > b.second;
    else return a < b;
}

int main(void){
    int N; cin >> N;
    int p=0,q=0;
    VI L(N), R(N);
    vector<P> v(N);
    int maxL = 0, minR = INF, maxd = 0;
    REP(i,N){
        cin >> L[i] >> R[i]; L[i]--;

        if(chmax(maxL, L[i])) p = i;
        else if(maxL == L[i] && R[i] < R[p]) p = i;

        if(chmin(minR, R[i])) q = i;
        else if(minR == R[i] && L[q] < L[i]) q = i;
    }

    REP(i,N){
        if(i == p || i == q) continue;
        chmax(maxd, R[i]-L[i]);
    }
    int ans = max(0, minR-maxL) + maxd;
    REP(i,N){
        v[i].first = max(R[i] - maxL, 0);
        v[i].second = max(minR - L[i], 0);
    }
    sort(ALL(v), comp);
    VI s(N-1,0), t(N-1,0);
    t[0] = v[0].second;
    REP(i,N-2){
        t[i+1] = min(t[i], v[i+1].second);
    }
    s[N-2] = v[N-1].first;
    REP(i,N-2){
        s[N-3-i] = min(s[N-2-i], v[N-2-i].first);
    }
    REP(i,N-1) chmax(ans, s[i]+t[i]);
    cout << ans << endl;
    return 0;
}

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

int main(){
    int N,x;
    cin >> N >> x;
    int a[N];
    for(int i=0; i<N; i++){
        cin >> a[i];
    }

    long long total = 0;
    for(int pairIndex=0; pairIndex<N-1; pairIndex++){
        int first = pairIndex;
        int second = pairIndex+1;
        if(a[first] > x){
            int diff = a[first] - x;
            a[first] -= diff;
            total += diff;
        }
        if(a[first] + a[second] > x){
            int diff = a[first] + a[second] - x;
            a[second] -= diff;
            total += diff;
        }
    }

    cout << total << '\n';
}

Measured memory_bytes: 3952
#include <bits/stdc++.h>
using namespace std;
 
int main(void) {
  vector<int> s(5);
  for (auto& tmp:s) {
    cin >> tmp;
  }
  int k; 
  cin>>k;
  if (s[4] - s[0] <= k) {
    cout << "Yay!" << endl;
  }else{ cout << ":(" << endl;}
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<iomanip>
#include <cmath>
#include <climits>
#include <algorithm>
#include <stdio.h>
#include <vector>
#include <queue>
#include <tuple>
#include <map>
#include <list>
#include <string>
#include <numeric>
#include <utility>
#include <cfloat>

using namespace std;

pair <long long , long long> ab_pair[100000];
int main(){
    int N;
    int M;
    cin >> N >> M;
    for(int i = 0; i < N; i++){
        int a;
        int b;
        cin >> a >> b;
        ab_pair[i] = make_pair(a, b);
    }

    sort(ab_pair, ab_pair + N);
    long long ans = 0;
    long long have_to_buy = M;
    for(int i = 0; i < N; i++){
        if(have_to_buy <= ab_pair[i].second){
            ans += ab_pair[i].first * have_to_buy;
            break;
        } else {
            ans += ab_pair[i].first * ab_pair[i].second;
            have_to_buy -= ab_pair[i].second;
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
    int s; cin>>s;
    vector<int> a(1e6,s);
    vector<int> com(1e6,0);
    int i=0,ans;

    while(1){
        if( a[i] % 2 == 0) a[i+1] = (a[i]/2);
        else if( (a[i] % 2) != 0) a[i+1] = (3*a[i] + 1);
        int v  = a[i];
        com[v]++;
        if(com[v] > 1){
            ans = i+1;
            break;
        }
        i++;
    }

    cout<<ans<<endl;

    return 0;    
}

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

int main(void){
    vector<vector<int>> bingo(3,vector<int>(3));
    for(int i=0;i<3;i++){
        for(int j=0;j<3;j++) cin >> bingo[i][j];
    }

    int n; 
    cin >> n;
    for(int i=0;i<n;i++){
        int a;
        cin >> a;
        for(int i=0;i<3;i++){
            for(int j=0;j<3;j++){
                if(a == bingo[i][j]) bingo[i][j] = -1;
            }
        }
    }

    bool clear=false;
    for(int i=0;i<3;i++){
        if(bingo[i][0]==bingo[i][1] && bingo[i][1]==bingo[i][2]) clear = true;
    }
    for(int j=0;j<3;j++){
        if(bingo[0][j]==bingo[1][j] && bingo[1][j]==bingo[2][j]) clear = true;
    }
    if(bingo[0][2]==bingo[1][1] && bingo[1][1]==bingo[2][0]) clear = true;
    if(bingo[0][0]==bingo[1][1] && bingo[1][1]==bingo[2][2]) clear = true;

    if(clear) cout << "Yes" << endl;
    else cout << "No" << endl;


}

Measured memory_bytes: 256
/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
public class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();//, b = sc.nextInt(), c=  sc.nextInt(), d = sc.nextInt();
		int sqrt = (int)Math.sqrt(a);
		List<Integer> list = new ArrayList<>();
		if(a<=3){
			System.out.println(1);return;	
		}
		for(int i=2;i<=sqrt;i++){
			for(int ii=2;;ii++){
				if(Math.pow(i,ii)<a){
					list.add((int)Math.pow(i,ii));
				} else if(Math.pow(i,ii)==a){
					list.add((int)Math.pow(i,ii));break;
				} else break;	
			}
		}
		Collections.sort(list);
		System.out.println(list.get(list.size()-1));
	}
}

Measured memory_bytes: 21844
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <queue>
using namespace std;

typedef struct{
	int x; //?????¨??????????¨???§?¨?
	int y; //?????¨??????????????§?¨?
	int turn; //???????????????????????°
	int f[20][20]; //?????£??????????????¶???
}info;

int main(){
	while(1){
		int w,h;
		info st; //????????¶???
		
		//input
		scanf(" %d %d", &w, &h);
		if(w==0) break;
		for(int i=0; i<h; ++i){
			for(int j=0; j<w; ++j){
				scanf(" %d", &st.f[i][j]);	
				if(st.f[i][j]==2){
					st.y=i;
					st.x=j;	
				}	
			}
		}
		st.turn=0;
		
		//?????????????????????
		int dx[4]={1,0,-1,0}, dy[4]={0,1,0,-1};
		
		int ans=-1;
		//BFS
		queue<info> que;
		que.push(st);
		while(!que.empty()){
			info p = que.front(); que.pop();
			
			//????????????????????????????????????
			for(int i=0; i<4; ++i){
				info v = p;
				
				//????????????????????¢??????????????§???????????????
				if(v.x+dx[i]<0 || v.x+dx[i]>=w) continue;
				if(v.y+dy[i]<0 || v.y+dy[i]>=h) continue;
				//?????????????????????????????£??\??????????????????????????????
				if(v.f[v.y+dy[i]][v.x+dx[i]] == 1) continue;
				
				//????????\?????????????????????????????????
				int nx=v.x, ny=v.y;
				for(int j=1; j<=20; ++j){
					nx=v.x+j*dx[i];
					ny=v.y+j*dy[i];
					
					//?????????
					if(nx<0||nx>=w) break;
					if(ny<0||ny>=h) break;
					
					if(v.f[ny][nx]==3){ //??´????????°???
						ans=v.turn+1;
						break;
					}
					else if(v.f[ny][nx]==1){ //?????????
						v.f[ny][nx]=0; //?????????????¶???????
						//?????????????????????
						nx-=dx[i]; 
						ny-=dy[i];
						v.x=nx;
						v.y=ny;
						v.turn++;
						if(v.turn<10) que.push(v);
						break;		
					}	
				}	
						
			}
			if(ans>0) break;	
		}
		
		printf("%d\n", ans);	
	}
}

Measured memory_bytes: 42764
#include <bits/stdc++.h>
#define ll long long
#define _for(a,b,i) for(int i=a;i<=b;i++)
#define for1(a,b,i) for(int i=a;i<b;i++)
using namespace std;
ll ma=0x80000000;
ll mi=0x7fffffff;
const ll zfc=0xffffffff;
const ll mod=1e9+7;
inline void input(ll &x)
{
    x=0;
    int f=1;
    char ch=getchar();
    while(!isdigit(ch))
	{
		if(ch=='-')f=-f;
		ch=getchar();
	}
    while(isdigit(ch))
	{
		x=x*10+(ch-'0');
		ch=getchar();
	}
    x*=f;
}
inline void output(ll x)
{
	if(x<0)
    {
        x=-x;
        putchar('-');
    }
    if(x/10>0)output(x/10);
    putchar(x%10+'0');
}
string st;
int main()
{
    cin>>st;
    if(st[0]=='Y'&&st[1]=='A'&&st[2]=='K'&&st[3]=='I')
    cout<<"Yes"<<endl;else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
int main(){
   int a,b;
   cin>>a>>b;
   int c = min(a,b);
   int d = max(a,b);
   if (c==1 &&d==2) cout << "3" <<endl;
   else if (c==1 &&d==3)  cout << "2" <<endl;
   else   cout << "1" <<endl;
}

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

void print(int n) {
    cout << n << endl;
}

int main() {
    string s;
    cin >> s;
    if (s == "SUN") print(7);
    else if (s == "MON") print(6);
    else if (s == "TUE") print(5);
    else if (s == "WED") print(4);
    else if (s == "THU") print(3);
    else if (s == "FRI") print(2);
    else if (s == "SAT") print(1);
}

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

const int inf = 1e9;
const ll linf = 1e18;

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

    int q; cin >> q;
    int l[q], r[q];
    for (int i = 0; i < q; i++) cin >> l[i] >> r[i];

    const int n = 100000;
    vector<bool> p(n + 1, true);
    p[0] = false, p[1] = false;
    for (int i = 2; i * i <= n; i++) {
        if (p[i]) {
            for (int j = i * i; j <= n; j += i) p[j] = false;
        }
    }

    vector<int> num;
    for (int i = 1; i <= 100000; i += 2) {
        if (p[i] && p[(i + 1) / 2]) num.push_back(i);
    }

    for (int i = 0; i < q; i++) {
        int x = upper_bound(num.begin(), num.end(), r[i]) - lower_bound(num.begin(), num.end(), l[i]);
        cout << x << endl;
    }
    return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
const long double PI = acos(-1);
typedef long long ll;
typedef pair<int64_t,int64_t> pll;
int dx[]={1,-1,0,0,1,-1,1,-1};
int dy[]={0,0,1,-1,1,-1,-1,1};
#define INF (2147483647)
#define mod (1000000007)
#define limit (7368791)
#define rep(i,a,b) for (int64_t i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define ALL(a) begin(a),end(a)
#define sz(s) (s).size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second

 
void solve()
{
    string a,b,c;cin>>a>>b>>c;
    if(a[a.size()-1]==b[0]&&b[b.size()-1]==c[0])cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPLL(i, n) for (ll i = 0; i < (ll)(n); i++)
using namespace std;
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;

ll N, K;
vector<ll> A;
vector<ll> F;

bool func(ll x){
  ll k = K;
  REPLL(i, N){
    k -= max(A[i]-x/F[i], 0LL);
    if(k < 0) return false;
  }
  return true;
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> N >> K;
  A.assign(N, 0);
  F.assign(N, 0);
  REP(i, N){
    cin >> A[i];
  }
  REP(i, N){
    cin >> F[i];
  }
  sort(A.begin(), A.end());
  sort(F.begin(), F.end(), greater<ll>());
  ll leftNG = -1;
  ll rightOK = 1e12+5;
  ll mid = (leftNG+rightOK)/2;
  while(rightOK - leftNG > 1){
    if(func(mid)){
      rightOK = mid;
    }else{
      leftNG = mid;
    }
    mid = (leftNG+rightOK)/2;
  }
  cout << rightOK << endl;
}

Measured memory_bytes: 3456
#include<stdio.h>
 
int main(){
	int a, b, n, step = 1;
	while(scanf("%d %d", &a, &b) != 0){
		if(a == 0 || b == 0) break;
		if(a <= b){
			n = a;
			a = b;
			b = n;
		}
		if(a % b == 0) n = b;
		while(a % b != 0){
			step++;
			if(a % b == 0){
				n = b;
				break;
			}
			a = a % b;
			n = a;
			a = b;
			b = n;
		}
		printf("%d %d\n", n, step);
		step = 1;
	}
	return 0;
}

Measured memory_bytes: 600
sx, sy, tx, ty = [int(i) for i in input().split()]

dx = tx - sx
dy = ty - sy

ans = 'U' * dy + 'R' * dx
ans += 'D' * dy + 'L' * dx
ans += 'L' + 'U' * (dy+1) + 'R' * (dx+1) + 'D'
ans += 'R' + 'D' * (dy+1) + 'L' * (dx+1) + 'U'

print(ans)


Measured memory_bytes: 3188
import sys
from bisect import bisect_left
from collections import defaultdict
def input(): return sys.stdin.readline().strip()

def main():
    H, W, N = map(int, input().split())
    black = []
    d = defaultdict(list)
    for _ in range(N):
        a, b = map(int, input().split())
        black.append((a - 1, b - 1))
        d[a - 1].append(b - 1)
    for key in d: d[key].sort()

    ans = [0] * 10
    checked = set()
    # (a, b)がテンプレートのどこにいるかで９通り試す
    for i in range(9):
        for a, b in black:
            h, w = a - i // 3, b - i % 3
            if (h, w) in checked: continue
            if h < 0 or w < 0: continue
            if h > H - 3 or w > W - 3: continue
            cnt = 0
            idx1 = bisect_left(d[h], w)
            idx2 = bisect_left(d[h], w + 3)
            cnt += idx2 - idx1
            idx1 = bisect_left(d[h + 1], w)
            idx2 = bisect_left(d[h + 1], w + 3)
            cnt += idx2 - idx1
            idx1 = bisect_left(d[h + 2], w)
            idx2 = bisect_left(d[h + 2], w + 3)
            cnt += idx2 - idx1
            #print("({}, {})=>{}".format(h, w, cnt))
            ans[cnt] += 1
            checked.add((h, w))
    ans[0] = (H - 2) * (W - 2) - sum(ans[1:])
    for a in ans: print(a)




if __name__ == "__main__":
    main()


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

using namespace std;

#define INF 100000000
#define YJ 1145141919
#define INF_INT_MAX 2147483647
#define INF_LL 9223372036854775
#define INF_LL_MAX 9223372036854775807
#define EPS 1e-10
#define MOD 1000000007
#define MOD9 998244353
#define Pi acos(-1)
#define LL long long
#define ULL unsigned long long
#define LD long double

#define int long long

using II = pair<int, int>;

int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }
int extgcd(int a, int b, int &x, int &y) { int g = a; x = 1; y = 0; if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x; return g; }

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(a)  begin((a)), end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())

const int MAX_N = 200005;
int N;
int A[MAX_N];

signed main()
{
  cin >> N;
  priority_queue<int> pq;
  REP(n,N) {
    cin >> A[n];
    pq.push(A[n]);
  }

  REP(n,N) {
    int k = pq.top();
    if(k != A[n]) {
      cout << k << endl;
      continue;
    }
    pq.pop();
    cout << pq.top() << endl;
    pq.push(k);
  }

  return 0;
}


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

using namespace std;

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

using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;

typedef pair<ll, ll> P;

#define bit(n) (1LL << (n))

//#define int long long

#define all(v) v.begin(), v.end()
#define sortAl(v) sort(all(v))
#define sortAlr(v)          \
  sort(v.begin(), v.end()); \
  reverse(v.begin(), v.end())

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

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

template <class T>
inline void chmax(T &a, T b) {
  a = std::max(a, b);
}
template <class T>
inline void chmin(T &a, T b) {
  a = std::min(a, b);
}

#define mod (ll)(1e9 + 7)
#define INF LLONG_MAX

bool is_large(const vll &a, const vll &b) {
  if (a[0] > b[0]) {
    return true;
  } else if (a[0] == b[0]) {
    for (int i = 9; i > 0; i--) {
      if (a[i] > b[i]) {
        return true;
      } else if (a[i] < b[i]) {
        return false;
      }
    }
  }
  return false;
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);

  ll n, m;
  cin >> n >> m;

  vll a(m);
  rep(i, m) {
    cin >> a[i];
  }

  ll need[10] = {0, 2, 5, 5, 4, 5, 6, 3, 7, 6};
  vvll dp(n + 10, vll(10));

  rep(i, n) {
    if (i == 0 || dp[i][0] != 0) {
      FORm(it, a) {
        ll v = *it;

        // compare
        vll candidate = dp[i];
        candidate[0]++;
        candidate[v]++;

        vll &target = dp[i + need[v]];
        if (is_large(candidate, target)) {
          target = candidate;
        }
      }
    }
  }

  auto ans = dp[n];
  for (int i = 9; i > 0; i--) {
    rep(j, ans[i]) {
      cout << i;
    }
  }

  cout << endl;

  return 0;
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
#define maxn 200005	
using namespace std;
int arr[maxn];
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int k,n;
	cin >> k >> n;
	for(int i=1;i<=n;i++)
		cin >> arr[i];
	int ans = k - (arr[1] + (k - arr[n]));
	for(int i=2;i<=n;i++)
		ans = min(ans,k - (arr[i] - arr[i-1]));
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#define ll long long int
#include <iomanip>

using namespace std;


int main(int argc, char const* argv[])
{
	int n, m, d;
	cin >> n >> m >> d;
	double p;
	if(d == 0){
			p = 1. / ((double)n) * (double)(m - 1);
	}else{
			p = ((2. * n - 2. * d) / (double(n) * n)) * (double)(m - 1);
	}
	cout << setprecision(12);
	cout << p << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(v) (v).begin(), (v).end()
typedef long long int lint;
using namespace std;

int main() {
    int n, m;
    cin >> n >> m;
    vector<vector<pair<int, int>>> data(n);
    for (int i = 0; i < m; i++) {
        int p, y;
        cin >> p >> y;
        p--;
        data[p].push_back(make_pair(y, i));
    }
    for (int i = 0; i < n; i++) {
        sort(all(data[i]));
    }
    vector<pair<int, int>> id(m);
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < data[i].size(); j++) {
            auto now = data[i][j];
            id[now.second] = make_pair(i + 1, j + 1);
        }
    }
    for (int i = 0; i < m; i++) {
        cout << setfill('0') << setw(6) << id[i].first << setw(6)
             << id[i].second << endl;
    }
}

Measured memory_bytes: 7808
s = int(input())
li = []
num = 0
for i in range(1000000):
    if i == 1:
        num = s
    elif num % 2 == 0:
        num //= 2
    else:
        num = 3 * num + 1
    li.append(num)
    if li.count(num) == 2:
        print(i)
        break

Measured memory_bytes: 3060
import sys
import numpy as np
from numba import njit#,i8


def input(): return sys.stdin.readline()

N,Q = map(int,input().split())

C=np.array(input().split(), int)

# Query取得-rightでソート
# dtypeQuery = [("index", int), ("start", int), ("end", int)]
queries=np.empty((Q,2),int)
# #rights=[[] for _ in range(N+1)]

for q in range(Q):
	l,r=map(int,input().split())
	#queries[q] = (q,l,r)
	queries[q][0] = l
	queries[q][1] = r
	#queries=np.sort(queries,order="end")

#queries=np.array(sys.stdin.buffer.read().split(),int).reshape(Q,2)

orderByR=np.argsort(queries[:,1])

# 各色の現在の一番右のindex
mostRightColorIndex = np.zeros(N+1, int)
# bit indexed tree
bitArray=np.zeros(N+1,int)

@njit(cache=True)
# @jit(返り値の型(引数1の型,引数2の型,．．．,引数nの型))
#@jit(i8[:](i8,i8,i8[:],i8[:,:],i8[:],i8[:],i8[:]))
def main(N,Q,C,queries,orderByR,mostRightColorIndex,bitArray):

	def add(itemCount, items, i, value):
		while i <= itemCount:
			items[i] += value
			i += (i & (-i))

	def sumFromStart(items, end):
		summary = 0
		i = end
		while i > 0:
			summary += items[i]
			i -= (i & (-i))
		return summary

	def sum(items, start,end):
		summary = sumFromStart(items, end) - sumFromStart(items, start-1)
		return summary

	# 答え配列
	#ans=np.zeros(Q, i8)#int)
	ans=[0]*Q
	# 左からBITと現在色の更新をしながら、クエリのrightに到達したときにBITにクエリ発行する
	qindex = 0

	for n in range(N):
		# 外側のループでは、全部の色をループ

		if Q <= qindex:
			break

		if 0 < mostRightColorIndex[C[n]]:
			# ループ中の場所の色のindexが既にある場合(=過去に、同じ色が登録されていた場合)
			# 今回で、同じ色の一番右側の要素はループ中の要素になる
			# 前登録したこの色の一番右のindexを一度BITから抜く(↓で再度登録される)
			add(N,bitArray,mostRightColorIndex[C[n]], -1 )

		# この要素の色の一番右のindexを、BITに登録
		mostRightColorIndex[C[n]] = n+1
		add(N,bitArray,n+1, 1)

		# while qindex < Q and n+1 == queries[qindex][2]:
		while qindex < Q and n+1 == queries[orderByR[qindex]][1]:
			# 今のBITが次のクエリ発行するための状態(n==query.right)だったら、クエリ発行
			tmpIndex = orderByR[qindex]
			start = queries[tmpIndex][0]
			end = queries[tmpIndex][1]
			ans[tmpIndex]=sum(bitArray,start,end)
			# print(tmpIndex,start,end,ans[tmpIndex])
			qindex += 1

	return ans

for a in main(N,Q,C,queries,orderByR,mostRightColorIndex,bitArray):
	print(a)


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

using namespace std;

int main() {
    int A, B, K;
    cin >> A >> B >> K;

    vector<int> factors;
    for (int i = 1; i <= min(A, B); i++)
    {
        if (A % i == 0 && B % i == 0)
        {
            factors.push_back(i);
        }
    }

    cout << factors[factors.size() - K];
}


Measured memory_bytes: 256
import java.util.*;
public class Main{
 
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		long N= sc.nextLong();
		long M=sc.nextLong();
		if(M<2l*N){
			long result=(M/2l);
			System.out.println(result);
		}else{
			long result=N+(M-2l*N)/4l;
			System.out.println(result);
				
		}
	}
}

Measured memory_bytes: 21844
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#define int long long
using namespace std;

int n, c, k;
int t[100000];

signed main() {
	int i;
	
	cin >> n >> c >> k;
	for (i = 0; i < n; i++) cin >> t[i];
	sort(t, t + n);
	
	int num = 0;	//今までに何人乗せたか？
	int ans = 0;	//バスの台数
	
	while (true) {
		int id = upper_bound(t + num, t + n, t[num] + k) - t;
		
		int ninzu = id - num;
		if (ninzu > c) ninzu = c;
		
		id = ninzu + num;
		
		ans++;
		num = id;
		
		if (num == n) {
			break;
		}
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll inf = 1e18;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define per(i, a, b) for (int i = b - 1; i >= a; i--)
#define int ll
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

signed main() {
    int n;
    cin >> n;
    rep(i, 0, n) {
        int a;
        cin >> a;
        if (a % 2 == 0) {
            if (a % 3 == 0 || a % 5 == 0) {
                continue;
            } else {
                cout << "DENIED\n";
                return 0;
            }
        }
    }
    cout << "APPROVED\n";
}


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

int n, t[10000], m, p[10000], x[10000], sum = 0;
int main() {
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> t[i];
        sum += t[i];
    }
    cin >> m;
    for (int j = 0; j < m; ++j) {
        cin >> p[j] >> x[j];
        cout << sum - (t[p[j]-1] - x[j]) << endl;
    }
    return 0;
}


Measured memory_bytes: 256
public class Main {
	public static void main(String[] args){
		java.util.Scanner scan = new java.util.Scanner(System.in);
		while(true){
			int a = Integer.parseInt(scan.next());
			String op = scan.next();
			int b = Integer.parseInt(scan.next());

			if("+".equals(op)){
				System.out.println(a + b);
			}else if("-".equals(op)){
				System.out.println(a - b);
			}else if("*".equals(op)){
				System.out.println(a * b);
			}else if("/".equals(op)){
				System.out.println(a / b);
			}else if("?".equals(op)){
				break;
			}
		}
		scan.close();

	}

}

Measured memory_bytes: 26248
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<queue>
#include<functional>
using namespace std;
string S[1000]; int H, W, c[26];
int main() {
	cin >> H >> W;
	for (int i = 0; i < H; i++) {
		cin >> S[i];
		for (int j = 0; j < W; j++)c[S[i][j] - 'a']++;
	}
	int A = (H / 2)*(W / 2) * 4, B, C = (H % 2)*(W % 2); B = (H*W) - A - C; A /= 4; B /= 2;
	for (int i = 0; i < 26; i++) { while (c[i] >= 4 && A >= 1) { A--; c[i] -= 4; } }
	for (int i = 0; i < 26; i++) { while (c[i] >= 2 && B >= 1) { B--; c[i] -= 2; } }
	for (int i = 0; i < 26; i++) { while (c[i] >= 1 && C >= 1) { C--; c[i] -= 1; } }
	if (A + B + C >= 1)cout << "No" << endl;
	else cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 256
def get_int
  gets.chop.to_i
end

def get_ints
  gets.chop.split.map(&:to_i)
end

def get_double
  gets.chop.to_f
end

def get_str
  gets.chop
end

def get_strs
  gets.chop.split
end

def main
  n = get_int
  a_arr = get_ints
  k = 1
  0.upto(n-1) do |i|
    a = a_arr[i]
    if a != k
      # pass
    else
      k += 1
    end
  end
  if k == 1
    puts -1
  else
    puts n - k + 1
  end
end

if __FILE__ == $0
  main
end

Measured memory_bytes: 16780
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
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 (a>b) { a=b; return 1; } return 0; }
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};

string S, T, U;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
    //cout << fixed << setprecision(15);
	
	int N; cin >> N;

	cout << (N+1) / 2 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(int)(n); ++i)
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using Graph = vector<vi>;  // vi <=> vl
using vb = vector<bool>;
using boolGraph = vector<vb>;
using P = pair<int, int>;  // int <=> ll
const int MOD = 1e9+7;
const double EPS = 1e-9;

int main() {
  int N, K; cin >> N >> K;
  Graph black(K, vi(K)), white(K, vi(K));
  rep(i,N) {
    int x, y; char c; cin >> x >> y >> c;
    int color = 0;
    if (c == 'W') color = 1;
    if (abs(x/K-y/K)%2 == color) ++black[x%K][y%K];
    else ++white[x%K][y%K];
  }

  Graph dpB(K+1, vi(K+1)), dpW(K+1, vi(K+1));
  rep(i,K) {
    rep(j,K) {
      dpB[i+1][j+1] = dpB[i+1][j] + dpB[i][j+1] - dpB[i][j] + black[i][j];
      dpW[i+1][j+1] = dpW[i+1][j] + dpW[i][j+1] - dpW[i][j] + white[i][j];
    }
  }

  int ans = 0;
  rep(i,K) {
    rep(j,K) {
      int Bsum = dpB[K][K] - (dpB[i+1][K]-dpB[i+1][j+1]) - (dpB[K][j+1]-dpB[i+1][j+1]);
      int Wsum = (dpW[i+1][K]-dpW[i+1][j+1]) + (dpW[K][j+1]-dpW[i+1][j+1]);
      int tmp = Bsum + Wsum;
      ans = max(ans, max(tmp, N-tmp));
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 16000
#include <bits/stdc++.h>
#define ff first
#define ss second
#define endl '\n'
using namespace std;
const long long INF = (long long) 1e18;
const int mod = (int) 1e9+7;
const int MAXN = (int) 305;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
ll n, k;
ll h[MAXN];
ll dp[MAXN][MAXN][MAXN];

ll d(int ind, int son, int kal){
    if(ind > n){
        return 0;
    }
    ll &r = dp[ind][son][kal];
    if(r != -1) return r;
    r = INF;
    r = min(r, d(ind + 1, ind , kal) + max(0LL, h[ind] - h[son]));
    if(kal)
        r = min(r, d(ind + 1, son, kal - 1));
    return r;   
}



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

    #ifdef Local
        freopen("../IO/int.txt","r",stdin);
        freopen("../IO/out.txt","w",stdout);
    #endif

    cin>>n>>k;

    ll mx = 0;
    for(int i = 1; i <= n; i++){
        cin>>h[i];
    }
    for(int i = 0; i < MAXN; i++){
        for(int j = 0; j < MAXN; j++){
            for(int k = 0; k < MAXN; k++)
                dp[i][j][k] = -1;
        }
    }
    
    cout<<d(1, 0, k)<<endl;
    

    #ifdef Local
        cout<<endl<<fixed<<setprecision(2)<<1000.0 * clock() / CLOCKS_PER_SEC<< " milliseconds ";
    #endif
}

Measured memory_bytes: 221952
#include <bits/stdc++.h>
using namespace std;
#define N_MAX 100000
int X[N_MAX];
int N, Q;

void swap(int a, int b) {
	int tmp = X[a];
	X[a] = X[b];
	X[b] = tmp;
	return;
}

void move(int cur) {
	if(0 < cur && X[cur - 1] == 0) X[cur - 1] = 1;
	if(cur < N - 1 && X[cur + 1] == 0) X[cur + 1] = 1;
	return;
}

int main() {
	cin >> N >> Q;
	for(int i = 0; i < N_MAX; i++) {
		X[i] = 0;
	}
	int cur = 0;
	int A, B;
	X[0] = X[1] = 1;
	for(int i = 0; i < Q; i++) {
		cin >> A >> B;
		A--, B--;
		if(A == cur) cur = B;
		else if(B == cur) cur = A;
		swap(A, B);
		move(cur);
	}
	move(cur);
	int S = 0;
	for(int i = 0; i < N; i++) {
		S += X[i];
	}
	cout << S << endl;
	return 0;
}

Measured memory_bytes: 640
using System;
using System.Linq;
using System.Collections.Generic;

namespace ABC158
{
    class C
    {
        static void Main(string[] args)
        {
            var S = Console.ReadLine().ToList();
            var Q = long.Parse(Console.ReadLine());

            var Mae = new List<char>();
            var Ushiro = new List<char>();

            var onecount = 0;
            for (int i = 0; i < Q; i++)
            {
                var q = Console.ReadLine().Split().ToArray();
                if (long.Parse(q[0]) == 1) onecount++;
                else
                {
                    var f = q[1];
                    var c = q[2].ToCharArray();
                    if (onecount % 2 == 0)
                    {
                        if (long.Parse(f) == 1)
                        {
                            Mae.Add(c[0]);
                        }
                        else
                        {
                            Ushiro.Add(c[0]);
                        }
                    }
                    else
                    {
                        if (long.Parse(f) == 1)
                        {
                            Ushiro.Add(c[0]);
                        }
                        else
                        {
                            Mae.Add(c[0]);

                        }
                    }
                }

            }
            if (onecount % 2 == 0)
            {

                for (int i = Mae.Count - 1; i >= 0; i--)
                {
                    Console.Write(Mae[i]);
                }

                for (int i = 0; i < S.Count; i++)
                {
                    Console.Write(S[i]);
                }

                for (int i = 0; i < Ushiro.Count; i++)
                {
                    Console.Write(Ushiro[i]);
                }
            }
            else
            {
                for (int i = Ushiro.Count - 1; i >= 0; i--)
                {
                    Console.Write(Ushiro[i]);
                }

                for (int i = S.Count - 1; i >= 0; i--)
                {
                    Console.Write(S[i]);
                }

                for (int i = 0; i < Mae.Count; i++)
                {
                    Console.Write(Mae[i]);
                }

            }
            Console.WriteLine();

        }
    }
}


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

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double dd;
#define all(v) v.begin(),v.end()
#define endl "\n"
#define clr(n, r) memset(n,r,sizeof(n));

void fast() {

    cin.tie(0);
    cin.sync_with_stdio(0);
}







int main() {
    fast();
    int n;cin>>n;
    string s;cin>>s;
    int ans=0,x=0;
    for (int i = 0; i <s.size() ; ++i) {
        x+=(s[i]=='I');
        x-=(s[i]=='D');
        ans=max(ans,x);
    }
    cout<<ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) for (int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
const int INFTY =2147483647;

int gcd(int a,int b){
    int x=max(a,b);
    int y=min(a,b);
    int z;
    while(x%y!=0){
        z=x;
        x=y;
        y=z%y;
    }
    return y;
}

int main(){
    int k;
    cin>>k;
    int ans=0;
    for(int i=1;i<=k;i++){
        for(int j=1;j<=k;j++){
            for(int h=1;h<=k;h++){
                ans+=gcd(i,gcd(j,h));
            }
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
#define ll long long
#define for(in1,in2,in3) for (int in1 = in2; in1 < in3; in1++)
#define inf 1e9
#define mp make_pair
#define pb push_back
#define f first
#define s second
using namespace std;

int mx,x,y,z,t,u,v,ans,n,m,o;
string s1,s2,ans1;

int main() {
	cin >> x >> y;
	cout << ceil(x*1.0/(y*2+1.0)) << "\n";
}

Measured memory_bytes: 256
"""
Greedyなのか？
よさそう→所持金として存在しない最小の整数を選んでく？
dicで管理かなぁ→X

シミュレーションは無理！
いくつ引けるか考える→一度処理したらもう使わない
よってO(N)!!

1 2 6 7 7 7 7 7 7 7
の時、3番目で3を使ってしまうのはもったいない！！
→最大化するためには大きい数字で小さい数字を使いたい

同じ数字が来た！→仕方ないので引き上げ
そうでない→ +1した数字を使ってずらす(そこの部分の答えは変わらない)

now の2倍+1以上→now以下にできる(1は除く) ansはA[i] // now

"""

N = int(input())

A = []

for i in range(N):

    a = int(input())
    A.append(a)

ans = 0
now = 1

for i in range(N):

    if now == 1:
        ans += A[i]-1
        now += 1

    elif now == A[i]:
        now += 1

    elif A[i] % now == 0:
        ans += A[i] // now - 1
    else:
        ans += A[i] // now

print (ans)


Measured memory_bytes: 51672
n = int(input())
s = [input() for _ in range(n)]

c0 = 0
c1 = 0
c2 = 0
c3 = 0
for i in s:
    if i == 'AC':
        c0 += 1
    elif i == 'WA':
        c1 += 1
    elif i == 'TLE':
        c2 += 1
    else:
        c3 += 1

print('AC x '+ str(c0))
print('WA x '+ str(c1))
print('TLE x '+ str(c2))
print('RE x '+ str(c3))


Measured memory_bytes: 16332
import sys
import bisect
from collections import defaultdict

ans=0
n=int(input())
a=[]
for i in range(n):
    #s,p=map(int,input().split())
    s,p=input().split()
    a.append((s,-int(p),i+1))
#a=[(1,int(i)) for i in input().split()]
a=sorted(a)

for i in range(n):
    print(a[i][2])
        
        



Measured memory_bytes: 38256
INF = float("inf")
white = 0; gray = 1; black =2

def dijkstra(s):
    # 頂点sをrootに設定
    mindist[s] = 0 

    while True:
        #最短経路木に頂点(最短経路木とつながる最小コストの辺を持つ頂点)を追加
        mincost = INF
        u = -1
        for i in range(n):
            if color[i] != black and mindist[i] < mincost:
                mincost = mindist[i]
                u = i
        if u == -1: break
        color[u] = black
        # 各頂点についてsからの最小コストを更新
        for v in range(n):
            if color[v] == black: continue # 確定済み
            if M[u][v] == INF: continue # 2頂点の間に辺が存在しない
            if mindist[u] + M[u][v] < mindist[v]:
                mindist[v] = mindist[u] + M[u][v]
                color[v] = gray

if __name__ == "__main__":
    n = int(input())
    M = [[INF]*n for _ in range(n)]
    for i in range(n):
        inp = [int(x) for x in input().split()]
        u = inp[0]
        k = inp[1]
        for v,c in zip(inp[2::2],inp[3::2]): M[u][v] = c
    color = [white]*n #各頂点の訪問状態 （white:未訪問 gray:暫定 black:確定）
    mindist = [INF]*n # 始点sからの最小コスト
    dijkstra(0)
    for i in range(n): print("{} {}".format(i,mindist[i]))


Measured memory_bytes: 5716
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define    endl        '\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define hell        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define ios        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
ll int n,k,ans=10000000;
vector<pii> v;
void func(ll int n,ll int k,ll int cnt)
{   
    
    if(n>=0&&k>0)
    {
        int res=100*(n+1);
        int x=ceil((k*1.0)/res);
        //cout<<x<<" "<<res<<" "<<n<<" "<<k<<" "<<cnt<<endl;
        if(x>v[n].first)
        {
            if(res*v[n].first+v[n].second>=k)
            {
                ans=min(ans,v[n].first+cnt);
                //cout<<ans<<" "<<n<<endl;
            }
            else
            {
                func(n-1,k-(res*v[n].first+v[n].second),cnt+v[n].first);
            }
        }
        else
        {
            ans=min(ans,x+cnt);
            //cout<<ans<<" "<<n<<endl;
        }
        func(n-1,k,cnt);
    }
}
int main()
{
    ios
    cin>>n>>k;
    ll x,y;

    for(int i=1;i<=n;i++)
    {
        cin>>x>>y;
        v.pb(make_pair(x,y));
    }

    func(n-1,k,0);
    cout<<ans;
}

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

int main() {
    int A, B, T;
    cin >> A >> B >> T;
    cout << T / A * B << endl;
}

Measured memory_bytes: 3640
#include <stdio.h>

int main(void){
	int n;
	scanf("%d",&n);
	while(n){
		int max,sum,i,t;
		max=-100001;
		sum=0;
		for(i=0;i<n;i++){
			scanf("%d",&t);
			if(sum<0)
				sum=0;
			sum+=t;
			if(sum>=max)
				max=sum;
		}
		printf("%d\n",max);
		scanf("%d",&n);
	}
	return 0;
}

Measured memory_bytes: 600
n,q=map(int,input().split())
s=input()
T=[0]*(n+1)
for i in range(n-1):
  T[i+2]=T[i+1]+[0,1][s[i:i+2]=="AC"]
for _ in range(q):
  l,r=map(int,input().split())
  print(T[r]-T[l-1]-[0,1][s[l-2:l]=="AC"])

Measured memory_bytes: 7748