akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <cmath>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>
#include <sstream>

typedef  long long ll;
#define mop 1000000007
using namespace std;


int main() {
   

    int n;
    cin >> n;
    vector <int> h;
    for (int i=0;i<n;i++){
        int p;
        cin >> p;
        h.push_back(p);
    }
    h.push_back(0);
    h.push_back(1);
    ll ans = 0;
    int flag;
    while(true){
        flag = 0;
        for (int i=0;i<n+1;i++){
            if(h[i] != 0){
                h[i]--;
                flag = 1;
            }else{
                if(flag == 1 and h[i+1] != 0){
                    ans++;
                }
            }
        }
//        for (int i=0;i<n;i++){
//            cout << h[i] << " ";
//        }
//        cout << ans << endl;
        if(flag == 0){
            break;
        }
    }
    cout << ans << endl;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  string S;
  cin >> S;
  int a=S.size();
  int b=0;
  
  for(int i=0;i<S.size();i++){
    if(S.at(i)=='0'){
      b++;
    }
  }
  cout << min(b,a-b)*2 << endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int k,s,i,j,l;
int main(){
	scanf("%d%d",&k,&s);
	for (i=0;i<=k;i++){
		for (j=0;j<=k;j++){
			if (s-i-j<=k&&s-i-j>=0) l++;
		}
	}
	printf("%d\n",l);
}

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

ll N,M,V,P;
vector<ll> A;

bool solve(int ind){
  if(A[P-1]>A[ind]+M) return 0;
  ll sum=(P+(N-1-ind))*M;
  for(int i=P-1;i<ind;i++) sum+=A[ind]+M-A[i];
  if(sum>=M*V) return 1;
  else return 0;
}

int main(){
  cin>>N>>M>>V>>P;
  A.resize(N);
  rep(i,N){
    cin>>A[i];
  }
  sort(A.rbegin(),A.rend());
  A.push_back(-1e18);

  int ok=P-1,ng=N;
  while(abs(ok-ng)>1){
    int mid=(ok+ng)/2;
    if(solve(mid)) ok=mid;
    else ng=mid;
  }
  cout<<ok+1<<endl;
  return 0;
}

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

#define dump(x) cout << (x) << '\n'
#define Int int64_t
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
 
Int INF = 1e18;
int inf = 1e9;
Int mod = 1e9+7;

int main() {
    Int k, n;
    cin >> k >> n;
    vector<Int> a(n);
    for (Int i = 0; i < n; i++) {
        cin >> a[i];
    }
    vector<Int> b;
    for (Int i = 0; i < n - 1; i++) {
        b.push_back(a[i + 1] - a[i]);
    }
    b.push_back(a[0] + k - a[n - 1]);
    sort(all(b));
    Int res = 0;
    for (Int i = 0; i < (Int)b.size() - 1; i++) {
        res += b[i];
    }
    dump(res);
    return 0;
}

Measured memory_bytes: 3956
#define _USE_MATH_DEFINES
#include<iostream>
#include<cstring>
#include<string>
#include<cmath>
#include<vector>
#include<algorithm>
#include<iterator>
#include<sstream>
#include<iomanip>
#include<map>
#include<queue>
#include<deque>
#include<fstream>
#include<random>

#define rep(i, n) for (ll i = 0; i < n; i++) 
#define rrep(i, n) for(ll i = n-1; i>=0; i--)
#define range(i, n, m) for (ll i = n; i < m; i++) 
#define rrange(i, n, m) for (ll i = n - 1; i => m; i--) 
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define vl vector<ll>
#define vvl vector<vector<ll> >
#define vp vector<pair<ll, ll> >
#define vvp vector<vector<pair<ll, ll> > >
#define First first
#define Second second.first
#define Third second.second
//#define MOD 998244353
#define MAX 100000

typedef long long int ll;
typedef unsigned long long int ull;

using namespace std;

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

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


	ll N;
	cin >> N;

	ll count = 0;

	rep(i, (ll)log10(N)) {
		if (i % 2 == 0) {
			count += 9 * pow(10, i);
		}
	}

	if (ll(log10(N)) % 2 == 0) {
		count += (N - pow(10, (ll)log10(N))) + 1;
	}


	cout << count << endl;



	return 0;
}



Measured memory_bytes: 888
N = int(input())

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

divs = make_divisors(N)

ans = 0

for d in divs:
    if d == 1:
        continue
    m = d - 1
    if N // m == N % m:
        ans += m

print(ans)




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



int main(){
	int N,M;
	cin>>N>>M;
	vector<pair<int,int>> E(M);
	
	for(int i=0;i<M;i++){
		cin>>E[i].second>>E[i].first;
	}
	sort(E.begin(),E.end());
	
	int ans = 0;
	int now = 0;
	for(int i=0;i<M;i++){
		if(E[i].first>now&&E[i].second>=now){
			ans++;
			now=E[i].first;
		}
	}
	
	cout<<ans<<endl;
	
	return 0;
}


Measured memory_bytes: 1024
fun main(args: Array<String>) {
    var (N,M) = readLine()!!.split(" ").map(String::toInt)
    
    var user = (1..N).map{i->
        var (a,b) = readLine()!!.split(" ").map(String::toLong)
        Pair(a,b)
    }.toMutableList()
     var point = (1..M).map{i->
        var (a,b) = readLine()!!.split(" ").map(String::toLong)
        Pair(a,b)
    }.toMutableList()
    
    for(u in user){
        var dist = point.map{p->
            Math.abs(u.first-p.first)+ Math.abs(u.second - p.second)
        }.toList()
        println(dist.indexOf(dist.min()!!)+1)
    }
}


Measured memory_bytes: 36020
package main

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

func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	t, _ := strconv.Atoi(sc.Text())
	return t
}

func main() {
	var N, X int
	fmt.Scan(&N, &X)
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	A := make([]int, N)
	for i := range A {
		A[i] = nextInt(sc)
	}
	A = append(A, X)
	sort.Ints(A)
	intervals := make([]int, 0)
	for i := 1; i < len(A); i++ {
		intervals = append(intervals, A[i]-A[i-1])
	}
	ans := intervals[0]
	for i := 1; i < len(intervals); i++ {
		ans = gcd(ans, intervals[i])
	}
	fmt.Println(ans)
}

func gcd(a, b int) int {
	if a%b == 0 {
		return b
	}
	return gcd(b, a%b)
}


Measured memory_bytes: 6144
import Control.Monad (replicateM)

main = do
    n <- readLn
    if n == 0 then return () else do
        xs <- replicateM n (readLn) :: IO [Int]
        print $ solve xs
        main

solve :: [Int] -> Int
solve (x:xs) = solve' xs 0 [(x,1)]
    where
    -- end
    solve' [] _ ps = sum $ map snd $ filter ((==0) . fst) $ ps
    -- even turn
    solve' (x:xs) 0 ((y,n):[]) 
        | x == y = solve' xs 1 ((x,n+1):[])
        | x /= y = solve' xs 1 ((x,n+1):[])
    solve' (x:xs) 0 ((y,n):(z,m):ps) 
        | x == y = solve' xs 1 ((x,n+1):(z,m):ps)
        | x /= y = solve' xs 1 ((x,m+n+1):ps)
    -- odd turn
    solve' (x:xs) 1 ((y,n):ps) 
        | x == y = solve' xs 0 ((x,n+1):ps)
        | x /= y = solve' xs 0 ((x,1):(y,n):ps)

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

int main() {
    #ifdef TooLazy
        freopen("A.txt", "r", stdin);
    #endif /// TooLazy

    ll n, t, ans = 0;

    cin >> n >> t;

    ll ara[n+5];

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

    sort(ara,ara+n);

    for(int i=0; i<n-1; i++) {
        if(ara[i] + t > ara[i+1]) {
            ans += ara[i+1] - ara[i];
        }
        else {
            ans += t;
        }
    }

    cout << ans+t << "\n";

    return 0;

}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
#define erep(i,n) for(int i = 0;i<=n;i++)
#define rep1(i,n) for(int i = 1;i<n;i++)
#define erep1(i,n) for(int i = 1;i<=n;i++)
typedef long long ll;
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstring vector<string>
#define vdouble vector<double>
#define vll vector<ll>
#define vbool vector<bool>
#define INF 100000000000000009
#define int long long
using P = pair<int,int>;
vvint to;
vint ans;

void dfs(int v,int p = -1){
    for(u:to[v]){
      if(u == p) continue;
      ans[u] += ans[v];
      dfs(u,v);
    }
}

signed main(){
    int n,q;
    cin >> n >> q;
    to.resize(n);
    rep(i,n-1){
        int a,b;
        cin >> a >> b;
        a--;
        b--;
        to[a].push_back(b);
        to[b].push_back(a);
    }
    ans.resize(n);
    rep(i,q){
        int p,x;
        cin >> p >> x;
        p--;
        ans[p] += x;
    }
    dfs(0);
    rep(i,n){
        cout << ans[i] << " "; 
    }
}

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

using namespace std;

#define YES cout << "YES" << endl;
#define NO  cout << "NO"  << endl;
#define Yes cout << "Yes" << endl;
#define No  cout << "No"  << endl;
 
#define INF INT_MAX
#define MOD 1000000007
#define PI  acos(-1)

using ll  = long long;
using ull = unsigned long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rrep(i, n) for (ll i = (n)-1; i >= 0; i--)

int main(int argc, char *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    int H, W;
    cin >> H >> W;

    int tmp1 = 0;
    char tmp2 = 'A';
    rep (i, H) {
        rep (j, W) {
            string str;
            cin >> str;
            if (str == "snuke") {
                tmp1 += i+1;
                tmp2 += j;
                break;
            }
        }
    }

    cout << tmp2 << tmp1 << endl;


    return 0;
}


Measured memory_bytes: 256
import math
from collections import deque
from collections import defaultdict

import itertools as it

#自作関数群
def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()
def factorization(n):
	res = []
	if n%2==0:
		res.append(2)
	for i in range(3,math.floor(n//2)+1,2):
		if n%i==0:
			c = 0
			for j in res:
				if i%j==0:
					c=1
			if c==0:
				res.append(i)
	return res
def fact2(n):
	p = factorization(n)
	res = []
	for i in p:
		c=0
		z=n
		while 1:
			if z%i==0:
				c+=1
				z/=i
			else:
				break
		res.append([i,c])
	return res
def fact(n):#階乗
	ans = 1
	m=n
	for _i in range(n-1):
		ans*=m
		m-=1
	return ans
def comb(n,r):#コンビネーション
	if n<r:
		return 0
	l = min(r,n-r)
	m=n
	u=1
	for _i in range(l):
		u*=m
		m-=1
	return u//fact(l)
def combmod(n,r,mod):
	return (fact(n)/fact(n-r)*pow(fact(r),mod-2,mod))%mod
def printQueue(q):
	r=copyQueue(q)
	ans=[0]*r.qsize()
	for i in range(r.qsize()-1,-1,-1):
		ans[i] = r.get()
	print(ans)
class UnionFind():
	def __init__(self, n):
		self.n = n
		self.parents = [-1]*n

	def find(self, x): # root
		if self.parents[x]<0:
			return x
		else:
			self.parents[x] = self.find(self.parents[x])
			return self.parents[x]

	def union(self,x,y):
		x = self.find(x)
		y = self.find(y)

		if x==y:
			return

		if self.parents[x]>self.parents[y]:
			x,y = y,x

		self.parents[x]+=self.parents[y]
		self.parents[y]=x

	def size(self,x):
		return -1*self.parents[self.find(x)]

	def same(self,x,y):
		return self.find(x)==self.find(y)

	def members(self,x): # much time
		root = self.find(x)
		return [i for i in range(self.n) if self.find(i)==root]

	def roots(self):
		return [i for i,x in enumerate(self.parents) if x<0]

	def group_count(self):
		return len(self.roots())

	def all_group_members(self):
		return {r: self.members(r) for r in self.roots()} # 1~n
def bitArr(n):#ビット全探索
	x = 1
	zero = "0"*n
	ans = []
	ans.append([0]*n)
	for i in range(2**n-1):
		ans.append(list(map(lambda x:int(x),list((zero+bin(x)[2:])[-1*n:]))))
		x+=1
	return ans;
def arrsSum(a1,a2):
	for i in range(len(a1)):
		a1[i]+=a2[i]
	return a1
def maxValue(a,b,v):
	v2 = v
	for i in range(v2,-1,-1):
		for j in range(v2//a+1): #j:aの個数
			k = i-a*j
			if k%b==0:
				return i
	return -1
def copyQueue(q):
	nq = queue.Queue()
	n = q.qsize()
	for i in range(n):
		x = q.get()
		q.put(x)
		nq.put(x)
	return nq
def get_sieve_of_eratosthenes(n):
	#data = [2]
	data = [0,0,0]
	for i in range(3,n+1,2):
		data.append(i)
		data.append(0)
	for i in range(len(data)):
		interval = data[i]
		if interval!=0:
			for j in range(i+interval,n-1,interval):
				data[j] = 0
	#ans = [x for x in data if x!=0]
	ans = data[:]
	return ans

s = input()

f1 = s[0]=="A"

f2 = s[2:-1].count("C")==1

t=""
for i in s:
	if i!="A" and i!="C":
		t+=i

f3 = t == t.lower()

if f1*f2*f3:
	print("AC")
else:
	print("WA")

Measured memory_bytes: 3444
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		ArrayList<Long> nums = new ArrayList<Long>();
		Scanner sc 	   = new Scanner(System.in);
		long N = sc.nextInt();
		long height=0,width=0;
		for(int i=0;i<N;i++) 
		{
			long a = sc.nextInt();
			nums.add(a);
		}
		Collections.sort(nums);
		Collections.reverse(nums);
		
		for(int i=1;i<nums.size();i++) 
		{
			long a = nums.get(i-1);
			long b = nums.get( i );
			if(a==b) 
			{
				 if		(height == 0)  height	 =	a;
				 else if(height != 0) { width	 =	a; break; }
				 nums.remove(i);nums.remove(i-1);i--;

			}
		}
		 System.out.println(height * width);
		
	}

}


Measured memory_bytes: 63048
#include <iostream>

using namespace std;

int main(){
	int W, H, x, y, r;

    cin >> W >> H >> x >> y >> r;
	
    if(x-r >= 0 && x+r <= W && y-r >= 0 && y+r <= H){
        cout << "Yes" << "\n";
    }else{
        cout << "No"  << "\n";
    }
    return 0;
}


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

int main(){
  int N, A, B;
  cin >> N >> A >> B;
  if (N * A > B){
    cout << B << endl;
  }
  else
  {
    cout << A * N << endl;
  }
  
}

Measured memory_bytes: 3636
/* ----------------------- reclone_rk --------------------------------------------*/ 
#include<bits/stdc++.h>
using namespace std;
#define int long long int
const int mod=1e9+7;

#define FastRead ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define prq priority_queue<int>
#define prqp priority_queue<pair<int,int>>
#define vtr vector<int>
#define INF INT_MAX
#define NINF INT_MIN
#define endl "\n"
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define pvtr vector<pair<int,int>>
#define FOR(i,a,n) for (int i=(a);i<=(n);++i)

int gcd(int a, int b){ if(a == 0) return b; return gcd(b%a, a);}
int MOD(int n){ return ((n%mod)+mod)%mod;}
int power(int a,int b){ if(b==0)return 1LL;int s=power(a,b/2LL);s*=s;s%=mod;if(b&1LL)return (s*a)%mod;return s;}
int inv(int a){return power(a,mod-2);}
int nCr(int n,int r){if(r>n)return 0LL;if(n-r<r)r=n-r;int ans=1;for(int i=0;i<r;i++){ans*=(n-i);ans=MOD(ans);ans*=inv(i+1);ans=MOD(ans);}return ans;}

int pi = 3.14159265358979323846;
signed main()
{   
    int a, b, c;
    cin>>a>>b>>c;
    int f = 0, s = 0;
    if(a == 5)
        f++;
    else if(a == 7)
        s++;

    if(b == 5)
        f++;
    else if(b == 7)
        s++;

    if(c == 5)
        f++;
    else if(c == 7)
        s++;

    if(f == 2 && s == 1)
        cout<<"YES"<<endl;
    else
        cout<<"NO"<<endl;
	return 0;
}
// 56425719433005567605

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<climits>
#include<queue>
#include<map>
#include<set>
#include<vector>
#include<list>
#include<stack>
#include<cstring>
#include<string>
using namespace std;

const int latte[8]={4,1,4,1,2,1,2,1},pri[8]={0,5,1,7,3,6,2,4};

int main(){
	int human[8];
	while(cin>>human[0]){
		int ansv=1000000000,anspri=10,ans;
		for(int i=1;i<8;i++){
			cin>>human[i];
		}
		for(int i=0;i<8;i++){
			int v=0;
			for(int j=0;j<8;j++){
				v += max(0,human[j]-latte[(i+j)%8]);
			}
			if(ansv>v || (ansv==v && anspri<pri[i])){
				ansv = v; anspri = pri[i]; ans = i;
			}
		}
		printf("%d",latte[ans]);
		for(int i=1;i<8;i++){
			printf(" %d",latte[(ans+i)%8]);
		}puts("");
	}
	return 0;
}

Measured memory_bytes: 1144
//C
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

//ここまで毎回include
//以下プログラム

using namespace std;

long gcd(long a, long b) {
	long r = -1;
	if (a < b) {
		swap(a, b);
	}
	while (r != 0) {
		r = a % b;
		if (r == 0) {
			return b;
		}
		else {
			a = b;
			b = r;
		}
	}
}

int main() {
	int n;
	cin >> n;
	vector<long> data(n);
	for (int i = 0; i < n; i++) {
		cin >> data.at(i);
	}
	long result = data.at(0);
	for (int i = 1; i < n; i++) {
		result = gcd(result, data.at(i));
	}
	cout << result << endl;
}



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

int main() {
	int n[100] = {0};
	int a, b;
	int f = 0;
	while ( cin >> a >> b ) {
		n[a - 1]++;
		n[b - 1]++;
		if ( a == 0 ) {
			f = 0;
			for ( int i = 0; i < 100; i++ ) {
				if ( ( i < 2 && n[i] % 2 == 0 ) || ( i >= 2 && n[i] % 2 == 1 ) )
					f = 1;
				n[i] = 0;
				
			}
			if ( f == 0 ) cout << "OK" << endl;
			else cout << "NG" << endl;
		}
	}

	
}

Measured memory_bytes: 1156
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#include <cmath>
#include <complex>
#include <map>
#include <climits>
#include <sstream>
using namespace std;

#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define EPS 1e-8
#define F first
#define S second
#define mkp make_pair

static const double PI=6*asin(0.5);
typedef long long ll;
typedef complex<double> CP;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vint;
static const int INF=1<<24;

template <class T>
void initvv(vector<vector<T> > &v,int a,int b, const T  &t = T()){
	v.assign(a,vector<T>(b,t));
}

//v.erase(unique(v.begin(),v.end()),v.end());
int main(){
	int n;
	cin>>n;
	rep(i,n){
		string s;
		cin>>s;
		if(s.substr(0,2)==">'"&&s.substr(s.size()-1,1)=="~"){
			s=s.substr(2);
			s=s.substr(0,s.size()-1);
			bool f=true;
			if(s.size()==0) f=false;
			if(s.size()&&s[0]!='='){
				f=false;
			}
			while(s.size()>1){
				if(s[0]==s[s.size()-1]&&s[0]=='='){
					s=s.substr(1,s.size()-2);
				}
				else{
					f=false;
					break;
				}
			}
			if(f){
				if(s[0]=='#'){
					cout<<"A\n";
				}
				else cout<<"NA\n";
			}
			else{
				cout<<"NA\n";
			}
		}
		else if(s.substr(0,2)==">^"&&s.substr(s.size()-2,2)=="~~"){
			s=s.substr(2);
			s=s.substr(0,s.size()-2);
			bool f=true;
			if(s.size()<2) f=false;
			if(s.size()>=2&&s.substr(0,2)!="Q=") f=false;
			while(s.size()>=2){
				if(s.substr(0,2)=="Q="){
					s=s.substr(2);
				}
				else{
					f=false;
					break;
				}
			}
			if(f){
				cout<<"B\n";
			}
			else cout<<"NA\n";
		}
		else{
			cout<<"NA\n";
		}
	}
}

Measured memory_bytes: 1216
#!/usr/bin/env python3
import bisect

def main():
    N = int(input())

    a = [3 ** 3 * 5, 3 ** 3 * 7, 3 * 5 * 7, 3 * 5 * 11, 3 * 5 * 13]
    a.sort()

    print(bisect.bisect_right(a, N))


if __name__ == '__main__':
    main()



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

int main() {
  int n, y;
  char x;
  cin >> n;
  vector<bool> cards(52, false);
  for (int i = 0; i < n; i++) {
    cin >> x >> y;
    if (x == 'S') cards.at(y - 1) = true;
    else if (x == 'H') cards.at(y + 12) = true;
    else if (x == 'C') cards.at(y + 25) = true;
    else if (x == 'D') cards.at(y + 38) = true;
  }
  for (int i = 0; i < 52; i++) {
    if (i < 13 && cards.at(i) == false) cout << "S " << i + 1 << endl;
    else if ((13 <= i && i < 26) && cards.at(i) == false) cout << "H " << i - 12 << endl;
    else if ((26 <= i && i < 39) && cards.at(i) == false) cout << "C " << i - 25 << endl;
    else if (39 <= i && cards.at(i) == false) cout << "D " << i - 38 << endl;
  }
}


Measured memory_bytes: 3008
#include<bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define INF LLONG_MAX
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
#define vi vector<int>
#define IP pair<int,P>
#define PI pair<P,int>
#define PP pair<P,P>
#define Yes(f){cout<<(f?"Yes":"No")<<endl;}
#define YES(f){cout<<(f?"YES":"NO")<<endl;}


signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(20);

    int h,n;
    cin>>h>>n;
    int s=0;
    rep(i,n){
        int a;
        cin>>a;
        s+=a;
    }

    Yes(h<=s);


}

Measured memory_bytes: 256
#include <stdio.h>

#define MAX 100005
#define NIL -1

typedef struct {int p, l, r;} Node;

Node T[MAX];
int n, D[MAX];

void print(int u) {
  int i,c;
  printf("node %d: ",u);
  printf("parent = %d, ",T[u].p);
  printf("depth = %d, ",D[u]);

  if( T[u].p == NIL ) printf("root, ");
  else if( T[u].l == NIL ) printf("leaf, ");
  else printf("internal node, ");

  printf("[");

  for(i=0, c=T[u].l; c != NIL; i++, c=T[c].r) {
    if(i) printf(", ");
    printf("%d",c);
  }
  printf("]\n");
}

void rec(int u, int p) {
  D[u] = p;
  if(T[u].r != NIL) rec(T[u].r,p);
  if(T[u].l != NIL) rec(T[u].l,p+1);
}

int main(void) {
  int i,j,d,v,c,l,r;
  scanf("%d",&n);
  for(i=0;i<n;i++) T[i].p = T[i].l = T[i].r = NIL;
  for(i=0;i<n;i++) {
    scanf("%d %d",&v,&d);
    for(j=0;j<d;j++) {
      scanf("%d",&c);
      if(j==0) T[v].l=c;
      else T[l].r =c;
      l = c;
      T[c].p = v;
    }
  }
  for(i=0;i<n;i++) {
    if(T[i].p == NIL) r = i;
  }
  
  rec(r,0);
  
  for(i=0;i<n;i++) print(i);
  
  return 0;
}


Measured memory_bytes: 6368
s = int(input())
A = [s]
i = 0
while True:
  if A[i] % 2 == 0:
    A.append(A[i]/2)
  else:
    A.append(A[i]*3+1)
  if A[i+1] in A[:i]:
    ans = i+1
    break
  i += 1
print(ans +1)
  


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

using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, x) for(int i=1;i<=(int)(x);i++)
#define all(x) (x).begin(),(x).end()

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

    double o = 0;

    reps(i, n) {
        if (i % 2 != 0) {
            o++;
        }
    }

    double a = (o / n);

    cout << a << endl;
}


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

int main()
{
	int n,x;
	cin>>n>>x;
	int m[n];
	int sum=0;
	for (int i=0;i<n;i++)
	{
		cin>>m[i];
		sum+=m[i];
	}
	int count=0;
	
	count+=n;
	x-=sum;
	sort(m,m+n);
	while (x>0)
	{
		x-=m[0];
		count++;
	}
	if (x<0)
	count--;
	
	cout<<count;
	
	
	
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main(){

  int N;
  cin>>N;
  int N1[N];
  int i;
  int j;
  int k;
  for(i=0;i<=N-1;i++){
  
    cin>>N1[i];
  }
  std::sort(N1,N1+N);
  int ans=0;
  if(N<=2){
    
    cout<<0;
    return 0;
  }
  for(i=0;i<=N-3;i++){
  
    for(j=i+1;j<=N-2;j++){
    
      if(N1[i]==N1[j])continue;
      for(k=j+1;k<=N-1;k++){
      
        if(N1[j]==N1[k])continue;
        if(N1[i]+N1[j]>N1[k]){
          //cout<<N1[i]<<","<<N1[j]<<","<<N1[k]<<endl;
          ans++;
        }
      }
    }
  }
  cout<<ans;
}

Measured memory_bytes: 3604
// In the name of God

#include <bits/stdc++.h>

using namespace std;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	int ans = 0;
	int s = 0;
	for(int i=0;i<n;i++) {
		int x;
		cin >> x;
		ans += x*s;
		s += x;
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{
    int N; cin>>N;
    int ans;
    for(int i=N;i>=1;i--){
        int x=sqrt(i);
        if(x*x==i){ 
            ans=i;
            break;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define PF push_front
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double
#define pii pair<int,int>
#define pll pair<LL,LL>
#define vi vector<int>
#define vl vector<LL>
#define vii vector<vi>
#define vll vector<vl>

const double pi = 3.14159265358979323846264;
const int mod=1000000007;

int main(){
	int h,w,n;
    cin>>h>>w>>n;
    h=max(h,w);
    cout<<(n+h-1)/h<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
    using namespace std;
    #define ll long long int
    #define pb push_back
    #define mk make_pair
    #define ft first
    #define sc second
    #define ppb pop_back
    #define sz size
    #define forn(i,a,n) for(i=a;i<n;i++)
    #define M 1000000007
    #define inf 2e18
    
    int main() {
 
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    ll n;
    cin>>n;
    vector<ll> v(n);
    for(ll i=0;i<n;i++)cin>>v[i];
    vector<ll> c(3,0);
    ll ans=1;
    for(ll i=0;i<n;i++){
        ll ctr=0,id=-1;
        for(ll j=0;j<3;j++)
            if(v[i]==c[j]){ctr++; id=j;}
        if(id==-1){
            cout<<"0"; return 0;
        }
        ans = (ans*ctr)%M;
        c[id]++;
    }
    cout<<ans;
    return 0;
    } 

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
using namespace std;
using Graph = vector<vector<int>>;
typedef pair<int,int> P;
typedef long long ll;

int main(){
    vector<ll> a(3); rep(i,3) cin >> a[i];
    int k; cin >> k;

    sort(all(a));

    rep(i,k) a[2] *= 2;

    ll ans = 0;

    rep(i,3) ans += a[i];

    cout << ans << endl;
}

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

int main() {

int a,b;
cin >> a >> b;
if(b%2==0&&a*2<=b&&b<=a*4) {cout<<"Yes"<<endl;}
else
{
  cout<<"No"<<endl;
}




}
/*vector <int> a(3);
for (int i = 0; i < n; i++) {
    cin >> a.at(i);
  }*/

Measured memory_bytes: 3648
#![allow(non_snake_case, unused_mut)]
use petgraph::unionfind::UnionFind;
use proconio::marker::Usize1;
//use std::collections::HashMap;
use std::collections::HashSet;

fn main() {
    proconio::input! {
        N:usize, M:usize,K:usize,
        AB:[(Usize1,Usize1);M],
        CD:[(Usize1,Usize1);K]
    }
    let mut tree: UnionFind<usize> = UnionFind::new(N);
    let mut friends = vec![HashSet::new(); N];
    let mut blocks = vec![HashSet::new(); N];
    for &(a, b) in AB.iter() {
        tree.union(a, b);
        friends[a].insert(b);
        friends[b].insert(a);
    }
    for &(c, d) in CD.iter() {
        if tree.find(c) == tree.find(d) {
            blocks[c].insert(d);
            blocks[d].insert(c);
        }
    }
    let mut sizes = vec![0usize; N];
    for i in 0..N {
        sizes[tree.find(i)] += 1;
    }
    for i in 0..N {
        let ans = sizes[tree.find(i)] - 1 - friends[i].len() - blocks[i].len();
        print!("{} ", ans);
    }
}


Measured memory_bytes: 30984
#include <iostream>
#include <vector>
#include <deque>
#include <set>
#include <cmath>
#include <bits/stdc++.h>
#include <limits>

#define MOD 1000000007

using namespace std;

long long dfs(int i, int n, vector<vector<long long>>& f, vector<vector<long long>>& p, vector<long long>& current_state)
{
    if(i == 10){
        long long sum_current_state = 0;
        for(int j = 0; j < 10; j++)
            sum_current_state += current_state[j];
        
        if(sum_current_state == 0)
            return LLONG_MIN;
        
        long long profit = 0;
        for(int j = 0; j < n; j++){
            long long count = 0;
            for(int k = 0; k < 10; k++)
                if(f[j][k] == 1 && current_state[k] == 1)
                    count++;
            profit += p[j][count];
        }
        
        return profit;
    }
    
    long long max_profit = LLONG_MIN;
    current_state[i] = 0;
    max_profit = max(max_profit, dfs(i+1, n, f, p, current_state));
    current_state[i] = 1;
    max_profit = max(max_profit, dfs(i+1, n, f, p, current_state));
    
    return max_profit;
}

int main(void){
    // Your code here!
    long long n;
    vector<vector<long long>> f;
    vector<vector<long long>> p;
    vector<long long> current_state(10, 0);
    
    cin >> n;
    for(int i = 0; i < n; i++){
        vector<long long> temp_vector(10, 0);
        for(int j = 0; j < 10; j++)
            cin >> temp_vector[j];
        f.push_back(temp_vector);
    }
    for(int i = 0; i < n; i++){
        vector<long long> temp_vector(10, 0);
        for(int j = 0; j < 11; j++)
            cin >> temp_vector[j];
        p.push_back(temp_vector);
    }
    
    cout << dfs(0, n, f, p, current_state) << endl;
}

Measured memory_bytes: 256
tmp = list(map(int, input().split()))
n = tmp[0]
m = tmp[1]

s = [1] * (n+1)
for i in range(m):
  m = int(input())
  s[m] = 0

for i in range(2, n+1):
  if s[i] != 0:
    s[i] = s[i-1] + s[i-2]

print(s[n] % 1000000007)

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

int main() {
  
  int N;
  cin >> N;
  
  vector<int> d(N);
  
  for(int i = 0;i < N;++i){
    cin >> d[i];
  }
  
  int num;
  int num2;
  int num3 = 0;
  
  for(int i = 0;i < N;++i){
    num2 = 0;
    for(int j = i + 1;j < N;++j){
      num = d[i] * d[j];
      num2 = num + num2;
    }
    num3 = num2 + num3;
  }
  cout << num3 << endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
const int MAXN = 2e5 + 1;
int n, m, i, j, k, z;
long long a[MAXN], b[MAXN];
signed main()
{
	ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
    cin >> n >> m >> k;
	for (i = 1; i <= n; ++i)
		cin >> a[i], a[i] += a[i - 1];
	for (i = 1; i <= m; ++i)
		cin >> b[i], b[i] += b[i - 1];
	z = 0, i = 0, j = m;
	while (a[i] <= k && i <= n)
	{
		while (b[j] > k - a[i])
			--j;
		z = max(z, i + j);
		++i;
	}
	cout << z;
}

Measured memory_bytes: 6768
//Card Eater

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define int long long
#define rep(i,x,y) for(ll i=x;i<y;i++)
#define nvarep(n,a) ll n;cin>>n;vector<ll>a(n);rep(i,0,n)cin>>a[i]
#define vecrep(n,a,type) vector<type>a(n);rep(i,0,n)cin>>a[i]
#define YN(flag) (flag?"Yes":"No")
#define lcm(a,b) (a/__gcd(a, b)*b)
#define range(a) (a).begin(),(a).end() 
#define pb push_back
#define mp make_pair
#define nnn "\n"
#define spa " "
using p = pair<ll,ll>;
using graph = vector<vector<ll>>;
const int inf = 2147483647;//2*10^9
const ll INF = 9223372036854775807;//9*10^18

signed main (){
    nvarep(n,a);
    map<int,int>m;
    rep(i,0,n)m[a[i]]++;
    for(auto i:m){
        while(i.second>2){
            i.second-=2;
            m[i.first]-=2;
            n-=2;
        }
    }
    int t=0;
    for(auto i:m)if(i.second>1)t++;
    cout<<n-t-(t%2?1:0)<<nnn;
    return 0;
}

Measured memory_bytes: 10332
#include<bits/stdc++.h>
using namespace std;
 
#define int long long
#define pb push_back 
#define pf push_front 
#define mp make_pair
#define fr first
#define sc second
#define Rep(i, n) for ( int i = 0 ; i < (n); i++ )
#define All(v) v.begin(), v.end()
 
typedef pair<int, int> Pii; typedef pair<int, Pii> Pip;
const int INF = 1107110711071107;
 
int N, m;
vector<Pii> d;
unordered_map<int, int> dp[1001][1001];
 
int dfs(int pre, int now, int n) {
  if ( n == m ) {
    return (now-pre + (N+1)-pre);
  }
  if ( dp[pre][now][n] > 0 ) return dp[pre][now][n];
 
  int ret = dfs(min(pre, d[n].sc), d[n].fr, n+1) + (d[n].fr-now);
  ret = min(ret, dfs(d[n].sc, d[n].fr, n+1) + (now-pre + d[n].fr-pre));
 
  return dp[pre][now][n] = ret;
}
 
signed main() {
  cin >> N >> m;
 
  Rep(i, m) {
    int c, b;
    cin >> c >> b;
    d.pb(Pii(b, c));    
  }
 
  sort(All(d));
 
  if ( m == 0 ) cout << N+1 << endl;
  else cout << dfs(d[0].sc, d[0].fr, 1) + d[0].fr << endl;
}

Measured memory_bytes: 65728
#include <iostream>
#include <string>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#include <functional>
#include <utility>

#define int long long

using P = std::pair<int, int>;
int n;
const int MAX_N = 1e5 + 100;

int C[MAX_N];
int D[MAX_N];
std::vector<std::vector<int>> edges;
std::vector<std::vector<int>> children;

void dfs(int idx, int p, int d) {
    D[idx] = d;
    for(auto i : edges[idx]) {
        if(i == p) {
            continue;
        }
        children[idx].push_back(i);
        dfs(i, idx, d + 1);
    }
}

signed main() {
    std::cin >> n;

    for(int i = 0; i < n; ++i)
        std::cin >> C[i];
    
    if(n == 2) {
        if(C[0] == C[1]) {
            std::cout << "YES" << std::endl;
        }else {
            std::cout << "NO" << std::endl;
        }

        return 0;
    }

    edges.resize(n);
    children.resize(n);
    for(int i = 0; i < n -1 ; ++i) {
        int a, b;

        std::cin >> a >> b;
        --a, --b;

        edges[a].push_back(b);
        edges[b].push_back(a);
    }
    int b = 0;
    for(int i = 0; i < n; ++i) {
        if(edges[i].size() != 1) {
            b = i;
            break;
        }
    }
    dfs(b, -1, 0);

    std::priority_queue<P, std::vector<P>> que;

    for(int i = 0; i < n; ++i)
        que.push({D[i], i});
    
    int last = 0;
    while(!que.empty()) {
        auto p = que.top();que.pop();
        last = p.second;

        int sum = 0, max = 0;
        if(children[p.second].size() == 0) {
            continue;
        }
        for(auto i : children[p.second]) {
            int v = C[i];

            max = std::max(max, v);
            sum += v;
        }

        int s = 0;
        if(sum - max < max) {
            s = (sum - max);
        }else {
            s = sum / 2;
        }

        if(sum >= C[p.second] && sum - C[p.second] <= s) {
            C[p.second] -= sum - C[p.second];
        }else {
            std::cout << "NO" << std::endl;
            return 0;
        }
    }

    if(C[last] == 0) {
        std::cout << "YES" << std::endl;
    }else {
        std::cout << "NO" << std::endl;
    }
}

Measured memory_bytes: 21624
# AOJ 0123 Speed Skating Badge Test
# Python3 2018.6.18 bal4u

m500 = [ 35.5, 37.5, 40.0, 43.0, 50.0, 55.0, 70.0, 1000.0 ]
m1000 = [ 71.0, 77.0, 83.0, 89.0, 105.0, 116.0, 148.0, 1000.0 ]
clas = [ "AAA", "AA", "A", "B", "C", "D", "E", "NA" ]

while True:
	try: t500, t1000 = list(map(float, input().split()))
	except: break
	for i in range(len(m500)):
		if t500 < m500[i] and t1000 < m1000[i]:
			print(clas[i])
			break


Measured memory_bytes: 5572
#include <stdio.h>

int main(void) {
	int arr[100];
	int n, i;
	scanf("%d", &n);
	for (i=1; i<=n; i++)
	{
		scanf("%d", &arr[i-1]);
	}
	for (i=n; i>=2; i--)
	{
		printf("%d ", arr[i-1]);
	}
	printf("%d\n", arr[0]);
	return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
#include <string.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for(int i = m; i < n; i++) 
#define mod 1000000007
#define pi 3.1415926535
typedef long long ll;
typedef vector<int> ve;
int main(){
    string N;
    cin>>N;
    char a=N[N.size()-1];
    if(a=='2'||a=='4'||a=='5'||a=='7'||a=='9'){
        cout<<"hon"<<endl;
    }else if(a=='0'||a=='1'||a=='6'||a=='8'){
        cout<<"pon"<<endl;
    }else if(a=='3'){
        cout<<"bon"<<endl;
    }



    return 0;
}

Measured memory_bytes: 3628
n,m  = list(map(int,input().split()))
tmpa = [[] for _ in range(n)]
pyxs = []
i_id = [0] * (n+1)
ans  = [None] * m 

for i in range(m):
    p,y = list(map(int,input().split()))
    pyxs.append([p,y,i])
pyxs.sort(key=lambda x: x[1])

for p,y,x in pyxs:
    i_id[p] += 1
    ans[x] = '{:06}'.format(p) + '{:06}'.format(i_id[p])

for s in ans:
    print(s)

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

n = int(input())
s = input().split()[0]

ans = 0
for i in range(1000):
    num_str = str(i).zfill(3)
    a = s.find(num_str[0])
    if a==-1:
        continue
    b = s[a+1:].find(num_str[1])
    if b==-1:
        continue
    b += a+1
    c = s[b+1:].find(num_str[2])
    if c!=-1:
        ans += 1
print(ans)


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

int main() {
  int N, a, b;
  cin >> N;
  a = (N / 10) % 111;
  b = (N - 1000 * (N / 1000)) % 111;
  if (a == 0 || b == 0) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    string s;
    cin >> s;
    int even_pos_0 = 0,odd_pos_1 = 0,even_pos_1 = 0,odd_pos_0 = 0;
    for (int i = 0 ; i < s.size() ; i ++)
    {
        if (i % 2 == 0)
        {
            if (s[i] == '0') even_pos_0++;
            else
            even_pos_1++;
        }
        else
        {
            if (s[i] == '0') odd_pos_0++;
            else
            odd_pos_1++;
        }
    }
    if (even_pos_0 + odd_pos_1 >= even_pos_1 + odd_pos_0) cout << even_pos_1 + odd_pos_0;
    else cout << even_pos_0 + odd_pos_1;
    return 0;
}


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

int main(){
  char S[4];
  for(int i=0;i<4;i++){
    cin >> S[i];
  }
  
  if(S[0] == S[1] && S[2] == S[3]){
    if(S[1] == S[2] && S[0] == S[3]){
      cout << "No" << endl;
    }
    else{
      cout << "Yes" << endl;
    }
  }
  
  else if(S[0] == S[2] && S[1] == S[3]){
    if(S[0] == S[1] && S[2] == S[3]){
      cout << "No" << endl;
    }
    else{
      cout << "Yes" << endl;
    }
  }
  
  
  else if(S[0] == S[3] && S[1] == S[2]){
    if(S[0] == S[1] && S[2] == S[3]){
      cout << "No" << endl;
    }
    else{
      cout << "Yes" << endl;
    }
  }
  
  else{
    cout << "No" << endl;
  }
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int gcd(int a, int b, int c) {
    int t, max;
    if(a>=b) {
        t=b;
        b=a;
        a=t;
    }
    if(c<=b) {
        t=b;
        b=c;
        c=t;
    }
    if(a>=c) {
        t=c;
        c=a;
        a=t;
    }
    for(t=a; t>=1; t--) {
        if(a%t==0 && b%t==0 && c%t==0) return t;
    }
    return 0;
}


int main() {
    long long n, i, j, k, part, sum=0;
    cin>>n;
    for(i=1; i<=n; i++) {
        for(j=i; j<=n; j++) {
            for(k=j; k<=n; k++) {
                part = gcd(i,j,k);
                if(i==j && i==k) {
                    sum += part;
                    continue;
                }
                if((i==j && j!=k) || (k!=j && i==k) || (k==j && i!=k)) {
                    sum += 3*part;
                    continue;
                }
                if(i!=j && i!=k) {
                    sum += 6*part;
                    continue;
                }
            }
        }
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define elif else if
int a,b,c,d;
string s;
signed main()
{
	cin>>a>>b>>c>>d;
	cout<<(a-c)*(b-d);
}

Measured memory_bytes: 256
n, a, b = map(int, input().split())

MOD = 10 ** 9 + 7

def nCk(n, k):
    num = 1
    for i in range(n, n - k, -1):
        num *= i
        num %= MOD
    tmp = 1
    for i in range(1, k + 1):
        tmp *= i
        tmp %= MOD
    num *= pow(tmp, MOD - 2, MOD)
    return num

ans = pow(2, n, MOD) - 1
ans -= nCk(n, a)
ans -= nCk(n, b)
print(ans % MOD)

Measured memory_bytes: 9228
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		
		int sum = 700;
		
		if(S.charAt(0) == 'o') {
			sum += 100;
		}
		if(S.charAt(1) == 'o') {
			sum += 100;
		}
		if(S.charAt(2) == 'o') {
			sum += 100;
		}
		System.out.println(sum);
		
	}
}


Measured memory_bytes: 22740
D = gets.to_i
C = gets.split.map(&:to_i)
S = []
D.times{
	S << gets.split.map(&:to_i)
}
warn C.inspect
warn S.inspect

T = Array.new(D){rand(26)}

def last(d, i)
	r = d
	while r >= 0
		break if T[r] == i
		r -= 1
	end
	r
end

def full_score
	r = 0
	D.times{|d|
		r += S[d][T[d]]
		26.times{|l|
			r -= C[l] * (d - last(d, l))
		}
	}
	r
end

def diff(d, q)
	r = 0
	r -= S[d][T[d]]
	r += S[d][q]
	nd = d + 1
	while nd < D && T[nd] != T[d]
		nd += 1
	end
	r -= C[T[d]] * (d - last(d - 1, T[d])) * (nd - d)
	nd = d + 1
	while nd < D && T[nd] != q
		nd += 1
	end
	r += C[q] * (d - last(d, q)) * (nd - d)
	r
end

s = full_score
warn "score:#{s}"
100_000.times{
	d = rand(D)
	q = rand(26)
	dif = diff(d, q)
	if dif > 0
		s += dif
		T[d] = q
	end
}
puts T.map{|i|i + 1}



Measured memory_bytes: 14500
#!/usr/bin/python
# -*- coding: utf-8 -*-
import sys
import os
import math
import itertools
import heapq
import numpy as np
from collections import OrderedDict, deque, Counter
from bisect import bisect_left, bisect_right, insort_left, insort_right
sys.setrecursionlimit(10000)

dx = [1, 0, -1, 0]
dy = [0, 1, 0, -1]


def solve():
    N = int(input())
    A = sorted(list(map(int, input().split(" "))))
    B = sorted(list(map(int, input().split(" "))))
    C = sorted(list(map(int, input().split(" "))))

    cnt = 0
    for ele in B:
        cnt += bisect_left(A, ele) * (N - bisect_right(C, ele))

    print(cnt)


solve()


Measured memory_bytes: 31440
N = int(input())
P = list(map(int, input().split()))
num = 0
for i in range(N - 1):
    if i + 1 == P[i]:
        P[i], P[i + 1] = P[i + 1], P[i]
        num += 1
if N >= 2 and N == P[-1]:
    P[-1], P[-2] = P[-2], P[-1]
    num += 1
print(num)


Measured memory_bytes: 14008
#include <bits/stdc++.h>
using namespace std;
#define _MACRO(_1, _2, _3, NAME, ...) NAME
#define _repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define _rep(i,n) _repl(i,0,n)
#define rep(...) _MACRO(__VA_ARGS__, _repl, _rep)(__VA_ARGS__)
#define mp make_pair
#define pb push_back
#define all(x) begin(x),end(x)
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cerr<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cerr<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream &o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream &o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

#define INF 1120000000

// z-algorithm : a[i] = s[0,n) と s[i,n) の最長共通接頭辞の長さ O(N)
vector<int> zAlgorithm(const string &s){
  int n = s.size();
  vector<int> a(n+1,0);
  int i=1, j=0;
  while(i<n){
    while(i+j<n && s[j] == s[i+j]) j++;
    a[i] = j;
    if(j==0){i++; continue;}
    int k = 1;
    while(i+k<n && k+a[k]<j) a[i+k]=a[k], k++;
    i += k;
    j -= k;
  }
  return a;
}

int main(){
  string s;
  cin>>s;
  int n = s.size();

  if(all_of(all(s), [&](char c){return c == s[0];})){
    cout << n << "\n1\n";
    return 0;
  }

  auto zarr = zAlgorithm(s);
  bool perioded = false;
  rep(i,2,n) if(n%i==0 && zarr[i] == n-i) perioded = true;

  if(!perioded){
    cout << "1\n1\n";
    return 0;
  }

  vector<bool> lb(n+1,true), rb(n+1, true);
  reverse(all(s));
  auto rarr = zAlgorithm(s);

  auto exec = [&](vector<int> &z, vector<bool> &b){
    rep(i,1,n){
      int j = i;
      while(j<n){
        if(z[j] >= i) b[j+i] = false;
        else break;
        j += i;
      }
    }
  };

  exec(zarr, lb);
  exec(rarr, rb);

  int res = 0;
  rep(i,1,n) if(lb[i] && rb[n-i]) res++;
  assert(res>0);

  cout << "2\n" << res << endl;

  return 0;
}


Measured memory_bytes: 4740
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        final Scanner scanner = new Scanner(System.in);
        solve(scanner);
    }

    static void solve(Scanner scanner) {
        int N = scanner.nextInt(), M = scanner.nextInt();
        scanner.nextLine();
        long[][] nums = new long[N][3];
        for (int i = 0; i < N; i++) {
            nums[i] = Arrays.stream(scanner.nextLine().split(" ")).mapToLong(Long::parseLong).toArray();
        }
        long ans = Long.MIN_VALUE;
        for (int i = 0; i < 8; i++) {
            int x = (i & 4) > 0 ? 1 : -1;
            int y = (i & 2) > 0 ? 1 : -1;
            int z = (i & 1) > 0 ? 1 : -1;
            Arrays.sort(nums, Comparator.comparingLong(n -> -1 * (n[0] * x + n[1] * y + n[2] * z)));
            long xm = Math.abs(Arrays.stream(nums).mapToLong(n -> n[0]).limit(M).sum());
            long ym = Math.abs(Arrays.stream(nums).mapToLong(n -> n[1]).limit(M).sum());
            long zm = Math.abs(Arrays.stream(nums).mapToLong(n -> n[2]).limit(M).sum());
            ans = Math.max(ans, xm + ym + zm);
        }
        System.out.println(ans);
    }

}

Measured memory_bytes: 33616
fn main() {
    let k = read::<u64>();
    let mut ret = 0;
    for x in 1..k+1 {
        for y in 1..k+1 {
            for z in 1..k+1 {
                ret += gcd(x, gcd(y, z));
            }
        }
    }
    println!("{}", ret);
}

fn gcd(a: u64, b: u64) -> u64 {
    if b == 0 {
        a
    } else {
        gcd(b, a % b)
    }
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().parse().ok().unwrap()
}

Measured memory_bytes: 2156
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#define rep(i, n)   for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

int main(){
    ll a,b,c;  cin >> a >> b >> c;
    if(c > a+b){
        if(a*a + b*b + c*c > 2*(a*b + b*c + c*a)){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }else{
        cout << "No" << endl;
    }
}


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

using namespace std;

int main(){
 int a,b,k; 
  cin >> a >> b >> k;
  
  int res=0;
  for(int i=0;i<k;i++){
   if(i%2==0) { b+=a/2;
   a/=2;
              }
   else{ 
   a+=b/2;
   b/=2;
   }
  }
  cout << a << " " << b << endl;
   
}

Measured memory_bytes: 256