akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define Dim 1000003
using namespace std;
ifstream f("A.in");
typedef long long ll;
ll V[Dim];
ll fr[Dim];

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

   for(int i=1;i<=N;i++)
   {
       cin>>V[i];
       fr[V[i]]++;
   }
   sort(V+1,V+N+1);

   if(fr[1])
   {
       if(fr[1]==1)
       cout<<1;
       else
       cout<<0;

       return 0;
   }

   int i=1,ans=0;
   while(i<=N)
   {
       if(fr[V[i]]==1)
       {
           bool ok=1;
       for(int j=2;j*j<=V[i]&&ok==1;j++)
       if(V[i]%j==0)
       {
           int d1=j,d2=V[i]/j;
           if( fr[d1]!=0 || fr[d2]!=0 ) ok=0;
       }
       if(ok==1) ans++;

       }
       i++;
   }
   cout<<ans;

   return 0;
}


Measured memory_bytes: 12820
#include <bits/stdc++.h>
using namespace std;
#define Int int64_t
#define dump(x) cout << (x) << endl
#define fi first
#define se second
Int mod = 1e9+7;
Int INF = 1e18;
double EPS = 0.00000001;
//Int mod = 1e6+3;

int main() {
    Int n;
    cin >> n;
    vector<Int> a(n);
    for (Int i = 0; i < n; i++) cin >> a[i];
    Int x = a[0];
    for (Int i = 1; i < n - 1; i+=2) {
        x = x - a[i] + a[i + 1];
    }
    x /= 2;
    vector<Int> res(n, 0);
    res[0] = x * 2;
 //   dump(x);
    for (Int i = 0; i < n; i++) {
        x = a[i] - x;
        if (i < n - 1) {
            res[i + 1] = x * 2;
        }
    }
    for (Int i = 0; i < n; i++) cout << res[i] << " ";
    cout << endl;
    return 0;
}

Measured memory_bytes: 2944
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;

int main(void) {
	ll n, a, b;
	cin >> n >> a >> b;
	if ((b - a) % 2 == 0) {
		cout << (b - a) / 2;
	}
	else {
		ll len = min(n - a, b - 1);
		cout << len - (b - a - 1) / 2;
	}
}

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

const ll mod =1000000007;

ll powmod(ll x,ll y){
	ll res=1;
	for(ll i=0;i<y;i++){
		res=res*x%mod;
	}
	return res;
}

vector<int> forintinput(int n) {
	vector<int> x;
	for(int i = 0;i < n;i++){
		int ia;
		cin >> ia;
		x.push_back(ia);
	}
	return x;
}
int main(){
	ll n;
	cin >> n;
	ll ans = powmod(10,n)-powmod(9,n)-powmod(9,n)+powmod(8,n);
	ans%=mod;
	ans=(ans+mod)%mod;
	cout << ans << endl;
}

Measured memory_bytes: 3624
import sys

# W H N X軸の最大、Y軸の最大、点の個数
w, h, n = map(int, input().split())

# xi, yi, ai 点のX座標、Y座標、処理
list = []
for i in range(n):
    xi, yi, ai = map(int, input().split())
    list.append([xi, yi, ai])

# 白で残っている座標初期化
x_min, y_min = 0, 0
x_max, y_max = w, h

for list_1 in list:
    # 処理が 1 なら X軸最小より大きければ入れ替える
    if list_1[2] == 1:
        if x_min < list_1[0]:
            x_min = list_1[0]
    # 処理が 2 なら X軸最大より小さければ入れ替える
    if list_1[2] == 2:
        if x_max > list_1[0]:
            x_max = list_1[0]
    # 処理が 3 なら Y軸最小より大きければ入れ替える
    if list_1[2] == 3:
        if y_min < list_1[1]:
            y_min = list_1[1]
    # 処理が 2 なら X軸最大より小さければ入れ替える
    if list_1[2] == 4:
        if y_max > list_1[1]:
            y_max = list_1[1]

# 残った面積は (X最大 - X最小) * (Y最大 - Y最小)
area = (x_max - x_min) * (y_max - y_min)
if (x_max - x_min) > 0 and (y_max - y_min) > 0:
    print(area)
else:
    print(0)

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

S = input()
CHR = [chr(i) for i in range(97, 97+26)]

judge = 1
i = 0

while(judge > 0 and i <= 25):
    judge = S.count(CHR[i])
    i = i+1

if(judge==0):
    print(CHR[i-1])
else:
    print("None")




Measured memory_bytes: 3188
#include <cstdio>
#include <string>
#include <iostream>
using namespace std;
int main()
{
	int n;
	string s;
	cin >> n >> s;
	for(int i(0);i<s.size();++i)
		s[i] = (s[i]-'A'+n)%26+'A';
	cout << s;
	return 0;
}


Measured memory_bytes: 256
n, q = map(int, input().split())
input_list = []
for i in range(n):
    name, time = input().split()
    input_list.append([str(name), int(time)])
queue_head = 0
now_time = 0
while queue_head != len(input_list):
    if q < input_list[queue_head][1]:
        input_list.append([input_list[queue_head][0], input_list[queue_head][1] - q])
        queue_head += 1
        now_time += q
    else:
        now_time += input_list[queue_head][1]
        print(input_list[queue_head][0], now_time)
        queue_head += 1



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

a = []

for i in range(N):
    a.append(input())

ind = 0
i = 0
flag = 0
while i < N:
    if a[ind] == "2":
        flag = 1
        i += 1
        break
    else:
        ind = int(a[ind])-1
    
    i += 1

if flag == 1:
    print(i)
else:
    print("-1")

Measured memory_bytes: 9468
#include <stdio.h>
typedef long long ll;

int main(void)
{
    ll a, ans;
    double b;
    scanf("%lld%lf", &a, &b);

    int tmp = b * 100 + 0.5;
    ans = a * tmp;
    printf("%lld\n", ans / 100);
    return 0;
}

Measured memory_bytes: 1740
n,m=map(int,input().split())
drink=[]
for i in range(n):
    a,b=map(int,input().split())
    drink.append([a,b])

ans=0
drink.sort()
cnt=0
while(m>0 and cnt<n):
    if m>=drink[cnt][1]:
        m-=drink[cnt][1]
        ans+=drink[cnt][0]*drink[cnt][1]
    else:
        ans+=drink[cnt][0]*m
        m=0
    cnt+=1

print(ans)

Measured memory_bytes: 20048
#include <queue>
#include <cstdio>
inline int getInt(){ int s; scanf("%d", &s); return s; }

#include <set>

using namespace std;

int main(){
  const int l = getInt();

  int n = 1;
  vector<pair<int, pair<int, int> > > edges;

  {
    int p2 = 1;
    int sum = 0;
    while(sum + p2 < l) {
      sum += p2;
      p2 *= 2;
      n++;
    }

    p2 /= 2;
    for(int i = 0; i < n - 1; i++){
      edges.push_back(make_pair(i, make_pair(i + 1, 0)));
      edges.push_back(make_pair(i, make_pair(i + 1, p2)));
      p2 /= 2;
    }

    int cur = sum + 1;

    for(int i = 0; i < n; i++){
      const int r = l - 1 - cur;
      if(r >= 0 && r >= sum){
	edges.push_back(make_pair(0, make_pair(i, cur)));
	cur += sum + 1;
      }
      sum = (sum + 1) / 2 - 1;
    }
  }

  printf("%d %d\n", n, (int)edges.size());
  for(const auto &e : edges){
    printf("%d %d %d\n", e.first + 1, e.second.first + 1, e.second.second);
  }

  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <boost/multiprecision/cpp_int.hpp>

using bint = boost::multiprecision::cpp_int;
bint power(const int& pow)
{
    bint ans = 1;
    for (int i = 0; i < pow; i++) {
        ans *= 2;
    }
    return ans;
}


int main()
{
    std::vector<bint> pows{};
    for (int i = 0; i < 33; i++) {
        pows.emplace_back(power(i));
    }

    int N;
    std::cin >> N;
    std::vector<int> as{};
    for (int i = 0; i < N; i++) {
        int a;
        std::cin >> a;
        as.emplace_back(a);
    }
    int ans = 0;
    std::sort(as.begin(), as.end());
    while (as.size() > 0) {
        int s = as.at(as.size() - 1);
        as.pop_back();
        int upper_pow = -1;
        for (int i = 0; i < 33; i++) {
            if (s < power(i)) {
                upper_pow = i;
                break;
            }
        }
        int diff = static_cast<int>(power(upper_pow) - s);
        auto it = std::lower_bound(as.begin(), as.end(), diff);
        if (it != as.end() and *it == diff) {
            as.erase(it, it + 1);
            ans++;
        }
    }
    std::cout << ans << std::endl;
    return 0;
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n,k,ans;
  cin >> n >> k;
  ans = 1;
  while(true){
    if(n/k > 0){
      n /= k;
      ans++;
    }
    else
      break;
  }
  cout << ans << endl;
}

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

const int mod=1e9+7;
int s,ans,f[1005][2005],g[1005][2005];

int main(){

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

    cin>>s;
    f[0][s]=1;
    for(int i=s;i>=0;i--)g[0][i]=1;
    for(int i=1;i<=700;i++){
        for(int j=s;j>=0;j--){
            f[i][j]=g[i-1][j+3];
            g[i][j]=(g[i][j+1]+f[i][j])%mod;
        }
        ans=(ans+f[i][0])%mod;
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 14580
s = str(input())
sum=0
for i in range(len(s)):
    if(i%2==0 and int(s[i])==1):
        sum+=1
    if(i%2==1 and int(s[i])==0):
        sum+=1
if(sum > (len(s)-sum)):
    print(len(s)-sum)
else:
    print(sum)

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

const int N = 1e6 + 5;

#define st first
#define nd second
#define make(a,b) make_pair(a,b)

typedef pair<int,int> pun;
typedef long long ll;

long long tab[N];

int main()
{
	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; i ++) {
		scanf("%lld", tab + i);
	}
	long long wynik = 0;
	while (true) {
		long long ile = 0;
		long long wklad = 0;
		for (int i = 0; i < n; i ++) {
			wklad = tab[i] / n;
			tab[i] %= n;
			tab[i] -= wklad;
			ile += wklad;
		}
		wynik += ile;
		if (ile == 0) {
			break;
		}
		for (int i = 0; i < n; i ++) {
			tab[i] += ile;
		}
	}
	printf("%lld\n", wynik);
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
	int a, b, c, count = 0;
	scanf("%d %d %d", &a, &b, &c);
	while(a <= b){
		if(c % a == 0){
			count++;
		}
		a++;
	}
	printf("%d\n", count);
	return 0;
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
#define ll long long 
#define ld long double
#define X first
#define Y second
#define pb push_back
#define max_el(x) max_element(x.begin(),x.end())-x.begin()
#define min_el(x) min_element(x.begin(),x.end())-x.begin()
#define mp make_pair
#define endl '\n'
#define fastread ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
// DONT USE MEMSET, USE VECTORS

void solve(){
	ll x;
	cin>>x;
	// if(x == 1){
	// 	cout<<1<<endl;
	// 	return;
	// }
	ll moves = 1;

	ll l = 1;
	ll h = x;

	while(l<=h){
		ll m = l + (h-l)/2;
		ll tot = m/2*11;
		if(m%2) tot += 6;
		if(tot >= x){
			moves = m;
			h = m-1;
		}
		else{
			l = m+1;
		}
	}

	cout<<moves<<endl;


}

int main(){
	fastread;
	int t = 1;
	// cin>>t;
	for(int i=1;i<=t;i++){
		// cout<<"Case #"<<i<<": ";
		solve();
	}
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main() {
	int K, A, B;
	scanf("%d%d%d", &K, &A, &B);
	int cna = 0;
	long long  ans = 1;
	while (K)
	{
		if (B - A > 2 && ans >= A && K >= 2) {
			ans += B - A;
			K = K - 2;
		}
		else {
			ans++;
			K--;
		}
	}
	printf("%lld\n", ans);
	return 0;
}



Measured memory_bytes: 128
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()
    #約数の大きい順にソートしたい場合
    #divisors.sort(reverse=True)
    return divisors

ans=0
n=int(input())
for i in range(1,n+1):
    ans+=(len(make_divisors(i))==8 and i%2==1)
print(ans)

Measured memory_bytes: 3060
import java.util.ArrayList
import java.util.Random

private fun readLn() = readLine()!! // string line
private fun readInt() = readLn().toInt() // single int
private fun readLong() = readLn().toLong() // single int
private fun readStrings() = readLn().split(" ") // list of strings
private fun readInts() = readStrings().map { it.toInt() } // list of ints



fun dfs(u: Int, p: Int, lvl: Int, adj: Array<ArrayList<Int>>, V1: ArrayList<Int>, V2: ArrayList<Int>) {
    if (lvl % 2 == 0) {
        V1.add(u)
    } else {
        V2.add(u)
    }
    for (v in adj[u]) {
        if (v == p) continue
        dfs(v, u, lvl + 1, adj, V1, V2)
    }
}

fun main(args: Array<String>) {

    val N = readInt()
    val adj = Array(N) { ArrayList<Int>() }
    for ((u, v) in (0 until N - 1).map { readInts().map { it - 1 } }) {
        adj[u].add(v)
        adj[v].add(u)
    }
    val V1 = ArrayList<Int>()
    val V2 = ArrayList<Int>()
    val r = Random()
    dfs(r.nextInt(N), -1, 0, adj, V1, V2)

    val (I0, I1, I2) = listOf(ArrayList<Int>(),ArrayList<Int>(),ArrayList<Int>())
    for (i in 1..N) {
        if (i % 3 == 1) I1.add(i)
        if (i % 3 == 2) I2.add(i)
        if (i % 3 == 0) I0.add(i)
    }

    val ans = Array(N) { 0 }
    if (Math.min(V1.size, V2.size) < I2.size) {
        val n = if (V1.size < V2.size) V1 else V2
        while (n.size > 0) {
            val t = I0
            ans[n.last()] = t.last()
            t.removeAt(t.size - 1)
            n.removeAt(n.size - 1)
        }
        val m = if (V1.size < V2.size) V2 else V1
        while (m.size > 0) {
            val t = if (I0.isNotEmpty()) I0 else if (I1.isNotEmpty()) I1 else I2
            ans[m.last()] = t.last()
            t.removeAt(t.size - 1)
            m.removeAt(m.size - 1)
        }
    } else {
        val n = if (V1.size < V2.size) V1 else V2
        while (n.size > 0) {
            val t = if (I2.isNotEmpty()) I2 else I0
            ans[n.last()] = t.last()
            t.removeAt(t.size - 1)
            n.removeAt(n.size - 1)
        }
        val m = if (V1.size < V2.size) V2 else V1
        while (m.size > 0) {
            val t = if (I0.isNotEmpty()) I0 else if (I1.isNotEmpty()) I1 else I2
            ans[m.last()] = t.last()
            t.removeAt(t.size - 1)
            m.removeAt(m.size - 1)
        }
    }
    println(ans.joinToString(" "))



}

/*
1 1 5 -> 3
1 5 1 -> 2
5 1 1 -> 1
 */


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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
template<typename T> using V = vector<T>;
template<typename T> using pq = priority_queue<T>;
template<typename T> using minpq = priority_queue<T, vector<T>, greater<T>>;
template<typename T, typename K> using ump = unordered_map<T, K>;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll e5 = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto i:mp)
#define eb emplace_back
#define F first
#define S second
#define all(obj) (obj).begin(), (obj).end()

ll inl() {
    ll x;
    cin >> x;
    return (x);
}

string ins() {
    string x;
    cin >> x;
    return (x);
}

/* ----------- ANSWER ----------- */
/* ------------------------------ */

int main() {
#ifdef MY_DEBUG
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wmissing-noreturn"
    while (true) {
#pragma clang diagnostic pop
#endif
        ll n, k;
        cin >> n >> k;

        if (k == 1)cout << 0 << endl;
        else cout << n - k << endl;

#ifdef MY_DEBUG
    }
#endif
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (int)(n); i++)
#define repR(i, n) for(ll i = n; i >= 0; i--)
#define For(i, m, n) for(ll i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;
typedef long double ld;
using namespace std;
struct Fast {Fast(){std::cin.tie(0);std::ios::sync_with_stdio(false);}} fast;

int main(void){
    string result = "No";
    ll A,B,C;
    cin >> A >> B >> C;
    if((A<C && C < B)
       || (A>C && C > B)){
        result = "Yes";
    }
    
    
    cout << result << endl;
    return 0;
}


Measured memory_bytes: 256
H,W=map(int,input().split())
mas=[list(s for s in input()) for _ in range(H)]
height=[]
width=[]
for i in range(H):
    for j in range(W):
        if mas[i][j]=='#':
            height.append(i)
            width.append(j)

height=set(height)
height=list(height)
width=set(width)
width=list(width)
for a in height:
    ans=[]
    for b in width:
        ans.append(mas[a][b])
    print(*ans,sep='')

Measured memory_bytes: 4764
n, m, k = map(int, input().split())

ans = False
for i in range(n + 1):
    if ans:
        break
    for j in range(m + 1):
        if i * (m - j) + (n - i) * j == k:
            ans = True
            break

if ans:
    print('Yes')
else:
    print('No')


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

int main(){
    int N;
    cin >> N;
    int H[N];
    for( int i = 0; i < N; i++){
        cin >> H[i];
    }

    bool ans = true;
    H[0] -= 1;
    for( int i = 1; i < N ; i++ ){
        if( H[i] >= H[i-1] ){
            // reduce 1 or no processing
            H[i] = max( H[i]-1, H[i-1] );
        }else{
            ans = false;
        }
    }
    printf( ans ? "Yes" : "No");
} 

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <vector>
using namespace std;

const int inf = 1e9;
const int mod = 1e9+7;

int main(void){
    int a, b, c;
    string s;
    cin >> a >> b >> c;
    if(a == b){
        cout << c << endl;
    }else if(b == c){
        cout << a << endl;
    }else if(a == c){
        cout << b << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;using ll=int_fast64_t;using ld=long double;using pll=pair<ll,ll>;using pld=pair<ld,ld>;const ll INF=1LL<<60;
void solve();int main(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(10);solve();}
#define fi first
#define se second
#define SELECTOR(_1,_2,_3,SELECT,...) SELECT
#define rep(...) SELECTOR(__VA_ARGS__,_rep1,_rep0)(__VA_ARGS__)
#define _rep0(i,n) for(ll i=0;i<n;++i)
#define _rep1(i,k,n) for(ll i=k;i<n;++i)
template<class T> vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<class... Ts> auto make_v(size_t a,Ts... ts){return vector<decltype(make_v(ts...))>(a,make_v(ts...));}
template<class T> inline bool chmax(T &a,const T &b){if(a<b){a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a,const T &b){if(a>b){a=b; return 1;} return 0;}
template<class T> void contout(const T &v){for(auto it=v.begin();it!=v.end();++it,cout<<(it!=v.end()?" ":"\n"))cout<<*it;}

template<class T,class F>
constexpr T bisection(T l,T r,F f,bool left=true,bool discrete=true){
  T eps=discrete?1:pow(10,-12);
  if((!left)^f(r)) return left?r:r+1;
  if(left^f(l)) return left?l-1:l;
  while(r-l>eps){
    T h=(l+r)/2;
    if((!left)^f(h)) l=h;
    else r=h;
  }
  return discrete?left?l:r:(l+r)/2;
}

void solve(){
  ll n,k; cin>>n>>k;
  vector<ll> A(n);
  rep(i,n) cin>>A[i];
  sort(A.begin(),A.end());

  auto check=[&](ll x){
    vector<ll> dp(k,0);
    dp[0]=1;
    rep(i,n){
      if(i==x) continue;
      vector<ll> newdp=dp;
      ll a=A[i];
      rep(j,k){
        if(j+a<k) newdp[j+a]=max(dp[j+a],dp[j]);
      }
      dp=newdp;
    }
    return *max_element(dp.begin()+max((ll)0,k-A[x]),dp.end());
  };
  cout<<bisection((ll)0,n-1,check,false)<<"\n";
}


Measured memory_bytes: 384
#include <iostream>
#include <utility>
#include <queue>

int main(int argc, char const *argv[]){
	int n,q,t = 0;
	std::cin >> n >> q;
	std::queue< std::pair<std::string,int> > que;
	
	for (int i = 0; i < n; ++i){
		std::string nm;
		int tm;
		std::cin >> nm >> tm;
		que.push(make_pair(nm,tm));
	} 

	while(!que.empty()){
		std::pair<std::string,int> front = que.front();
		que.pop();
		if(front.second - q > 0){
			t += q;
			que.push(make_pair(front.first,front.second-q));
		}else{
			t += front.second;
			std::cout << front.first << ' ' << t << std::endl;
		}
	}
	return 0;
}


Measured memory_bytes: 6320
fn read<T: std::str::FromStr>(
    stdin_lock: &mut std::io::StdinLock,
    buf: &mut Vec<u8>,
    delimiter: u8,
) -> T {
    buf.clear();
    let l = std::io::BufRead::read_until(stdin_lock, delimiter, buf).unwrap();
    buf.truncate(l - 1); // remove delimiter
    let s = unsafe { std::str::from_utf8_unchecked(&buf) };
    s.parse().unwrap_or_else(|_| panic!("read"))
}

fn main() {
    let stdin = std::io::stdin();
    let mut stdin_lock = stdin.lock();
    let mut buf: Vec<u8> = Vec::new();
    let a: i32 = read(&mut stdin_lock, &mut buf, b' ');
    let b: i32 = read(&mut stdin_lock, &mut buf, b' ');
    let k: i32 = read(&mut stdin_lock, &mut buf, b'\n');

    let mut count = 0;
    let mut ans = 0;
    for i in 0..b {
        let n = b - i;
        if a % n == 0 && b % n == 0 {
            count += 1;
            if count == k {
                ans = n;
                break;
            }
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <tuple>
# include <unordered_map>
# include <numeric>
# include <complex>
# include <bitset>
# include <random>
# include <chrono>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
typedef pair<LL, LL> P;
constexpr int INF = 2000000000;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
const double PI = acos(-1);
int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
# define ALL(x)      (x).begin(),(x).end()
# define UNIQ(c)     (c).erase(unique(ALL((c))),(c).end())
# define mp          make_pair
# define eb          emplace_back
# define FOR(i,a,b)  for(int i=(a);i<(b);i++)
# define RFOR(i,a,b) for(int i=(a);i>=(b);i--)
# define REP(i,n)    FOR(i,0,n)
# define INIT        std::ios::sync_with_stdio(false);std::cin.tie(0)

int n;

vector<pair<int, int>> v;

int main() {
	cin >> n;
	REP(i, n) {
		int a, b;
		cin >> a >> b;
		v.emplace_back(mp(a, b));
	}
	sort(ALL(v));
	int ans = v[0].first-1+n;
	for (int i = 1; i < n; i++) {
		ans += min(abs(v[i].first - v[i - 1].first)-1, abs(v[i].second - v[i - 1].second)-1);
	}
	ans += v[n - 1].second;
	cout << ans << endl;
}

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

int main(){
  int N;
  cin >> N;
  for(int i=0;i<N;i++){
    string S;
    cin >> S;
    map<char,int> loop;
    map<char,map<int,char> > mp;
    mp['1'][0]='.';loop['1']=5;
    mp['1'][1]=',';
    mp['1'][2]='!';
    mp['1'][3]='?';
    mp['1'][4]=' ';
    mp['2'][0]='a';loop['2']=3;
    mp['2'][1]='b';
    mp['2'][2]='c';
    mp['3'][0]='d';loop['3']=3;
    mp['3'][1]='e';
    mp['3'][2]='f';
    mp['4'][0]='g';loop['4']=3;
    mp['4'][1]='h';
    mp['4'][2]='i';
    mp['5'][0]='j';loop['5']=3;
    mp['5'][1]='k';
    mp['5'][2]='l';
    mp['6'][0]='m';loop['6']=3;
    mp['6'][1]='n';
    mp['6'][2]='o';
    mp['7'][0]='p';loop['7']=4;
    mp['7'][1]='q';
    mp['7'][2]='r';
    mp['7'][3]='s';
    mp['8'][0]='t';loop['8']=3;
    mp['8'][1]='u';
    mp['8'][2]='v';
    mp['9'][0]='w';loop['9']=4;
    mp['9'][1]='x';
    mp['9'][2]='y';
    mp['9'][3]='z';
    char set='0';
    int count=0;
    for(int i=0;i<S.size();i++){
      if(S[i]=='0'){
        if(set!='0'){
          cout << mp[set][count%loop[set]];
          set='0';
        }
        count = 0;
      }else if(S[i]==set){
        count++;
      }else{
        set=S[i];
      }
    }
    cout << endl;
  }
}



Measured memory_bytes: 3224
while True:
    n,m=map(int,input().split())
    if n==0:break
    a=[int(input())for _ in range(n)]
    b=[int(input())for _ in range(m)]
    sa=sum(a)
    sb=sum(b)
    f=0
    for i in a:
        for j in b:
            if sa-i+j==sb-j+i:
                print(i,j)
                f=1
                break
        if f:
            break
    else:
        print(-1)


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

int main(){
  string s;
  cin >> s;
  if(s == "SUN") cout << 7 << endl;
  else if(s == "MON") cout << 6 << endl;
  else if(s == "TUE") cout << 5 << endl;
  else if(s == "WED") cout << 4 << endl;
  else if(s == "THU") cout << 3 << endl;
  else if(s == "FRI") cout << 2 << endl;
  else if(s == "SAT") cout << 1 << endl;
  return 0;
}

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

#define ipair pair<int,int>
#define rep(i,n) for(i=0;i<n;i++)
#define repj(i,j,n) for(i=j;i<n;i++)

#define PB(a,i) (a).push_back(i)
#define ALL(a) (a).begin(),(a).end()
#define SIZE(a,n) (a).resize(n)
#define SORT(a) sort(ALL(a))
#define RSORT(a, type) sort(ALL(a),greater<type>())
#define MAPIN(a,i,j) (a).insert(make_pair(i,j))
#define PREC(n) setprecision(n)

#define OK(i) cout<<"OK "<<i<<endl
#define Yes cout<<"Yes"<<endl
#define YES cout<<"YES"<<endl
#define No cout<<"No"<<endl
#define NO cout<<"NO"<<endl

using namespace std;

typedef unsigned long long lli;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector< vi > Matrix;

int main() {
    int n,m;

    cin>>n>>m;

    if(n==m)Yes;
    else No;
	
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<long>a(n);
  vector<int>colors(n,0);
  vector<long>arrayMin;
  int i,j;
  for(i=0;i<n;i++){
    cin >> a[i];
  }
  arrayMin.push_back(a[0]);
  for(i=1;i<n;i++){
    if(arrayMin[arrayMin.size()-1]>=a[i]){
      arrayMin.push_back(a[i]);
    }else{
      for(j=0;j<arrayMin.size();j++){
        if(arrayMin[j]<a[i]){
          arrayMin[j]=a[i];
          break;
        }
      }
    }
  }
  cout << arrayMin.size() << endl;

}


Measured memory_bytes: 2552
#include<bits/stdc++.h>
using namespace std;
#define pb			push_back
#define vi  		vector<int>
#define all(a)		(a).begin(),(a).end()
#define F 			first
#define S 			second
#define endl		"\n"
#define fast 		ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define int 		long long int
#define mod			1000000007

static int t[3][4001];
int32_t main(){

	int n;cin>>n;
	int arr[n-1];
	map<int,int>mp;
	for(int i=0;i<n;i++){
		mp[i+1]=0;
	}
	for(int i=0;i<n-1;i++){
		cin>>arr[i];
		mp[arr[i]]+=1;
	}
	for(auto x:mp){
		cout<<x.S<<endl;
	}
	return 0;
}

Measured memory_bytes: 17656
x1, y1, x2, y2 = map(int,input().split())
dx, dy = x2-x1, y2-y1

x3, y3 = x1 + dx - dy, y1 + dy + dx
x4, y4 = x1 - dy, y1 + dx

print(x3, y3, x4, y4)


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

int main(){
    int h, w;
    char d = '.';
    while(true){
        cin >> h >> w;
        if(h == 0 && w == 0)
            break;
        for(int i = 0; i < h; i++){
            if(i == 0 || i == (h - 1)) {
                for (int j = 0; j < w; j++) {
                    cout << '#';
                }
            }
            if(i > 0 && i < (h - 1)){
                cout << '#';
                for(int i = 0; i < (w - 2); i++){
                    cout << '.';
                }
                cout << '#';
            }
            cout << '\n';
        }
        cout << '\n';
    }
    return 0;
}

Measured memory_bytes: 2936
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <array>
#include <bitset> 
#include <unordered_map>

using namespace std;
typedef long long LL;
typedef pair<int,int> P;

const LL M=1e9+7;
int main() {
	int N;
	cin >> N;
	LL ct[60]={};
	for(int i=0;i<N;i++){
		LL a;
		cin >> a;
		for(int j=0;j<60;j++){
			if(a&(1LL<<j)){
				ct[j]++;
			}
		}
	}
	LL ret=0;
	for(int i=0;i<60;i++){
		LL v=ct[i]*(N-ct[i])%M;
		for(int j=0;j<i;j++){
			v*=2;
			v%=M;
		}
		ret+=v;
		ret%=M;
	}
	cout << ret << endl;



	return 0;
}



Measured memory_bytes: 888
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cmath>

using namespace std;

int main() {
  int N, M;
  cin >> N >> M;
  vector<int64_t> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  vector<int64_t> B(M);
  vector<int64_t> C(M);
  vector<pair<int64_t, int64_t>> BC(M);
  auto cmp = [](pair<int64_t, int64_t> &a, pair<int64_t, int64_t> &b) {
               return b.second > a.second;
             };
  priority_queue<pair<int64_t, int64_t>, vector<pair<int64_t, int64_t>>, decltype(cmp)> q(cmp);
  for (int i = 0; i < M; i++) {
    int64_t B, C;
    cin >> B >> C;
    pair<int64_t, int64_t> p = make_pair(B, C);
    q.push(p);
  }
  sort(A.begin(), A.end());

  for (int i = 0; i < N; i++) {
    if (q.empty()) {
      break;
    }
    auto p = q.top();
    q.pop();
    if (p.second <= A[i]) {
      break;
    }
    A[i] = p.second;
    if (p.first > 1) {
      pair<int64_t, int64_t> nextp = make_pair(p.first-1, p.second);
      q.push(nextp);
    }
  }
  int64_t sum = 0;
  for (auto a : A) {
    sum += a;
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 6388
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
#define double long double
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef vector<pii> VP;
typedef vector<string> VS;
typedef priority_queue<int> PQ;
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; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
#define eps 1e-12 
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int D; cin >> D;
	int C[26];
	int S[370][26];
	VI T(D);
	REP(i, 26)cin >> C[i];
	REP(i, D)REP(j, 26)cin >> S[i][j];

	VI last(26, -1);
	int ans = 0;
	REP(i, D) {
		
		int res;
		VI ress;
		int sa = -INF;
		int out;

		REP(t, 26) {
			int tmp = ans;
			VI tmpp = last;
			
			tmp += S[i][t];
			tmpp[t] = i;
			REP(j, 26) {
				tmp -= C[j] * (i - tmpp[j]);
			}


			if (sa < tmp - ans) {
				res = tmp;
				ress = tmpp;
				sa = tmp - ans;
				out = t + 1;
			}
		}
		last = ress;
		ans = res;
		cout << out << '\n';
	}


	return 0;
}

Measured memory_bytes: 3740
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define sz(x) (int)((x).size())
#define debug(x) cout << #x << ":" << x << ' ';
#define debugg(x) cout << #x << ":" << x << ' ' << "\n";
#define endl "\n"
#define L(X) ((X)<<1)
#define R(X) (((X)<<1)|1)
#define M(X,Y) (((X)+(Y))>>1)
#define FIN freopen("input.in", "r", stdin);
#define FOUT freopen("output.out", "w", stdout);

using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<ll, ll>;

const int MAXN = 1e5 + 5;
const int MOD = 1e9 + 7;
const int INF = 0x3f3f3f3f;
const long long int LINF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-9;
const double PI = acos(-1);

template<typename T>   T max_self(T& a, T b) { if (a < b) a = b; return a; }
template<typename T>   T min_self(T& a, T b) { if (a > b) a = b; return a; }
template<typename T>   T add(T x, T y) { return ((x % MOD)  + (y % MOD)) % MOD;}
template<typename T>   T mul(T x, T y) { return ((x % MOD) * (long long)(y % MOD)) % MOD;}
template<typename T>   T sub(T x, T y) { return add(x, -y + MOD);}
template<typename T>   T gcd(T a, T b) { return b ? gcd(b, a % b) : a;}
template<typename T>   T lcm(T a, T b) { return a / gcd(a, b) * b;}
template<typename T>   vector<T> read(vector<T>& v, int n) {v.resize(n); for (auto &x : v)cin >> x;}
template<typename T>   void trav(vector<T> &v) {for (int i = 0 ; i < (int)v.size() ; ++i) {cout << v[i]; if (i != (int)v.size() - 1) cout << ' ';}}
int lg2(long long x)   {   return 64 - __builtin_clzll(x) - 1;	}
int lg2(int x)   {   return 32 - __builtin_clzll(x) - 1;	}

vector<int> adj[MAXN];
int dp[MAXN];

int solve(int u, int par) {
	if(dp[u] != -1) return dp[u];
	int dist = 0;
	for(auto &v : adj[u]) {
		if(v == par) continue;
		max_self(dist, 1 + solve(v, u));
	}
	return dp[u] = dist;
}

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

	int n, m;
	cin >> n >> m;

	for(int i = 0, x, y ; i < m ; ++i) {
		cin >> x >> y;
		adj[x].push_back(y);
	}

	int ans = 0;

	memset(dp, -1, sizeof dp);

	for(int i = 1 ; i <= n ; ++i) {
		max_self(ans, solve(i, -1));
	}	

	cout << ans << endl;


	return 0;
}

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

int main() {
    int a, b;
    cin >> a >> b;
    string aa, bb;
    for (int i = 0; i < b; i++) {
        aa += to_string(a);
    }
    for (int i = 0; i < a; i++) {
        bb += to_string(b);
    }
    vector<string> vec;
    vec.push_back(aa);
    vec.push_back(bb);
    sort(vec.begin(), vec.end());
    cout << vec.at(0) << endl;
}


Measured memory_bytes: 3684
#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 INF 1e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{

int h, n;
cin >> h >> n;


int x, ans = 0;
for (int i = 0; i < n; i++){
    cin >> x;
    ans +=x ;
}
if (h <= ans){
    cout << "Yes" << endl;
    }
else {
    cout << "No" << endl;
} 
return 0;
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
#define LL long long

LL N, M, K, ans,mi;
string s;



int main() {
	cin >> N>>M;
	ans = 0;
	mi = 100000000;
	LL a = 0;
	for (int i = 1; i <= N; i++) {
		ans += M + i - 1;
		if (abs(M + i - 1) < mi) {
			mi = abs(M + i - 1);
			a = M + i - 1;
		}
	}

	cout <<ans-a << endl;
	
	return 0;

}

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

using namespace std;
typedef long long ll;
typedef pair< ll , string > P;

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

	rep(i , (( int )( s.size() )) ){
		cout<<"x";
	}
}


Measured memory_bytes: 256
def solve(h):
    n = len(h)
    res = 0
    for y in range(1, max(h)+1):
        x = 0
        while x < n:
            if (h[x] >= y):
                res += 1
                while (x < n) and (h[x] >= y):
                    x += 1
            x += 1
    return res

n = int(input())
h = list(map(int, input().split()))
print(solve(h))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define rep(i, n) for(int (i)=0;(i)<(n);(i)++)
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
bool custom1 (pair<int, int> a, pair<int, int> b) {
  return (a.first < b.first);
}
bool custom2(pair<int, int> a, pair<int, int> b) {
  return (a.second < b.second);
}

const int MAX = 200005;
const long long MOD = 1000000007;
const long long MODMOD = 998244353;
const double PI = acos(-1);

long long fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
struct UnionFind {
  vector<int> p;
  vector<int> s;
  void init(int n) {
    p.resize(n, -1);
    s.resize(n, 1);
  }
  int find(int n) {
    if(p[n] == -1) return n;
    else return find(p[n]);
  }
  int size(int n) {
    return s[find(n)];
  }
  void unite(int n, int m) {
    int pn = find(n);
    int pm = find(m);
    if(pn == pm) return;
    if(s[pn] > s[pm]) {
      s[pn] = s[pn] + s[pm];
      p[pm]= pn;
    } else {
      s[pm] = s[pm] + s[pn];
      p[pn] = pm;
    }
  }
};

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

int main() {
  long long h, w;
  cin >> h >> w;
  if(h == 1 || w == 1) cout << 1 << endl;
  else if(h * w % 2 == 0) cout << h * w / 2LL << endl;
  else cout << h * w / 2LL + 1LL << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
const int N=200050;
const int M=2*N;
int n,a[N];
struct SegmentTree
{
	int mn[M],mx[M];
	void Set(int i, int x)
	{
		i+=n-1;
		mn[i]=mx[i]=x;
		for(i>>=1;i;i>>=1)
		{
			mn[i]=min(mn[i<<1],mn[i<<1|1]);
			mx[i]=max(mx[i<<1],mx[i<<1|1]);
		}
	}
	int GetMx(int l, int r)
	{
		int ans=0;
		for(l+=n-1,r+=n-1;l<=r;l>>=1,r>>=1)
		{
			if(l%2==1) ans=max(ans,mx[l++]);
			if(r%2==0) ans=max(ans,mx[r--]);
		}
		return ans;
	}
	int GetMn(int l, int r)
	{
		int ans=n;
		for(l+=n-1,r+=n-1;l<=r;l>>=1,r>>=1)
		{
			if(l%2==1) ans=min(ans,mn[l++]);
			if(r%2==0) ans=min(ans,mn[r--]);
		}
		return ans;
	}
} ST;
int b[N];
int main()
{
	int k;
	scanf("%i %i",&n,&k);
	for(int i=1;i<=n;i++) scanf("%i",&a[i]),ST.Set(i,a[i]);
	for(int i=1;i<n;i++) b[i]=a[i]<a[i+1],b[i]+=b[i-1];
	int ans=1,cnt=0;
	if(b[k-1]==k-1) cnt=1,ans=0;
	for(int i=2;i<=n-k+1;i++)
	{
		int l=i-1,r=i+k-1;
		if(a[l]!=ST.GetMn(l,r) || a[r]!=ST.GetMx(l,r))
		{
			if(b[r-1]-b[i-1]==k-1) cnt++;
			else ans++;
		}
	}
	if(cnt>0) ans++;
	printf("%i\n",ans);
	return 0;
}

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

int main()
{
    int n,i,j;
    double mid,ans,ara[55];
    cin>>n;
    for (i=1; i<=n; i++)
        cin>>ara[i];
    sort(ara+1, ara+n+1);
    mid=(ara[1]+ara[2])/2.0;
    ara[2]=mid;
    for (i=2; i<n; i++)
    {
        ara[i+1]=(ara[i]+ara[i+1])/2.0;
        mid=ara[i+1];
    }
    cout << mid<<endl;

    return 0;
}


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

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

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

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


using namespace std;
using ll = long long;

const ll MOD = 1000000007;
const ll INF = 1e18;
const double pi = acos(-1);
const int dx4[4] = {1, 0, -1, 0};
const int dy4[4] = {0, 1, 0, -1};
const int dx8[8] = {1,1,0,-1,-1,-1,0,1};
const int dy8[8] = {0,1,1,1,0,-1,-1,-1};


#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()


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; }

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

void solve(){
    
    // remove the bottom 3 lines when you submit this code.
    std::ifstream in("sample.txt");
    std::cin.rdbuf(in.rdbuf());

    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int k; cin >> k;
    
    
    ll ans = 0;
    for (int a = 1; a <= k; a++) {
        for (int b = 1; b <= k; b++) {
            for (int c = 1; c <= k; c++) {
                ans += gcd(gcd(a, b), c);
            }
        }
    }
    cout << ans << endl;
    
}



signed main() {
    solve();
    return 0;
}



Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std; 
int main() {
  string s, t; 
  cin >> s >> t; 
  int mini = INT_MAX;
  for(int i = 0; i < s.length() - t.length() + 1; i++) {
    int ans = 0;
    for(int j = 0; j < t.length(); j++) {
      if(t[j] != s[i+j]) {
        ans++;
      }
    }
    mini = min(mini, ans);
  }
  cout << mini;
  return 0; 
}

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

int main(){
  string a,b;
  cin >> a >> b;
  if(a[0] == b[2] && a[1] == b[1] && a[2] == b[0]) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
using namespace std;
typedef long long ll;

int main() {
	ll x , y, z;
	cin >> x >> y >> z;
	ll l = 0;
	ll r = 1e5;
	ll c = (l+r)/2;
	while(r - l > 1){
		if(y*c + z*(c+1) <= x){
			l = c;
		}else{
			r = c;
		}
		c = (l+r)/2;
	}
	cout << l << endl;
	return 0;
}


Measured memory_bytes: 256
//#pragma GCC target ("avx2")
//#pragma GCC optimization ("O3")
//#pragma GCC optimization ("unroll-loops")
#include <bits/stdc++.h>

using namespace std;

#define int long long
#define sz(a) (int) (a).size()
#define all(a) (a).begin(), (a).end()
#define x first
#define y second

mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);

    int x;
    cin >> x;
    if (1800 <= x) {
        cout << 1 << "\n";
    } else if (1600 <= x) {
        cout << 2 << "\n";
    } else if (1400 <= x) {
        cout << 3 << "\n";
    } else if (1200 <= x) {
        cout << 4 << "\n";
    } else if (1000 <= x) {
        cout << 5 << "\n";
    } else if (800 <= x) {
        cout << 6 << "\n";
    } else if (600 <= x) {
        cout << 7 << "\n";
    } else if (400 <= x) {
        cout << 8 << "\n";
    }

    return 0;
}


Measured memory_bytes: 3652
import bisect
N = int(input())
rs = [list(map(int, input().split())) for i in range(N)]
bs = [list(map(int, input().split())) for i in range(N)]
points = []
for r in rs:
    points.append((r[0], r[1], 'red'))
for b in bs:
    points.append((b[0], b[1], 'blue'))
points.sort()

rys = []
cnt = 0
for p in points:
    if p[2]=='red':
        bisect.insort_left(rys, p[1])
    else:
        idx = bisect.bisect_left(rys, p[1]) - 1
        if idx == -1:
            continue
        else:
            rys.pop(idx)
            cnt += 1
print(cnt)


Measured memory_bytes: 3188
#pragma GCC optimize "O3"

#define F first
#define S second

#include <bits/stdc++.h>

using namespace std;

typedef long long LL;

constexpr int N = 2002;

LL dp[N][2], z, w, a[N];
int n;

LL dfs(bool xy, int prv, LL v) {
  if(prv == n) {
    return abs(v - a[prv]);
  }
  LL &rtn = dp[prv][xy];
  if(rtn != -1)
    return rtn;
  if(!xy)
    rtn = INT_MIN;
  else
    rtn = INT_MAX;
  for(int i = prv+1; i <= n; ++i) {
    if(!xy)
      rtn = max(rtn, dfs(!xy, i, a[prv]));
    else
      rtn = min(rtn, dfs(!xy, i, a[prv]));
  }
  return rtn;
}

int main() {
  memset(dp, -1, sizeof(dp));
  scanf("%d %lld %lld", &n, &z, &w);
  a[0] = w;
  for(int i = 1; i <= n; ++i)
    scanf("%lld", a+i);
  printf("%lld\n", dfs(0, 0, z));
}


Measured memory_bytes: 384
string = input()

odd = list(string[0::2])
even = list(string[1::2])

odd_if = set(odd) <= {'R', 'U', 'D'}
even_if = set(even) <= {'L', 'U', 'D'}

if odd_if and even_if:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
using namespace std;
#include<bits/stdc++.h>
#define Debug(...) fprintf(stderr, __VA_ARGS__)
#define st first
#define nd second
#define FORE(i,a,b) for(int i=(a),b_=(b);i<=b_;++i)
#define FORD(i,a,b) for(int i=(a),b_=(b);i>=b_;--i)
#define TR(c, it) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); it++)
#define removeDuplicate(a) sort(a.begin(), a.end()); a.resize(distance(a.begin(), unique(a.begin(), a.end())))
 
const int N = 1e2 + 1;
const int W = 1e5 + 1; 
const int MOD = 1e9 + 7; 
const int INF =  1e9 + 100; 
long long dp[N][W]; 
 
 
int main() {
    #define TASK "TASK"	
	// freopen(TASK".inp","r",stdin);
	// freopen(TASK".out","w",stdout);
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	int n, w; 
	cin >> n >> w ; 
 
	vector <int> weights(n + 1), values(n + 1);
 
	for (int i = 1; i <= n; ++i) {
		cin >> weights[i] >> values[i]; 
	}
	for(int i = 0; i <= n; ++i) dp[i][0] = 0; 
	for(int i = 0; i <= w; ++i) dp[0][i] = 0;  
	for (int i = 1; i <= n; ++i) {
		for(int j = 0; j <= w; ++j) {
			if (j >= weights[i]) {
				dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - weights[i]] + values[i]); 
			}
			else {
				dp[i][j] = dp[i - 1][j]; 
			}
		}
	}
	cout << dp[n][w] << endl; 
 
 
     
  	return 0;
}

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

int main() {
  int n; cin >>n;
  int b1=0,b2=0,b4=0;
  rep(i,0,n) {
    int a; cin >>a;
    if (!(a&3)) b4+=1;
    else if (!(a&1)) b2+=1;
    else b1+=1;
  }
  int ans=0;
  if (b2==n) ans=1;
  else if (b2==0 && b4-b1>=-1) ans=1;
  else if (b2>0 && b4-b1>=0) ans=1;
  if (ans==1) cout <<"Yes" <<endl;
  else cout <<"No" <<endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
bool dfs(int i,int n){
    if(n<=0){
        if(n==0)return true;
        return false;
    }
    return dfs(i+1,n-i);
}
int main(){
    int n;
    while(cin>>n,n){
        int cnt=0;
        for(int i=1;i<n;i++){
            if(dfs(i,n))cnt++;
        }
        cout<<cnt<<endl;
    }
}

Measured memory_bytes: 1160
a = input()
l=['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
if len(set(a))==26:
  print('None')
else:
  for i in range(len(l)):
    if l[i] not in a:
      print(l[i])
      break

Measured memory_bytes: 3188
l, r = map(int, input().split())
if l % 2019 == 0:
  print(0)
else:
  if l // 2019 + 1 <= r // 2019:
    print(0)
  else:
    a = 2019
    for i in range(l, r + 1):
      for j in range(i + 1, r + 1):
        if a > (i * j) % 2019:
          a = (i* j) % 2019
    print(a)

Measured memory_bytes: 3060
#include <stdio.h>
#include <stdlib.h>

#define N 200
#define M 20000

int main()
{
  int top = 1,S[N],y;
  char str[M];
  
 while(scanf("%s ",str) != EOF){
   
   
    if(str[0] >= '0' && str[0] <= '9'){
      S[top] = atoi(str);
    }
    else if(str[0] == '+'){
      y = S[top-2] + S[top-1];
    top -= 2;
    S[top] = y;
  }
  else if(str[0] == '-'){
    y = S[top-2] - S[top-1];
    top -= 2;
     S[top] = y;     
  }
  else{
    y = S[top-2] * S[top-1];
    top -= 2;
    S[top] = y;
  }

  top++;
  }

  top--;
  printf("%d\n",S[top]);

  return 0;
}
	

 


  

  
	     

  



Measured memory_bytes: 2108