akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;

/*BigInteger
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/rational.hpp>
namespace xxx = boost::multiprecision;
using Bint = xxx::cpp_int;
using Real = xxx::number<xxx::cpp_dec_float<1024>>;
*/

#define int long long
#define pb(x) push_back(x)
#define m0(x) memset((x), 0LL, sizeof(x))
#define mm(x) memset((x), -1LL, sizeof(x))

//container
#define ALL(x) (x).begin(), (x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
#define PERM(c) \
  sort(ALL(c)); \
  for (bool c##p = 1; c##p; c##p = next_permutation(ALL(c)))

// debug
#define GET_VAR_NAME(variable) #variable
#define test(x) cout << GET_VAR_NAME(x) << " = " << x << endl;

// bit_macro
#define Bit(n) (1LL << (n))
#define Bitset(a, b) (a) |= (1LL << (b))
#define Bitunset(a, b) (a) &= ~(1LL << (b))
#define Bitcheck(a, b) ((((a) >> (b)) & 1LL) == 1LL)
#define Bitcount(a) __builtin_popcountll((a))

//typedef
typedef long long lint;
typedef unsigned long long ull;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

//constant
constexpr int INF = (int)1e18;
constexpr int MOD = (int)1e9 + 7;
constexpr double PI = (double)acos(-1);
constexpr double EPS = (double)1e-10;
constexpr int dx[] = {-1, 0, 0, 1, 0, -1, -1, 1, 1};
constexpr int dy[] = {0, -1, 1, 0, 0, 1, -1, 1, -1};

//
template <typename T>
void chmax(T &a, T b) { a = max(a, b); }
template <typename T>
void chmin(T &a, T b) { a = min(a, b); }
//
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

//
struct Accelerate_Cin {
  Accelerate_Cin() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);
  };
} Accelerate_Cin;

int R, C, N;

int parse(int x, int y) {
  if (y == 0) return x;
  if (x == R) return R + y;
  if (y == C) return R + C + (R - x);
  return 2 * R + C + (C - y);
}

signed main() {
  cin >> R >> C >> N;
  vector<P> v;
  for (int i = 0; i < N; i++) {
    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    if (x1 != 0 && x1 != R && y1 != 0 && y1 != C) continue;
    if (x2 != 0 && x2 != R && y2 != 0 && y2 != C) continue;
    v.push_back({parse(x1, y1), i});
    v.push_back({parse(x2, y2), i});
  }

  sort(ALL(v));

  stack<int> stk;
  for (auto x : v) {
    int a = x.second;
    if (stk.empty()) {
      stk.push(a);
    } else {
      if (stk.top() == a) {
        stk.pop();
      } else {
        stk.push(a);
      }
    }
  }

  if (stk.size()) {
    cout << "NO" << endl;
  } else {
    cout << "YES" << endl;
  }
  return 0;
}


Measured memory_bytes: 6256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v) (v).begin,(v).end()
#define INF 1e9
#define MOD 1e9+7
typedef long long llong;
using namespace std;

int main(){
	int n;
	cin >> n;
	vector<int> cnt(26, 1);
	vector<char> s(n);
	REP(i, n){
		cin >> s[i];
		cnt[s[i] - 'a']++;
	}

	llong ans = cnt[0];
	for(int i = 1; i < 26; ++i){
		ans *= cnt[i];
		ans %= (int)MOD;
	}

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

Measured memory_bytes: 384
import java.util.Scanner;

public class Main{
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int N, M, X;
        N = sc.nextInt();
        M = sc.nextInt();
        X = sc.nextInt();

        int[] A = new int[M];
        for (int i = 0; i < M; ++i){
            A[i] = sc.nextInt();
        }

        int l = 0;
        int r = 0;
        for (int i = 0; i < M; ++i){
            if (A[i] < X){
                ++l;
            }else if (A[i] > X){
                ++r;
            }
        }
        System.out.println(Math.min(l, r));
    }
}

Measured memory_bytes: 23252
#include <stdio.h>
#include <algorithm>

using namespace std;

int main() {
	int n, w, pref[110], mini = 1000000, temp;
	scanf("%d", &n);
	pref[0] = 0;
	for (int i = 1; i <= n; i++) {
		scanf("%d", &w);
		pref[i] = pref[i - 1] + w;
	}
	for (int i = 0; i < n; i++) {
		temp = abs(pref[n] - pref[i] - pref[i]);
		mini = min(mini, temp);
	}
	printf("%d\n", mini);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <string>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <numeric>
using namespace std;

int abs(int num){
   if (num > 0)
      return num;
   else
      return -num;
}

int main(){
  string S;
  cin >> S;
  cout << "ABC" + S << endl;
}

Measured memory_bytes: 256
import random

class  Dise:
    def __init__(self,top,flont,right,left,back,bottom):
        self.top,self.flont,self.right,self.left,self.back,self.bottom=top,flont,right,left,back,bottom
        self.order='NNNNWNNNWNNNENNNENNNWNN'
    def rot(self,d):
        if d=='N':
            self.top,self.flont,self.bottom,self.back=self.flont,self.bottom,self.back,self.top
        elif d=='E':
            self.top,self.right,self.bottom,self.left=self.left,self.top,self.right,self.bottom
        elif d=='S':
                self.top,self.flont,self.bottom,self.back=self.back,self.top,self.flont,self.bottom
        elif d=='W':
            self.top,self.right,self.bottom,self.left=self.right,self.bottom,self.left,self.top
    
    def gettop(self):
        return self.top
    def getfront(self):
        return self.flont
    def getright(self):
        return self.right
    def getleft(self):
        return self.left
    def getback(self):
        return self.back
    def getbottom(self):
        return self.bottom
    
    def equals(self,another):
        for i in range(len(self.order)):
            self.rot(self.order[i])
            flag=0
            if dise1.gettop()==dise2.gettop() and dise1.getfront()==dise2.getfront() and dise1.getright()==dise2.getright() and dise1.getleft()==dise2.getleft() and dise1.getback()==dise2.getback() and dise1.getbottom()==dise2.getbottom():
                flag=1
                break
        if flag==1:
            return 1
        else:
            return 0

n=int(input())
A=[[0*6]for i in range(n)]
for i in range(n):
    A[i]=list(map(int,input().split()))
    
flag=1
for i in range(n):
    for j in range(i+1,n):
        dise1=Dise(A[i][0],A[i][1],A[i][2],A[i][3],A[i][4],A[i][5])
        dise2=Dise(A[j][0],A[j][1],A[j][2],A[j][3],A[j][4],A[j][5])
        if dise1.equals(dise2)==1:
            flag=0
            break
if flag==1:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 8220
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("filed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n:usize = read();
    let k:usize = read();
    let q:usize = read();
    let mut v = vec![0; n];
    for _ in 0..q {
        v[read::<usize>() - 1] += 1;
    }
    for i in v {
        if k > q - i {
            println!("Yes");
        } else {
            println!("No");
        }
    }
}


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


int main(){
	
	string str,Ostr;

	getline(cin , str);
    	    
   for(int i =0 ; i< str.length(); i++)
   {
   	if(isupper(str.at(i)))
		{
			if(i == 0 || str.at(i-1) == ' ' )
			Ostr += str.at(i);
		}	
   }
   
	cout<<Ostr;
}

Measured memory_bytes: 384
#include <iostream>

using namespace std;

int main()
{
	int R;
  	cin >> R;
  	if(R < 1200){
      cout << "ABC";
    }else if(1200 <= R && R < 2800){
      cout << "ARC";
    }else{
      cout << "AGC";
    }
  	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(int argc, char *argv[]) {
  int x, y;
  for (int i = 0; i <= 3000; i++) {
    cin >> x >> y;
    if (x == 0 && y == 0)
      break;
    if (x < y)
      cout << x << " " << y << endl;
    else
      cout << y << " " << x << endl;
  }
  return 0;
}

Measured memory_bytes: 3104
#include <iostream>
#include <iomanip>
#include <fstream>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <string>
#include <tuple>
#include <vector>
#include <map>
#include <unordered_map>
#include <list>
#include <set>
#include <stack>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <cassert>
using namespace std;
#define LL long long
#define MP(a, b) make_pair(a, b)
#define POWER9 1000000000
#define MOD POWER9+7
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483647
#define INT_MAX 2147483647
#define LL_MIN (LL)-9223372036854775807
#define LL_MAX (LL)9223372036854775807
#define PI 3.14159265359

int N;
int s[100];
int dp[100][10001];
int solve(int now, int sum){
	if(now == N){
		if(sum % 10 == 0) return 0;
		else return sum;
	}
	if(dp[now][sum] != -1) return dp[now][sum];
	return dp[now][sum] = max(solve(now+1,sum),solve(now+1,sum+s[now]));
}
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << setprecision(9);

	cin >> N;
	for(int i=0; i<N; i++){
		cin >> s[i];
		for(int j=0; j<=10000; j++) dp[i][j] = -1;
	}
	cout << solve(0,0) << endl;

	return 0;
}


Measured memory_bytes: 4224
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main(){
  int N,M,X,Y;
  cin>>N>>M>>X>>Y;
  vector<int> x(N);
  vector<int> y(M);
  for(int i=0; i<N;i++){
  	cin>>x[i];
  }
  for(int i=0; i<M;i++){
  	cin>>y[i];
  }
  x.push_back(X);
  y.push_back(Y);
  sort(x.begin(), x.end());
  sort(y.begin(), y.end());
  if(x.back() < y.front()){
    cout<<"No War"<<endl;
    return 0;
  }
  cout<<"War"<<endl;
  return 0;
}

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

int main()
{
    int n;
    cin >> n;
    vector<int> lis(n);
    for (int i = 0; i < n; i++)
    {
        cin >> lis.at(i);
    }
    int mod = 1000000007;
    long long ans = 0;

    long long sum = 0;
    for (int i = n - 2; i >= 0; i--)
    {
        sum = (sum + lis.at(i + 1)) % mod;
        ans = (ans + lis.at(i) * sum) % mod;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3988
#[doc = " https://github.com/hatoo/competitive-rust-snippets"]
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Write};
#[allow(unused_imports)]
use std::iter::FromIterator;
mod util {
    use std::fmt::Debug;
    use std::io::{stdin, stdout, BufWriter, StdoutLock};
    use std::str::FromStr;
    #[allow(dead_code)]
    pub fn line() -> String {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.trim().to_string()
    }
    #[allow(dead_code)]
    pub fn chars() -> Vec<char> {
        line().chars().collect()
    }
    #[allow(dead_code)]
    pub fn gets<T: FromStr>() -> Vec<T>
    where
        <T as FromStr>::Err: Debug,
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.split_whitespace()
            .map(|t| t.parse().unwrap())
            .collect()
    }
    #[allow(dead_code)]
    pub fn with_bufwriter<F: FnOnce(BufWriter<StdoutLock>) -> ()>(f: F) {
        let out = stdout();
        let writer = BufWriter::new(out.lock());
        f(writer)
    }
}
#[allow(unused_macros)]
macro_rules ! get { ( $ t : ty ) => { { let mut line : String = String :: new ( ) ; stdin ( ) . read_line ( & mut line ) . unwrap ( ) ; line . trim ( ) . parse ::<$ t > ( ) . unwrap ( ) } } ; ( $ ( $ t : ty ) ,* ) => { { let mut line : String = String :: new ( ) ; stdin ( ) . read_line ( & mut line ) . unwrap ( ) ; let mut iter = line . split_whitespace ( ) ; ( $ ( iter . next ( ) . unwrap ( ) . parse ::<$ t > ( ) . unwrap ( ) , ) * ) } } ; ( $ t : ty ; $ n : expr ) => { ( 0 ..$ n ) . map ( | _ | get ! ( $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ ( $ t : ty ) ,*; $ n : expr ) => { ( 0 ..$ n ) . map ( | _ | get ! ( $ ( $ t ) ,* ) ) . collect ::< Vec < _ >> ( ) } ; ( $ t : ty ;; ) => { { let mut line : String = String :: new ( ) ; stdin ( ) . read_line ( & mut line ) . unwrap ( ) ; line . split_whitespace ( ) . map ( | t | t . parse ::<$ t > ( ) . unwrap ( ) ) . collect ::< Vec < _ >> ( ) } } ; ( $ t : ty ;; $ n : expr ) => { ( 0 ..$ n ) . map ( | _ | get ! ( $ t ;; ) ) . collect ::< Vec < _ >> ( ) } ; }
#[allow(unused_macros)]
macro_rules ! debug { ( $ ( $ a : expr ) ,* ) => { eprintln ! ( concat ! ( $ ( stringify ! ( $ a ) , " = {:?}, " ) ,* ) , $ ( $ a ) ,* ) ; } }
const BIG_STACK_SIZE: bool = true;
#[allow(dead_code)]
fn main() {
    use std::thread;
    if BIG_STACK_SIZE {
        thread::Builder::new()
            .stack_size(32 * 1024 * 1024)
            .name("solve".into())
            .spawn(solve)
            .unwrap()
            .join()
            .unwrap();
    } else {
        solve();
    }
}
fn solve() {
    let (n, a, b) = get!(usize, u64, u64);
    let xs = util::gets::<u64>();

    let ans = xs
        .windows(2)
        .map(|w| min(b, a * (w[1] - w[0])))
        .sum::<u64>();

    println!("{}", ans);
}


Measured memory_bytes: 10620
#include <bits/stdc++.h>
using namespace std;
int main(){
int a,n,b,p1=0,p2=0,p3=0,t;
cin>>n>>a>>b;
for(int i=1;i<=n;i++){
	cin>>t;
	if(t<=a)
	p1++;
	else if(t>a&&t<=b)
	p2++;
	else
	p3++;
}
cout<<min(min(p1,p2),p3);

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
int main() {
    int n, m; std::cin >> n >> m;
    int answ(1);
    auto update = [&](int g) {
        if (m / g >= n) answ = std::max(answ, g);
    };
    for (int i = 1; i * i <= m; i++) {
        int j = m / i;
        if (i * j == m) {
            update(i);
            update(j);
        }
    }
    std::cout << answ << std::endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;

namespace AtCoder.B
{
    public class Program
    {
        public static void Main() { var r = GetResult(); Debug.WriteLine(r); Console.Write(r); }

        private static object GetResult()
        {
            var (a, b, c, d) = Read4Longs();
            return Math.Max(Math.Max(a * c, a * d), Math.Max(b * c, b * d));
        }

        #region Console.Read

        public static string ReadText() { return Console.ReadLine(); }
        public static List<string> ReadTexts() { return Console.ReadLine().Split(' ').ToList(); }
        public static long ReadLong() { return long.Parse(Console.ReadLine()); }
        public static (long, long) Read2Longs() { var ls = ReadLongs(); return (ls[0], ls[1]); }
        public static (long, long, long) Read3Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2]); }
        public static (long, long, long, long) Read4Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3]); }
        public static (long, long, long, long, long) Read5Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3], ls[4]); }
        public static List<long> ReadLongs() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList(); }

        #endregion
    }
}


Measured memory_bytes: 28268
D, G = map(int, input().split())
P, C = [], []
for _ in range(D):
  p, c = map(int, input().split())
  P.append(p)
  C.append(c)
  
ans = 1<<60
for bit in range(1<<D):
  s = 0
  num = 0
  rest_max = -1
  for i in range(D):
    if bit & (1<<i):
      s += 100*(i+1)*P[i]+C[i]
      num += P[i]
    else:
      rest_max = i
  if s < G:
    rest_max_point = 100*(rest_max+1)
    need = -(-(G-s)//rest_max_point)
    if need < P[rest_max]:
      num += need
    else:
      continue
  ans = min(ans, num)
  
print(ans)  
      
    

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

int main()
{
	int N;
	std::vector<int> As;

	std::cin >> N;

	int num_minus = 0;
	for (int i = 0; i < N; ++i) {
		int A;
		std::cin >> A;
		As.push_back(A);

		if (A < 0) {
			++num_minus;
		}
	}
	long sum = 0;
	if (num_minus % 2 == 0) {
		for (int i = 0; i < N; ++i) {
			sum += std::abs(As[i]);
		}
	}
	else {
		std::vector<int> As_abs;
		for (int i = 0; i < N; ++i) {
			const int A_abs = std::abs(As[i]);
			sum += A_abs;
			As_abs.push_back(A_abs);
		}

		int min = *std::min_element(As_abs.begin(), As_abs.end());
		sum -= 2 * min;
	}
	std::cout << sum;

	return 0;
}

Measured memory_bytes: 1400
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll cnt;
int main() {
	ll n;
	cin >> n;
	for (ll i = 1; i < n; ++i) {
		for (ll j = i; j < n; ++j) {
			if (i * j >= n)break;
			if (i == j)++cnt;
			else cnt += 2;
		}
	}
	cout << cnt << endl;
	return  0;
}

Measured memory_bytes: 3632
#include <iostream>
#define MAX_T 100000
#define MAX_W 10000

typedef long long ll;
using namespace std;

int n, k;
ll T[MAX_T];

int check(ll P){
  int i = 0;
  for(int j = 0; j < k; j++){
    ll s = 0;
    while(s + T[i] <= P){
      s += T[i];
      i++;
      if(i == n){ return n; }
    }
  }
  return i;
}

int solve(){
  ll left = 0;
  ll right = MAX_T * MAX_W;
  ll mid;
  while(right - left > 1){
    mid = (left + right) / 2;
    int v = check(mid);
    if(v >= n){ right = mid; }
    else { left = mid; }
  }
  return right;
}

int main(){
  cin >> n >> k;
  for(int i = 0; i < n; i++){
    cin >> T[i];
  }
  ll ans = solve();
  cout << ans << endl;
  
  return 0;
}



Measured memory_bytes: 3888
N=int(input())
T=list(map(int,input().split()))
M=int(input())
P=[list(map(int, input().split())) for i in range(M)]
tmp=0
ans=0

for i in range(M):
    tmp=0
    for j in range(len(T)):
        if j == P[i][0]-1:
            tmp +=P[i][1]
        else:
            tmp +=T[j]
    print(tmp)

Measured memory_bytes: 9200
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;
    
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define doublecout(a) cout<<fixed<<setprecision(15)<<a<<endl;
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second
#define P pair<ll,ll> 
#define m_p make_pair
#define V vector<ll> 
#define U_MAP unordered_map<ll,ll>
#define pq priority_queue<ll>
#define rpq priority_queue<ll,vector<ll>,greater<ll>>
#define p_b push_back
    
ll n,cnt,ans,a,b,c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k,q;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};
    
//------ Believe yourself as a genius!!!!!! ------
    
int main(void){
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    
    cin>>n;
    rep(i,100){
        rep(j,100){
            tmp=4*i+7*j;
            if(tmp==n){
                Cout("Yes");
                return 0;
            }
        }
    }
    Cout("No");
    return 0;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
#include <string.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for(int i = m; i < n; i++) 
#define mod 1000000007
#define pi 3.1415926535
typedef long long ll;

int main(){
    int A,B,K;
    cin>>A>>B>>K;
    rep(i,K){
        if(i%2==0){
            if(A%2==1){
                A--;
            }
            B+=A/2;
            A/=2;
        }else{
            if(B%2==1){
                B--;
            }
            A+=B/2;
            B/=2;
        }
    }

    cout<<A<<" "<<B<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include<string>
#include<string.h>
#include <math.h>
#include<iostream>
#include <algorithm>
#include <map>
#include <vector>
#include <queue>
using namespace  std;


/*
//my header
#include "define.h"
#include "geometry.h"*/

#define MyAbs(a) ((a)>0?(a):-(a))
#define MyEqualDoule(a,b) (MyAbs(a-b)<1e-6)

#define foreach(i,n) for(i=0;i<n;++i)
#define foreachd(i,n) for(int i=0;i<n;++i)
#define printfInt1(n) printf("%d\n",n)
#define scanfInt1(n) scanf("%d",&n)
#define scanfInt2(a,b) scanf("%d%d", &a, &b)
#define scanfInt3(a,b,c) scanf("%d%d%d", &a, &b, &c)
#define scanfFloat2(a,b) scanf("%f%f", &a,&b)


void init()
{
#ifdef _WIN32
	freopen("1.txt", "r", stdin);
#endif
}

void func();

int main()
{
	init();
	func();

	return 0;
}

class CNumberTheory
{
public:
	//譛?、ァ蜈ャ郤ヲ謨ー
	static int gcd(int a, int b)
	{
		int t;
		while (b) {
			t = a % b;
			a = b;
			b = t;
		}
		return a;
	}
	//譛?ー丞?蛟肴焚
	static int lcm(int a,int b)
	{
		return a / gcd(a,b) * b;
	}
	//郤ソ諤ァ逕滓?蟆丈コ守ュ我コ始逧?エ?焚,螯よ棡a譏ッ邏?焚?碁ぅ荵?ns[a] = true
	static void GenePrimeJudge(int n, bool* ans)
	{
		memset(ans, true, sizeof(bool) * (n+1));
		ans[0] = false;
		ans[1] = false;
		int i;
		for(i = 2; i <= n; ++ i)
		{
			if(ans[i])
			{
				int j = 2;
				int k;
				while((k = i * j++) <= n)
					ans[k] = false;
			}
		}
	}
	//郤ソ諤ァ逕滓?蟆丈コ守ュ我コ始逧?エ?焚,螯Ｑrime[size = p]荳ュ蟄俶叛蟆丈コ始逧?エ?焚
	static void GenePrimeList(int n, int *prime, int& p)
	{
		bool* ans = new bool[n+1];
		memset(ans, true, sizeof(bool) * (n+1));
		ans[0] = false;
		ans[1] = false;
		p = 0;
		int i;
		for(i = 2; i <= n; ++ i)
		{
			if(ans[i])
			{
				prime[p++] = i;
				int j = 2;
				int k;
				while((k = i * j++) <= n)
					ans[k] = false;
			}
		}
	}

	//郤ソ諤ァ逕滓?蟆丈コ守ュ我コ始逧?エ?焚,螯よ棡a譏ッ邏?焚?碁ぅ荵?ns[a] = true,蟷カ荳廃rime[size = p]荳ュ蟄俶叛蟆丈コ始逧?エ?焚
	static void GenePrimeJudgeAndList(int n, bool* ans, int *prime, int& p)
	{
		memset(ans, true, sizeof(bool) * (n+1));
		ans[0] = false;
		ans[1] = false;
		p = 0;
		int i;
		for(i = 2; i <= n; ++ i)
		{
			if(ans[i])
			{
				prime[p++] = i;
				int j = 2;
				int k;
				while((k = i * j++) <= n)
					ans[k] = false;
			}
		}
	}
};

class CSearch
{
public:
	//扈吝ョ壻ク?クェ譛牙コ擾シ磯撼髯榊コ擾シ画焚扈Б?梧アゆササ諢丈ク?クェi菴ソ蠕輸[i]遲我コ嗣ey?御ク榊ュ伜惠蛻呵ソ泌屓-1
	static int BinarySearch(int key, int* arr, int n)
	{
		int l = 0, r = n - 1;
		while(l <= r)
		{
			int mid = (r + l)>>1;
			if(arr[mid] == key)
				return mid;
			if(arr[mid] < key)
				l = mid + 1;
			else
				r = mid + 1;
		}
		return -1;
	}

	//扈吝ョ壻ク?クェ譛牙コ擾シ磯撼髯榊コ擾シ画焚扈Б?悟庄蜷ォ譛蛾?螟榊?邏?シ梧アよ怙蟆冗噪i菴ソ蠕輸[i]螟ァ莠嗣ey?御ク榊ュ伜惠蛻呵ソ泌屓-1
	static int BinarySearch_FirstPos_Greater(int key, int* arr, int n)
	{
		int l = 0, r = n - 1;
		while(l < r)
		{
			int mid = (r + l)>>1;
			if(arr[mid] > key)
				r = mid;
			else
				l = mid + 1;
		}
		return arr[r] > key ? r: -1;
	}
};

bool ans[1000000];
int prime[100000];

void func()
{
	int p;
	CNumberTheory::GenePrimeJudgeAndList(999999, ans, prime, p);

	int n;
	while(~scanf("%d", &n))
	{
		int ret;;
		ret = CSearch::BinarySearch_FirstPos_Greater(n,prime,p);
		if(ret == -1)
			ret = p;
		printfInt1(ret);
	}
}

Measured memory_bytes: 2480
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define max0(a,b,c) max(max(a,b),c)
#define min0(a,b,c) min(min(a,b),c)
#define ft first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define all(v) (v).begin(),(v).end()
#define mod 1000000007
using namespace std;
using Graph = vector<vector<int>>;
typedef long long lint;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ldouble;
typedef vector<int> vec;
typedef vector<ll> lvec;
typedef vector<ull> ulvec;
typedef vector<double> dvec;
typedef vector<pair<int,int>> pvec;
typedef vector<pair<ll,ll>> plvec;
typedef vector<tuple<ll,ll,ll>> tvec;
typedef vector<string> svec;

int main(){
    int a,b;
    cin>>a>>b;
    cout<<a*b-(a+b-1);
}

Measured memory_bytes: 256
#include <stdio.h>
 
int main() {
    int a, b;
    int temp;
 
    scanf("%d %d", &a, &b);
 
    if (b > a) {
        temp = a;
        a = b;
        b = temp;
    }
 
    while (a % b != 0) {
        a = a%b;
 
        if (b > a) {
            temp = a;
            a = b;
            b = temp;
        }
    }
 
    printf("%d\n", b);
    return 0;
}


Measured memory_bytes: 2044
N=int(input())
S=[input() for i in range(N)]

S.sort()
ans=[S[0]]
num=1
max_num=1
for i in range(N-1):
  if(S[i]==S[i+1]):
    num+=1
  else:
    num=1
  if(num==max_num):
    ans.append(S[i+1])
  if(num>max_num):
    max_num=num
    ans=[S[i+1]]
  
ans.sort()
for i in range(len(ans)):
  print(ans[i])

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

#include <map> 

using namespace std;
#include <math.h>    // for sqrt

map< int64_t, int > prime_factor(int64_t n);

map< int64_t, int > prime_factor(int64_t n) {
  map< int64_t, int > ret;
  for(int64_t i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}


int main() {
    long A,B;
    
    cin >> A >> B;
    auto a = __gcd(A,B);

    vector<long> vec;

    for(auto p : prime_factor(a)) {
        while(p.second--) vec.push_back(p.first);
    }

    vec.erase(std::unique(vec.begin(), vec.end()), vec.end());

    cout << vec.size()+1 << endl;
    return 0;
}

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

using ll = long long;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = (n); i > 0; i--)
#define all(n) n.begin(), n.end()
#define print(n) cout << n << endl

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    
    ll n,m;
    cin >> n >> m;

    vector<ll> h(n+1);
    rep(i,n) cin >> h[i+1];
    
    vector<ll> e(n+1,0);
    ll a,b;
    rep(i,m){
        cin >> a >> b;
        if(e[a] < h[b]) e[a] = h[b];
        if(e[b] < h[a]) e[b] = h[a];
    }
    ll ans=0;
    rep(i,n+1){
        if(i==0) continue;
        if(e[i]==0 || e[i] < h[i]){
            ans++;
        }
    }
    print(ans);
    return 0;   
    
}

Measured memory_bytes: 4660
#include <bits/stdc++.h>
#define endl '\n'
using namespace std;

const int MAX_N = 2e5 + 5;

int n;
string s;

int nextChar[MAX_N][27], firstLetter[27];

bool usedStates[MAX_N];
int dp[MAX_N], parent[MAX_N];

void Precompute() {
	int currNext[27];
	for(int i = 0; i < 26; i++) {
		currNext[i] = n;
	}

	for(int i = n - 1; i >= 0; i--) {
		for(int j = 0; j < 26; j++) {
			nextChar[i][j] = currNext[j];
		}
		
		currNext[s[i] - 'a'] = i;
	}
	
	for(int i = 0; i < 26; i++) {
		firstLetter[i] = currNext[i];
	}
}

int Solve(int ind) {
	if(ind == n) {
		return 0;
	}
	else if(usedStates[ind]) {
		return dp[ind];
	}
	
	int bestAns = n + 10, bestAnsChar = 0;
	for(int i = 0; i < 26; i++) {
		if(Solve(nextChar[ind][i]) + 1 < bestAns) {
			bestAns = Solve(nextChar[ind][i]) + 1;
			bestAnsChar = i;
		}
	}
	
	dp[ind] = bestAns;
	parent[ind] = bestAnsChar;
	usedStates[ind] = true;
	
	return bestAns;
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	cin >> s;
	n = s.size();
	
	s += 'a';
	
	Precompute();
	
	int ansLength = n + 1, startInd = 0, startLetter = 0;
	for(int i = 0; i < 26; i++) {
		if(Solve(firstLetter[i]) + 1 < ansLength) {
			ansLength = Solve(firstLetter[i]) + 1;
			startInd = firstLetter[i];
			startLetter = i;
		}
	}
	
	string ans = "";
	ans += (char)(startLetter + 'a');
	while(startInd < n) {
		ans += (char)(parent[startInd] + 'a');
		
		startInd = nextChar[startInd][parent[startInd]];
	}
	
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 23828
#include<bits/stdc++.h>
using namespace std;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<long long> vlong;
#define _GLIBCXX_DEBUG
#define vpush(a,x) a.push_back(x);
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
const int INF = 1 << 30;
const int dx[] = {1,0,-1,0,1,1,-1,-1};
const int dy[] = {0,-1,0,1,1,-1,-1,1};
#define stp(x)  setprecision(x)
int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  string s;
  cin>>s;
  int count=0,count2=0;
  rep(i,(int)s.size()){
    if(i%2==0 && s[i]!='1'){
      count++;
    }
    else if(i%2==1 && s[i]!='0'){
      count++;
    }
  }
  rep(i,(int)s.size()){
    if(i%2==0 && s[i]!='0'){
      count2++;
    }
    else if(i%2==1 && s[i]!='1'){
      count2++;
    }
  }
  cout<<(count<count2 ? count : count2)<<'\n';
  return(0);
}


Measured memory_bytes: 512
import math
def isprime(x):
    if x==2:
        return 1
    elif x<2 or x%2==0:
        return 0
    else :
        i=3
        while i<=math.sqrt(x):
            if x%i==0:
                return 0
            i=i+2
        return 1

while True:
    ans=[]
    a,d,n=map(int,input().split())
    if a==0 and d==0 and n==0:
        break
    i=0
    while len(ans)<=n:
        if isprime(a+d*i)==1:
            ans.append(a+d*i)
        i+=1
    print(ans[n-1])


Measured memory_bytes: 5660
N = int(input())
S = list(input())

numE = S.count('E')
numTurn = numE
numW = 0

for dir in S:
    if dir == 'E':
        numE -= 1
    else:
        numW += 1
    if numTurn > numE + numW:
        numTurn = numE + numW

print(numTurn)


Measured memory_bytes: 5964
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

using namespace std;

// repetition
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

// container util
#define all(x) (x).begin(), (x).end()

// debug
#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x)                                         \
  cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
       << " " << __FILE__ << endl;

// typedef
typedef long long lint;
typedef unsigned long long ull;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

// constant
const int MOD = (int)1e9 + 7;
const int INF = (int)1e18;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

// conversion
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

//
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
//

int H, W;
vector<string> a;

int dp[1100][1100] = {0};

void add(int& a, int b) {
  a += b;
  a %= MOD;
}

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

  cin >> H >> W;
  a.resize(H);
  rep(i, H) cin >> a[i];

  dp[0][0] = 1;

  rep(y, H) {
    rep(x, W) {
      if (y + 1 < H && a[y + 1][x] == '.') add(dp[y + 1][x], dp[y][x]);
      if (x + 1 < W && a[y][x + 1] == '.') add(dp[y][x + 1], dp[y][x]);
    }
  }

  cout << dp[H - 1][W - 1] << endl;

  return 0;
}

Measured memory_bytes: 5632
#include<bits/stdc++.h>
using namespace std;
#define arep(i,x,n) for(int i=int(x);i<(int)(n);i++)
#define rep(i,n) for(long long i = 0;i < n;++i)
#define pi 3.141592653589793
#define eps 0.00000001
#define INF 1e9+7  
using ll = long long; 
using P=pair<int,int>;
using lP=pair<ll,ll>;
using fP=pair<double,double>;
ll const mod=998244353;
const ll MAX=300000;
using vi=vector<int>;
using vc=vector<char>;
using vs=vector<string>;
using vvi =vector<vector<int>>;
using vvc=vector<vector<char>>;
using vvp =vector<vector<P>>;
int main(){
    ll n=0;
    cin>>n;
    ll a=1,b;
    for(ll i=1;i*i<=n;i++){
        if(n%i==0)a=i;
    }
    b=n/a;
    cout<<a+b-2<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int i,sum;
	char S[100],num[100];
	
	scanf("%s",S);
	
	i=0;
	sum=0;
	
	while(S[i]!=0){
		if(S[i]=='+'){
			sum=sum+1;
		}else{
			sum=sum-1;
		}
		
		i++;
	}
	printf("%d\n",sum);
	
	return 0;
}

Measured memory_bytes: 128
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

func main() {
	var n, d int
	fmt.Scan(&n)
	fmt.Scan(&d)

	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)

	points := make([][]int, n)
	for i := 0; i < n; i++ {
		points[i] = make([]int, d)
		for j := 0; j < d; j++ {
			scanner.Scan()
			points[i][j], _ = strconv.Atoi(scanner.Text())
		}
	}

	var ret int
	for i := 0; i < n; i++ {
		for j := i + 1; j < n; j++ {
			var s float64
			for k := 0; k < d; k++ {
				s += float64((points[i][k] - points[j][k]) * (points[i][k] - points[j][k]))
			}
			s = math.Sqrt(s)
			f := math.Floor(s)
			if s == f {
				ret++
			}
		}
	}

	fmt.Println(ret)
}


Measured memory_bytes: 640
import java.util.*

// 入力取得
fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun listOfString() = next().split(" ")
fun listOfInt() =listOfString().map { it.toInt() }
fun listOfLong() =listOfString().map { it.toLong() }
fun listOfDouble() =listOfString().map { it.toDouble() }

fun main(args: Array<String>) {
    val H = nextLong()
    var h = H
    var n:Long = 0L
    while(h > 0L) {
        h /= 2L
        n++
    }
    n--
    println("${2*powerN(2, n.toInt()) - 1}")
}

fun powerN(number: Long, power: Int): Long {
    var power = power
    if (power == 0) return 1
    var result = number

    while (power > 1) {
        result *= number
        power--
    }

    return result.toLong()
}

inline fun <T> Iterable<T>.sumByLong(selector: (T) -> Long): Long {
    var sum = 0L
    for (element in this) {
        sum += selector(element)
    }
    return sum
}

Measured memory_bytes: 33656
#include <iostream>
#include <map>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;

int main()
{
	int n;
	cin >> n;
	auto m = map<string, int>();
	int h = 0;
	for(int i = 0; i < n; ++i){
		string s;
		cin >> s;
		h = max(h, ++m[s]);
	}
	auto ans = vector<string>();
	for(auto it : m){
		if(it.second == h) ans.push_back(it.first);
	}
	sort(ans.begin(), ans.end());
	for(auto a : ans) cout << a << endl;
	return 0;
}

Measured memory_bytes: 26868
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main() {
    int n;
    cin >> n;
    vector<int> h(n),a(n);
    for(int i = 0; i < n; i++) cin >> h[i];
    int ans=0;
    if(n==1){
        ans = h[0];
    }
    else{
    while(h != a){
       for(int i = 0; i < n-1; i++) {
           if(i==0 && h[0]!=0) {
               ans ++;
               continue;
           }

           if(h[i]==0 && h[i+1] != 0) ans ++;

       } 
       for(int i = 0; i < n; i++) {
           if(h[i]!=0) h[i]--;
       }
    }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3604
#!/usr/bin/env python3
import sys
import math

def solve(K: int):
    sum = 0
    for a in range(1, K + 1):
        for b in range(1, K + 1):
            for c in range(1, K + 1):
                sum += math.gcd(math.gcd(a,b), c)

    print(sum)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    K = int(next(tokens))  # type: int
    solve(K)

if __name__ == '__main__':
    main()


Measured memory_bytes: 67784
//in progress
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define fr(i,a,b) for(int i = (int)(a); i <= (int)(b); i++)
#define forn(i,n) for(int i =0; i < (int)(n); i++)
#define rfr(i,a,b) for(int i = (int)(a); i >= (int)(b); i--)
#define PI 3.14159265
ll n,a[100010],store[100010],k=2;
ll recur(int ind)
{
  if(ind>=n-1)
  return (ll)0;
  for(int i=1;i<=k && i+ind<n;i++)
  {
    if(store[ind+i]==-1)
    store[ind+i]=recur(ind+i);
  }
  ll x=10000000000000;
  for(int i=1;i<=k && i+ind<n;i++)
    x=min(store[ind+i]+abs(a[ind+i]-a[ind]),x);
  return x;
}
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  //freopen("a.in", "r", stdin);
  //freopen("a.out", "w", stdout);
  cin>>n;
  memset(store,-1,sizeof(store));
  for(int i=0;i<n;i++)
  cin>>a[i];
  cout<<recur(0)<<"\n";
  return 0;
}


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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n";
#define int long long

const int N=2e5+5;

int n, k, idx;
int a[N];
set<int> s;

int32_t main()
{
	IOS;
	cin>>n>>k;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		if(a[i]==1)
			idx=i;
	}
	int ans=(n-1+k-2)/(k-1);
	cout<<ans;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <iomanip>
#include <algorithm>
#include <queue>
#include <bitset>
#include <map>

using namespace std;

int main(){

    int A, B, K;
    cin >> A >> B;

    if ((A+B) % 2 == 1){
        cout << "IMPOSSIBLE" << endl;
        return 0;
    }

    cout << (A + B) / 2 << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        List<List<Integer>> list = new ArrayList<>();
        List<Integer> p = new ArrayList<>();
        for(int i=0; i<m; i++) {
            int k = sc.nextInt();
            List<Integer> s = new ArrayList<>();
            for(int j=0; j<k; j++) {
                s.add(sc.nextInt() -1);
            }
            list.add(s);
        }
        for(int i=0; i<m; i++) {
            p.add(sc.nextInt());
        }
        int ans = 0;
        for(int bit=0; bit<Math.pow(2, n);bit++) {
            boolean ok = true;
            for(int i=0; i<m; i++) {
                int count = 0;
                for(int sw : list.get(i)) {
                    if(((bit >> sw) & 1) == 1) {
                        count++;
                    }
                }
                if(count % 2 != p.get(i)) {
                    ok = false;
                    break;
                }
            }
            if(ok) ans++;
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 36448
using namespace std;

struct SplayNode{
  SplayNode*left,*right,*parent;
  int size,value;
  SplayNode(){
    left=nullptr;
    right=nullptr;
    parent=nullptr;
    size=1;
  }
  void rotate(){
    SplayNode*p,*pp,*c;
    p=parent;
    pp=p->parent;

    if(p->left==this)c=right,right=p,p->left=c;
    else c=left,left=p,p->right=c;

    if(pp&&pp->left==p)pp->left=this;
    if(pp&&pp->right==p)pp->right=this;
    parent=pp;
    p->parent=this;
    if(c)c->parent=p;

    p->update();
    update();
  }
  int state(){
    if(!parent)return 0;
    if(parent->left==this)return 1;
    if(parent->right==this)return -1;
    return 0;
  }
  void splay(){
    while(state()!=0){
      if(parent->state()==0)rotate();
      else if(state()==parent->state()){
        parent->rotate();
        rotate();
      }
      else{
        rotate();
        rotate();
      }
    }
  }
  void update(){
    size=1;
    if(left)size+=left->size;
    if(right)size+=right->size;
  }
};

SplayNode*get(int index,SplayNode*root){
  SplayNode*now=root;
  while(true){
    int lsize=now->left?now->left->size:0;
    if(index<lsize){
      now=now->left;
    }
    if(index==lsize){
      now->splay();
      return now;
    }
    if(index>lsize){
      now=now->right;
      index=index-lsize-1;
    }
  }
}


#include<bits/stdc++.h>

SplayNode node[220000];

int main(){
  int q,ord,x;
  cin>>q;
  int size=0;
  for(int i=0;i<q;i++){
    node[i].parent=&node[i+1];
    node[i+1].left=&node[i];
    node[i+1].update();
  }

  SplayNode*root=&node[q];

  for(int i=0;i<q;i++){
    cin>>ord;
    if(ord==0){
      cin>>x;
      root=get(size++,root);
      root->value=x;
    }
    if(ord==1){
      cin>>x;
      root=get(x,root);
      cout<<root->value<<endl;
    }
    if(ord==2){
      size--;
    }
  }
}



Measured memory_bytes: 9968
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1e+9;

template <class T>
inline bool chmin(T &a, T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}

template <class T>
inline bool chmax(T &a, T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}

int main()
{
  int N, K;
  cin >> N >> K;
  ll V[N];
  for (int i = 0; i < N; i++)
  {
    cin >> V[i];
  }

  int LR = min(N, K);
  ll ans = 0;
  for (int l = 0; l <= LR; l++)
  {
    for (int r = 0; r <= LR - l; r++)
    {
      vector<ll> val(0);
      for (int i = 0; i < l; i++)
      {
        val.push_back(V[i]);
      }
      for (int i = 0; i < r; i++)
      {
        val.push_back(V[N - 1 - i]);
      }

      sort(val.begin(), val.end());
      for (int i = 0; i < K - l - r; i++)
      {
        if (val.size() > 0 && val[0] < 0)
          val.erase(val.begin());
        else
          break;
      }

      ll sum = 0;
      for (int i = 0; i < val.size(); i++)
      {
        sum += val[i];
      }

      chmax(ans, sum);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(){
	int num[4]={0};
	int N;string st;
	while(cin >> N >> st){
		if(st==",A") num[0]++;
		if(st==",B") num[1]++;
		if(st==",AB") num[2]++;
		if(st==",O") num[3]++;
	};
	for(int i=0;i<4;i++) cout << num[i] <<'\n' ;
}

Measured memory_bytes: 1200
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <cmath>
#include <queue>
#include <numeric>
#include <climits>
#include <iterator>
#include <iomanip>
#include <stack>
#include <set>
#include <cstdio>
#include <bitset>
#include <functional>
#include <tuple>
#include <list>
#include <deque>
#include <sstream>
using namespace std;
const constexpr int INF = 1e9;

#define FOR(i, a, n) for (ll i = (ll)a; i<(ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)

typedef long long ll;
typedef vector<int> VI;
typedef pair<ll, ll> P;
struct Less{
   bool operator()(const pair<string, int>&a, const pair<string, int>&b){
        if(a.first==b.first){
            return a.second < b.second;
        }
       return a.first < b.first;
    }
};
const constexpr ll MOD = 1e9 + 7;


ll extGCD(ll a, ll b, ll& x, ll& y){
    if(b==0){
        x=1;
        y=0;
        return a;
    }
    ll d = extGCD(b, a%b, y, x);
    y -= a/b*x;
    return d;
}
ll GCD(ll a, ll b){
    if(b==0) return a;
    return GCD(b, a%b);
}


int main() {
    ll N, M;  cin >> N >> M;
    
    ll ans=1;
    for(ll i=1; i*i<=M; ++i){
        if(M%i!=0) continue;
        
        if(i<=M/N) ans = max(ans, i);
        if(M/i<=M/N) ans = max(ans, M/i);
    }
    cout << ans << endl;
    
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,a) for(int i=0;i<(a);i++)
const ll MOD=1000000007;

int use[55];
ll beki[55];
const ll INF=LLONG_MAX;

int main(){
  beki[0]=1;
  rep(i,51) beki[i+1]=2*beki[i];
  int N; cin>>N;
  int A[N],B[N];
  rep(i,N) cin>>A[i];
  rep(i,N) cin>>B[i];
  for(int i=1;i<=51;i++) use[i]=1;
  for(int i=51;i>=1;i--){
    use[i]=0;
    ll G[55][55];
    rep(j,55) rep(k,55){
      if(j==k) G[j][k]=0;
      else G[j][k]=INF;
    }
    for(int j=51;j>=1;j--) for(int k=j;k>=1;k--){
      if(use[k]) G[j][j%k]=min(G[j][j%k],beki[k]);
    }
    rep(l,51) rep(j,51) rep(k,51) if(G[j][l]!=INF&&G[l][k]!=INF){
      G[j][k]=min(G[j][k],G[j][l]+G[l][k]);
    }
    bool flag=0;
    rep(j,N) if(G[A[j]][B[j]]==INF) flag=1;
    if(flag&&i==51){
      cout<<-1<<endl;
      return 0;
    }
    if(flag) use[i]=1;
  }
  ll ans=0;
  for(int i=1;i<=50;i++) if(use[i]) ans+=beki[i];
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int judge(int,int,int,int,int);
int main(){

  int W,H,x,y,r;
  int j;

  scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
  if(judge(W,H,x,y,r)==-1)printf("No\n");
  else printf("Yes\n");

  return 0;

}

int judge(int W,int H,int x,int y,int r){

  if(x-r<0 || x+r>W || y-r<0 || y+r>H)return -1;
  else return 1;

}

Measured memory_bytes: 2600
# https://onlinejudge.u-aizu.ac.jp/courses/library/4/CGL/all/CGL_1_C
# この問題は後の交差判定のところで使う
from math import sqrt


class Vector:
    def __init__(self, ls):
        '''
        ls ... list
        '''
        self.vec = ls

    def __len__(self):
        return len(self.vec)

    def __getitem__(self, idx):
        return self.vec[idx]

    def __repr__(self):
        return f'Vector({self.vec})'

    def add(self, vec):
        '''
        vec ... vector class
        '''
        assert len(self) == len(vec)
        ret = [a + b for a, b in zip(self.vec, vec.vec)]
        return Vector(ret)

    def sub(self, vec):
        '''
        vec ... vector class
        '''
        assert len(self) == len(vec)
        ret = [a - b for a, b in zip(self.vec, vec.vec)]
        return Vector(ret)

    def mul(self, vec):
        '''
        vec ... vector class
        '''
        assert len(self) == len(vec)
        ret = [a * b for a, b in zip(self.vec, vec.vec)]
        return Vector(ret)

    def norm(self):
        tmp = sum([x * x for x in self.vec])
        return sqrt(tmp)


def norm(vec):
    '''
    vec ... Vector class
    '''
    return vec.norm()


def cross(a, b):
    '''
    Outer product for 2d
    a,b ... Vector class
    '''
    assert len(a) == 2 and len(b) == 2
    first = a[0] * b[1]
    second = a[1] * b[0]
    return first - second


def dot(a, b):
    return sum(a.mul(b))


EPS = 1e-10


def ccw(p0, p1, p2):
    '''
    問題を解くための関数
    引数はすべてVector
    '''
    a = p1.sub(p0)
    b = p2.sub(p0)
    if cross(a, b) > EPS:
        return 'COUNTER_CLOCKWISE'
    elif cross(a, b) < -EPS:
        return 'CLOCKWISE'
    elif dot(a, b) < 0:  # 同一直線状でa,bが逆を向いている
        return 'ONLINE_BACK'
    elif a.norm() < b.norm():  # a,bが同じ方向を向いて かつ bがaよりも長い
        return 'ONLINE_FRONT'
    else:
        return 'ON_SEGMENT'


# load data
x0, y0, x1, y1 = list(map(int, input().split()))
N = int(input())
p0 = Vector([x0, y0])
p1 = Vector([x1, y1])
for _ in range(N):
    x2, y2 = list(map(int, input().split()))
    p2 = Vector([x2, y2])
    print(ccw(p0, p1, p2))



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

//4
//判断本组数据一共需要转换几次，若是奇数次，则交换
void Change1(int *p1, int *p2, int count1, int count2)
{
	int count;
	int temp;
	if (count1 >= count2)
	{
		count = count1;
	}
	else
	{
		count = count2;
	}
	if(count%2==0)
	{
		temp = *p1;
		*p1 = *p2;
		*p2 = temp;
	}
}

void SetValue(int *p1, int *p2, int iCountL, int iCountR)
{
	if ((iCountL + iCountR) % 2 == 0)
	{
		*p2 = (iCountL + iCountR) / 2;
		*p1 = (iCountL + iCountR) / 2;
	}
	else if (iCountL > iCountR)
	{
		*p2 = (iCountL + iCountR) / 2 + 1;
		*p1 = (iCountL + iCountR) / 2;
		Change1(p2, p1, iCountL, iCountR);
	}
	else
	{
		*p1 = (iCountL + iCountR) / 2 + 1;
		*p2 = (iCountL + iCountR) / 2;
		Change1(p2, p1, iCountL, iCountR);
	}
}

void Trans(int *p2, const string &str)
{
	int iCountR;//表示R的个数
	int iCountL;//表示L的个数
	static const basic_string <char>::size_type npos = -1;
	int posR = 0;//指示当前寻找的R位置
	int posL = 0;//指示当前寻找的R位置
	//第一个肯定是R，所以从R开始寻找
	do
	{
		posL = str.find('L', posR);// find L
		iCountR = posL - posR;//由于最后一个肯定是L，所以posL肯定能找到
		//if (posL==str.size()-1)
		//{
		//	iCountL = str.size() - posL;
		//	SetValue(&p2[posL - 1], &p2[posL], iCountL, iCountR);
		//	break;
		//}
		posR = str.find('R', posL);// find R
		if (posR == npos)//cannot find R,from the posL to end are all L
		{
			iCountL = str.size() - posL;
			SetValue(&p2[posL - 1], &p2[posL], iCountL, iCountR);
		}
		else//find R
		{
			iCountL = posR - posL;
			SetValue(&p2[posL - 1], &p2[posL], iCountL, iCountR);
		}
	} while (posR != npos);
}

int main(void)
{
	int i;
	string S;
	char s;

	//Input the string
	cin >> S;

	int *pNumber = new int[S.size()];

	//Intial the Array value
	for (i = 0; i < S.size(); i++)
	{
		pNumber[i] = 0;
	}
	Trans(pNumber, S);

	//Output the value
	for (i = 0; i < S.size(); i++)
	{
		cout << pNumber[i] << ' ';
	}
	delete[] pNumber;
	return 0;
}

Measured memory_bytes: 1024