akhauriyash/Code-Regression huggingface dataset:
// 基本テンプレート
 
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
using namespace std;
 
#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;

int dp[1010][1010], dp2[1010], c[1010], w[1010];
 
signed main() {
    int N; cin >> N;
    for(int i=1; i<=N; i++) {
        cin >> c[i] >> w[i];
        c[i] += w[i];
        w[i] += w[i-1];
        dp[i][i+1] = c[i];
    }

    for(int d=1; d<=N; d++) {
        for(int l=1; l<=N-d+1; l++) {
            int r = l + d, piv, sum = w[r-1] - w[l-1];
            // 左を伸ばす
            piv = l;
            dp[l][r] |= (dp[l+1][r] && c[piv] >= sum);

            // 右を伸ばす
            piv = r - 1;
            dp[l][r] |= (dp[l][r-1] && c[piv] >= sum);
        }
    }

    fill(dp2, dp2 + N + 2, INF);
    dp2[1] = 0;
    for(int i=1; i<=N; i++) {
        for(int j=i+1; j<=N+1; j++) {
            if(dp[i][j]) chmin(dp2[j], dp2[i] + 1);
        }
    }
    cout << dp2[N+1] << endl;
    return 0;
}


Measured memory_bytes: 10044
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

int main(){
  int N;
  int mod = 1000000007;
  cin >> N;
  int A[N];
  for(int i=0;i<N;i++) cin >> A[i];
  int x = 0;
  int y = 0;
  int z = 0;
  int T[N];
  for(int i=0;i<N;i++){
    T[i] = (A[i]==x) + (A[i]==y) + (A[i]==z);
    if(A[i]==x) x++;
    else if (A[i]==y) y++;
    else if (A[i]==z) z++;
    }
  ll sum=1;
  for(int i=0;i<N;i++){
    sum *= T[i];
    sum = sum % mod;
  }
  cout << sum << endl;
  return 0;
}


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

int main(){

    int n,sco; cin>>n;

    string res;

    vector<pair<pair<string,int>,int>> p(n);
    
    for(int i=0; i<n; i++){

        cin>>res>>sco;
        
        p.at(i) = make_pair(make_pair(res,(-1)*sco),i);

    }

    sort(p.begin(),p.end());

    for(int i=0; i<n; i++) cout<<p.at(i).second + 1<<endl;

    return 0;
}




Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
 
int main(){
	int num[30], w, n, a, b;
	char c;
	for(int i = 1; i <= 30; i++){
		num[i-1] = i;
	}
	cin >> w >> n;
	while(cin >> a >> c >> b){
		swap(num[a-1], num[b-1]);
	}
	for(int i = 0; i < w; i++){
		cout << num[i] << endl;
	}
	return 0;
}


Measured memory_bytes: 3004
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = GetLongNumArray();
            var N = input[0];
            var K = input[1];
            var p = GetLongNumArray().OrderBy(x => x).ToList();
            var result = 0;

            for (int i = 0; i < K; i++)
            {
                result += (int)p[i];
            }

            Console.WriteLine(result);
        }

        private static long[] GetLongNumArray()
        {
            var input = Console.ReadLine().Split(' ');
            return input.Select(x => long.Parse(x)).ToArray();
        }

        private static long GetLongNum()
        {
            return long.Parse(Console.ReadLine());
        }

        private static string[] GetStringArray()
        {
            return Console.ReadLine().Split(' ');
        }

        private static string GetString()
        {
            return Console.ReadLine();
        }
    }
}


Measured memory_bytes: 28592
list1 = input().split(" ")
list2 = input().split(" ")
list3 = input().split(" ")
count = int(input())
correct = ['o','o','o']
answer = "No"
for i in range(count):
	num = input()
	list1 = ['o' if i == num else i for i in list1]
	list2 = ['o' if i == num else i for i in list2]
	list3 = ['o' if i == num else i for i in list3]
	vlist1 = [list1[0],list2[0],list3[0]]
	vlist2 = [list1[1],list2[1],list3[1]]
	vlist3 = [list1[2],list2[2],list3[2]]
	xlist1 = [list1[0],list2[1],list3[2]]
	xlist2 = [list1[2],list2[1],list3[0]]
	if list1 == correct:
		answer = "Yes"
		break
	elif list2 == correct:
		answer = "Yes"
		break
	elif list3 == correct:
		answer = "Yes"
		break
	elif vlist1 == correct:
		answer = "Yes"
		break
	elif vlist2 == correct:
		answer = "Yes"
		break
	elif vlist3 == correct:
		answer = "Yes"
		break
	elif xlist1 == correct:
		answer = "Yes"
		break
	elif xlist2 == correct:
		answer = "Yes"
		break    
print(answer)

Measured memory_bytes: 3064
import sys
n = int(input())
print(0)#, flush=True)
s = input()
if s == "Vacant":
    sys.exit()
l = 0
r = n
ls = s
rs = s

def nibun(l, r, m, ls, rs, s):
    if ((m-l) % 2 == 0 and ls == s) or\
        ((m-l) % 2 == 1 and ls != s):
        return 1
    else:
        return 0

for ii in range(21):
    m = (l+r)//2
    print(m)#, flush=True)
    s = input()
    if s == "Vacant":
        break
    if nibun(l, r, m, ls, rs, s) == 0:
        r = m
        rs = s
    else:
        l = m
        ls = s

Measured memory_bytes: 38852
#include<bits/stdc++.h>
using namespace std;
int main(){ 
  char c;
  cin >> c;
  if (c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o'){
    cout << "vowel\n";
  }
  else
  {
    cout << "consonant\n";
  }
  return 0;
}

Measured memory_bytes: 256
inp=input().split()
a = int(inp[0])
b = int(inp[1])
k = int(inp[2])
if (k>=a+b):
    print('0 0')
else:
    if (a>=k):
        print('{} {}'.format(a-k, b))
    else:
        print('0 {}'.format(a+b-k))

Measured memory_bytes: 3060
// Package main provides
//
// File:  d.go
// Author: ymiyamoto
//
// Created on Sun Dec  2 05:20:19 2018
//
package main

import "fmt"

const mod = 1e9 + 7

var n, m int64

func primeFactorization(x int64) map[int64]int64 {
	val := x
	ret := map[int64]int64{}

	for i := int64(2); i*i <= x; i++ {
		for val%i == 0 {
			val /= i
			ret[i]++
		}
	}

	if val > 1 {
		ret[val]++
	}

	return ret
}

func combination(n, k, p int64) int64 {
	var fact func(n int64) int64
	fact = func(n int64) int64 {
		if n == 0 {
			return 1
		}
		return n * fact(n-1) % p
	}

	var power func(n, m, p int64) int64
	power = func(n, m, p int64) int64 {
		if m == 0 {
			return 1
		}

		n2 := n * n % p
		if m%2 == 0 {
			return power(n2, m/2, p) % p
		}
		return n * power(n2, (m-1)/2, p) % p
	}

	x := fact(n)
	y := fact(k)
	z := fact(n - k)
	return x * (power(y, p-2, p) * power(z, p-2, p) % p) % p
}

func main() {
	fmt.Scan(&n, &m)

	var ans int64 = 1
	for _, v := range primeFactorization(m) {
		ans *= combination(v+n-1, v, mod)
		ans %= mod
	}

	fmt.Println(ans)
}


Measured memory_bytes: 7808
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T> >;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define repb(i, n) for(ll i = (n)-1; i >= 0; i--)
#define repr(i, a, b) for(ll i = (a); i < (b); i++)
#define reprb(i, a, b) for(ll i = (b)-1; i >= (a); i--)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
const ll MOD = 1000000007;
const ll INF = 100000000000000000LL;
inline ll GCD(ll a, ll b){ return b?GCD(b, a % b):a; }
inline ll LCM(ll a, ll b){ return a/GCD(a, b)*b; }
inline ll powint(unsigned long long x, ll y){ ll r=1; while(y){ if(y&1) r*=x; x*=x; y>>=1; } return r; }
inline ll powmod(ll x, ll y, ll m = MOD){ ll r=1; while(y){ if(y&1) r*=x; x*=x; r%=m; x%=m; y>>=1; } return r; }
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; }
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif

void pr(bool f){
    cout << (f ? "Yes" : "No") << endl;
    exit(0);
}

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll n;
    cin >> n;
    ll N = 1ll << n;
    vll a(N);
    rep(i, N){
        cin >> a[i];
    }
    sort(ALL(a), greater<ll>());
    dump(a);
    multiset<ll> yet;
    repr(i, 1, N) yet.insert(a[i]);
    vll fin(1, a[0]);
    rep(i, n){
        vll fin2 = fin;
        rep(i, SZ(fin)){
            auto it = yet.lower_bound(fin[i]);
            if(it == yet.begin()) pr(0);
            it--;
            fin2.emplace_back(*it);
            yet.erase(it);
        }
        sort(ALL(fin2), greater<ll>());
        swap(fin, fin2);
    }
    pr(1);
    return 0;
}

Measured memory_bytes: 17784
#include<iostream>
#include<algorithm>
#include<cassert>
#include<vector>
#include<fstream>
#include<string>
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
#include<queue>
#include<map>

using namespace std;
#define REP(i,m,n) for(int i=m;i<n;++i)
#define REPll(i,m,n) for(ll i=m;i<n;++i)
#define INF 10000000000000000
#define MOD 1000000007
#define ll long long
#define mp make_pair
#define all(v) v.begin(),v.end()

vector<ll>v;

ll check(ll a) {
	REPll(i, 0, v.size()) {
		a -= a%v[i];
	}
	return a;
}

int main() {
	ll k, bottom = 0, top = INF, small = -1, big = -1;
	ll hoge;
	cin >> k;
	REP(i, 0, k) {
		int tmp;
		cin >> tmp;
		v.push_back(tmp);
	}
	//big
	REP(i, 0, 200) {
		hoge = (bottom + top) / 2;
		if (2 < check(hoge)) {
			top = hoge;
		}
		else {
			bottom = hoge;
		}
	}
	if (2 == check(top)) {
		big = top;
	}else if (2 == check(bottom)) {
		big = bottom;
	}
	//small
	bottom = 0, top = INF;
	REP(i, 0, 200) {
		hoge = (bottom + top) / 2;
		if (2 > check(hoge)) {
			bottom = hoge;
		}
		else {
			top = hoge;
		}
	}
	if (2 == check(bottom)) {
		small = bottom;
	}
	else if (2 == check(top)) {
		small = top;
	}
	if (small != -1 && big != -1) {
		cout << small << " " << big << endl;
	}
	else {
		cout << "-1" << endl;
	}
	return 0;
}

Measured memory_bytes: 1400
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

int main() {
    int A, B;
    char op;
    cin >> A >> op >> B;
    if(op == '+') {
        cout << A + B << endl;
    } else {
        cout << A - B << endl;
    }
    return 0;
}

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

#define ll long long
#define s second
#define f first

int main()
{
	ll n;
	string s;
	cin >> n >> s;
	
	if(n&1)
	{
		cout << "No\n";
		return 0;
	}
	
	string a= s.substr(0,n/2);
	string b= s.substr(n/2,n/2);
	
	if(a==b)
	{
		cout << "Yes\n";
		return 0;
	}
	else cout << "No\n";
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INFLL LLONG_MAX // 9223372036854775807
#define EPS 1e-9
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
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; }
using namespace std;

int main(){
    Init();
    const ll N = 1e6+1;
    ll n, ans = 0; cin >> n;
    vector<int> d(N, 0);
    rep(i, n){
        ll tmp; cin >> tmp;
        d[tmp]++;
    }
    for(ll i=1; i<N; i++){
        if(d[i] == 0) continue;
        if(d[i] == 1) ans++;
        for(ll j=i+i; j<N; j+=i) d[j] = 0;
    }
    cout << ans << endl;
}

Measured memory_bytes: 7068
h,w=map(int,input().split())
a=[input() for i in range(h)]
hi=[]
we=[]
def str_del(str,index):
    str = str[:index]+str[index+1:]
    return str

for i in range(h):

    if a[i] =='.'*w:
        we+=[i]

for i in range(w):
    memo=[]
    for j in range(h):
        memo+=a[j][i]
    if ''.join(memo) =='.'*h:
        hi+=[i]

for i in we[::-1]:
    a.pop(i)
for z in range(len(a)):
    for x in hi[::-1]:
        a[z]=str_del(a[z], x)

for i in a:
    print(i)

Measured memory_bytes: 3064
#include<stdio.h>
  
   char s[200],p[200];
  
int main(void){
    int sl,pl,i,j;
    scanf("%s",s);
    scanf("%s",p);
  
    i = 0;
    while(s[i] != '\0')
        i++;
     sl = i;
     i = 0;
    while(p[i] != '\0')
        i++;
     pl = i;
  
    for(i = 0;i < sl;i++){
        for(j = 0;j < pl;j++){
            if(s[(i + j) % sl] != p[j])
                break;
        }
        if(j == pl){
            printf("Yes\n");return 0;
        }
    }
    printf("No\n");
 
    return 0;
}


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

int main(){
  int H,W;
  cin>>H>>W;
  vector <string> www(H);
  for(int i=0;i<H;i++){
    cin>>www.at(i);
  }
  for(int i=0;i<W+2;i++){
    cout<<'#';
  }
  cout<<endl;
  for(int i=0;i<H;i++){
  cout<<'#'<<www.at(i)<<'#'<<endl;
  }
  for(int i=0;i<W+2;i++){
    cout<<'#';
  }

}

Measured memory_bytes: 256
import bisect 

A,B,Q = map(int, input().split())
INF = 10 ** 18
s = [-INF] + [int(input()) for i in range(A)] + [INF]
t = [-INF] + [int(input()) for i in range(B)] + [INF]
for q in range(Q):
    x = int(input())
    b,d = bisect.bisect_right(s, x), bisect.bisect_right(t, x)
    res = INF
    for S in [s[b-1],s[b]]:
        for T in [t[d-1],t[d]]:
            d1,d2 = abs(S-x)+abs(T-S),abs(T-x)+abs(S-T)
            res = min(res,d1,d2)
    print(res)

Measured memory_bytes: 14592
n = int(input())

# 例外処理
if n == 2:
    print(1)
    exit()
if n == 3:
    print(2)
    exit()

# n % k = 1 の数
m = n - 1
i = 2
ans = 1
while i * i <= m:
    if m % i == 0:
        num = 1
        while m % i == 0:
            num += 1
            m //= i
        ans *= num
    i = i + 1
if m != 1:
    ans *= 2
ans -= 1

# n % k = 0 の場合
# nを素因数分解する
m = n
import numpy as np
i = 2
factor = []
while i * i <= n:
    if n % i == 0:
        l = []
        num = 1
        l.append(num)
        while n % i == 0:
            num *= i
            l.append(num)
            n //= i
        factor.append(np.array(l))
    i = i + 1
if n > 1:
    factor.append(np.array([1, n]))

# 直積を求めることでnの全約数を得る
divisor = factor[-1]
for i in range(len(factor) - 1):
    divisor = np.outer(divisor, factor[i])
divisor = np.outer(np.array(1), divisor)

# 判定
for i in divisor[0]:
    if i == 1:
        continue
    n = m
    while n % i == 0:
        n //= i
    if n % i == 1:
        ans += 1

print(ans)

Measured memory_bytes: 12508
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
#include <cstdio>
#include <cstdint>
using namespace std;

uint_fast16_t d;
uint_fast32_t M = 0;
uint_fast64_t c, sd = 0, sc = 0;
char ct;

int main() {
    while((ct=getchar_unlocked())>47) M = (M<<1) + (M<<3) + ct - 48;
    while(M--) {
        c = 0;
        d = getchar_unlocked();
        getchar_unlocked();
        while((ct=getchar_unlocked())>47) c = (c<<1) + (c<<3) + ct - 48;
        sc += c;
        sd += c * (d - 48);
    }
    printf("%lld\n", --sc + --sd / 9);
	return 0;
}


Measured memory_bytes: 256
N, M = [int(i) for i in input().split()]
AC = 0
WA = 1

ac_count = 0
wa_count = 0
data = {}
for _ in range(M):
  p, s = input().split()
  if p in data:
    if data[p][AC] == 1:
      # AC済のものはスキップ
      continue
  if s == "AC":
    if p in data:
      wa_count += data[p][WA]
    ac_count += 1
    data[p] = [1, 0]
  if s == "WA":
    if p in data:
      data[p][WA] += 1
    else:
      data[p] = [0, 1]

print(ac_count, wa_count)


Measured memory_bytes: 29148
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()

typedef long long ll;

struct UnionFind{
    vector<int> Parent;
    vector<int> sizes;
    UnionFind(int n):Parent(n),sizes(n,1){ rep(i,n)Parent[i]=i; }
    //find the root of x
    int root(int x){
        if(x!=Parent[x]){
        Parent[x] = root(Parent[x]);
        }
        return Parent[x];
    }
    //merge x and y
    void unite(int x,int y){
        x = root(x);
        y = root(y);
        if(x == y) return;
        if(sizes[x] < sizes[y]) swap(x, y);
        Parent[y] = x;
        sizes[x] += sizes[y];
    }
    bool same(int x,int y){ return root(x) == root(y); }
    int size(int x){ return sizes[root(x)]; }
};

int N;
vector<int> A,B;
vector<pair<int, int>> A_sorted,B_sorted;

void INPUT(){
    cin>>N;
    A.resize(N);B.resize(N);
    rep(i,N){
        cin>>A[i];
        A_sorted.push_back({A[i],i});
    }
    rep(i,N){
        cin>>B[i];
        B_sorted.push_back({B[i],i});
    }
    sort(all(A_sorted));
    sort(all(B_sorted));
}

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

    //sortしてA[i]<=B[i]を満たないならいかなる置換でも達成できない
    rep(i,N){
        if(A_sorted[i].first>B_sorted[i].first){
            cout<<"No"<<endl;
            return 0;
        }
    }

    //sortして達成可能な場合
    //sortしたときの対応関係から、互いに素な巡回置換の数を数える
    UnionFind uni(N);
    rep(i,N){
        uni.unite(A_sorted[i].second,B_sorted[i].second);
    }
    //互いに素な巡回置換の個数（つまり、UnionFindのグループの数）
    int cnt = 0;
    rep(i,N){
        if(uni.Parent[i] == i)cnt++;
    }
    /*
    互いに素な巡回置換が1つのとき、N-1回の互換（swap）で表現でき、
    そこから互いに素な循環が1つ増えるたびに、必要な互換の数は1ずつ減るので、
    cnt > 1のときはN-2回以内のswapで達成可能
    */
    if(cnt > 1){
        cout<<"Yes"<<endl;
        return 0;
    }
    /*
    互いに素な巡回置換が1つのとき
    Bの要素をswapしてもよければ、1つの巡回置換を2つに分解できる
    一番簡単なswapは隣り合う要素なので、そこを確認する
    A[i]<=A[i+1]
    ∧||   ∧||
    B[i]<=B[i+1]
    B[i]とB[i+1]をswapしてもいい条件は
    ・A[i]<=B[i+1]（自明）
    ・A[i+1]<=B[i]（確認）
    */
    rep(i,N-1){
        if(A_sorted[i+1].first <= B_sorted[i].first){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
}

Measured memory_bytes: 3444
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define PB push_back
#define MP make_pair
#define SZ size()
#define Fr first
#define Sc second
#define si(a) scanf("%d", &a)
#define sl(a) scanf("%I64d", &a)
#define sd(a) scanf("%lf", &a)
#define ss(a) scanf("%s", a)
#define debug(x) cout << #x << ": " << x << endl
#define Fast_IO ios_base::sync_with_stdio(0);cin.tie(0)

typedef long long Long;
typedef pair <int, int> Pii;
///<-------------------------------------------------END OF TEMPLATE-------------------------------------------------->

#define MAX 105
int N, ps[30], cnt[30];
char S[MAX];

int main() {
   ss(S);
   N = strlen(S);

   memset(ps, -1, sizeof(ps));
   for(int i = 0; i < N; i++) {
      int c = S[i] - 'a';
      cnt[c] = max(cnt[c], i - ps[c] - 1);
      ps[c] = i;
   }
   int ans = N;
   for(int i = 0; i < 26; i++) {
      cnt[i] = max(cnt[i], N - ps[i] - 1);
      ans = min(ans, cnt[i]);
   }
   printf("%d\n", ans);
}


Measured memory_bytes: 256
import math

a, b, h, m = map(int, input().split())

angle = min(abs(30 * h + 0.5 * m - 6 * m), 360 - abs(30 * h + 0.5 * m - 6 * m))

print(math.sqrt(a ** 2 + b ** 2 - 2 * a * b * math.cos(math.radians(angle))))

Measured memory_bytes: 62168
import math

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

def bitlist(x,digit):
    res = [0 for i in range(digit)]
    now = x
    for i in range(digit):
        res[i]=now%2
        now = now >> 1
    return res

#a = list(map(int, input().split()))

m = int(input())
n = m//2
flag2 = m%2

num2=0
num5=0
ans2=1
ans5=1

while(True):
    if(ans2 > n):
       break
    num2 += 1
    ans2 *= 2
    
while(True):
    if(ans5 > n):
       break
    num5 += 1
    ans5 *= 5   

have2 = 0
have5 = 0
#print(num2,num5)
now2 = num2
for i in range(num2):
    times = n // int(2**now2)
    have2 += times
    now2 -=1
    #print("t",times)

now5 = num5
for i in range(num5):
    times = n // int(5**now5)
    have5 += times
    now5 -=1
    
#print(have2+n,have5,flag2)

if(flag2==0):
    print(min(have2+n,have5))
else:
    print(0)

Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
#define PI 3.1415926535
const long long int MOD = 1e9+7;
#define pb push_back
#define mp make_pair
#define fill(a)  memset(a, 0, sizeof (a))
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);
#define watch(x) cout << (#x) << " is " << (x) << endl;
const long long int MAXX = 2e5+5;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> ii;
typedef pair<int,ii> iii;
typedef vector<ii> vii;
typedef vector<vii> vvii;
typedef vector< iii > viii;

ll lcm(ll a, ll b) {
   return a / __gcd(a, b) * b;
}
int XOR(int x, int y){
  return (x | y) & (~x | ~y);
}
bool cmp(const pair<int,int> &a,const pair<int,int> &b) {
    return (a.second < b.second);
}
// bool isl = binary_search(x.begin(), x.end(), 5);
// __builtin_popcount(x)  - Returns the number of set bits in x
const long long int N = 1e6;
int binsearch(int lo, int hi){
    while(lo<hi){
        int mid=(lo+hi)/2;
        if((mid))   // check(mid)
            hi=mid;
        else
            lo=mid+1;
    }
    return lo;
}
int power(int x,int y){
    int res=1;
    while(y>0){
      if(y&1) res=((res*x));

      y/=2;
      x=((x*x));
    }
    return res;
}
int whites[MAXX],red[MAXX],rwhites[MAXX],rred[MAXX];
int main(){
    FAST
    int n;
    cin>>n;
    string s;
    cin>>s;
    int ans=n;
    for(int i=1;i<=n;i++){
        whites[i]=whites[i-1]+(s[i-1]=='W');
        red[i]=red[i-1]+(s[i-1]=='R');

    }
    for(int i=n;i>=1;i--){
        rwhites[i]=rwhites[i+1]+(s[i-1]=='W');
        rred[i]=rred[i+1]+(s[i-1]=='R');

    }
    ans=min(whites[n],red[n]);
    for(int i=1;i<n;i++){
        int leftw=whites[i];
        int leftr=red[i];
        int rightr=rred[i+1];
        int rightw=rwhites[i+1];
        int change=min(leftw,rightr);
        int anss=0;
        anss+=min(leftw,rightr);
        leftw-=change;
        rightr-=change;
        anss+=leftw+rightr;
        ans=min(ans,anss);

    }
    cout<<ans;
    return 0;
}


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

using namespace std;

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define FORR(i, a, b) for(int i = (a); i > (b); --i)
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define VECCIN(x)                                                              \
    for(auto &youso_ : (x)) cin >> youso_
#define mp make_pair
#define bitcnt __builtin_popcount
#define All(a) (a).begin(), (a).end()
template <typename T = long long> inline T IN() {
    T x;
    cin >> x;
    return (x);
}
inline void CIN() {}
template <class Head, class... Tail>
inline void CIN(Head &&head, Tail &&... tail) {
    cin >> head;
    CIN(move(tail)...);
}
#define CINT(...)                                                              \
    int __VA_ARGS__;                                                           \
    CIN(__VA_ARGS__)
#define LCIN(...)                                                              \
    ll __VA_ARGS__;                                                            \
    CIN(__VA_ARGS__)
#define SCIN(...)                                                              \
    string __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define Yes(a) cout << (a ? "Yes" : "No") << "\n"
#define YES(a) cout << (a ? "YES" : "NO") << "\n"

typedef long long ll;
typedef unsigned long long ul;
typedef vector<int> V;
typedef vector<ll> VL;
typedef pair<int, int> Pair;
typedef pair<ll, ll> PL;
typedef priority_queue<int> PQ;
typedef priority_queue<int, V, greater<int>> PQG;

const int INF = 1e9;
const int MOD = 1e9 + 7;
// const int MOD = 998244353;
const ll LINF = 1e18;

ll N;
map<ll, ll> sum;

map<ll, ll> primefact(ll n) {
    map<ll, ll> res;
    for(ll i = 2; i * i <= n; i++) {
        while(n % i == 0) {
            res[i]++;
            n /= i;
        }
    }
    if(n != 1) res[n] = 1;
    return res;
}

int main() {
    cin >> N;
    FOR(i, 1, N + 1) {
        auto tmp = primefact(i);
        FOREACH(p, tmp) sum[p.first] += p.second;
    }
    map<ll, ll> num;
    REP(i, N + 1) {
        if(sum[i] >= 2) num[3]++;
        if(sum[i] >= 4) num[5]++;
        if(sum[i] >= 14) num[15]++;
        if(sum[i] >= 24) num[25]++;
        if(sum[i] >= 74) num[75]++;
    }
    ll ans = num[75];
    ans += (num[3] - 1) * num[25];
    ans += (num[5] - 1) * num[15];
    ans += (num[3] - 2) * num[5] * (num[5] - 1) / 2;
    cout << ans << "\n";
}

Measured memory_bytes: 256
count = 0
a = 0
b = 0
while (count <= 3000) and (a  <= 10000) and (b <= 10000):
    a,b = map(int, input().split())
    if a == b == 0:
        break

    if a > b:
        tmp = a
        a = b
        b = tmp

    count += 1
    print(a, b, sep = ' ')


Measured memory_bytes: 5608
class InputLine
  def self.to_s
    gets.chomp
  end

  def self.to_i
    InputLine.to_s.to_i
  end
  
  def self.to_f
    InputLine.to_s.to_f
  end

  def self.to_sa
    InputLine.to_s.split(' ')
  end

  def self.to_ia
    InputLine.to_sa.map(&:to_i)
  end
  
  def self.to_fa
    InputLine.to_sa.map(&:to_f)
  end
end

def main(argv)
  s = InputLine.to_s

  d = 0

  3.times do |i|
    next if s[i] == 'S'
    j = 0
    while i + j < 3 do
      break if s[i + j] == 'S'
      j += 1
    end
    d = [d, j].max
  end

  puts d.to_s
end

if self.to_s == 'main' then
  main(ARGV)
end

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

int main(void){
  int i,j;
  int v[3][3];
  for(i = 0;i<3;i++){
      for(j=0;j<3;j++){
      
      cin >> v[i][j];
        
    }
    
  }

  
  
  if(v[0][0]-v[0][1]==v[1][0]-v[1][1]&&v[2][0]-v[2][1]==v[1][0]-v[1][1]){
  if(v[0][1]-v[0][2]==v[1][1]-v[1][2]&&v[2][1]-v[2][2]==v[1][1]-v[1][2]){
    if(v[0][0]-v[1][0]==v[0][1]-v[1][1]&&v[0][2]-v[1][2]==v[0][1]-v[1][1]){
      if(v[1][0]-v[2][0]==v[1][1]-v[2][1]&&v[1][2]-v[2][2]==v[1][1]-v[2][1]){
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
}
cout << "No" << endl;


  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = 1; i <= n; i++)
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
using P = pair <int, int>;
 

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

   int sum = 0;
   rep(i,n){
       sum += a[i];
   }
   int av1 = sum/n;
   int av2 = sum/n+1;

   int ans1=0,ans2=0 ;
   rep(i,n){
       ans1 +=(av1-a[i])*(av1-a[i]);
       ans2 +=(av2-a[i])*(av2-a[i]);

   }
   cout << min (ans1,ans2) <<endl;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> w(n);
  for (int i = 0; i < n; i++) {
    cin >> w[i];
  }
  int ans = 999999999;
  for (int i = 1; i < n - 1; i++) {
    int s1 = 0, s2 = 0;
    for (int j = 0; j <= i; j++) {
      s1 += w[j];
    }
    for (int j = i + 1; j < n; j++) {
      s2 += w[j];
    }
    if (abs(s1 - s2) < ans) {
      ans = abs(s1 - s2);
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
double a[100010];
int main()
{
	int n;
	double ans=0;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%lf",&a[i]);
	sort(a+1,a+n+1);
	ans=a[1];
	for(int i=2;i<=n;i++)ans=(ans+a[i])/2;
	printf("%.8lf\n",ans);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define ld long double
#define pll pair<ll, ll>
#define pii pair<int, int>
#define f first
#define se second
#define pb push_back
#define ft fflush(stdout)
 
 
using namespace std;
 
 
const int N = 3e5;
const int PLS = 3e5 + 123;
const ull mod = 1e9 + 7;
const ll inf = 1e16;


ll n, a[N], dp[N], h[N], t[4 * N];


void upd(ll v, ll tl, ll tr, ll pos, ll val) {
    if (tl == tr) {
        t[v] = max(t[v], val);
        return;
    }
    ll tm = (tl + tr)>>1;
    if (pos <= tm)
        upd(v * 2, tl, tm, pos, val);
    else
        upd(v * 2 + 1, tm + 1, tr, pos, val);
    t[v] = max(t[v * 2], t[v * 2  + 1]);
}


ll get(ll v, ll tl, ll tr, ll l, ll r) {
    if (r < tl || tr < l)
        return 0ll;
    ll tm = (tl + tr)>>1;
    if (l <= tm && tr <= r)
        return t[v];
    return max(get(v * 2, tl, tm, l, r), get(v * 2 + 1, tm + 1, tr, l, r));
}


int main() {
    ios_base::sync_with_stdio(NULL);
    cin.tie(NULL); cout.tie(NULL);
    cin >> n;
    for (int i = 1; i <= n; i++)
        cin >> h[i];
    for (int i = 1; i <= n; i++)
        cin >> a[i];
    for (int i = 1; i <= n; i++) {
        dp[i] = a[i] + get(1, 1, n, 1, h[i] - 1);
        upd(1, 1, n, h[i], dp[i]);
    }
    ll mx = 0;
    for (int i = 1; i <= n; i++)
        mx = max(mx, dp[i]);
    cout << mx;
}

Measured memory_bytes: 14592
#include <vector> 
#include <list> 
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <complex>
using namespace std;

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

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;

typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<LL> VLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(t,c) for(typeof((c).begin()) t=(c).begin(); t!=(c).end(); ++t)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(t,a,b) for(int t=(a);t<(b);++t)
#define REP(t,n)  FOR(t,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

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



const LL mod = 1000000007;

LL gcd(LL a, LL b) { if (a%b == 0) { return b; } else return gcd(b, a%b); }
LL lcm(LL a, LL b) { return a / gcd(a, b)*b; }

#define Yes_ cout<<"Yes"<<endl; return 0;
#define No_ cout<<"No"<<endl; return 0;


#define YES_ cout<<"YES"<<endl; return 0;
#define NO_ cout<<"NO"<<endl; return 0;

#define POSSIBLE cout<<"POSSIBLE"<<endl; return 0;
#define IMPOSSIBLE cout<<"IMPOSSIBLE"<<endl; return 0;




int main() {
	
	int a, b, c;
	string s;
	cin >> s;
	int num = count(ALL(s), 'o');
	cout << 700 + num * 100 << endl;




}


Measured memory_bytes: 764
#!/usr/bin/env python
# -*- coding: utf-8 -*-

S = input()

A = int(S[:2])
B = int(S[2:])

a = 1 <= A <= 12
b = 1 <= B <= 12
if a and not b:
    print('MMYY')
elif not a and b:
    print('YYMM')
elif a and b:
    print('AMBIGUOUS')
else:
    print('NA')


Measured memory_bytes: 2940
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define REP(i,s,n) for(int i=s; i<(n); ++i)
#define ALL(n) begin(n),end(n)
using ll = long long;
const ll INF = 1e18;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }



int main(){
    int N;
    cin >> N;
    vector<ll> A(N);
    REP(i,0,N) cin >> A[i];

    sort(A.begin(), A.end(), std::greater<ll>());

    ll award_sum = 0;
    REP(i, 1, N){
        award_sum += A[i / 2];
    }
    cout << award_sum << endl;

    return 0;
}


Measured memory_bytes: 4876
/*
LANG:C++
PROB:

*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>
#include <iostream>
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)


using namespace __gnu_pbds;
using namespace std;


typedef tree<int, null_type, less<int>, rb_tree_tag,
            tree_order_statistics_node_update>
    ordered_set;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;
typedef unsigned long long ui64;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }
const int mod=1000000007;
  i64 poww(i64 a, i64 b)
  {
    a%=mod;
    i64 res=1;
    while(b)
      {
if(b&1)res=res*a%mod;

      a=a*a%mod;
      b/=2;

      }
      return res;
  }
  i64 inv(i64 a)
  {
    return poww(a,mod-2);
  }
i64 calc(i64 m)
{

  i64 lo=1,hi=m,ans=1;

  while(hi>=lo)
  {
i64 mid=(hi+lo)/2;
// cout<<mid<< " ";
if(mid*(mid+1)<=2*m)
{
  ans=mid;
  lo=mid+1;
}
else
hi=mid-1;

    }

    return ans;
}

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

    // ifstream fin(".in");
    // ofstream fout(".in");
i64 x;
cin>>x;
i64 ans=0, cnt=0;
for(i64 i=2;i*i<=x;i++)
{
  cnt=0;
if(x%i==0)
{
cnt=0;
while(x%i==0)
{
  x/=i;
  cnt++;
}

// cout<<cnt<<" "<<i<<"\n";
ans+=calc(cnt);


  }


}


if(x>1)ans++;
cout<<ans;
    return 0;
  }


Measured memory_bytes: 3652
#include<bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  if(n==2){
    int a,b;
    cin >> a >> b;
    cout << a+b << endl;
  }else{
    cout << "Hello World" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

def main(O, E):
    A = []
    if(len(O)==len(E)):
        for i in range(len(O)):
            A.append(O[i])
            A.append(E[i])
        print("".join(A))
    else:
        for i in range(len(E)):
            A.append(O[i])
            A.append(E[i])
        A.append(O[-1])
        print("".join(A))  
    
if __name__ == '__main__':
    O = input()
    E = input()
    
    main(O, E)

Measured memory_bytes: 3064
n = int(input())
a = list(map(int, input().split()))

ma = max(a)
mi = min(a)

num = 0
ans = []

if ma >= -mi:
    ind = a.index(ma)
    for i in range(1, n):
        while a[i-1] > a[i]:
            num += 1
            ans.append(str(ind+1) + ' ' + str(i+1))
            a[i] += ma
            if a[i] > ma:
                ma = a[i]
                ind = i

else:
    ind = a.index(mi)
    for i in range(n-2, -1, -1):
        while a[i] > a[i+1]:
            num += 1
            ans.append(str(ind+1) + ' ' + str(i+1))
            a[i] += mi
            if a[i] < mi:
                mi = a[i]
                ind = i

print(num)
for i in ans:
    print(i)

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

int main(void){
   long long H,W;
   cin >> H >> W;
   
   if(H == 1 || W == 1){
      cout << 1 << endl;
      return 0;
   }
   if(W % 2 == 0){
      cout << W * H / 2 << endl;
   }else{
      W++;
      cout << W * H / 2 - (int)(H / 2) << endl;
   }
   return 0;
}

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

def solve(N: int, M: int, a: "List[int]", b: "List[int]", c: "List[int]"):
    import numpy as np    
    from scipy.sparse import csr_matrix    
    from scipy.sparse.csgraph import floyd_warshall
    omat = csr_matrix((c+c, (a+b, b+a)), shape=(N+1, N+1), dtype=np.int32)
    smat = floyd_warshall(omat)
    return ((omat-smat) > 0).sum() // 2


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools
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
    M = int(next(tokens))  # type: int
    a = [int()] * (M)  # type: "List[int]"
    b = [int()] * (M)  # type: "List[int]"
    c = [int()] * (M)  # type: "List[int]"
    for i in range(M):
        a[i] = int(next(tokens))
        b[i] = int(next(tokens))
        c[i] = int(next(tokens))
    print(solve(N, M, a, b, c))

def test():
    import doctest
    doctest.testmod()

if __name__ == '__main__':
    #test()
    main()


Measured memory_bytes: 38236
#include<bits/stdc++.h>
#define IO ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define ff first
#define ss second
using namespace std;
typedef long long ll;
const int maxn = 1e5 + 5;
const int mod = 1e9 + 7;
vector<ll> phi(maxn);
void gen()
{
    for(int i = 1; i < maxn; i++)
        phi[i] = i;
    for(int j = 2; j < maxn; j++){
        if(phi[j] == j){
            for(int k = j; k < maxn; k += j)
                phi[k] -= phi[k] / j;
        }
    }

}
ll power(ll a, ll p){
    if(p == 0) return 1;
    if(p == 1) return a % mod;
    if(p & 1) return a * power(a, p - 1) % mod;
    ll r = power(a, p / 2);
    return r * r % mod;
}
void add(ll &a, ll b){
    a += b;
    if(a > mod)
        a -= mod;
}
void check()
{
    int cnt = 0;
    int cnt2 = 0;
    set<pair<int, pair<int, int> > > s;
    for(int i = 1; i <= 10; i++) {
        for (int j = 1; j <= 10; j++) {
            for (int k = 1; k <= 10; k++) {
                if(s.find(make_pair(i, make_pair(j, k))) != s.end()) continue;
                s.insert(make_pair(i, make_pair(j, k)));
                int gcd = __gcd(i, __gcd(j, k));
                if(i % 3 == 0 && j % 3 == 0 && k % 3 == 0) cnt2++;
                cout << i << ' ' << j << ' ' << k << " -> " << gcd << '\n';
                if(gcd == 3) cnt++;
            }
        }
    }
    cout << cnt << ' ' << cnt2 << '\n';
}

int main() {
//    check();
//    gen();
    IO;
    int n, k;
    cin >> n >> k;
//    phi[1] = 0;
//    for(int i = 1; i <= k; i++)
//        add(phi[i], phi[i - 1]);

    vector<ll> seq(k + 1);
    for(int i = 1; i <= k; i++)
        seq[i] = power(k / i, n);

    for(int i = k; i >= 1; i--){
        for(int j = i + i; j <= k; j += i)
            add(seq[i], -seq[j]);
    }

//    for(int i = 0; i <= k; i++)
//        cout << "seq[" << i << "] = " << seq[i] << '\n';
    ll ans = 0;
    for(int i = 1; i <= k; i++)
        add(ans, seq[i] * i % mod);

    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 4760
#include <iostream>
using namespace std;
long long a[100005];
int main()
{
    int n;
    cin >> n;
    for(int i=0;i<n;i++)
    {
        cin >> a[i];
    }
    int zero=0;
    for(int i=0;i<n;i++)
    {
        if(a[i]==0)
        {
            zero++;
        }
    }
    if(zero>0)
    {
        cout << 0 << endl;
        return 0;
    }
    long long prod=1;
    for(int i=0;i<n;i++)
    {
        if(a[i]<=1000000000000000000/prod)
        {
            prod=prod*a[i];
        }
        else
        {
            cout << -1 << endl;
            return 0;
        }
    }
    cout << prod << endl;
    return 0;
}


Measured memory_bytes: 4412
#include <stdio.h>

int main()
{
	int N;
	scanf("%d",&N);
	int C[20],V[20];
	for ( int i = 0; i < N; i++ ) {
		scanf("%d",&C[i]);
	}
	for ( int i = 0; i < N; i++ ) {
		scanf("%d",&V[i]);
	}

	int sum = 0;
	for ( int i = 0; i < N; i++ ) {
		if ( C[i] - V[i] > 0 ) sum += C[i] - V[i];
	}

	printf("%d\n",sum);
  	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
const int MAX = 510000;

int main() {
	ll N, K;
    cin >> N >> K;
    ll ans = 0LL;
    for (int i=K; i<=N+1; i++) ans += i*(N-i+1)%MOD+1;
    cout << ans%MOD << endl;
}


Measured memory_bytes: 3632
//  Created by conan1024hao in 2019.
//  Copyright © 2019 conan1024hao. All rights reserved.
//  専用ライブラリです、自由にコピーして構いません。
//  感谢看我的代码！Wechat:conan1024hao QQ:810396815
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define IINF 10e8
#define INF 10e16
#define MOD 1000000007
#define mod 1000000007
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define Endl endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
//using Int=int_fast64_t;
typedef long long int ll;
typedef pair<ll,ll>Pll;
typedef pair<int,int>Pin;
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[8]={-1,0,1,0,1,1,-1,-1};
int dy[8]={0,-1,0,1,1,-1,1,-1};
char dir[4]={'u','l','d','r'};
ll cmp1(pair<ll,string>a,pair<ll,string> b){
        if(a.fi!=b.fi)
        return a.fi<b.fi;
        else
        return a.se<b.se;
}
//--------------------------------------------------------------------------

//---------------------------------------------------------------------------
int main(){//問題をちゃんと見ろ!!!!!!!!!!!!!!!!!      llか??????????        memset()!!!!!!!!!!!!       ペナを減らせ!!!!!!!!!!!!!
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    int N;
    scanf("%d",&N);
    int res=N;
    for(int i=0;i<=N;i++) {
    int cc =0;
    int t=i; while(t>0)cc+=t%6,t/=6; t=N-i; while(t>0)cc+=t%9,t/=9; if(res>cc)res=cc;
    } printf("%d\n",res);
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------




Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.util.regex.Pattern;

import java.io.InputStreamReader;

public class Main {

    public static void main(String[] args) {

        try(var br = new BufferedReader(new InputStreamReader(System.in))) {

            if(Pattern.matches("[A-Z]", br.readLine())){
                System.out.println("A");
            }else{
                System.out.println("a");
            }

        } catch (IOException e) {
            e.printStackTrace();
        }
    }

}

Measured memory_bytes: 33716
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int a[1000];
    for(int i=0;i<n;i++)
    cin>>a[i];
    int count=1;
    int max=a[0];
    for(int i=1;i<n;i++)
    {
        if(a[i]>=max)
        {
            count++;
            max=a[i];
        }
    }
    cout<<count;
    return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
#include <set>
#include <array>
#include <stdio.h>
#include <string.h>
using ll = long long;
using ull = unsigned long long;
using namespace std;
#define int long long
#define CONTAINS_VEC(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define ARY_REVERSE(v,a) (reverse((v), (v)+(a)))
#define REP(i, n) for (int (i)=0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()
#define CONTAINS_SET(m, a) (m).find((a)) != m.end()
void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YESNO(bool b) { cout << (b ? "YES" : "NO") << endl; }

int flg[1000001];

signed main()
{
	int s;
	cin >> s;

	int cur = s;
	flg[cur] = true;
	for (int i = 0; i <= 1000000; i++)
	{
		if (cur % 2 == 0) cur /= 2;
		else cur = 3 * cur + 1;

		if (flg[cur])
		{
			cout << (i + 2) << endl;
			return 0;
		}
		
		flg[cur] = true;
	}
}



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

using namespace std;

int main() {
  int a, b, k;
  cin >> a >> b >> k;
  bool turn = true;
  for(int i = 0; i < k; ++i) {
    if(turn) {
      if(a % 2 == 1) --a;
      a /= 2;
      b += a;
    } else {
      if(b % 2 == 1) --b;
      b /= 2;
      a += b;
    }
    turn = !turn;
  }
  cout << a << " " << b << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
using Graph=vector<vector<int>>;
using edge= struct{int to;ll cost;};


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


int main()
{
  int a,b,ans;
  cin>>a>>b;
  ans=a-2*b;
  if(ans<0)
  {
    cout<<0<<endl;
    return 0;
  }
  cout<<ans<<endl;

}

Measured memory_bytes: 256