akhauriyash/Code-Regression huggingface dataset:
import math
import queue
from collections import defaultdict
import itertools as it

def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()
def factorization(n):
	res = []
	if n%2==0:
		res.append(2)
	for i in range(3,math.floor(n//2)+1,2):
		if n%i==0:
			c = 0
			for j in res:
				if i%j==0:
					c=1
			if c==0:
				res.append(i)
	return res
def fact2(n):
	p = factorization(n)
	res = []
	for i in p:
		c=0
		z=n
		while 1:
			if z%i==0:
				c+=1
				z/=i
			else:
				break
		res.append([i,c])
	return res
def fact(n):#階乗
	ans = 1
	m=n
	for _i in range(n-1):
		ans*=m
		m-=1
	return ans
def comb(n,r):#コンビネーション
	if n<r:
		return 0
	l = min(r,n-r)
	m=n
	u=1
	for _i in range(l):
		u*=m
		m-=1
	return u//fact(l)
def combmod(n,r,mod):
	return (fact(n)/fact(n-r)*pow(fact(r),mod-2,mod))%mod
def printQueue(q):
	r=qb
	ans=[0]*r.qsize()
	for i in range(r.qsize()-1,-1,-1):
		ans[i] = r.get()
	print(ans)
def dq():
	return queue.deque()
class UnionFind():
	def __init__(self, n):
		self.n = n
		self.parents = [-1]*n

	def find(self, x): # root
		if self.parents[x]<0:
			return x
		else:
			self.parents[x] = self.find(self.parents[x])
			return self.parents[x]

	def union(self,x,y):
		x = self.find(x)
		y = self.find(y)

		if x==y:
			return

		if self.parents[x]>self.parents[y]:
			x,y = y,x

		self.parents[x]+=self.parents[y]
		self.parents[y]=x

	def size(self,x):
		return -1*self.parents[self.find(x)]

	def same(self,x,y):
		return self.find(x)==self.find(y)

	def members(self,x): # much time
		root = self.find(x)
		return [i for i in range(self.n) if self.find(i)==root]

	def roots(self):
		return [i for i,x in enumerate(self.parents) if x<0]

	def group_count(self):
		return len(self.roots())

	def all_group_members(self):
		return {r: self.members(r) for r in self.roots()} # 1~n
def bitArr(n):#ビット全探索
	x = 1
	zero = "0"*n
	ans = []
	ans.append([0]*n)
	for i in range(2**n-1):
		ans.append(list(map(lambda x:int(x),list((zero+bin(x)[2:])[-1*n:]))))
		x+=1
	return ans;
def arrsSum(a1,a2):
	for i in range(len(a1)):
		a1[i]+=a2[i]
	return a1
def maxValue(a,b,v):
	v2 = v
	for i in range(v2,-1,-1):
		for j in range(v2//a+1): #j:aの個数
			k = i-a*j
			if k%b==0:
				return i
	return -1

k = readInt()
s = readChar()

if len(s)<=k:
	print(s)
else:
	print(s[:k]+"...")

Measured memory_bytes: 9788
n=int(input())
flag=0
for i in range(1,10):
  for j in range(1,10):
    if n == i*1000+i*100+i*10+j or n == j*1000+j*100+j*10+i:
      flag = 1
if flag or n%1000==0:
  print("Yes")
else:
  print("No")


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

typedef long long ll;

ll w,h,v,t,x,y,p,q,R,answer;

inline ll getDist(ll dx,ll dy) { return dx*dx+dy*dy; }

ll countValue(bool phase,ll coef_x){
  ll enemy_x = p;
  if( coef_x >= 0 ) {
    if( ( coef_x & 1LL ) ) enemy_x = w - enemy_x;
    enemy_x += (coef_x*w);
  }
  else {
    if( coef_x & 1LL ) enemy_x = ( coef_x * w) + w - p;
    else               enemy_x = ( coef_x * w) + p;
  }

  ll coef_y_L = 0, coef_y_R = R / h + ( R % h != 0LL ) + 1;
  ll binary_search_solution = 0;
  ll prev = LLONG_MAX;
  rep(_,33){
    ll coef_y = ( coef_y_L + coef_y_R ) / 2LL;
    if( coef_y == prev ) break;
    prev = coef_y;
    if( !phase ) coef_y *= -1LL;
    ll enemy_y = q;
    if( phase ) {
      if( ( coef_y & 1LL ) ) enemy_y = h - enemy_y;
      enemy_y += (coef_y*h);
    } else {
      if( coef_y & 1LL ) enemy_y = ( coef_y * h) - ( h - q );
      else               enemy_y = ( coef_y * h) - q;
    }

    if(  phase ) assert( enemy_y >= 0LL );
    if( !phase ) assert( enemy_y <= 0LL );
    ll dist = getDist(x-enemy_x,y-enemy_y);

    if( dist <= R*R ) {
      binary_search_solution = max(binary_search_solution,llabs(coef_y) + 1LL);
      coef_y_L = llabs(coef_y);
    } else {
      coef_y_R = llabs(coef_y);
    }
  }

  return binary_search_solution;
}

int main(){
  cin >> w >> h >> v >> t >> x >> y >> p >> q;
  R = v * t;
  ll coef = R / w + ( R % w != 0LL );
  for(ll coef_x=-coef;coef_x<=coef;coef_x++){
    answer += countValue(true,coef_x);
    answer += countValue(false,coef_x);
  }
  cout << answer << endl;
  return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <sstream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>

#define BEGIN(x) x.begin()
#define END(x) x.end()
#define ALL(x) BEGIN(x), END(x)
#define PAIR make_pair
#define VEC(type) vector<type >

#define FOR(i, A, B) for(auto i = (A);i != (B); i++)
#define FORD(i, A, B) for(auto i = (A);i != (B); i--)

#define READRANGE(begin, end) FOR(it, begin, end) cin >> *it
#define READVEC(V) READRANGE(BEGIN(V), END(V))

using namespace std;

typedef long long lint;
typedef pair<int, int> Pii;
typedef pair<int, lint> Pil;
typedef pair<lint, lint> Pll;
typedef pair<lint, int> Pli;

void io_init()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
};

int main(int argc, char **argv)
{
    io_init();

    // Actual program code starts here.
    string S;
    cin >> S;
    const int n = S.size();
    int removed = 0;
    char last = 'A';
    for (int i = 0;i + 1 < n;) {
        int j = i + 2;
        while (j < n && S[j] == S[j - 2])
            j++;

        // j == n or a[j] != a[j - 2]
        if (j == n)
            break;
        removed += j - i - 1;
        S[j - 1] = S[i];
        i = j - 1;
    }

    cout << (removed % 2 == 1 ? "First" : "Second") << endl;
    return 0;
};


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <map>
using namespace std;
 
 
int main() {
    int n;
    cin>>n;
    vector<int> a(n);
    for(int i=0; i<n; ++i) {
        int tmp;
        cin>>tmp;
        a[i]=tmp-1;
    }

    int can=false, count=0;
    int button=0;
    while(!can && count<n) {
        if(a[button]==1) can=true;
        else button=a[button];
        count++;
    }
    if(can) cout<<count<<endl;
    else cout<<-1<<endl;
    
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#define ll long long
using namespace std;

bool thru[2510], work[2510];

void search(int now, vector<vector<int>> &G){
    work[now]=1;
    for(int i=0; i<G[now].size(); ++i){
        if(!work[G[now][i]]){
            search(G[now][i], G);
        }
    }
}

int main() {
	int N, M;
	ll P;
	cin >> N >> M >> P;
	vector<vector<int>> g(N+1), rev(N+1);
	vector<vector<ll>> cost(N+1);
	for(int i=0; i<M; ++i){
	    int a, b;
	    ll c;
	    cin >> a >> b >> c;
	    g[a].push_back(b);
	    cost[a].push_back(P-c);
	    rev[b].push_back(a);
	}
	search(1, g);
	for(int i=1; i<=N; ++i){
	    thru[i] |= work[i];
	    work[i]=0;
	}
	search(N, rev);
	int cnt=0;
	for(int i=1; i<=N; ++i){
	    thru[i] &= work[i];
	    if(thru[i]) ++cnt;
	}
	vector<ll> mn(N+1, 1e18);
	mn[1]=0;
	for(int i=1; i<cnt; ++i){
	    for(int p=1; p<=N; ++p){
	        if(thru[p]){
	            for(int q=0; q<g[p].size(); ++q){
	                if(thru[g[p][q]]){
	                    mn[g[p][q]]=min(mn[g[p][q]], mn[p]+cost[p][q]);
	                }
	            }
	        }
	    }
	}
	for(int p=1; p<=N; ++p){
	    if(thru[p]){
	        for(int q=0; q<g[p].size(); ++q){
	            if(thru[g[p][q]]){
	                if(mn[g[p][q]]>mn[p]+cost[p][q]){
	                    cout << -1 << endl;
	                    return 0;
	                }
	            }
	        }
	    }
	}
	cout << max(-mn[N], (ll) 0) << endl;
	return 0;
}


Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
#define int long long
struct UnionFind{
  int n;
  vector<int> p,r;
  UnionFind(){}
  UnionFind(int n):n(n){init();}
  void init(){
    p.clear();
    r.clear();
    p.resize(n);
    r.resize(n,1);
    for(int i=0;i<n;i++) p[i]=i;
  }
  int find(int x){
    return (p[x]==x?x:p[x]=find(p[x]));
  }
  bool same(int x,int y){
    x=find(x);y=find(y);
    return x==y;
  }
  void unite(int x,int y){
    x=find(x);y=find(y);
    if(x==y) return;
    if(r[x]<r[y]) swap(x,y);
    p[y]=x;
    r[x]+=r[y];
  }
};
signed main(){
  int n,m;
  cin>>n>>m;
  UnionFind uf(n);
  for(int i=0;i<m;i++){
    int s,t;
    cin>>s>>t;
    uf.unite(s,t);
  }
  int q;
  cin>>q;
  for(int i=0;i<q;i++){
    int s,t;
    cin>>s>>t;
    cout<<(uf.same(s,t)?"yes":"no")<<endl;
  } 
  return 0;
}

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

using namespace std;

typedef long long ll;

#define sz(x) ((int)(x).size())
#define in(x) int x;cin>>x
#define inn(x, y) int x,y;cin>>x>>y
#define innn(x, y, z) int x,y,z;cin>>x>>y>>z
#define bit(n) (1<<(n))

#define out(x) cout<<(x)<<endl;
#define outt(x,y) cout<<(x)<<" "<<(y)<<endl;
#define err(x) cerr<<(x)<<endl;
#define errr(x,y) cerr<<(x)<<" "<<(y)<<endl;
#define errrr(x,y,z) cerr<<(x)<<" "<<(y)<<" "<<(z)<<endl;

#define rep(i,n) for (int i=0;i<(n);i++)
#define repp(i,n) for (int i=1;i<=(n);i++)
#define reppp(j, i, n) for (int j=i+1; j<n; j++)

#define lim5 100002
#define lim9 1000000002

#define deg(rad) (((rad)/2/M_PI)*360)
#define mid(min, max) ((min + max) / 2)

template<typename TypeInt>
std::string Itoa(const TypeInt v, int base)
{
    static const char table[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
    string ret;
    static numeric_limits<TypeInt> t;
    TypeInt n = v;
    if (t.is_signed) {
        if (v < 0) n *= -1;
    }

    while (n >= base) {
        ret += table[n%base];
        n /= base;
    }
    ret += table[n];
    if (t.is_signed) {
        if (v < 0 && base == 10) ret += '-';
    }
    // 文字列の順番を逆にする
    std::reverse(ret.begin(), ret.end());

    return ret;
}

int main() {
	inn(n, k);
	out(Itoa(n, k).length());

	return 0;
}


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

using namespace std;

#ifdef DEBUG_MODE
	#define DBG(n) n;
#else
	#define DBG(n) ;
#endif

#define REP(i,n) for(ll (i) = (0); (i) < (n); ++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define ALL(v) v.begin(),v.end()
#define INF 1100000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007

typedef long long ll;
typedef pair<ll, ll> P;


int main()
{
  int N, M;
  cin >> N >> M;
  vector<int> P(M), Y(M);
  vector<set<pair<int, int>>> vv(N + 1);
  REP(i, M) {
    cin >> P[i] >> Y[i];
    vv[P[i]].insert(make_pair(Y[i], i));
  }

  for (int i = 1; i <= N; i++) {
    int cnt = 1;
    for (auto e : vv[i]) {
      Y[e.second] = cnt;
      cnt++;
    }
  }
  REP(i, M) {
    cout << setw(6) << setfill('0') << P[i] 
         << setw(6) << setfill('0') << Y[i] << endl;
  }

	return 0;
}



Measured memory_bytes: 13696
#include <bits/stdc++.h>
typedef long long int lint;

#define PI acos(-1)
#define INF64 1LL << 60
#define INF32 1 << 29
#define LIMIT(d_in, d_min, d_max) max(d_min, min(d_max, d_in))
#define all(a) (a).begin(), (a).end()
#define INV ((long long int)1000000007)

using namespace std;
lint CountP(lint current, lint N, int X, vector<lint> BP, vector<lint> P)
{
	if (X < 0)
		return current + 1;
	//cout << N << " " << X << " " << BP[X] << " " << P[X] << endl;

	if (N == 1)
		return current;
	else if (N <= 1 + BP[X])
		return CountP(current, N - 1, X - 1, BP, P);
	else if (N <= 1 + BP[X] + 1)
		return current + 1 + P[X];
	else if (N <= 1 + BP[X] + 1 + BP[X])
		return CountP(current + 1 + P[X], N - 1 - BP[X] - 1, X - 1, BP, P);
	else
		return current + P[X] * 2 + 1;
}
void execute()
{
	lint N;
	int X;
	cin >> X >> N;

	vector<lint> BP(X + 1);
	vector<lint> P(X + 1);
	BP[0] = 1;
	P[0] = 1;
	for (int i = 0; i < X; i++)
	{
		BP[i + 1] = BP[i] * 2 + 3;
		P[i + 1] = P[i] * 2 + 1;
	}
	cout << CountP(0, N, X - 1, BP, P) << endl;
	return;
}

int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	execute();

	int stop;
	cin >> stop;

	return 0;
}

Measured memory_bytes: 256
#include <atcoder/all>
#include <bits/stdc++.h>
using namespace std;
using namespace atcoder;
#define int long long
   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; }
    const int MAX =200005;
const int MOD =1000000007;
using mint = modint998244353;
signed main(){
  int n,k;
  cin>>n>>k;
  pair<int,int> p[n];int p0;
  mint k2=k;
  k2=1-k2.inv();
  mint ans=0,itr1=1,itr2=1;
  for(int i=1;i<n;i++){
    itr1=k2.pow(max(0ll,i+1-k));
    ans+=itr2*itr1;
    itr2+=itr1.inv();
     //cerr<<ans.val()<<' '<<itr1.val()<<endl;
  }
  ans/=2;
  
 // cerr<<ans.val()<<endl;
  for(int i=0;i<n;i++){
    cin>>p0;
    p[i]={p0,i};
  }
  sort(p,p+n);
  fenwick_tree<mint> tr(n),tr2(n);
  for(int i=0;i<n;i++){
    int j=p[i].second;
   itr1=k2.pow(max(0ll,j+1-k));
   ans-=tr.sum(j,n)/itr1;
   ans+=tr2.sum(j,n);
   tr.add(j,itr1);
   tr2.add(j,1);

  }
  cout<<ans.val()<<endl;

}


Measured memory_bytes: 8032
#include <iostream>
#include <cmath>
#include <iomanip>
#include <limits>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
    int H,W;
    cin >> H >> W;
    string s[H+2];
    string t;
    s[0] = "";
    s[H+1] = "";
    for(int i=0;i<W+2;i++){
        s[0] += '.';
        s[H+1] += '.';
    }
    for(int i=1;i<H+1;i++){
        s[i] = ".";
        cin >> t;
        s[i] += t + ".";
    }

    for(int i=1;i<H+1;i++){
        for(int j=1;j<W+1;j++){
            if(s[i].at(j) == '#') continue;
            int num = 0;
            if(s[i-1].at(j-1) == '#') num++;
            if(s[i-1].at(j) == '#') num++;
            if(s[i-1].at(j+1) == '#') num++;
            if(s[i].at(j-1) == '#') num++;
            if(s[i].at(j+1) == '#') num++;
            if(s[i+1].at(j-1) == '#') num++;
            if(s[i+1].at(j) == '#') num++;
            if(s[i+1].at(j+1) == '#') num++;
            s[i].at(j) = char(num + '0');
        }
    }

    for(int i=1;i<H+1;i++){
        cout << s[i].substr(1,W) << endl;
    }
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
from collections import Counter


def read():
    N, M = list(map(int, input().strip().split()))
    AB = []
    for i in range(M):
        a, b = map(int, input().strip().split())
        AB.append((a, b))
    return N, M, AB


class UnionFind():
    """Union-Find木の実装
    """

    def __init__(self, n):
        self.n = n
        self.parent = [x for x in range(n)]

    def find(self, x):
        """要素xが所属するグループを返す
        """
        if self.parent[x] == x:
            return x
        else:
            self.parent[x] = self.find(self.parent[x])
            return self.parent[x]

    def union(self, x, y):
        """要素x, yがそれぞれ所属するグループを併合する
        """
        x = self.find(x)
        y = self.find(y)
        if x > y:
            x, y = y, x
        self.parent[y] = x

    def parents(self):
        """全てのノードについて、対応する親ノードを返す"""
        return [self.find(x) for x in range(self.n)]


def solve(N, M, AB):
    uf = UnionFind(N)
    for a, b in AB:
        uf.union(a-1, b-1)
    C = Counter(uf.parents())
    return C.most_common()[0][1]


if __name__ == '__main__':
    inputs = read()
    outputs = solve(*inputs)
    if outputs is not None:
        print("%s" % str(outputs))


Measured memory_bytes: 49484
#include <iostream>
#include <stdio.h>
#include <bits/stdc++.h>
#include <queue>
#include <math.h>
#include <bitset>
#define INF 100000000000
#define N 1000000007
#define ll long long
using namespace std;

int main(){
    string s;
    cin>>s;
    ll l=s.size();
    if(s[l-1]=='s') cout<<s<<"es"<<endl;
    else cout<<s<<"s"<<endl;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h> 
 
using namespace std;
 
typedef long long ll; 
typedef pair<int, int> pii;
 
#define REP(i,n) for(int(i)=0;(i)<(int)(n);(i)++)
 
vector<int> adj[2100];
int dp[2100][2100];
int ans;
int n,k;
 
int dfs(int v, int p, int maxd) {
	if (maxd < 0) return 0;
 	
	int &ret = dp[v][maxd];
	if (ret == -1) {
		ret = 1;
		if (maxd == k) {
			for (int x : adj[v]) if (x != p) {
				ret = max(ret, dfs(x,v,k));  
			}
		}
 		
 		dp[v][0] = 1;
		for (int max_c = 0; max_c <= k-1; max_c++) {
			dp[v][max_c+1] = max(dp[v][max_c+1], dp[v][max_c]);
			
			int rem = min(max_c, k - 2 - max_c);
			int s = 0;
			for (int x : adj[v]) if (x != p) s += dfs(x,v,rem);
			for (int x : adj[v]) if (x != p) dp[v][max_c+1] = max(dp[v][max_c+1], 1 + dfs(x,v,max_c) + s - dfs(x,v,rem));
		}
	}
	return ret;
}
 
int main() {
	memset(dp,-1,sizeof(dp));
 
	scanf("%d %d", &n, &k);
	REP(i,n-1) {
		int u,v;
		scanf("%d %d", &u, &v); u--; v--;
		adj[u].push_back(v);
		adj[v].push_back(u);
	}
 
	printf("%d\n", n-dfs(0,-1,k));
}

Measured memory_bytes: 17792
#include <stdio.h>
int main(){
	int i,j,k;
	int a[100];
	int n;
	int key;
	scanf("%d",&n);
	for(i=0;i<n;i++) scanf("%d",&a[i]);
	
	for(k=0;k<n-1;k++) printf("%d ",a[k]);
	
	printf("%d\n",a[k]);
	for(i=1;i<n;i++){
		key=a[i];
		j=i-1;
		while(j>=0 && a[j]>key){
			a[j+1]=a[j];
			j--;
			}
		a[j+1]=key;
		for(k=0;k<n-1;k++) printf("%d ",a[k]);
		printf("%d\n",a[k]);
	}
		
	return 0;
}

Measured memory_bytes: 600
from functools import reduce

def gcd(a, b):
    if a > b:
        a, b = b, a
    if a == 0:
        return b
    return gcd(b%a, a)

N, X = map(int, input().split())
x = [int(i) for i in input().split()]

delta = [abs(X-i) for i in x]
print(reduce(gcd, delta))

Measured memory_bytes: 14596
#include <bits/stdc++.h>
#define LL long long
#define FOR(i,c) for(__typeof(c.begin()) i = c.begin(); i != c.end(); i++)
#define F first
#define S second
using namespace std;

const LL mod = 1e9 + 7;

template<typename T> T gcd(T a, T b) { return b == 0?a: gcd(b, a % b); }
template<typename T> T LCM(T a, T b) { return a*(b/gcd(a, b)); }
template<typename T, typename S> T expo(T b, S e, const T &m){if(e <= 1)return e == 0?1: b;\
	return (e&1) == 0?expo((b*b)%m, e>>1, m): (b*expo((b*b)%m, e>>1, m))%m;}
template<typename T, typename S> T expo(T b, S e){if(e <= 1)return e == 0?1: b;\
	return (e&1) == 0?expo((b*b), e>>1): (b*expo((b*b), e>>1));}
template<typename T, typename S> T modinv(T a, S mod) { return expo(a, mod-2, mod); }
template<class T, class S> std::ostream& operator<<(std::ostream &os, const std::pair<T, S> &t) {
	os<<"("<<t.first<<", "<<t.second<<")";
	return os;
}
template<class T> std::ostream& operator<<(std::ostream &os, const std::vector<T> &t) {
	os<<"["; FOR(it,t) { if(it != t.begin()) os<<", "; os<<*it; } os<<"]";
	return os;
}
const int MAXN = 1e5 + 3;

LL arr[MAXN], n;

bool solve() {
  bool flag = false;
  LL sum = 0, cnt = 0, even = 0;
  for(int i = 0; i < n; i++) {
    if(arr[i] == 1) {
      flag = true;
    }
    cnt += arr[i] % 2;
    sum += arr[i] - 1;
  }
  even = n - cnt;
  if(flag) {
    return sum % 2 == 1;
  }
  if(cnt == 1 and n % 2 == 1) {
    LL g = 0;
    for(int i = 0; i < n; i++) {
      if(arr[i] % 2) arr[i]--;
      g = gcd(g, arr[i]);
    }
    for(int i = 0; i < n; i++) {
      arr[i] /= g;
    }
    return !solve();
  }
  if(even % 2 == 1) return true;
  return false;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin >> n;
  for(int i = 0; i < n; i++) {
    cin >> arr[i];
  }
  bool ok;
  if(n == 1) {
    if(arr[0] % 2 == 0) ok = true;
    else ok = false;
  } else {
    ok = solve();
  }
  if(ok) {
    cout << "First" << endl;
  } else {
    cout << "Second" << endl;
  }
  return 0;
}


Measured memory_bytes: 1024
void main() {
	auto ip = readAs!(int[]), X = ip[0], Y = ip[1];
	writeln(X + Y / 2);
}

// ===================================

import std.stdio;
import std.string;
import std.functional;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int n,r,c=0;
    scanf("%d",&n);
    if(n<1000){
        while(n>0){

    r=n%10;
    if(r==7){
      c++;
      break;
    }
    n=n/10;
    }
    if(c>0)
        printf("Yes\n");
    else
        printf("No\n");

    }

}


Measured memory_bytes: 1660
#include <bits/stdc++.h>
using namespace std;
const int INF = 1e5;

int N;
vector<vector<int>> G;
vector<int> color;//0:見探索 1, -1:色分け
bool jdg;//二部グラフか否か

void Bipartite_Graph(int now, int pre){
    if(now != pre && color[now] != 0){
        if(color[now] == color[pre])jdg = false;
    }else{
        if(now == pre)color[now] = -1;
        color[now] = color[pre] * -1;
        for(auto v : G[now]){
            if(v == pre)continue;
            Bipartite_Graph(v, now);
        }
    }
    return;
}

void warshall_floyd(vector<vector<int>> &_Date){
    for(int k = 0; k < _Date.size(); k++){        //経由頂点
        for(int i = 0; i < _Date.size(); i++){    //始点
            for(int j = 0; j < _Date.size(); j++){//終点
                _Date[i][j] = min(_Date[i][j], _Date[i][k] + _Date[k][j]);
            }
        }
    }
}

int main(){
    cin >> N;
    G.assign(N, vector<int>());
    color.assign(N, 0);
    jdg = true;
    vector<vector<int>> dis(N, vector<int>(N, INF));
    for(int i = 0; i < N; i++){
        for(int j = 0; j < N; j++){
            char a;
            cin >> a;
            if(a == '1'){
                dis[i][j] = 1;
                G[i].push_back(j);
            }
        }
    }
    
    Bipartite_Graph(0, 0);
    int ans = -1;
    if(jdg){
        warshall_floyd(dis);
        for(int i = 0; i < N; i++){
            for(int j = 0; j < N; j++){
                if(i == j)continue;
                ans = max(ans, dis[i][j] + 1);
                //最長パスではなくノード数なので + 1
            }
        }
    }
    
    cout << ans << endl;
    return 0;
}


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

int main()
{
    int n, k; cin>>n>>k;
    map<int, int> a;
    for(int i=0; i<n; ++i) {
        int t; cin>>t;
        ++a[t];
    }
    priority_queue<int> q;
    for(auto& e: a) q.push(-e.second);

    long res=0;
    for(; q.size()>k; q.pop()) res-=q.top();
    cout<<res<<endl;
}


Measured memory_bytes: 10748
#include <string>
#include <cstring>
#include <iostream>

using namespace std;

#define MOD 10007

#define MAX_N 1050

int main()
{
	int N;

	string S;

	cin >> N >> S;

	int dp[MAX_N][8];

	memset(dp, 0, sizeof(dp));

	dp[0][1] = 1;

	for (int i = 1; i <= N; i++)
	{
		if (S[i - 1] == 'J')
		{
			dp[i][1] = dp[i - 1][1] + dp[i - 1][2] + dp[i - 1][3] + dp[i - 1][4];
			dp[i][2] = dp[i - 1][1] + dp[i - 1][2] + dp[i - 1][3] + dp[i - 1][4] + dp[i - 1][5] + dp[i - 1][6];
			dp[i][3] = dp[i - 1][1] + dp[i - 1][2] + dp[i - 1][3] + dp[i - 1][4] + dp[i - 1][6] + dp[i - 1][7];
			dp[i][4] = dp[i - 1][1] + dp[i - 1][2] + dp[i - 1][3] + dp[i - 1][4] + dp[i - 1][5] + dp[i - 1][6] + dp[i - 1][7];
			dp[i][5] = 0;
			dp[i][6] = 0;
			dp[i][7] = 0;
		}

		if (S[i - 1] == 'O')
		{
			dp[i][1] = 0;
			dp[i][2] = dp[i - 1][1] + dp[i - 1][2] + dp[i - 1][3] + dp[i - 1][4] + dp[i - 1][5] + dp[i - 1][6];
			dp[i][3] = 0;
			dp[i][4] = dp[i - 1][1] + dp[i - 1][2] + dp[i - 1][3] + dp[i - 1][4] + dp[i - 1][5] + dp[i - 1][6] + dp[i - 1][7];
			dp[i][5] = dp[i - 1][2] + dp[i - 1][4] + dp[i - 1][5] + dp[i - 1][6];
			dp[i][6] = dp[i - 1][2] + dp[i - 1][3] + dp[i - 1][4] + dp[i - 1][5] + dp[i - 1][6] + dp[i - 1][7];
			dp[i][7] = 0;
		}

		if (S[i - 1] == 'I')
		{
			dp[i][1] = 0;
			dp[i][2] = 0;
			dp[i][3] = dp[i - 1][1] + dp[i - 1][2] + dp[i - 1][3] + dp[i - 1][4] + dp[i - 1][6] + dp[i - 1][7];
			dp[i][4] = dp[i - 1][1] + dp[i - 1][2] + dp[i - 1][3] + dp[i - 1][4] + dp[i - 1][5] + dp[i - 1][6] + dp[i - 1][7];
			dp[i][5] = 0;
			dp[i][6] = dp[i - 1][2] + dp[i - 1][3] + dp[i - 1][4] + dp[i - 1][5] + dp[i - 1][6] + dp[i - 1][7];
			dp[i][7] = dp[i - 1][3] + dp[i - 1][4] + dp[i - 1][6] + dp[i - 1][7];
		}

		for (int j = 1; j <= 7; j++)
		{
			dp[i][j] %= MOD;
		}
	}

	cout << (dp[N][1] + dp[N][2] + dp[N][3] + dp[N][4] + dp[N][5] + dp[N][6] + dp[N][7]) % MOD << endl;

	return 0;
}

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

int main() {
  int N;
  cin >> N;
  
  vector<int> p(N);
  for( int i = 0; i < N; i++ ) cin >> p.at(i);
  sort( p.begin(), p.end() );
  
  int ans = 0;
  for( int i = 0; i < N; i++ ){
    if( i == N-1 ){
      p.at(i) /= 2;
    }
    ans += p.at(i);
  }
  cout << ans << endl;
}

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

int main() {
	int L, a, b, c, d;
		cin >> L >> a >> b >> c >> d;
		
		int k = a / c;
		int s = b / d;
		
		if (a % c != 0) {
			k++;
		}
		if (b % d != 0) {
			s++;
		}
		
		cout << (L - (k > s ? k : s)) << endl;
}

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

int a[5004] = {0};
bool dp[5004][5004];
int n, k;

bool check(int i){
    for(int j=0;j<n;++j){
        dp[j][0] = true;
        for(int l=1;l<=k;++l){
            dp[j][l] = false;
        }
    }

    for(int j=0;j<n;++j){
        if(j != i)dp[j][min(k,a[j])] = true;
        if(j > 0){
            for(int l=1;l<=k;++l){
                dp[j][l] = (dp[j][l] || dp[j-1][l]);
                if(j != i && l >= a[j])
                    dp[j][l] = (dp[j][l] || dp[j-1][l-a[j]]);
            }
        }
    }

    for(int j=max(0,k-a[i]);j<k;++j)
        if(dp[n-1][j])return true;
    return false;
}

int main(){
    cin >> n >> k;
    for(int i=0;i<n;++i){
        cin >> a[i];
    }
    sort(a, a+n);

    int unnecessary = -1, necessary = n;
    while(necessary - unnecessary > 1){
        int mid = (necessary + unnecessary) / 2;
        if(check(mid))necessary = mid;
        else unnecessary = mid;
    }

    cout << unnecessary + 1 << endl;

    return 0;
}


Measured memory_bytes: 24704
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

const int INF = 1 << 20;
const int dy[4] = {-1, 0, 1, 0};
const int dx[4] = {0, 1, 0, -1};
int H, W;
string s[50];

bool contain(int y, int x) {
  return y >= 0 && y < H && x >= 0 && x < W;
}

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  cin >> H >> W;
  int sum = 0;
  for (int i = 0; i < H; i++) {
    cin >> s[i];
    for (int j = 0; j < W; j++) {
      sum += s[i][j] == '#';
    }
  }
  
  int dis[50][50];
  fill_n((int*)dis, 50 * 50, INF);
  dis[0][0] = 1;
  queue<pii> que;
  que.emplace(0, 0);
  while (!que.empty()) {
    pii cur = que.front();
    que.pop();
    int y, x;
    tie(y, x) = cur;
    for (int i = 0; i < 4; i++) {
      int ny = y + dy[i];
      int nx = x + dx[i];
      if (contain(ny, nx) && s[ny][nx] == '.' && dis[ny][nx] == INF) {
        dis[ny][nx] = dis[y][x] + 1;
        que.emplace(ny, nx);
      }
    }
  }
  if (dis[H - 1][W - 1] == INF) {
    cout << -1 << endl;
  } else {
    cout << H * W - dis[H - 1][W - 1] - sum << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const long long INF = 1LL << 60;
const int MOD = 1000000007;
using pint = pair<ll, ll>;

int main(){
    ll N;
    bool check = true;
    cin >> N;
    ll cnt_4 = 0, cnt_2 = 0, other = 0;
    for (int i = 0; i < N; i++) {
      ll tmp = 0;
      cin >> tmp;
      if (tmp % 4 == 0) cnt_4++;
      else if(tmp%2==0){
        cnt_2++;
      }
      else{
        other++;
      }
    }
    if (cnt_2 == 0) {
      if (cnt_4 >= other - 1) check = false;
    } else {
      if (cnt_2 % 2 == 0) {
        if (cnt_4 >= other - 1) check = false;
      } else {
        if (cnt_4 >= other) check = false;
      }
    }
    if (check) cout << "No" << endl;
    else cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 3596
#include <cmath>
#include <cstdio>
#include <limits>
#include <tuple>
#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <numeric>
#include <string>
#include <array>

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

using namespace std;
using ll = long long;

int main() {
  ios::sync_with_stdio(false);
  ll n;
  cin >> n;

  vector<ll> primes;
  primes.push_back(2);
  vector<ll> ans;
  for (int i = 3; i < 55555; ++i) {
    if (ans.size() >=n) break;
    bool isPrime = true;
    for (const auto& prime : primes){
      if (i%prime==0) {isPrime = false; break;}
    }
    if (isPrime) {
      primes.push_back(i);
      if (i%5 == 1) ans.push_back(i);
    }

  }

  rep(i, n) cout << ans.at(i) << " ";
  cout << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define MAX_N 50

int main(void){
	int i;
	int n;
	int fn[MAX_N];
	fn[0] = fn[1] = 1;
	for(i = 0; i < MAX_N-2; i++)
		fn[i+2] = fn[i+1] + fn[i];
	scanf("%d", &n);
	printf("%d\n", fn[n]);

	return 0;
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for (int i = 0; i < n; ++i)
#define REP(i,k,n) for (int i = k; i <= n; ++i)
#define REPR(i,k,n) for (int i = k; i >= n; --i)
#define pb push_back
#define F first
#define S second
#define I insert
#define mp make_pair
#define sz(a) (int)((a).size())
#define all(a) (a).begin(), (a).end()
#define debug1(a) cout<<" a : "<<a<<"\n"
#define debug2(a,b) cout<<" a : "<<a<<" b : "<<b<<"\n"
#define debug3(a,b,c) cout<<" a : "<<a<<" b : "<<b<<" c : "<<c<<"\n"
#define debug4(a,b,c,d) cout<<" a : "<<a<<" b : "<<b<<" c : "<<c<<" d : "<<d<<"\n"
// #define M 421412341324321
#define MOD 998244353 


signed main()
{
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	
	int n,m;
	cin>>n>>m;
	pair <int, int> a[n];
	rep(i,n)
	{
		cin>>a[i].F>>a[i].S;
	}
	multiset <int> s;
	vector <multiset <int>> v(m+1);
	rep(i,n)
	{
		int x = m-a[i].F;
		if (x>=0)
		v[x].insert(a[i].S);
	}
	int c = 0;
	REPR(i,m,0)
	{
		if (v[i].size())
		{
			for (auto itr = v[i].begin();itr!=v[i].end();itr++)
			s.insert(*itr);
		}
		if (s.size())
		{
			c+=*s.rbegin();
			s.erase(prev(s.end()));
		}
	}
	cout<<c;

	return 0;
}


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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;

li n, a, b;
li c, d;

inline bool solve() {
    li o = abs(b - a);
    li diff = d - c;
    rep(i, n - 1) {
        li ma = d * i + o;
        li mi = c * i + o;

        // n-i回upさせて[mi, ma]におさまればOK
        li maa = d * (n - i - 1);
        li mii = c * (n - i - 1);
        //p5(i, ma, mi, maa, mii);
        if (maa < mi || mii > ma) {
            continue;
        }
        return true;
    }
    return false;
}

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

    cin >> c >> d;

    cout << (solve() ? "YES" : "NO") << endl;

    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
typedef vector<lint> vlint;

#define inf 1e+9
#define endl "\n"
#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 all(x) (x).begin(), (x).end()

#define pb push_back
#define eb emplace_back
#define Size(c) (int)(c).size()

#define lb(c, x) distance((c).begin(), lower_bound(all(c), (x)))
#define ub(c, x) distance((c).begin(), upper_bound(all(c), (x)))

template <class T> using pq = priority_queue<T>;
template <class T> using pqg = priority_queue<T, vector<T>, greater<T>>;

template <class T, class S> inline bool chmax(T &a, S b) {
    if(a < b) {a = b;return 1;} return 0;
}
template <class T, class S> inline bool chmin(T &a, S b) {
    if(a > b) {a = b;return 1;} return 0;
}
template <class T>
void line(vector<T> &x){for (auto&& xi : x) cin >> xi;}

inline void IN(void){ return;}

template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){ cin >> first; IN(rest...); return;}

#define INT(...) int __VA_ARGS__; IN (__VA_ARGS__)
#define LINT(...) lint __VA_ARGS__; IN (__VA_ARGS__)
#define STR(...) string __VA_ARGS__; IN(__VA_ARGS__)

template <class T> void UNIQUE(vector<T> &x) {
    sort(all(x)); x.erase(unique(all(x)), x.end());
}
template <class T> void print_vec(T first, T end){
    for (auto i = first; i < end - 1; i++) cout << *i << " ";
    cout << *(end-1) << endl;
}
template <class T> void print(T a){ cout << a << endl;};
vector<string> Yes = {"No", "Yes"};
vector<string> YES = {"NO", "YES"};


int mod = 1e9 + 7;
int bit_length(int n){
    for (int i = 31; i >= 0; --i){
        if (n & (1 << i)) return i+1;
    }
    return 1;
}

lint powmod(lint x, lint y, lint m){
    if (y == 0) return 1;
    lint ret = 1;
    rep(i, bit_length(y)+1){
        if (y & (1 << i)){
            ret *= x; ret %= m;
        }
        x *= x; x %= m;
    }
    return ret;
}

int main(){
    INT(n, k);
    vlint cnt(k+1, 0);
    for (int i = k; i > 0; --i){
        cnt[i] += powmod(k/i, n, mod);
        cnt[i] %= mod;
        for (int j = i+i; j <= k; j += i){
            cnt[i] -= cnt[j];
            cnt[i] %= mod;
        }
    }
    lint ans = 0;
    rep1(i, k+1){
        ans += i * cnt[i] % mod;
        ans %= mod;
    }
    if (ans < 0) ans += mod;
    print(ans);
}
    



Measured memory_bytes: 4056
n = int(input())
h = list(map(int, input().split()))
preb = 0
num = -1
ans = []

for i in range(len(h)):
  if preb >= h[i]:
    num += 1
  else:
    ans.append(num)
    num = 0
  preb = h[i]
ans.append(num)
print(max(ans))

Measured memory_bytes: 14224
#include <iostream>
#include <algorithm>
#include <cstring>

#define REP(i, a, b) for ( int i = (a); i < (b); i++ )
#define REVREP(i, a, b) for ( int i = (a); i >= (b); i--)
#define DEBUG_INT(var) printf("the value of "#var" is %d\n", var)
#define PRINT_ARRAY(name, i) printf("the value of "#name"[%d] is %d\n", (i), name[(i)])
#define DEBUG_ARRAY(name, begin, end) REP(i, begin, end) PRINT_ARRAY(name, i)

#define YES puts("YES")
#define NO  puts("NO")
#define Yes puts("Yes")
#define No  puts("No")

using namespace std;

typedef long long ll;

int ans;
int A, B;

int main(void) {
    scanf("%d %d", &A, &B);

    REP(i, A, B+1) {
    	int x = i;
    	int d[6];
    	REP(j, 0, 5) {
    		d[j] = x % 10;
    		x -= d[j];
    		x /= 10;
    	}
    	if (d[0] == d[4] && d[1] == d[3]) ans++;
    }
   

  
    printf("%d\n", ans);

	return 0;
}


Measured memory_bytes: 256
import Foundation

#if swift(>=4.0)
extension String {
    func split(by separator: String) -> [String] {
        return self.components(separatedBy: separator)
    }
    func toArray() -> [String] {
        return self.map{String($0)}
    }
}
func exponentiate(_ lhs: Int, _ rhs: Int) -> Int {
    return (0..<rhs).reduce(1){i,_ in i*lhs}
}
#else
extension String {
    func split(by separator: String) -> [String] {
        return self.componentsSeparatedByString(separator)
    }
    var count: Int {
        return self.characters.count
    }
    func toArray() -> [String] {
        return self.characters.map{String($0)}
    }
    func uppercased() -> String {
        return self.uppercaseString
    }
    func lowercased() -> String {
        return self.lowercaseString
    }
}
//extension Array where Element == String {
//    func joined(separator separator: String) -> String {
//        return self.joinWithSeparator(separator)
//    }
//}
extension Array where Element: Comparable {
    func max() -> Element {
        return self.maxElement()!
    }
    func min() -> Element {
        return self.minElement()!
    }
    func sorted() -> Array {
        return self.sort()
    }
    func reversed() -> Array {
        return self.reverse()
    }
    mutating func sort() {
        self.sortInPlace()
    }
}
extension Array {
    init(repeating: Element, count: Int) {
        self.init(count: count, repeatedValue: repeating)
    }
}
func stride<T: Strideable>(from start: T, to end: T, by stride: T.Stride) -> StrideTo<T> {
    return start.stride(to: end, by: stride)
}
func exponentiate(lhs: Int, _ rhs: Int) -> Int {
    return (0..<rhs).reduce(1){i,_ in i*lhs}
}
#endif
func readInt() -> Int? {
    return Int(readLine()!)
}
func readStringSplit(by separator: String) -> [String] {
    return readLine()!.split(by: separator)
}
func readIntSplit(by separator: String) -> [Int] {
    return readLine()!.split(by: separator).map{Int($0)!}
}

/*************** テストスペース ***************/



/*************** メインプログラム ***************/

let input = readIntSplit(by: " ")
let (N, L) = (input[0], input[1])
var S = [String]()
for _ in 0..<N {
    S += [readLine()!]
}
print(S.sorted().joinWithSeparator(""))


Measured memory_bytes: 9828
#include <bits/stdc++.h>
using namespace std;
int main(){
	vector <vector<int> > A (5);
	int temp_1,temp_2,temp;
	for(int i=0; i<3; i++){
		cin>>temp_1;
		cin>>temp_2;
		A[temp_1].push_back(temp_2);
		A[temp_2].push_back(temp_1);
	}
	int V[5]={0,0,0,0,0};
	int ans=0;
	int breaki=0;
    if((A[1].size()==1 || A[1].size()==2) && (A[2].size()==1 || A[2].size()==2) 
	&& (A[3].size()==1 || A[3].size()==2) && (A[4].size()==1 || A[4].size()==2)){
       for(int i=1; i<=4; i++){
       	V[1]=0;
       	V[2]=0;
       	V[3]=0;
       	V[4]=0;
       	temp=i;
       	while((V[1]==0 || V[2]==0 || V[3]==0 || V[4]==0) && breaki==0){
       		if(V[A[temp][0]]==0){
       			V[A[temp][0]]=1;
       			temp=V[A[temp][0]];
			   }else{
			   	 if(A[temp].size()==1){
			   	 		ans--;
						breaki=1;
			   	 
					}else{
						if(V[A[temp][1]]==0){
							V[A[temp][1]]=1;
							temp=V[A[temp][1]];
							
						}else{
							ans--;
							breaki=1;
							
						}
					}
			   }
		   }
		   
		   ans++;
	   }	
	   
	   if(ans>0){
	   	cout<<"YES";
	   	
	   }else{
	   	cout<<"NO";
	   }
	   
	   
	   
	}else{
	cout<<"NO";
	}
}

Measured memory_bytes: 256
INF = 99999999999999999999999999
n = int(input())
graph = [[-1] * (n+1) for _ in range(n+1)]
mst = [[-1] * (n+1) for _ in range(n+1)]
V = [ele for ele in range(1, n+1)]
T = []

for i in range(1, n + 1):
    tmp = [int(ele) for ele in input().split()]
    graph[i][1:] = tmp


def my_mst_solver():
    # あるノード n の辺の集合から、もっとも軽いもののindexを知りたい
    # sortされていればすぐだが、graphは添字と依存しているため、sortはできない
    # なので、(w,to) という形で表現された辺のリストがあると非常に便利になるのではないか。
    # これって隣接リストの拡張か？？まあいいや
    ans = 0
    edges = [[0]]
    for i in range(1, n + 1):
        tmp = []
        for to, w in enumerate(graph[i][1:], 1):
            if w != -1:
                tmp.append([w, to])
        tmp.sort()  # pythonのlist.sort()は安定ソートかつ、要素が配列の場合はele[0]でソートする
        edges.append(tmp)

    # 1. Gから任意の頂点 r を選び、それをMSTのルートとしてTに追加する
    root = 1
    T.append(root)
    # 2. 次の処理を T = V になるまで繰り返します。
    # Tに属する頂点と　V - T に属する頂点をつなぐ辺の中で、重みが最小のものである辺 (p_u, u) を選び、
    # それを MST の辺とし、 u を T に追加します

    while set(T) != set(V):
        tmp = [INF, INF]
        for i in T:
            if edges[i] != [] and edges[i][0] < tmp:
                tmp = edges[i][0]
                idx = i
        else:
            # T, MSTの更新
            ans += tmp[0]
            T.append(tmp[1])
            mst[idx][tmp[1]] = tmp[0]
            mst[tmp[1]][idx] = tmp[0]
            # edgesの更新
            for k in range(1, n + 1):
                edges[k] = list(filter(lambda x: x[1] not in T, edges[k]))

    print(ans)


if __name__ == "__main__":
    my_mst_solver()



Measured memory_bytes: 6716
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define ALL(x) (x).begin(), (x).end()
#define REP(i ,n) for(int i = 0; i < (int)(n); i++)
#define pb push_back
typedef vector<int>vint;
typedef vector<ll>vll;
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

bool cmp(vint A, vint B){
    REP(i,A.size()){
        if(A[i] != B[i]) return false;
    }
    return true;
}

int main()
{
    int N;
    cin >> N;
    vint P(N),Q(N);
    cin >> P;
    cin >> Q;
    vint R;
    REP(i,N){
        R.pb(i+1);
    }
    vector<vint> coll;

    do{
        vint S;
        for(auto r:R)S.pb(r);
        coll.pb(S);
    }while(next_permutation(R.begin(),R.end()));

    sort(coll.begin(),coll.end());
    int pidx=0;
    int qidx=0;
    REP(i,coll.size()){
        if(cmp(coll[i],P))pidx=i;
        if(cmp(coll[i],Q))qidx=i;
    }
    cout << abs(pidx-qidx) << endl;
}

Measured memory_bytes: 6304
/*
A fallen time that's bygone
A crude elite that's from a distant zone
You turn a blind eye on what's "brave"
You don't know if it's the truth you told

Anger looks on the quiet dreaming
Seals the sense incandescent ones

Hold back desire for danger
A bet you lose, you'll have no way to turn
I see the man who lives and breathes corruption
Into a circle that you call your own

Don't run away, from the pain. A claim that you deal with
A power game, from within. Impossible for you to see this

Laid down the laws of deceit
The ones who cherish are the ones who'll go
Into the ashes of a tortured world
Only in mind's eye can you see a light

Harmony breaks, dark awakes, in old eyes - the trouble, feel it
Here to stay, mark the way, improvise the judgement hearing

Don't run away, from the pain. A claim that you deal with
A power game, from within. Impossible for you to see this

Anger looks on the quiet dreaming
Seals the sense incandescent ones

All remains of the glowing embers
Is a bleak cold irrelevance
*/

#pragma GCC optimize("O3")
#define _CRT_SECURE_NO_WARNINGS
#include <fstream>
#include <iostream>
#include <string>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <ctime>

#include <memory.h>
#include <assert.h>

#define y0 sdkfaslhagaklsldk

#define y1 aasdfasdfasdf
#define yn askfhwqriuperikldjk
#define j1 assdgsdgasghsf
#define tm sdfjahlfasfh
#define lr asgasgash
#define norm asdfasdgasdgsd
#define have adsgagshdshfhds
#define ends asdgahhfdsfshdshfd
#define prev asdgSHJsfgsdfhdsh
#define hash asdgasdgasdgdfrywewery

#define eps 1e-9
#define M_PI 3.141592653589793
#define bsize 300

#define ldouble long double
using namespace std;

#define bs 1000000007

const int N = 610031;

long long n,ans;

int main(){
//    freopen("apache.in","r",stdin);
//    freopen("apache.out","w",stdout);
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(0);
    //cin.tie(0);

    cin>>n;

    for (int v=1;v<=1000000;v++){
    	long long P=n/v;
    	if (n%v)
    		continue;
    	if (v>=P-1)
    		continue;
    	ans+=P-1;
    }

    cout<<ans<<endl;

//    cin.get(); cin.get();
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <utility>
#include <set>
#include <stack>
#include <climits>
#include <cmath>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define reps(i,s,n) for(int i=s, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
typedef long long ll;
const char sp = ' ';


using namespace std;

int main(void){
    ll N;
    ll p;
    cin>>N;
    ll count=0;
    ll thc=0;
    rep1(i, N){
        cin>>p;
        if(p==i) thc++;
        else{
            
            if(thc>=1) count+=(thc-1)/2+1;
            thc=0;
        }
        //cout<<thc<<endl;
    }
    if(thc>=1) count+=(thc-1)/2+1;
    thc=0;
    cout<<count<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(c) begin(c), end(c)
#define dump(x) cerr << __LINE__ << ":\t" #x " = " << (x) << endl

struct segtree {
    vector<int> lazy, dat;
    int n;

    segtree(int n_, int init){
        n = 1;
        while(n < n_) n *= 2;
        dat.assign(n*2, init);
        lazy.assign(n*2, -1);
    }


    void set(int l, int r, int x){
        static queue<tuple<int,int,int>> q;
        q.emplace(0, n, 1);
        while(q.size()){
            int segl, segr, n;
            tie(segl, segr, n) = q.front();
            q.pop();
            push(segl, segr, n);
            if(segr <= l || r <= segl);
            else if(l <= segl && segr <= r) lazy[n] = x;
            else {
                int segm = (segl + segr) / 2;
                q.emplace(segl, segm, n*2);
                q.emplace(segm, segr, n*2+1);
            }
        }
    }

    int get(int k){
        return get(k, 0, n, 1);
    }

    int get(int k, int segl, int segr, int n){
        push(segl, segr, n);
        if(segl + 1 == segr) return dat[n];
        int segm = (segl + segr) / 2;
        if(k < segm) return get(k, segl, segm, n*2);
        else return get(k, segm, segr, n*2+1);
    }

    void push(int segl, int segr, int node){
        if(lazy[node] != -1){
            dat[node] = lazy[node];
            if(segl + 1 != segr){
                lazy[node*2] = lazy[node];
                lazy[node*2+1] = lazy[node];
            }
            lazy[node] = -1;
        }
    }
};

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

    int n, q;
    cin >> n >> q;
    segtree st(n, 2147483647);
    for(int iq = 0; iq < q; ++iq){
        int t;
        cin >> t;
        // dump(t);
        if(t == 0){
            int s, t, x;
            cin >> s >> t >> x;
            ++t;
            st.set(s, t, x);
        } else {
            int i;
            cin >> i;
            cout << st.get(i) << '\n';
        }
    }
}

Measured memory_bytes: 4932