akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
 
signed main(){
cin.tie(0);
ios::sync_with_stdio(false);
 
    int N;
    cin >> N;
    int ans = 0, asum = 0, bsum = 0, absum = 0;
    REP(i, N) {
        string S;
        cin >> S;
        REP(j, S.size() - 1) {
            if (S[j] == 'A' && S[j + 1] == 'B') ans++;
        }
        if (S[0] == 'B' && S[S.size() - 1] == 'A') absum++;
        else if (S[0] == 'B') bsum++;
        else if (S[S.size() - 1] == 'A') asum++;
    }
    if (asum == 0 && bsum == 0 && absum!=0)   absum--;

    cout << ans + min(asum + absum, bsum + absum) << endl;
 
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const LL mod=1e9+7;
const int maxn=2e5+10;
const LL inf=1e18;
typedef pair<LL,int> P;
int main()
{
    LL k;
    scanf("%lld",&k);
    LL res=0;
    for(LL i=1;i<=k;i++){
        for(LL j=1;j<=k;j++){
            for(LL l=1;l<=k;l++){
                LL pre=__gcd(i,j);
                pre=__gcd(pre,l);
                res+=pre;
            }
        }
    }
    printf("%lld\n",res);
    return 0;
}


Measured memory_bytes: 3828
#include <bits/stdc++.h>
using namespace std;
#define int long long
using ll=long long;
using vi=vector<int>;
using vl=vector<long long>;
using pii=pair<int,int>;
using pll=pair<long long,long long>;
#define ITR(i,c) for(auto i=begin(c);i!=end(c);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define REPW(i,n) for(i=0;i<(int)(n);++i)
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define OUTOFRANGE(y,x,h,w) (y<0||x<0||y>=h||x>=w)
#define dump(...)
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
#define INF (1001001001)
#define INFLL (1001001001001001001ll)
template<class T> ostream& operator << (ostream &os,const vector<T> &v) {
    ITR(i,v) os << *i << (i==end(v)-1 ? "" : "\n"); return os; }
template<class T> istream& operator >> (istream &is,vector<T> &v) {
    ITR(i,v) is >> *i; return is; }
template<class T> istream& operator >> (istream &is, pair<T,T> &p) {
        is >> p.first >> " " >> p.second; return is; }
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;}
//------------------------------------------------------------------------------
struct before_main_function {
    before_main_function() {
        #ifdef int
            #undef INF
            #define INF INFLL
            #define stoi stoll
        #endif
        cin.tie(0);ios::sync_with_stdio(false);
        cout<<setprecision(15)<<fixed;
        #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

map<int,int> m;
signed main() {
    int n;
    cin>>n;
    REP(i,n) {
        int a;
        cin>>a;
        m[a]++;
    }
    int x=-1,y=-1;
    for(auto itr=rbegin(m);itr!=rend(m);itr++) {
        if(itr->second>=4) {
            if(x==-1) {
                x=y=itr->first;
                break;
            }
        }
        if(itr->second>=2) {
            if(x==-1) {
                x=itr->first;
            } else if(y==-1) {
                y=itr->first;
                break;
            }
        }
    }
    if(x==-1 || y==-1) {
        cout<<0<<endl;
    } else {
        cout<<x*y<<endl;
    }
    return 0;
}


Measured memory_bytes: 6528
n = int(input())
ABC = [list(map(int, input().split())) for i in range(n)]

# i日目にjを選択した後の幸福度 dp[i][j]
dp = [[0 for j in range(3)] for i in range(n + 1)]

for i in range(n):
    for j in range(3):
        for k in range(3):
            if j == k:
                continue
            dp[i + 1][k] = max(dp[i + 1][k], dp[i][j] + ABC[i][k])

print(max(dp[-1]))


Measured memory_bytes: 47328
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

def root(x):
    if par[x] == x:
        return x
    par[x] = root(par[x])
    return par[x]

def union(x,y):
    x = root(x)
    y = root(y)
    if rank[x] < rank[y]:
        par[x] = y
    else:
        par[y] = x
        if rank[x] == rank[y]:
            rank[x] += 1


n,m,k = LI()
ab = [LI() for _ in range(m)]
cd = [LI() for _ in range(k)]

par = [i for i in range(n)]
rank = [0]*n

cnt = [0]*n
cnt2 = [0]*n
for a,b in ab:
    if root(a-1) != root(b-1):
        union(a-1,b-1)
    cnt[a-1] += 1
    cnt[b-1] += 1

for c,d in cd:
    if root(c-1) != root(d-1):
        continue
    cnt2[c-1] += 1
    cnt2[d-1] += 1

f = defaultdict(int)
for i in range(n):
    f[root(i)] += 1

ans = [0]*n
for i in range(n):
    ans[i] = f[root(i)] -1 -cnt2[i] - cnt[i]

print(*ans)  



Measured memory_bytes: 123740
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <iomanip>
#include <map>
#include <bitset>
#include <cstdio>
#include <set>
#include <stack>
#include <queue>
#include <cassert>
#include <numeric>
#define rep(i,n) Rep(i,0,n)
#define Rep(i,k,n) for(int i=k ; i<n ; i++)
#define rep1(i,n) for(int i=1 ; i<=n ; i++)
#define vi vector<int>
#define vii vector<vector<int>>
#define mii map<int,int>
#define Sort(v) sort(v.begin(),v.end())
#define Reverse(v) reverse(v.begin(),v.end())
#define ALL(a)  (a).begin(),(a).end()
#define pb push_back
//#define int ll
typedef long long ll;

const int md = 1000000007;
const int INF = 1<<30;
using namespace std;

string yn(bool x){
    return x ? "Yes" : "No";
}

int main(){
    int n; cin >> n;
    int m; cin >> m;
    int x[m];
    rep(i,m){
        cin >> x[i];
    }

    sort(x,x+m);

    vector<int> d;
    rep(i,m-1){
        d.push_back(x[i+1] - x[i]);
    }

    Sort(d);
    reverse(d.begin(),d.end());

    int ans = x[m-1] - x[0];

    if(n >= m) ans = 0;
    else{
        rep(i,n-1){
            ans -= d[i];
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 1276
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)



typedef long long ll;
#define INF 1LL<<60
int N, M, K;
int A[101010];
//-----------------------------------------------------------------
ll dp[101010][300];
int main() {
	cin >> N >> M >> K;
	rep(i, 1, N + 1) scanf("%d", &A[i]);

	rep(i, 1, N + 1) {
		dp[i][1] = A[i];
	}

	rep(j, 2, K + 1) {
		deque<int> deq;
		rep(i, 1, N + 1) {
			while (deq.size() && dp[deq.back()][j - 1] <= dp[i][j - 1]) deq.pop_back();
			deq.push_back(i);
			ll ma = dp[deq.front()][j - 1];
			if (0 < ma) dp[i + 1][j] = ma + (ll)j * A[i + 1];
			if (deq.front() == i - M + 1) deq.pop_front();
			
		}
	}

	ll ans = 0;
	rep(i, 1, N + 1) ans = max(ans, dp[i][K]);

	/*rep(j, 1, K + 1) rep(i, 1, N + 1) {
	printf("dp[%d][%d] = %lld\n", i, j, dp[i][j]);
	}*/

	cout << ans << endl;
}

Measured memory_bytes: 235008
// AOJ 2409

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main(void)
{
	int n, m;
	cin >> n >> m;
	vector <pair <int, int> > data(m);
	for (int i = 0; i < m; i++){
		cin >> data[i].first >> data[i].second;
	}
	
	int now = 1, ret = 0;
	
	while (1){
		int ma = 0, japlj;
		bool flag = false;
		for (int i = 0; i < m; i++){
			if (data[i].first <= now && now <= data[i].second){
				// cout << "*";
				ma = max(ma, data[i].second);
				flag = true;
			}
		}
		// puts("");
		if (!flag) break;
		now = ma + 1;
		ret++;
		// cout << flag << " " << now << endl;
		// cin >> japlj;
		
		if (n < now) break;
	}
	
	if (n < now){
		cout << ret << endl;
	}
	else {
		cout << "Impossible" << endl;
	}
	
	
	#if 0
	int now = 1, ret = 0;
	
	while (now < n){
		int ma = 0;
		bool flag = false;
		for (int j = 0; j < m; j++){
			if (data[j].first <= now){
				ma = max(ma, data[j].second);
				flag = true;
			}
		}
		if (ma != 0){
			now = ma + 1;
			ret++;
		}
		// cout << now << endl;
		if (!flag) break;
	}
	
	if (n < now){
		cout << ret << endl;
	}
	else {
		cout << "Impossible" << endl;
	}
	#endif
	
	return 0;
	
}

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

int main() {
int n;
int count = 0;
  cin >> n;
vector<int> p(n);
  
  for (int i = 0; i < n; i++) 
  {
    cin >> p.at(i);
  }
  for(int i = 1; i < n-1; i++)
  {
    if ( p.at(i) < p.at(i+1) &&  p.at(i-1) < p.at(i)|| p.at(i) > p.at(i+1) &&  p.at(i-1) > p.at(i))
    {
      count++;
    }
  }
  cout << count << endl;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int mod=1000000007;
int N,K;
long ans;
vector<long> X(100100);
long power(long a, long n, long m)
{
        long ret = 1;
        for (; n > 0; n >>= 1, a = a * a % m)
        {
                if (n % 2 == 1)
                {
                        ret = ret * a % m;
                }
        }
        return ret;
}

vector<long> divisor(long n)
{
        vector<long> res;
        for(long i = 1; i * i <= n; i++)
        {
                if(n % i == 0)
                {
                        res.push_back(i);
                        if(i * i != n) res.push_back(n / i);
                }
        }
        sort(res.begin(), res.begin());
        return res;
}

main()
{
        cin>>N>>K;
        for(int i=K;i>0;i--)
        {
                long res=((power(K/i,N,mod)-X[i])%mod+mod)%mod;
                ans=(ans+res*i+mod)%mod;
                vector<long> d=divisor(i);
                for(auto &it : d)X[it]=(X[it]+res+mod)%mod;
        }
        cout<<ans<<endl;
}

Measured memory_bytes: 3824
#include <bits/stdc++.h>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x)      begin(x),end(x)

using namespace std;
using vecint = vector<int>;
using ll = int64_t;
constexpr ll MOD = 1000000007;

ll frac[3000];
ll fracinv[3000];

// a^-1 mod p
ll inv(ll a,ll p){
  return ( a == 1 ? 1 : (1 - p*inv(p%a,a)) / a + p );
}

void init() {
  frac[0] = 1;
  fracinv[0] = 1;
  FOR(i,1,3000) {
    frac[i] = (i * frac[i-1]) % MOD;
    fracinv[i] = inv(frac[i], MOD);
  }
}

ll comb(ll n, ll k) {
  ll tmp = (frac[n] * fracinv[k]) % MOD;
  return (tmp * fracinv[n-k]) % MOD;
}

int main()
{
  init();
  ll n,k;
  cin>>n>>k;
  FOR(i,1,k+1) {
    if (n-k+1 < i) {
      cout << 0 << endl;
      continue;
    }
    ll res = (comb(n-k+1, i) * comb(k-1, i-1)) % MOD;
    cout << res << endl;
  }
  return 0;
}


Measured memory_bytes: 256
def main():
    N, M = map(int, input().split())
    A = list(map(int, input().split()))
    A.sort(reverse=True)
    ans = 1
    for i in range(M):
        if A[i] < sum(A)/(4*M): ans = 0

    if ans == 1: print("Yes")
    else: print("No")


main()

Measured memory_bytes: 3060
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        long[] L = new long[N + 1];
        L[0] = 2;
        L[1] = 1;

        for (int i = 2; i < N + 1; i++) {
            L[i] = L[i - 1] + L[i - 2];
        }

        PrintWriter out = new PrintWriter(System.out);
        out.println(L[N]);

        sc.close();
        out.flush();
    }
}

Measured memory_bytes: 35548
#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
#include<math.h>
#include<unordered_map>
using namespace std;
using LL = long long;
const long long INF = 1e16;
int main(){
    int N;
    cin >> N;
    int K;
    cin >> K;
    int h[111111];
    for(int i = 1;i <= N;i++){
        cin >> h[i];
    }
    sort(h+1, h+N+1);
    LL ans = INF;
    for(int i = 1;i <= N-K+1;i++){
        if(h[i+K-1]-h[i] < ans)ans = h[i+K-1]-h[i];
    }
    cout << ans;
}



Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define pi acos(-1.0)
const ll INF = 1LL<<61;
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
ll jou(ll N, ll P){if(P==0) return 1;
  if(P%2==0){ll t = jou(N, P/2);return t*t % mod;
  }return (N * jou(N, P-1)) % mod;}  //jou(n,mod-2)で逆元
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//  cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる




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

  int x=n%11;

  if(x==0) cout << 2*(n/11) << endl;
  else if(x<=6) cout << 2*(n/11)+1 << endl;
  else cout << 2*(n/11)+2 << endl;

}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <unordered_map>
#include <unordered_set>
using namespace std;

#define ABS(a) (((a) >= 0) ? (a) : -(a))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) > (b) ? (b) : (a))
#define FOR(i, a, b) for (int i = (a); i <= (b); ++i)
#define RFOR(i, a, b) for (int i = (a); i >= (b); --i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
// 変えた(00000000)
#define NINTH_POWER_OF_TEN 100000000000000000
#define int long long

typedef long long ll;
typedef pair<int, int> Pair;

const int kMaxM = 100000;

int n, m, s, t;
int u[kMaxM], v[kMaxM], a[kMaxM], b[kMaxM];
int ans = 0;

// AdjacencyListGraph begin

class AdjacencyListGraph {
 public:
  class Edge {
   public:
    int to, cost;
    Edge(int to, int cost) : to(to), cost(cost) {}
  };

  int n;
  vector<vector<Edge>> es;
  vector<int> ds;
  AdjacencyListGraph(int n) :
  n(n), es(n), ds(n, NINTH_POWER_OF_TEN) {}

  void AddEdge(int from, int to, int cost) {
    Edge e(to, cost);
    es[from].push_back(e);
    return;
  }

  int Dfs(int v) {
    // something
    REP(i, es[v].size()) {
      Edge& e = es[v][i];
      // something
      Dfs(e.to);
    }
    // something
    return 0;
  }

  void Dijkstra(int s) {
    ds[s] = 0;
    priority_queue<Pair, vector<Pair>, greater<Pair>> q;

    q.push(Pair(0, s));
    while (!q.empty()) {
      Pair p = q.top(); q.pop();
      int d = p.first, v = p.second;
      if (ds[v] < d) { continue; }

      REP(i, es[v].size()) {
        Edge e = es[v][i];
        int nd = ds[v] + e.cost;
        if (nd < ds[e.to]) {
          ds[e.to] = nd;
          q.push(Pair(nd, e.to));
        }
      }
    }
  }
};

// AdjacencyListGraph end


signed main() {
  cin >> n >> m >> s >> t;
  REP(i, m) { cin >> u[i] >> v[i] >> a[i] >> b[i]; }

  AdjacencyListGraph yens(n+1);
  AdjacencyListGraph yent(n+1);
  AdjacencyListGraph snukes(n+1);
  AdjacencyListGraph snuket(n+1);
  REP(i, m) {
    yens.AddEdge(u[i], v[i], a[i]);
    yens.AddEdge(v[i], u[i], a[i]);
    yent.AddEdge(u[i], v[i], a[i]);
    yent.AddEdge(v[i], u[i], a[i]);
    snukes.AddEdge(u[i], v[i], b[i]);
    snukes.AddEdge(v[i], u[i], b[i]);
    snuket.AddEdge(u[i], v[i], b[i]);
    snuket.AddEdge(v[i], u[i], b[i]);
  }
  yens.Dijkstra(s);
  yent.Dijkstra(t);
  snukes.Dijkstra(s);
  snuket.Dijkstra(t);

  Pair ps[n+1];
  ps[0] = Pair(NINTH_POWER_OF_TEN, 0);
  FOR(i, 1, n) {
    int cost = yens.ds[i] + snuket.ds[i];
    ps[i] = Pair(cost, i);
  }
  sort(ps, ps+n+1);

  int pi = 0;
  REP(i, n) {
    Pair p = ps[pi];
    while (p.second <= i) { p = ps[++pi]; }
    cout << 1000000000000000 - p.first << endl;
  }

  return 0;
}


Measured memory_bytes: 39288
import heapq
N, M = map(int, input().split())
h = []
for i in input().split():
    heapq.heappush(h, int(i))
data = [list(map(int, input().split())) for _ in range(M)]
data = sorted(data, reverse=1, key=lambda x: x[1])
for b, c in data:
    for j in range(b):
        a = heapq.heappushpop(h, c)
        if a == c:
            print(sum(h))
            exit()
print(sum(h))

Measured memory_bytes: 88728
import sys
sys.setrecursionlimit(10**8)

n = int(input())

def dfs(s, mx):
    if len(s) == n:
        print(s)
        return
    for i in range(ord('a'), mx + 2):
        t = s
        t += chr(i)
        mxc = mx
        mxc = max(mxc, i)
        dfs(t, mxc)
    return


mx = ord('a')
dfs('a', mx)

Measured memory_bytes: 56024
#include <bits/stdc++.h>
#include <string>
#include <algorithm>
#include <string.h>
#include <ctype.h>
#include <math.h>
#include <float.h>
#include <iomanip>
#include <iostream>
using namespace std;
 
int main(){

    long long N,A[200020]={},x=0,y=0;
    cin>>N;
    for(int i=0;i<N;i++){
        cin>>A[i];
    }

    int l=0,r=N-1;
    while(l!=r){
        if(x<=y){
            x+=A[l];
            l++;
        }else{
            y+=A[r];
            r--;
        }
    }

    if(x<=y){
        x+=A[l];
        l++;
    }else{
        y+=A[r];
        r--;
    }

    cout <<abs(x-y)<<endl;
    
    return 0;

}


Measured memory_bytes: 1792
#include <iostream>
#include <iomanip>
#include <random>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <sstream>
#include <bitset>
#include <cassert>
#include <fstream>
#include <queue>

#define len(X) ((int)(X).size())

#ifdef __LOCAL
	#define DBG(X) cout << #X << "=" << (X) << '\n';
#else
	#define DBG(X)
#endif
 
using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld  = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int INT_INF = (int)(2e9);
const ll  LL_INF  = (ll)(2e18);

const int NIL = -1;
static mt19937 _g(time(nullptr));

inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for(auto el: v) cout << el << " "; return os; }
template<typename T> inline T fetch() { T ret; cin >> ret; return ret; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for(auto& elem: ret) cin >> elem; return ret; }

void solve() {
	int n = fetch<int>();
	int m = fetch<int>();

	vector<int> cnt(n, 1), flag(n, 0);
	vector<pii> acts(m);
	flag[0] = 1;

	for(auto& act: acts) {
		act.first  = fetch<int>() - 1;
		act.second = fetch<int>() - 1;
	}

	for(auto& act: acts) {
		if(flag[act.first]) {
			flag[act.second] = 1;
		}

		if(cnt[act.first] == 1) {
			flag[act.first] = 0;
		}

		--cnt[act.first];
		++cnt[act.second];
	}

	int answ = 0;

	for(auto& elem: flag) {
		answ += elem;
	}

	cout << answ << '\n';
}

int main() {
	fast_io();
	solve();

	return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
typedef pair<ll, ll> P;
#define MOD 998244353
ll gcd(ll a, ll b) {
    return (b==0) ? a : gcd(b, a%b);
}

int main() {

    int n; cin >> n;
    string s; cin >> s;
    if (n % 2 != 0) {
        cout << "No" << endl;
        return 0;
    }
    int d = n/2;
    
    string ans = "Yes";
    rep (i,d) {
        if (s[i] != s[i+d]) {
            ans = "No";
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		String s1 = scan.next();
		String s2 = scan.next();
		String s3 = scan.next();

		System.out.println("A"+s2.charAt(0)+"C");
	}

}


Measured memory_bytes: 23124
n = int(input())
li = list(map(int, input().split()))
li_a = []
for i in range(n-1):
  if li[i] < li[i+1]:
    li_a.append(i+1)
if len(li_a) == 1:
  print(n - li_a[0] - 1)
elif len(li_a) == 0:
  print(n-1)
else:
  li_b = []
  for j in range(len(li_a)-2):
    li_b.append(li_a[j+1]-li_a[j]-1)
  li_b.append(n - li_a[-1] - 1)
  print(max(li_b))

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

int main() {
	string S;
	cin >> S;
	
	for (int i = 0; i < S.size(); ++i) {
    	if (i % 2 == 1 && S[i] == 'R') { 
        	cout << "No";
      		return 0;
    	} else if (i % 2 == 0 && S[i] == 'L') {
        	cout << "No";
        	return 0;
        }
    }
	cout << "Yes";
}

Measured memory_bytes: 256
import java.util.*; 
import java.lang.*; 


public class Main{
    
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
                
                int N = scan.nextInt();
                int cnt=0;
                
                for(int i=1; i<=Math.sqrt(N); i++){
                    for(int j=N; i<=j; j--){
                        if(i*j<=N-1){
                            if(i==j){
                                cnt++;
                            }else{
                                cnt+=2;
                            }
                        }                     
                    }
                }
                
                System.out.println(cnt);

        }
}

Measured memory_bytes: 36296
#include <bits/stdc++.h>
using namespace std;
enum {
  ATT, DEF, SAV
};
class Player {
  public:
    int power;
    int state;
    bool powerflag;
    Player() {
      power = 0;
      powerflag = false;
    }
    void def() {
      if(powerflag) power = 0;
      powerflag = false;
      state = DEF;
    }
    void att() {
      state = ATT;
      if(powerflag) power = 0;
      powerflag = true;
    }
    void sav() {
      state = SAV;
      if(powerflag) power = 0;
      powerflag = false;
      if(power < 5) ++power;
    }
};
int isOvered(Player, Player);

int main() {
  int n;
  cin >> n;
  vector<vector<int>> commands(2);
  for(int t = 1; t >= 0; --t) {
    for(int i = 0; i < n; ++i) {
      string command;
      cin >> command;
      commands[t].push_back(
        command == "kougekida" ? ATT :
        command == "mamoru" ? DEF :
        SAV
      );
    }
  }
  Player nakajima, isono;
  for(int i = 0; i < n; ++i) {
    int t = 0;
    auto operate = [&](Player& player) {
      (
        (commands[t][i] == ATT) ? player.att() :
        (commands[t][i] == DEF) ? player.def() :
        player.sav()
      );
      ++t;
    };
    operate(nakajima);
    operate(isono);
    if(isOvered(nakajima, isono) >= 0) {
      cout << (isOvered(nakajima, isono) ? "Isono-kun" : "Nakajima-kun") << endl;
      return 0;
    }
  }
  cout << "Hikiwake-kun" << endl;
  return 0;
}

int isOvered(Player a, Player b) {
  auto def = [&](int num) {
    return (
      num == ATT ? "ATT" :
      num == DEF ? "DEF" :
      "SAV"
    );
  };
  // cout << def(a.state) << ", " << a.power << ",  " << def(b.state) << ", " << b.power << endl;
  bool t = false;
  do {
    Player me, you;
    (t ? you : me) = a;
    (t ? me : you) = b;
    // cout << "t: " << t << endl;
    if(me.state == ATT && you.state == ATT) {
      if(me.power == you.power) return -1;
      if(me.power > you.power) return t;
    } else if(me.state == ATT && me.power == 0) {
      return !t;
    } else if(me.state == ATT && you.state == DEF) {
      if(me.power == 5) return t;
      return -1;
    } else if(me.state == ATT && you.state == SAV) {
      return t;
    }
  } while(t = !t, t);
  return -1;
}

Measured memory_bytes: 1236
K = int(input())
A = list(map(lambda x:int(x), input().split(" ")))
A.reverse()

n = [2,2]

for a in A:

    n1 = (n[0]//a+(1 if n[0]%a>0 else 0))*a
    n2 = (n[1]//a)*a
    # print([n,n1,n2,a])
    if n1>n2:
        print("-1")
        exit()
    n[0] = n1
    n[1] = n2+a-1

if len(n)>0:
    print(min(n),max(n))
else:
    print("-1")


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

using namespace std;

#define N 600
#define M 120000

int n,m,a[M],b[M],ans;
bool f[N][N];

int main(){
    scanf("%d%d",&n,&m);
    for (int i=1;i<=m;i++)
        scanf("%d%d",&a[i],&b[i]);
    for (int i=1;i<=n;i++){
        f[i][i]=1;
        for (int j=m;j;j--){
            if (f[i][a[j]] && f[i][b[j]]){f[i][0]=1; break;}
            if (f[i][a[j]] || f[i][b[j]]) f[i][a[j]]=f[i][b[j]]=1;
        }
    }
    for (int i=1;i<=n;i++)
        for (int j=1;j<i;j++)
            if (!f[i][0] && !f[j][0]){
                bool fl=0;
                for (int k=1;k<=n;k++) fl|=(f[i][k]&f[j][k]);
                if (!fl) ans++;
            }
    printf("%d\n",ans);

    return 0;
}


Measured memory_bytes: 1280
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <stdlib.h>
#include <string>
#include <utility>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define loop(i, x, n) for (int i = (x); i < (n); i++)
#define all(v) (v).begin(), (v).end()
#define int long long
using namespace std;
const int MOD = 1e9 + 7;
const int INF = 1e18;
// template<typename T> void cmax(T &a, T b) { a = max(a, b); }
// template<typename T> void cmin(T &a, T b) { a = min(a, b); }

void cmax(string &a, string b) {
  if (a == "-" || a.size() < b.size())
    a = b;
  else if (a.size() == b.size()) {
    if (a < b) a = b;
  }
  return;
}

int num[10] = {0, 2, 5, 5, 4, 5, 6, 3, 7, 6};

signed main() {
  int n, m;
  cin >> n >> m;
  vector<int> a(m);
  rep(i, m) cin >> a[i];
  vector<string> dp(20004, "-");
  dp[0] = "";
  rep(i, n + 1) {
    if (dp[i] == "-") continue;
    for (auto x : a) cmax(dp[i + num[x]], dp[i] + (char)(x + '0'));
  }
  cout << dp[n] << endl;
  return 0;
}


Measured memory_bytes: 43776
import sys

#+++++
		
def main():
	s = input()
	odd=set(['R','U','D'])
	eve=set(['L','U','D'])
	for i,c in enumerate(s):
		if (i+1) % 2 == 1 and c not in odd:
			return 'No'
		elif (i+1) % 2 == 0 and c not in eve:
			return 'No'
	return 'Yes'
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)

if __name__ == "__main__":
	if sys.platform =='ios':
		sys.stdin=open('inputFile.txt')
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Measured memory_bytes: 3064
#[allow(unused_imports)] use proconio::{input, marker::{Bytes, Chars, Usize1, Isize1}};
#[allow(unused_imports)] use std::cmp::{min, max};
#[allow(unused_imports)] use superslice::Ext as _;

#[proconio::fastout]
fn main() {
	input! {
		n: usize,
	}

	let mut tn = n;
	let mut s = 0;
	while tn != 0 {
		s += tn%10;
		tn /= 10;
	}

	if n % s == 0 {
		println!("Yes");
	}
	else {
		println!("No");
	}
}


Measured memory_bytes: 2136
#include<cassert>
#include <boost/multiprecision/cpp_int.hpp>
#define ll long long int
#define CON 100010
const long long mod=1e9+7;
const int INF=1001001001;
//const ll inf=1e9+7;
//const ll ful=1e18;
using namespace std;

//namespace mp = boost::multiprecision;
int main() 
{
	char s;
	cin>>s;
	if(isupper(s))
	{
		cout<<"A"<<endl;
	}
	else 
	{
		cout<<"a"<<endl;
	}
	return 0;
}


Measured memory_bytes: 3620
// AUTHOR : Kishan Srivastav
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
#define in freopen("input.txt", "r", stdin)
#define out freopen("output.txt", "w", stdout)
#define ios ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);


int main() {
	ios
#ifndef ONLINE_JUDGE
	in;
	out;
#endif
	int n;
	cin>>n;
	string s[n];
	map<string,int>m;
	for(int i = 0; i < n ; i++){
		cin>>s[i];
		sort(s[i].begin(),s[i].end());
		m[s[i]]++;
	}
	ll ans = 0;
	for(auto it :m){
		//if(it.second <= 0)continue;
        for(int i = 1;i < it.second;i++)
        	ans += i;
	}
	cout<<ans<<endl;
	
}

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

using namespace std;

typedef long long ll;

ll gcd(ll a , ll b){
	return !a ? b : gcd(b % a , a);
}

void solve(){
	ll A , B , C , D;
	cin >> A >> B >> C >> D;
	if(B > D){
		cout << "No" << endl;
		return ;
	}
	if(A < B){
		cout << "No" << endl;
		return ;
	}
	if(C >= B){
		cout << "Yes" << endl;
		return ;
	}
	if(B == D){
		if(A % B > C){
			cout << "No" << endl;
		}
		else{
			cout << "Yes" << endl;
		}
		return ;
	}
	ll t = gcd(D - B , B);
	ll v = (B - 1 - (A % B)) / t * t + (A % B);
	if(v > C){
		cout << "No" << endl;
	}
	else{
		cout << "Yes" << endl;
	}
}
int main(){
	int T;
	ios::sync_with_stdio(0);
	cin >> T;
	while(T --)
		solve();
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}

int main() {


    int ans = 0;

    int n; cin >> n;
    srep(i,1,n+1){
        int p;
        cin >> p;
        if(p!=i)ans++;
    }

    if(ans<=2)yn;

    return 0;
}
 
 


Measured memory_bytes: 256
from collections import deque

def mymax(a:int, b:int, c:int):
    if a > b:
        if c > a:
            return c
        else:
            return a
    else:
        if c > b:
            return c
        else:
            return b


def main():
    s = input()
    t = input()
    lens = len(s)
    lent = len(t)
    dp = [[0] * (lent+1) for _ in range(lens+1)]


    for i in range(1, lens + 1):
        for j in range(1, lent + 1):
            dp[i][j] = mymax(
                dp[i-1][j-1] + (s[i-1] == t[j-1]),
                dp[i-1][j],
                dp[i][j-1]
            )
    
    string = deque([])
    i = lens; j = lent
    for _ in range(lens+lent+1):
        if s[i-1] == t[j-1]:
            string.appendleft(s[i-1])
            i -= 1
            j -= 1
        else:
            if dp[i-1][j] > dp[i][j-1]:
                i -= 1
            else:
                j -= 1
        if i <= 0 or j <= 0:
            break
    print(''.join(string))

if __name__ == "__main__":
    main()


Measured memory_bytes: 144752
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i,n) for (int i = 0; i < (n); i++)
typedef pair<int,int> P;
const int INF = 100000000;

int W,H;
int sy, sx, gy, gx;

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

bool movable(vector<vector<char>> &c, vector<vector<int>> &mat, int h, int w) {
  if ((h<0) || (h>=H) || (w<0) || (w>=W)) {
    return false;
  }
  else if (mat[h][w]!=INF || (c[h][w]=='#')) {
    return false;
  }
  else {
    return true;
  }
}


int bfs(vector<vector<char>> &c, vector<vector<int>> &mat) {
   
  queue<P> que;
  que.push(P(0,0));
  mat[0][0] = 0;

  while(que.size()) {
    P p = que.front();
    que.pop();

    if ((p.first==H-1)&&(p.second==W-1)) {
      return mat[p.first][p.second];
    }

    rep(i,4){
      if (movable(c,mat,p.first+dy[i],p.second+dx[i])) {
        que.push(P(p.first+dy[i],p.second+dx[i]));
        mat[p.first+dy[i]][p.second+dx[i]]=mat[p.first][p.second]+1;
      }
    }
  }
  return INF;
}

int main() {
  int ans = 0;
  int black = 0;
  cin >> H >> W;

  vector<vector<char>> c(H,vector<char> (W));
  
  rep(h,H) {
    rep(w,W) {
      cin >> c[h][w]; 
      if (c[h][w] == '#') {
        black++;
      }
    }
  }

  vector<vector<int>> mat(H,vector<int> (W, INF));
  int step = bfs(c,mat);
  if (step == INF) {
    cout << -1 << endl;
  } 
  else {
    cout << H*W-black-step-1 << endl;
  }
}

Measured memory_bytes: 256
s = input()

l = 0
r = len(s) - 1

ans = 0
while r > l:
    if s[l] == s[r] == "x":
        l += 1
        r -= 1
    elif s[l] == "x":
        l += 1
        ans += 1
    elif s[r] == "x":
        r -= 1
        ans += 1
    elif s[l] == s[r]:
        l += 1
        r -= 1
    else:
        ans = -1
        break

print(ans)


Measured memory_bytes: 3316
import Foundation
extension String {
    func therefoce() -> String{
        let s = self.suffix(1)
        if s == "3" {return "bon"}
        if s == "0"||s=="1"||s=="6"||s=="8" {return "pon"}
        else {return "hon"}
    }
}

func main(){
    print(readLine()!.therefoce())
}
main()


Measured memory_bytes: 12948
#include <bits/stdc++.h>
 
//#include <unistd.h>
//#include <iostream>
 
using namespace std;
 
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl;
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}
typedef long long ll;
#define int ll
 
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const long double pi = 3.1415926535897932384626433832795028841971L;
#define Sp(p) cout<<setprecision(25)<< fixed<<p<<endl;
//int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
//int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
vi dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
vi dx2 = { 1,1,0,-1,-1,-1,0,1 }, dy2 = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
const ll MOD = 1000000007;
//const ll MOD = 998244353;
// #define mp make_pair
//#define endl '\n'
signed main() {
	string s;
	cin >> s;
	cout << s.substr(0, 4) << " " << s.substr(4, 8) << endl;
}

Measured memory_bytes: 256
N, T = map(int, input().split())
Tlist = list(map(int, input().split()))

ans = 0
for i in range(1,N):
  dif = Tlist[i] - Tlist[i-1]
  if dif >= T:
    ans += T
  else:
    ans += dif

ans += T

print(ans)

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

using namespace std;
using ll =long long;
typedef pair<int,int> P;
#define SORT(a) sort((a).begin(),(a).end())
#define REV(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

void coY() {cout <<"Yes"<<endl;}
void coN(){cout <<"No"<<endl;}
 
//Write From this Line

//const ll mod = 1e9+7;
//const ll mod = 998244353;
int main()
{
	ll x, k, d;
	cin >> x >> k >> d;
	x = abs(x);
	ll koenai = x / d;
	// 超えない回数だけ近づく。
	koenai = min(koenai, k);
	x -= koenai * d;
	k -= koenai;
	if(k % 2 == 0){
		cout << x << endl;
	} else {
		cout << abs(x - d) << endl;
	}
}


Measured memory_bytes: 3636
N = int(input())
A = list(map(int,input().split()))
MAX = max(A)
BIG = 10**9+7
L = len(bin(MAX)[2:])
ans = 0
for j in range(L):
    zero = 0
    one = 0
    for i in range(N):
        if (A[i] >> j) & 1:
            one+=1
        else:
            zero+=1
    ans += ((zero*one)%BIG)*pow(2,j,BIG)
    ans = ans%BIG
print(ans)

Measured memory_bytes: 124456
#include<bits/stdc++.h>
using namespace std;
#define  ft  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define  ll  long long
#define  pi  pair<int,int>
#define  pb  push_back
#define  F   first
#define  S   second
#define  B   begin()
#define  E   end()
const int N=2e5+3;
//string s,p;
//vector<int>v;
//map<int,int>mp;

int main()
{
    ft
    ll t,i,j,n,m,l,r;
    cin>>n>>m>>l;
    r=ceil(n*1.0/l);
    if(r<=m)
    {
        cout<<"Yes\n";
    }
    else
    {
        cout<<"No\n";
    }
    return 0;
}



Measured memory_bytes: 3756
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
using ll = long long;
const int INF = 2147483647;
const ll MOD = 1000000007;
// const ll INF = 1000000000000000000LL;


int main(){
    ll a,b,x;
    cin >> a >> b >> x;
    ll ans;
    ans = b/x-a/x;
    if(a%x==0)
        ans++;
    cout << ans << endl;
}


Measured memory_bytes: 3636
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;

/*
<url:https://arc064.contest.atcoder.jp/tasks/arc064_b>
問題文============================================================
 長さ 3 以上の文字列 s があります。 s の中に同一の文字が隣り合う箇所はありません。
 
 高橋君と青木君がゲームで勝負します。 二人は交互に次の操作を行います。 高橋君が先手です。
 
 s から両端以外の文字をひとつ取り除く。
 ただし、その文字を取り除くことで、s の中に同一の文字が隣り合う箇所ができる場合、その文字を取り除くことはできない。
 先に操作を行えなくなった人が負けです。 二人が最適に行動したとき、どちらが勝つかを判定してください。
=================================================================

解説=============================================================

 いくつかのパターンで実験すると
 最終的に取り除くことができない文字列は
 abacadaeabafa...aza
 といったような形になる
 ここで両端は取り除くことができないので
 両端が同一文字の場合は　奇数長, 異なる文字の場合は 偶数長　の文字列となる
 よって、最初の文字列の偶奇及び両端の文字を見ることによって
 文字列の長さが 偶/奇 => 偶/奇 への変化がわかるので
 先手、後手のどちらで止まるのかがわかる
 
================================================================
*/
void solve(){
    string s; cin >> s;
    cout << ((s.length()%2 == 0)^(s.front() == s.back())?"Second":"First") << endl;
    return;
}
int main(void) {
	cin.tie(0); ios::sync_with_stdio(false);
    solve();
	return 0;
}


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

using namespace std;

using ll = long long;

const long long MOD = 1e9 + 7;
const int INF = 1e9 + 7;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<ll> T(N), A(N);
    for (int i = 0; i < N; ++i) cin >> T[i] >> A[i];
    ll nowT = 1, nowA = 1;
    for (int i = 0; i < N; ++i) {
        ll d = max((nowT + T[i] - 1) / T[i], (nowA + A[i] - 1) / A[i]);
        nowT = T[i] * d;
        nowA = A[i] * d;
    }
    cout << nowT + nowA << endl;
}

Measured memory_bytes: 256
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    x,n=map(int,input().split())
    P = list(map(int,input().split()))
    n_lis = [0]*102
    for p in P:
        n_lis[p] += 1
    dis = 0
    while 1:
        if n_lis[x-dis] == 0:
            print(x-dis)
            break
        elif n_lis[x+dis] == 0:
            print(x+dis)
            break
        dis += 1

if __name__=='__main__':
    main()

Measured memory_bytes: 61996
#pragma once
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
#include <numeric>
#include <iomanip>
#define M_PI acos(-1)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1000000007;
const int MAX_V = 201;
int now = 0;

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
struct edge {
	int t;
	edge(int _t) : t(_t) {}
};
bool use[100010];


vector<edge> te[100010];
vector<edge> fe[100010];
int t[64];
int d[100100];
ll rec(int num) {
	if (num == 0) return 0;
	return rec(num - 1) + num;
}

void Solve() {

	ll a, b, k;
	cin >> a >> b >> k;

	for (size_t i = 0; i < k; i++)
	{
		if (i % 2 == 0) {
			a /= 2;
			b += a;
		}
		else {
			b /= 2;
			a += b;
		}
	}

	cout << a << " " << b << endl;;
}


int main() {
	Solve();
	return 0;
}



Measured memory_bytes: 6016
#include<stdio.h>
#include<string.h>
#include<math.h>

long long int solve(long long int dp[][3], long long int a[], long long int b[], long long int c[], long long int i, int flag)
{
	if(dp[i][flag] != -1)
		return dp[i][flag];
	long long int k;
	if(flag == 0)
		k = a[i];
	else if(flag == 1)
		k = b[i];
	else
		k = c[i];
	dp[i][flag] = k + fmax(solve(dp,a,b,c,i-1,(flag +1)%3),solve(dp,a,b,c,i-1,(flag +2)%3));
	return dp[i][flag];
}
int main()
{
	long long int n, i;
	scanf("%lld", &n);
	long long int a[n+1], b[n+1], c [n+1], dp[n+1][3];
	memset(dp,-1,sizeof(dp));
	for (i = 1; i <= n; ++i)
		scanf("%lld %lld %lld", a + i, b + i, c + i);
	dp[1][0] = a[1];
	dp[1][1] = b[1];
	dp[1][2] = c[1];
	printf("%lld\n", (long long int)fmax(solve(dp,a,b,c,n,0),fmax(solve(dp,a,b,c,n,1),solve(dp,a,b,c,n,2))));
	return 0;
}

Measured memory_bytes: 14208
def test():
    s = input()
    c_0 = s.count("0")
    c_1 = s.count("1")
    if c_0 != 0 and c_1 != 0:
        print(2*min(c_0,c_1))
    else:
        print(0)


if __name__ == "__main__":
    test()


Measured memory_bytes: 3188
#include <bits/stdc++.h>
//#include <atcoder/all>
#define ll long long
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
#define repm(i, a, b) for (ll i = (ll)(a); i > (ll)(b); i--)
#define all(v) v.begin(), v.end()
#define rall(x) (x).rbegin(), (x).rend()
#define pll pair<long long, long long>
#define pb emplace_back
#define mp make_pair
#define mt make_tuple
#define vc vector<char>
#define vvc vector<vc>
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<long long>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vvb = vector<vb>;
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;}
//snippets:tmp,cl,cvl,cs,co,coy,con,cov,setp

const ll M = 998244353893;

vector<ll> fac(300001); //n!(mod M)
vector<ll> ifac(300001); //k!^{M-2} (mod M)
//a,bの範囲的にこれだけ配列を用意していけば十分


int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll n;
  cin >> n;
  ll count=0;
  repi(i,1,n+1){
    count+=(n-1)/i;
  }
  cout<<count<<endl;
}


Measured memory_bytes: 7860
#include<bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  int n, m; cin >> n >> m;
  vector<int> h(n + 1);
  vector<bool> ok(n + 1, true);
  for(int i = 1; i <= n; i++) {
    cin >> h[i];
  }
  for(int i = 0; i < m; i++) {
    int u, v; cin >> u >> v;
    if(h[u] > h[v]) swap(u, v);
    if(h[u] == h[v]) {
      ok[v] = false;
    }
    ok[u] = false;
  }
  int ans = 0;
  for(int i = 1; i <= n; i++) {
    if(ok[i]) ans++;
  }
  cout << ans << '\n';
}

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

int main() {
	int N;
	cin >> N;
	vector<int> B(N - 1);
	for (int& i : B) cin >> i;
	int ans = B.front() + B.back();
	for (int i = 1; i < N - 1; ++i) ans += min(B[i - 1], B[i]);
	cout << ans;
}

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, c, d;
  cin >> a >> b >> c >> d;
  int ans=0;
  if(a > b) ans+=b;
  else ans+=a;
  if(c > d) ans+=d;
  else ans+=c;
  cout << ans << endl;
  return 0;
  
}

Measured memory_bytes: 256
local ffi = require("ffi")
local C = ffi.C
ffi.cdef[[
long long atoll(const char*);
]]

local function lltonumber(str)
  return C.atoll(str)
end

local n = io.read("*n", "*l")
local s = io.read()
local t = {}
for i = 1, 60 do
  t[i] = {}
end
do
  local j = 0
  for w in s:gmatch("%d+") do
    j = j + 1
    local v = lltonumber(w)
    for k = 1, 60 do
      t[k][j] = v % 2LL == 1LL
      v = v / 2LL
    end
  end
end
local flag = {}
for i = 1, 60 do
  flag[i] = 1
end
local pow2 = {}
pow2[1] = 1LL
for i = 2, 61 do
  pow2[i] = pow2[i - 1] * 2LL
end
local ret = 0LL

for ib = 60, 1, -1 do
  local right = false
  local cnt = 0
  local tib = t[ib]
  for i = 1, n do
    if tib[i] then
      cnt = cnt + 1
      right = i
    end
  end
  if flag[ib] == 1 then
    if cnt == 0 then
      -- nothing
    elseif cnt % 2 == 1 then
      ret = ret + pow2[ib]
    else
      ret = ret + pow2[ib + 1]
      for ic = ib - 1, 1, -1 do
        if t[ic][right] then
          flag[ic] = 1 - flag[ic]
          for i = 1, right do
            if tib[i] then
              t[ic][i] = not t[ic][i]
            end
          end
        end
      end
    end
  else--flag[ib] == 0
    if cnt == 0 then
      ret = ret + pow2[ib + 1]
      -- nothing
    elseif cnt % 2 == 1 then
      ret = ret + pow2[ib]
    else
      ret = ret + pow2[ib + 1]
      for ic = ib - 1, 1, -1 do
        if t[ic][right] then
          for i = 1, right do
            if tib[i] then
              t[ic][i] = not t[ic][i]
            end
          end
        end
      end
    end
  end
end
ret = tostring(ret):gsub("LL", "")
print(ret)


Measured memory_bytes: 135076
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

const long long mod = 1000000007;
const long long inf = 1e18;

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    int r,g;
    cin>>r>>g;
    cout<<2*g-r<<endl;
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define ll long long
#define f first 
#define s second
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);
#define mp make_pair
#define pb push_back
int par[100001];
int parent1(int x)
{
	while(par[x]!=x)
	{
		par[x] = par[par[x]];
		x = par[x]; 
	}
	return x;
}
void unite(int x,int y)
{
	int x1 = parent1(x);
	int y1 = parent1(y);
	par[x1] = y1;
}
int main(){
  int n,t,q,r,m,x,y,z;
  FIO;  
  cin >> n >> m;
  for (int i = 0; i < n; ++i)
  {
  	par[i] = i;
  }
  for (int i = 0; i < m; ++i)
  {
  	cin >> x >> y >> z;
  	x--;y--;
  	unite(x,y);
  }
  int ans = 0;	
  for (int i = 0; i < n; ++i)
  {
  	if(par[i] == i)
  		ans++;
  }
  cout << ans << " ";
  return 0;
}

Measured memory_bytes: 640