akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <math.h>
#include <string.h>

void main()
{
  char S[5];
  scanf("%s", &S);
  if(S[2]==S[3])
  {
    if(S[4]==S[5])
      printf("Yes");
    else
      printf("No");
  }
   else
      printf("No");
}


Measured memory_bytes: 128
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <chrono>
#include <random>
#include <tuple>
#include <utility>
#include <fstream>
#include <complex>
#include <cstdint>
#define _USE_CMATH_DEFINES

const long INF = (1l << 30);
const long LINF = (1l << 60); //1.15*10^18

const long MAX = 1000000000000000000;

long n;
long ans = 1;

int main(){
    scanf("%ld", &n);
    bool flag = false;
    for(int i = 0; i < n; i++){
        long a;
        scanf("%ld", &a);
        if(a != 0 && MAX / a + 1 < ans){
            flag = true;
            ans = 1;
        }else{
            ans *= a;
        }
    }
    if(ans == 0){
        printf("0\n");
    }else if(flag || ans > MAX){
        printf("-1\n");
    }else{
        printf("%ld\n", ans);
    }
}


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

int main(){
  int N,A,B,countA=0,countB=0;//Aはそこまでの予選通過人数、Bは買いが期の学生の中の順位
  string S;
  cin >> N >> A >> B >> S;
  for(int i=0;i<S.size();i++){
    if(S.at(i)=='a'){
      if(countA<A+B){
        countA++;
        cout << "Yes" << endl;
      }
      else{
        cout << "No" << endl;
      }
    }
    else if(S.at(i)=='b'){
      countB++;
      if(countA<A+B && countB<=B){
        cout << "Yes" << endl;
        countA++;
      }
      else{
        cout << "No" << endl;
      }
    }
    else{
      cout << "No" << endl;
    }
  }
}

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

int main() {
    int n,m;
    cin >> n >> m;
    vector<ll> pref (m);
    vector<ll> order (m);
    vector<tuple<ll,ll,ll>> py (m);
    for(int i=0; i<m; i++){
        ll p,y;
        cin >> p >> y;
        py.at(i) = make_tuple(p,y,i);
        pref.at(i) = p;
    }
    sort(py.begin(),py.end());
    ll count = 1;
    for(int i=0; i<m-1; i++){
        if(get<0>(py.at(i)) == get<0>(py.at(i+1))){
            order.at(get<2>(py.at(i))) = count;
            count++;
        }
        else{
            order.at(get<2>(py.at(i))) = count;
            count = 1;
        }
    }
    order.at(get<2>(py.at(m-1))) = count;
    for(int i=0; i<m; i++){
        string ans = "";
        for(int j=0; j<6 - to_string(pref.at(i)).size(); j++){
            ans += '0';
        }
        ans += to_string(pref.at(i));
        for(int j=0; j<6 - to_string(order.at(i)).size(); j++){
            ans += '0';
        }
        ans += to_string(order.at(i));
        cout << ans << endl;
    }
}

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

#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 ALL(v) v.begin(), v.end()


string S;

int main() {
  std::cout << std::fixed << std::setprecision(20);
  
  cin >> S;

  char a = S.at(0);
  char b = S.at(1);
  char c = S.at(2);


  if(a == 'R' && b == 'R'  && c == 'R'){
    cout << "3" << endl;
    return 0;
  }
  if(a == 'R' && b == 'R'){
    cout << "2" << endl;
    return 0;
  }
  if(b == 'R' && c == 'R'){
    cout << "2" << endl;
    return 0;
  }
  if(a == 'R' || b == 'R' || c == 'R'){
     cout << "1" << endl;
    return 0;
  }
   cout << "0" << endl;
  return 0;
}

Measured memory_bytes: 3608
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define veci vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define vec2(a,b) vector<vec>(a,vec(b))
#define vec2ll(a,b) vector<vec>(a,vecll(b))
#define vec3(a,b,c) vector<vector<vec>>(a,vec2(b,c))
#define vec3ll(a,b,c) vector<vector<vecll>>(a,vec2ll(b,c))
#define fi first
#define se second
#define all(c) begin(c),end(c)
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))


using namespace std;
int in() {int x;cin>>x;return x;}
ll lin() {ll x;cin>>x;return x;}
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T> inline void print(pair<T,T> p){cout<<"("<<p.first<<","<<p.second<<") ";}
//template<class T> inline void print(vector<pair<T,T>> v){for(auto e:v)print(e); cout<<endl;}
//template<class T> inline void print(T v){for(auto e:v)cout<<e<<" ";cout<<endl;}
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
    for(T& x:vec) is >> x;
    return is;
}
const ll INF=1e9+7;

int main()
{
    ll a,b,c;
    cin >> a >> b >> c;
    if(c-a-b<=0){
        cout << "No" << endl;
    }
    else{
        ll d=c-a-b;
        if(4*a*b<d*d){
            cout << "Yes" << endl;
        }
        else{
            cout << "No" << endl;
        }
    }
    return 0;
} 

Measured memory_bytes: 256
n = int(input())
s = sorted([int(input()) for _ in range(n)])
if sum(s) % 10 != 0:
    print(sum(s))
    quit()
else:
    for i in s:
        if i % 10 != 0:
            s.remove(i)
            print(sum(s))
            quit()
print('0')

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

int main(){
   vector<int> d(3);
   for(int i=0;i<3;i++) cin>>d[i];
   int a,b,c;
   sort(d.begin(),d.end());
   a=d[0],b=d[1],c=d[2];
   //printf("%d %d %d\n",a,b,c);
   int cnt=0;
   while(c-b>1) {
       b+=2;cnt++;
   }
   while(c-a>1) {
       a+=2;cnt++;
   }
    //printf("%d %d %d\n",a,b,c);
   if(c-b==1){
       if(a==b) {
           a++;b++;cnt++;
       }
       else if(a==c) {
           a++;c++;b+=2;cnt+=2;
       }
   }
   else if(c-a==1){
       if(a==b) {a++;b++;cnt++;}
       else if(b==c) {a+=2;b++;c++;cnt+=2;}
   }
   if(a==b && b==c) cout<<cnt<<endl;
}


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

template<typename T> 
struct BIT{
  Int n;
  map<Int, T> bit;
  //1-indexed
  BIT():n(-1){}
  BIT(Int n_):n(n_){}
  
  T sum(Int i){
    T s=0;
    for(Int x=i;x>0;x-=(x&-x))
      s+=bit[x];
    return s;
  }
  void add(Int i,T a){
    if(i==0) return;
    for(Int x=i;x<=n;x+=(x&-x))
      bit[x]+=a;
  }
  
  Int lower_bound(Int w){
    if(w<=0) return 0;
    Int x=0,r=1;
    while(r<n) r<<=1;
    for(Int k=r;k>0;k>>=1){
      if(x+k<=n&&bit[x+k]<w){
	w-=bit[x+k];
	x+=k;
      }
    }
    return x+1;
  }
  
  T sum0(Int i){
    return sum(i+1);
  }
  void add0(Int i,T a){
    add(i+1,a);
  }
};

signed main(){
  Int n,c;
  cin>>n>>c;
  BIT<Int> bit((Int)1e17);
  vector<Int> s(n,1);
  for(Int i=0;i<n;i++) bit.add(s[i]*n+(n-(i+1)),1);
  for(Int i=0;i<c;i++){
    Int x;
    cin>>x;
    if(x){
      Int m;
      cin>>m;
      Int k=bit.lower_bound(n-m+1);
      cout<<n-(k%n)<<" "<<s[n-(k%n)-1]-1<<endl;
    }else{
      Int t,p;
      cin>>t>>p;
      t--;
      bit.add(s[t]*n+(n-(t+1)),-1);
      s[t]+=p;
      bit.add(s[t]*n+(n-(t+1)),1);
    }
  }
  return 0;
}

Measured memory_bytes: 69572
N = int(input())
BA = []
for _ in range(N):
    a, b = map(int, input().split())
    BA.append((b, a))

t = 0
clear = True
for b, a in sorted(BA):
    t += a
    if t > b:
        clear = False
        break

print("Yes" if clear else "No")


Measured memory_bytes: 31936
#include <bits/stdc++.h>
#include <set>
# define ll long long 
# define str string 
# define speed ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
# define time cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n"
using namespace std;
vector < pair < string , int > > A,B;
set<int> st,st1;
ll a,b,c,d,e,f,g,h,cnt,bnt,l;
str s,lk;
int main(){
	speed;
	cin>>a;
	for (int i = 0; i < a; ++i){
		cin>>s>>b;
		A.push_back({s,b});
	}
	cin>>lk;
	for (int i = 0; i < a; ++i){
			if(A[i].first==lk){
				cnt++;
			}		
			else if(cnt>0) bnt+=A[i].second;	
	}
	cout<<bnt<<"\n";

	time;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define REP(i,j,n) for(int i = j;i < (n);i++)
#define intput(i) cout << i << endl
#define ll long long
#define stringput(s) cout << (string)(s) << endl

int main(){
  ll N, K;
  cin >> N >> K;
  ll ans = K;
  rep(i, N-1){
    ans *= (K-1);
  }
  cout << ans << endl;
}


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

int main() {
  string TKSS;
  cin >> TKSS;
  
  if(TKSS == "a" || TKSS == "e" || TKSS == "i" || TKSS == "o" || TKSS == "u"){
    cout << "vowel" << endl;
  }
  else{
    cout << "consonant" << endl;
  }
}


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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int i = 0;i < (n);i++)
#define FOR(i, a, b) for(int i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

int32 N, K, Q;
vector<int64> A;

int main(void){
	cin >> N >> K >> Q;
	A.resize(N);
	REP(i, N) cin >> A[i];
	int64 res = INF_LL;
	REP(i, N){
		int64 tmp = A[i];
		A[i] = -1;

		int32 cnt = 0, cQ = 0, r = 0;
		int64 maxi = 0;
		vector<int64> v;
		v.push_back(tmp);
		REP(l, N){
			priority_queue<int64, vector<int64>, greater<int64>> pq;
			while(l<N){
				if(A[l] != -1 && A[l] < tmp) break;
				if(A[l] != -1) pq.push(A[l]);
				l++;
			}
			while(pq.size() >= K){
				v.push_back(pq.top()); pq.pop();
			}
		}
		sort(all(v));
		if(v.size() >= Q){
			res = min(res, v[Q-1]-tmp);
		}

		A[i] = tmp;
	}
	cout << res << endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <iostream>
#include <cmath>
#include <map>
#include <set>
using namespace std;

const int loop = 7 * 24 * 60;

int s, n, t, w, d, p, m;
string week, zone;

bool match(int time) {
	int weekday = time / 24 / 60;
	int day = time % (24 * 60) / 60;
	if( day < 6 || 18 <= day ){
		day = 1;
	}else{
		day = 0;
	}
	return ((w >> weekday) & 1) && ((d >> day) & 1);
}
int main() {
	while( cin >> s >> n >> t >> week >> zone >> p >> m, s ){
		if( week == "All" ){
			w = (1 << 7) - 1;
		}else{
			w = 1 << 1;
		}
		if( zone == "All" ){
			d = 3;
		}else if( zone == "Day" ){
			d = 1;
		}else if( zone == "Night" ){
			d = 2;
		}
		
		double q = pow((p - 1.0) / p, n);
		double ans = -1e+100;
		for(int start = 24 * 60 - s ; start <= 24 * 60 * 2 ; start++ ){
			double sump = 1.0;
			int time = start;
			for(int i = 0 ; i < m ; i++ ){
				if( match(time) && match((time + s) % loop) ){
					sump *= q;
				}
				time = (time + t) % loop;
			}
			ans = max(ans, 1.0 - sump);
		}
		printf("%.10f\n", ans);
	}
}

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

int main() {
    int N, AC=0, WA=0, TLE=0, RE=0;
    string s;

    cin >> N;

    for (int i = 0; i < N; ++i) {
        cin >> s;

        if (s=="AC"){
            AC+=1;
        }

        else if (s=="WA"){
            WA+=1;
        }

        else if (s=="TLE"){
            TLE+=1;
        }

        else if (s=="RE"){
            RE+=1;
        }

    }

    cout << "AC x " << AC << endl;
    cout << "WA x " << WA << endl;
    cout << "TLE x " << TLE << endl;
    cout << "RE x " << RE << endl;
}


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

using namespace std;

#define ll long long
constexpr ll inf = 1e9+7;

ll cs[9] = {0};

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

    ll N;
    cin>>N;
    for (ll n = 0; n < N; n++) {
        ll a;
        cin>>a;
        if (a < 3200) cs[a / 400]++;
        else cs[8]++;
    }
    ll cnt = 0;
    for (ll i = 0; i < 8; i++) if (cs[i] > 0) cnt++;

    ll mn;
    if (cnt == 0) mn = 1;
    else mn = cnt;

    ll mx = cnt + cs[8];

    cout<<mn<<" "<<mx<<endl;

    return 0;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
nums = [list(map(int, input().split())) for _ in range(m)]

for i in range(1000):
  is_ok = True
  num_str = str(i)
  if len(num_str) != n:
    continue
  for s, c in nums:
    if num_str[s-1] != str(c):
      is_ok = False
      break
  if is_ok:
    print(num_str)
    exit(0)
print(-1)

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

	
int main(){
	int N;
	cin >> N;
	vector<int> canA(N);
	vector<int> canB(N);
	for(int i = 0; i < N; i++) cin >> canA.at(i);
	for(int i = 0; i < N; i++) cin >> canB.at(i);
	
  	vector<int> sum(N);
	for(int i = 0; i < N; i++){
		int sumAB = 0;
		for(int j = 0; j <= i; j++){
			sumAB += canA.at(j);
		}
		for(int k = i; k < N; k++){
			sumAB += canB.at(k);
		}
		sum.at(i) = sumAB;
	}
	sort(sum.begin(), sum.end());
	reverse(sum.begin(), sum.end());
	cout << sum.at(0) << endl;
}

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

#define rep(i,n) for(ll i=0;i<(n);++i)
using ll = long long;
using pll = pair<ll,ll>;
constexpr ll INF = (1LL<<60);
constexpr ll MOD = (1e9+7);
//constexpr ll MOD = (998244353);
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(a>b){a=b;return 1;}return 0;}
void dump(){cerr<<endl;}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){cerr<<h<<", ";dump(forward<Ts>(t)...);}
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T>vector<T> vec(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto vec(size_t a, Ts... ts){return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...));}
template<class T>vector<T> _vec(size_t a,T v){return vector<T>(a,v);}
template<class T, class... Ts>auto _vec(size_t a, Ts... ts){return vector<decltype(_vec<T>(ts...))>(a, _vec<T>(ts...));}

int main(){

  int n;
  string s,t,a;
  cin>>n>>s>>t;

  rep(i,n){
    a += s[i];
    a += t[i];
  }
  cout<<(a)<<endl;

}

Measured memory_bytes: 256
K = gets.to_i

gcd = ->(a,b){
    return gcd.call(b,a) if b>a
    until((r=a%b) == 0)
        a,b = b,r
    end
    b
}

triple = K*(K+1)/2
double = 0
single = 0
(1..(K-1)).each do |a|
    ((a+1)..K).each do |b|
        double += gcd.call(b,a)
    end
end

single = 0
(1..(K-2)).each do |a|
    ((a+1)..(K-1)).each do |b|
        d = gcd.call(b,a)
        ((b+1)..K).each do |c|
            single += gcd.call(c,d)
        end
    end
end
p triple + (6*double) + (6*single)

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

int f(int n, vector<int> a)
{
    int i, j = 0;
    for (i = 0; i < n; i++)
    {
        j = a[j] - 1;
        if (j == 1)
        {
            return i + 1;
        }
    }
    return -1;
}

int main()
{
    int n, i;
    cin >> n;
    vector<int> a(n);
    for (i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    cout << f(n, a) << "\n";
    return 0;
}

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

int main() {
  int N = 0;
  string S;
  cin >> N >> S;
  
  int ans = 1;
  for (int i = 0; i < N; i++) {
    if (i != 0 && S.at(i) != S.at(i - 1))
      ans++;
  }
  cout << ans << endl;
}

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

#define MOD 1000000007LL

long long dp[110][101010];

int main(){
	int N,K;
	cin >> N >> K;
	vector<int> a(N);
	for(auto &i:a)cin >> i;
	
	dp[0][0]=1;
	
	for(int i=0;i<N;i++){
		for(int j=0;j<=K;j++){
			dp[i+1][j]+=dp[i][j];
			dp[i+1][j]%=MOD;
			dp[i+1][min(j+a[i],K)+1]+=MOD-dp[i][j];
			dp[i+1][min(j+a[i],K)+1]%=MOD;
		}
		for(int j=0;j<K;j++){
			dp[i+1][j+1]+=dp[i+1][j];
			dp[i+1][j+1]%=MOD;
		}
	}
	cout << dp[N][K] << endl;
	return 0;
}

Measured memory_bytes: 79360
#include <iostream>
using namespace std;
#define MAX 100000

int n, k;
long long T[MAX];

int check(long long P) {
    int i = 0;
    for (int j = 0; j < k; ++j) {
        long long s = 0;
        while (s + T[i] <= P) {
            s += T[i];
            i++;
            if (i == n) {
                return n;
            }
        }
    }

    return i;
}

int solve() {
    long long left = 0;
    long long right = 100000 * 10000;
    while (right - left > 1) {
        long long mid = (left + right) / 2;
        int v = check(mid);
        if (v >= n) {
            right = mid;
        } else {
            left = mid;
        }
    }

    return right;
}

int main() {
    cin >> n >> k;
    for (int i = 0; i < n; ++i) {
        cin >> T[i];
    }
    cout << solve() << endl;
    return 0;
}



Measured memory_bytes: 3872
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b =sc.nextInt();
        if(a<b) {
            System.out.println("a < b");
        }else if(a>b) {
            System.out.println("a > b");
        }else {
            System.out.println("a == b");
        }
    }
}


Measured memory_bytes: 26264
from itertools import *
def f(s):
 if sum(s)==10:return"((({} + {}) + {}) + {})".format(*s)
 for a,b,c,d in permutations(s):
  for x,y,z in permutations('+-*+-*',3):
   for t in[f"({a} {x} {b}) {y} ({c} {z} {d})",f"(({a} {x} {b}) {y} {c}) {z} {d}",f"({a} {x} ({b} {y} {c})) {z} {d}"]:
    if eval(t)==10:return'('+t+')'
 else:return 0
for e in iter(input,'0 0 0 0'):print(f(list(map(int,e.split()))))


Measured memory_bytes: 5660
N, K = list(map(int, input().split()))
h = [int(input()) for i in range(N)]

h.sort()

left = h[0]
right = h[K - 1]
min_diff = right - left
for i in range(len(h)):
    if i <= K - 1: continue

    left = h[i - K + 1]
    right = h[i]
    diff = h[i] - left

    if diff < min_diff:
        min_diff = diff

print(min_diff)


Measured memory_bytes: 7384
N = int(input())
src = list(map(int,input().split()))

r = 0
tmp = 0
ans = 0
for l in range(N):
    while r < N and (tmp & src[r]) == 0:
        tmp += src[r]
        r += 1
    ans += r-l
    tmp -= src[l]
print(ans)

Measured memory_bytes: 24712
#include <iostream>
#include <algorithm>
#include <queue>
using namespace std;
#define N 200200
pair <long long, long long> v[N];
queue <pair<long long, long long> > q;
long long damage, D, A, curr, ans;
int i, n;
int main()
{
    cin >> n >> D >> A;
    for (i = 0; i < n; ++i)
        cin >> v[i].first >> v[i].second;
    sort (v, v + n);
    for (i = 0; i < n; ++i){
        while (!q.empty() && v[i].first > q.front().first){
            damage -= q.front().second;
            q.pop();
        }
        if (v[i].second - damage > 0){
            curr = (v[i].second - damage) / A;
            if (curr * A < v[i].second - damage)
                ++curr;
            damage += curr * A;
            ans += curr;
            q.push(make_pair(2 * D + v[i].first, curr * A));
        }
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 4992
#include <iostream>
#include <stdio.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)

int main(){
  int n,a,b;
  cin>>n>>a>>b;
  int sumd=0;
  for(int i=1;i<=n;i++){
    int num=i,sum=0,dig;
    while(num){
      dig = num % 10;
      sum += dig;
      num /= 10;
    }
    if(a<=sum&&sum<=b)sumd+=i;
  }
  cout<<sumd<<endl;
  return 0;
}


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

typedef long long ll;

int main(){
    int c[3][3];
    for(int i=0; i<3; i++){
        for(int j=0; j<3; j++){
            cin >> c[i][j];
        }
    }
    
    int a[3], b[3];
    
    a[0] = 0;
    for(int i=0; i<3; i++){
        b[i] = c[0][i] - a[0];
    }
    
    for(int i=0; i<3; i++){
        a[i] = c[i][0] - b[0];
    }
    
    bool flag=true;
    for(int i=0; i<3; i++){
        for(int j=0; j<3; j++){
            if(a[i]+b[j] != c[i][j]){
                flag = false;
            }
        }
    }
    
    cout << (flag?"Yes":"No") << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
template <class T> void chmin(T &a, const T &b) noexcept { if (b < a) a = b; }
template <class T> void chmax(T &a, const T &b) noexcept { if (a < b) a = b; }
void debug_out() { cout << "\n"; }
template <class T, class... Args>
void debug_out(const T &x, const Args &... args) { cout << x << " "; debug_out(args...);}
#ifdef _DEBUG
  #define debug(...) debug_out(__VA_ARGS__)
#else
  #define debug(...) 
#endif

const int mod = 1000000007;
// const int mod = 998244353;
struct mint {
  ll x;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
  bool operator==(const mint rhs) const { return x == rhs.x; }
  bool operator!=(const mint rhs) const { return x != rhs.x; }
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}


int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  string s;
  cin >> s;
  int n = s.length();
  vector<vector<mint> > dp(n+5, vector<mint>(15,0));
  dp[0][0] = 1; 
  rep(i,n) {
    if (s[i] == '?') {
      rep(j,13) { //余り
        rep(k,10) { //くっつける数
          int r = (10*j + k) % 13;
          dp[i+1][r] += dp[i][j];
        }
      }
    }
    else {
      int x = s[i] - '0';
      rep(j,13) { //余り
        int r = (10*j + x) % 13;
        dp[i+1][r] += dp[i][j];
      }
    }
  }
  cout << dp[n][5] << endl;
  return 0;
}

Measured memory_bytes: 15184
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair <int, int> ii;
typedef vector <int> vi;
typedef double ld;
#define X first
#define Y second
#define mk make_pair
#define pb push_back
#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(x) (x).begin(), (x).end()
const int MOD = (int) 1e9 + 7;
const ll base =  31;
void MAIN();
int main(){
    //freopen("input.txt", "r", stdin);
    ios:: sync_with_stdio(false); cin.tie(0);
    MAIN();
    return 0;
}
////////////////////////////////////////////////////////////////////////

const int N = 300032;

//a1 + a2 <= b*2

int n;
ii a[N];

void MAIN(){
    cin >> n;
    Rep(i, n) cin >> a[i].Y >> a[i].X;
    sort(a, a + n);
    int l = 0, r = n;
    while(l < r){
        int mid = l + r + 1 >> 1;
        ll sum = 0;
        multiset <int> s;
        bool ok = false;
        for(int i = n-1; i >= 0; i --){
            if(s.size() == mid - 1){
                if(sum + a[i].Y <= 1LL*a[i].X*mid) ok = true;
            }
            s.insert(a[i].Y);
            sum += a[i].Y;
            if(s.size() >= mid){
                set <int>:: iterator it = s.end(); it --;
                sum -= *it;
                s.erase(it);
            }
        }
        if(ok) l = mid;
        else r = mid - 1;
    }
    cout << l << endl;
}

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

using namespace std;

#define x first
#define y second
#define mp make_pair
#define pb push_back
#define sqr(a) ((a) * (a))
#define sz(a) int(a.size())
#define all(a) a.begin(), a.end()
#define forn(i, n) for(int i = 0; i < int(n); i++) 
#define fore(i, l, r) for(int i = int(l); i < int(r); i++)

typedef long long li;
typedef long double ld;
typedef pair<int, int> pt;

template <class A, class B> ostream& operator << (ostream& out, const pair<A, B> &a) {
	return out << "(" << a.x << ", " << a.y << ")";
}

template <class A> ostream& operator << (ostream& out, const vector<A> &v) {
	out << "[";
	forn(i, sz(v)) {
		if(i) out << ", ";
		out << v[i];
	}
	return out << "]";
}

mt19937 rnd(time(NULL));

const int INF = int(1e9);
const li INF64 = li(1e18);
const int MOD = int(1e9) + 7;
const ld EPS = 1e-9;
const ld PI = acos(-1.0);

int n, m;
int w;

bool read () {
	if (scanf("%d%d%d", &n, &m, &w) != 3)
		return false;
	return true;
}

void solve() {
	printf("%d\n", min((w + m - 1) / m, (w + n - 1) / n));
}

int main() {
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
	
	int tt = clock();
#endif
	
	cerr.precision(15);
	cout.precision(15);
	cerr << fixed;
	cout << fixed;

#ifdef _DEBUG
	while(read()) {	
#else
	if(read()) {
#endif
		solve();
		
#ifdef _DEBUG
	cerr << "TIME = " << clock() - tt << endl;
	tt = clock();
#endif

	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int X;
  int Y;
  int Z;
  
  cin >> X;
  cin >> Y;
  cin >> Z;
  
  cout << Z;
  cout << " ";
  cout << X;
  cout << " ";
  cout << Y;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<algorithm>
#include<queue>
#include<vector>
#include<set>
#include<map>
#include<ctime>
#include<iostream>
typedef long long LL;
using namespace std;
const int Maxn = 1e4 + 5;
LL A[Maxn],vis[Maxn];
int main()
{
	LL N;
	while( cin >> N ){
		int m = 0 , d = 0;
		for( int i = 1 ; i <= N ; i++ ){
			scanf(" %lld",&A[i]);
			if( A[i] & 1 )	m++;
			else	vis[++d] = i;
		}
		LL ans = 0;
		if( m == N )	cout << "0" << endl;
		else{
			for( int i = 1 ; i <= d ; i++ ){
				while( A[vis[i]] % 2 == 0 ){
					ans++;
					A[vis[i]] /= 2;
				}
			}
			cout << ans << endl;
		}
		memset( A , 0 , sizeof(A) );
		memset( vis , 0 , sizeof(vis) );
	}
}

Measured memory_bytes: 384
// https://atcoder.jp/contests/abcXXX/tasks/abcXXX_x

#include <iostream>
#include <vector>
#include <tuple>
#include <algorithm>
#include <string>
#include <cmath>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

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

static const ll INF = 1001001001;
static const ll LLINF = 1001001001001001001;

#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define RANGE(i, m, n) for(ll i = (m); i <= (n); ++i)

void debug_out() {}
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 1
#endif

int run(istream& in, ostream& out) {
    string S;
    in >> S;
    vector<string> v{"SUN","MON","TUE","WED","THU","FRI","SAT"};
    ll ans = 0;
    REP(i, v.size()) {
        if (v[i] == S) {
            cout << 7-i << endl;
        }
    }
    return 0;
}
int main() {
    return run(cin, cout);
}


Measured memory_bytes: 256
def gcd(a,b): 
    if a == 0: 
        return b 
    return gcd(b % a, a) 

def lcm(a,b): 
    return (a*b) / gcd(a,b) 

arr = list(map(int, input().split()))
print(int(lcm(arr[0],arr[1])))

Measured memory_bytes: 3060
data = [
    [[0 for r in range(10)] for f in range(3)] for b in range(4)
]
    
count = int(input())
for c in range(count):
    b,f,r,v = [int(i) for i in input().split()]
    data[b-1] [f-1] [r-1] += v
    
for bi, b in enumerate(data):
    for f in b:
        for r in f:
            print(' {0}'.format(r), end='')
        print()
    if bi < 3:
        print('#' * 20)

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

int main() {
  long long X, sum=100, count=0;
  cin >> X;
  
  while(X>sum) {
  long long intr = sum * 1 / 100;
  sum += intr;
  count++;
  }
  cout << count << endl;
}

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

#define MOD (1000000000+7)
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define nl '\n'
#define all(x) x.begin(), x.end()
#define print(vec,l,r) for(int i = l; i <= r; i++) cout << vec[i] <<" "; cout << endl;
#define forf(i,a,b) for(int i = (a); i < (b); i++)
#define forr(i,a,b) for(int i = (a); i > (b); i--)
#define input(vec,N) for(int i = 0; i < (N); i++) cin >> vec[i];
#define debug(x) cerr << #x << " = " << (x) << endl;

// template starts
typedef long long int ll;

// template ends here
ll power(ll x, ll n, ll p){
	ll res = 1;
	if(n == 0) return 1;
	if(n == 1) return x%p;
	if(n%2 == 1) res = x%p;

	ll temp = power(x,n/2,p);
	
	return res*((temp*temp)%p)%p;
}
void solve(){
	// code starts from here
	int N;
	cin >> N;
	
	ll ans = power(10,N,MOD) - 2*power(9,N,MOD) + power(8,N,MOD);
	cout << (ans%MOD + MOD)%MOD << endl;
	
}

clock_t startTime;
double getCurrentTime() {
	return (double)(clock() - startTime) / CLOCKS_PER_SEC;
}

int main(){
 	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	//startTime = clock();
	
	int T;
	//cin >> T;
	T = 1;
	while(T--){
		solve();
	}
	
	//cout << getCurrentTime() << endl;
	return 0;
}


Measured memory_bytes: 3656
n = int(input())
A = [int(i) for i in input().split()]
check = [i for i in A if i == 0]
if 0 in check:
    print(0)
else:   
    A.sort(reverse=True)
    work = 1
    for a in A:
        work *= a
        if work > 10**18:
            print('-1')
            break
    else:
        print(work)

Measured memory_bytes: 21604
#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define irep(i,a,b) for(ll i=ll(a);i>=ll(b);i--)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define pb push_back
#define mp make_pair
#define F .first
#define S .second 
using ll=long long;
using ld=long double;
const ll INF = 1LL<<60;
const ll mod=1e9+7;
using namespace std;
ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }


vector<vector<ll>> x(30);
ll y[30],z[30],z2[30];
int main(){
    string s,t;
    bool f=true,q=true;
    cin>>s>>t;
    ll sl=s.length(),tl=t.length();
    rep(i,0,sl){
        ll zz=s[i]-'a';
        x[zz].pb(i);
        z[zz]++;
    }
    rep(i,0,tl)z2[t[i]-'a']++;
    rep(i,0,30)if(z[i]==0&&z2[i]>0)q=false;
    ll pos=0,num,roop=-1,last;
    while(q&&pos<tl&&roop<1e6){
        f=true;
        num=-1;
        roop++;
        rep(i,0,30)y[i]=0;
        while(f&&pos<tl){
            ll zzz=(ll)(t[pos]-'a');
            while(x[zzz][y[zzz]]<num&&z[zzz]>y[zzz])y[zzz]++;
            if(z[zzz]>y[zzz]&&x[zzz][y[zzz]]>=num){
                num=x[zzz][y[zzz]];
                y[zzz]++;
                pos++;
                if(pos==tl)last=num;
            }
            else f=false;
        }
    }
    if(!q||roop==1e6)cout<<-1<<endl;    
    else cout<<roop*sl+last+1<<endl;

}


Measured memory_bytes: 1724
//#include <bits/stdc++.h>
//using namespace std;
#include<cstdio>
#include<cstring>
#include<algorithm>
typedef long long LL;
//#pragma comment(linker, "/STACK:102400000,102400000")

const int N=1e5+10;
int a[N];
int main()
{
    int n,ans;
    scanf("%d",&n);
    for(int i=1;i<=n;i++) scanf("%d",&a[i]);
    ans = 1;
    int flag = 0;
    int temp = a[1];
    for(int i=2;i<=n;i++)
    {
        if(!flag){
            if(temp > a[i]) flag = 1;
            else if(temp < a[i]) flag = 2;
        }
        else if(flag == 1){
            if(temp < a[i])
            {
                flag = 0;
                ans++;
            }
        }
        else if(flag == 2){
            if(temp > a[i])
            {
                flag = 0;
                ans++;
            }
        }
        temp = a[i];
    }
    printf("%d\n",ans);
    return 0;
}






Measured memory_bytes: 512
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;
map<int, int> m = {{1, 5}, {2, 6}, {3, 6}, {4, 6}, {5, 6}, {6, 5}};

int main() {
  ll x;
  cin >> x;
  ll res = x % 11;
  if (res == 0) {
    cout << (x / 11) * 2 << endl;
  } else if (res <= 6) {
    cout << (x / 11) * 2 + 1 << endl;
  } else {
    cout << (x / 11) * 2 + 2 << endl;
  }
  return 0;
}

Measured memory_bytes: 3608
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<stdio.h>
#include<deque>
#include<map>
#include<queue>
#include<cmath>

typedef long long ll;

#define debug(x) cout << #x << "=" << x << endl;
#define debug_arr(a, n) for(ll i = 0; i < n; i++)cout << a[i] << " "
#define inf 100000000000
#define loop(i,n) for(ll i = 0; i < n; i++)
#define graph vector<vector<ll>>
#define P pair<ll,ll>

using namespace std;

int main(){
    double a,b,x;
    cin >>a >>b >>x;

    double d = double(x) / a, result;

    if(d * 2 < a * b){
        double c = d * 2.0 / b;
        result = atan2(b , c);
    }else{
        d = (a * b) - d;
        double c = d * 2.0 / a;
        result = atan2(c , a);
    }

    double pi = acos(-1);
    result = result / (2.0 * pi) * 360;

    printf("%.10f",result);

    return 0;
}

Measured memory_bytes: 384
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.0000001
using namespace std;

int main(){

	int N;
	scanf("%d",&N);
	int* table = new int[N];
	int* reverse_table = new int[N];

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

	for(int i = 0; i < N; i++)reverse_table[i] = table[N-1-i];

	int maximum = table[0];
	int index = 0,pre_index;

	while(true){

		pre_index = index;
		index = maximum/10;

		if(pre_index == index)break;

		for(int i = pre_index+1; i <= index; i++){
			maximum = max(maximum,10*i+table[i]);
		}

		if(maximum >= 10*(N-1))break;
	}

	if(maximum < 10*(N-1)){
		printf("no\n");
		return 0;
	}

	maximum = reverse_table[0];
	index = 0;

	while(true){

		pre_index = index;
		index = maximum/10;

		if(pre_index == index)break;

		for(int i = pre_index+1; i <= index; i++){
			maximum = max(maximum,10*i+reverse_table[i]);
		}

		if(maximum >= 10*(N-1))break;
	}

	if(maximum < 10*(N-1)){
		printf("no\n");
		return 0;
	}else{
		printf("yes\n");
	}

	return 0;
}

Measured memory_bytes: 5492
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;

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

    string s;
    cin >> s;

    if(n%2 == 0) {
        string t = s.substr(0, n/2);
        if(s == t + t) {
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
using std::min;

const int kN = 2e3 + 5;
int n, x, y;
int cnt[kN];

int get_dis(int a, int b) {
    return min(b - a, abs(x - a) + abs(y - b) + 1);
}

int main() {
    scanf("%d%d%d", &n, &x, &y);
    for (int i = 1; i <= n; i++) {
        for (int j = i + 1; j <= n; j++) {
            cnt[get_dis(i, j)]++;
        }
    }
    for (int i = 1; i < n; i++) {
        printf("%d\n", cnt[i]);
    }
}

Measured memory_bytes: 128
#include <iostream> 
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<iomanip>
#include<sstream>
#include<cmath>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define req(i,n) for(int i = 1;i <=  n; i++)
#define rrep(i,n) for(int i = n -1;i >= 0;i--)
typedef long long int ll;
typedef long double ld;
const ll INF = 1LL << 60;
const int inf = (1 << 30);
const int MOD = 1000000007;
ll n,ans = 0, sum = 0, p;
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T & val) {
    std::fill((T*)array, (T*)(array + N), val);
}
struct Corr {
    int x;
    int y;
    int depth;
};
queue<Corr> q;
ll bfs(vector<vector<char>> grid,int i,int j) {
    Corr sta = { j,i,0 };
    vector<vector<int>> ispassed(grid.size(), vector<int>(grid[0].size(), false));
    int dx[8] = { 1, 0, -1, 0 };
    int dy[8] = { 0, 1, 0, -1 };
    int sd = 0; q.push(sta);
    while (!q.empty()) {
        Corr now = q.front(); q.pop();
        sd = max(sd, now.depth);
        for (int k = 0; k < 4; k++) {
            int nextx = now.x + dx[k],nexty = now.y + dy[k];
            if (nextx >= grid[0].size() || nextx < 0) continue;
            if (nexty >= grid.size() || nexty < 0) continue;
            if (ispassed[nexty][nextx]) continue;
            if (grid[nexty][nextx] == '#') continue;
            ispassed[nexty][nextx] = true;
            Corr next = { nextx, nexty, now.depth + 1 };
            q.push(next);
        }
    }return sd;
}
int main() {
    int h, w; cin >> h >> w;
    vector<vector<char>> s(h, vector<char>(w));
    rep(i, h) {
        rep(j, w) {
            cin >> s[i][j];
        }
    }
    if (h == 2 && w == 1) {
        cout << 1 << endl;
        return 0;
    }
    else if (w == 2 && h == 1) {
        cout << 1 << endl;
        return 0;
    }
    rep(i, h) {
        rep(j, w) {
            if (s[i][j] == '.') {
                ans = max(bfs(s, i, j), ans);
            }
        }
    }cout << ans << endl;
}

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

#include <iostream>
//#include <algorithm>
// #include <iomanip>
#define ll long long
#define map unordered_map
#define set unordered_set
#define pll pair<ll, ll>
#define vll vector<ll>

using namespace std;

const ll MOD = 1000000007;
const ll INF = (1LL << 62);

//-------------------------
// ダイクストラ
//-------------------------
struct edge {
  ll to;
  ll cost;
};

const ll MAX_N = 100005;
ll N, M;
vector<edge> edges[MAX_N];
ll d[MAX_N];   // startからの最短距離
ll pv[MAX_N];  // 経路復元用

void dijkstra(ll start) {
  // 距離が最小のものから処理するためのキュー
  priority_queue<pll, vector<pll>, greater<pll>> que;

  fill(d, d + MAX_N, INF);
  fill(pv, pv + MAX_N, -1);  // 経路復元用

  d[start] = 0;
  que.push(pll(0, start));

  while (!que.empty()) {
    pll p = que.top();
    que.pop();

    ll from = p.second;  // 頂点番号

    ll p_cost = p.first;
    if (d[from] < p_cost) {
      // 試す価値なし
      continue;
    }

    for (ll i = 0; i < edges[from].size(); i++) {
      edge e = edges[from][i];

      ll next_cost = d[from] + e.cost;
      if (d[e.to] > next_cost) {
        d[e.to] = next_cost;
        que.push(pll(d[e.to], e.to));

        pv[e.to] = from;  // 経路復元用
      }
    }
  }
}

ll ans[100005];

void calc() {
  scanf("%lld %lld", &N, &M);

  for (ll i = 0; i < M; i++) {
    ll from, to;
    scanf("%lld %lld", &from, &to);

    ll cost = 1;

    edges[from].emplace_back(edge{to, cost});
    edges[to].emplace_back(edge{from, cost});
  }

  dijkstra(1);

  // for (ll i = 1; i <= N; i++) {
  //   cout << i << ":" << d[i] << endl;
  // }
  // cout << d[N] << endl;

  // 経路復元
  // for (ll goal = 2; goal <= N; goal++) {
  // ll start = 1;
  // ll current = goal;
  // vll path;
  // for (;;) {
  //   path.emplace_back(current);
  //   if (current == start) {
  //     break;
  //   }
  //   current = pv[current];
  //   if (current == -1) {
  //     break;
  //   }
  //   cout << "current:" << current << endl;
  // }
}

int main() {
  calc();

  for (ll i = 2; i <= N; i++) {
    if (pv[i] == -1) {
      cout << "No" << endl;
      return 0;
    }
  }

  cout << "Yes" << endl;
  for (ll i = 2; i <= N; i++) {
    cout << pv[i] << endl;
  }
}


Measured memory_bytes: 19616
#include<iostream>

using namespace std;

class Dice{

public:
  int top,bottom,north,south,west,east;

  Dice(){}
  Dice(int t, int b, int n, int s, int w, int e)
    :top(t),bottom(b),north(n),south(s),west(w),east(e){}

  void setDice(int t, int b, int n, int s, int w, int e){
    top = t; bottom = b, north = n; south = s, west = w; east = e;
  }

  void rotateNorth(){setDice(south,north,top,bottom,west,east);}
  void rotateSouth(){setDice(north,south,bottom,top,west,east);}
  void rotateEast(){setDice(west,east,north,south,bottom,top);}
  void rotateWest(){setDice(east,west,north,south,top,bottom);}
  void rotateCW(){setDice(top,bottom,west,east,south,north);}
  void rotateCCW(){setDice(top,bottom,east,west,north,south);}
};


int main(){

  int n;
  while(cin >> n && n){
    Dice d(1,6,5,2,4,3);
    int sum = 0;
    while(n--){
      string s;
      cin >> s;
      if(s[0] == 'N') d.rotateNorth();
      if(s[0] == 'S') d.rotateSouth();
      if(s[0] == 'E') d.rotateEast();
      if(s[0] == 'W') d.rotateWest();
      if(s[0] == 'R') d.rotateCW();
      if(s[0] == 'L') d.rotateCCW();
      //cout << d.top << endl;
      sum += d.top;
    }
    cout << sum+1 << endl;
  }
  return 0;
}

Measured memory_bytes: 1204
let input = readLine()!.split(separator: " ").map { Double($0)! }

let w = input[0]
let h = input[1]
let x = input[2]
let y = input[3]

print(w * h / 2.0, 2.0 * x == w && 2.0 * y == h ? "1" : "0")

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

bool err;
int p;
string formula;
map<string, int> dic;

int parseAtom()
{
	string name;

	name += formula[p++];
	if(islower(formula[p])) name += formula[p++];

	int res = 0;
	if(!dic.count(name)) err = true;
	else res = dic[name];

	return res;
}

int parseInt()
{
	int res = 0;
	while(isdigit(formula[p])) {
		res *= 10;
		res += formula[p] - '0';
		p++;
	}

	return res;
}

int parseMolecule()
{
	int res = 0;
	while(formula[p] == '(' || isupper(formula[p])) {
		int val = 0;
		if(formula[p] == '(') {
			p++;
			val = parseMolecule();
			p++;
		}
		else 
		{
			val = parseAtom();
		}

		int mul = max(1, parseInt());
		res += val * mul;
	}

	return res;
}

int solve()
{
	p = 0;
	err = false;

	formula += '$';

	int res = 0;
	while(formula[p] != '$') {
		res += parseMolecule();
	}

	if(err) res = -1;

	return res;
}

int main()
{
	dic.clear();
	string str;
	int w;

	while(1) {
		cin >> str;
		if(str == "END_OF_FIRST_PART") break;

		cin >> w;
		dic[str] = w;
	}

	while(cin >> formula, formula != "0") {
		int res = solve();
		if(res == -1) cout << "UNKNOWN" << endl;
		else cout << res << endl;
	}
}

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

using namespace std;

int n;
vector < int > G[2020], A[2020], answer;
int a[2020], nxt[2020];
bool used[2020];

void go(int v, int p = 0)
{
  used[v] = true;
  priority_queue < int > q;
  for(int i = 0; i < G[v].size(); ++ i)
  {
    int to = G[v][i];
    if(used[to])
      continue;
    go(to, v);
    q.push(A[to][0]);
  }
  A[v].push_back(v);
  while(!q.empty())
  {
    int x = q.top();
    q.pop();
    nxt[A[v].back()] = x;
    A[v].push_back(x);
    if(nxt[x] != 0)
      q.push(nxt[x]);
  }
  nxt[A[v].back()] = 0;
}

int main()
{
  scanf("%d", &n);
  for(int i = 1; i <= n; ++ i)
    scanf("%d", &a[i]), G[0].push_back(i);
  sort(a + 1, a + n + 1);
  for(int i = 1; i <= n; ++ i)
    for(int j = 1; j <= n; ++ j)
    {
      if(j == i) continue;
      if(__gcd(a[i], a[j]) > 1)
        G[i].push_back(j);
    }
  go(0);

  for(int i = 1; i <= n; ++ i)
    printf("%d ", a[A[0][i]]);
}


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


def solve(inp):
    (N, K) = map(int, inp.readline().strip().split(' '))

    i = 0
    while True:
        if N == 0:
            break
        i += 1
        N = int(N / K)

    return str(i)


def main():
    import sys
    result = solve(sys.stdin)
    if result is not None and result != '':
        print(result)


if __name__ == '__main__':
    main()


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

using namespace std;

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

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

int sum = 0;

int func(int n) {
    if (n == 0) {
        return sum;
    } else {
        sum += n + func(n-1);
    }
}

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

    int N;
    cin >> N;

    func(N);

    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 28;
vector <pair<int, int>> p;
long long ans;
int main(){
	int n, m;
	cin >> n >> m;
	for(int i = 0; i < n; i++){
		int a, b;
		cin >> a >> b;
		p.push_back({a, b});
	}
	sort(p.begin(), p.end());
	int c = 0;
	int i = 0;
	while(c + p[i].second < m){
		c += p[i].second;
		ans += (long long)p[i].first * p[i].second;
		i ++;
	}
	ans += (long long)p[i].first * (m - c);
	cout << ans;
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define EPS (1e-7)
#define INF (1e9)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
const double PI = acos(-1);
const ll MOD = 1000000007;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
 
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

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

  vector<ll> B(60);

  rep(i,N) {
    bitset<60> s(A[i]);
    rep(j,60) {
      if (s.test(j)) B[j]++;
    } 
  }

  vector<ll> C(60);
  rep(i,60) {
    C[i] = pow(2,i);
    C[i] %= MOD;
  }
  ll ans = 0;
  rep(i,60) {
    ll k = B[i] * (N - B[i]) % MOD;
    ll l = C[i] * k % MOD;
    ans += l;
    ans %= MOD;
  }

  cout << ans << endl;

}

Measured memory_bytes: 2560
#include <algorithm>
#include <cmath>
#include <climits>
#include <functional>
#include <iostream>
#include <queue>
#include <string>
#include <numeric>
#include <vector>
#include <map>

using namespace std;
using ll = long long;
template<typename T> void print(T t) {cout << t << endl;}

vector<pair<ll, int>> prime_factorize(ll n) {
    vector < pair < ll, int >> res;
    int num = 0;
    while (n % 2 == 0) {
        num++;
        n /= 2;
    }
    if (num != 0) res.emplace_back(make_pair( 2, num ));

    for (ll p = 3; p * p <= n; p += 2) {
        num = 0;
        while (n % p == 0) {
            num++;
            n /= p;
        }
        if (num != 0) res.emplace_back(make_pair(p, num));
    }
    if (n != 1)res.emplace_back(make_pair(n, 1));
    return res;
}


struct Room {
    int id, mark, step;
    vector<int> vicinities;
};

int main() {
    int N, M, a, b;
    cin >> N >> M;
    vector<Room> rooms(N+1);
    for (int i = 1; i <= N; i++) {
        rooms[i].id = i;
        rooms[i].step = i==1 ? 0:INT_MAX;
    }
    for (int i = 0; i < M; i++) {
        cin >> a >> b;
        rooms[a].vicinities.push_back(b);
        rooms[b].vicinities.push_back(a);
    }


    queue<int> que;
    que.push(1);
    while (!que.empty()) {
        int id = que.front();
        que.pop();

        int step = rooms[id].step+1;
        for (int i : rooms[id].vicinities) {
            if (step < rooms[i].step) {
                rooms[i].step = step;
                rooms[i].mark = id;
                que.push(i);
            }
        }
    }

    print("Yes");
    for (int i = 2; i <= N; i++) {
        print(rooms[i].mark);
    }

}



Measured memory_bytes: 11292