akhauriyash/Code-Regression huggingface dataset:
import queue


class Edge:
    def __init__(self, to, cost):
        self.to = to
        self.cost = cost


class P:
    def __init__(self, distance, v):
        self.distance = distance
        self.v = v


# def dijkstra(_s):
#     que = queue.Queue()
#     global d
#     d = [float("inf") for i in range(N)]
#     d[_s] = 0
#     que.put(P(0, _s))
#
#     while not que.empty():
#         p = que.get()
#         v = p.v
#         if d[v] < p.distance:
#             continue
#         for i in range(0, len(G[v])):
#             e = G[v][i]
#             if d[e.to] > d[v] + e.cost:
#                 d[e.to] = d[v] + e.cost
#                 que.put(P(d[e.to], e.to))

def bfs(_s):
    q = queue.Queue()
    global d
    d = [float("inf") for i in range(N)]
    used = [False for i in range(N)]
    used[_s] = True
    d[_s] = 0
    q.put(_s)

    while not q.empty():
        p = q.get()
        for i in range(0, len(G[p])):
            if not used[G[p][i]]:
                used[G[p][i]] = True
                d[G[p][i]] = d[p] + 1
                q.put(G[p][i])


if __name__ == '__main__':
    N = int(input())
    a = []
    b = []
    for i in range(N - 1):
        tmp_a, tmp_b = list(map(int, input().split()))
        a.append(tmp_a - 1)
        b.append(tmp_b - 1)

    G = [[] for i in range(N)]
    for i in range(0, N - 1):
        # G[a[i]].append(Edge(b[i], 1))
        # G[b[i]].append(Edge(a[i], 1))
        G[a[i]].append(b[i])
        G[b[i]].append(a[i])

    # Fennec
    global d
    bfs(0)
    Fennec_d = d

    # sunuke
    bfs(N - 1)
    sunuke_d = d

    for i in range(0, len(Fennec_d)):
        if Fennec_d[i] <= sunuke_d[i]:
            sunuke_d[i] = -1
        else:
            Fennec_d[i] = -1

    # print(Fennec_d)
    # print(sunuke_d)

    Fennec_count = 0
    sunuke_count = 0
    for i in range(0, len(Fennec_d)):
        if Fennec_d[i] < 0:
            sunuke_count += 1
        else:
            Fennec_count += 1

    if sunuke_count < Fennec_count:
        print("Fennec")
    else:
        print("Snuke")


Measured memory_bytes: 34624
#include <bits/stdc++.h>
#include <string>
#include <cstring>
#include <algorithm>
#include <math.h>
#include <map>
#include <bitset>
#include <cmath>
#include <set>
#include <utility>

#define INF 1000000000000
#define MOD 1000000007 //10^9+7:合同式の法

using namespace std;
typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)

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

    if(A <= 9 and B <= 9)
        cout << A * B << endl;
    else
        cout << -1 << endl;


}

Measured memory_bytes: 3596
#include <iostream>
#include <vector>
#include <map>
using namespace std;

int main()
{
    int n;
    vector<int>vec;
    cin>>n;
    map<int,int> map_;

    for(int i=0;i<n;++i){
        int m;
        cin>>m;
        map_[m]++;
    }
    int sum=0;
    for(auto x:map_){
        sum+=(x.first>x.second?x.second:x.second-x.first);
    }
    cout<<sum<<endl;

    return 0;
}


Measured memory_bytes: 4736
from collections import defaultdict

N, M = map(int, input().split())
A = list(map(int, input().split()))

S = [0]*(N+1); S[0] = 0;
d = defaultdict(int); d[0] = 1;
for i in range(1, N+1):
  S[i] = (S[i-1] + A[i-1]) % M
  d[S[i]] += 1
  
ans = 0
for key, val in d.items():
  ans += val * (val - 1) // 2
print(ans)

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

int main() {
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  map<string, int> MA;
  int mx = 0;
  string S;
  while (cin >> S) mx = max(mx, ++MA[S]);
  for (auto ma : MA) if (ma.second == mx) cout << ma.first << "\n"; 
}

Measured memory_bytes: 23808
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
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 main() {
  int N;
  cin>>N;
  string c;
  cin>>c;
  int RED=0;
  for(int i=0;i<N;i++){
    if(c[i]=='R'){RED++;}
  }
  int out=0;
  for(int i=RED;i<N;i++){
    if(c[i]=='R'){out++;}
  }
  cout<<out<<endl;
  return 0;  
}

Measured memory_bytes: 3708
local DBG = true
local function dbgpr(...)
    if DBG then
        io.write("[dbg]")
        print(...)
    end
end
local function dbgpr_t(tbl, use_pairs)
    if DBG then
        local enum = ipairs
        if use_pairs then
            enum = pairs
        end
        dbgpr(tbl)
        io.write("[dbg]")
        for i,v in enum(tbl) do
            io.write(i)
            io.write(":")
            io.write(tostring(v))
            io.write(" ")
        end
        print("")
    end
end
local H, W = io.read("n", "n")
local INF = 99999999999
local function vert(H, W)
    local m = W % 3
    if m == 0 then
        return 0
    else
        return H
    end
end

local function horiz(H, W)
    return vert(W, H)
end

local function maxmindiff(a,b,c)
    local max = math.max(a,b,c)
    local min = math.min(a,b,c)
    return max - min
end

local function vh(H, W)
    local d = W // 3
    local h = H // 2
    local ans = INF
    for w=math.max(d,0),math.min(d+2,W) do
        local area1 = w * H
        local area2 = (W - w) * h
        local area3 = (W - w) * (H - h)
        ans = math.min(ans, maxmindiff(area1,area2,area3))
    end
    return ans
end


local function hv(H, W)
    return vh(W, H)
end

local answers = {vert(H, W), horiz(H, W), vh(H, W), hv(H, W)}
--dbgpr_t(answers)
print(math.min(table.unpack(answers)))



Measured memory_bytes: 1012
package main

import (
	"fmt"
)

func pow(x, n int) int {
	ans := 1
	for i := 0; i < n; i++ {
		ans *= x
	}
	return ans
}

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

	if n == 100 {
		fmt.Println(pow(100, d) * (n + 1))
		return
	}
	fmt.Println(pow(100, d) * n)
}


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

int main() {
  string s, t;
  cin >> s >> t;

  if ( t == s + "a" ) {
    cout << "Yes" << endl;
  }
  
  else if ( t == s + "b" ) {
    cout << "Yes" << endl;
  }
  
  else if ( t == s + "c" ) {
    cout << "Yes" << endl;
  }
  
  else if ( t == s + "d" ) {
    cout << "Yes" << endl;
  }
  
  else if ( t == s + "e" ) {
    cout << "Yes" << endl;
  }

  else if ( t == s + "f" ) {
    cout << "Yes" << endl;
  }
  
  else if ( t == s + "g" ) {
    cout << "Yes" << endl;
  }
  
  else if ( t == s + "h" ) {
    cout << "Yes" << endl;
  }
  
  else if ( t == s + "i" ) {
    cout << "Yes" << endl;
  }
  
  else if ( t == s + "j" ) {
    cout << "Yes" << endl;
  }
  
  else if ( t == s + "k" ) {
    cout << "Yes" << endl;
  }
  
  else if ( t == s + "l" ) {
    cout << "Yes" << endl;
  }
  
  else if ( t == s + "m" ) {
    cout << "Yes" << endl;
  }
  
  else if ( t == s + "n" ) {
    cout << "Yes" << endl;
  }
  
  else if ( t == s + "o" ) {
    cout << "Yes" << endl;
  }
  
  else if ( t == s + "p" ) {
    cout << "Yes" << endl;
  }
  
  else if ( t == s + "q" ) {
    cout << "Yes" << endl;
  }
  
  else if ( t == s + "r" ) {
    cout << "Yes" << endl;
  }
  
  else if ( t == s + "s" ) {
    cout << "Yes" << endl;
  }
  
  else if ( t == s + "t" ) {
    cout << "Yes" << endl;
  }
  
  else if ( t == s + "u" ) {
    cout << "Yes" << endl;
  }
  
  else if ( t == s + "v" ) {
    cout << "Yes" << endl;
  }
  
  else if ( t == s + "w" ) {
    cout << "Yes" << endl;
  }
  
  else if ( t == s + "x" ) {
    cout << "Yes" << endl;
  }
  
  else if ( t == s + "y" ) {
    cout << "Yes" << endl;
  }
  
  else if ( t == s + "z" ) {
    cout << "Yes" << endl;
  }
  
  else {
  cout << "No" << endl;
  }
}


Measured memory_bytes: 3080
from sys import stdin
import sys
import math
from functools import reduce
import functools
import itertools
from collections import deque,Counter,defaultdict
from operator import mul
import copy
# ! /usr/bin/env python
# -*- coding: utf-8 -*-
import heapq
sys.setrecursionlimit(10**6)
# INF =  float("inf")
INF = 10**18
import bisect
import statistics
mod = 10**9+7
# mod = 998244353

# C,Pを求める前処理
m = 10**5

fact = [0]*(m+5)
fact_inv = [0]*(m+5)
inv = [0]*(m+5)

fact[0] = fact[1] = 1
fact_inv[0] = fact_inv[1] = 1
inv[1] = 1

for i in range(2,m+5):
    fact[i] = fact[i-1] * i % mod
    inv[i] = mod - inv[mod % i] * (mod // i) % mod
    fact_inv[i] = fact_inv[i-1] * inv[i] % mod

# nCkをmod（素数）で割った余りを求める．ただしn<10**7
# 前処理はm=n+5まで
def cmb(n,k,mod):
    if n < k:
        return 0
    else:
        return fact[n] * (fact_inv[k] * fact_inv[n-k] % mod) % mod

N, K = map(int, input().split())
A = [0] + sorted(list(map(int, input().split())))

ans = 0
for i in range(1,N+1):
    ans = (ans + (A[i]*((cmb(i-1,K-1,mod) - cmb(N-i,K-1,mod)) % mod)) % mod) % mod

print(ans % mod)

Measured memory_bytes: 98436
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  int n, m;
  cin >> n;
  map<int, int> mp;
  rep(i, 0, n) {
    int d;
    cin >> d;
    mp[d]++;
  }

  cin >> m;
  rep(i, 0, m) {
    int t;
    cin >> t;
    if (mp[t] == 0) {
      cout << "NO" << endl;
      return 0;
    }
    mp[t]--;
  }

  cout << "YES" << endl;
}


Measured memory_bytes: 9600
#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
int n,k;
bool f;
int main(void){
  cin >> n;
  for(int i = 0; i < n; i++){
    char c;
    int m;
    cin >> c >> m;
    k += m * (c=='('?1:-1);
    if(k < 0) f = true;
  }
  if(f || k) cout << "NO" << endl;
  else cout << "YES" << endl;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;

int main() {
//    cin.tie(0); ios::sync_with_stdio(0);
    double t; cin >> t;
    double a = 3.1415926535897932384626;
    t *= 2;
    t *= a;
    cout << t << endl;
    return 0;
}

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

using namespace std;

int main() {
    unsigned int n, m, c;
    cin >> n >> m >> c;

    vector<int> b(m);
    for (int i = 0; i < m; ++i) {
        cin >> b[i];
    }

    int ans = 0;
    while (n--) {
        int tsum = c;
        for (int i = 0; i < m; ++i) {
            int a;
            cin >> a;
            tsum += a * b[i];
        }
        if (tsum > 0)ans++;

    }

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


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

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

    int x[n][d];

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < d; j++) {
            cin >> x[i][j];
        }
    }

    int ans = 0;
    for (int i = 0; i < n - 1; i++) {
        for (int j = i + 1; j < n; j++) {
            int distance = 0;
            for (int k = 0; k < d; k++) {
                int d = (x[i][k] - x[j][k]);
                distance += (d * d);
            }

            for (int l = 1; l < 130; l++) {
                if (l * l == distance) {
                    ans++;
                    break;
                }
            }
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 384
require 'set'

class Hash
  def push(key, value)
    self[key] = [] if self[key] == nil
    self[key].push(value)
  end
end

class Array
  def lower_bound(value)
    left = -1;
    right = self.length;
    while left + 1 < right
      mid = left + (right - left) / 2;
      if self[mid] >= value
        right = mid
      else
        left = mid
      end
    end
    right
  end

  def unique
    res = [self.first]
    each_cons(2) do |a, b|
      if a != b
        res.push(b)
      end
    end
    res
  end
end

def get_ints
  gets.split.map(&:to_i)
end

def get_ints_minus_one
  get_ints.map { |x| x - 1 }
end

def get_int
  gets.chomp.to_i
end


N = get_int
A = get_ints

approved = true
A.each do |a|
  if a % 2 == 0
    if a % 3 != 0 && a % 5 != 0
      approved = false
      break
    end
  end
end

puts approved ? 'APPROVED' : 'DENIED'


Measured memory_bytes: 14468
#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
using namespace std;
int main()
{
 int k;
 cin>>k;
 
 long long int cnt=0;
 for(int i=1;i<=k;i++)
 {
     for(int j=1;j<=k;j++)
     {
         for(int h=1;h<=k;h++)
         {
             cnt+=(__gcd(i,__gcd(j,h)));
         }
     }
 }
    cout<<cnt;
 

return 0;   
}

Measured memory_bytes: 3592
N,K = map(int, input().split())
V = [int(v) for v in input().split()]

ans = 0
for i in range(K+1):
    if i < N:
        for j in range(i+1):
            temp1 = V[:j]
            temp2 = V[N-(i-j):]
            temp = temp1 + temp2
            temp.sort()
            s = sum(temp)
            k = 0
            while k < len(temp) and k < K-i:
                if temp[k] < 0:
                    s -= temp[k]
                k += 1
            ans = max(ans, s)
    else:
        temp = sorted(V)
        s = sum(temp)
        j = 0
        while j < min(N, i-N):
            if temp[j] < 0:
                s -= temp[j]
            j += 1
        ans = max(ans, s)
        
print(ans)

Measured memory_bytes: 40944
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define range(a) a.begin(),a.end()
int main(){
	cout<<fixed<<setprecision(15);
	int n;
	cin>>n;
	vector<int>p(n);
	rep(i,n)cin>>p[i];
	vector<int>q(n);
	rep(i,n)cin>>q[i];
	vector<int>r(n);
	rep(i,n)r[i]=i+1;
	int x,y;
	int i=0;
	do{
		if(r==p)x=i;
		if(r==q)y=i;
		i++;
	}while(next_permutation(range(r)));
	cout<<abs(x-y)<<endl;
}

Measured memory_bytes: 256
import collections
import itertools

N = int(input())
A = list(map(int, input().split()))

ac = collections.Counter(A)

dp = [0] * (N+1)
dp2 = [0] * (N+1)
total = 0
for no, num in ac.items():
    dp[no] = int(num*(num-1)/2)
    dp2[no] = dp[no] - (num-1)
    total += dp[no]

for k in range(1,N+1):
    no = A[k-1]
    print(int(total - dp[no] + dp2[no]))


Measured memory_bytes: 33940
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <vector>
#include <set>
#include <numeric>

using namespace std;
string t="abcdefghijklmnopqrstuvwxyz";
int cnt[26];

int main(){
   string s;
   cin>>s;
   if(s.size()==26){
      for(int i=24;i>=0;i--){
         if(s[i]<s[i+1]){
            char min_s='z';
            for(int j=i+1;j<26;j++){
               if(s[j]>s[i])min_s=min(min_s,s[j]);
            }
            cout<<s.substr(0,i)<<min_s<<endl;
            return 0;
         }
      }
      cout<<-1<<endl;
      return 0;
   }

   for(int i=0;i<s.size();i++){
      for(int j=0;j<26;j++){
         if(s[i]==t[j]){
            cnt[j]++;
         }
      }
   }
   for(int i=0;i<26;i++){
      if(cnt[i]==0){
         cout<<s<<t[i]<<endl;
         return 0;
      }
   }
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
 
int main(){
	int n,m,ans=0;
	cin>>n;
	string s[n],ser;
	for(int i=0;i<n;i++)cin>>s[i];
	cin>>m;
	string t[m];
	for(int j=0;j<m;j++)cin>>t[j];

	for(int i=0;i<n;i++){
		int cnt=0;
		string ser=s[i];
		for(int j=0;j<n;j++){
			if(ser==s[j])cnt++;
		}
		for(int j=0;j<m;j++){
			if(ser==t[j])cnt--;
		}
		ans=max(ans,cnt);
	}
	cout<<ans<<endl;
}

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

int main() {
	int n, r;
	cin >> n >> r;
	if (n >= 10) cout << r << endl;
	else cout << r + 100 * (10 - n);
	return 0;
}

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

using namespace std;
int main(void){
    int n,m;
    cin >> n >> m;
    vector<int> a(m);
    int sum = 0;
    for(int i = 0;i < m;i++){
        cin >> a[i];
        sum += a[i];
    }
    
    int ans = max(-1,n - sum);
    cout << ans << endl;
}


Measured memory_bytes: 3676
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> V;
#define rep(s,e) for(ll i=s;i<e;i++ )
typedef pair<ll,ll> P;
const ll mod = 1000000007;
const ll INF = 100000000000009;
ll i;



int main(){
    ll N;
    cin>>N;
    V v(N);
    rep(0,N)cin>>v.at(i);
    map<ll,ll> sa,sb;
    rep(0,N){
        if(i%2==0){
            if(sa.count(v.at(i)))sa[v.at(i)]++;
            else sa[v.at(i)]=1;
        }
        else{
            if(sb.count(v.at(i)))sb[v.at(i)]++;
            else sb[v.at(i)]=1;
        }
    }
    ll ma=0,mb=0;
    ll sya,syb;
    for(P x:sa){
        if(x.second>ma){
            sya=x.first;
            ma=x.second;
        }
    }
    for(P x:sb){
        if(x.second>mb){
            syb=x.first;
            mb=x.second;
        }
    }
    ll sma=0,smb=0;
    ll sha,shb;
    sa.erase(sya);
    sb.erase(syb);
    for(P x:sa){
        if(x.second>sma){
            sha=x.first;
            sma=x.second;
        }
    }
    for(P x:sb){
        if(x.second>smb){
            shb=x.first;
            smb=x.second;
        }
    }

    if(sya!=syb)cout<<N-ma-mb;
    else{
        cout<<N-max(ma+smb,mb+sma);
    }
    cout<<endl;
    
}

Measured memory_bytes: 7296
#include <bits/stdc++.h>
#define rep(i, n) for(int i= 0; i < (n); i++)
using ll= long long int;
using namespace std;
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; }
ll mod= 1e9 + 7;


int main(){
  int n;
  cin >>n;
  int a[n];
  rep(i,n)cin >>a[i];
  sort(a,a+n);
  int g=a[n-1]&2;
  int b,c;
  if(!g){b=c=a[n-1]/2;}else{b=a[n-1]/2;c=b+1;}
  int ans=1000000001;
  int d=0;
  rep(i,n-1){
    if(ans>abs(a[i]-b)){ans=abs(a[i]-b); d=a[i];}
    if(ans>abs(a[i]-c)){ans=abs(a[i]-c); d=a[i];}
  }
  cout << a[n-1] << " " << d << endl; 
} 

Measured memory_bytes: 3992
S = str(input())

num = 0
for i in range(len(S)):
    if i % 2 == 0:
        if S[i] == "L":
            num += 1
    else:
        if S[i] == "R":
            num += 1

if num == 0:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
N = int(input())
A = list(map(int,input().split()))
cmax = 0
a = 0
ind = -1
for i in range(N):
    if abs(A[i])>cmax:
        cmax = abs(A[i])
        a = A[i]
        ind = i
if a>0:
    B = []
    for i in range(N):
        if A[i]<0:
            A[i] += a
            B.append([ind+1,i+1])
    for i in range(1,N):
        A[i] += A[i-1]
        B.append([i,i+1])
    print(len(B))
    for j in range(len(B)):
        print(*B[j])
elif a<0:
    B = []
    for i in range(N):
        if A[i]>0:
            A[i] += a
            B.append([ind+1,i+1])
    for i in range(N-2,-1,-1):
        A[i] += A[i+1]
        B.append([i+2,i+1])
    print(len(B))
    for j in range(len(B)):
        print(*B[j])
else:
    print(0)

Measured memory_bytes: 38384
;グローバル変数
(setq *n* (read))
(setq *l* nil)

(defun split (x str)
  (let ((pos (search x str))
        (size (length x)))
    (if pos
      (cons (subseq str 0 pos)
            (split x (subseq str (+ pos size))))
      (list str))))

;マージソート実装
(defun merge-list (f l1 l2)
  (cond ((atom l1) l2)
        ((atom l2) l1)
        ((funcall f (car l1) (car l2))
         (cons (car l1) (merge-list f (cdr l1) l2)))
        (t (cons (car l2) (merge-list f l1 (cdr l2))))))

(defun merge-sort (f l n)
  (cond ((= n 1) (list (car l)))   ; 新しいリストを返す
        ((= n 2)
         (let ((x (first l)) (y (second l)))
           (if (funcall f x y) (list x y) (list y x))))
        (t (let ((m (truncate n 2)))
             ; リストを二分割し再帰呼び出しの結果をマージする
             (merge-list f
                         (merge-sort f l m)
                         (merge-sort f (nthcdr m l) (- n m)))))))

;ガイドブック順ソートの定義
(defun my< (a b)
  (cond
    ((equal (car a) (car b))
     (if (> (parse-integer (cadr a)) (parse-integer (cadr b))) t nil))
    ((string< (car a) (car b))
     t)
    (t nil)))

;入力
(dotimes (i *n*)
  (setq *l* (append *l* (list (append (split " " (read-line)) (list (1+ i)))))))

;ソート実行
(setq *l* (merge-sort #'(lambda (a b) (my< a b)) *l* (length *l*)))

;出力
(format t "~{~a~^~%~}~%" (mapcar #'caddr *l*))


Measured memory_bytes: 6632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = (1e9)+7;
int A[100001];

ll calc(int n){
  ll res=1;
  for(int i=0;i<n/2;i++) res=res*2%mod;
  return res%mod;
}


int main(){
  int n;
  cin>>n;
  for(int i=0,a;i<n;i++)cin>>a,A[a]++;

  bool flg=1;
  if(n%2==1){
    flg=A[0]==1;
    for(int i=2;i<n-1;i+=2)if(A[i]!=2)flg=0;  
  }
  else {
    for(int i=1;i<n-1;i+=2)if(A[i]!=2)flg=0;
  }
  cout << (flg? calc(n):0)<<endl;
  return 0;
}


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

int main() {
    int32_t n;
    cin >> n;
    int32_t a[n + 1];

    for (int32_t i = 0; i < n; i++) {
        cin >> a[i];
    }
    a[n] = -1;

    int32_t answer = 0;
    int32_t c = 1;
    for (int32_t i = 0; i < n; i++) {
        if (a[i + 1] == a[i]) {
            c++;
        } else {
            answer += c / 2;
            c = 1;
        }
    }
    cout << answer << endl;

    return 0;
}


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

#define lp2(i,n) for(int i=0;i<n;i++)
#define lp3(i,a,b) for(int i=a;i<b;i++)

using namespace std;

int main(){
  int n;
  cin>>n;
  int h[n];
  lp2(i,n)cin>>h[i];
  lp2(k,n){
    if(k!=n-1)cout<<h[k]<<" ";
    else cout<<h[k]<<endl;
    }
  lp3(i,1,n){
    int v=h[i];
    int j=i-1;
    while(j>=0&&h[j]>v){
      h[j+1]=h[j];
      h[j]=v;
      j--;
    }
    lp2(k,n){
      if(k!=n-1)cout<<h[k]<<" ";
      else cout<<h[k]<<endl;
  }
  }
  
  return 0;
  
}



Measured memory_bytes: 3092
#include<bits/stdc++.h>
using namespace std;
int main(){
long int n,W;
  cin>>n>>W;
  long int wt[n],val[n];
  for(int i=0;i<n;i++){
		cin>>wt[i]>>val[i];}
  long int k[n+1][W+1];
  for(int i=0;i<=n;i++){
		for(int w=0;w<=W;w++){
			if(i==0 or w==0)
              k[i][w]=0;
          	else if(wt[i-1]<=w)
              k[i][w]=max(val[i-1]+k[i-1][w-wt[i-1]],k[i-1][w]);
          	else
              k[i][w]=k[i-1][w];
        }
  }
  cout<<k[n][W];
  return 0;
}
                          

Measured memory_bytes: 79104
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
#include <sstream>
#include <iomanip>
#include <set>
#include <stack>
#include <cassert>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vvb> vvvb;
typedef vector<vvvb> vvvvb;
typedef vector<string> vs;
typedef vector<vs> vvs;
typedef vector<vvs> vvvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<vvd> vvvd;
typedef pair<ll, ll> PL;
typedef vector<PL> vpl;
typedef vector<vector<PL>> vvpl;
const int INF = 1001001001;
const ll LINF = 1e17;
const double pi = 3.1415926535897932;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define RFOR(i, a, b) for(ll i = (a); i > b; i--)
#define rep(i, n) for(ll i = 0; i < n; i++)
#define rrep(i, n) for(ll i = n-1; i > -1; i--)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)
#define ff first
#define ss second
#define pb push_back
#define epb emplace_back

template <typename T>
T gcd(T a, T b) {
    return (a == 0) ? b : gcd(b%a, a);
}
template <typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

bool p_comp_fs(const PL p1, const PL p2){ return p1.first < p2.first;};
bool p_comp_fg(const PL p1, const PL p2){ return p1.first > p2.first;};
bool p_comp_ss(const PL p1, const PL p2){ return p1.second < p2.second;};
bool p_comp_sg(const PL p1, const PL p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec){
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}

inline ll popcnt(ll x){return __builtin_popcount((unsigned int)x);};
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }

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

    cout << 0 << endstr << flush;
    string s0; cin >> s0;
    if(s0 == "Vacant") return 0;
    cout << N-1 << endstr << flush;
    string sn; cin >> sn;
    if(sn == "Vacant") return 0;
    
    ll l = 0, r = N-1;
    ll idx = 0;
    while(idx < 20){
        ll mid = (l+r)/2;
        mid %= N;
        cout << mid << endstr << flush;
        string res; cin >> res;
        if(res == "Vacant") return 0;
        ll len = mid-l, ren = r-mid;
        if(len%2 == 0 && s0 != res){
            r = mid; sn = res;
        }
        else if(len%2 == 1 && s0 == res){
            r = mid; sn = res;
        }
        else if(ren%2 == 0 && sn != res){
            l = mid; s0 = res;
        }
        else if(ren%2 == 1 && sn == res){
            l = mid; s0 = res;
        }
        idx++;
    }
    
    return 0;
}


Measured memory_bytes: 852
#include<bits/stdc++.h>
#define inf 1<<30
using namespace std;

int k,ans;
string a,b;

void dfs(string s,int n,int num)
{
  if(n==k){
    if(s==b)ans=min(ans,num);
  }
  else {
    int dif=(b[n]-s[n]+10)%10;
    if(s[n]==b[n]){
      dfs(s,n+1,num);
    }
    else {
      for(int i=n;i<k;i++){
	s[i]=((s[i]-'0'+dif)%10)+'0';
	dfs(s,n,num+1);
      }
    }
  }
}

int main()
{
  while(1){
    cin>>k;
    if(k==0)break;
    cin>>a>>b;

    ans=inf;
    dfs(a,0,0);
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 1212
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int k, a, b;
    cin >> k >> a >> b;
    if (a % k == 0 || b % k == 0 || b / k > a / k)
        cout << "OK\n";
    else
        cout << "NG\n";
}


Measured memory_bytes: 3596
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <iomanip>
#include <numeric>

struct Trump;
std::vector<Trump> deck();
int read_Holding_Num();
void output(std::vector<Trump> trump);

struct Trump
{
	char mark;
	int number;
	Trump() = default;
	Trump(char newMark, int newNumber) : mark(newMark), number(newNumber){}
};

int main()
{
	std::vector<Trump> trump = deck();

	int n = read_Holding_Num();

	char mark;
	int number; 

	for (int i = 0; i < n; ++i)
	{
		std::cin >> mark >> number;
		trump.erase(std::remove_if(trump.begin(), trump.end(), [mark, number](Trump x){return x.mark == mark && x.number == number; }), trump.end());
	}

	output(trump);

	return 0;
}

std::vector<Trump> deck()
{
	std::vector<Trump> trump;
	std::vector<char> mark = { 'S', 'H', 'C', 'D' };
	size_t size_mark = mark.size();

	for (size_t i = 0; i < size_mark; ++i)
	{
		for (int j = 1; j <= 13; ++j)
		{
			trump.emplace_back(mark[i], j);
		}
	}
	return trump;
}

int read_Holding_Num()
{
	int n;
	std::cin >> n;
	return n;
}

void output(std::vector<Trump> trump)
{
	for (auto& item : trump)
	{
		std::cout << item.mark << " " << item.number << std::endl;
	}
}


Measured memory_bytes: 3148
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
#define o_set tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>
#define int ll
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int N,S;
vector<int> v;
vector<int> pot;
int mod=998244353;
bool vis[3009][3009];
int memo[3009][3009];
int sol(int pos,int p){
  if(p>S)return 0;
  if(pos==N)return (p==S);
  if(vis[pos][p])return memo[pos][p];
  vis[pos][p]=1;
  int tot=0;
  tot=sol(pos+1,p)*2;
  tot+=sol(pos+1,p+v[pos]);
  return memo[pos][p]=tot%mod;
}
signed main(){
		ios_base::sync_with_stdio(0);cin.tie(0);
		cin>>N>>S;
		for(int i=0;i<N;i++){
      int a;
      cin>>a;
      v.push_back(a);
		}
		pot.push_back(1);
		for(int i=0;i<5000;i++){
      pot.push_back(pot[i]*2%mod);
		}
		cout<<sol(0,0);
}

Measured memory_bytes: 83196
n = int(input())
if n == 111:
  print(999)
elif n == 119:
  print(991)
elif n ==191:
  print(919)
elif n ==911:
  print(199)
elif n == 199:
  print(911)
elif n == 919:
  print(191)
elif n ==991:
  print(119)
elif n ==999:
  print(111)


Measured memory_bytes: 2940
import java.io.*;
import java.util.*;

class Main
{
    public static void main (String args[]) throws IOException         //?????????
    {
        InputStreamReader is = new InputStreamReader(System.in);       //?????????
        BufferedReader br = new BufferedReader(is);                    //?????????
        Scanner sc = new Scanner(System.in);

        int a = sc.nextInt();
        int b = sc.nextInt();
        
        int area = a * b;
        int length = 2*(a+b);
        
        System.out.println(area+" "+length);
    }
}
    

Measured memory_bytes: 26132
#include<bits/stdc++.h>
  using namespace std;
    #define ll long long
    #define ull unsigned long long
    #define fr(i,a,b) for(int i =a ; i < b; i++)
    #define FR(i,a,b) for(int i =a ; i > b; i--) 
    #define frj(j,a,b) for(int j =a ; j < b; j++)
    #define FRE(i,a,b) for(int i =a ; i >= b; i--) 
    #define fre(i,a,b) for(int i =a ; i <= b; i++)
    #define fra(s) for(auto it = s.begin(); it != s.end() ; ++it)

    #define mkp make_pair 
    #define pb push_back
    #define pii pair<int,int>
    #define speed   ios::sync_with_stdio(false), cin.tie(0) , cout.tie(0)
    #define c(a,b) cout<<a<<"--"<<b<<endl;
    #define frv(i,a,v) for(int i =  a ; i < v.size() ; ++i)
    #define cp(a,i)  cout<<a[i].first<<" "<<a[i].second<<endl;
    #define pp(a) cout<<a.first<<" "<<a.second<<endl;
    //sum array
    #define sa(n) int a[n]; int s[n];cin>>a[0];s[0]=a[0];fr(i,1,n) {cin>>a[i];s[i]=s[i-1]+a[i];}
    #define sa1(n) int a[n+1]; long long s[n+1]; a[0]=0; s[0]=0;cin>>a[1];s[1]=a[1];fr(i,2,n+1) {cin>>a[i];\
    s[i]=s[i-1]+a[i];}

    #define pr(a,n) fr(i,0,n){cout<<a[i]<<" ";}cout<<endl;
    #define prv(v)   for(auto it = v.begin() ; it!= v.end() ;++it){cout<<*it<<" ";}cout<<endl;
    #define prs(s)   for(auto x : s){cout<<x<<" ";}cout<<endl;
    
    #define all(x)           x.begin(), x.end()
    #define prm(m,r,c) fr(i,0,r){frj(j,0,c){cout<<m[i][j]<<" "; }cout<<endl;}
    #define fillm(m,r,c,k) fr(i,0,r)frj(j,0,c)m[i][j]=k;
    constexpr auto PI  = 3.14159265358979323846L;
    constexpr auto eps = 1e-6;
    constexpr auto mod = 1000000007;
    #define MOD 1000000007
   // #define maxv 200005
    #define MAXN 100001

  template<class T> ostream& operator<<(ostream& out, vector<T> vec) { out<<"("; for (auto& v: vec) out<<v<<", "; return out<<")"; }
  template<class T> ostream& operator<<(ostream& out, set<T> vec) { out<<"("; for (auto& v: vec) out<<v<<", "; return out<<")"; }


    const int INF = 1e9 +5;
int main(){
      
      speed;

      int n,k ;
      cin>>n>>k;
      int h[n];
      fr(i,0,n)
      cin>>h[i];

      vector<int> dp (n,INF);
      dp[0]=0;
      fr(i,0,n)
        {
          for(int j = i+1 ; j <=i+k ; j++)
          {
            if(j<n)
                {
                  dp[j]=min(dp[j],dp[i]+abs(h[i]-h[j]));
                }

          }
        }

        cout<<dp[n-1]<<endl;
      return 0;

  }



Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define SORT(x) sort(x.begin(),x.end())
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
int main(){
    int ans=0;
    double w,h;
    cin>>w>>h;
    double x,y;
    cin>>x>>y;
    if(w==2*x&&h==2*y){
        ans=1;
    }
    printf("%.10f %d",(w*h)/2,ans);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
typedef long long ll;
using namespace std;

int main()
{
  ll N;

  ll ans = 0;
  // ll ans_tmp;

  cin >> N;

  // int f[N + 1];
  // int f;
  // int f_tmp;

  for (ll n = 1; n < N + 1; n++)
  {
    ll y = (ll)(N / n);
    ans += y * (y + 1) * n / 2;
  }

  cout << ans << endl;
}


Measured memory_bytes: 3132
/*input
3 1
1 2 1
*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
using namespace __gnu_pbds; 
#define int long long 
#define pii pair<int,int>
#define pb push_back
#define f first
#define s second
#define FOR(i,n) for(int i=0;i<n;i++)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int power(int x, int y, int mod = 2e18)
{int ans = 1;x%=mod;while(y){if(y&1)ans = (x * ans) % mod;x = (x * x) % mod;y >>= 1;}return ans;}

#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 << endl; }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args) {
        const char* comma = strchr(names + 1, ',');
        cerr.write(names, comma - names) << " : " << arg1 << "  ";
        __f(comma + 1, args...);
    }
#else
#define trace(...)
#endif // ifndef ONLINE_JUDGE

template <typename T> ostream& operator << (ostream& os, const vector<T>& v) { for (int i = 0; i < v.size(); ++i) os << v[i] << " "; return os; } 
template <typename T> ostream& operator << (ostream& os, const set<T>& v) { for (auto it : v) os << it << " "; return os; } 
template <typename T, typename S> ostream& operator << (ostream& os, const pair<T, S>& v) { os << v.first << " " << v.second; return os; } 
template <typename T, typename S> ostream& operator << (ostream& os, const map<T, S>& v) { for (auto it : v) os << it.first << "=>" << it.second << "\n"; return os; } 

typedef tree<int, null_type, less<int>, rb_tree_tag,tree_order_statistics_node_update> ordered_set; 
int const MOD = 1e9+7;
int const inf = 2e18;
int const N = 2e5+10;
vector<int> v[N];
bool vis[N];
void dfs(int i){
  vis[i]=1;
  for(auto x :v[i]){
    if(!vis[x]){
      dfs(x);
    }
  }
}
signed main() {
  IOS;
  int n,m;
  cin>>n>>m;
  FOR(i,m){
    int x,y,z;
    cin>>x>>y>>z;
    v[x].pb(y);
    v[y].pb(x);
  } 
  int ans =0 ;
  FOR(i,n+1){
    if(i != 0){
      
      if(!vis[i]){
        ans++;
        dfs(i);
      }
    }
  }
  cout << ans << endl ; 



return 0;
}

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

bool up[10000002];
vector<int> v1;
vector<int> v2;

int Nx,Ny;
const int MAXN = 200;
vector<int> edgex[MAXN+1],edgey[MAXN+1];
int matchx[MAXN+1],matchy[MAXN+1];
bool visitx[MAXN+1],visity[MAXN+1];
bool dfs(int x){
   visitx[x]=true;
   for(int i=0;i<edgex[x].size();i++){
      int y=edgex[x][i];
      visity[y]=true;
      if(matchy[y]==-1||(!visitx[matchy[y]]&&dfs(matchy[y]))){
         matchy[matchx[x]=y]=x;
         return true;
      }
   }
   return false;
}
int matching(){
   memset(matchx,-1,sizeof matchx);
   memset(matchy,-1,sizeof matchy);
   int ans=0;
   for(int i=0;i<Nx;i++){
      memset(visitx,0,sizeof visitx);
      memset(visity,0,sizeof visity);
      if(dfs(i))  ans++;
   }
   return ans;
}
bool op(int x,int y){
	int tmp=abs(x-y);
	if(tmp==1||tmp==2)	return false;
	for(long long int i=3;i*i<=tmp;i++)
		if(tmp%i==0)
			return false;
	return true;
}

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin>>n;
	for(int i=0,x;i<n;i++){
		cin>>x;
		up[x]=true;
	}
	for(int i=1;i<=10000001;i++)
		if(up[i]!=up[i-1]){
			if(i&1)
				v1.push_back(i);
			else
				v2.push_back(i);
		}
	Nx=v1.size();Ny=v2.size();
	for(int i=0;i<Nx;i++)
		for(int j=0;j<Ny;j++)
			if(op(v1[i],v2[j]))
				edgex[i].push_back(j),edgey[j].push_back(i);
	int k=matching();
	cout<<k+(Nx-k)/2*2+(Ny-k)/2*2+3*((Nx-k)&1)<<endl;
}

Measured memory_bytes: 6656
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <utility>
#include <string>
#include <stack>
#include <regex>
#include <cctype>
#include <set>

#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<long long>
#define vvl vector<vector<long long>>

using namespace std;

typedef long long ll;

int main()
{
  int N;
  cin >> N;
  vi a(N);
  set<int> st;
  REP(i, N)
  {
    cin >> a[i];
  }

  int res = 0;
  REP(i, N)
  {
    if (i == 0)
    {
      continue;
    }

    if (a[i] == a[i - 1])
    {
      int sum = 2;
      for (int j = i; j < N - 1; j++)
      {
        if (a[j] != a[j + 1])
        {
          i = j;
          break;
        }
        else
        {
          i++;
          sum++;
        }
      }
      res += sum / 2;
    }
  }

  cout << res << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long l;
typedef long long ll;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    const l mod = 1000000007;
    l t;
   // cin>>t;
   t = 1;
    while(t--)
    {
        string s1,s2;
        cin>>s1>>s2;
        l a = 0;
        for(l i = 0 ; i<3 ; i++)
        if(s1[i]==s2[i])
        a++;
        cout<<a<<endl;
    }
    return 0;
}

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

using namespace std;

int main()
{
	string a,b;
	int n , ans=0;
	cin >> a >> b;
	n = a.size();
	for( int i = 0 ; i < n ; i++ ) if( a[i] != b[i] ) ans++;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3924
i=int(input())
s=input().split()
b=[]
for h in range(i):
  b.append(int(s[h]))
a=0
for h in range(i):
  if b[h]==h+1:
    if h<i-1:
      if b[h+1]==h+2:
        b[h+1]=h+1
        a+=1
      else:
        a+=1
    else:
      a+=1
print(str(a))

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

int main() {
  int N;
  string S;
  cin >> N >> S;
  int S_size = S.size();
  char c = '\0';
  int ans = 0;
  for (int i = 0; i < S_size; ++i) {
    if (S[i] != c) {
      ++ans;
      c = S[i];
    }
  }
  cout << ans << endl;
}

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

using namespace std;

const int MaxN = 200005;

int n;
long long k;
int a[MaxN], depth[MaxN];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> k;
    for (int i = 1; i <= n; i++)
    {
        cin >> a[i];
        depth[i] = -1;
    }
    depth[1] = 0;
    int Count = 0, x = 1;
    while (depth[a[x]] == -1)
    {
        x = a[x];
        Count++;
        k--;
        if (k == 0)
        {
            cout << x;
            return 0;
        }
        depth[x] = Count;
    }
    x = a[x];
    Count++;
    k--;
    k = k % (Count - depth[x]);
    while (k > 0)
    {
        k--;
        x = a[x];
    }
    cout << x;
    return 0;
}

Measured memory_bytes: 5212
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
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; }
const ll INF = 1LL << 60;
const int MAX = 1000000010;
const ll MOD = 1000000007;
const double PI = acos(-1);

int main() {
    ll N, K; cin >> N >> K;
    ll ans = K;

    for (int i = 0; i < N - 1; i++) {
        ans *= K - 1;
    }

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

Measured memory_bytes: 3624
#include<iostream>
#include<algorithm>
#include<string>
#include<math.h>
#include<vector>

using namespace std;

int main(void)
{
	string s;
	cin >> s;

	if (s[5] == '1')
	{
		cout << "TBD" << endl;
	}
	else if (s[6] > '4')
	{
		cout << "TBD" << endl;
	}
	else if(s[6]<='4')
		cout << "Heisei" << endl;



	return 0;
}

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

using namespace std;
int main(){
	int b,c,d,e,i,N;
	vector<int> a;
	cin >> N;
	c = 0;
	d = 0;
	e = 0;
	for(i=0;i<N;i++){
		cin >> b;
		a.push_back(b);
	}
	for(i=0;i<N;i++){
		if(a[i]%4==0){
			c += 1;
		}else if(a[i]%2==0){
			e += 1;
		}else{
			d += 1;
		}
	}
	if(e!=1){
		if(c>=d){
			cout << "Yes" << endl;
		}else if((d-c)==1 && (c+d)==N){
			cout << "Yes" << endl;
		}else{
			cout << "No" << endl;
		}
	}else{
		if(c>=(d+1)){
			cout << "Yes" << endl;
		}else if(c==d && (c+d)==(N-1)){
			cout << "Yes" << endl;
		}else{
			cout << "No" << endl;
		}
	}
}

Measured memory_bytes: 892
#include<bits/stdc++.h>
using namespace std;
const int MOD = (int)1e9+7;
map<pair<long long, int>, int> M;

int DP(long long N, int k)
{
  if(N<0) return 0;
  if(N>(2LL<<(k+1))-2) N = (2LL<<(k+1))-2;
  if(N == 0) return 1;
  auto it = M.find(make_pair(N, k));
  if(it != M.end()) return it->second;
  long long ans = 0;
  ans += DP(N-(2LL<<k), k-1);
  ans += DP(N-(1LL<<k), k-1);
  ans += DP(N, k-1);
  return M[make_pair(N, k)] = ans % MOD;
}

int solve(long long N)
{
  M.clear();
  return DP(N, 61);
}
int main()
{
  long long N;
  scanf("%lld", &N);
  printf("%d\n", solve(N));
}

Measured memory_bytes: 256
def kmpTable(w):
    lw = len(w)
    nx = [-1] * (lw + 1)
    j = -1
    for i in range(lw):
        while j >= 0 and w[i] != w[j]:
            j = nx[j]
        j += 1
        nx[i + 1] = j
    return tuple(nx)
def kmpSearch(s, w):
    ls = len(s)
    start = 0
    w_idx = 0
    ret = []
    nx = kmpTable(w)
    while start + w_idx < ls:
        if s[start + w_idx] == w[w_idx]:
            w_idx += 1
            if w_idx == len(w):
                ret.append(start)
                start = start + w_idx - nx[w_idx]
                w_idx = nx[w_idx]
        else:
            if w_idx == 0:
                start += 1
            else:
                start = start + w_idx - nx[w_idx]
                w_idx = nx[w_idx]
    return ret
T = input()
P = input()
ans = kmpSearch(T, P)
if ans:
    print("\n".join(map(str, ans)))	



Measured memory_bytes: 117860
import math
a,b,x = list(map(int,input().split()))
if a*b*0.5*a > x:
    c = (2*x) / (a*b)
    ans = 90 - math.degrees(math.atan(c/b))
    print(ans)
else:
    c = (2*x) / a**2 - b
    if b-c == 0:
        ans = 0
    else:
        ans = 90 - math.degrees(math.atan(a/(b-c)))
    print(ans)

Measured memory_bytes: 3188
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int T = sc.nextInt();
		int c = 0, t = 0;
		int min = 9999;
		for (int i = 0; i < N; i++) {
			c = sc.nextInt();
			t = sc.nextInt();
			if (t <= T) {
				min = Math.min(min, c);
			}
			
		}
		if(min == 9999) {
			System.out.println("TLE");
		}else {
			System.out.println(min);
		}
	}
}


Measured memory_bytes: 21844
import sys
from operator import itemgetter
sys.setrecursionlimit(10**7)
N = int(input())
li = [[int(x) for x in input().split()] for _ in range(N)]
li.sort(key=itemgetter(2),reverse=True)
map = [[-1 for _ in range(101)] for _ in range(101)]
ans = [0]*3
for i in range(101):
    for j in range(101):
        h = -1
        flag = True
        for x in li:
            if(h == -1):
                h=x[2]+abs(x[0]-i)+abs(x[1]-j)
            else:
                if(x[2]!=0):
                    if(h!=x[2]+abs(x[0]-i)+abs(x[1]-j)):
                        flag = False
                else:
                    if(h>abs(x[0]-i)+abs(x[1]-j)):
                        flag = False
        if(flag):
            if(h>ans[2]):
                ans=[i,j,h]

print(str(ans[0])+' '+str(ans[1])+' '+str(ans[2]))


Measured memory_bytes: 3316
#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 = 1e5 + 5;

int32_t main()
{
	IOS;
	set<int> s;
	for(int i = 1; i <= 5; i++)
	{
		int x;
		cin >> x;
		s.insert(x);
	}
	int ans = 1;
	while(s.find(ans) != s.end())
		ans++;
	cout << ans;
	return 0;
}

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

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int N;
    cin >> N;
    int ans = 0;
    vector<int> arr(N+1);
    for (int i = 1; i <= N; ++i) {
        cin >> arr[i];
        if ((i & 1) && (arr[i] & 1)) {
            ans ++;
        }
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 3656
#include<iostream>

using namespace std;

int main(){
  int sum1 = 0, sum2 = 0;
  int n;
  for(int i = 0; i< 4; i++){
    cin >> n;
    sum1 += n;
  }
  for(int i = 0; i< 4; i++){
    cin >> n;
    sum2 += n;
  }

  if(sum1 > sum2) cout << sum1<<endl;
  else cout << sum2<<endl;

  return 0;
}
  

Measured memory_bytes: 1160
X,Y=map(int,input().split())
N=(X+Y)//3
import sys
sys.setrecursionlimit(10**8)
A=X-N
B=Y-N
No=False
if (X+Y)%3!=0 or X<N or Y<N:
    No=True
ans=1
C=min(A,B)
for i in range(0, C):
    ans*=N-i
    ans%=(10**9+7)
def inv(i, p, q):
    if q==1:
        return i%p
    if q%2==0:
        x=inv(i, p,q//2)
        return (x**2)%p
    else:
        x=inv(i, p,q//2)
        return (x**2*i)%p
tmp=1
for i in range(C):
    tmp*=(i+1)
    tmp%=(10**9+7)
iv=inv(tmp, 10**9+7,10**9+5)
ans=ans*iv%(10**9+7)
if No:
    print(0)
else:
    print(ans)

Measured memory_bytes: 38768
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    int n; cin>>n;
    int a[n]; int hash[n+1]={0};
    for(int i=1;i<n;i++)
    {
        cin>>a[i];
        hash[a[i]]++;
    }
    for(int i=1;i<=n;i++) cout<<hash[i]<<"\n";
    return 0;
}

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

using namespace std;

typedef long long ll;

int n;
int arr[1000002];
int ans, exist1;
int isOdd;

int main(){
    scanf("%d", &n);
    for(int i=1; i<=n; i++){
        scanf("%1d", &arr[i]);
        arr[i]--;

        if(arr[i] == 1) exist1 = 1, isOdd ^= !((i-1) & (n-i));
    }
    if(isOdd){ printf("1"); return 0; }

    if(!exist1){
        for(int i=1; i<=n; i++){
            if(arr[i] == 2) isOdd ^= !((i-1) & (n-i));
        }
        if(isOdd) printf("2");
        else printf("0");
        return 0;
    }

    printf("0");
}


Measured memory_bytes: 4096
#include<bits/stdc++.h>
typedef long long int ll;
using namespace std;

void solve()
{
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	
	while(true) 
	{
		c -= b;
		if(c <= 0)
		{
			cout << "Yes\n";
			return ;
		}
		a -= d;
		if(a <= 0)
		{
			cout << "No\n";
			return ;
		}
	}
}

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


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

using namespace std;
#define ll long long
#define ld long double
#define  P pair<ll,ll>
#define FOR(i,n,m) for(ll i=n; i<(ll)m;i++)
#define FORr(i,m,n) for(ll i=n; i>=(ll)m; i--)
#define FORm(i,m) for(auto i=m.begin();i!=m.end();i++)
#define VEC2(x,a,b) vector<vector<ll>> x = vector<vector<ll>>(a,vector<ll>(b,0))
#define sortAl(v) sort(v.begin(),v.end())
#define sortAlr(v) sort(v.begin(),v.end()); reverse(v.begin(),v.end())
#define cinv(v,n,m) FOR(i,n,m) cin>>v.at(i)
#define coutv(v,n,m) FOR(i,n,m) cout<<v.at(i) <<" "; cout<<endl
#define cout(n) cout<<fixed<<setprecision(n)

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin>>n;
    while(n!=0){
      vector<string> s(n);
      FOR(i,0,n){
        cin>>s[i];
      }

      FOR(i,1,n){
        ll tmp_pos=0;
        FOR(j,0,s[i].size()){
          if(s[i][j] == '.'){
            tmp_pos = j;
          }
          else{
            s[i][tmp_pos] = '+';
          }
        }
      }
      //+から|をはやす
      FORr(i,1,n-1){
        ll tmp_pos = 0;
        FOR(j,0,s[i].size()){
          if(s[i][j] == '+'){
            tmp_pos = j;
            break;
          }
        }
        FORr(j,1,i-1){
          if(s[j][tmp_pos] == '.'){
            s[j][tmp_pos] = '|';
          }
          else{
            break;
          }
        }
      }
      // . を消す
      FOR(i,0,n){
        FOR(j,0,s[i].size()){
          if(s[i][j] == '.') s[i][j] = ' ';
        }
      }
      FOR(i,0,n){
        cout<<s[i]<<endl;
      }
      cin>>n;
    }
}



Measured memory_bytes: 3548