akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using static System.Math;
using System.Text;
using System.Threading;
using System.Globalization;
using System.Runtime.CompilerServices;
using Library;

namespace Program
{
    public static class ABC042A
    {
        static public int numberOfRandomCases = 0;
        static public void MakeTestCase(List<string> _input, List<string> _output, ref Func<string[], bool> _outputChecker)
        {
        }
        static public void Solve()
        {
            var A = NN;
            var B = NN;
            var C = NN;
            if (new[] { A, B, C }.Count(e => e == 5) == 2 && new[] { A, B, C }.Count(e => e == 7) == 1)
            {
                Console.WriteLine("YES");
            }
            else
            {
                Console.WriteLine("NO");
            }
        }
        static class Console_
        {
            static Queue<string> param = new Queue<string>();
            public static string NextString() { if (param.Count == 0) foreach (var item in Console.ReadLine().Split(' ')) param.Enqueue(item); return param.Dequeue(); }
        }
        class Printer : StreamWriter
        {
            public override IFormatProvider FormatProvider { get { return CultureInfo.InvariantCulture; } }
            public Printer(Stream stream) : base(stream, new UTF8Encoding(false, true)) { base.AutoFlush = false; }
            public Printer(Stream stream, Encoding encoding) : base(stream, encoding) { base.AutoFlush = false; }
        }
        static public void Main(string[] args) { if (args.Length == 0) { Console.SetOut(new Printer(Console.OpenStandardOutput())); } var t = new Thread(Solve, 134217728); t.Start(); t.Join(); Console.Out.Flush(); }
        static long NN => long.Parse(Console_.NextString());
        static double ND => double.Parse(Console_.NextString());
        static string NS => Console_.NextString();
        static long[] NNList(long N) => Repeat(0, N).Select(_ => NN).ToArray();
        static double[] NDList(long N) => Repeat(0, N).Select(_ => ND).ToArray();
        static string[] NSList(long N) => Repeat(0, N).Select(_ => NS).ToArray();
        static IEnumerable<T> OrderByRand<T>(this IEnumerable<T> x) => x.OrderBy(_ => xorshift);
        static long Count<T>(this IEnumerable<T> x, Func<T, bool> pred) => Enumerable.Count(x, pred);
        static IEnumerable<T> Repeat<T>(T v, long n) => Enumerable.Repeat<T>(v, (int)n);
        static IEnumerable<int> Range(long s, long c) => Enumerable.Range((int)s, (int)c);
        static uint xorshift { get { _xsi.MoveNext(); return _xsi.Current; } }
        static IEnumerator<uint> _xsi = _xsc();
        static IEnumerator<uint> _xsc() { uint x = 123456789, y = 362436069, z = 521288629, w = (uint)(DateTime.Now.Ticks & 0xffffffff); while (true) { var t = x ^ (x << 11); x = y; y = z; z = w; w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)); yield return w; } }
    }
}
namespace Library {
}


Measured memory_bytes: 12768
#include <iostream> // cin, cout, cerr, clog
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota, accumulate, inner_product
#include <cstdio> // printf, scanf
#include <climits> // INT_MIN, LLONG_MIN
#include <cmath> // long, trig, pow
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <stack> // stack
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <unordered_map> // hashed by keys
#include <unordered_set> // hashed by keys
#include <iomanip> // cout<<setprecision(n)

#define rep(i,n) for(int i = 0; i < n; i++)
#define ENDL "\n"
#define print(i) std::cout << std::setprecision(10) << (i) << "\n"

#define int long long // at least int64 > 9*10^18
#define all(v) v.begin(), v.end()

#define ceil(a,b) a%b?a/b+1:a/b

signed main() {
	int n;
	std::cin >> n;
	std::vector<double> p(n);
	rep(i,n) std::cin >> p[i];
	std::vector<std::vector<double> > dp(n+1,std::vector<double>(n+1,0));
	dp[0][0]=1;
	rep(i,n) rep(j,i+1) {
		dp[i+1][j] += dp[i][j]*(p[i]);
		dp[i+1][j+1] += dp[i][j]*(1-p[i]);
	}
	double sum = 0;
	rep(i,n/2+n%2) sum+=dp[n][i];
	print(sum);
	return 0;
}


Measured memory_bytes: 70656
// https://beta.atcoder.jp/contests/abc116

#define SUBMIT

#include <bits/stdc++.h>
using namespace std;

int f(int n) {
    return (n % 2 == 0) ? (n / 2) : (3 * n + 1);
}

int main() {
    int s;
    cin >> s;
    set<int> a;
    a.insert(s);

    int ans = 1;
    while (true) {
        s = f(s);
        ans++;
        if (a.count(s)) break;
        else a.insert(s);
    }

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

Measured memory_bytes: 256
Q = int(input())
MAX = 10**5 + 10
def makePrimeChecker(n):
    """
    エラトステネスの篩.
    nまでの自然数が素数かどうかを表すリストを返す.
    """
    isPrime = [True] * (n + 1)
    isPrime[0] = False
    isPrime[1] = False
    for i in range(2, int(n ** 0.5) + 1):
        if isPrime[i]:
            for j in range(i * i, n + 1, i):
                isPrime[j] = False
    return isPrime

is_prime = makePrimeChecker(MAX)
cum_sim = [0] * (MAX)
for i in range(1, MAX):
    if i % 2 == 0:
        cum_sim[i] = cum_sim[i-1]
    else:
        if is_prime[i] and is_prime[(i+1)//2]:
            cum_sim[i] = cum_sim[i-1] + 1
        else:
            cum_sim[i] = cum_sim[i-1]
for q in range(Q):
    l, r = map(int, input().split())
    print(cum_sim[r] - cum_sim[l-1])
    

Measured memory_bytes: 78892
#include <iostream>
#include <string>
#include <cmath>
#include <vector>

using namespace std;

int main()

{
    /*long long int n, p;

    cin >> n >> p;
    int ans = 1;
    if (n == 1)
    {
        cout << p;
        return 0;
    }
    for (int i = 2; i <= p; i++)
    {

        if (p % i == 0)
        {
            long long int p1 = p;

            int a = 0;

            while (p1 % i == 0)
            {

                p1 /= i;
                a += 1;
            }
            if (a >= n)
            {

                p = p1;
                for (int j = 0; j < a / n; j++)
                {
                    ans *= i;
                }
            }
        }
    }

    cout << ans;
    */
    long long int N, P;
    cin >> N >> P;
    if (N == 1)
    {
        cout << P << endl;
        return 0;
    }
    else
    {
        long long int ans = 1;
        for (int i = 2; i <= 1000000; i++)
        {
            long long int A;
            A = pow(i, N);
            if (P % A == 0)
            {
                ans = i;
            }
        }
        cout << ans << endl;
        return 0;
    }
}


Measured memory_bytes: 256
n = int(input())
s = ([int(input()) for _ in range(n)])
s_min = sum(s)
if sum(s)%10 == 0:
    for i in s:
        if i%10 != 0:
            if s_min > i:
                s_min = i
    print(sum(s) - s_min)
else:
    print(sum(s))


Measured memory_bytes: 2940
#include<iostream>
#include<string>
#include<vector>
#include<stdbool.h>
#include<numeric>
#include<math.h>
#include<algorithm>
#include<set>
#include<string>
#include<stdlib.h>
typedef long long ll;
using namespace std;

int main() {
	int N, K, num = 1,i=0;
	cin >> N >> K;
	for (;i < N;i++) {
		if (2 * num >= num + K) {
			break;
		}
		else num *= 2;
	}
	for (;i < N;i++) {
		num += K;
	}
	cout << num << endl;
}
	

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

using namespace std;

int main() {
  int N, ans{200000};
  string S;
  cin >> N >> S;
  vector<int> l(N+1), r(N+1);
  for (int i = 0; i != N; ++i) {
    l[i+1] = l[i] + (S[i] == '#');
    r[N-i-1] = r[N-i] + (S[N-i-1] == '.');
  }
  for (int i = 0; i <= N; ++i) ans = min(ans, l[i] + r[i]);
  cout << ans << endl;
}


Measured memory_bytes: 5256
while True :
    H, W = map(int, raw_input().split(" "))
    if (H == W == 0) :
        break
    ans = ""
    for h in range(0, H) :
        for w in range(0, W) :
            if ((w + h) % 2 == 0) :
                ans += "#"
            else :
                ans += "."
        ans += "\n"
    print("%s" % (ans))

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

using namespace std;

typedef long long int ll;

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

  string s, t;
  cin >> s >> t;
  t.pop_back();
  if(s == t) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 3656
#include<bits/stdc++.h>
 
using namespace std;
using S = set<long long>;
using D = deque<long long>;
using L = vector<long long>;
using M = map<int,long long>;
using A = vector<vector<long long>>;
using Q = priority_queue<long long>;
using U = unordered_map<int,long long>; //mapとの違いはkeyの順番を保持していない

#define sorted(vector) sort(vector.begin(),vector.end()) //O(nlongn)
#define sortedreverce(vector) sort(vector.rbegin(),vector.rend()) //O(nlongn)
#define vmin(vector) *min_element(vector.begin(),vector.end()) //O(N)
#define vmax(vector) *max_element(vector.begin(),vector.end()) //O(N)
#define vsum(vector) accumulate(vector.begin(),vector.end(),0) //O(N)
#define vcount(vector,a) count(vector.begin(), vector.end(),a) //O(N)
#define bisect_left(vector,a) (lower_bound(vector.begin(),vector.end(),a)-vector.begin())
#define bisect_right(vector,a) (upper_bound(vector.begin(),vector.end(),a)-vector.begin())
#define vfind(vector,a) find(vector.begin(), vector.end(), a) != vector.end() //遅いからあんまり使うな
//存在確認はmap!!!!!!!!!!!!!か配列に埋め込んでcontinueで回避
//__gcd(a,b)はコンパイラがGCC時のみ

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    long long n,m,tmpa,tmpb;
    cin>>n>>m;
    A a(n,L(2,0));
    for(int i=0  ;i<n  ;i++){
        cin>>tmpa>>tmpb;
        a[i]={tmpa,tmpb};
    }
    sorted(a);
    long long ans=0;
    for(int i=0  ;i<n  ;i++){
        if (a[i][1]<m){
            m-=a[i][1];
            ans+=a[i][1]*a[i][0];
        }else{
            ans+=a[i][0]*m;
            break;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 5760
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
const int INF = 1001001001;
const int mod = 1000000007;

int main(){
    int n,m;
    cin >> n >> m;
    vector<bool> v(n,false);
    vector<ll> dp(n,0);
    rep(i,m) {
        int a;
        cin >> a;
        a--;
        v.at(a) = true;
    }
    if(!v.at(0)) dp.at(0) = 1;
    if(n > 1 && !v.at(1)) dp.at(1) = dp.at(0) + 1;
    for(int i = 2; i < n;i++){
        if(v.at(i)) continue;
        dp.at(i) = (dp.at(i-1) + dp.at(i-2)) % mod;
    }
    cout << dp.at(n-1) << endl;

}

Measured memory_bytes: 4060
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long N,ans=1,ch=1;
  cin>>N;
  vector<long long>A(N);
  for(int i=0;i<N;i++){
  	cin>>A[i];
  }  
  for(int i=0;i<N;i++){
  	if(A[i]==0){
    	ch=0;
    }
  }  
  for(int i=0;i<N;i++){
    
    if(A[i]>1000000000000000000/ans){
       ans=-1;
       break;
    }
    ans*=A[i];
  }
  if(ch==0){
  	cout<<0;
  }else{
  int64_t a=ans;
  cout<<a;
  }
}


Measured memory_bytes: 4052
//c++ -std=gnu++14 a.cpp
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
#include <climits>
#include <fstream>
#include <random>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
//typedef pair<ll, ll> P;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define revrep(i, n) for(int i = (n)-1; i >= 0; i--)
#define pb push_back
#define f first
#define s second
#define chmin(x, y) x = min(x, y);
#define chmax(x, y) x = max(x, y);
#define len(x) ((int)(x).size())

//const ll INFL = LLONG_MAX;//10^18 = 2^60
const ll INFL = 1LL<<60;
//const int INF = INT_MAX;
const int INF = 1 << 30;//10^9
const ll MOD = 1000000007;
//const ll MOD = 998244353;
double EPS = 1e-10;

vector<ll> dy = {0, 1, 0, -1, 1, 1, -1, -1, 0};
vector<ll> dx = {1, 0, -1, 0, 1, -1, 1, -1, 0};

void pres(double A){printf("%.9lf\n", A);}
void BinarySay(ll x, ll y = 60){rep(i, y) cout << (x>>(y-1-i) & 1); cout << endl;}
ll cnt_bit(ll x){return __builtin_popcountll(x);}

ll pow_long(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2) res *= x;
    x *= x; k /= 2;
  }
  return res;
}

ll pow_mod(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2){
      res *= x; res %= MOD;
    }
    x *= x; x %= MOD;
    k /= 2;
  }
  return res;
}

ll inverse(ll x){return pow_mod(x, MOD - 2);};

ll gcd(ll a, ll b){
    if(b == 0) return a;
    return gcd(b, a % b);
}

ll lcm(ll x, ll y){
  ll res = x / gcd(x, y);
  res *= y;
  return res;
};


//コンビネーション
const int MAXcomb = 2000010;
ll fac[MAXcomb], finv[MAXcomb], inv[MAXcomb];
//facはn!,finvは1/n!
//invは逆元
void COMinit(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < MAXcomb; 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;
    }
}
ll comb(int n, int k){
    if(n < k) return 0;
    if(n < 0 || k < 0) return 0;
    return fac[n] * finv[k] % MOD * finv[n-k] % MOD;
}


ll disit(ll s, ll base = 10){
  ll res = 0;
  while(s){
    res++;
    s /= base;
  }
  return res;
}


void solve(){
  int N;
  cin >> N;
  vector<ll> A(N);
  rep(i, N) cin >> A[i];
  ll x = 1000;
  rep(i, N-1){
    if(A[i] < A[i+1]){
      x = x / A[i] * A[i+1] + x % A[i];
    }
  }
  cout << x << endl;
}

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


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const static ll MOD = 1e9+7;
const static ll INF = 1e14;




int main() {
    ll N; cin >> N;
    vector<ll> A(N);
    for(int i = 0; i < N; i++) cin >> A[i];
    map<pair<ll, ll>, ll> M, D;
    vector<vector<ll>> M_(N+1, vector<ll>(N+1)), D_(N+1, vector<ll>(N+1));
    //ll M_[N+1][N+1], D_[N+1][N+1];
    for(int i = 0; i < N; i++){
        for(int j = i; j < N; j++){
            ll SUM = 0;
            for(int k = i; k <= j; k++){
                SUM += A[k];
            }
            D_[i][j] = SUM;
        }
    }




    for(int i = 0; i < N-1; i++) {
        M_[i][i+1] = A[i]+A[i+1];
        M_[i][i] = 0;
    }

    for(int i = 3; i <= N; i++){ //区間の長さ
        for(int j = 0; j <= N-i; j++){ //各区間
            ll l = j, r = j+i-1;
            ll Min = 1e13;
            for(int k = l; k < r; k++){ //区間の分け方
                ll temp = 0;
                temp += M_[l][k] + M_[k+1][r];
                temp += D_[l][k] + D_[k+1][r];
                Min = min(Min, temp);
            }
            M_[l][r] = Min;
        }
    }


    cout << M_[0][N-1] << endl;
}

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


using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)

vector<bool> seen;
vector<int> ans;

void dfs(vector<vector<int> > &g,int start){
seen[start]=true;

for(auto next:g[start]){
  if(seen[next]) continue;
ans[next]+=ans[start];
  dfs(g,next);
}

}


int main(){
int n,q;
cin>>n>>q;

rep(i,n){
  ans.push_back(0);
  seen.push_back(false);
}//初期化
vector<vector<int>> G(n);
rep(i,n-1){
  int a,b;
  cin>>a>>b;
  G[a-1].push_back(b-1);
  G[b-1].push_back(a-1);
}//グラフの作成
rep(i,q){
  int A,B;
  cin>>A>>B;
  ans[A-1]+=B;
}//グラフの点が持ってる点数
 
dfs(G,0);
rep(i,n){
  cout<<ans[i]<<" ";
}

  return 0;
}


Measured memory_bytes: 23540
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define eps LDBL_EPSILON
#define moder 1000000007
#define int long long
#define double long double
#define ll long long
#define INF LLONG_MAX/3
#define P std::pair<int,int>
#define prique priority_queue<int,vector<int>,greater<int>>
using namespace std;
signed main(){
	string a,b,c;
	cin>>a>>b>>c;
	cout<<a[0]<<b[1]<<c[2]<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
int main()
{
	int a; cin >> a;
	int arr[a + 50];
	for(int i=0; i<a; i++)
		cin >> arr[i];
	long long ans = 1;
	int cnt[a + 50] = {0};
	for(int i=0; i<a; i++)
	{
		cnt[arr[i]] ++;
		if(arr[i] != 0 && cnt[arr[i] - 1] < cnt[arr[i]])
		{
			cout << '0';
			return 0;
		}
		if(arr[i] == 0) ans = ans * (3 - cnt[arr[i]] + 1) % mod;
		else 			ans = ans * (cnt[arr[i] - 1] - cnt[arr[i]] + 1) % mod;
	}
	cout << ans << '\n';
	return 0;
}

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

using namespace std;

int main(){
    int n,W;
    cin >> n >> W;
    int w[n+10],v[n+10];
    for(int i=0;i<n;i++){
        long ww,vv;
        cin >> ww >> vv;
        w[i] = ww;
        v[i] = vv;
    }

    long T[n+1][W+1] = {};
    for(int i=1;i<n+1;++i){
        for(int j=1;j<W+1;++j){
            if(j < w[i-1]){
                T[i][j] = T[i-1][j];
            }else{
                T[i][j] = max(T[i-1][j], v[i-1]+T[i-1][j-w[i-1]]);
            }
        }
    }

    cout << T[n][W] << endl;



}


Measured memory_bytes: 79104
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = long long;
using std::cout;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return std::vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

int main() {
	int n; scanf("%d", &n); std::vector<int> a(n);
	for(int i = 0; i < n; i++) scanf("%d", &a[i]);
	
	int ans = 1 << 30, s = 0, t = 0;
	for(int i = 0; i < n; i++) s += a[i];
	for(int i = 0; i < n - 1; i++) {
		s -= a[i];
		t += a[i];
		
		ans = std::min(ans, std::abs(s - t));
	}
	
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 256
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        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 -self.parents[self.find(x)]

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

    def members(self, x):
        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()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

N,M = map(int,input().split())
edges = []
for i in range(M):
    x = list(map(int,input().split()))
    edges.append(x)
ans = 0
for i in range(M):
    uf = UnionFind(N)
    for j in range(M):
        if j != i:
            uf.union(edges[j][0]-1,edges[j][1]-1)
        if j == M-1 and uf.group_count() != 1:
            ans += 1
print(ans)


Measured memory_bytes: 9304
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int,int> P; 


int main(){
    int n;
    while(cin >> n,n){
        vector<int> count(26,0);
        vector<char> c(n);
        for (int i = 0; i < n; i++) {
            cin >> c[i];
        }
        bool f=false;
        P p[2]={{0,-1},{0,0}};
        char a;
        int b;
        for (int i = 0; i < n; i++) {
            count[c[i]-'A']++;
            int t = c[i]-'A';
            if(count[t]>=p[0].first){
                if(p[0].second!=t){
                    p[1]=p[0];
                }
                p[0]=make_pair(count[t],t);
            }
            else if(p[1].first<count[t]){
                p[1]=make_pair(count[t],t);
            }
            if(p[0].first > n-1-i+p[1].first){
                a=(char) (p[0].second+'A');
                b=i+1;
                break;
            }

        }
        if(p[0].first==p[1].first){
            puts("TIE");
        }
        else{
            cout << a << " " << b << endl;
        }
    }
    return 0;
}



Measured memory_bytes: 3084
// {{{
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
// }}}

using namespace std;

using ll [[maybe_unused]] = long long;
using ull [[maybe_unused]] = unsigned long long;
using ld [[maybe_unused]] = long double;

[[maybe_unused]] static constexpr int mod = (int)1e9 + 7;
[[maybe_unused]] static constexpr int inf = 100100100;
[[maybe_unused]] static constexpr ll linf = 1e18;
[[maybe_unused]] static constexpr double eps = 1e-9;
[[maybe_unused]] static constexpr double pi = 3.14159265359;

#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rrep(i, a) for (ll i = a; i >= 0; --i)
#define all(obj) begin(obj), end(obj)
#define rall(obj) rbegin(obj), rend(obj)
#define pb push_back
#define fst first
#define snd second


ll A[2][101];
ll S[2][101];

int main() {
    // cin.tie(0);
    // ios_base::sync_with_stdio(false);
    ll N;
    cin >> N;
    rep (i, 2) {
        rep (j, N) {
            cin >> A[i][j];
        }
    }
    rrep (i, N - 1) {
        S[1][i] = A[1][i] + S[1][i + 1];
        S[0][i] = A[0][i] + max(S[0][i + 1], S[1][i]);
    }
    cout << S[0][0] << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define tag "spoj"
#define maxn 100007
#define oo 1000000007
#define mid ((l+r)>>1)
#define meset(a,x) memset(a,x,sizeof(a))
#define loop(x) for(int LoOpEr=1;LoOpEr<=x;LoOpEr++)
///>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
int main()
{
    #ifdef dmdd
    freopen(tag".inp","r",stdin); freopen(tag".out","w",stdout);
    #endif //dmdd
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    long long ans=0;
    int n;
    cin>>n;
    vector<int> a(n+1);
    for(int &x: a) cin>>x;

    vector<int> b(n);
    for(int i=0,x,tmp;i<n;i++)
    {
        cin>>x;
        tmp=min(x,a[i]);ans+=tmp;a[i]-=tmp;x-=tmp;
        tmp=min(x,a[i+1]);ans+=tmp;a[i+1]-=tmp;x-=tmp;
    }

    cout<<ans;
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <cstring>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>
#include <fstream>

using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(ll i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD 1000000007
#define P pair<ll, ll>

ll ans = INF;
int main() {
	ll n, a, b;
	cin >> n >> a >> b;
	if (abs(b - a) % 2 == 0)ans = (b - a) / 2;
	else {
		ans = min({ ans, a + (b - a - 1) / 2, n - b + 1 + (b - a - 1) / 2 });
	}
	ans = min({ ans, b - 1, n - a });
	cout << ans << endl;
}





Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    char s[101];
    long long int i,k;
    scanf("%s",s);
    scanf("%lld",&k);
    if(k>100) k=100;
    for(i=0;i<k;i++){
        if(s[i]!='1'){
            printf("%c",s[i]);
            return 0;
        }
    }
    printf("1");
    return 0;
}


Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;
#define int long long int
#define endl "\n"
const int MOD=1e9+7;
#ifndef HOME
#define cerr if(0)cerr
#endif

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int a[3][3];
    int vis[3][3];
    int n = 3;
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            cin>>a[i][j];
        }
    }
    map<int,int>m;
    int num;
    cin>>num;
    for(int i=0;i<num;i++){
        int x;
        cin>>x;
        m[x]++;
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            if(m[a[i][j]]){
                vis[i][j] = true;
            }else{
                vis[i][j] = false;
            }
        }
    }
    bool flag = false;
    for(int i=0;i<n;i++){
        bool ok1 = false;
        bool ok2 = false;
        for(int j=0;j<n;j++){
            if(!vis[i][j]){
                ok1 = true;
            }
            if(!vis[j][i]){
                ok2 = true;
            }
        }
        if(!ok1){
            cout<<"Yes"<<endl;
            return 0;
        }
        if(!ok2){
            cout<<"Yes"<<endl;
            return 0;
        }

    }
    
    for(int i=0;i<n;i++){
        if(!vis[i][i]){
            // cerr<<a[i][i]<<endl;
            flag = true;
        }
    }
    if(!flag){
        cout<<"Yes"<<endl;
        return 0;
    }
    if(vis[0][2] and vis[1][1] and vis[2][0]){
        cout<<"Yes"<<endl;
        return 0;
    }
    cout<<"No"<<endl;
    return 0;
    
}



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

int main() {
  int n; ll a, b; cin >> n >> a >> b;
  vi hp(n);
  rep(i,n) cin >> hp[i];
  sort(rall(hp));

  ll ans = 0;
  int sz = n;
  while (1) {
    ll sum = -ans * (a-b);
    rep(i,sz) sum += hp[i];

    if (sum <= 0) break;

    ll explosion = (a-b) + sz*b;
    ll count = (sum-1) / explosion + 1;
    ans += count;
    ll damage = count * b;

    int j = 0;
    while (j < sz && hp[j] > damage) {
      hp[j] -= damage;
      ++j;
    }
    sz = j;
  }

  priority_queue<ll> pq;
  ll min_count = 0;
  rep(i,sz) {
    min_count += hp[i] / (a-b);
    if (hp[i] % (a-b)) pq.push(hp[i] % (a-b));
  }
  rep(i,ans-min_count) {
    if (pq.empty()) break;
    pq.pop();
  }

  int add = 0;
  while (!pq.empty()) {
    if (pq.top() <= add * b) break;
    pq.pop();
    ++add;
  }

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


Measured memory_bytes: 1784
#include<map>
#include<bitset>
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<stack>
#define REP(i,x,y) for(ll i=x;i<=y;i++)
#define SIZE(a) ll(a.size())
#define vll vector<ll>
#define MEMSET(a, n, m) for(ll i=0;i<=n;i++) a[i] = m
#define BIT(n) (ll(1)<<n)
#define UNIQUE(v) v.erase(unique(v.begin(),v.end()),v.end())
#define UNIQUE_ARRAY(a,n) n = unique(a + 1, a + x + 1) - a - 1
#define SORT(a,n) sort(a+1,a+n+1)
#define SORT_O(a,n,order) sort(a+1,a+n+1,order)
#define PER(i,y,x) for(ll i=y;i>=x;i--)
typedef long long ll;
using namespace std;
int main(){
    ll a;
    cin>>a ;
    cout << 48-a <<endl;

}


Measured memory_bytes: 256
#include<iostream>
 
#define MAXN 100000
#define MAXQ 50000
 
using namespace std;
 
int n,q;
int S[MAXN+1],T[MAXQ+1];
int cnt=0;
 
bool binarySearch( int num )
{
    int mi;
    int lo=0;
    int hi=n;   
    while( lo <= hi ) {
        mi=(lo+hi)/2;
        if( num < S[mi] ) {
            hi=mi-1;
        } else if( S[mi] < num ) {
            lo=mi+1;
        } else {
            return true;
        }
    }
     
 
    return false;
}
 
int main()
{
    ios::sync_with_stdio( false );
    cin>>n;
    for( int i=0; i<n; i++ ) {
        cin>>S[i];
    }
 
    cin>>q;
    for( int i=0; i<q; i++ ) {
        cin>>T[i];
        cnt += binarySearch( T[i] );
    }
    cout<<cnt<<endl;
     
    return 0;
}

Measured memory_bytes: 1776
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define Max(x,y,z) max(x,max(y,z))
#define Min(x,y,z) min(x,min(y,z))
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
 
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<long long, long long> pll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll,ll> ii;
typedef vector<pair<ll,ll> > vii;
typedef vector<long long> vll;
typedef vector<vll> vvll;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<pair<long long,long long> > vpll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef pair<ll,pair<ll,ll> > iii;
#define PI 3.141592653589793
#define mod (ll)(1000*1000*1000+7)
//# define N 300005
template<typename T> T gcd(T a,T b) { if(a==0) return b; return gcd(b%a,a); }
template<typename T> T pow(T a,T b, ll m){T ans=1; while(b>0){ if(b%2==1) ans=((ans%m)*(a%m))%m; b/=2; a=((a%m)*(a%m))%m; } return ans%m; }
# define INF (ll)1e18+5LL
# define LN 20  
typedef pair<ll,pair<ll,ll> > pii;
# define INF1 (ll)4e9+2
# define maxn 50005
# define offset 1005


/*************************************************
struct Coupon {
    ll l;
    ll r;
    ll id;

    Coupon(ll l, ll r, ll id): l(l), r(r), id(id) {} // Initialization

    bool operator<(const Coupon& c) { // Sorting
        return l < c.l;    
    }
};

**************************************************/

int main()
{
   ll n,k;
   cin >> n >> k;
   ll zr=(n/k);
   ll hr=((n/k));
   if(n%k>=(k+1)/2)
     hr++;
   if(k&1)
     hr=0;
   //trace2(zr,hr);
   ll ans=zr*zr*zr;
   ans+=hr*hr*hr;
   cout << ans;
}

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

using namespace std;
using ll =long long;
#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;
#define leftunique(a) {sort((a).begin(),(a).end());(a).erase(unique((a).begin(),(a).end()),(a).end());}
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; }
static const ll INF = 1LL << 60;
//Write From this Line

int main()
{
	ll x, y, a, b, c;
	cin >> x >> y >> a >> b >> c;
	vector<ll> p(a), q(b), r(c);
	rep(i,a) cin >> p[i];
	rep(i,b) cin >> q[i];
	rep(i,c) cin >> r[i];
	sort(p.rbegin(),p.rend());
	sort(q.rbegin(),q.rend());
	sort(r.rbegin(),r.rend());
	// p(つまり赤)を大きい方からx個食べる
	// q(つまり緑)を大きい方からy個食べる
	ll ans = 0;
	vector<ll> look(x+y);
	rep(i,x){
		ans += p[i];
		look[i] = p[i];
	}
	rep(i,y){
		look[x+i] = q[i];
		ans += q[i];
	}
	sort(look.begin(),look.end());
	int count = 0;
	rep(i,x+y){
		cerr<<r[count]<<endl;
		if(look[i] < r[count]){
			ans -= look[i];
			ans += r[count];
			count ++ ;
		}
	}
	cout << ans << endl;
}


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

#define ln                '\n'
#define all(dat)           dat.begin(), dat.end()
#define loop(i, to)        for (int i = 0; i < to; ++i)
#define cont(i, to)        for (int i = 1; i <= to; ++i)
#define circ(i, fr, to)    for (int i = fr; i <= to; ++i)
#define foreach(i, dat)    for (__typeof(dat.begin()) i = dat.begin(); i != dat.end(); ++i)

typedef long long          num;

using namespace std;

int n, d, ans;

int main() {
    ios_base::sync_with_stdio(0);
    cin >> n >> d;
    cont (i, n) {
        cont (j, d) {
            if (j / 10 >= 2 && j  % 10 >= 2 && (j / 10) * (j % 10) == i) {
                ++ans;
            }
        }
    }
    cout << ans << ln;
}


Measured memory_bytes: 764
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <stack>
#include <cmath>
#include <queue>
#include <numeric>


int main()
{
	std::string s;

	std::cin >> s;

	int count = 0;
	for (size_t i = 0; i < s.length(); i++)
	{
		if (s[i] == '1') {
			count++;
		}
	}

	std::cout << count << std::endl;

}


Measured memory_bytes: 256
//#include "bits/stdc++.h"
#include <iostream>
#include <vector>
#include <map>
#include <utility>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <complex>
#include <bitset>
#include <functional>
#include <stack>
#include <regex>
#include <tuple>
#include <iomanip>

#define int long long
#define REP(i,a,n) for(int i=a;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define REV(i,a,n) for(int i=n;i>=a;--i)
#define all(e) e.begin(),e.end()
#define rall(e) e.rbegin(),e.rend()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define show(n) cerr<<#n<<" = "<<n<<endl
#define showp(n) cerr<<n.fs<<", "<<n.sc<<endl
#define shows(n) for(auto z:n){cerr<<z<<", ";}cerr<<endl
#define showsp(n) for(auto z:n){cerr<<z.fs<<" "<<z.sc<<", "}cerr<<endl

#define yes puts("Yes")
#define no puts("No")
#define case(i) printf("Case #%lld: ",i)

using namespace std;

using vi=vector<int>;
using pint=pair<int,int>;

inline void io(){cin.tie(0);ios::sync_with_stdio(false);cout.tie(0);cout<<fixed<<setprecision(20);}
template<typename T> inline void in(T &e){cin>>e;}
template<typename T> inline void out(T e){cout<<e<<endl;}

const int INF=1LL<<55;
const int MOD=1000000007;
const double EPS=1e-8;

int a,b;

signed main(){
    io();
    cin>>a>>b;
    out(a*b-a-b+1);


    return 0;
}


Measured memory_bytes: 888
#include <stdio.h>

int main(void)
{
	int a[10],i,max[3]={0},n,j;
	for(i=0;i<10;i++)
	scanf("%d",&a[i]);
	
	for(j=0;j<3;j++){
	for(i=0;i<10;i++)
	{
		if(a[i]>max[j]) {max[j] = a[i]; n = i;}
	}
	a[n]= 0;
	}
	for(j=0;j<3;j++)
	printf("%d\n",max[j]);
	
	return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <bits/stdc++.h>
typedef long long ll;
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;

//素因数分解
vector<pair<ll,int>> factorize(ll n){
    vector<pair<ll,int>>res;
    for(ll i=2;i*i<=n;i++){
        if(n%i)continue;
        res.emplace_back(i,0);
        while (n%i == 0)
        {
        n /= i;
        res.back().second++;
        }
        
    }
    if(n != 1) res.emplace_back(n,1);
    return res;
}

int main(){
    int X;
    cin >> X;
    if(X==3 || X==5 || X==7)cout << "YES" << endl;
    else cout << "NO" << endl;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		string[] str = Console.ReadLine().Split();
		int D = int.Parse(str[0]);
		int N = int.Parse(str[1]);
		int ans = N;
		if(N == 100){
			ans += 1;
		}
		if(D == 1){
			ans *= 100;
		} else if(D == 2){
			ans *= 10000;
		}
		Console.WriteLine(ans);
	}
}

Measured memory_bytes: 13140
#include<cstdio>
#include<string>
#include<iostream>
#include<algorithm>
#define _USE_MATH_DEFINES
#include<math.h>
#include<queue>
#include<set>
#include<vector>
#define INF 100000000

#define MAX_N 100

typedef long long int ll;
using namespace std;



int main(){

	int n;
	int math[MAX_N];

	scanf("%d", &n);

	for(int i = 0; i < n; i++){
		scanf("%d", &math[i]);
	}

	for(int i = n-1; i >= 0; i--){
		if(i != n-1 )
			printf(" ");
		printf("%d",math[i]);
	}

	printf("\n");

	return 0;

}

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

#define ll long long
#define ull unsigned long long
#define N 100005
#define mod 1000000007
#define boost ios_base::sync_with_stdio(false);cin.tie(0)
#define prec(n) fixed<<setprecision(n)

#define pii pair<int,int> 
#define pll pair<ll,ll> 
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define vi vector<int> 
#define vll vector<ll>
#define all(c) c.begin(),c.end()
#define tr(it,c) for( typeof(c.begin()) it = c.begin() ; it!=c.end() ; it++)

ll modulo(ll num,ll MOD=mod){ return ((num%MOD)+MOD)%MOD;} // for negative integer
ll power(ll b,ll e,ll MOD=mod){ll ans=1; while(e){if(e%2) ans=(ans*b)%MOD; b=(b*b)%MOD; e/=2;} return ans;}
ll inv(ll num,ll MOD=mod){ return power(modulo(num),MOD-2,MOD); }

int main()
{
    boost;
    ll n,diff,m,i,j; string s1,s2;
    
    cin>>n>>m;
    
    cin>>s1>>s2;
    if(m>n)
    {
        swap(s1,s2);
        swap(n,m);
    }
    ll lcm = (n*m)/__gcd(n,m);
    
    ll diff1,diff2 ; 
    diff1 = lcm/n ; 
    diff2 = lcm/m;
    
    i=j=0;
    map<ll,char> mi ; 
    
    int ind = 0 ;
    
    while(i<n)
    {
        mi[ind] = s1[i];i++;
        ind+=diff1;
    }
    ind = 0 ;    
    while(j<m)
    {
        if(mi[ind] and mi[ind]!=s2[j]) { cout<<"-1"; return 0; }
        ind+=diff2;j++;
    }
    cout<<lcm<<endl;
    return 0;
}

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

using namespace std;
int n;
string s;
int cnt=0,cnt2=0;
int main(){
	cin>>n>>s;
	int cnt=0;
	for(int i=0;i<n;i++){
		if(s[i]=='(')cnt++;
		else if(s[i]==')'){
			if(cnt>0)cnt--;
			else cnt2++;
		}
		
	}
//	cout<<cnt<<" "<<cnt2<<endl;
	for(int i=0;i<cnt2;i++)cout<<'(';
	cout<<s;
	for(int i=0;i<cnt;i++)cout<<')';
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  for(int i=0; i<N; i++){
   cin >> a.at(i); 
  }
  
  vector<int> checked(N, 0);
  checked.at(0) = 1;
  int current = 1;
  int count = 0;
  
  while(current != 2){
    int next = a.at(current - 1);
    if(checked.at(next - 1) == 1){
      count = -1;
      break;
    }
    else{
      current = next;
      checked.at(current - 1) = 1;
      count++;
    }
  }
  
  cout << count << endl;
}

Measured memory_bytes: 1024
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using static System.Console;
using static System.Math;
using static Utils;
class Program
{

    void Solve()
    {
        var N = io.Int;
        var x = new int[N];
        var y = new int[N];
        for (int i = 0; i < N; i++)
        {
            x[i] = io.Int;
            y[i] = io.Int;
        }

        var xy = new Tuple<int, int>[N];
        for (int i = 0; i < N; i++)
        {
            xy[i] = new Tuple<int, int>(x[i], y[i]);
        }

        var ans = 0.0;
        var num = 0;
        Permute(xy, tup =>
        {
            num++;
            var pre = tup[0];
            for (int i = 1; i < tup.Length; i++)
            {
                var cur = tup[i];
                var dis = Sqrt(Pow(pre.Item1 - cur.Item1, 2) + Pow(pre.Item2 - cur.Item2, 2));
                ans += dis;
                pre = cur;
            }
        });
        ans /= num;
        WriteLine(ans);
    }

    public static void Permute<T>(T[] array, Action<T[]> action)
    {
        Permute(array, 0, array.Length, action);
    }

    private static void Permute<T>(T[] array, int pos, int count, Action<T[]> action)
    {
        if (count == 0)
        {
            action(array);
            return;
        }
        for (var i = 0; i < count; i++)
        {
            Swap(array, pos, pos + i);
            Permute(array, pos + 1, count - 1, action);
            Swap(array, pos, pos + i);
        }
    }

    private static void Swap<T>(T[] array, int x, int y)
    {
        var temp = array[x];
        array[x] = array[y];
        array[y] = temp;
    }

    SimpleIO io = new SimpleIO();
    public static void Main(string[] args) => new Program().Stream();
    private void Stream()
    {
        //var exStdIn = new System.IO.StreamReader("stdin.txt");
        //SetIn(exStdIn);
        Solve();
        io.Flush();
    }

}

class SimpleIO
{
    string[] _nextBuffer;
    int _bufferCnt;
    char[] cs = new char[] { ' ', '"', ',' };
    StreamWriter sw = new StreamWriter(OpenStandardOutput())
    {
#if DEBUG
        AutoFlush = true
#else
        AutoFlush = false
#endif
    };
    public SimpleIO()
    {
        _nextBuffer = new string[0];
        _bufferCnt = 0;
        SetOut(sw);
    }
    string Next()
    {
        if (_bufferCnt < _nextBuffer.Length) return _nextBuffer[_bufferCnt++];
        var st = ReadLine();
        while (st == string.Empty) st = ReadLine();
        _nextBuffer = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        _bufferCnt = 0;
        return _nextBuffer[_bufferCnt++];
    }
    public string String => Next();
    public char Char => char.Parse(String);
    public int Int => int.Parse(String);
    public long Long => long.Parse(String);
    public double Double => double.Parse(String);
    public void Flush() => Out.Flush();
}
class Utils
{
    public static T id<T>(T x) => x;
}

Measured memory_bytes: 13268
N, X = map(int, input().split())
U = 2 * N - 1

if N == 1:
    print("Yes")
    print(1)
    exit()


if X == 1 or X == U:
    print("No")
    exit()

ans = [-1] * U
ans[N - 1] = X

big = U - X
small = X - 1

Xsmall = X - 1
Xbig = X + 1

if small < big:
    for i in range(small):
        ans[N + i] = Xsmall
        Xsmall -= 1
    for i in range(U):
        if ans[i] == -1:
            ans[i] = Xbig
            Xbig += 1
else:
    for i in range(big):
        ans[N + i] = Xbig
        Xbig += 1
    for i in range(U):
        if ans[i] == -1:
            ans[i] = Xsmall
            Xsmall -= 1

print("Yes")
print(*ans, sep="\n")

Measured memory_bytes: 15636
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);
		long h = Long.parseLong(scanner.nextLine());
		long ans = bin(h);
		System.out.println(ans);

	}


	public static long bin(long x) {

		long count = 0;

		if(x <= 1) {

			count = 1;

			return count;

		}



		while(x > 1) {

			if(x % 2 != 0) {

				x = x - 1;

			}

			x /= 2;
			count++;

		}

		return (long) ((Math.pow(2,count + 1)) - 1);

	}

}

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

int x;
int i,n,flag;
int main(){
    ios::sync_with_stdio(false);
    cin>>n;
    int ans;
    for (i=0;i<n;i++){
        cin>>x;
        if(x==2){
            ans++;
        }
        else if (x%2!=0){
            flag=1;
            for(int j=3;j*j<=x;j+=2){
                if (x%j==0){
                    flag=0;
                    break;
                }
                
            }
            if(flag==1){
                ans++;
            }
                
        }
    }
    
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const long long INF = 1LL<<60;

ll GCD(ll x,ll y){
    if(y == 0) return x;
    else return GCD(y,x%y);
}

ll LCM(ll a,ll b){
    return a / GCD(a,b) * b;
}

const int MOD = 1000000007;



int main() {
    string s; cin >> s;
    string t = s;reverse(t.begin(),t.end());
    int ans = 0;
    for(int i = 0;i < s.length()/2;i++){
        if(s[i] != t[i]) ans++;
    }
    cout << ans;
}


Measured memory_bytes: 3560
using System;
using System.Linq;

namespace AtCoder0705
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            string[] S = new string[N];
            for(var i =0; i<N; i++)
            {
                S[i] = Console.ReadLine();
            }

            int ac = 0;
            int wa = 0;
            int tle = 0;
            int re = 0;

            for(var i = 0; i<N; i++)
            {
                if (S[i] == "AC") { ac++; }
                if (S[i] == "WA") { wa++; }
                if (S[i] == "TLE") { tle++; }
                if (S[i] == "RE") { re++; }
            }

            Console.WriteLine("AC x " +ac);
            Console.WriteLine("WA x " +wa);
            Console.WriteLine("TLE x " +tle);
            Console.WriteLine("RE x " +re);

        }
    }
}


Measured memory_bytes: 31316
#設定
import sys
input = sys.stdin.buffer.readline

#ライブラリインポート
from collections import defaultdict

#入力受け取り
def getlist():
	return list(map(int, input().split()))

#処理内容
def main():
	X = int(input())
	DP = [0] * 100200
	DP[0] = 1
	for i in range(100001):
		if DP[i] == 1:
			DP[i + 100] = 1
			DP[i + 101] = 1
			DP[i + 102] = 1
			DP[i + 103] = 1
			DP[i + 104] = 1
			DP[i + 105] = 1

	if DP[X] == 1:
		print(1)
	else:
		print(0)

if __name__ == '__main__':
	main()

Measured memory_bytes: 39920
import sys
input = sys.stdin.readline

n = int(input())
h = [int(x) for x in input().split()]

ans = 0

def solve(l, r):
    global ans
    if l >= r:
        return
    if 0 not in h[l:r]:
        minh = min(h[l:r])
        ans += minh
        for i in range(l, r):
            h[i] -= minh
        solve(l, r)
    else:
        for i in range(l, r):
            if h[i] == 0:
                solve(l, i)
                l = i + 1
        solve(l, r)
solve(0, n)

print(ans)

Measured memory_bytes: 38640
// AOJ 2891 Namo.. Cut
// 2019.3.22 bal4u

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

//// 高速数値入力
#if 1
#define gc() getchar_unlocked()
#define pc(c) putchar_unlocked(c)
#else
#define gc() getchar()
#define pc(c) putchar(c)
#endif
int in()
{
	int n = 0, c = gc();
	do n = 10 * n + (c & 0xf), c = gc(); while (c >= '0');
	return n;
}

//// 閉路の検出
#define MAX_V 100002
int  *to[MAX_V], hi[MAX_V];
char cycle[MAX_V];            // 検出の結果

void dfs(int V)
{
	int i, j, f, node, par, next;
	static char used[MAX_V];
	static int path[MAX_V], sz;
	typedef struct { int node, par; } Q;
	static Q q[MAX_V*2]; int top;

	f = 0, sz = 0, top = 1;
	q[0].node = 1, q[0].par = 0;
	while (top) {
		node = q[--top].node, par = q[top].par;
		//		printf("top=%d, node=%d, par=%d, sz=%d\n", top, node, par, sz);
		if (node < 0) { sz--; continue; }
		used[node] = 1;
		path[sz++] = node;
		q[top++].node = -1;

		for (i = 0; i < hi[node]; i++) {
			next = to[node][i];
			if (next == par) continue;
			if (used[next] && !f) {
				f = 1;
				for (j = sz - 1; path[j] != next; j--) cycle[path[j]] = 1;
				cycle[path[j]] = 1;
			}
			else if (!used[next]) q[top].node = next, q[top++].par = node;
		}
	}
}

int main()
{
	int i, N, Q, u, v;
	int *memo, sz;

	// 入力受付。C言語ではややこしい
	N = in();
	memo = malloc(sizeof(int) * N * 2);
	sz = 0; for (i = 0; i < N; i++) {
		memo[sz++] = u = in(), memo[sz++] = v = in();
		hi[u]++, hi[v]++;
	}
	for (i = 1; i <= N; i++) {
		if (hi[i]) to[i] = malloc(sizeof(int) * hi[i]);
	}
	memset(hi, 0, sizeof(int) * (N + 1));
	i = 0; while (i < sz) {
		u = memo[i++], v = memo[i++];
		to[u][hi[u]++] = v, to[v][hi[v]++] = u;
	}

	dfs(N + 1);     // 閉路の検出 閉路上にある頂点 u --> cycle[u] == 1

	Q = in();
	while (Q--) {
		u = in(), v = in();
		pc((cycle[u] & cycle[v]) ? '2' : '1'), pc('\n');
	}
	return 0;
}


Measured memory_bytes: 8072
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan=new Scanner(System.in);
		n=scan.nextInt();
		int[] f=new int[4];
		for(int i=0;i<n;i++) {
			f[scan.nextInt()]++;
		}
		dp=new double[301][301][301];
		for(double[][] d:dp) for(double[] dd:d) Arrays.fill(dd,-1);
		System.out.println(go(f[1],f[2],f[3]));
	}
	static double[][][] dp;
	static int n;
	
	public static double go(int f1, int f2, int f3) {
		int rem=f1+f2+f3;
		if(rem==0) return 0;
		
		if(dp[f1][f2][f3]!=-1) return dp[f1][f2][f3];
		
		double res=0;
		res+=n*1.0/(f1+f2+f3);
		
		if(f1>0) res+=f1*1.0/rem*go(f1-1,f2,f3);
		if(f2>0) res+=f2*1.0/rem*go(f1+1,f2-1,f3);
		if(f3>0) res+=f3*1.0/rem*go(f1,f2+1,f3-1);
		
		return dp[f1][f2][f3]=res;
	}
}

Measured memory_bytes: 307412
import sys
input = sys.stdin.readline

def main():
	n, l = map(int, input().strip().split())
	a = [0] * n
	m = 10**9
	u = None
	for i in range(n):
		a[i] = l + i
		if abs(a[i]) < m:
			m = abs(a[i])
			u = i
	print(sum(a) - a[u])

if __name__ == '__main__':
	main()


Measured memory_bytes: 38256