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


typedef long long ll;
#define CIN_I(a) ll a;cin>>a;
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)

int main() {
    CIN_I(N);
    vector<int> p(N), q(N);
    REP(i, N) cin >> p[i], --p[i];
    REP(i, N) cin >> q[i], --q[i];
    
    map<vector<int>, int> zyunretu;
    int count = 0;

    vector<int> v(N);
    REP(i, N) v[i] = i;

    do {
        zyunretu[v] = count++;
    } while (next_permutation(v.begin(), v.end()));

    cout << abs(zyunretu[p] - zyunretu[q]) << endl;
}

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

#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define RFOR(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define LL long long
#define INF INT_MAX

const double EPS = 1e-14;
const double PI  = acos(-1.0);


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

  string s;
  cin >> s;

  int a[26] = {};
  int b[26] = {};

  REP (i, n) {
    b[s[i] - 'a']++;
  }

  int ans = 0;
  REP (i, n) {
    b[s[i] - 'a']--;
    a[s[i] - 'a']++;
    int cnt = 0;
    REP (j, 26) {
      if (b[j] > 0 && a[j] > 0) cnt++;
    }
    ans = max(ans, cnt);
  }

  cout << ans << endl;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define _abs(x)((x) < 0 ? (x) * -1 : (x))
#define _max(x, y)(max(0, max((x), (y))))
#define _min(x, y)(max(0, min((x), (y))))

int main()
{
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    //freopen("debug.txt", "w", stderr);

    cin.tie(0);
    ios::sync_with_stdio(false);

    string a, b, c;

    cin >> a >> b >> c;

    cout << (char)toupper(a[0]) << (char)toupper(b[0]) << (char)toupper(c[0]) << endl;

    return 0;
}


Measured memory_bytes: 256
n = int(input())
m = list(map(int,input().split()))
count = 0
for i in range(n-1):
  if m[i]<=m[i+1]:
    pass
  else:
    s = m[i]-m[i+1]
    m[i+1]=m[i+1]+s
    count = count + s
print(count)

Measured memory_bytes: 32380
n, k = gets.split.map(&:to_i)
s = gets.chomp

# compress
a = Array.new(n, 0)
first = true
nn = 0
for i in 0...n
    if first || s[i] == s[i-1]
        first = false
    else
        nn = nn + 1
    end
    a[nn] = a[nn] + (s[i] == "0" ? -1 : 1)
end
nn = nn + 1

#p a
# しゃくとり法
ans = 0
cur = 0
b = 0
e = 0
len = 0
while b < nn && e < nn do
#    print "#{b} #{e} - #{len} #{k} - #{cur} #{ans}\n"
    if a[e] >= 0
#       p "**1"
        # 1
        cur = cur + a[e] 
        ans = [ans, cur].max
        e = e + 1
    else
#       p "**0"
        # 0
        if len < k
            len = len + 1
        else
#           p "---"
            # 1 になるまで進める
            if a[b] >= 0
                # 1
                cur = cur - a[b]
                b = b + 1
                if b < nn
                    cur = cur + a[b]
                    b = b + 1
                end
            else
                # 0
                cur = cur + a[b]
                b = b + 1
            end
        end
        cur = cur - a[e] 
        ans = [ans, cur].max
        e = e + 1
    end
end

puts ans

Measured memory_bytes: 2812
#include <iostream>
using namespace std;
int main(){
  int x[4],y[4];
  cin>>x[0]>>y[0]>>x[1]>>y[1];
  int vx = x[1]-x[0];
  int vy = y[1]-y[0];
  x[2] = x[1]-vy;
  y[2] = y[1]+vx;
  int temp;
  temp = vx;
  vx = -vy;
  vy = temp;
  
  x[3] = x[2]-vy;
  y[3] = y[2]+vx;
  
  cout<<x[2]<<" "<<y[2]<<" "<<x[3]<<" "<<y[3]<<endl;
  return 0;
}

Measured memory_bytes: 256
//標準入力(n)
//let n:i64=read();
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
//標準入力[a(1)...a(n)]
//let a:Vec<i64>=read_vec();
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}

fn main() {
    let n:i64=read();
    let a:Vec<i64>=read_vec();
    let mut b = Vec::new();
    for i in 0..n{
        b.push(a[i as usize]-i-1);
    }
    //for i in 0..n{println!("{}", b[i as usize]);}
    b.sort();
    let t:i64=b[(n/2) as usize];
    let mut ans:i64=0;
    for i in 0..n{
        ans +=
            if b[i as usize] - t>0{b[i as usize] - t}
            else {t-b[i as usize]};
    }
    println!("{}", ans);
}


Measured memory_bytes: 9464
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
#define mem(a,v) memset((a), (v), sizeof (a))
#define enl printf("\n")
#define case(t) printf("Case #%d: ", (t))
#define ni(n) scanf("%d", &(n))
#define nl(n) scanf("%lld", &(n))
#define nai(a, n) for (int i = 0; i < (n); i++) ni(a[i])
#define nal(a, n) for (int i = 0; i < (n); i++) nl(a[i])
#define pri(n) printf("%d\n", (n))
#define prl(n) printf("%lld\n", (n))
#define pii pair<int, int>
#define pil pair<int, long long>
#define pll pair<long long, long long>
#define vii vector<pii>
#define vil vector<pil>
#define vll vector<pll>
#define vi vector<int>
#define vl vector<long long>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef cc_hash_table<int,int,hash<int>> ht;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> oset;
const double pi = acos(-1);
const int MOD = 1e9 + 7;
const int INF = 1e9 + 7;
const int MAXN = 1e6 + 5;
const double eps = 1e-9;
ll x[3], y[3];

int main() {
	ll s; nl(s);
	//ab=s+cd
	x[0] = y[0] = 0;
	x[1] = (int)sqrt(s);
	for (int i = 0; x[1]+i <= min(s, x[1]+10ll) && x[1] + i <= 1000000000ll; i++) {
		y[2] = (s+x[1]+i-1) / (x[1]+i);
		if (y[2] > 1000000000ll)
			continue;
		ll dif = (x[1]+i) * y[2] - s;
		y[1] = x[2] = 0;
		int fl = dif == 0;
		for (ll j = 1; j * j <= dif; j++) {
			if (dif % j != 0)
				continue;
			if (dif / j > 1000000000)
				continue;
			y[1] = j;
			x[2] = dif / j;
			fl = 1;
			break;
		}
		if (fl) {
			x[1] += i;
			break;
		}
	}
	for (int i = 0; i < 3; i++)
		printf("%lld %lld ", x[i], y[i]);
	enl;
	return 0;
}


Measured memory_bytes: 256
from collections import Counter
n=int(input())
a=list(map(int,input().split()))
ans=0
accum = [0]*(n+1)
accum[0]=0
for i in range(n):
    accum[i+1]=a[i]+accum[i]

z=Counter(accum)
for k,v in z.items():
    ans+=v*(v-1)/2
    
print(int(ans))


Measured memory_bytes: 41672
//
//  main.cpp
//  CoderTest
//
//  Created by yuya on 2019/05/20.
//  Copyright © 2019 yuya. All rights reserved.
//

#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair <int,int> P;


ll findgcd(ll,ll);
ll findlcm(ll,ll);


int main(){
    
    ll A,B,C,D;
    cin >> A >> B >> C >> D;
    
    ll E, cnt;
    
    E = findlcm(C, D);
    cnt = (B-A+1) - ( (B/C - (A-1)/C) + (B/D - (A-1)/D) - (B/E - (A-1)/E) ) ;
    
    cout << cnt << endl;
    
    return 0;
}



ll findlcm(ll a,ll b){
    
    ll g = findgcd(a,b);
    
    ll l = a*b/g;
    
    return l;
}


ll findgcd(ll a,ll b){
    ll tmp,r;
    if(a<b){
        tmp = a;
        a = b;
        b = tmp;
    }
    
    if(b==0) return a;
    // 0とのgdcはその数そのものと定義
    
    /* ユークリッドの互除法 */
    r = a % b;
    while(r!=0){
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}


Measured memory_bytes: 256
n,m=map(int,raw_input().split())
a=map(int,raw_input().split())
b=[0]
for v in a:b.append((b[-1]+v)%m)
ret = 0
z = {}
for c in b:
 if c not in z:z[c]=1
 else:
  ret+=z[c]
  z[c]+=1
print ret

Measured memory_bytes: 13084
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(unused_macros)]
#![allow(unused_imports)]

use std::str::FromStr;
use std::io::*;
use std::collections::*;
use std::cmp::*;

struct Scanner<I: Iterator<Item = char>> {
    iter: std::iter::Peekable<I>,
}

macro_rules! exit {
    () => {{
        exit!(0)
    }};
    ($code:expr) => {{
        if cfg!(local) {
            writeln!(std::io::stderr(), "===== Terminated =====")
                .expect("failed printing to stderr");
        }
        std::process::exit($code);
    }}
}

impl<I: Iterator<Item = char>> Scanner<I> {
    pub fn new(iter: I) -> Scanner<I> {
        Scanner {
            iter: iter.peekable(),
        }
    }

    pub fn safe_get_token(&mut self) -> Option<String> {
        let token = self.iter
            .by_ref()
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        if token.is_empty() {
            None
        } else {
            Some(token)
        }
    }

    pub fn token(&mut self) -> String {
        self.safe_get_token().unwrap_or_else(|| exit!())
    }

    pub fn get<T: FromStr>(&mut self) -> T {
        self.token().parse::<T>().unwrap_or_else(|_| exit!())
    }

    pub fn vec<T: FromStr>(&mut self, len: usize) -> Vec<T> {
        (0..len).map(|_| self.get()).collect()
    }

    pub fn mat<T: FromStr>(&mut self, row: usize, col: usize) -> Vec<Vec<T>> {
        (0..row).map(|_| self.vec(col)).collect()
    }

    pub fn char(&mut self) -> char {
        self.iter.next().unwrap_or_else(|| exit!())
    }

    pub fn chars(&mut self) -> Vec<char> {
        self.get::<String>().chars().collect()
    }

    pub fn line(&mut self) -> String {
        if self.peek().is_some() {
            self.iter
                .by_ref()
                .take_while(|&c| !(c == '\n' || c == '\r'))
                .collect::<String>()
        } else {
            exit!();
        }
    }

    pub fn peek(&mut self) -> Option<&char> {
        self.iter.peek()
    }
}

trait Joinable {
    fn join(self, sep: &str) -> String;
}

impl<U: ToString, T: Iterator<Item = U>> Joinable for T {
    fn join(self, sep: &str) -> String {
        self.map(|x| x.to_string()).collect::<Vec<_>>().join(sep)
    }
}
fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin.bytes().map(|c| c.unwrap() as char));
    let N: usize = sc.get();
    let S: Vec<char> = sc.chars();
    if N % 2 != 0 {
        println!("No");
        return;
    }
    for i in 0..N/2 {
        if S[i] != S[N/2 + i] {
            println!("No");
            return;
        }
    }
    println!("Yes");
}


Measured memory_bytes: 4352
s=input()
for _ in range(int(input())):
    a=input().split()
    i,j=map(int, a[1:3])
    if a[0] == "print":
        print(s[i:j+1])
    elif a[0] == "reverse":
        t1=s[0:i]
        t2=list(s[i:j+1])
        t2.reverse()
        t3=s[j+1:]
        s=t1+"".join(t2)+t3
    else:
        s=s[0:i]+a[3]+s[j+1:]

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

using namespace std;

int main() {
    long long K, A, B;
    cin >> K >> A >> B;

    if (B - A <= 2) {
        cout << K + 1 << endl;
    } else {
        long long t = max(0LL, (K - (A - 1)) / 2);
        cout << A + (B - A) * t + (K - (A - 1)) % 2 << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ALL(v) v.begin(),v.end()
#define UN(v) sort(ALL(v)),v.erase(unique(ALL(v)))
#define FILL(x,y) memset(x,y,sizeof(x))
#define EACH(v,it) for(__typeof(v.begin()) it=v.begin();it!=v.end();it++)
#define FIO ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
typedef unsigned int uint;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pii> vii;
int n,m;
vi E[100005];
int ans=INT_MIN;
int dis[100005];
/*---main code---*/
 
int DFS(int x)
{
	if(dis[x]!=-1)
	{
		return dis[x];
	}
	dis[x]=0;
	EACH(E[x],it)
	{
		int to=*it;
		dis[x]=max(dis[x],DFS(to)+1);
	}
	return dis[x];
}
 
int main()
{
	FIO;
	cin>>n>>m;
	FILL(dis,-1);
	for(int i=0;i<m;i++)
	{
		int x,y;
		cin>>x>>y;
		E[x].push_back(y);
	}
	for(int i=1;i<=n;i++)
	{
		ans=max(ans,DFS(i));
	}
	cout<<ans<<'\n';
	return 0;
}
 

Measured memory_bytes: 7552
#include"bits/stdc++.h"
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

using ll = long long;
using vll = vector<ll>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using P = pair<int, int>;

void Main(){
    string s; cin >> s;
    ll cnt = 0;
    ll sum = 0;
    rep(i, s.size()){
        if(s[i] == 'W') {
            cnt++;
            sum += i;
        }
    }
    ll ans = sum - cnt * (cnt-1) / 2;
    cout << ans << endl;
    return;
}

int main(){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}

Measured memory_bytes: 3744
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	ll n,ans=0;
	cin>>n;
	if(n%2!=0){
		cout << 0;
	}
	else{
		for(ll i=5;i<=n;i*=5){
			ans+=(n/i)/2;
		}
			cout <<ans;
	}
	// your code goes here
	return 0;
}

Measured memory_bytes: 256
#include<iostream> 
#include<vector> 
#include<string> 
#include<algorithm> 
using namespace std; 
int main()
{
	int n;
	cin >> n;
	int ans = 0;
	for (int i = 0; i < n; i++)
	{
		int a, b;
		cin >> a >> b;
		ans += (b - a) + 1;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
const int INF=1<<30;
int a[2000005],n;

void maxheap(int i)
{
    int l=i*2;
    int r=i*2+1;
    int p=i/2;
    int m=-1;
    if(l<=n&&a[l]>a[i])m=l;
    else m=i;
    if(r<=n&&a[r]>a[m])m=r;
    if(m!=i)
    {
        swap(a[m],a[i]);
        maxheap(m);
    }
}

void heapinsertKey(int i,int key)
{
    if(key<a[i])return;
    a[i]=key;
    while(i>1&&a[i/2]<a[i])
    {
        swap(a[i],a[i/2]);
        i=i/2;
    }
}

int main()
{

    string s;
    while(cin>>s)
    {
        if(s=="end")break;
        if(s=="insert")
        {
            int x;
            n++;
            cin>>x;a[n]=-INF;
            heapinsertKey(n,x);
        }
        else
        {
            if(n<1)cout<<"error"<<endl;
            int max=a[1];
            cout<<max<<endl;
            a[1]=a[n--];
            maxheap(1);
        }
    }
    //for(int i=1;i<=n;i++)cout<<' '<<a[i];
    //cout<<endl;
    return 0;
}



Measured memory_bytes: 7044
class Union():
    def __init__(self, N):
        self.Parent = []
        for i in range(N):
            self.Parent.append(-1)

    def root(self, A):
        if(self.Parent[A] < 0):
            return A
        else:
            self.Parent[A] = self.root(self.Parent[A])
            return self.Parent[A]

    def size(self, A):
        return int(-1 * self.Parent[self.root(A)])

    def connect(self, A, B):
        A = self.root(A)
        B = self.root(B)
        if (A == B):
            return False

        if(self.size(A) < self.size(B)):
            A, B = B, A
        self.Parent[A] += self.Parent[B]
        self.Parent[B] = A
        return True


N, M = map(int, input().split())
A = [-1 for _ in range(M)]
B = [-1 for _ in range(M)]

for i in range(M):
    a, b = map(int, input().split())
    A[i], B[i] = a - 1, b - 1

ans = [0 for _ in range(M)]
ans[M-1] = N * (N-1) / 2

uni = Union(N)
for i in range(M-1, 0, -1):
    ans[i - 1] = ans[i]
    if(uni.root(A[i]) != uni.root(B[i])):
        ans[i - 1] -= uni.size(A[i]) * uni.size(B[i])
        uni.connect(A[i], B[i]);

for i in range(M):
    print(int(ans[i]))


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

int main() {
  int N, M, X;
  cin >> N >> M >> X;
  int A[100];
  int last=M;
  for(int i=0; i<M; i++){
    cin >> A[i];
    if(X<A[i]){
      last=i;
      break;
    }
  }
  cout << min(last, M-last) << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
unsigned int C(unsigned int n,unsigned int r);
int main()
{
    int m,n;
    scanf("%d %d",&m,&n);
    printf("%d",C(m,2)+C(n,2));
    return 0;
}
unsigned int C(unsigned int n,unsigned int r)
{
    unsigned int i,ans[100];
    if(r==0)return 1;
    if(r==1)return n;
	ans[0]=1,ans[1]=n;
	for(i=2;i<=r;i++)
	{
	    ans[i]=ans[i-1]*(n-i+1)/i;
	}
	return ans[r];
}


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

#define dbg(x) cerr<<#x": "<<x<<"\n"
#define dbg_p(x) cerr<<#x": "<<x.first<<","<<x.second<<"\n"
#define dbg_v(x, n) do{cerr<<#x"[]: ";for(int _=0;_<n;++_)cerr<<x[_]<<" ";cerr<<'\n';}while(0)
#define dbg_ok cerr<<"OK!\n"

#define st first
#define nd second

#define DMAX 
#define NMAX 
#define MMAX 

using namespace std;

int n, k, ans1, ans2, ans3, a, b, c, x, y;

template<class T>
ostream& operator<<(ostream& out, vector<T> v) {
	out << v.size() << '\n';
	for(auto e : v) out << e << ' ';
	return out;
}

int main() {
	ios_base::sync_with_stdio(false);
	cin >> a >> b >> c >> x >> y;	

	ans1 = x * a + y * b;
	int m1 = min(x, y);
	ans2 = 2 * m1 * c + (x - m1) * a + (y - m1) * b;

	ans3 = 2 * m1 * c + (x - m1) * c * 2 + (y - m1) * c * 2;
	cout << min({ans1, ans2, ans3});
}

Measured memory_bytes: 256
import sys
# sys.setrecursionlimit(100000)


def input():
    return sys.stdin.readline().strip()


def input_int():
    return int(input())


def input_int_list():
    return [int(i) for i in input().split()]


def main():
    import math
    a, b = input().split()
    x = int(a + b)
    sq = int(math.sqrt(x))
    if sq**2 == float(x):
        print("Yes")
    else:
        print("No")

    return


if __name__ == "__main__":
    main()


Measured memory_bytes: 62132
#include <vector>
#include <iostream>
#include <algorithm>
#pragma warning(disable : 4996)
using namespace std;
const int inf = 1012345678;
int n, x[200009], y[200009], c[200009]; pair<int, int> w[400009];
int main() {
	scanf("%d", &n);
	int pl1 = inf, pr1 = -inf, ql1 = inf, qr1 = -inf;
	for (int i = 0; i < n; i++) {
		scanf("%d %d", &x[i], &y[i]);
		if (x[i] > y[i]) swap(x[i], y[i]);
		pl1 = min(pl1, x[i]);
		pr1 = max(pr1, x[i]);
		ql1 = min(ql1, y[i]);
		qr1 = max(qr1, y[i]);
		w[i] = make_pair(x[i], i);
		w[n + i] = make_pair(y[i], i);
	}
	sort(w, w + 2 * n);
	fill(c, c + n, 2);
	int two = n, r = 0;
	long long ret = 1LL * (pr1 - pl1) * (qr1 - ql1);
	for (int i = 0; i <= 2 * n; i++) {
		while (r < 2 * n && two >= 1) {
			if (c[w[r].second]-- == 2) two--;
			r++;
		}
		if (two == 0) ret = min(ret, 1LL * (w[2 * n - 1].first - w[0].first) * (w[r - 1].first - w[i].first));
		if (i != 2 * n) {
			c[w[i].second]++;
			if (c[w[i].second] == 2) two++;
		}
	}
	printf("%lld\n", ret);
	return 0;
}

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

int gcd(int a,int b){
  int x,r;
  x=a*b;
  if(a<b) swap(a,b);
  r=a%b;
  while(r){
    a=b;
    b=r;
    r=a%b;
  }
  return b;
}

int main(){
  ll N,X,g;
  cin>>N>>X;
  ll x[N],d[N];
  for(int i=0;i<N;i++) cin>>x[i];
  for(int i=0;i<N;i++) d[i]=abs(X-x[i]);
  g=d[0];
  for(int i=0;i<N;i++) g=gcd(g,d[i]);
  cout<<g<<endl;
}


Measured memory_bytes: 1792
#include <iostream>

using namespace std;

int64_t hp[100'000];

int main()
{
    int N;
    int64_t A, B;

    cin >> N >> A >> B;
    A -= B;
    for (int i = 0; i < N; i++)
    {
        cin >> hp[i];
    }

    int64_t lower = 0;
    int64_t upper = 1'000'000'000;
    while (lower + 1 < upper)
    {
        int64_t mid = (lower + upper) / 2;

        int64_t req = 0;
        for (int i = 0; i < N; i++)
        {
            int64_t rem = hp[i] - B * mid;
            if (rem <= 0)
            {
                continue;
            }

            req += (rem + A - 1) / A;
        }
        bool sufficient = req <= mid;

        if (!sufficient)
        {
            lower = mid;
        }
        else
        {
            upper = mid;
        }
    }

    cout << upper << endl;

    return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;

#define MAX_V 100001
#define INF (1e9 + 1)



int V,E,r,a,b,c;
vector<int> Gto[MAX_V];
vector<int> Gcost[MAX_V];

int d[MAX_V];
void dijkstra(){
  int i;
  for(i=0;i<MAX_V;i++)d[i]=INF;
  d[r]=0;
  priority_queue< pair<int,int> > Q;
  Q.push( make_pair(0,r) );
  while(!Q.empty()){
    pair<int,int> p=Q.top();
    Q.pop();
    int pos=p.second,cost=-p.first;
    if( cost > d[pos] )continue;
    for(i=0;i<Gto[pos].size();i++){
      int to=Gto[pos][i];
      int newcost=cost+Gcost[pos][i];
      if( newcost < d[to]){
        d[to]=newcost;
        Q.push( make_pair(-d[to],to) );
      }
    }
  }

  for(i=0;i<V;i++){
    if(d[i]==INF)printf("INF\n");
    else printf("%d\n",d[i]);
  }
}

int main(){
  int i;
  scanf("%d %d %d",&V,&E,&r);
  for(i=0;i<E;i++){
    scanf("%d %d %d",&a,&b,&c);
    Gto[a].push_back(b);
    Gcost[a].push_back(c);
  }
  dijkstra();
  return 0;
}

Measured memory_bytes: 15192
# B - Problem Set

n  = int(input())
d = list(map(int, input().split()))
m = int(input())
t = list(map(int, input().split()))

import collections
dd = collections.Counter(d)
tt = collections.Counter(t)
f = True
for i in tt.keys():
    if dd[i] < tt[i]:
        f = False
        break
if f:
    print("YES")
else:
    print("NO")

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

using namespace std;

#define int long long
#define all(v) (v).begin(), (v).end()
#define resz(v, ...) (v).clear(), (v).resize(__VA_ARGS__)
#define reps(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

using Pi = pair<int, int>;
using Tapris = tuple<int, int, int>;
using vint = vector<int>;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  string s;
  cin >> s;
  if(s.size() == 26) {
    bool used[26] = {};
    rep(i, s.size()) used[s[i]-'a'] = true;
    int idx = 25;
    while(idx >= 0) {
      reps(i, s[idx]+1, 'z'+1) {
	if(!used[i-'a']) {
	  cout << s.substr(0, idx) << (char)i << endl;
	  return 0;
	}
      }
      used[s[idx]-'a'] = false;
      --idx;
    }
    cout << -1 << endl;
  } else {
    bool used[26] = {};
    rep(i, s.size()) used[s[i]-'a'] = true;
    rep(i, 26) {
      if(!used[i]) {
	cout << s << (char)(i+'a') << endl;
	return 0;
      }
    }
  }

  return 0;
}


Measured memory_bytes: 256
/* 
	Author: ankrypt
*/


#include <bits/stdc++.h>

using namespace std;

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int

ll A, B;
std::vector<ll> adj[100];
ll hashCnt[10];

int main() {
	for(int i = 0; i < 3; i++) {
		scanf("%lld %lld", &A, &B);
		adj[A].push_back(B);
		adj[B].push_back(A);
		hashCnt[A]++;
		hashCnt[B]++;
	}
	ll cntEve = 0;
	ll cntOdd = 0;
	for(int i = 1; i <= 4; i++) {
		// cout << hashCnt[i] << " ";
		if(hashCnt[i] == 2) {
			cntEve++;
		}
		else if(hashCnt[i] == 1) {
			cntOdd++;
		}
	}
	if(cntEve == 2 && cntOdd == 2) {
		cout << "YES\n";
	} 
	else {
		cout << "NO\n";
	}
	
	return 0;
}
/*
	Powered by Buggy Plugin
*/


Measured memory_bytes: 256
from collections import Counter
n = int(input())
c = list(input())
for i in range(n)[-1::-1]:
    if c[i] == "W":
        del c[i]
    else:
        break
c.reverse()
for i in range(len(c))[-1::-1]:
    if c[i] == "R":
        del c[i]
    else:
        break

d = Counter(c)
r = d["R"]
w = d["W"]
rc, wc = 0, 0
if w > r:
    c.reverse()
    for i in range(r):
        if c[i] == "R":
            rc += 1
    print(r - rc)
else:
    for i in range(w):
        if c[i] == "W":
            wc += 1
    print(w - wc)

Measured memory_bytes: 83548
import java.util.*;

public class Main {

    public static StringBuilder output = new StringBuilder();

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int k = in.nextInt();
        int arr[] = new int[10];
        Arrays.fill(arr, 1);
        for (int i = 0; i < k; i++) {
            int c = in.nextInt();
            arr[c]--;
        }
        Solver solver = new Solver();
        solver.solve(arr, n);
        System.out.println(output);
    }

}

class Solver {
    public void solve(int arr[], int n) {
        while (helper(n, arr)) {
            n++;
        }

        Main.output.append(n);
    }

    public boolean helper(int n, int arr[]) {
        while (n > 0) {
            if (arr[n % 10] == 0) {
                return true;
            }
            n /= 10;
        }
        return false;
    }
}

Measured memory_bytes: 35644
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <numeric>
#include <regex>
#include <tuple>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
#define modulo 1000000007 // 10^9 + 7
#define INF 1000000000 // 10^9
#define LLINF 1LL<<60

int H, W;
bool maze[8][8];

void input() {
	cin >> H >> W;
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			char tmp; cin >> tmp;
			if (tmp == '#') maze[i][j] = true;
		}
	}
}

void dfs(int row, int col) {
	maze[row][col] = false;
	if (row + 1 < H && maze[row + 1][col]) dfs(row + 1, col);
	else if (col + 1 < W && maze[row][col + 1]) dfs(row, col + 1);
}


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

	input();
	dfs(0, 0);
	bool flag = true;
	for (int i = 0; i < H && flag; i++) {
		for (int j = 0; j < W && flag; j++) {
			if (maze[i][j]) flag = false;
		}
	}

	if(flag) cout << "Possible" << endl;
	else cout << "Impossible" << endl;

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int a,b,c,M=100005,mi,mj,i,j,d[100010],r=0,max;
  char p[100010]={1,1};
  for(i=2;i*i<M;i++){
    if(p[i])continue;
    for(j=i*i;j<M;j+=i)p[j]=1;
  }
  for(i=r=0;i<M;i++){
    if(p[i]==0)d[r++]=i;
  }
  while(scanf("%d %d %d",&a,&b,&c),a){
    for(i=max=0;d[i]<=a;i++){
      for(j=0;j<=i&&d[i]*d[j]<=a;j++){
	if(b*d[i]>c*d[j])continue;
	if(max<d[i]*d[j])max=d[mi=i]*d[mj=j];
      }
    }
    printf("%d %d\n",d[mj],d[mi]);
  }
  return 0;
}

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


int main() {

string S,T,U;
int A,B;
cin >> S >> T;
cin >> A >> B;
cin >> U;

if (U == S) {
    A--;
} else if (U == T) {
    B--;
}

cout << A << " "<< B << endl;

return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using P = pair<int, int>;

int main() {

    long int h,w;
    cin >> h >> w;
    long int output = (h * w + 1) / 2;

    if(h == 1 || w == 1){
        cout << '1' << endl;
    }else{
        cout << output << endl;
    }
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdio>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <string.h>
#include <queue>
#include <vector>
using namespace std;
typedef long long LL;
const int N = 200007;
const int M = 15005;
const int offset = 7500;
const int INF = 0x3f3f3f3f;
const int MOD = 1000000007;
const double eps = 1e-20;
int n,m;
int vis[N];
int main()
{
    while (~scanf("%d%d",&n,&m))
    {
        memset(vis,0,sizeof vis);
        int f=0;
        for (int i=0;i<m;i++)
        {
            int a,b;
            scanf("%d%d",&a,&b);
            if (a>b)
                swap(a,b);
            if (a==1)
            {
                if (vis[b])
                    f=1;
                vis[b]=1;
            }
            else if (b==n)
            {
                if (vis[a])
                    f=1;
                vis[a]=1;
            }
        }
        if (f)
            printf("POSSIBLE\n");
        else
            printf("IMPOSSIBLE\n");
    }
    return 0;
}

/*


*/

Measured memory_bytes: 1024
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int k = sc.nextInt();
    int a = sc.nextInt();
    int b = sc.nextInt();
    for(int i = 1;i<1001;i++){
      int tmp = k * i;
      if(a <= tmp && tmp <= b){
        System.out.println("OK");
        return;
      }
    }
    System.out.println("NG");
  }
}


Measured memory_bytes: 35772
#include <algorithm>
#include <cstdio>

using namespace std;

int main() {
  int l[11], v1, v2;
  while (scanf("%d", l+1) == 1) {
    l[0] = 0;
    for (int i = 2; i < 11; i++) {
      scanf(",%d", l+i);
      l[i] += l[i-1];
    }
    scanf(",%d,%d\n", &v1, &v2);
    printf("%d\n", lower_bound(l, l+11, double(l[10]*v1)/double(v1+v2))-l);
  }
  return 0;
}

Measured memory_bytes: 0
import sys
from collections import deque
input = sys.stdin.readline
H, W = map(int, input().split())
sx, sy = map(int, input().split())
gx, gy = map(int, input().split())
sx -= 1
sy -= 1
gx -= 1
gy -= 1

C = [list(input()) for i in range(H)]
inf = float("inf")
for i in range(H):
    for j in range(W):
        if C[i][j] == ".":
            C[i][j] = 0
        else:
            C[i][j] = 1
d0 = [[1, 0], [0, 1], [-1, 0], [0, -1]]
d1 = [[-2, -2], [-2, -1], [-2, 0], [-2, 2], [-1, 2], [0, 2], [-2, 1], [-1, -2], [-1, -1], [-1, 1], [0, -2], [1, -2], [1, -1], [1, 1], [1, 2], [2, -2], [2, -1], [2, 0], [2, 1], [2, 2]]
# d1 = [[i, j] for i in range(-2, 3) for j in range(-2, 2)]
dist = [[inf] * W for i in range(H)]
dist[sx][sy] = 0
que = deque([[0, sx, sy]])
while que:
    L, x, y = que.popleft()
    # if x == gx and y == gy:
    #     break
    for dx, dy in d0:
        nx, ny = x + dx, y + dy
        if 0 <= nx < H and 0 <= ny < W and L + C[nx][ny] < dist[nx][ny] and C[nx][ny] == 0:
            dist[nx][ny] = L + C[nx][ny]
            que.appendleft([L, nx, ny])
    for dx, dy in d1:
        nx, ny = x + dx, y + dy
        if 0 <= nx < H and 0 <= ny < W and L + C[nx][ny] + 1 < dist[nx][ny] and C[nx][ny] == 0:
            dist[nx][ny] = L + C[nx][ny] + 1
            que.append([L + 1, nx, ny])
            # que.appendleft([L + 1, nx, ny])

            # if C[nx][ny] == 1:
            #     que.append([L + 1, nx, ny])
            # else:
            #     que.appendleft([L, nx, ny])
# for h in range(H):
#     print(dist[h])

ans = dist[gx][gy]
if ans == inf:
    print(-1)
else:
    print(ans)


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

using namespace std;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<typename Q_temp>
using smaller_queue = priority_queue <Q_temp, vector<Q_temp>, greater<Q_temp> >;

const int INF = (int) 1e9;
const ll LINF = (ll) 4e18;
const ll MOD = (ll) (1e9 + 7);
const double PI = acos(-1.0);
const int limit = 100010;

#define REP(i,m,n) for(ll i = m; i < (ll)(n); ++i)
#define rep(i,n) REP(i, 0, n)
#define MP make_pair
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define NP(v) next_permutation(v.begin(),v.end())
#define debug(x) cout << #x << ":" << x << endl;
#define debug2(x) for(auto a : x) cout << a << " "; cout << endl;

vector<pii> around = {MP(1, 0), MP(-1, 0), MP(0, 1), MP(0, -1)};

//------------------------------------------------------

ll mod(ll a, ll b) { //a mod b
    if (a >= 0) return a % b;
    else return (b - (-a) % b) % b;
}

ll pow2(ll n) { //(-2)^n
    ll res = 1;
    rep(i, n) res *= -2;
    return res;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    if (n == 0) {
        cout << 0 << endl;
        return 0;
    }
    ll sum = 0;
    stack<ll> st;

    rep(i, 40) { //(-2)^i の位
        ll div = 1LL << (i + 1);
        ll digit = (bool)(mod(mod(n, div) - mod(sum, div), div));
        sum += digit * pow2(i);
        st.push(digit);
    }

    while (st.top() == 0) st.pop();
    while (!st.empty()) {
        cout << st.top();
        st.pop();
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
/**
 * @copyright (c) 2020 Daisuke Hashimoto
 */

#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using Pair = pair<int64_t, int64_t>;

constexpr int64_t kBigNumber = 1e18;
constexpr int64_t kPrime = 1000000007LL;
// std::cout << std::setprecision(20) << 1.1 << endl;

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

  int64_t N;
  cin >> N;
  // const int64_t L = static_cast<int64_t>(T.length());
  vector<int64_t> A(N);
  vector<int64_t> B(N);
  for (int64_t i = 0; i < N; ++i) {
    cin >> A[i] >> B[i];
  }
  sort(A.begin(), A.end());
  sort(B.begin(), B.end());
  if (N % 2 == 1) {
    int64_t median_index = (N + 1) / 2 - 1;
    cout << (B[median_index] - A[median_index] + 1) << endl;
  } else {
    int64_t median_index_0 = N / 2 - 1;
    int64_t median_index_1 = N / 2;
    cout << (B[median_index_0] + B[median_index_1] - A[median_index_0] - A[median_index_1] + 1) << endl;
  }
  return 0;
}


Measured memory_bytes: 6364
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize("-Ofast")
#include <bits/stdc++.h>
using namespace std;

typedef int in;
#define int long long
#define f first
#define s second
#define pb push_back
#define pp push
#define RETURN exit(0)
#define pow(x,y) (int)(pow(x,y))
#define ceil(x) (int)(ceil(x))
#ifndef ONLINE_JUDGE
#define debug(x) cout<<x<<endl;
#else
#define debug(x) 42
#endif
const int MAX=1e4;
const int MOD=1e9+7;
const int MAAX=1e15;
const long double EPS=1e-6;
const int N=1e6;
int power(int x,int y)
{
    if (y == 0)
        return 1;
    int a=power(x,y/2);
    if (y % 2 == 0)
        return a * a % MOD;
    else
        return x * a * a % MOD;
}
long double sq(int x){
    long double s=0,e=x,mid;
    while(e-s>=EPS){
        mid=(s+e)/2;
        if(mid*mid<=x){
            s=mid;
        }
        else{
            e=mid-EPS;
        }
    }
    return s;
}
bool check(int x){

}
int binary(int x,int y){
    int s=x,e=y,mid;
    while(s<e){
        mid=ceil((s+e)/2.0);
        if(check(mid))
            s=mid;
        else
            e=mid-1;
    }
    return s;
}
vector<int> primes;
bool visted[N+5];
void sieve(){
    visted[0]=visted[1]=1;
    for(int i=2;i*i<=N;i++){
        if(visted[i]==0){
            primes.pb(i);
            for(int j=i*i;j<=N;j+=i){
                visted[j]=1;
            }
        }
    }
    for(int i=sqrt(N)+1;i<=N;i++){
        if(visted[i]==0)
            primes.pb(i);
    }
    return;
}

string n;
int dp[2][6][10][10];
int fun(int fn,int ln,int idx=0,bool bol=0){
    if(idx==n.size()){
        return 1;
    }
    if(idx==n.size()-1){
        return (bol||fn<=n[idx]-'0'?1:0);
    }
    int &ret=dp[bol][idx][fn][ln];
    if(ret+1){
        return ret;
    }
    ret=0;
    if(idx==0){
        for(int i=1;i<=n.size();i++){
            if(i==1){
                ret+=(fn==ln);
            }
            else if(i<n.size()){
                ret+=fun(fn,ln,n.size()-i+1,1);
            }
            else{
                if(ln<=n[0]-'0')
                    ret+=fun(fn,ln,1,(ln==n[0]-'0'?0:1));
            }
        }
    }
    else{
        if(bol){
            for(int i=0;i<10;i++){
                ret+=fun(fn,ln,idx+1,1);
            }
        }
        else{
            for(int i=0;i<=n[idx]-'0';i++){
                ret+=fun(fn,ln,idx+1,(i==n[idx]-'0'?0:1));
            }
        }
    }
    return ret;
}
int cal(int x){
    int l=0;
    while(x){
        l=x%10;
        x/=10;
    }
    return l;
}
int si(){
    int ans=0;
    for(int i=0;i<n.size();i++){
        ans*=10;
        ans+=n[i]-'0';
    }
    return ans;
}

in main()
{
    //freopen("in.in","r",stdin);
    //freopen("out.out","w",stdout);
    int tc=1;
    //sieve();
    //scanf("%lld",&tc);
    while(tc--)
    {
        cin>>n;
        if(n.size()<2){
            cout<<n<<endl;
            break;
        }
        int x=si();
        memset(dp,-1,sizeof dp);
        int ans=0;
        for(int i=1;i<=x;i++){
            if(i%10==0)
                continue;
            ans+=fun(cal(i),i%10);
        }
        cout<<ans<<endl;
    }
    RETURN;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#if ONLINE_JUDGE
#define DEBUG false
#else
#define DEBUG true
#endif
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, k, n) for (int i = (int)(k); i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n)-1; i >= 0; i--)
#define rREP(i, k, n) for (int i = (int)(n)-1; i >= k; i--)
#define foreach(i, vec) for(auto &&i : vec)
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort(all(x))
#define REV(x) reverse(all(x))
#define MAX(x) *max_element(all(x))
#define MIN(x) *min_element(all(x))
#define LOWitr(x, n) lower_bound(all(x), n)
#define UPRitr(x, n) upper_bound(all(x), n)
#define cii(x) int x;cin >> x
#define cill(x) LL x;cin >> x
#define cis(x) string x;cin >> x
#define co(x) cout << x << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define truecheck assert
#define dump(x) cerr << #x << ": " << (x) << endl
using namespace std;
typedef long long LL;
typedef long long int64;
typedef std::vector<int> VI;
typedef std::vector<VI> VVI;
typedef std::vector<LL> VL;
typedef std::vector<VL> VVL;
typedef std::vector<string> VS;
typedef std::pair<int, int> PII;
typedef std::pair<int64, int64> PLL;
typedef std::queue<int> QI;
typedef std::priority_queue<int> PQI;
template<class T,class U>inline bool chmax(T &a, const U &b){if (a<b){a=b;return true;}return false;}
template<class T,class U>inline bool chmin(T &a, const U &b){if (b<a){a=b;return true;}return false;}
template<class T,class U>inline void vcin(T &v, U n){rep(i, n){typename T::value_type a;cin >> a;v.pb(a);}}

const int INF = 1e9, MOD = 1e9 + 7;
const LL LLINF = 1e16;
// M_PI 3.1415...

int main() {
    fastcin();
    cout << fixed << setprecision(10);
    cis(s);
    cill(q);
    LL mode = 0;
    string left="", right="";
    rep(i, q){
        cill(t);
        if (t==1){
            mode++;
            continue;
        }
        cill(f);
        cis(c);
        if ((mode + f) % 2 == 0){
            right += c;
        }else{
            left += c;
        }
    }
    reverse(all(left));
    s = left + s + right;
    if (mode % 2 == 1){
        reverse(all(s));
    }
    string ans = s;
    co(ans);
    return 0;
}

Measured memory_bytes: 1456
def main():
    x, n = (int(x) for x in input().split())
    p = [int(x) for x in input().split()]

    if x not in p:
        print(x)
    else:
        for i in range(1, 200):
            if x - i not in p:
                print(x - i)
                break
            if x + i not in p:
                print(x + i)
                break

if __name__ == '__main__':
    main()

Measured memory_bytes: 9148
#include<stdio.h>
int main()
{
    unsigned long long  a,b,n,k,N,i;
    scanf("%llu%llu",&n,&k);
    N=1;
    for(i=0;i<n;i++){
        a=N*2;
        b=N+k;
               if(a>=b)N=b;
         else if(b>a)N=a;
    }
    printf("%llu",N);
                return 0;
}




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

int main() {
  int n, m;
  cin >> n >> m;
  int work_days = 0;
  for ( int i = 0; i < m; i++ ) {
    int a;
    cin >> a;
    work_days += a;
  }
  int ans = n - work_days;
  ans = ( ans < 0 ) ? -1 : ans;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3624
a, b = gets.chomp.split.map(&:to_i)

# 遅延評価でtake_whileを取り、偽になった境界は取るので+1する
puts b > 1 ? (1..Float::INFINITY).lazy.take_while{ |i| a * i - (i - 1) < b }.force.size + 1 : 0

Measured memory_bytes: 1916
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define ms(s,x) memset(s,x,sizeof(s))
#define ls rt<<1
#define rs rt<<1|1
#define pb push_back
#define inf 0x3f3f3f3f
typedef long long ll;
using namespace std;

const double PI = acos(-1.0);
const double eps = 1e-8;
const int MAXN = 1e5+5;
const ll MOD = 1e9+7;

bool judge(char* s, int len){
    rep(i, 0, len/2-1){
        if (s[i] != s[len-i-1]) return 0;
    }
    return 1;
}

int main()
{
    char str[105];
    scanf("%s", str);
    int len = strlen(str);
    if (len&1 && judge(str, len) && judge(str, len/2))
        printf("Yes\n");
    else printf("No\n");

    return 0;
}


Measured memory_bytes: 256
n=int(input())
a=[int(i) for i in input().split()]

a_bin=[]

for i in a:
    a_bin.append(format(i, '#062b')[2:])



def get_keta_num(keta,a_list):
    zero=0
    one=0
    for i in a_list:
        if i[-keta]=="0":
            zero+=1
        else:
            one+=1
    return zero*one

ans=0
for i in range(1,61):
    ans+=(2**(i-1))*get_keta_num(i,a_bin)
    ans=ans%(10**9+7)

print(ans)

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


using namespace std;
 
using tpl = tuple<int, int, int>;
typedef pair<int,int> pii;
typedef long long ll;


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

ll N;
ll A[10010];
ll B[10010];

int main(){

    cin >> N;
    ll sum_a = 0;
    ll sum_b = 0;

    for(int i = 0; i < N; i++){
        cin >> A[i];
        sum_a += A[i];
    }
    for(int i = 0; i < N; i++){
        cin >> B[i];
        sum_b += B[i];
    }
    
    if(sum_a > sum_b){
        cout<<"No"<<endl;
        return 0;
    }

    ll cnt = 0;
    for(int i = 0; i < N; i++){
        cnt += (max(0LL, B[i] - A[i]) + 1) / 2;
    }
    if(cnt <= sum_b - sum_a){
        cout <<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
    

    return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<stack>
using namespace std;

int main() {
	stack<int> S1;
	stack<pair<int, int> > S2;
	char ch;
	int sum = 0;
	for (int i = 0; cin >> ch; i++) {
	
		if (ch == '\\') {
			S1.push(i);
		} else if (ch == '/' && S1.size() > 0) {
			int j = S1.top();
			S1.pop();
			sum += i - j;
			int a = i - j;
			while (S2.size() > 0 && S2.top().first > j) {
				a += S2.top().second; 
				S2.pop();
			}
			S2.push(make_pair(j, a));
		}
	}

	vector<int> ans;
	while (S2.size() > 0) {
		ans.push_back(S2.top().second);
		S2.pop();
	}
	reverse(ans.begin(), ans.end());
	cout << sum << endl;
	cout << ans.size();
	for (int i = 0; i < ans.size();i++) {
		cout << " ";
		cout << ans[i];
	}
	cout << endl;

	return 0;

}

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

using namespace std;
long long x[10000010], y[10000010];
#define rep(i, n) for (int i = 0; i < (n); i++)
#define lep(j, n) for (int j = 0; j < (n); j++)
#define reps(i, n) for (int i = 1; i < (n); i++)
#define leps(i, n) for (int j = 1; j < (n); j++)
#define all(x) (x).begin(), (x).end()
#define pii pair<int, int>
#define int long long
#define gsort(x, n) sort((x), (x) + (n), greater<int>());
#define setout(n, x) setw(n) << setfill(x)
#define Fixed fixed << setprecision(10);
const long long mod = 1e9 + 7;

signed main()
{

   cin.tie(0);
   ios::sync_with_stdio(false);

   int a, b;
   cin >> a >> b;

   if (a <= 8 && b <= 8)
      cout << "Yay!" << '\n';
   else
      cout << ":(" << '\n';
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define all(v) (v).begin(), (v).end()
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
using namespace std;
typedef long long LL;
const int INF = 999999999;

struct edge{
    int src, to, cost;
};
using Edges = vector<edge>;
using WeightedGraph = vector<Edges>;

vector<int> dijkstra(WeightedGraph &G, int st){
    vector<int> dist(G.size(), INF);
    using pi = pair<int, int>;
    priority_queue<pi, vector<pi>, greater<pi>> q;
    dist[st] = 0;
    q.push(mp(dist[st], st));
    while(!q.empty()){
        int cost, idx;
        tie(cost, idx) = q.top(); q.pop();
        if(dist[idx] < cost) continue;
        for(auto &e: G[idx]){
            if(dist[e.to] <= cost+e.cost) continue;
            dist[e.to] = cost+e.cost;
            q.push(mp(dist[e.to], e.to));
        }
    }
    return dist;
}

int main(){
    int N, M, s, t;
    cin >> N >> M >> s >> t;
    s--; t--;
    WeightedGraph G(N);
    rep(i, M){
        int x, y;
        cin >> x >> y;
        x--; y--;
        G[x].emplace_back((edge){x, y, 1});
        G[y].emplace_back((edge){y, x, 1});
    }
    vector<int> ds, dt;
    ds = dijkstra(G, s);
    dt = dijkstra(G, t);
    int X = ds[t];
    map<int, int> ms, mt;
    rep(i, N){
        ms[ds[i]]++;
        mt[dt[i]]++;
    }

    LL ans = 0;
    for(auto &i: ms){
        int tmp = X-2-i.first;
        ans += 1LL*i.second*mt[tmp];
    }
    cout << ans << endl;
}




Measured memory_bytes: 12364
#include<stdio.h>

int main(void)
{
	int a[100][100] = {0};
	int b[100][100] = {0};
	int i,l,j,n,m,k;
	long c;
	
	scanf("%d %d %d",&n,&m,&l);	
	
	for(i=0;i < n;i++){
		for(j = 0;j < m;j++){
			scanf("%d",&a[i][j]);
		}
	}
	
	for(i=0;i < m;i++){
		for(j = 0;j < l;j++){
			scanf("%d",&b[i][j]);
		}
	}
	
	for(i=0;i < n;i++){
		for(j = 0;j < l;j++){
			c = 0;
			for(k = 0;k < m;k++){
				c+= a[i][k] * b[k][j];
		}
		printf("%ld",c);
		if(j < l-1){
			putchar(' ');
		}
		else{
			putchar('\n');
		}
		}
	}
	return 0;
}


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

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplece_back
#define mp make_pair
#define i_i pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< i_i >
#define Edge pair< i_i, int>
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; scanf("%lld", &x);
#define int2(x, y) int x, y; scanf("%lld %lld", &x, &y);
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second
 
//int dxy[5] = {0, 1, 0, -1, 0};
// assign

int dp[50][50][50];
 
signed main()
{
    rep(i, 50) {
        rep(j, 50) {
            rep(k, 50) {
                dp[i][j][k] = (i / 5) * 1520 + (i % 5) * 380 +
                    (j / 4) * 1870 + (j % 4) * 550 +
                    (k / 3) * 2244 + (k % 3) * 850;
            }
        }
    }
    Int(t);
    while (t) {
        int ans = INF;
        t /= 100;
        for (int i = 0; i * 2 <= t; i++) {
            for (int j = 0; i * 2 + j * 3 <= t; j++) {
                if ((t - (i * 2 + j * 3)) % 5) {
                    continue;
                } else {
                    int k = (t - (i * 2 + j * 3)) / 5;
                    ans = min(ans, dp[i][j][k]);
                }
            }
        }
        cout << ans << endl;
        cin >> t;
    }

    return 0;
}

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

int main() {
    string s;
    cin >> s;
    unordered_map<char, int> cnt;
    for(char c : s) cnt[c]++;
    int ans = 0;
    for(auto& i : cnt) ans += i.second % 2;
    cout << ans / 2 << endl;
}


Measured memory_bytes: 3196
#include<iostream>
#include<string>
#include<stack>/*** LIFO *** stack<type> var;
push(), top():to get data, pop():to remove, size(), empty() ***/
using namespace std;

#define Fp(I, STAT, END) for(int I = STAT; I < END; I++)
#define Fm(I, STAT, END) for(int I = STAT; I > END; I--)

int main(){
    int A[3], sum = 0;
    Fp(i, 0, 3){
        cin >> A[i];
        sum += A[i];
    }
    if(sum > 21) cout << "bust" << endl;
    else cout <<"win" << endl;
    
    return 0;
}


Measured memory_bytes: 256
import sys
#import bisect
input = sys.stdin.buffer.readline
#lb = bisect.bisect_left

def main():
	N,K=map(int,input().split())
	vA=list(map(int, input().split()))
	#INF = 1001001001

	vA.sort()
	
	res = sum(vA[:-K]) if K else sum(vA)
	print(res)

main()


Measured memory_bytes: 21988
package main

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

func main() {
	stdin := bufio.NewScanner(os.Stdin)

	stdin.Scan()
	num := stdin.Text()

	A, _ := strconv.Atoi(strings.Split(num, " ")[0])
	B, _ := strconv.Atoi(strings.Split(num, " ")[1])

	stdin.Scan()
	str := stdin.Text()

	for i := 0; i < A+B+1; i++ {
		if i == A {
			if str[i] != '-' {
				fmt.Println("No")
				os.Exit(0)
			}
		} else {
			if (str[i] < '0') || (str[i] > '9') {
				fmt.Println("No")
				os.Exit(0)
			}
		}
	}

	fmt.Println("Yes")

}


Measured memory_bytes: 640