akhauriyash/Code-Regression huggingface dataset:
/* 𝑶(𝒎𝒊𝒏(r,n-r)) */

#include <iostream>
constexpr long long MOD = 1'000'000'007;

long long comb(long long n, long long r) {
    //--------Valid Error------------------
    if (n <= 0 || r < 0) return 0LL;
    if (n < r) return 0LL;
    //-------------------------------------

    r = std::min(r, n - r);
    if (r == 0LL) return 1LL;
    if (r == 1LL) return n;

    int inverse[r + 1];
    for (long long i = 1LL; i <= r; ++i) {
        long long a = i, b = MOD, u = 1LL, v = 0LL, t;
        while (b > 0) {
            t = a / b;
            std::swap(a -= t * b, b);
            std::swap(u -= t * v, v);
        }
        inverse[i] = (u >= 0 ? u % MOD : (MOD - (-u) % MOD));
    }

    long long retVal = 1LL;
    for (long long i = 0LL; i < r; i++) {
        retVal *= (n - i);  // retVal = n! / (n-r)!
        retVal %= MOD;
        retVal *= inverse[i + 1];  // retVal /= r!
        retVal %= MOD;
    }
    return retVal;
}

// test-----------------------------------------------
void abc145_d();  // nCr の n<=0 となりうる

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

void abc145_d() {
    using lli = long long;
    lli x, y;
    std::cin >> x >> y;

    lli k = 2LL * x - y;
    if (k % 3LL) {
        std::cout << "0\n";
        return;
    }
    k /= 3LL;

    lli t = 2LL * y - x;
    if (t % 3LL) {
        std::cout << "0\n";
        return;
    }
    t /= 3LL;

    long long ans = comb(k + t, k);
    std::cout << ans << std::endl;

    return;
}

Measured memory_bytes: 1536
import bisect,collections,copy,heapq,itertools,math,numpy,string
import sys
sys.setrecursionlimit(10**7)

def S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())

def main():
    H, N = LI()
    A = LI()
    print("Yes" if H<=sum(A) else "No")

main()



Measured memory_bytes: 37688
N = gets.to_i
D = gets.split.map(&:to_i)
M = gets.to_i
T = gets.split.map(&:to_i)

counter = Hash.new(0)

D.each do |d|
  counter[d] += 1
end

T.each do |t|
  if counter[t] <= 0
    puts 'NO'
    exit
  end

  counter[t] -= 1
end

puts 'YES'


Measured memory_bytes: 42012
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
int main(){
    ll H,N;
  cin >>H>>N;
  ll A[N];
  ll sum=0;
  for(int i=0;i<N;i++){
  cin>>A[i];
    sum=sum+A[i];
  }
if(sum>=H)cout<<"Yes"<<endl;
if(sum<H)cout<<"No"<<endl;

}

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

struct Point{double x,y;};//点
struct Segment{Point p1,p2;};//線
double dot(Point a,Point b){//内積
    return a.x*b.x+a.y*b.y;
}
double cross(Point a,Point b){//外積
    return a.x*b.y-a.y*b.x;
}
double norm(Point a){
    return a.x*a.x+a.y*a.y;
}
Point project(Segment s,Point p){
    Point base,q;
    Point ans;
    base.x=s.p2.x-s.p1.x;
    base.y=s.p2.y-s.p1.y;
    q.x=p.x-s.p1.x;
    q.y=p.y-s.p1.y;
    double r=dot(q,base)/norm(base);
    ans.x=s.p1.x+base.x*r;
    ans.y=s.p1.y+base.y*r;
    return ans;
}
Point reflect(Segment s,Point p){
    Point ans;
    ans.x=p.x+(project(s,p).x-p.x)*2.0;
    ans.y=p.y+(project(s,p).y-p.y)*2.0;
    return ans;
}

int main(void){
    int n;
    Segment a;
    Point p,ans;
    cin>>a.p1.x>>a.p1.y>>a.p2.x>>a.p2.y;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>p.x>>p.y;
        ans=reflect(a,p);
        cout<<fixed<<setprecision(10)<<ans.x<<" "<<ans.y<<endl;
    }
    return 0;
}



Measured memory_bytes: 3288
#![allow(non_snake_case,unused_imports)]
use std::io::Read;
use std::cmp::max;
use std::cmp::min;
use std::str::FromStr;
use std::collections::HashMap;
use std::collections::HashSet;
use std::collections::BinaryHeap;

fn main(){
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();
    let N = iter.next().unwrap().parse::<usize>().unwrap();
    
    let mut LR = (0..N).map(|_| (
        iter.next().unwrap().parse::<isize>().unwrap(),
        iter.next().unwrap().parse::<isize>().unwrap()
    )).collect::<Vec<_>>();
    LR.sort();

    let mut ra = (0..N).map(|_| LR[0].1).collect::<Vec<_>>();
    let mut rb = (0..N).map(|_| LR[N-1].1).collect::<Vec<_>>();
    for i in 1..N{
        ra[i] = min(ra[i-1],LR[i].1);
        let i = N-1-i;
        rb[i] = min(rb[i+1],LR[i].1);
    }

    let lf = LR[N-1].0;
    let mut ans = ra[0]-LR[0].0+1 + max(0,rb[1]-lf+1);
    for i in 1..N-1{
        let (li,ri) = LR[i];
        let mut tmp = max(0,min(ri,ra[i-1])-li+1)+max(0,rb[i+1]-lf+1);
        tmp = max(tmp,max(0,ri-li+1)+max(0,min(ra[i-1],rb[i+1])-lf+1));
        ans = max(ans,tmp);
    }

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


Measured memory_bytes: 10492
#include<stdio.h>

int main(void) {
	int n, m;
	scanf("%d", &n);
	if (n % 2 == 0) {
		m = (n / 2) *(n / 2);
	}
	else {
		m = (n + 1)*(n - 1) / 4;
	}
	printf("%d", m);
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define pb push_back
#define fi first
#define se second
#define CLR(A, X) memset(A, X, sizeof(A))
using namespace std;

typedef long long LL;
typedef pair<int, int> PII;
const double eps = 1e-10;
int dcmp(double x) { if(fabs(x) < eps) return 0; return x>0?1:-1; }
const LL MOD = 1e9+7;
const int N = 1e5+5;

int a[N], b[N];

int main() {
    int n, x;
    scanf("%d", &n);
    for(int i = 1; i <= n; i++) {
        scanf("%d", &x);
        int cnt = 0;
        while(x%2 == 0) {
            x /= 2;
            cnt++;
        }
        a[i] = cnt;
    }
    sort(a+1, a+1+n);
    int i = 1, j = 1;
    while(i <= n) {
        b[i++] = a[j];
        if(i <= n) b[i++] = a[n-j+1];
        j++;
    }
    bool flag = 1;
    for(i = 1; i < n; i++) {
        if(b[i]+b[i+1] < 2) {
            flag = 0;
            break;
        }
    }
    if(n==1 && b[1]<2) flag = 0;
    printf("%s\n", flag?"Yes":"No");
    return 0;
}


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

using namespace std;

#ifdef LOCAL
#define dmp(x) cerr<<__LINE__<<" "<<#x<<" "<<x<<endl
#else
#define dmp(x) void(0)
#endif

#define int long long

const int MOD = 1e9 + 7;
const int N = 504002;

int n, m;
int a[N], b[N];
bitset<400> ids[400];

void solve(int v, int t)
{
    if (t == -1)
        return;
    int x = a[t], y = b[t];
    if (ids[v][x] && ids[v][y])
    {
        for (int j = 0; j < n; j++)
        {
            ids[v][j] = 1;
        }
        return;
    }
    if (!ids[v][x] && !ids[v][y])
    {
        solve(v, t - 1);
        return;
    }
    ids[v][x] = 1, ids[v][y] = 1;
    solve(v, t - 1);
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> m;
    for (int i = 0; i < m; i++)
    {
        cin >> a[i] >> b[i];
        a[i]--, b[i]--;
    }
    for (int i = 0; i < n; i++)
    {
        ids[i][i] = 1;
        solve(i, m - 1);
    }
    int ans = 0;
    for (int i = 0; i < n; i++)
    {
        for (int j = i + 1; j < n; j++)
        {
            if ((ids[i] & ids[j]).count() == 0)
            {
                ans++;
            }
        }
    }
    cout << ans;
}


Measured memory_bytes: 5120
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
INF = float("inf")


def dfs(i, used, g, ng):
    for n in g[i]:
        if n not in used and (i, n) != ng and (n, i) != ng:
            used.add(n)
            dfs(n, used, g, ng)


def main():
    N, M = map(int, input().split())
    g = defaultdict(list)
    k = []
    for _ in range(M):
        a, b = map(int, input().split())
        g[a].append(b)
        g[b].append(a)
        k.append((a, b))

    ans = 0
    for a, b in k:
        used = set()
        dfs(1, used, g, (a, b))
        if len(used) != N:
            ans += 1
    print(ans)





if __name__ == '__main__':
    main()


Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
  	string s;
  	cin>>n>>s;
  	int all_e=0,left_w=0,left_e=0,right_e=0;
  	
  	vector<int>sum(0);
  	for(int i=0;i<n;i++){
    	if(s[i]=='E')all_e++;
    }
  	for(int i=0;i<n;i++){
    	if(s[i]=='W'){
        	
          	right_e=all_e-left_e;
          	
        }
      	else{
        	
          	right_e=all_e-1-left_e;
          	
          	
        }
      
      	sum.push_back(left_w + right_e);
      if(s[i]=='W'){
      	left_w++;
      }
      else{
      	left_e++;
      }
    }
  	sort(sum.begin(),sum.end());
  	cout<<sum[0]<<endl;

}

Measured memory_bytes: 2812
#ifdef _MSC_VER
#include "stdc++.h"
#endif
#ifdef __GNUC__
#include<bits/stdc++.h>
#endif
using namespace std;

using ll = long long;

//constant
const double EPS = 1e-10;

#define REP(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, s, e) for (ll i = s; i < e; i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(), (x).rend()

//debug
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define DEBUG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl;

// vector
//template<typename T> vector<vector<T>> vv(ll H, ll W, T v) { return vector<vector<T>> vec(H, vector<T>(W, v)); }

// view vector
template<typename T> void view(T e) { cout << e << endl; }
template<typename T> void view(const vector<T>& v) { for (const auto& e : v) { cout << e << " "; } cout << endl; }
template<typename T> void view(const vector<vector<T> >& vv) { for (const auto& v : vv) { view(v); } }

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




// ***************************************

double A, B;
ll N;

ll f(ll x){
    ll ans = floor(A * (double)x / B) - A * floor((double)x / B);
    return ans;
}


int main(){

    cin >> A >> B >> N;

    if (B == 1 || A == 1) {
        cout << 0 << endl;
        return 0;
    }

    cout << f(min((ll)B - 1, N)) << endl;

    return 0;
}


Measured memory_bytes: 3720
#define _USE_MATH_DEFINES

#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <utility>
#include <climits>
#include <vector>
#include <map>
#include <queue>
using namespace std;

#define ll long long
const int MOD = 1000000007;//10^9+7
const string SPACE = " ";

ll powsur(ll a, ll b, ll p) {

	if (b == 0) {

		return 1;

	}
	else if (b % 2 == 0) {

		ll d = powsur(a, b / 2, p);
		return ((d%p)*(d%p)) % p;

	}
	else {

		return ((a%p)*powsur(a, b - 1, p) % p) % p;

	}

}
//pは素数,aのb乗をpで割った余り

ll CMOD(ll n, ll r, ll p) {

	ll a = 1, b = 1, c = 1, re;
	for (int i = 1; i <= n; i++) {

		a *= i;
		a = a%p;

	}
	for (int i = 1; i <= r; i++) {

		b *= i;
		b = b%p;

	}
	for (int i = 1; i <= n - r; i++) {

		c *= i;
		c = c%p;

	}
	b = powsur(b, p - 2, p);
	c = powsur(c, p - 2, p);
	re = ((a%p)*(b%p)) % p;
	re = ((re%p)*c%p) % p;

	return re;

}
//pは素数,(nCr)%p

ll gcd(ll a, ll b) {

	if (a > b) {

		ll tmp = a;
		a = b;
		b = tmp;

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

}
//最大公約数

ll lcm(ll a, ll b) {

	return (a / gcd(a, b))*b;

}
//最小公倍数

ll MAX(ll a, ll b) {

	if (a > b)return a;
	else return b;

}

int main() {

	ll N, K, ans = 0;

	cin >> N >> K;

	if (K == 0)ans = N*N;
	else {

		for (int i = K + 1; i <= N; i++) {

			ans += (N / i)*(i - K) + MAX(N%i - K + 1, 0);

		}

	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
N = int(input())
a = list(map(int, input().split()))
cnt = 10000
for i in range(len(a)):
    tmp_cnt = 0
    while int(a[i] % 2) == 0:
        tmp_cnt += 1
        a[i] /= 2
    if tmp_cnt <= cnt:
        cnt = tmp_cnt
    else:
        continue
print(cnt)


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

int main ()
{
    int a,b,x,y;
    scanf("%d%d",&a,&b);
    if(b<10) x=a*10+b;
    if(b>=10&&b<100) x=a*100+b;
    if(b==100) x=a*1000+b;
    y=sqrt(x);
    if(x==y*y) printf("Yes");
    else printf("No");
}


Measured memory_bytes: 256
import math
x, k, d = map(int, input().split())
ans = []
a = math.floor(abs(x) / d)
if a > k:
  a = k
  if x > 0:
    ans = (abs(x - d * k))
  else:
    ans = (abs(x + d * k))
else:
  if x > 0:
    tmp = (abs(x - d * a))
    if (k - a) % 2 == 1:
      ans = (abs(x - d * (a + 1)))
    else:
      ans = tmp
  else:
    tmp = (abs(x + d * a))
    if (k - a) % 2 == 1:
      ans = (abs(x + d * (a + 1)))
    else:
      ans = tmp
print (ans)

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

int main()
{

int n,k;
cin>>n>>k;

int arr[n];
for(int index = 0;index<n;index++)
cin>>arr[index];

sort(arr,arr+n);

int ans = 0 ;
for(int index =0;index<k;index++)
ans += arr[index];

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


Measured memory_bytes: 3560
N = int(input())
S = "MARCH"
dic = {s:0 for s in "MARCH"}
for _ in range(N):
    s = input()[0]
    if s in "MARCH":
        dic[s] += 1
        
        
res = 0
for i0 in range(3):
    s0 = S[i0]
    if dic[s0] == 0:
        continue
    for i1 in range(i0 + 1, 4):
        s1 = S[i1]
        if dic[s1] == 0:
            continue
        if s1 == s0:
            continue
        for i2 in range(i1 + 1, 5):
            s2 = S[i2]
            if dic[s2] == 0:
                continue
            if s2 in (s0, s1):
                continue
            res += dic[s0] * dic[s1] * dic[s2]    
print(res)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <ctime>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>
#include <cmath>
#include <assert.h>
#include <iomanip>
using namespace std;
#define vi vector<int>
#define pii pair<int,int>
#define x first
#define y second
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define SZ(x) (int)x.size()
#define rep(i,a,b) for(int i=a;i<b;i++)
#define per(i,a,b) for(int i=b-1;i>=a;i--)
#define pi acos(-1)
#define mod 1000000007
#define inf 1000000007
#define ll long long
#define ull unsigned long long
#define DBG(x) cerr<<(#x)<<"="<<x<<"\n";
#define N 100010
#define _DEBUG
template <class U,class T> void Max(U &x, T y){if(x<y)x=y;}
template <class U,class T> void Min(U &x, T y){if(x>y)x=y;}
template <class T> void add(int &a,T b){a=(a+b)%mod;}
inline int gcd(int a,int b){return b==0?a:gcd(b,a%b);}
inline ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}

int pow(int a,int b){
    int ans=1;
    while(b){
        if(b&1)ans=1LL*ans*a%mod;
        a=1LL*a*a%mod;b>>=1;
    }
    return ans;
}
int pow(int a,int b,int c){
    int ans=1;
    while(b){
        if(b&1)ans=1LL*ans*a%c;
        a=1LL*a*a%c;b>>=1;
    }
    return ans;
}

char s[3003],t[3003];
int dp[3003][3003];
int main(){
    //srand(time(NULL)+clock());
    int ca=0,T,k,i,j,m=0,K,n;
    double start=clock();
    scanf("%s%s",s,t);
    n=strlen(s),m=strlen(t);
    rep(i,0,n)rep(j,0,m){
        dp[i+1][j+1]=max(dp[i+1][j],dp[i][j+1]);
        if(s[i]==t[j])Max(dp[i+1][j+1],dp[i][j]+1);
    }
    int sz=0;
    int x=n,y=m;
    while(x&&y){
        if(dp[x][y]==dp[x-1][y])x--;
        else if(dp[x][y]==dp[x][y-1])y--;
        else s[sz++]=t[y-1],x--,y--;
    }
    s[sz]=0;
    reverse(s,s+sz);
    puts(s);
    cerr<<(1.*clock()-start)/CLOCKS_PER_SEC<<"\n";
}


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

int main() {
    string s; cin >> s;
    rep(i,s.size()) {
        //偶
        if (i % 2 == 0) {
            if (s[i] == 'L') {
                cout << "No" << endl; 
                return 0;
            }
        } else {
            //奇
            if (s[i] == 'R') {
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
    return 0;
}

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

long long int gcd(long long int m,long long int n)
{
	if (n == 0)
		return m;
	return gcd(n,m % n);
}

int main()
{
	long long int a, b;
	while (cin >> a >> b)
		cout << gcd(a, b) << " " << a * b / gcd(a, b) << endl;
	return 0;
}

Measured memory_bytes: 1156
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <stdbool.h>
typedef long long ll;
#define rep(i,n) for(ll i=0; i<(ll)(n); i++)
#define REP(i,l,r) for(ll i=l; i<(ll)(r); i++)
#define max(l,r) ((l)>(r)?l:r)
#define min(l,r) ((l)<(r)?l:r)
#define swap(l,r) {ll tp=l;l=r;r=tp;}
const ll MOD = 1000000007;
const int INF = (1 << 30);
int upcmpii(const void *a, const void *b){
    return (*(int*)a == *(int*)b ? 0 : (*(int*)a > *(int*)b ? 1 : -1));
}
void sort_ui(int *a, int n){ qsort(a, n, sizeof(int), upcmpii);}

#define E_MAX 202020
#define V_MAX 202020
typedef struct edlst{
    int fr, to;
}E;
typedef struct graph{
    E e[E_MAX*2];
    int st[V_MAX], siz[V_MAX];
}G;
G g;
int upe(const void *a, const void *b){
    if(((E*)a)->fr != ((E*)b)->fr) 
        return (((E*)a)->fr > ((E*)b)->fr ? 1 : -1);
    else
        return (((E*)a)->to == ((E*)b)->to ? 0 : (((E*)a)->to > ((E*)b)->to ? 1 : -1));
}
void g_init(int vn, int en){
    int a, b;
    rep(i, vn) g.siz[i] = 0;
    rep(i, en) {
        scanf("%d%d", &a, &b);
        a--; b--;
        g.e[2*i].fr = a; g.e[2*i].to = b;
        g.e[2*i+1].fr = b; g.e[2*i+1].to = a;
        g.siz[a]++; g.siz[b]++;
    }
    qsort(g.e, 2*en, sizeof(E), upe);
    g.st[0] = 0;
    rep(i, vn-1){
        g.st[i+1] = g.st[i] + g.siz[i];
    }
}

int n, q;
ll scr[202020] = {0}, ans[202020] = {0};
bool ch[202020] = {false};
void dfs(int vi, ll sum) {
    ch[vi] = true;
    ans[vi] = sum + scr[vi];
    rep(i, g.siz[vi]) {
        if(!ch[g.e[g.st[vi] + i].to]) {
            dfs(g.e[g.st[vi] + i].to, ans[vi]);
        }
    }
}

void solve() {
    int p, x;
    rep(i, q) {
        scanf("%d%d", &p, &x);
        scr[p-1] += x;
    }
    dfs(0, 0);
}

int main(){
    scanf("%d%d", &n, &q);
    g_init(n, n-1);
    solve();
    rep(i, n) {
        printf("%lld ", ans[i]);
    }
    puts("");
}

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

using namespace std;
typedef long long ll;
int main() {
  int n;
  cin >> n;
  ll ans = 0;

  for(int i = 0; i < n; i++) {
    ll l,r;
    cin >> l >> r;
    ans += r - l + 1;
  }

  cout << ans << endl;
}
  


Measured memory_bytes: 256
function Main(input) {
  input = input.split("\n");
  const n = input[0].split(" ")[0];
  const k = input[0].split(" ")[1];
  const s = input[1].split("");

  var happyRCount = 0;
  var happyLCount = 0;

  for (var i = 0; i < n - 1 ; i ++) {
    if (s[i] === "R" && s[i + 1] === "R") {
      happyRCount = happyRCount + 1;
    }
  }

  for (var i = n-1; i > 0 ; i --) {
    if (s[i] === "L" && s[i - 1] === "L") {
      happyLCount = happyLCount + 1;
    }
  }

  var happyCount = happyRCount + happyLCount;

  var maxHappyCount = 0;

  if (happyCount + k * 2 > n -1 ) {
    maxHappyCount = n -1;
  } else {
    maxHappyCount = happyCount + k * 2;
  }
  console.log(maxHappyCount);
}
  
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 8396
using System;
using System.Collections.Generic;

class Program
{
    static string InputPattern = "InputX";

    static List<string> GetInputList()
    {
        var WillReturn = new List<string>();

        if (InputPattern == "Input1") {
            WillReturn.Add("1 21");
            //Yes
        }
        else if (InputPattern == "Input2") {
            WillReturn.Add("100 100");
            //No
        }
        else if (InputPattern == "Input3") {
            WillReturn.Add("12 10");
            //No
        }
        else {
            string wkStr;
            while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
        }
        return WillReturn;
    }

    static void Main()
    {
        List<string> InputList = GetInputList();
        string[] SplitArr = InputList[0].Split(' ');
        int wkInt = int.Parse(SplitArr[0] + SplitArr[1]);

        for (int I = 0; I * I <= wkInt; I++) {
            if (I * I == wkInt) {
                Console.WriteLine("Yes");
                return;
            }
        }
        Console.WriteLine("No");
    }
}


Measured memory_bytes: 11092
#include <vector>
#include <iostream>
using namespace std;
int main() {
  int n = 0;
  cin >> n;
  vector<int> d(n, 0);
  for(int i = 0; i < n; ++i) {
    cin >> d[i];
  }
  int sum = 0;
  for(int i = 0; i < n - 1; ++i) {
    for(int j = i + 1; j < n; ++j) {
      sum += d[i] * d[j];
    }
  }
  cout << sum << endl;
  return 0;
}


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

#define int long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define dbg(x) cerr << #x << ": " << x << endl;
#define dbg2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define dbg3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define dbgB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

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

template<typename T>
void print1(T begin, T end) {
	while (begin != end) {
		cerr << (*begin) << " ";
		*begin++;
	}
	cerr << endl;
}

template<typename T>
void print2(T Array, int height, int width) {
	for (int i = 0; i < height; i++) {
		for (int j = 0; j < width; j++) {
			cerr << " " << Array[i][j];
		}
		cerr << endl;
	}
}

void print() { std::cerr << endl; }
template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
	std::cerr << head << " ";
	print(std::forward<Tail>(tail)...);
}

template<class T>
void Add(T &a, const T &b, const T &mod=1000000007) {
	int val = ((a % mod) + (b % mod)) % mod;
	if (val < 0) { val += mod; }
	a = val;
}

template <typename X, typename T> auto vectors(X x, T a) { return vector<T>(x, a); }
template <typename X, typename Y, typename Z, typename... Zs> auto vectors(X x, Y y, Z z, Zs... zs) { auto cont = vectors(y, z, zs...); return vector<decltype(cont)>(x, cont); }

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

int N, K;
int A[222222];

signed main() {
	cin >> N >> K;
	rep (i, N) {
		cin >> A[i];
		A[i]--;
	}

	vector<int> route;
	route.push_back(0);
	set<int> rs;
	rs.insert(0);

	vector<int> before;
	vector<int> loop;
	for (int i = 1; ; i++) {
		int next = A[route[i-1]];
		if (rs.count(next)) {
			int idx = 0;
			for (int j = 1; j < rs.size(); j++) {
				if (route[j] == next) {
					idx = j;
					break;
				}
				before.push_back(route[j]);
			}
			for (int j = idx; j < rs.size(); j++) {
				loop.push_back(route[j]);
			}

			break;
		}
		rs.insert(next);
		route.push_back(next);
	}

	print1(all(before));
	print1(all(loop));

	if (K <= 1 + before.size()) {
		cout << route[K] + 1 << endl;
	} else {
		K--;
		K -= before.size();
		cout << loop[K % loop.size()] + 1 << endl;
	}

	return 0;
}

Measured memory_bytes: 18676
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = std::int_fast64_t;
using std::cout;
using std::cerr;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return std::vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

int main() {
	int a, b, c, d; scanf("%d%d%d%d", &a, &b, &c, &d);

	std::string ans = "Yes", nxt = "No";
	while(true) {
		c -= b;
		if(c <= 0) {
			printf("%s\n", ans.c_str());
			break;
		}

		std::swap(a, c);
		std::swap(b, d);
		ans.swap(nxt);
	}
	return 0;
}


Measured memory_bytes: 3696
# ABC131C - Anti-Division
from fractions import gcd


def main():
    a, b, c, d = list(map(int, input().rstrip().split()))
    total = b - a + 1
    a -= 1
    lcm = c * d // gcd(c, d)
    total -= b // c - a // c
    total -= b // d - a // d
    total += b // lcm - a // lcm
    print(total)


if __name__ == "__main__":
    main()

Measured memory_bytes: 5048
N=input()
if len(N)%2==0:
    for i in range(len(N)):
        if i%2==0:
            if N[i]!="h":
                print("No")
                exit()
        else:
            if N[i]!="i":
                print("No")
                exit()
else:
    print("No")
    exit()
print("Yes")

Measured memory_bytes: 38384
m=10**9+7
input()
i=s=r=0
f=1
a=input().split()
for _ in a:
 s+=pow(i+1,m-2,m)
 r+=int(a[i])*~-s+int(a[~i])*s
 i+=1
 f=f*i%m
print(r*f%m)

Measured memory_bytes: 11480
#include <bits/stdc++.h>
using namespace std;
int32_t main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n; cin >> n;
    vector< pair<int, int> > vec(2*n);
    for (int i = 0; i < n; ++i) {
		vec[i].second = i, vec[i+n].second = i+n;
		cin >> vec[i].first >> vec[i+n].first;
    }
    sort(vec.begin(), vec.end());
;
    int cntA = 0, cntB = 0, cntD = 0;
    vector<bool> used(n, 0);
    int64_t ans = 0;
    for (int i = 0; i < n; ++i) {
        ans += vec[i].first;
        if (vec[i].second < n) ++cntA; else ++cntB;
        if (used[vec[i].second % n]) ++cntD; used[vec[i].second % n] = 1;
    }

    if (cntA && cntB && cntD == 0) {
        if (vec[n-1].second % n != vec[n].second % n) ans -= vec[n-1].first - vec[n].first;
		else {
            if (cntB == 1 && vec[n-1].second >= n) ans -= vec[n-1].first - vec[n].first;
            else if (cntA == 1 && vec[n-1].second < n) ans -= vec[n-1].first - vec[n].first;
            else {
                ans += min(vec[n].first - vec[n-2].first, vec[n+1].first - vec[n-1].first);
            }
		}
    }
    cout << ans;
}


Measured memory_bytes: 1792
#include<iostream>
#include<cmath>
using namespace std;
int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	int k,a,b;
	cin>>k>>a>>b;
	int t1=ceil(1.0*a/k),t2=floor(1.0*b/k);
	if(t1<=t2){
		cout<<"OK"<<endl;
	}
	else{
		cout<<"NG"<<endl;
	}
	return 0;
}

Measured memory_bytes: 3620
#include <iostream>
#include <map>
#include <vector>
#include <cmath>
#define int long long
typedef long long ll;
using namespace std;

ll N, K, ans=0;

void allsearch(){
    ans=0;
    for(ll i=1;i<=N;i++){
        for(ll j=i+1;j<=N-1;j++){
            for(ll l=j+1;l<=N;l++) if(i+j+l==K) ans++;
        }
    }
    cout << ans << endl;
}

signed main(){
    while(cin >> N >> K){
        if(N==0) break;
        allsearch();
    }
    
    return 0;
}


Measured memory_bytes: 3096
#!/usr/bin/env python3
import sys
from collections.abc import Iterable
from math import *
from itertools import *
from collections import *
from functools import *
from operator import *
try:
    from math import gcd
except Exception:
    from fractions import gcd


def solve(N: int, d: "List[int]"):
    d = sorted(d)
    hi = N // 2
    return d[hi] - d[hi - 1]


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    d = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    result = solve(N, d)
    if isinstance(result, Iterable) and not isinstance(result, str):
        result = '\n'.join([str(v) for v in result])
    print(result)

if __name__ == '__main__':
    main()


Measured memory_bytes: 17340
using System;

namespace Debt_Hell
{
    class Program
    {
        static void Main(string[] args)
        {
            int k = 100000;
            int inp = int.Parse(Console.ReadLine());
            for (int i = 0; i < inp; i++)
                k += (int)Math.Ceiling((k * 0.05) / 1000) * 1000;
            Console.WriteLine(k.ToString());
        }
    }
}

Measured memory_bytes: 8980
import math
n,m = map(int,input().split())
cnt = 0
if n >= 2:
  cnt = math.factorial(n) // (math.factorial(n - 2) * math.factorial(2))
if m >= 2:
  cnt = cnt + math.factorial(m) // (math.factorial(m - 2) * math.factorial(2))
print(cnt)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
constexpr int64_t mod=1e9+7;

int main()
{
  int n;
  cin>>n;
  for (int i = 0; i < 50000; ++i)
  {
    int j=i*1.08;
    if(n==j)
    {
      cout<<i<<endl;
      return 0;
    }
  }
  cout<<":("<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<map>
#include<queue>
#include<cstdlib>
#include<ctime>
#define rep(i,j,k) for(register int i = j; i <= k; i++)
#define dow(i,j,k) for(register int i = j; i >= k; i--)
#define ll long long
#define mp make_pair
using namespace std;
 
inline int read() {
	int s = 0, t = 1; char c = getchar();
	while( !isdigit(c) ) { if( c == '-' ) t = -1; c = getchar(); }
	while( isdigit(c) ) s = s * 10 + c - 48, c = getchar();
	return s * t;	
} 

const int N = 1e5+5, p = 1e9+7;
ll fac[N] = {1}, inv[N] = {1,1}, f[N];
int cnt[N], v[N];
inline ll C(int n,int m) { 
	if( m < 0 || m > n ) return 0;
	return fac[n] * inv[m] % p * inv[n-m] % p;
}

int main() {
	int n = read();
	rep(i,1,n+1) fac[i] = fac[i-1] * i % p;
	rep(i,2,n+1) inv[i] = (p - p / i) * inv[p % i] % p;
	rep(i,2,n+1) inv[i] = inv[i] * inv[i-1] % p;
	
	int pos = 0;
	rep(i,1,n+1) { 
		v[i] = read(), cnt[v[i]]++;
		if( cnt[v[i]] > 1 ) pos = v[i];
	}
	int s, t;
	rep(i,1,n+1) if( v[i] == pos ) { s = i; break; }
	dow(i,n+1,1) if( v[i] == pos ) { t = i; break; }
	
	int num = t - s - 1, lr = s - 1 + n + 1 - t;
	rep(i,1,n+1) { 
		cout<<(C(n+1,i) - C(lr,i-1) + p) % p<<endl;
	}
    return 0;
} 

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

int main() {
  int a,b; cin >>a >>b;
  int num = 1;
  int ans = 0;
  while(num<b){
    num += a-1; ans++;
  }
  
  cout <<ans;
  cout <<endl;
}


Measured memory_bytes: 256
n,m = map(int,input().split(' '))

bar = [[] for _ in range(n)]

for i in range(m):
    a,b = map(lambda x:int(x)-1,input().split(' '))
    bar[a].append(b)
    bar[b].append(a)

result = 0

def search(root=[0]):
    global result
    if len(root) >= n:
        result += 1
        return
    nxt = set(bar[root[-1]])
    nxt = nxt - set(root)
    for nxt_ in nxt:
        search(root+[nxt_])

search()
print(result)

Measured memory_bytes: 3064
from bisect import bisect_left, bisect_right
def resolve():
    def judge_m(mid):
        tot = 0
        for i in range(p_n):
            d = mid//P[i]
            tot += bisect_right(M, d)
        return tot >= K


    def judge_p(mid):
        tot = 0
        for i in range(p_n): # 正と正の積
            d = mid//P[i]
            tmp = bisect_right(P, d)
            if i < tmp:
                tmp -= 1 # 自身を除く
            tot += tmp
        for i in range(m_n): # 負と負の積
            d = mid//M[i]
            tmp = bisect_right(M, d)
            if i < tmp:
                tmp -= 1 # 自身を除く
            tot += tmp
        tot //= 2
        return tot >= K


    INF = 10 ** 18 + 1
    N, K = map(int, input().split())
    A = sorted(map(int, input().split()))

    P = []
    M = []
    Z = []
    for a in A:
        if a > 0:
            P.append(a)
        elif a < 0:
            M.append(a)
        else:
            Z.append(a)

    p_n = len(P)
    m_n = len(M)
    z_n = len(Z)
    minus = p_n * m_n
    zero = z_n*(z_n-1)//2 + z_n*p_n + z_n*m_n
    plus = p_n*(p_n - 1)//2 + m_n*(m_n-1)//2

    if K <= minus: # X が負の時
        M.sort()
        l, u = -INF, 0
        while u - l > 1:
            mid = (u+l)//2
            if judge_m(mid):
                u = mid
            else:
                l = mid
        return print(u)
    elif K <= (minus + zero):
        return print(0)
    elif K <= (minus + zero + plus):
        K -= (minus + zero)
        M = [abs(m) for m in M]
        P.sort()
        M.sort()
        l, u = -1, INF
        while u - l > 1:
            mid = (u + l)//2
            if judge_p(mid):
                u = mid
            else:
                l = mid
        return print(u)


if __name__ == "__main__":
    resolve()


Measured memory_bytes: 119288
/*    FAILING IS AN ART
       AND 
     I HAVE MASTERED IT
*/
#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long 
#define ff first
#define ss second
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back 
#define mp make_pair
#define inf 2000000009
#define mod 1000000007
#define ld long double
using namespace std;

int main()
{ 

    fast;

    ll h,n;
    cin>>h>>n;
    ll s=0,x;

    for(ll i=0;i<n;i++)
        cin>>x,s+=x;

    if(s>=h)
        cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

   
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <string>
#include <cmath>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //ai>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //ai>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define REV(x) (reverse(x.begin(),x.end())) //reverse
#define TO(x,t,f) ((x)?(t):(f))
#define CLR(mat) memset(mat, 0, sizeof(mat))
#define FILV(x,a) fill(x.begin(),x.end(),a)
#define FILA(ar,N,a) fill(ar,ar+N,a)
#define NEXTP(x) next_permutation(x.begin(),x.end())
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;else return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define pb push_back
#define pri(aa) cout<<(aa)<<endl
#define mp(x,y) make_pair(x,y)
#define fi first
#define se second
const ll INF=1e18+7;
const ll N = 1007;


int main(){
	ll m,n;
	cin>>m>>n;
	ll d = -1;
	ll ans = 0;
	priority_queue<P> q;
	FOR(i,0,n){
		ll a,b;
		cin>>a>>b;
		q.push({-b,-a});
	}
	while(!q.empty()){
		P x = q.top();
		q.pop();
		x.fi*=-1;
		x.se*=-1;
		if(x.se>d){
			d = x.fi - 1;
			ans++;
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 2420
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

template <typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 10

/* Permutation <-> ID */
// {0,1,2} <=> 0, {0,2,1} <=> 1, {2, 1, 0} <=> 5

namespace PermutationConverter {
  const int MAX_DATASIZE = 20;

  ll encode(int N, const int *data){
    bool used[MAX_DATASIZE] = {};
    ll id = 0, t = 1;

    for(int i=1; i<=N; i++) t *= i;

    for(int i=0; i<N; i++){
      t /= (N - i);
      used[data[i]] = true;
      id += count(used, used+data[i], false) * t;
    }

    return id;
  }

  void decode(int N, ll id, int *data) {
    bool used[MAX_DATASIZE] = {};
    ll t = 1;

    for(int i=1; i<=N; i++) t *= i;

    for(int i=0; i<N; i++) {
      t /= (N - i);

      int s = id / t;
      for(int j=0; ; j++) {
        if (!used[j] && s == 0) {
          data[i] = j;
          used[j] = true;
          break;
        }
        s -= !used[j];
      }

      id %= t;
    }
  }
};

void bfs(int N, int *A, map<int, int> &ss) {

  queue<int> que1, que2;

  que1.push(PermutationConverter::encode(N, A));

  for(int i=0; i<4; i++) {

    while(que1.size()) {
      int id = que1.front();
      que1.pop();

      if (ss.find(id) != ss.end()) continue;
      ss[id] = i;

      PermutationConverter::decode(N, id, A);

      for (int i=0; i<N; i++) {
        for (int j=i+2; j<=N; j++) {
          reverse(A+i, A+j);
          que2.push(PermutationConverter::encode(N, A));
          reverse(A+i, A+j);
        }
      }
    }

    swap(que1, que2);
  }
}

int main(){
  int N, A[SIZE], B[SIZE];

  scanf("%d", &N);

  for (int i=0; i<N; i++) {
    scanf("%d", A+i);
    A[i]--;
  }

  iota(B, B+N, 0);

  map<int, int> ss1, ss2;

  bfs(N, A, ss1);
  bfs(N, B, ss2);

  int ans = N-1;

  for (auto p : ss2) {
    auto it = ss1.find(p.first);
    if (it == ss1.end()) continue;
    ans = min(ans, p.second + it->second);
  }

  cout << ans << endl;

  return 0;
}



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

#define ll long long int
#define ull unsigned long long int
#define db double
#define ld long double
#define MOD 1000000007
#define inf (1LL << 62)
#define pi acos(-1.0)
#define si(a) scanf("%lld",&a)
#define sd(n) scanf("%lf", &n)
#define for1(i, stop) for(ll i = 1; i <= stop; i++)
#define for0(i, stop) for(ll i = 0; i < stop; i++)
#define rep1(i, start) for(ll i = start; i >= 1; i--)
#define rep0(i, start) for(ll i = (start-1); i >= 0; i--)
#define loop(i, start, stop, inc) for(ll i = start; i <= stop; i += inc)
#define pb(v,a) v.push_back(a)
#define pll pair <ll, ll>
#define mp make_pair
#define pbp(v,a,i) v.push_back(make_pair(a,i))
#define srt(v) sort(v.begin(),v.end())
#define rv(v) reverse(v.begin(),v.end())
#define ms(n, i) memset(n, i, sizeof(n))
#define debug printf("Debug\n");
#define en '\n'



#define _fastio  ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0);

map<int,int>m;
int main()
{
	_fastio
	int n,ar[200005],cn=0;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&ar[i]);
		m[ar[i]]=m[ar[i]]+1;
	}
	for(int i=1;i<=n;i++)
	{
		int vl=ar[i];
		if(vl!=1 && m[1]>=1)
		{

		}
		else if(m[vl]>1)
        {

        }
		else
		{
			bool fl=true;
			for(int j=2;j*j<=vl;j++)
			{
				if(vl%j==0)
				{
					if(m[j]>=1)
					{
						fl=false;
						break;
					}
					int j1=vl/j;
					if(m[j1]>=1)
					{
						fl=false;
						break;
					}
				}
			}
			if(fl)
				cn=cn+1;
		}
	}
    printf("%d\n",cn);
}


Measured memory_bytes: 33532
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <sys/time.h>
#include <cmath>
#include <tuple>
#include <queue>
#include <bitset>

using namespace std;

void solve(long long N, vector<long long> A){
    vector<long long> minus;
    vector<long long> plus;
    vector<long long> zero;
    for (int i = 0; i < N; i++) {
        A[i] -= i+1;
        if (A[i] < 0) {
            minus.push_back(-A[i]);
        } else if (A[i] > 0){
            plus.push_back(A[i]);
        } else {
            zero.push_back(A[i]);
        }
    }
    sort(minus.begin(), minus.end());
    sort(plus.begin(), plus.end());
    long long b = 0;
    int idx;
    if (minus.size() + zero.size() < plus.size()) {
        idx = (plus.size() - (minus.size() + zero.size()) + 1)/2;
        b = plus[idx-1];
    } else if (minus.size() > zero.size() + plus.size()){
        idx = (minus.size() - (plus.size() + zero.size()) + 1)/2;
        b = - minus[idx-1];
    }
    long long ret = 0;
    for (int i = 0; i < N; i++) {
        A[i] = abs(A[i] - b);
        ret += A[i];
    }
    std::cout << ret << std::endl;
}

int main(){
    struct timeval start,end;
    long long span;
    gettimeofday(&start,NULL);

    long long N;
    scanf("%lld",&N);
    vector<long long> A(N-1+1);
    for(int i = 0 ; i <= N-1 ; i++){
    	scanf("%lld",&A[i]);
    }
    solve(N, A);

    gettimeofday(&end,NULL);
    span = (end.tv_sec -start.tv_sec)*1000000LL + (end.tv_usec - start.tv_usec);
    std::cerr << "--Total Time: " << span/1000 << "ms" << endl;
    return 0;
}


Measured memory_bytes: 5620
#include <iostream>
#include <cstdlib>
#include <stack>

using namespace std;

int main()
{
    // 標準ライブラリから stack を使用
    stack<int> S;
    int a, b;
    string s;

    while (cin >> s) {
        if (s[0] == '+') {
            a = S.top(); S.pop();
            b = S.top(); S.pop();
            S.push(a + b);
        } else if (s[0] == '-') {
            b = S.top(); S.pop();
            a = S.top(); S.pop();
            S.push(a - b);
        } else if (s[0] == '*') {
            a = S.top(); S.pop();
            b = S.top(); S.pop();
            S.push(a * b);
        } else {
            S.push(atoi(s.c_str()));
        }
    }

    cout << S.top() << endl;

    return 0;
}


Measured memory_bytes: 3216
/* Author: Rennan Rocha
 * Time: $%Y%$-$%M%$-$%D%$ $%h%$:$%m%$:$%s%$
**/

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

#define F first
#define S second
#define PB push_back
#define MP make_pair

#define ll long long
#define vi vector<int>
#define vll vector<ll>
#define pi pair<int,int>
#define pll pair<ll, ll>
#define vpi vector<pi>
#define vpll vector<pll>

#define INF 1e18
#define MOD 1000000007
//#define DEBUG

using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
//*find_by_order(); order_of_key();

unsigned seed = std::chrono::system_clock::now().time_since_epoch().count();
std::default_random_engine e(seed);
std::mt19937 rng((int) seed);

int main() {
    ios_base::sync_with_stdio(false);

    ll m;
    cin >> m;
    for(ll n = 1; n <= m; n++) {
        ll ans = 0;
        for(ll x = 1; x*x <= n-5; x++) {
            for(ll y = 1; x*x+y*y+x*y <= n-3; y++) {
                for(ll z = 1; x*x+y*y+z*z+x*y+x*z+y*z <= n; z++) {
                    if(x*x+y*y+z*z+x*z+y*z+x*y == n) ans++;
                }
            }
        }
        cout << ans << "\n";
    }
}


Measured memory_bytes: 3608
#include <iostream>
#include <vector>
using namespace std;
int main(){
	int n,m;
	int a[3];
	cin>>n>>m;
	a[0]=-1;
	a[1]=-1;
	a[2]=-1;
	for(int i=0;i<m;i++){
		int s,c;
		cin>>s>>c;
		if(a[s-1]==-1){
			a[s-1]=c;
		}else{
			if(a[s-1]==c){
				continue;
			}else{
				cout<<-1<<endl;
				return 0;
			}
		}
	}
	if(a[0]==0){
		if(n==1){
			cout<<0<<endl;
		}else{
			cout<<-1<<endl;
		}
		return 0;
	}
	if(n==1){
		if(a[0]==-1){
			cout<<0<<endl;
		}else{
			cout<<a[0]<<endl;
		}
		return 0;
	}
	for(int i=0;i<n;i++){
		if(a[i]==-1){
			if(i==0){
				cout<<1;
			}else{
				cout<<0;
			}
		}else{
			cout<<a[i];
		}
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 256
import numpy as np

n = int(input())

a = np.asarray(list(map(int, input().split())))

dic = {}

for i in range(n):
    if a[i] in dic:
        dic[a[i]] += 1
    else:
        dic[a[i]] = 1

if max(dic.values()) >= 2:
    print("NO")
else:
    print("YES")


Measured memory_bytes: 38108
n=int(input())
a=[0]*n
b=[0]*n
c=[0]*n
a[:]=map(int,input().split())
b[:]=map(int,input().split())
c[1:]=map(int,input().split())
r=0
l=n
for ii in range(n):
  r+=b[a[ii]-1]
  if l+1==a[ii]-1:
    r+=c[a[ii]-1]
  l=a[ii]-1
print(r)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF = 1e10;
const ll MOD = 1000000007;
typedef pair<ll,ll> P;
class UnionFind{
    private:
        vector<ll> par;
        vector<ll> siz;
    public:
        UnionFind(ll sz){
            par.resize(sz);
            siz.assign(sz,1LL);
            rep(i,sz) par[i] = i;
        }

        ll find(ll x){
            if (par[x] == x) return x;
            else return par[x] = find(par[x]);
        }

        void unite(ll x,ll y){
            x = find(x);
            y = find(y);
            if (x == y) return;
            if (siz[x] < siz[y]) swap(x,y);
            siz[x] += siz[y];
            par[y] = x;
        }

        bool same(ll x,ll y){
            return find(x) == find(y);
        }

        ll size(ll x){
            return siz[find(x)];
        }
};
ll n,k,l;
int main(){
    cin >> n >> k >> l;
    UnionFind road(n),train(n);
    ll p,q;
    rep(i,k){
        cin >> p >> q;
        road.unite(p-1,q-1);
    }
    rep(i,l){
        cin >> p >> q;
        train.unite(p-1,q-1);
    }
    map<P,ll> c;
    rep(i,n){
        c[P(road.find(i),train.find(i))]++;
    }
    rep(i,n-1){
        cout << c[P(road.find(i),train.find(i))] << " ";
    }
    PRINT(c[P(road.find(n-1),train.find(n-1))]);
}


Measured memory_bytes: 19200
#include <iostream>
using namespace std;
int main() {
	string s;
	int a = 0, b = 0, i = 0;
	cin >> s;
	for(i = 0; i < 3; i++){
	    if(s[i] == 'A') a++;
	    else b++;
	}
	cout << ( a == 3 || b == 3 ? "No" : "Yes") << "\n";
	return 0;
}

Measured memory_bytes: 256
n,m = map(int,input().split())
 
dic = {0:0}
 
for i in range(m):
  a,b = map(int,input().split())
  tmp_arr = list(map(int, input().split()))
  
  arr = []
  for j in range(1, n+1):
    if j in tmp_arr:
      arr.append('1')
    else:
      arr.append('0')
  
  c = int(''.join(arr),2)
  
  dic2 = dic.copy()
  
  for k,v in dic.items():
    if (k|c) in dic2.keys():
      dic2[k|c] = min(dic2[k|c],a+v)
    else:
      dic2[k|c] = a+v
 
  dic = dic2
 
if ((2**n)-1) in dic.keys():
  print(dic[(2**n) -1])
else:
  print(-1)

Measured memory_bytes: 4216
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace CSharp_AtCoder
{


    class Program
    {
        

        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            string[] ST = Console.ReadLine().Split(' ');
            string S = ST[0];
            string T = ST[1];

            string ans = "";
            for(int i = 0; i < N; i++)
            {
                ans += S[i].ToString() + T[i].ToString();
            }

            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
#define FOR(i,a,n) for(ll i=(ll)a;i<(ll)n;i++)
#define rep(i,n) FOR(i,0,n)
using namespace std;
typedef long long ll;

ll n,u,v,a,b,d1[100009],d2[100009];
vector<ll> e[100009];

int main(){
    cin>>n>>u>>v;
    rep(i,n-1){
        cin>>a>>b;
        e[a].push_back(b);
        e[b].push_back(a);
    }
    queue<ll>que;
    que.push(v);
    rep(i,n+1)d1[i]=d2[i]=1e18;
    d1[v]=0;
    while(!que.empty()){
        ll x=que.front();
        que.pop();
        rep(i,e[x].size()){
            if(d1[e[x][i]]==1e18){
                d1[e[x][i]]=d1[x]+1;
                que.push(e[x][i]);
            }
        }
    }
    d2[u]=0;
    que.push(u);
    while(!que.empty()){
        ll x=que.front();
        que.pop();
        if(d1[x]==d2[x])continue;
        rep(i,e[x].size()){
            if(d2[e[x][i]]==1e18){
                d2[e[x][i]]=d2[x]+1;
                que.push(e[x][i]);
            }
        }
    }

    ll mn=1e18,mx=0;

    FOR(i,1,n+1){
        if(d1[i]==d2[i]){
            mn=d1[i];
        }
        if(d1[i]>d2[i]){
            mx=max(mx,d1[i]-1);
        }
    }

    cout<<mx<<endl;
}

Measured memory_bytes: 8064