akhauriyash/Code-Regression huggingface dataset:
# -*- coding: utf-8 -*-

## Library

import sys
from fractions import gcd
import math
from math import ceil,floor
import collections
from collections import Counter
import itertools
import copy

## input

# N=int(input())
# A,B,C,D=map(int, input().split())
# S = input()
# yoko = list(map(int, input().split()))
# tate = [int(input()) for _ in range(N)]
# N, M = map(int,input().split()) 
#    P = [list(map(int,input().split())) for i in range(M)]
#    S = []
#    for _ in range(N):
#        S.append(list(input()))
H,W = map(int,input().split()) 

S = []
for _ in range(H):
    S.append(list(input()))

R = []
C = []

for i in range(H):
    flag = 1
    for j in range(W):
        if S[i][j] == "#":
            flag = 0
            break
    if flag == 1:
        R.append(i)

for i in range(W):
    flag = 1
    for j in range(H):
        if S[j][i] == "#":
            flag = 0
            break
    if flag == 1:
        C.append(i)

C.sort(reverse=True)
R.sort(reverse=True)

if len(C)>0:
    for i in range(len(C)):
        for j in range(H):
            del S[j][C[i]]

if len(R)>0:
    for i in range(len(R)):
        del S[R[i]]

for i in range(len(S)):
    for j in range(len(S[i])):
        print(S[i][j], end='')
    print()

Measured memory_bytes: 79748
#include <algorithm>
#include <array>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
using namespace std;

int main(int argc, char** argv) {
	int n, k, q;
	vector<int> a, points;

	cin >> n >> k >> q;
	a.resize(q);
	points.resize(n);
	fill(points.begin(), points.end(), 0);

	for (auto &i : a) {
		cin >> i;
	}

	for (int i = 0; i < q; i++) {
		points.at(a.at(i) - 1)++;
	}

	for (int i = 0; i < points.size(); i++) {
		cout << ((k - q + points.at(i) > 0) ? "Yes" : "No") << endl;
	}

	return 0;
}


Measured memory_bytes: 1408
#include<iostream>
#include <iomanip>
using namespace std;
int a[1000];
int main()
{
	int n;
	int maxn=0;
	int sum=0;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
	cin>>a[i];
	if(a[i]>maxn)
	maxn=a[i];
	sum+=a[i];
}
if(sum-maxn<=maxn)
cout<<"No";
else
cout<<"Yes";
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define endl '\n'
int mod=1e9+7;
int mod2=998244353;

signed main(){
  while(true){
    int n,m;
    cin>>n>>m;
    if(!n&&!m)break;
    vector<pair<int,int> > a(n);
    for(int i=0;i<n;i++){
      cin>>a[i].second>>a[i].first;
    }
    sort(a.begin(),a.end(),greater<pair<int,int> >());
    int sum=0;
    int ans=0;
    for(int i=0;i<n;i++){
      sum+=a[i].second;
      if(sum-a[i].second<=m&&sum>m){
        ans+=(sum-m)*a[i].first;
      }else if(sum>m)ans+=a[i].first*a[i].second;
    }
    cout<<ans<<endl;
  }
}



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

int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if(a+b>c+d){
        cout << "Left" << endl;
    }
    else if(a+b<c+d){
        cout << "Right" << endl;
    }
    else{
        cout << "Balanced" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a;
  int sum = 0;
  cin >> a;
  if(a/100 == 1){
    sum++;
    a-= 100;
  }
  if(a/10 == 1){
    sum++;
    a -= 10;
  }
  if(a/1 == 1){
    sum++;
  }

  
  
  cout << sum << endl;
  
}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
#define ll long long
bool flag[1000002];

int main()
{
    int n,a,cnt;
    ll i,j;
    bool mark=false;
    scanf("%d",&n);
    cnt=-1;
    for(i=1; i<=n; i++)
    {
        scanf("%d",&a);
        if(cnt==-1)cnt=a;
        flag[a]=true;
        cnt=__gcd(cnt,a);
    }
    if(cnt>1)printf("not coprime\n"),exit(0);
    cnt=0;
    for(i=2; i<1000001; i++)
    {
        a=0;
        for(j=1; i*j<1000001; j++)a+=flag[i*j];
        if(a>1)mark=true;
        cnt=max(cnt,a);
    }
    if(!mark)printf("pairwise coprime\n");
    else if(cnt<n)printf("setwise coprime\n");
    else printf("not coprime\n");
    return 0;
}


Measured memory_bytes: 4688
#include <iostream>
using namespace std;
#define MAX 21

int main()
{
	int num[MAX];
	int n;

	cin >> n;
	for (int i=0; i<n; ++i)
		cin >> num[i];

	int ans = 0;
	for (int i=1; i<n-1; ++i) {
		if ((num[i] < num[i-1] && num[i] > num[i+1]) ||
		(num[i] > num[i-1] && num[i] < num[i+1]))
			ans++;
	}
	cout << ans << '\n';

	return 0;
}


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

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

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

    int p[n];
    rep(i, n){
        cin >> p[i];
    }

    int count = 0;
    rep(i, n){
        if(p[i] != i + 1)
            count++;
    }
    if(count <= 2)
        puts("YES");
    else
        puts("NO");
    return 0;
}


Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author NikuKyabe
 */

#include "bits/stdc++.h"

using namespace std;
#define int long long


class ADayOfTakahashi {
public:
    void solve(std::istream &in, std::ostream &out) {
      int a, b;
      in >> a >> b;
      out << (a - 1) + (a <= b ? 1 : 0) << endl;
    }
};


signed main() {
  ios::sync_with_stdio(false);
  cout.tie(0);
  cout << fixed;
  ADayOfTakahashi solver;
  std::istream &in(std::cin);
  std::ostream &out(std::cout);
  solver.solve(in, out);
  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstring>
#include<vector>
#include<bitset>
using namespace std;
typedef long long LL;
const int N=2005;
bitset<N> dpl[N],dpr[N],a[N];
char ss[N];
int main()
{
	int n;
	scanf("%d",&n);
	for (int u=2;u<=n;u++)
	{
		scanf("%s",ss+1);
		for(int i=1;i<u;i++)
		{
            if(ss[i]=='1') a[u][i]=1;
            else a[i][u]=1;
        }
	}
    for(int u=1;u<=n;u++) dpr[u][u]=1,dpl[u][u]=1;
    for (int d=2;d<=n;d++)
    {
    	for (int l=1;l<=n;l++)
    	{
    		int r=l+d-1;
    		if (r>n) break;
    		if ((dpr[l]&a[r]&dpl[r-1]).count()) dpr[l][r]=1;
    		if ((dpl[r]&a[l]&dpr[l+1]).count()) dpl[r][l]=1;
		}
	}
	printf("%d\n",(dpr[1]&dpl[n]).count());
	return 0;
}


Measured memory_bytes: 1792
"""
author : halo2halo
date : 9, Jan, 2020
"""

import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

S = int(readline())
S1, S2 = divmod(S, 100)

if 12 >= S1 > 0:
    if 12 >= S2 > 0:
        ans = 'AMBIGUOUS'
    else:
        ans = 'MMYY'
else:
    if 12 >= S2 > 0:
        ans = 'YYMM'
    else:
        ans = 'NA'

print(ans)


Measured memory_bytes: 3060
N=int(input())
A=[0]
for a in input().split():
  A.append(int(a))
A.append(0)
ALL=0
for i in range(len(A)-1):
  ALL+=abs(A[i]-A[i+1])
for i in range(len(A)):
  if i in (0,len(A)-1):
    continue
  ans=0
  ans+=ALL
  ans-=abs(A[i]-A[i+1])+abs(A[i]-A[i-1])
  ans+=abs(A[i-1]-A[i+1])
  print(ans)

Measured memory_bytes: 14048
#include <iostream>
#include<cstring>

using namespace std;

int main()
{
   string U,S,T;
   int A,B;
   cin>>S>>T;
   cin >>A>>B;
   cin>>U;
   if(U==T)
     B--;
   else
    A--;
   cout <<A<<" "<<B;

    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>

using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype
template <class T> int __builtin_popcount(T n) { return n ? 1 + __builtin_popcount(n & (n - 1)) : 0; }
#endif

#define foreach(it, c) for (__typeof__((c).begin()) it=(c).begin(); it != (c).end(); ++it)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define CLEAR(arr, val) memset(arr, val, sizeof(arr))

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

template <class T> void max_swap(T& a, const T& b) { a = max(a, b); }
template <class T> void min_swap(T& a, const T& b) { a = min(a, b); }

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

const double PI = acos(-1.0);
const int dx[] = { 0, 1, 0, -1 };
const int dy[] = { 1, 0, -1, 0 };



int main()
{
	bool www = false;
	int n;
	while (cin >> n, n)
	{
		if (www)
			cout << endl;

		static int v[] = { 10, 50, 100, 500 };
		int num[4];
		rep (i, 4)
			cin >> num[i];

		int sum = 0;
		rep (i, 4)
			sum += v[i] * num[i];

		int change[4];
		int s = sum - n;
		for (int i = 3; i >= 0; --i)
		{
			int t = s / v[i];
			change[i] = t;
			s -= t * v[i];
		}

		for (int i = 0; i < 4; ++i)
			if (num[i] - change[i] > 0)
				cout << v[i] << " " << num[i] - change[i] << endl;
		www = true;
	}
}

Measured memory_bytes: 864
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,k;
  string s;
  cin>>n>>k;
  cin>>s;
  for(int i=0;i<n;i++){
    if(i==k-1)cout<<char(s[i]+32);
    else cout<<s[i];
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define oset tree < int ,  null_type ,  less ,  rb_tree_tag ,  tree_order_statistics_node_update >
#define endl '\n'
#define int long long int
#define db long double
#define str string
#define mod 1000000007
#define ff first
#define ss second
#define PQi priority_queue<int>
#define Vi vector<int>
#define Si set<int>
#define Li list<int>
#define mk make_pair
#define pii pair<int,int>
#define all(x) (x.begin(),x.end())
#define pb(x) push_back(x)
#define For(i,n,s) for(int i=s;i<n;i++)
#define mat2D(T,r,c) vector<vector<int> > T(r,vector<int>(c))
#define vec2D vector<vector<int> >
#define fastIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define getVal(x) {int val;cin>>val;x.pb(val);}
#define debug(x) {for(auto i :x) cout << i << " ";cout << endl;}

void solve() {
    int a, b;
    cin >> a >> b;
    cout << (a + b) % 24;
}

int32_t main() {
    fastIO;
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
# endif
    solve();
    return 0;
}

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

struct cmp {
  bool operator()(const pair<double,string>& lhs, const pair<double,string>& rhs) const
  {
    return lhs.first == rhs.first ? lhs.second < rhs.second : lhs.first > rhs.first;
  }
};

int main()
{
  int N;
  while (cin >> N && N != 0) {
    vector<pair<double,string> > v(N);
    for (int i = 0; i < N; i++) {
      string L;
      int P, A, B, C, D, E, F, S, M;
      cin >> L >> P >> A >> B >> C >> D >> E >> F >> S >> M;
      int t = A + B + C + (D + E)*M;
      int c = F * S * M;
      double e = double(c - P) / t;
      v[i] = make_pair(e, L);
    }
    sort(v.begin(), v.end(), cmp());
    for (int i = 0; i < N; i++) {
      cout << v[i].second << endl;
    }
    cout << '#' << endl;
  }
  return 0;
}

Measured memory_bytes: 0
import heapq
N, K = map( int, input().split())
V = list(  map( int, input().split()))
ans = 0
for i in range(N+1):
    for j in range(N+1):
        if i + j > K or i + j > N:
            break
        cnt = i+j
        if j == 0:
            q = V[:i]
            now = sum(q)
            heapq.heapify(q)
            while q and (cnt < K):
                t = heapq.heappop(q)
                if t >= 0:
                    break
                else:
                    now += -t
                    cnt += 1
        else:
            q = V[:i] + V[-j:]
            now = sum(q)
            heapq.heapify(q)
            while q and (cnt < K):
                t = heapq.heappop(q)
                if t >= 0:
                    break
                else:
                    now += -t
                    cnt += 1
        if ans < now:
            ans = now
print( ans)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const ll mod = 1000000007;
const ll INF = 1001001001;
const ll LINF = 1001001001001001001;

void prvec(vector<ll> vec){ //for debug
    ll n = vec.size();
    cout << "------------------------------------\n" ;
    rep(i,n) cout << i << " " << vec.at(i) << "\n";
    cout << "------------------------------------\n" ;
}

void pr2d(vector<vector<ll>> vec){ // for debug
    ll h = vec.size();
    ll w = vec.at(0).size();
    cout << "------------------------------------\n" ;
    rep(i,h){
        rep(j,w){
            cout << vec.at(i).at(j) << " ";
        }
        cout << "\n";
    }
    cout << "------------------------------------\n" ;
}

//75 = 75 or 25*3 or 15*5 or 5*5*3

int main(){
    ll n ; cin >> n;
    vector<ll> prefac(n+1,0);
    for(int i=2;i<=n;i++){
        ll x = i;
        for(int j=2;j<=n;j++){
            while(x%j==0){
                prefac.at(j)++;
                x/=j;
            }
        }
    }
    //prvec(prefac);

    ll cnt3 = 0, cnt5 = 0, cnt15 = 0, cnt25 = 0, cnt75 = 0;
    rep(i,n+1){
        if(prefac.at(i)>=2)cnt3++;
        if(prefac.at(i)>=4)cnt5++;
        if(prefac.at(i)>=14)cnt15++;
        if(prefac.at(i)>=24)cnt25++;
        if(prefac.at(i)>=74)cnt75++;
    }

    ll ans = cnt75 + (cnt25*(cnt3-1)) + (cnt15*(cnt5-1)) + (cnt5*(cnt5-1)/2)*(cnt3-2);
    cout << ans << endl;
    return 0;
}


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

using namespace std;

using ld = long double;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	int n;
	cin >> n;
	ld dyn[2][n + 1];
	dyn[0][0] = 1;
	
	for(int j = 1; j <= n; j++)
	{
		dyn[0][j] = 0;
	}
	
	ld p;
	
	for(int i = 1; i <= n; i++)
	{
		cin >> p;
		
		dyn[1][0] = dyn[0][0] * (1 - p);
		
		for(int j = 1; j < i; j++)
		{
			dyn[1][j] = dyn[0][j - 1] * p + dyn[0][j] * (1 - p);
		}
		
		dyn[1][i] = dyn[0][i - 1] * p;
		
		for(int j = 0; j <= i; j++)
		{
			dyn[0][j] = dyn[1][j];
		}
	}
	
	ld result = 0;
	
	for(int i = n / 2 + 1; i <= n; i++)
	{
		result += dyn[0][i];
	}
	
	cout << fixed << setprecision(10) << result << '\n';
}

Measured memory_bytes: 384
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
#include <random>
#include <cassert>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 4e5 + 10;
vector<pair<int, int>> vp[N];
LL ans[N];
int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int n, m;
	cin >> n >> m;
	for (int i = 1; i <= m; i++)
	{
		int p, y;
		cin >> p >> y;
		vp[p].emplace_back(y, i);
	}
	for (int i = 1; i <= n; i++)
	{
		sort(vp[i].begin(), vp[i].end());
		for (int j = 0; j < vp[i].size(); j++)
		{
			int pos = vp[i][j].second;
			ans[pos] = 1LL * i * 1000000 + j + 1;
		}
	}
	for (int i = 1; i <= m; i++)
		printf("%012lld\n", ans[i]);
	return 0;
}

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

using namespace std;

#define int long long

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

  int h1, m1, h2, m2, k;
  cin >> h1 >> m1 >> h2 >> m2 >> k;

  h1 *= 60;
  h1 += m1;

  h2 *= 60;
  h2 += m2;

  cout << max(h2 - h1 - k, 0ll) << "\n";
}


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

class Dijkstra {
    int n;
    vector<vector<pair<int, double>>> adj;
    vector<double> d;

public:
    Dijkstra(int n) : n(n), adj(n), d(n, numeric_limits<double>::infinity()) {}

    void add_edge(int a, int b, double w) {
        assert(0 <= a && a < n && 0 <= b && b < n);
        adj[a].emplace_back(b, w);
        adj[b].emplace_back(a, w);
    }

    void add_arc(int a, int b, double w) {
        assert(0 <= a && a < n && 0 <= b && b < n);
        adj[a].emplace_back(b, w);
    }

    void run(int a) {
        d[a] = 0;
        priority_queue<pair<double, int>, vector<pair<double, int>>, greater<pair<double, int>>> que;
        que.emplace(0, a);

        while (que.size()) {
            auto top = que.top();
            que.pop();
            int u = top.second;

            for (auto& p : adj[u]) {
                int v = p.first;
                double w = p.second;
                if (d[u] + w < d[v]) {
                    d[v] = d[u] + w;
                    que.emplace(d[v], v);
                }
            }
        }
    }

    double dist(int a) {
        return d[a];
    }
};

int main() {
    int n, m, r;
    cin >> n >> m >> r;
    Dijkstra g(n);
    for (int i = 0; i < m; i++) {
        int a, b, w;
        cin >> a >> b >> w;
        g.add_arc(a, b, w);
    }
    g.run(r);
    for (int i = 0; i < n; i++) {
        double d = g.dist(i);
        if (d == numeric_limits<double>::infinity()) cout << "INF" << '\n';
        else cout << (long long) d << '\n';
    }
}


Measured memory_bytes: 19332
using System;
using System.Linq;
using System.Collections.Generic;
using System.Numerics;
namespace ABC177
{
    class Program
    {
        static void Main(string[] args)
        {
            var S = Console.ReadLine();
            var T = Console.ReadLine();

            var ans = int.MaxValue;
            for (int i = 0; i < S.Length - T.Length + 1; i++)
            {
                var anstemp = 0;
                var Stemp = S.Substring(i, T.Length);
                //Console.WriteLine();
                for (int j = 0; j < T.Length; j++)
                {
                    if (Stemp[j] != T[j]) anstemp++;
                }

                ans = Math.Min(ans, anstemp);
            }
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 26112
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=(a);i<(n);i++)
#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI (3.1415926535897932384)

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}

template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>void tf(bool b,S t,T f){if(b)puta(t);else puta(f);}
void YN(bool b){tf(b,"YES","NO");}
void Yn(bool b){tf(b,"Yes","No");}
void yn(bool b){tf(b,"yes","no");}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1;for(auto s:t){os<<(a?"":" ")<<s;a=0;}return os;}
template<class S>auto&operator>>(istream&is,vector<S>&t){for(S&a:t)cin>>a;return is;}

/*他のライブラリを入れる場所*/


int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n,m;
	cin>>n>>m;
	vector<pll> v(n);
	rep(i,n)cin>>v[i].fs>>v[i].sc;
	sort(all(v));
	ll ans=0;
	rep(i,n){
		if(v[i].sc>=m){
			ans+=v[i].fs*m;
			break;
		}else{
			ans+=v[i].fs*v[i].sc;
			m-=v[i].sc;
		}
	}
	puta(ans);
	return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define pb push_back
#define pair pair<int,int>
#define ll long long
#define f first
#define se second
using namespace std;
double pi=acos(-1.0);
int main(){
 int n;
  scanf("%d",&n);
  double ans=0;
  double x;
  while(n--)
  {
    scanf("%lf",&x);
    ans+=(1.0/x);
  }
  ans=(1.0/ans);
  printf("%.5lf",ans);
}

Measured memory_bytes: 256
import java.util.*;


public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int a=sc.nextInt();
		int b=sc.nextInt();
		if(b%a==0){
			System.out.println(a+b);
		}else{
			System.out.println(b-a);
		}

	}
}


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

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

	int N,M;
	int i,j;
	int tmp;
	int answer;
	int counter=0;
	double ave;
	vector<int> given;

	cin >> N >> M;
	
	if(N==M){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}

	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template < typename T > std::string to_string( const T& n ){
	std::ostringstream stm ;
	stm << n ;
	return stm.str() ;
}


int main(void){
	int m,f,r;
	cin >>m>>f>>r;
	while(m!=-1||f!=-1||r!=-1){
		if(m==-1||f==-1||m+f < 30)cout <<"F\n";
		else if(m+f >= 80)cout <<"A\n";
		else if(m+f >= 65)cout <<"B\n";
		else if(m+f >= 50||r>=50)cout <<"C\n";
		else cout <<"D\n";
		cin >>m>>f>>r;
	}
	return 0;
}


Measured memory_bytes: 3056
n, m = map(int, input().split())
nl = [i for i in range(1000)]
if m == 0:
    for i in range(1000):
        st = str(i)
        if len(st) != n:
            nl[i] = 1000
    print(min(nl) if min(nl) < 1000 else -1)
    exit()
for h in range(m):
    s, c = map(int, input().split())
    for i in range(1000):
        st = str(i)
        if len(st) != n or st[s - 1] != str(c):
            nl[i] = 1000
print(min(nl) if min(nl) < 1000 else -1)

Measured memory_bytes: 9136
package main

import (
	"fmt"
)

func main() {
	var a,b int
	fmt.Scan(&a,&b)
	
	if a <= 5 {
		fmt.Println(0)
	} else if a >= 6 && a <= 12 {
		fmt.Println(b / 2)
	} else {
		fmt.Println(b)
	}
}

Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
#include<vector>
#include<iomanip>

using namespace std;
using ll=long long;

#define rep(i, a, n) for (int i = (a); i < (n); ++i)

int main(){
  std::cin.tie(nullptr);                  // 標準入出力高速化
  std::ios_base::sync_with_stdio(false);  // SとS++の入出力出力を非同期
  vector<int> a(3);
  rep(i,0,3) cin>>a[i];
  sort(a.begin(),a.end(),greater<int>());
  cout<<10*a[0]+a[1]+a[2]<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(int i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(int i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define uniq(x) (x).erase(unique((x).begin(), (x).end()), (x).end())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N, W;
    cin >> N >> W;    
    vector<pair<int, int>> wv(N);
    rep(i, N) cin >> wv[i].first >> wv[i].second;
    int wmin = wv[0].first;
    vector<vector<vector<int>>> dp(N);
    int ans = 0;
    
    rep(i, N) {
        wv[i].first -= wmin;
    }
    
    rep(i, N) {
        dp[i].resize(N + 1);
        
        rep(ii, N + 1) {
            dp[i][ii].resize(N * 3, 0);
        }
    }
    
    rep(i, N) {
        if (i == 0) {
            dp[i][1][wv[i].first] = wv[i].second;
            continue;
        }
        
        reps(ii, 1, N + 1) {
            if (ii == 1) {
                rep(iii, N * 3) {
                    if (iii == wv[i].first) {
                        dp[i][ii][iii] = max(dp[i - 1][ii][iii], wv[i].second);
                    }
                    else {
                        dp[i][ii][iii] = dp[i - 1][ii][iii];
                    }
                }
                
                continue;
            }
            
            rep(iii, N * 3) {
                dp[i][ii][iii] = max(dp[i][ii][iii], dp[i - 1][ii][iii]);
                
                if (iii < wv[i].first) {
                    continue;
                }
                
                if (dp[i - 1][ii - 1][iii - wv[i].first] == 0) {
                    continue;
                }
                
                dp[i][ii][iii] = max(dp[i - 1][ii][iii], dp[i - 1][ii - 1][iii - wv[i].first] + wv[i].second);
            }
        }
    }
    
    reps(i, 1, N + 1) {
        rep(ii, N * 3) {
            if (((ll)i * wmin + ii) > (ll)W) {
                continue;
            }
            
            ans = max(ans, dp[N - 1][i][ii]);
        }
    }
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 12544
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
using namespace std;
typedef long long ll;
typedef struct {
  vector<int> to;
  ll score;
} Node;

int N, Q;
ll res[210000];
Node v[210000];

void dfs(int id, ll score, int prev)
{
  res[id] = v[id].score + score ;
  for(auto it:v[id].to){
    if( prev != it ) dfs(it, res[id], id);
  }
  return;
}

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

  rep(i,N-1) {
    int a, b;
    cin >> a >> b;
    v[a-1].to.push_back(b-1);
    v[b-1].to.push_back(a-1);
  }

  rep(i,Q){
    int p;
    ll x;
    cin >> p >> x;
    v[p-1].score += x;
  }

  vector<bool> visited(N, false);

  dfs(0, 0, -1);

  rep(i,N) {
    printf("%lld", res[i]);
    printf("%c", (i==N-1 ? '\n': ' ' ));
  }

}


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

int main(void){
    long long N;
    cin >> N;
    string Name = "";
    long long Nbuf = N;
    while(Nbuf > 0){
        int Cbuf = (Nbuf-1)%26;
        Name = (char)('a'+Cbuf) + Name;
        Nbuf = (Nbuf - Cbuf - 1)/26;
    }
    cout << Name << endl;
    return 0;
}

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

int N;
vector<int> G;
vector<pair<int, int> > V;

int erase(int s) {
  int res = N;
  while(res) {
    int a, b;
    for(a = s + 1; a <= N; ++a) {
      if(a == N || G[s] != G[a]) break;
    }
    --a;
    for(b = s - 1; b >= -1; --b) {
      if(b == -1 || G[s] != G[b]) break;
    }
    ++b;
    if(a - b + 1 >= 4) {
      s = min(N - 1, a + 1);
      res -= a - b + 1;
      for(int i = b; i <= a; ++i) G[i] = 0;
      for(int i = N - 1, j = N - 1; i >= 0; --i) {
        if(G[i] != 0) {
          int tmp = G[i];
          G[i] = 0;
          G[j--] = tmp;
        }
      }
    } else {
      break;
    }
  }
  return res;
}

int main() {
  while(cin >> N && N) {
    G.resize(N);
    for(int i = 0; i < N; ++i) {
      cin >> G[i];
    }
    int res = N;
    for(int i = 0; i < N; ++i) {
      for(int j = 1; j <= 3; ++j) {
        vector<int> tmp = G;
        G[i] = j;
        res = min(res, erase(i));
        G = tmp;
      }
    }
    cout << res << endl;
  }
  return 0;
}

Measured memory_bytes: 1320
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>

using namespace std;
int n, m,x,y;

bool from_one[200001];
bool to_n[200001];

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

  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    cin >> x >> y;
    if (x == 1) {
      from_one[y] = true;
    } else if (x == n) {
      to_n[y] = true;
    } else if (y == 1) {
      from_one[x] = true;
    } else if (y == n) {
      to_n[x] = true;
    }
  }

  bool good = false;
  for (int i = 1; (i <= n) && !good; i++) {
    good = from_one[i] && to_n[i];
  }
  if (good) {
    cout << "POSSIBLE";
  } else {
    cout << "IMPOSSIBLE";
  }
  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define RI(X) scanf("%d", &(X))
#define RII(X, Y) scanf("%d%d", &(X), &(Y))
#define RIII(X, Y, Z) scanf("%d%d%d", &(X), &(Y), &(Z))
#define DRI(X) int (X); scanf("%d", &X)
#define DRII(X, Y) int X, Y; scanf("%d%d", &X, &Y)
#define DRIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)
#define RS(X) scanf("%s", (X))
#define CASET int ___T, case_n = 1; scanf("%d ", &___T); while (___T-- > 0)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define PII pair<int,int>
#define VI vector<int>
#define VPII vector<pair<int,int> >
#define PLL pair<long long,long long>
#define VPLL vector<pair<long long,long long> >
#define F first
#define S second
typedef long long LL;
using namespace std;
const int MOD = 1e9+7;
const int SIZE = 1e6+10;
int a[SIZE],p[SIZE],d[SIZE],an[SIZE];
set<int>D,U,H;
VI e[SIZE];
int main()
{
	DRII(N,K);
	REPP(i,1,N+1)
	{
		RI(a[i]);
		p[a[i]]=i;
	}
	int rr=1;
	U.insert(N+1);
	U.insert(0);
	D.insert(N+1);
	D.insert(0);
	REPP(i,1,N+1)
	{
		// for(; rr<min(N+1,i+K); rr++) U.insert(a[i]);

		U.erase(a[i]);

		if(i-K>0) D.erase(a[i-K]);

		set<int>::iterator it=U.lower_bound(a[i]);

		if(*it!=N+1)d[i]++,e[p[*it]].PB(i);

		it--;

		if(*it!=0)d[p[*it]]++,e[i].PB(p[*it]);

		it=D.lower_bound(a[i]);

		if(*it!=N+1)d[i]++,e[p[*it]].PB(i);

		it--;

		if(*it!=0)d[p[*it]]++,e[i].PB(p[*it]);

		D.insert(a[i]);
	}

	REPP(i,1,N+1)  if(d[i]==0)H.insert(i);

	REP(kk,N)
	{
		int x=*H.rbegin();
		H.erase(x);
		an[x]=N-kk;
		REP(i,SZ(e[x]))
		{
			d[e[x][i]]--;

			if(!d[e[x][i]])  H.insert(e[x][i]);
		}
	}

	for(int i=1; i<=N; i++)printf("%d%c",an[i],i<N?' ':'\n');

	return 0;
}


Measured memory_bytes: 82048
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <string>

using namespace std;

#define LL long long

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

int n;

class Robot {
public:
	int l, r;
	Robot(int _l, int _r): l(_l), r(_r) {

	}
};

class position {
public:
	int x;
	int rn, direct;
	position(int _x, int _rn, int _direct): x(_x), rn(_rn), direct(_direct) {
	}
};

bool cmpp(const position &a, const position &b) {
	return a.x < b.x;
}
bool cmpr(const Robot &a, const Robot &b) {
	return a.r < b.r;
}

vector<Robot> r;
vector<position> p;

void read_in() {
	scanf("%d", &n);
	int x, l;
	for (int i = 0; i < n; ++i) {
		scanf("%d%d", &x, &l);
		p.push_back(position(x - l, i, 0));
		p.push_back(position(x + l, i, 1));
		r.push_back(Robot(0, 0));
	}
	sort(p.begin(), p.end(), cmpp);
	int cur = 0;
	for (int i = 0; i < p.size(); ++i) {
		if (p[i].direct) {
			r[p[i].rn].r = cur;
		}
		else {
			r[p[i].rn].l = cur;
		}
		if (i < int(p.size()) - 1 && p[i].x < p[i + 1].x) {
			++cur;
		}
	}
	sort(r.begin(), r.end(), cmpr);
}

void calc() {
	// for (int i = 0; i < n; ++i) {
		// cout << r[i].l << ' ' << r[i].r << endl;
	// }
	int m = p.size(); 
	int *a = new int[m + 10];
	for (int i = 0; i < m; ++i) {
		a[i] = 0;
	}
	int res = 0;
	int cur = 0;
	for (int i = 0; i < n; ++i) {
		// int left = r[i].l, right = r[i].r;
		// a[right] = max(a[right], a[left] + 1);
		// res = max(res, a[right]);
		// for (cur = cur + 1; cur < r[i].r; ++cur) {
			// a[cur] = a[cur - 1];
		// }
		for (int j = cur + 1; j <= r[i].r; ++j) {
			a[j] = a[j - 1];
		}
		cur = r[i].r;
		a[cur] = max(a[cur], a[r[i].l] + 1);
		res = max(res, a[cur]);
	}
	cout << res << endl;
}

int main() {
	read_in();
	calc();
	return 0;
}

Measured memory_bytes: 5812
import java.util.*;
class  Main{
      public static void main(String[] args) {
          Scanner scan = new Scanner(System.in);
           int N= scan.nextInt();
           int M = scan.nextInt();
           for(int i=0;i<M;i++){
               N-=scan.nextInt();
           }
           if(N<0){
               System.out.println(-1);
           }
           else{
               System.out.println(N);
           }
          }
   }


Measured memory_bytes: 46236
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())
union = UnionFind(N)
for i in range(M):
    A,B = map(int,input().split())
    union.union(A-1,B-1)
print(union.group_count()-1)


Measured memory_bytes: 12812
#include<iostream>

using namespace std;

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

int dp[2][2][10010];

int main() {
  int n;
  cin >> n;
  int a[n - 1];
  rep (i, n - 1) cin >> a[i];
  rep (i, 2) rep (j, 2) rep (k, 10010) dp[i][j][k] = 1e9;
  dp[0][0][0] = dp[0][1][1] = 0;
  rep (ii, n - 1) {
    int i = ii + 1;
    rep (j, i + 1) dp[1][0][j] = min(dp[1][0][j], dp[0][0][j]);
    rep (j, i + 1) dp[1][1][j + 1] = min(dp[1][1][j + 1], dp[0][1][j]);
    rep (j, i + 1) dp[1][0][j] = min(dp[1][0][j], dp[0][1][j] + a[i - 1]);
    rep (j, i + 1) dp[1][1][j + 1] = min(dp[1][1][j + 1], dp[0][0][j] + a[i - 1]);
    rep (i, 2) rep (j, 10010) dp[0][i][j] = dp[1][i][j];
    rep (i, 2) rep (j, 10010) dp[1][i][j] = 1e9;
  }
  cout << dp[0][0][n / 2] << endl;
}

Measured memory_bytes: 1356
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author varunvats32
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CDistinctOrNot solver = new CDistinctOrNot();
        solver.solve(1, in, out);
        out.close();
    }

    static class CDistinctOrNot {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            Set<Integer> set = new HashSet<>();
            for (int i = 0; i < n; i++) {
                set.add(in.nextInt());
            }
            if (set.size() == n) {
                out.println("YES");
            } else {
                out.println("NO");
            }
        }

    }
}



Measured memory_bytes: 100068
#include<bits/stdc++.h>
using namespace std;
int n,a[101];
int pd()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	scanf("%d",&a[i]);
	for(int i=1;i<=n;i++)
	if(a[i]%6!=0&&a[i]%10!=0&&a[i]%2==0)
	return 0;
	return 1;
}
signed main()
{
	if(pd())
	printf("APPROVED");
	else
	printf("DENIED");
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
using namespace std;
const int N=1e5+5;
int n;
long long d[N],cur[N];
int id[N],sz[N],par[N];
bool cmp(int a,int b){return d[a]>d[b];}
int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;i++)
	{
		scanf("%lld",&d[i]);
		id[i]=i;
		sz[i]=1;
	}
	sort(id+1,id+n+1,cmp);
	for (int i=1;i<n;i++)
	{
		long long dpar=d[id[i]]+sz[id[i]]-(n-sz[id[i]]);
		for (int j=i+1;j<=n;j++)
			if (dpar==d[id[j]])
			{
				par[id[i]]=id[j];
				cur[id[j]]+=cur[id[i]]+sz[id[i]];
				sz[id[j]]+=sz[id[i]];
			}
			else
				if (dpar>d[id[j]])
					break;
		if (!par[id[i]])
			break;
	}
	if (cur[id[n]]!=d[id[n]])
		printf("-1\n");
	else
		for (int i=1;i<n;i++)
			printf("%d %d\n",id[i],par[id[i]]);
	return 0;
}

Measured memory_bytes: 4472
#include <bits/stdc++.h>
using namespace std;
 
int64_t divceil(int64_t numer, int64_t denom) {
    if (numer % denom == 0) {
        return numer / denom;
    } else {
        return 1L + numer / denom;
    }
}
int main() {
    int64_t N, K;
    cin >> N;
    cin >> K;
    int64_t max_a = -1;

    vector<int64_t> A(N);
    int64_t total_length = 0;
    for (uint64_t i = 0; i < N; i++) {
        cin >> A[i];
        total_length += A[i];
    }
 
    // 適当な初期値を与えて上界とする
    double upper_bound = -1;
    for (auto a : A) {
        int64_t split_num_heuristic = (K * a) / total_length;
        upper_bound = max(upper_bound, 1.0 * a / (split_num_heuristic + 1));
    }
  
    int64_t result = upper_bound + 2;
    int64_t left = 1;
    int64_t right = upper_bound + 1;
    while (right >= left) {
        int64_t mid = (left + right * 9) / 10;
 
        int64_t total_split = 0;
        for (uint64_t i = 0; i < N; i++) {
            int64_t split_num = divceil(A[i], mid) - 1L;
            total_split += split_num;
        }
 
        if (total_split <= K) {
            result = min(mid, result);
            right = mid - 1;
        } else {
            left = mid + 1;
        }
    }
    cout << result << endl;
}

Measured memory_bytes: 4844
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long ;
int main(){
    string s;
    cin >> s;
    if(s == "SSS") cout << 0 << endl;
    else if(s == "RSS") cout << 1 << endl;
    else if(s == "RRS") cout << 2 << endl;
    else if(s == "RRR") cout << 3 << endl;
    else if(s == "SSR") cout << 1<< endl;
    else if(s == "SRR") cout << 2 << endl;
    else if(s == "SRS") cout << 1 << endl;
    else if(s == "RSR") cout << 1 << endl;
}

Measured memory_bytes: 3588
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define llu unsigned long long
#define ld double
#define llu unsigned long long
#define rep(i,x,y)  for(int i=int(x);i<int(y);++i)
#define For(i,x,y)  for(int i=int(x);i<=int(y);++i)
#define FOr(i,x,y)  for(int i=int(x);i>=int(y);--i)
#define pi acos(-1) 
#define mk make_pair
#define pa pair<ll,ll>
#define lf else if
#define IL inline
#define max(x,y)    ((x)<(y)?(y):(x))
#define min(x,y)    ((x)<(y)?(x):(y))
#define sqr(x)      ((x)*(x))
#define Mul(x,y)    ((x)=1LL*(x)*(y)%mod)
#define Add(x,y)    ((x)=((x)+(y))%mod)
#define E(x)        return writeln(x),0
#define LL			(long long)
#define p(x)        printf("~%lld~\n",LL(x))
#define pp(x,y)     printf("~~%lld %lld~~\n",LL(x),LL(y))
#define ppp(x,y,z)  printf("~~~%lld %lld %lld~~~\n",LL(x),LL(y),LL(z))
#define pppp(a,b,c,d)	printf("~~~%lld %lld %lld %lld\n",LL(a),LL(b),LL(c),LL(d))
#define f_in(x)     freopen(x".in","r",stdin)
#define f_out(x)    freopen(x".out","w",stdout)
#define open(x)     f_in(x),f_out(x)
#define fi first
#define se second
#define GuYue		puts("\nGuYueNa________________________________________________________________________________")
#define y1			fafa____
typedef complex<double> E;
namespace SHENZHEBEI{
#ifdef LOCAL
    struct _{_(){freopen("cf.in","r",stdin);}}_; 
#endif 
#define NEG 1
    static const int GYN=2333333;
    char SZB[GYN],*S=SZB,*T=SZB;
    inline char gc(){   if (S==T){  T=(S=SZB)+fread(SZB,1,GYN,stdin); if (S==T) return '\n';  }   return *S++;    }
#if NEG
    inline ll read(){    ll x=0,g=1; char ch=gc();   for (;!isdigit(ch);ch=gc()) if (ch=='-') g=-1;  for (;isdigit(ch);ch=gc())  x=x*10-48+ch;   return x*g; }
    inline void write(ll x){    if (x<0) putchar('-'),x=-x;  if (x>=10)   write(x/10);    putchar(x%10+'0');  }
#else
    inline ll read(){    ll x=0; char ch=gc();   for (;!isdigit(ch);ch=gc());    for (;isdigit(ch);ch=gc())  x=x*10-48+ch;   return x;   }
    inline void write(ll x){    if (x>=10)   write(x/10);    putchar(x%10+'0');  }
#endif
    inline char readchar(){ char ch=gc();   for(;isspace(ch);ch=gc());  return ch;  }
    inline ll readstr(char *s){ char ch=gc();   int cur=0;  for(;isspace(ch);ch=gc());      for(;!isspace(ch);ch=gc())  s[cur++]=ch;    s[cur]='\0';    return cur; }
	void Print(long long *a,int s,int t){For(i,s,t)printf("%lld ",a[i]);puts("");}
	void Print(int *a,int s,int t){For(i,s,t)printf("%d ",a[i]);puts("");}
	void Print(char *a,int s,int t){For(i,s,t)putchar(a[i]);puts("");}
	void writeln(ll x){write(x);puts("");}
}using namespace SHENZHEBEI;
const ll N=400010;
ll a[N],ans,n;
bool Check(ll x){
	rep(i,1,n){
		if ((a[n-i]>=x)==(a[n-i+1]>=x))return a[n-i]>=x;
		if ((a[n+i]>=x)==(a[n+i-1]>=x))return a[n+i]>=x;
	}return (a[n]<x)^(n&1);
}
int main(){
	n=read();For(i,1,n*2-1)a[i]=read();
	ll l=1,r=n*2-1;
	for(;l<=r;){
		ll mid=(l+r)/2;
		if (Check(mid))	l=mid+1,ans=mid;
		else			r=mid-1;
	}writeln(ans);
}

Measured memory_bytes: 4096
#include <bits/stdc++.h>
#include <string>
#include <stdio.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
using namespace std;

int main(void) {
    int A, B, count=0;
    string str,rev;
    cin>>A>>B;


    for(int i=A;i<=B;i++){
      std::ostringstream oss;
      oss << i;
      str = oss.str();
      rev = oss.str();
      // cout<<i<<" rev: "<<rev<<" str "<<str<<endl;
      // str = to_string(i);
      // rev = to_string(i);
      reverse(rev.begin(), rev.end());
      if(rev==str)count++;

    }

      cout<<count<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iomanip>
using namespace std;
typedef long long ll;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

#define EPS (1e-7)
#define INF (1e15)
#define PI (acos(-1))
#define MOD 1000000007

#define REP(i,n) for(int i=0;i<n;i++)
#define REPS(i,f,n) for(int i=(f);i<(n);i++)
#define EACH(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)

#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define arrdump(n,a) for(int i=0;i<n;i++) {cout<<((i>0)? " ":"")<<a[i];}cout<<"\n";


typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_7_B&lang=jp

#define NIL -1
#define MAX 1000

int n;
struct Node
{
    int l, r, p;
};
Node T[MAX];
int D[MAX], H[MAX];

static void setDepth(int id, int d) {
    D[id] = d;
    if (T[id].l != NIL) setDepth(T[id].l, d+1);
    if (T[id].r != NIL) setDepth(T[id].r, d+1);
}

static int setHeight(int id) {
    int h1 = 0, h2 = 0;
    if (T[id].l != NIL)
        h1 = setHeight(T[id].l) + 1;
    if (T[id].r != NIL)
        h2 = setHeight(T[id].r) + 1;
    return H[id] = max(h1, h2);
}

static int getSibling(int id) {
    if (T[id].p == NIL) return NIL;
    if (T[T[id].p].l != NIL && T[T[id].p].l != id)
        return T[T[id].p].l;
    if (T[T[id].p].r != NIL && T[T[id].p].r != id)
        return T[T[id].p].r;
    return NIL;
}

static void print(int id) {
    cout << "node " << id << ": ";
    cout << "parent = " << T[id].p << ", ";
    cout << "sibling = " << getSibling(id) << ", ";

    int deg = 0;
    if (T[id].l != NIL) deg++;
    if (T[id].r != NIL) deg++;
    cout << "degree = " << deg << ", ";

    cout << "depth = " << D[id] << ", ";
    cout << "height = " << H[id] << ", ";

    if (T[id].p == NIL) cout << "root" << "\n";
    else if (T[id].l == NIL && T[id].r == NIL) cout << "leaf" << "\n";
    else cout << "internal node" << "\n";
}

int main() {
    cin >> n;
    REP(i, n) T[i].p = NIL;
    REP(i, n) {
        int id, l, r;
        cin >> id >> l >> r;
        T[id].l = l;
        T[id].r = r;
        if (l != NIL) T[l].p = id;
        if (r != NIL) T[r].p = id;
    }

    int root = 0;
    REP(i, n) if (T[i].p == NIL) root = i;

    setDepth(root, 0);
    setHeight(root);

    REP(i, n) print(i);

    return 0;
}



Measured memory_bytes: 3108
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using uint = unsigned int;
#define rep(i,n) for(int i=0;i<int(n);i++)
#define rep1(i,n) for(int i=1;i<=int(n);i++)
#define per(i,n) for(int i=int(n)-1;i>=0;i--)
#define per1(i,n) for(int i=int(n);i>0;i--)
#define all(c) c.begin(),c.end()
#define si(x) int(x.size())
#define pb emplace_back
#define fs first
#define sc second
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
template<class T,class U> void chmax(T& x, U y){if(x<y) x=y;}
template<class T,class U> void chmin(T& x, U y){if(y<x) x=y;}
template<class T> void mkuni(V<T>& v){sort(all(v));v.erase(unique(all(v)),v.end());}
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

#ifdef LOCAL
#define show(x) cerr << "LINE" << __LINE__ << " : " << #x << " = " << (x) << endl
void dmpr(ostream& os){os<<endl;}
template<class T,class... Args>
void dmpr(ostream&os,const T&t,const Args&... args){
	os<<t<<" ~ ";
	dmpr(os,args...);
}
#define shows(...) cerr << "LINE" << __LINE__ << " : ";dmpr(cerr,##__VA_ARGS__)
#define dump(x) cerr << "LINE" << __LINE__ << " : " << #x << " = {";  \
	for(auto v: x) cerr << v << ","; cerr << "}" << endl;
#else
#define show(x) void(0)
#define dump(x) void(0)
#define shows(...) void(0)
#endif

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);		//DON'T USE scanf/printf/puts !!
	cout << fixed << setprecision(20);
	using P = pair<int,int>;

	int N,M; cin >> N >> M;
	map<P,int> eid;
	VV<int> G(N);
	rep(i,M){
		int x,y; cin >> x >> y;
		x--,y--;
		G[x].pb(y);
		eid[P(x,y)] = i;
	}
	VV<bool> reach(N,V<bool>(N));
	V<bool> ex(M);
	rep(s,N){
		reach[s][s] = true;
		queue<int> q; q.push(s);
		while(!q.empty()){
			int v = q.front(); q.pop();
			for(int u: G[v]) if(!reach[s][u]){
				reach[s][u] = true;
				q.push(u);
			}
		}
	}
	rep(s,N){
		rep(_,2){
			V<bool> vis(N); vis[s] = true;
			function<void(int)> dfs = [&](int v){
				if(vis[v]) return;
				vis[v] = true;
				for(int u: G[v]) dfs(u);
			};
			for(int c: G[s]){
				int e = eid[P(s,c)];
				if(vis[c]) ex[e] = true;
				dfs(c);
			}
			reverse(all(G[s]));
		}
	}
	V<bool> same(M);
	rep(x,N){
		for(int y: G[x]){
			int e = eid[P(x,y)];
			same[e] = reach[y][x] ^ ex[e];
		}
	}
	rep(i,M) cout << (!same[i] ? "same" : "diff") << '\n';
}


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

public class Main{
	static final int MOD = 1000000007;
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);

		//入力
		int x = sc.nextInt();
		sc.close();

		//処理
		int ans = 0;
		int now = 0;
		for(int i = 1; true; i++){
			now += i;
			if(now >= x){
				ans = i;
				break;
			}
		}

		//出力
		out.println(ans);
		
		out.flush();
	}
}

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

#define ALL(a) (a).begin(), (a).end()
#define ll long long

#define INF (int)1e8

using namespace std;

signed main(){
	int V, E; cin >> V >> E;
	vector<vector<int> > adj(V, vector<int>(V,INF));
	for(int i = 0; i < E; i++){
		int s,t,d; cin >> s >> t >> d;
		adj[s][t] = d;
	}
	vector<vector<int> > dp((1 << V), vector<int>(V, INF));
	dp[(1 << V)-1][0] = 0;
	for(int i = (1 << V) -2; i >= 0; i--){
		for(int j = 0; j < V; j++){
			for(int k = 0; k < V; k++){
				if((i & (1 << j)) == 0){
					dp[i][k] = min(dp[i][k], dp[i | (1 << j)][j] + adj[j][k]);
				}
			}
		}
	}
	if(dp[0][0] == INF)dp[0][0] = -1;
	cout << dp[0][0] << endl;
	


	return 0;
}





Measured memory_bytes: 6232