akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
using namespace std;

class Node{
public:
	int id;
	vector< int > e_to;
	vector< double> e_cost;
	int pre;
    
	bool def;
	int min_cost;
    
    Node(){
    	def = false;
		min_cost = -1;
		pre = -1;
	}
};

bool operator==(const Node& ot1, const Node& ot2){
	return ot1.min_cost == ot2.min_cost;
}
bool operator!=(const Node& ot1, const Node& ot2){
	return !(ot1 == ot2);
}
bool operator<(const Node& ot1, const Node& ot2){
	return ot1.min_cost < ot2.min_cost;
}
bool operator>(const Node& ot1, const Node& ot2){
	return ot1.min_cost > ot2.min_cost;
}
bool operator<=(const Node& ot1, const Node& ot2){
	return !(ot1 > ot2);
}
bool operator>=(const Node& ot1, const Node& ot2){
	return !(ot1 < ot2);
}

class Dijkstra{
	priority_queue< Node, vector< Node >, greater< Node > > que;
	vector< Node > nodes;
public:
	void Init(int node_num){
		nodes.clear();
		nodes.resize(node_num);
		for(int i = 0; i < node_num; ++i){
			nodes[i] = Node();
		}
	}

	void Put(int id, int to, double cost){
		nodes[id].id = id;
		nodes[id].e_to.push_back(to);
		nodes[id].e_cost.push_back(cost);
	}
	
    double Run(int s, int t){
		for(vector< Node >::iterator it = nodes.begin(); it != nodes.end(); ++it){
			it->min_cost = -1;
			it->def = false;
			it->pre = -1;
		}
		
		nodes[s].min_cost = 0;
		que.push(nodes[s]);

		while(!que.empty()){
			Node def_node = que.top();
			que.pop();
			
			if(def_node.def)continue;
			
			def_node.def = true;
			
			for(int i = 0; i < def_node.e_to.size(); ++i){
				int to = def_node.e_to[i];
				double cost = def_node.min_cost + def_node.e_cost[i];
				
				if(nodes[to].min_cost < 0 || cost < nodes[to].min_cost){
					nodes[to].min_cost = cost;
					nodes[to].pre = def_node.id;
					que.push(nodes[to]);
				}
			}
		}
		return nodes[t].min_cost;
	}

	void GetRoute(int t, vector< int > *route){
		int id = t;
		
		while(1){
			route->push_back(id);
			id = nodes[id].pre;
			
			if(nodes[id].pre == -1){
				route->push_back(id);
				break;
			}
		}
	}
};

int main(){
	int n, m, b, s, g;
	double cost;
	vector< int > x, y, route;
	Dijkstra dst;
	
	while(cin >> n, n){
		dst.Init(n);
		x.resize(n);
		y.resize(n);
		for(int i = 0; i < n; ++i){
			cin >> b;
			cin >> x[b - 1] >> y[b - 1];
		}
		
		for(int i = 0; i < n; ++i){
			for(int j = i + 1; j < n; ++j){
				if((x[i] - x[j]) * (x[i] - x[j]) + (y[i] - y[j]) * (y[i] - y[j]) <= 2500){
					dst.Put(i, j, sqrt((x[i] - x[j]) * (x[i] - x[j]) + (y[i] - y[j]) * (y[i] - y[j])));
					dst.Put(j, i, sqrt((x[i] - x[j]) * (x[i] - x[j]) + (y[i] - y[j]) * (y[i] - y[j])));
				}
			}
		}
		
		cin >> m;
		for(int i = 0; i < m; ++i){
			route.clear();
			cin >> s >> g;
			cost = dst.Run(s - 1, g - 1);
			if(cost < 0){
				cout << "NA" << endl;
			}else{
				dst.GetRoute(g - 1, &route);
				reverse(route.begin(), route.end());
				for(int j = 0; j < route.size(); ++j){
					cout << (j ? " " : "") << route[j] + 1;
				}
				cout << endl;
			}
		}
	}
    return 0;
}

Measured memory_bytes: 1252
fun dividableCount(max: Long, divider: Long): Long {
    return max / divider
}

fun dividableCount(min: Long, max: Long, divider: Long): Long {
    var count = dividableCount(max, divider) - dividableCount(min, divider)
    if (min % divider == 0L) count++
    return count
}

fun gcd(i1: Long, i2: Long): Long {
    var m = i1
    var n = i2
    var temp: Long
    while (m % n != 0L) {
        temp = n
        n = m % n
        m = temp
    }
    return n
}

fun koubaisu(i1: Long, i2: Long) = i1 * i2 / gcd(i1, i2)

fun main(args: Array<String>) {
    val inputs = readLine()!!.split(' ').map { it.toLong() }
    val a = inputs[0]
    val b = inputs[1]
    val c = inputs[2]
    val d = inputs[3]
    val allnum = b - a + 1
    val dividableByC = dividableCount(a, b, c)
    val dividableByD = dividableCount(a, b, d)
    val cdprouct = koubaisu(c, d)
    val dividableByCandD = dividableCount(a, b, cdprouct)
    val result = allnum - dividableByC - dividableByD + dividableByCandD
    println(result)
}

Measured memory_bytes: 36388
#include <bits/stdc++.h>
using namespace std;
#define ll long long
template <typename T>
bool PN(T x){ if (x <= 1) return false; if (x == 2) return true; for (int i = 2; i < sqrt(x) + 1; i++) if (x % i == 0) return false; return true;}
const ll MOD = 1e9+7;
long long Comb(int n, int i){long long ans = 1; if(i == 0 || i == n) return 1; else {for(int j = 1; j <= i; ++j){
      ans *=(n+1-j);
      ans /= j;
      ans %= MOD;} }return ans;}


void solve(){
  int n; cin >> n;
  int a[n];
  for(int i = 0; i < n; ++i) cin >> a[i];
  int ans[n];
  deque<int> an;
  
    for(int i = 0; i < n; ++i){
        if(n%2 == 0){
            if(i % 2 == 1) {
              an.push_front(a[i]);
            } else {
              an.push_back(a[i]);
          }
        } else {
            if(i % 2 == 0) {
              an.push_front(a[i]);
            } else {
              an.push_back(a[i]);
          }
        }
      }
      for(int i = 0; i < n; ++i){
          cout << an[i] << " ";
      }
      cout << endl;
      return;
  
}

int main(void){
    solve();
    return 0;
}


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


using namespace std;


int main(void) {
	int a, b, c, d, e, f;
	float x, y;
	while(cin >> a >> b >> c >> d >> e >> f){
		x = round((float)(c*e - b*f) / (a*e - b*d) * 1000) / 1000;
		y = round((float)(a*f - c*d) / (a*e - b*d) * 1000) / 1000;
		if(abs(x) < 0.0005)x = 0.0;
		if(abs(y) < 0.0005)y = 0.0;
		printf("%.3f %.3f\n", x, y);
	}
}

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

int main(){
    vector<int> a(9);
    for(int &p : a) cin>>p;
    int n;
    cin>>n;
    vector<int>b(n);
    vector<bool>c(9,0);
    for(int &p:b) cin>>p;
    for(int &p:b){
        for(int i=0;i<9;i++){
            if(a.at(i)==p){
                c.at(i)=1;
            }
        }
    }
    if(c.at(0)&&c.at(1)&&c.at(2)){
        cout<<"Yes";
        return 0;
    }
    if(c.at(3)&&c.at(4)&&c.at(5)){
        cout<<"Yes";
        return 0;
    }
    if(c.at(6)&&c.at(7)&&c.at(8)){
        cout<<"Yes";
        return 0;
    }
    if(c.at(0)&&c.at(3)&&c.at(6)){
        cout<<"Yes";
        return 0;
    }
    if(c.at(1)&&c.at(4)&&c.at(7)){
        cout<<"Yes";
        return 0;
    }
    if(c.at(2)&&c.at(5)&&c.at(8)){
        cout<<"Yes";
        return 0;
    }
    if(c.at(0)&&c.at(4)&&c.at(8)){
        cout<<"Yes";
        return 0;
    }
    if(c.at(2)&&c.at(4)&&c.at(6)){
        cout<<"Yes";
        return 0;
    }
    cout<<"No";
}

Measured memory_bytes: 256
import java.util.Scanner;

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

		String ret = "";
		name[0] = s.charAt(0);
		name[1] = s.charAt(1);
		name[2] = s.charAt(2);

		ret = new String(name);
		System.out.println(ret);

		sc.close();
	}
}



Measured memory_bytes: 35736
#include <iostream>
#include <iomanip> // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple> // get<n>(xxx)
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set> // S.insert(M);
// if (S.find(key) != S.end()) { }
// for (auto it=S.begin(); it != S.end(); it++) { }
// auto it = S.lower_bound(M);
#include <random> // random_device rd; mt19937 mt(rd());
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib> // atoi(xxx)
using namespace std;

#define DEBUG 0 // change 0 -> 1 if we need debug.
// insert #if<tab> by my emacs. #if DEBUG == 1 ... #end

typedef long long ll;

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

// const int C = 1e6+10;
// const ll M = 1000000007;

const int MAX_SIZE = 1000010;
const long long MOD = 1000000007;

long long inv[MAX_SIZE];
long long fact[MAX_SIZE];
long long factinv[MAX_SIZE];

void init() {
  inv[1] = 1;
  for (int i=2; i<MAX_SIZE; i++) {
    inv[i] = ((MOD - inv[MOD%i]) * (MOD/i))%MOD;
  }
  fact[0] = factinv[0] = 1;
  for (int i=1; i<MAX_SIZE; i++) {
    fact[i] = (i * fact[i-1])%MOD;
    factinv[i] = (inv[i] * factinv[i-1])%MOD;
  }
}

long long C(int n, int k) {
  if (n >=0 && k >= 0 && n-k >= 0) {
    return ((fact[n] * factinv[k])%MOD * factinv[n-k])%MOD;
  }
  return 0;
}

long long power(long long x, long long n) {
  if (n == 0) {
    return 1;
  } else if (n%2 == 1) {
    return (x * power(x, n-1)) % MOD;
  } else {
    long long half = power(x, n/2);
    return (half * half) % MOD;
  }
}

long long gcm(long long a, long long b) {
  if (a < b) {
    return gcm(b, a);
  }
  if (b == 0) return a;
  return gcm(b, a%b);
}

ll N, K;
ll A[100010];

int main() {
  init();
  cin >> N >> K;
  for (auto i = 0; i < N; ++i) {
    cin >> A[i];
  }
  ll g = A[0];
  for (auto i = 1; i < N; ++i) {
    g = gcm(g, A[i]);
  }
  for (auto i = 0; i < N; ++i) {
    if (A[i]-K >= 0 && (A[i]-K) % g == 0) {
      cout << "POSSIBLE" << endl;
      return 0;
    }
  }
  cout << "IMPOSSIBLE" << endl;
}


Measured memory_bytes: 24448
#include <bits/stdc++.h>
#define rep(i,n)    for(int i = 0; i < (n) ; ++i)
#define orep(i,n)   for(int i = 1; i <= (n); ++i)   // one rep
#define drep(i,n)   for(int i = (n)-1; i >= 0; --i) // down rep
#define srep(i,s,t) for(int i = (s); i < (t); ++i)  // set rep
#define rng(x)  (x).begin(),(x).end()   // range
#define rrng(a) (a).rbegin(),(a).rend() // reverse range
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define ru(x,y) (((x)+(y)-1)/(y)) // round up
#define fi first
#define se second
#define eb emplace_back
#define fcout cout << fixed << setprecision(15)


using namespace std;
using ll  = long long;
using P   = pair<int,int>;
using vi  = vector<int>;
using vvi = vector<vi>;
using vp  = vector<P>;
using vl  = vector<ll>;

template<typename T> void Yes(T flag) {
  cout << (flag ? "Yes" : "No") << endl;
}

template<typename T> void pv(vector<T> vec) {
  cout << "[";
  for(auto& v : vec) { cout << v << ","; }
  cout << "]" << endl;
}

template<>
void pv(vector<P> vec) {
  cout << "[";
  for(auto& v : vec) {
    cout << "<" << v.fi << ","<< v.se << ">" << ",";
  }
  cout << "]" << endl;
}

ll dp[2005][2005];

int main() {
  int n;
  cin >> n;
  vp a(n);
  rep(i,n) {
    int t;
    cin >> t;
    a.at(i) = P(t,i);
  }
  sort(rrng(a));

  rep(i,n) rep(j,n) {
    if(i+j > n-1) continue;
    ll u = a.at(i+j).fi;
    ll d = a.at(i+j).se;
    dp[i][j+1] = max(dp[i][j] + u * abs(n-d-j-1),dp[i][j+1]);
    dp[i+1][j] = max(dp[i+1][j],dp[i][j]+u*abs(d-i));
  }

  ll res = 0;
  rep(i,n+1) {
    res = max(res,dp[i][n-i]);
  }

  cout << res << endl;

  return 0;
}


Measured memory_bytes: 26288
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i=0;i<((int)(n));i++)
#define reg(i,a,b) for(int i=((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i=((int)(n))-1;i>=0;i--)
#define ireg(i,a,b) for(int i=((int)(b));i>=((int)(a));i--)
typedef long long int lli;
typedef pair<int,int> mp;
#define fir first
#define sec second
#define IINF INT_MAX
#define LINF LLONG_MAX
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define pque(type) priority_queue<type,vector<type>,greater<type> >
#define memst(a,b) memset(a,b,sizeof(a))
#define iter(v,ite) for(auto ite=(v).begin();ite!=(v).end();ite++)
#define mimunum(v,x) distance((v).begin(),lower_bound((v).begin(),(v).end(),x))


char s[100005];
int main(void){
	scanf("%s",s);
	int ls=strlen(s);
	int p=0,g=0;
	rep(i,ls){
		if(s[i]=='g')g++;
		else p++;
	}
	
	int ans;
	if(ls%2==0)ans=g-ls/2;
	else ans=g-(ls+1)/2;
	printf("%d\n",ans);
	return 0;
}






Measured memory_bytes: 384
n, m = [int(x) for x in input().split()]
s = []
c = []
for _ in range(n):
    a, b = [int(x) for x in input().split()]
    s.append((a, b))
for _ in range(m):
    a, b = [int(x) for x in input().split()]
    c.append((a, b))
for sx, sy in s:
    v = []
    for i, (cx, cy) in enumerate(c):
        v.append((i, abs(cx - sx) + abs(cy - sy)))
    print(sorted(v, key=lambda x: x[1])[0][0] + 1)

Measured memory_bytes: 3064
n,d = map(int,input().split())

ls =[]

for _ in range(n):
  ls.append(list(map(int,input().split())))

def calc(a,b):
  num = 0
  for i in range(len(a)):
    num += (a[i]-b[i])**2
  if num**0.5 == int(num**0.5):
    return 1
  return 0

count = 0
for i in range(n-1):
  for j in range(i+1,n): 
    count += calc(ls[i],ls[j])
print(count)
    

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
  int a[1001],i,ma=100000,p,n;
  double m1,m2;
int main(){
  for(cin>>n;i<n;i++)cin>>a[i];
  sort(a,a+n);
  m1=(double)(a[n-1]+a[n-2])/(a[1]-a[0]);
  for(i=n-1;i>0;i--)if(a[i]-a[i-1]<=ma){ma=a[i]-a[i-1];p=i;}
  for(i=n-1;i>0;i-=2)if(i!=p){
    m2=(double)(a[i-1]+a[i])/(a[p]-a[p-1]);
    break;
  }
  m1=max(m1,m2);
  printf("%.9f\n",m1);
}

Measured memory_bytes: 3292
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.Map;
import java.util.StringTokenizer;

public class Main {

	// Atcoder用のサンプルプログラム
	public static void main(String[] args) {
		String line = "";
		try {
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			
			line = br.readLine();

			StringTokenizer st0 = new StringTokenizer(line, "");
			int cnt0=Integer.parseInt(st0.nextToken());
			
			line = br.readLine();
			StringTokenizer st = new StringTokenizer(line, " ");
			
			String s = "";
			Map<String,Integer> stringMap = new HashMap<String,Integer>();
			int[] hairetu=new int[cnt0];
			int hairetuMax=0;
			for (int i = 0; i < cnt0;i++) {
				
				s= st.nextToken();
				hairetu[i]=Integer.parseInt(s);
				//System.out.println(s);
				if (stringMap.get(s)==null) {
					stringMap.put(s, 1);
				} else {
					stringMap.put(s, stringMap.get(s)+1);
				}
				
				if(hairetuMax<hairetu[i]) {
					hairetuMax=hairetu[i];
				}
				
			}
			
			int max=0;
			int maxSuji=0; // maxになったときの0-8の数字
			int temp=0;
			
			for (int j=1;j < hairetuMax+1;j++) {
				temp=0;
				
				if (j==1) {
					
					if (stringMap.get("1")!=null) {
						temp=temp+stringMap.get("1");	
						
					}
					if (stringMap.get("2")!=null) {
						temp=temp+stringMap.get("2");	
					}
					
				} else if (j==9) {
					if (stringMap.get("8")!=null) {
						temp=temp+stringMap.get("8");	
					}
					if (stringMap.get("9")!=null) {
						temp=temp+stringMap.get("9");	
						//System.out.println(temp);
					}
				} else {
					if (stringMap.get(String.valueOf(j-1))!=null) {
						temp=temp+stringMap.get(String.valueOf(j-1));	
					}
					if (stringMap.get(String.valueOf(j))!=null) {
						temp=temp+stringMap.get(String.valueOf(j));	
					}
					if (stringMap.get(String.valueOf(j+1))!=null) {
						temp=temp+stringMap.get(String.valueOf(j+1));	
					}
				}
				if (temp > max) {
					//System.out.println(temp + " " + max);
					//System.out.println(j);
					max=temp;
					maxSuji=j;
				}
			}
			
			int x = 0;
			for (int i = 0; i < cnt0;i++) {
				//System.out.println(hairetu[i]);
				if (maxSuji-1 ==hairetu[i] || maxSuji ==hairetu[i] || maxSuji+1 ==hairetu[i]) {
					x++;
				}
			}
			
			
			
			
			//String tempS = st.nextToken();

			//int k = Integer.parseInt(tempK);
			//int s = Integer.parseInt(tempS);
			
			//String result="";
            /*StringBuffer sb = new StringBuffer();
            
			for (int i =0;i<s.length();i++) {
				if (i % 2 == 0) {
					//result = result + s.charAt(i);
                    sb.append(s.charAt(i));
				}
			}
			System.out.println(sb.toString());
			*/
			System.out.println(x);
			
		} catch (Exception e) {
			e.printStackTrace();
		}
	}


}


Measured memory_bytes: 51648
from itertools import permutations
n = int(input())
s = input()
s_num = []

for i in range(n):
    num = 0
    if s[i] == 'G':
        num = 1
    elif s[i] == 'B':
        num = 2
    s_num.append(num)
# R: 0, G: 1, B: 2

# RGB, RBG, GBR, GRB, BRG, BGR

indexs = [[], [], []]
for i, v in enumerate(s_num):
    indexs[v].append(i)

color_sum = [[len(indexs[0])], [len(indexs[1])], [len(indexs[2])]]
for i in range(n):
    for j in range(3):
        if s_num[i] == j:
            color_sum[j].append(color_sum[j][-1] - 1)
        else:
            color_sum[j].append(color_sum[j][-1])

ans = 0
for i, j, k in permutations([0, 1, 2]):
    for first in indexs[i]:
        for second in indexs[j]:
            if second < first:
                continue
            third_exp = second + (second - first)
            if third_exp < n:
                if s_num[third_exp] == k:
                    ans -= 1
            tmp = color_sum[k][second]
            ans += tmp
#             print(tmp, ans)
# print(color_sum)
print(ans)


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

using namespace std;

int main(void) {

  string N;
  cin >> N;

  long long sum = 0;
  for (long long i = 0; i<N.size(); i++) {
    sum += N.at(i) - '0';
  }

  if (sum % 9 == 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


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


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

def solve_knapsack(capacity):
    # basic checks
 
    dp = [0]*(capacity + 1)
    # populate the capacity = 0 columns, with '0' capacity we have '0' profit

    for i in range(0, N):
        weights,profits = map(int,input().split())
        for c in range(capacity, weights-1, -1):
            tmp = profits + dp[c - weights]
            if tmp > dp[c]: dp[c] = tmp
 
    # maximum profit will be at the bottom-right corner.
    return dp[capacity]
  
def main():
 
    res = solve_knapsack(W)
 
    print(res)
if __name__ == "__main__":
	main()

Measured memory_bytes: 9716
#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)
        cin>>a[i];
        if(n==1)
            cout<<a[0];
        else if(n%2==0)
        {
    for(int i=n-1;i>=1;i=i-2)
        cout<<a[i]<<" ";
    for(int i=0;i<=n-2;i+=2)
        cout<<a[i]<<" ";
   }else
   {
       for(int i=n-1;i>=0;i-=2)
        cout<<a[i]<<" ";
       for(int i=1;i<=n-2;i+=2)
        cout<<a[i]<<" ";
   } return 0;
}


Measured memory_bytes: 2944
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T,class U> using P = pair<T,U>;
template<class T> using vec = vector<T>;
template<class T> using vvec = vector<vec<T>>;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
 
int main(){
    string s;
    cin >> s;
    if (s[2]==s[3] && s[4]==s[5]) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
from collections import Counter
n = int(input())
a = list(map(int, input().split()))

c = Counter(a)
key = c.keys()
comb = 0
for i in key:
    comb += (c[i] * (c[i]-1)) // 2

for i in a:
    ans = comb - (c[i] - 1)
    print(ans)

Measured memory_bytes: 26780
# coding: utf-8
h, w = map(int, input().split())
a = [input() for _ in range(h)]

row = [False] * h
col = [False] * w
for i in range(h):
    for j in range(w):
        if a[i][j] == "#":
            row[i] = True
            col[j] = True

for i in range(h):
    if row[i]:
        for j in range(w):
            if col[j]:
                print(a[i][j], end="")
        print()

Measured memory_bytes: 4468
n, k, c = map(int, input().split())
s = input()
l = [-1] * k
r = [-1] * k
nowl = 0
indl = 0
while nowl < n and indl < k:
    for i in range(nowl, n):
        if s[i] == "o":
            l[indl] = i
            nowl = i + c + 1
            indl += 1
            break
nowr = n - 1
indr = k - 1
while nowr >= 0 and indr >= 0:
    for i in range(nowr, -1, -1):
        if s[i] == "o":
            r[indr] = i
            nowr = i - c - 1
            indr -= 1
            break
for i in range(k):
    if l[i] == r[i]:
        print(l[i] + 1)


Measured memory_bytes: 20612
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
#define int long long
using namespace std;
typedef pair<int,int>P;
#define F first
#define S second

int h,w;
string s[555];
int a[555][555];
int b[555][555];
signed main(){
	cin>>h>>w;

	r(i,h)cin>>s[i];

	r(i,h){
		r(j,w){
			if(!i || (i!=h-1 && j%2==0))a[i][j]=1;
			else b[i][j]=1;
		}
	}

	r(i,h){
		r(j,w){
			if(!i || (i!=h-1 && j%2==0)){
				if(s[i][j]=='#')b[i][j]=1;
			}
			else{
				if(s[i][j]=='#')a[i][j]=1;
			}
		}
	}

	r(i,h){
		r(j,w){
			cout<<(a[i][j]?'#':'.');
		}
		cout<<endl;
	}
	cout<<endl;
	r(i,h){
		r(j,w){
			cout<<(b[i][j]?'#':'.');
		}
		cout<<endl;
	}

}

Measured memory_bytes: 5632
import math
# import numpy as np  # Pythonのみ！
# from operator import xor
# import re
# from scipy.sparse.csgraph import connected_components  # Pythonのみ！
# ↑cf.  https://note.nkmk.me/python-scipy-connected-components/
# from scipy.sparse import csr_matrix
# import string
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():

    r=int(input())
    print(math.pi*r*2)

resolve()

Measured memory_bytes: 62036
import itertools
n=int(input())
x=list(itertools.permutations([i+1 for i in range(n)]))
p=[int(i) for i in input().split()]
q=[int(i) for i in input().split()]
l=len(x)
a,b=-1,-1
for i in range(l):
    #print(x[i])
    if list(x[i])==p:
        a=i
    if list(x[i])==q:
        b=i
print(abs(a-b))


Measured memory_bytes: 8052
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <tuple>
#include <bitset>
#include <memory>
#include <cmath>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cfloat>
#include <cassert>
#include <random>
int main() {
	int price; std::cin >> price;
	auto rest = price % 100;
	if ((rest + 4) / 5 > price / 100) {
		std::cout << "0\n";
	}
	else {
		std::cout << "1\n";
	}
}

Measured memory_bytes: 888
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<int,int>;

vector<int>bitSearch(int bit,int n){
    vector<int>S;
    rep(i,n)if(bit&(1<<i))S.push_back(i);
    return S;
}



int main(){
    string s;cin>>s;
    int n = s.size();
    int dig = 0;
    rep(i,n)dig += s[i]-'0';
    cout<<(stoi(s)%dig==0 ? "Yes":"No");
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define ll long long
#define lf long double
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef pair <ll,ll> ii;
typedef vector <ll> vi;
typedef vector <ii> vii;
typedef vector <bool> vb;
typedef vector <vector <ll> > vv;
typedef vector <vector <vector<ll> > > vvv;
typedef vector <string> vs;
typedef vector <lf> vf;
#define tr1(x) cerr << #x << ": " << x << endl
#define tr2(x, y) cerr << #x << ": " << x << " | " << #y << ": " << y << endl
#define tr3(x,y,z) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define tr4(x,y,z,w) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<" | "<<#w<<": "<<w<<endl
#define trv(a) cerr<<#a<<": ";for(ll zz=0;zz<a.size();zz++) cerr<<a[zz]<<" ";cerr<<endl
#define trii(x) cerr<<#x<<": ("<<x.F<<","<<x.S<<")\n";
#define trset(s) cerr<<#s<<": ";for(auto &i:s) cerr<<i<<" ";cerr<<"\n"
#define mod 1000000007ll
#define inf 9999999999999999ll
#define nl endl
#define sz(x) (ll)(x).size()
#define all(x) x.begin(), x.end()
#define modulo 998244353ll

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin>>n;
    vv g(201,vi(201,0));
    for(ll i=0;i<=n;i++)
    {
        for(ll j=i;j<=n;j++)
        {
            g[i][j]=g[j][i]=__gcd(i,j);
        }
    }
    ll ans=0;
    for(ll i=1;i<=n;i++)
    {
        for(ll j=1;j<=n;j++)
        {
            for(ll k=1;k<=n;k++)
            {
                ans+=g[g[i][j]][k];
            }
        }
    }
    cout<<ans<<nl;
}


Measured memory_bytes: 3784
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {


		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		for(int i = 1; i < 1100;i++ ) {
			int eight = i * 8 /100;
			int ten = i * 10 /100;
			if(eight ==a && ten == b) {
				System.out.println(i);
				return;
			}
		}
		System.out.println(-1);
	}
}

Measured memory_bytes: 21844
//بِسْمِ ٱللَّٰهِ ٱلرَّحْمَٰنِ ٱلرَّحِيمِ
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef double db;

#define endl "\n"

const int MOD = 1000000007;


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

    int a ,b ;
    cin >>a >> b;
    
    cout << 6 - (a+b) << endl;
    
    return 0;
}


Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for(int i=0;i<(int)n;i++)
#define PI acos(-1)
#define fast_io ios_base::sync_with_stdio(false) ; cin.tie(0); cout.tie(0);
ll mod=1e9+7;

ll rep_pow(ll a, ll b){//繰り返し2乗法
    if(b==0) return 1;
    else if(b%2==0){
        ll memo = rep_pow(a, b/2);
        return memo*memo%mod;
    }else{
        return rep_pow(a, b-1)*a%mod;
    }
}
ll nCr(ll n, ll r){//mod逆元使ったnCr
    ll ret=1;
    rep(i,r){
        ret *= n-i;//分子
        ret %= mod;
        ret *=rep_pow(r-i, mod-2);//mod逆元によりr!で割ると同値
        ret %= mod;
    }
    return ret;
}
ll gcd(ll a, ll b){if(b==0) return a; return gcd(b, a%b);}
bool isPrime(int x){
    if(x==1) return false;
    else if(x==2) return true;
    else if(x%2==0) return false;
    for(int i=3;i<=sqrt(x);i+=2){
        if(x%i==0){
            return false;
        }
    }
    return true;
}

int main(){
    fast_io
    int A,B,M;
    cin>>A>>B>>M;
    int ans;
    int a_min=100100100, b_min=100100100;
    int a[A], b[B], x[M],y[M],c[M];
    rep(i,A) {
        cin>>a[i];
        a_min=min(a_min, a[i]);
    }

    rep(i,B) {
        cin>>b[i];
        b_min=min(b_min, b[i]);
    }
    rep(i,M) cin>>x[i]>>y[i]>>c[i];
    ans=a_min+b_min;
    rep(i,M){
        ans=min(ans, a[x[i]-1]+b[y[i]-1]-c[i]);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 2176
# AOJ 1148: Analyzing Login/Logout Records
# Python3 2018.7.17 bal4u

while True:
    n, m = map(int, input().split())
    if n == 0: break
    r = int(input())
    rd = [list(map(int, input().split())) for i in range(r)]
    for i in range(int(input())):
        ts, te, tm = map(int, input().split())
        ans = T = cnt = 0
        for t, pc, m, s in rd:
            if t >= te:
                if T > 0: ans += te-T
                break
            if m != tm: continue
            if s:
                cnt += 1
                if T == 0: T = ts if t < ts else t
            else:
                cnt -= 1
                if cnt == 0:
                    if t > ts and T > 0: ans += t - T
                    T = 0
        print(ans)



Measured memory_bytes: 5892
#include <cstdio>
#include <cmath>
#include <iostream>
#include <set>
#include <algorithm>
#include <vector>
#include <map>
#include <cassert>
#include <string>
#include <cstring>
#include <queue>

using namespace std;

#define rep(i,a,b) for(int i = a; i < b; i++)
#define S(x) scanf("%d",&x)
#define S2(x,y) scanf("%d%d",&x,&y)
#define P(x) printf("%d\n",x)
#define all(v) v.begin(),v.end()
#define FF first
#define SS second
#define pb push_back
#define mp make_pair

typedef long long int LL;
typedef pair<int, int > pii;
typedef vector<int > vi;

int main() {
  int n;
  S(n);
  int px,py,pt;
  px = py = pt = 0;
  while(n--) {
    int t;
    S(t);
    int x,y;
    S2(x,y);
    int dist = abs(px - x) + abs(py - y);
    int dt = t - pt;
    if(dt >= dist && (dt - dist) % 2 == 0) {
      
    } else {
      printf("No\n");
      return 0;
    }
  }
  printf("Yes\n");
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
/*	#include <boost/math/common_factor.hpp>  boost::math::lcm(10,20) ---> use it to find lcm. fill_n(&an[0][0],n*m,0); typedef long long ll;*/
using namespace std;
#define IO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define int long long 
#define PI pair<int , int >
#define mpr make_pair
#define ff first
#define ss second
#define endl "\n"
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define FO(i,a,b) for(int i = (int)a;i < (int)b;++i)
#define FE(i,a,b) for(int i = (int)a;i <= (int)b;++i)
const int MOD = 1e9+7;
const int MAXN = 1e5+3;
int dx[] = {1,-1,0,0};
int dy[] = {0,0,-1,1};
#define print(x) cerr << #x << " is " << x << endl;
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}
bool cmp(PI p1,PI p2){
	if(p1.ff < p2.ff)return true;	// You should not be writing p1.ss <= p2.ss !!!
	else if(p1.ff == p2.ff){ if(p1.ss < p2.ss)return true; return false; }
	return false;
}

void solve(){
	int n,k;
	cin >> n >> k;
	int R,S,P;
	cin >> R >> S >> P;
	string t;
	cin >> t;
	//cout << t << endl;
	///*
	string ans = "";
	int mx = 0;
	FO(i,0,k){
		if(t[i] == 'r'){
			ans += 'p';
			mx += P;
		}else if(t[i] == 'p'){
			ans += 's';
			mx += S;
		}else {
			ans += 'r';
			mx += R;
		}
		//cout << ans << endl;
	}
	
	FO(i,k,(int)t.length()){
		if(t[i] == 'r'){
			if(ans[i-k] == 'p'){
				ans += '?';
			}else{
				ans += 'p';
				mx += P;
			}
		}else if(t[i] == 'p'){
			if(ans[i-k] == 's'){
				ans += '?';
			}else {
				ans += 's';
				mx += S;
			}
		}else {
			if(ans[i-k] == 'r'){
				ans += '?';
			}else {
				ans += 'r';
				mx += R;
			}
		}
	}
	cout << mx << endl;
	//*/
}
/* When you have to multiply many things , do it in different (multiple) lines, not in a single line .*/
int32_t main(){
	IO;
	#ifndef ONLINE_JUDGE
	//freopen("input.txt", "r", stdin);
	#endif // ONLINE_JUDGE
	// std::cout << std::setprecision(15); std::cout << std::fixed;
	int nT = 1;
	//cin >> nT;
	FE(i,1,nT)
		solve();
	return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define x first
#define y second
#define ll long long
#define pii pair<int,int>
#define pb push_back
#define all(x) x.begin(),x.end()
#define endl '\n'


int main()
{
	map<int,int> mp;
	int n;
	cin>>n;
	long long an=0;
	for(int i=1;i<=n;i++){
		int a;
		cin>>a;
		int val=a-i;
		an+=mp[-val];
		mp[a+i]++;
	}
	cout<<an<<endl;
	return 0;
}

Measured memory_bytes: 20480
n, x = map(int, input().split())
a = list(map(int, input().split()))

ba = sum(a)
if a[0] > x:
    a[0] = x
for i in range(n-1):
    if a[i] + a[i+1] <= x:
        continue
    a[i+1] = x - a[i]
print(ba - sum(a))


Measured memory_bytes: 14252
y, m, d = map(int, input().split('/'))
 
if y < 2019:
	print("Heisei")
elif y == 2019:
	if m < 4 or (m == 4 and d <= 30):
		print("Heisei")
	else:
		print("TBD")
else:
	print("TBD")

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

int main()
{
    double xp1, yp1, xp2, yp2, xp, yp;
    int q;

    cin >> xp1 >> yp1 >> xp2 >> yp2;
    cin >> q;

    //直線p1p2の方程式作り、p1p2の傾きとpxの傾きの積が-1になることを利用して、直線pxの方程式を作る。2つの直線の方程式から交点を求め完了。
    for( int i = 0; i < q; i++ )
    {
        cin >> xp >> yp;

        double a, b, mx, my, x, y;
        a = xp2 - xp1;
        b = yp2 - yp1;
        
        //p1とp2が縦に並んだ場合
        if( a == 0 )
            cout << fixed << setprecision(10) << xp1 + ( xp1 - xp ) << " " << yp << endl;
        //p1とp2が横に並んだ場合
        else if( b == 0 )
            cout << fixed << setprecision(10) << xp << " " << yp1 + ( yp1 - yp ) << endl;
        else
        {
            mx = ( yp - yp1 + a * xp / b + b * xp1 / a ) / ( b / a + a / b );
            my = -1 * a * mx / b + yp + a * xp / b;
            x = mx + ( mx - xp );
            y = my + ( my - yp );
            cout << fixed << setprecision(10) << x << " " << y << endl;
        }
    }
    return 0;
}


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

int main(){
  long n, k;
  std::cin >> n >> k;
  std::string s;
  std::cin >> s;

  std::vector<long> zeroToOne = {0};
  std::vector<long> oneToZero;

  if(s[0] == '0')
    oneToZero.push_back(0);

  char before = s[0];
  for(long i = 1; i < n; ++i){
    if(before == '0' && s[i] == '1')
      zeroToOne.push_back(i);
    else if(before == '1' && s[i] == '0')
      oneToZero.push_back(i);
    before = s[i];
  }

  oneToZero.push_back(n);

  long ans = 0;

  if(oneToZero.size() < k + 1)
    ans = n;
  else{
    for(unsigned int i = 0; i < oneToZero.size() - k; ++i){
      long diff = oneToZero[i + k] - zeroToOne[i];
      if(diff > ans)
        ans = diff;
    }
  }

  std::cout << ans << std::endl;

  return 0;
}


Measured memory_bytes: 1404
h, w = map(int, input().split())

count = 0
for i in range(h):
    a = list(input())
    for j in range(w):
        if a[j] == '#':
            a[j] = 1
        else:
            a[j] = 0
    count += sum(a)
    
if count == w + h - 1:
    print('Possible')
else:
    print('Impossible')

Measured memory_bytes: 9072
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Diagnostics;

class Myon
{
    public Myon() { }
    public static int Main()
    {
        new Myon().calc();
        return 0;
    }

    Scanner cin;
    Func cin2;
    void calc()
    {
        cin = new Scanner();
        cin2 = new Func();
        char[] a=cin.next().ToCharArray();
        int n=a.Length;
        int ans=0;
        for(int i=0;i<n/2;i++)
        {
            if(a[i]!=a[n-1-i])ans++;
        }
        Console.WriteLine(ans);
    }
}



class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}

class Answer
{
    public void Int2DArrayAns(int[,]x,char c)
    {
        for(int i=0;i<x.GetLength(0);i++)
        {
            for(int j=0;j<x.GetLength(1)-1;j++)
            {
                Console.Write(x[i,j]);
                Console.Write(c);
            }
            Console.WriteLine(x[i,x.GetLength(1)-1]);
        }
    }
    public void Char2DArrayAns(char[,]x,char c)
    {
        for(int i=0;i<x.GetLength(0);i++)
        {
            for(int j=0;j<x.GetLength(1)-1;j++)
            {
                Console.Write(x[i,j]);
                Console.Write(c);
            }
            Console.WriteLine(x[i,x.GetLength(1)-1]);
        }
    }
}

class Func
{
    public long GCDLong(long a, long b)
    {
        while(a!=0)
        {
          long t=a;
          a=b%a;
          b= t;
        }
      
        return b;        
    }
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second

using P = pair<ll,int>;

const int V=400004;
const ll INF=LLONG_MAX/3;

struct Point{int x,y,id;};
bool cmp1(const Point &l, const Point &r)
{
    return l.x==r.x ? l.y<r.y : l.x<r.x;
}
bool cmp2(const Point &l, const Point &r)
{
    return l.y==r.y ? l.x<r.x : l.y<r.y;
}

struct edge{int to; ll cost;};
vector<edge> G[V];
ll d[V];

int main()
{
    int m,n,k;
    scanf(" %d %d %d", &m, &n, &k);

    vector<Point> p(k);
    rep(i,k) scanf(" %d %d", &p[i].x, &p[i].y);

    // sort by x,y
    sort(all(p),cmp1);

    rep(i,k) p[i].id=i;

    // put switch to goal if there is not
    if(!(p[k-1].x==m && p[k-1].y==n))
    {
        p.pb({m,n,k});
        ++k;
    }

    // connect y-direction
    rep(i,k-1)
    {
        if(p[i].x==p[i+1].x)
        {
            int dist = p[i+1].y-p[i].y;
            int u = 2*p[i].id, v = 2*p[i+1].id;
            G[u].pb({v,dist});
            G[v].pb({u,dist});
        }
    }

    // connect start and p[0]
    int start = 2*k;
    if(p[0].x==1)
    {
        int u = 2*p[0].id;
        G[start].pb({u,p[0].y-1});
        G[u].pb({start,p[0].y-1});
    }

    // sort by y,x
    sort(all(p),cmp2);

    // connect x-direction
    rep(i,k-1)
    {
        if(p[i].y==p[i+1].y)
        {
            int dist = p[i+1].x-p[i].x;
            int u = 2*p[i].id+1, v = 2*p[i+1].id+1;
            G[u].pb({v,dist});
            G[v].pb({u,dist});
        }
    }

    // change direction
    rep(i,k)
    {
        int u = 2*i, v = 2*i+1;
        G[u].pb({v,1});
        G[v].pb({u,1});
    }

    // dijkstra
    priority_queue<P,vector<P>,greater<P>> pq;
    pq.push(P(0,start));
    fill(d,d+V,INF);
    d[start] = 0;
    while(!pq.empty())
    {
        P now = pq.top();
        pq.pop();
        int v = now.se;
        if(now.fi>d[v]) continue;
        for(const auto &e:G[v])
        {
            if(d[e.to]>d[v]+e.cost)
            {
                d[e.to] = d[v]+e.cost;
                pq.push(P(d[e.to],e.to));
            }
        }
    }

    ll ans = min(d[2*k-2],d[2*k-1]);
    if(ans == INF) ans = -1;
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 50624
#include <cstdio>
#include <algorithm>
#define maxn 1000010
using namespace std;
struct node{
	int l,r;
}a[maxn];
int tot;
char s[maxn];
int cmp(node a,node b){
	return a.l-a.r>b.l-b.r;
}
int main(){
	int n,ln,rn;
	int i,j;
	ln=rn=0;
	scanf("%d",&n);
	for(i=1;i<=n;i++){
		int l=0,r=0;
		scanf("%s",s+1);
		for(j=1;s[j];j++)
			if(s[j]=='(')l++;
			else if(s[j]==')'){
				if(l)l--;
				else r++;
			}
		if(!l&&r)rn+=r;
		else if(l&&!r)ln+=l;
		else if(l&&r)a[++tot]=(node){l,r};	
	}
	sort(a+1,a+1+tot,cmp);
	for(int i=1;i<=tot;i++){
		if(ln<a[i].r)
			return printf("No\n")*0;
		ln-=a[i].r,ln+=a[i].l;
	}
	if(ln!=rn)return printf("No\n")*0;
	printf("Yes\n");
	return 0;
}

Measured memory_bytes: 3120
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
ll N;
int main(){
  cin>>N;
  vector<ll>a(2*N-1);
  for(int i=0;i<2*N-1;i++)
    cin>>a[i];
  ll left=1;ll right=2*N-1;
  vector<ll>b(2*N-1);
  while(1<right-left){
    ll mid=left+(right-left)/2;
    for(int i=0;i<2*N-1;i++)
    if(mid<=a[i])b[i]=1;else b[i]=0;
    ll x=-1;ll y=-1;
    for(int i=N-1;i<2*N-2;i++){
      if(b[i]==b[i+1]){y=i;break;}
    }for(int i=N-1;0<i;i--){
    if(b[i]==b[i-1]){x=i;break;}
    }if(x==-1 && y==-1){
    if((N%2==0 && b[N-1]==1)|| (N%2==1 && b[N-1]==0))
      right=mid;
      else
        left=mid;
    }else if(x!=-1 && y==-1){
    if(b[x]==1)left=mid;else right=mid;
    }else if(x==-1 && y!=-1){
    if(b[y]==1)left=mid;else right=mid;
    }else{
    if(y+x<=2*N-2){
    if(b[y]==1)left=mid;else right=mid;
    }else{
    if(b[x]==1)left=mid;else right=mid;
    }
    }
  }cout<<left<<endl;
  return 0;
}

Measured memory_bytes: 6408
from fractions import gcd
# from datetime import date, timedelta
from heapq import*
import math
from collections import defaultdict, Counter, deque
import sys
from bisect import *
import itertools
import copy
sys.setrecursionlimit(10 ** 7)
MOD = 10 ** 9 + 7

#グリッドを適当に移動してみると、いくつかの連結成分ができる
#その連結成分の条件を満たす組は（白の個数）×(黒の個数)で求まる。
#あとはそれを、すべての連結成分毎に足し合わせる
#PyPyは再帰遅い
def main():
    
    h, w = map(int, input().split())
    s = [list(input()) for i in range(h)]
    start = []
    for i in range(h):
        for j in range(w):
            if s[i][j] == "#": 
                start.append([i,j])

    ans = [0,0]
    vis = [[-1 for i in range(w)] for j in range(h)]
    def f(x, y, pre):
        vis[x][y] = 1
        if s[x][y] == "#":
            ans[0] += 1
        else:
            ans[1] +=1
        for i, j in [[1, 0], [-1, 0], [0, 1], [0, -1]]:
            nx = i + x
            ny = j + y
            if nx >= 0 and ny >= 0 and nx < h and ny < w and vis[nx][ny] == -1:
                if pre == "B" and s[nx][ny] == ".":
                    f(nx,ny,"W")
                elif pre == "W" and s[nx][ny] == "#":
                    f(nx, ny, "B")
                
    
    ret = 0
    for i, j in start:
        if vis[i][j] == -1:
            f(i, j, "B")
        ret += ans[0] * ans[1]
        ans[0] = ans[1] = 0
    print(ret)
        

if __name__ == '__main__':
    main()


Measured memory_bytes: 277564
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

int main(){
    int s;  cin>>s;
    vector<int> a(1000001);
    a[s]=s;
    int temp=a[s];
    
    for(int i=1;i<1000001;i++){
        if(temp%2==0&&a[temp/2]==0){
            a[temp/2]=temp/2;
            temp=temp/2;
        }else  if(temp%2==1&&a[temp*3+1]==0){
            a[temp*3+1]=3*temp+1;
            temp=3*temp+1;
        }else{
            cout<<i+1<<endl;
            break;
        }
    }
}

Measured memory_bytes: 4096
#include<iostream>
#include<iomanip>
#include<queue>
using namespace std;
int main()
{
  int n,i;
  double s,t;
  priority_queue<double,vector<double>,greater<double>> q;
  cin >> n;
  for(i=0;i<n;i++){
    cin >> t;
    q.push(t);
  }
  while(!q.empty()){
    s=q.top(); q.pop();
    t=q.top(); q.pop();
    s=(s+t)/2;
    if(q.empty()){
      cout << setprecision(10) << s << endl;
      return 0;
    }
    q.push(s);
  }
}

Measured memory_bytes: 256
newArray = []

x, y = input().split()

while x + y != "00":
    x = int(x)
    y = int(y)
    if x < y or x == y:
        newArray.append([str(x), str(y)])
    else:
        newArray.append([str(y), str(x)])
    x, y = input().split()

for i in range(len(newArray)):
    print(newArray[i][0] + " " + newArray[i][1])

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

using namespace std;


#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#define time__(d)for(auto blockTime = make_pair(chrono::high_resolution_clock::now(), true); blockTime.second;debug("%s: %.5lf s\n", d, chrono::duration_cast<chrono::milliseconds>(chrono::high_resolution_clock::now() - blockTime.first).count()/1000.0), blockTime.second = false)

template <typename T>std::string NumberToString ( T Number ){std::ostringstream ss; ss << Number;return ss.str(); } // Usages NumberToString(3)
template <typename T>T StringToNumber ( const string &Text ){istringstream ss(Text);T result;return ss >> result ? result : 0;} // StringToNumber<int>("3")

string StrCpy(string str, long long int start, long long int end){string temp = "";for(long long int i=start; i<=end; i++){temp += str[i];}return temp;}

#define ull unsigned long long int
#define ll long long int
#define gcd(a, b)  __gcd(a, b)
#define lcm(a, b)  ((a*b)/gcd(a, b))


int solve(){

    double d,s,t;

    cin >> d >> s >> t;

    if( (d/t) <= s) cout << "Yes" << endl;
    else cout << "No" << endl;
    

    return 0;

}

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

    //freopen("input.txt","r",stdin);

    time__("programm time"){
        solve();
	}
    return 0;

}


Measured memory_bytes: 3824
//stringray

#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

/*#ifndef __LOCAL__ 
#pragma comment(linker,"/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#endif*/ 

using namespace std;
using namespace __gnu_pbds;

typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ost;

typedef pair<int,int> pii;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<pii> vpii;
typedef vector<vi> vvi;
typedef vector<set<int>> vsi;

#define endl "\n"
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(),x.end()
#define pb emplace_back
#define F first
#define S second
#define fori(i,n) for(int i=1;i<=n;++i)
#define forn(i,n) for(int i=0;i<n;++i)
#define sz(x) int(x.size())
#define error(x) cout<<#x<<" "<<x<<endl
#define IOS  ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(0)


const int N=100*1000;
const int mod=1e9+7;

int min3(int a,int b,int c){return min(a,min(b,c));}
int max3(int a,int b,int c){return max(a,max(b,c));}
int min4(int a,int b,int c,int d){return min(min(a,b),min(c,d));}
int max4(int a,int b,int c,int d){return max(max(a,b),max(c,d));}

template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
template<typename T>
istream& operator >> (istream& is,vector<T>& vec){
  for(T &x:vec)is>>x;
  //for(int i=0;i<vec.size();++i)is>>x[i];
  return is;
}

template<typename T>
ostream& operator << (ostream& os,vector<T>& vec){
  for(int i=0;i<vec.size();++i){
    os<<vec[i]<<(i+1==vec.size()?"":" ");
  }
  return os;
}

ll mpow(ll a, ll b){
  ll ret=1;
  while(b>0){
    if(b&1)ret=(ret*a)%mod;
    (a=a*a)%=mod;
    b>>=1LL;
  }
  return ret;
}

//#define int int64_t
//int a[N+2];
void solve(){
  int n,d;cin>>n>>d;
  d=2*d+1;
  int ans=n/d+((n%d>0)?1:0);
  cout<<ans<<endl;
}
int32_t  main(){
  IOS;
  solve();
  return 0;
}



Measured memory_bytes: 256
#include<map>
#include<queue>
#include<time.h>
#include<limits.h>
#include<cmath>
#include<ostream>
#include<iterator>
#include<set>
#include<stack>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include <cstring>
using namespace std;
#define ll long long
const int N = 2e5 + 10;
ll dep[N];
ll nxt[N];
map<ll,ll>mp;
int main()
{
    ll n,k;
    cin >> n >> k;
    for(int i=1;i<=n;i++)
    {
        cin >> nxt[i];
    }
    ll cnt = 0,i;
    for( i=1;i<=2e5+5 && dep[i] == 0;i=nxt[i])
    {
        mp[cnt] = i;
        dep[i] = cnt++;
    }
    ll kk = cnt - dep[i],ans,begin = dep[i];
//    cout << kk << ' ' << begin << '\n';
//    for(int i=0;i<cnt;i++)
//    {
//        cout << mp[i] << ' ';
//    }
//    cout << '\n';
//    cout <<k << " " << mp[k] << '\n';
    if(k < cnt)
    {
        ans = mp[k];
    }
    else
    {
        k -= begin;
        k %= kk;
        ans = mp[k+begin];
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 19024
n,k = map(int, input().split())
a =list( map(int, input().split()))

ima = 0
here = 0

b = ['']*n

while True:

  b[here]=ima
  ima += 1
  here = a[here]-1
 
  if b[here] != '':
    y = ima - b[here]
    x,z = divmod( (k - ima) , y)
#    print(ima)
    ima =  ima + (x * y)
    b = ['']*n
#    print(ima , k , x , y)
  if ima == k:
    break
      
print(here+1)

Measured memory_bytes: 101116