akhauriyash/Code-Regression huggingface dataset:
N = int(input())
A = []
B = []

for _ in range(N):
    a,b = map(int, input().split())
    A.append(a)
    B.append(b)

C = list(zip(A,B))
C = sorted(C, key=lambda x:x[1])

time = 0
for a,b in C:
    time = time + a
    if time<=b:
        continue
    print("No")
    exit()
print("Yes")

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

using namespace std;

#define pb push_back

const int maxi = 1e6+10;
int a[maxi];
string s;
vector<int> v[maxi];
int m,n;

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

    cout<<(n*(n-1)/2+ m*(m-1)/2);
    return 0;
}
//volim tvoje oci tamne kao greh


Measured memory_bytes: 24832
#include<iostream>
#include<string.h>
#include<math.h>

using namespace std;

int main(){
	int tc, i, j;;
	
	long long n;
	cin>>n;
	
	long long ans = 0;
	long long awal = 100;
	while(awal < n){
		awal = awal*1.01;
		ans++;
	}
	
	cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 3652
# coding: utf-8
"""this is python work script"""

def find_score(card_list):
    """return score list about a and b"""
    sum_a, sum_b = 0, 0
    card_list.sort()
    
    for i in range(len(card_list)):
        if i % 2 == 0:
            sum_a += card_list.pop()
        else:
            sum_b += card_list.pop()
            
    return sum_a, sum_b

def solve(card_list):
    """solve problem"""
    a_score, b_score = find_score(card_list)
    diff_score = a_score - b_score
    
    return diff_score

def main():
    """main method"""
    _ = input()
    list_cards = list(map(int, input().split(' ')))
    answer = solve(list_cards)
    print(answer)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
n,i;A[2<<17],B[2<<17],T[2<<17],F[1<<17];
long M,D[1<<17],P[1<<17],R[2<<17];
s(u,p,i,I){
	D[u]=1;
	for(i=F[u];I=B[i];i=T[i])I-p?s(I,u),D[u]=D[u]*-~D[I]%M:0;
}
S(u,p,x,i,I){
	for(m(i=F[u],p);I=B[i];I-p?S(I,u,R[i]*x%M+1,0,0),x=x*-~D[I]%M:0)i=T[i];
	P[u]=x%M;
}
m(i,p){
	i?m(T[i],p),R[i]=R[T[i]]*(B[i]-p?-~D[B[i]]:1)%M:0;
}
main(u,v){
	for(;~scanf("%d%d",&u,&v);)i++?A[i-1]=B[i]=u,B[i-1]=A[i++]=v:(n=u,M=v);
	for(;--i;F[A[i]]=i)T[i]=F[A[i]];
	s(*R=1,0);
	S(1,0,1);
	for(;i++<n;)printf("%d\n",P[i]);
}

Measured memory_bytes: 13184
using System;
using System.Linq;
using System.Collections.Generic;
namespace C
{
    class Program
    {
        static void Main(string[] args)
        {
            long [] line_1 = Console.ReadLine().Trim().Split().Select(x => Int64.Parse(x)).ToArray();
            long [] line_2 = Console.ReadLine().Trim().Split().Select(x => Int64.Parse(x)).ToArray();
            int N = (int)line_1[0];
            int K = (int)line_1[1];
            for (int i = K; i < N; i++)
            {
                Console.WriteLine(line_2[i - K] < line_2[i] ? "Yes" : "No");
            }
            Console.ReadLine();
        }
    }
}


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

int main(){
    int A, B, C, X, Y;
    cin >> A >> B >> C >> X >> Y;
    int res1, res2, res3;
    res1 = A*X + B*Y;
    if (X>Y){
        res2 = (X-Y)*A + Y*2*C;
    }else{
        res2 = (Y-X)*B + X*2*C;
    }
    res3 = max(X, Y) * 2 * C;
    cout << min(min(res1, res2), res3) << endl;
    return 0;
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func Scan() string {
	sc.Scan()
	return sc.Text()
}

func iScan() int {
	n, _ := strconv.Atoi(Scan())
	return n
}

func fScan() float64 {
	n, _ := strconv.ParseFloat(Scan(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func SScan(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scan()
	}
	return a
}
func iSScan(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = iScan()
	}
	return a
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func sum(a []int) int {
	x := 0
	for _, v := range a {
		x += v
	}
	return x
}

var mod int = 1000000007

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	s := Scan()
	for i := 0; i < len(s); i += 2 {
		fmt.Print(string(s[i]))
	}
	fmt.Println("")
}


Measured memory_bytes: 2980
import math
arr=[]
for i in range(3):
	temp=list(map(int,input().split()))
	arr.append(temp)
d={}
n=int(input())
for i in range(n):
	x=int(input())
	if x in d:
		d[x]+=1
	else:
		d[x]=1
brr=[]
for i in range(3):
	brr.append([])
for i in range(3):
	for j in range(3):
		if arr[i][j] in d:
			brr[i].append(1)
		else:
			brr[i].append(0)
flag=False
if brr[0][0]==1 and brr[0][1]==1 and brr[0][2]==1:
	flag=True
if brr[0][0]==1 and brr[1][1]==1 and brr[2][2]==1:
	flag=True
if brr[2][0]==1 and brr[1][1]==1 and brr[0][2]==1:
	flag=True
if brr[0][0]==1 and brr[1][0]==1 and brr[2][0]==1:
	flag=True
if brr[1][0]==1 and brr[1][1]==1 and brr[1][2]==1:
	flag=True
if brr[2][0]==1 and brr[2][1]==1 and brr[2][2]==1:
	flag=True
if brr[0][1]==1 and brr[1][1]==1 and brr[2][1]==1:
	flag=True 
if brr[0][2]==1 and brr[1][2]==1 and brr[2][2]==1:
	flag=True
if flag:
	print("Yes")
else:
	print("No")

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

n = int(input())
a = [int(x) for x in input().split()]

from collections import Counter

c = Counter(a)

ans = 0

for i in c.keys():
    if c[i] == i:
        pass
    elif c[i] < i:
        ans += c[i]
    else:
        ans += (c[i] - i)

print(ans)

Measured memory_bytes: 64552
import sys
sys.setrecursionlimit(2147483647)
INF = 1 << 60
MOD = 10**9 + 7 # 998244353
input = lambda:sys.stdin.readline().rstrip()
from collections import Counter
def resolve():
    m, n, k = map(int, input().split())
    grid = [list(map(int, input())) for _ in range(m)]
    # grid が 1 の個数が k 以下にする
    # m <= 10 なので、m についてどこで切るかを全探索 -> その後 n について貪欲
    res = INF

    counter = Counter()
    index_to_number = [None] * m
    def adding(j):
        for i in range(m):
            counter[index_to_number[i]] += grid[i][j]

    for U in range(1 << (m - 1)):
        counter.clear()
        index_to_number = [None] * m
        now = 0
        for i in range(m):
            index_to_number[i] = now
            now += (U >> i) & 1
        score = bin(U).count('1')
        # print(U, index_to_number)
        for j in range(n):
            # 一旦足してみる
            adding(j)
            if max(counter.values()) > k:
                score += 1
                counter.clear()
                adding(j) # もう1回やりなおす
                if max(counter.values()) > k: # やりなおした結果ダメなら無理
                    break

        else: # break されずに済めば OK
            res = min(res, score)
    print(res)
resolve()

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

int main(void){
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    if(A+B>C+D)
        cout << "Left" <<endl;
    else if(A+B<C+D)
        cout << "Right" <<endl;
    else
        cout << "Balanced" <<endl;
}

Measured memory_bytes: 256
def main():
    S = input()
    if S == "RRR":
        return 3
    if S == "RRS":
        return 2
    if S == "RSR":
        return 1
    if S == "RSS":
        return 1
    if S == "SRR":
        return 2
    if S == "SRS":
        return 1
    if S == "SSR":
        return 1
    if S == "SSS":
        return 0

if __name__ == '__main__':
    print(main())

Measured memory_bytes: 61844
S = input()

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

if 1 <= A <= 12 and 1 <= B <= 12:
    print('AMBIGUOUS')
elif 1 <= A <= 12 and 0 <= B <= 99:
    print('MMYY')
elif 0 <= A <= 99 and 1 <= B <= 12:
    print('YYMM')
else:
    print('NA')

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <string>
#include <functional>
#include <math.h>
#include <map>
using namespace std;

int main() {
	int n;
	long long h;
	cin >> n >> h;
	int a[100000], b[100000];
	for (int i = 0; i < n; i++) {
		cin >> a[i] >> b[i];
	}
	sort(a, a + n, greater<int>());
	sort(b, b + n, greater<int>());
	int count = 0;
	for (int i = 0; i < n; i++) {
		if (b[i] > a[0]) {
			count++;
		}
	}
	int ans = 0;
	for (int i = 0; i < count; i++) {
		h -= b[i];
		ans++;
		if (h <= 0) {
			cout << ans << endl;
			return 0;
		}
	}
	while (h > 0) {
		h -= a[0];
		ans++;
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define INF INT_MAX
#define ll  long long
#define ull unsigned long long
#define rep(i,n) for(ll i=0; i<n; ++i)
#define FOR(i, s, e) for(ll i=s; i<e; ++i)
#define MOD 1000000007
using namespace std;
template<class T> inline bool chmin(T& a, T b) { if(a>b) {a=b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) { if(a<b) {a=b; return true;} return false;}

int main() {
  double L; cin >> L;
  printf("%.12f\n", L/3*L/3*L/3);
}


Measured memory_bytes: 3784
import sys

N = int(sys.stdin.readline())

all_sum = N * (N+1) / 2
threes = (N//3) * (N//3 + 1) / 2
fives = (N//5) * (N//5 + 1) / 2
fifs = (N//15) * (N//15 + 1) / 2

ans = all_sum - threes*3 - fives*5 + fifs*15

print(int(ans))

Measured memory_bytes: 9184
#include<bits/stdc++.h>
#define For(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 FileName      "test"
#define ll            long long
#define ld            long double
#define ull           unsigned long long
#define Print(x)      cerr << #x << "is " << x << '\n';
#define pb            push_back
#define X             first
#define Y             second
//#define Karma

using namespace std;

template<typename T> inline void Cin(T &x)
{
    char c;
    T sign = 1;
    x = 0;
    for (c = getchar(); c < '0' || c > '9'; c = getchar())
        if (c == '-') sign = -1;
    for (; c >= '0' && c <= '9'; c = getchar())
        x = x * 10 + c - '0';
    x *= sign;
}
template <typename T> inline void Out(T x) {if(x > 9) Out(x / 10); putchar(x % 10 + '0');}
template <typename T> inline void Cout(T x, char c) {if(x < 0) putchar('-'); x = abs(x); Out(x); putchar(c);}
template <typename T, typename... Args> inline void Cin(T& a, Args&... args) {Cin(a);Cin(args...);}
template <typename T, typename... Args> inline void Cout(T a, char c, Args... args) {Cout(a, c);Cout(args...);}

typedef pair<int, int> pii;
typedef pair<ll, int> plli;
const int N = 1e3 + 7;
const ll mod = 1e9 + 7;

ll f[N][N], h, w;
char a[N][N];

ll DP(int x, int y)
{
    if(f[x][y] != -1) return f[x][y];
    if(a[x][y] == '#') return f[x][y] = 0;
    ll& res = f[x][y];
    res = 0;
    if(x > 1) res += DP(x - 1, y);
    if(y > 1) res += DP(x, y - 1);
    res %= mod;
    return res;
}

void Enter()
{
     cin >> h >> w;
     For(i, 1, h)
     {
         For(j, 1, w)
         cin >> a[i][j];
     }
}

void Solve()
{
     memset(&f, -1, sizeof f);
     f[1][1] = 1;
     cout << DP(h, w) % mod;
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
#ifdef Karma
    freopen(FileName".inp", "r", stdin);
    freopen(FileName".out", "w", stdout);
#endif // Karma

    Enter();
    Solve();

    return 0;
}


Measured memory_bytes: 9216
#include<iostream>
#include<climits>
using namespace std;
	int main(){
		int e,m,p,q,r,min,x;
		while(cin>>e,e){
			min=INT_MAX;
			for(int z=0;z*z*z<=e;z++)
			for(int y=0;y*y+z*z*z<=e;y++){
				x=e-z*z*z-y*y;
				if(x+y+z<min)
				min=x+y+z;
			}
			cout<<min<<endl;
		}
		return 0;
	}

Measured memory_bytes: 864
import sys
sys.setrecursionlimit(10**7)
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def MI(): return map(int, sys.stdin.readline().split())
def II(): return int(sys.stdin.readline())


def func(v):
    if ans[v] != -1:
        return
    ans[v] = c[index]
    global index
    index += 1
    for next_v in graph[v]:
        if v == next_v:
            continue
        func(next_v)


n = II()
graph = [[] for _ in range(n)]
for _ in range(n-1):
    u, v = MI()
    graph[u-1].append(v-1)
    graph[v-1].append(u-1)
c = sorted(LI(), reverse=True)
ans = [-1] * n
index = 0
func(0)
print(sum(c[1::]))
for i in range(n):
    print(ans[i], end=' ')
print()


Measured memory_bytes: 56424
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i < n; i++)
#define elif else if
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll MOD2 = 998244353;
const ll INF = 1e15;

int main(){
    string alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
    map<char, int> mp;
    rep(i, 26){
        mp[alpha[i]] = i;
    }
    int N;
    string S;
    cin >> N >> S;
    int n = S.size();
    rep(i, n){
        int j = mp[S[i]];
        cout << alpha[(j+N)%26];
    }
}

Measured memory_bytes: 256
from sys import stdin
from collections import defaultdict as dd
from collections import deque as dq
import itertools as it
from math import sqrt, log, log2
from fractions import Fraction

x, y = map(int, input().split())

if y%2==1:
    print('No')
    exit()

if y > 4*x or y < 2*x:
    print('No')
    exit()

print('Yes')


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

const bool DEBUG = false;

int N;
vector<int> a;

void input() {
  cin >> N;
  a = vector<int>(N);
  for (size_t i = 0; i < N; i++) cin >> a[i];
}

int main(int argc, char const *argv[]) {
  input();

  vector<int> b(N);
  for (int i = N - 1; i >= 0; i--) {
    int current = 0;
    for (int j = 2 * (i + 1); j <= N; j += (i + 1)) current += b[j - 1];
    if (((a[i] == 1) && (current % 2 == 0)) ||
        ((a[i] == 0) && (current % 2 == 1))) {
      b[i] = 1;
    }
  }

  vector<int> ans;
  for (int i = 0; i < N; i++)
    if (b[i] != 0) ans.push_back(i + 1);

  cout << ans.size() << endl;
  // if (ans.size() == 0) return 0;
  for (auto &&elem : ans) {
    cout << elem << " ";
  }
  cout << endl;

  return 0;
}


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

#define ll long long
#define INF 99999999
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

template < typename T > std::string to_string( const T& n )
{
    std::ostringstream stm ;
    stm << n ;
    return stm.str() ;
}

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

    vector<pair<ll, ll> > A;
    rep(i,N)
    {
        ll tmp;
        cin >> tmp;
        A.push_back(make_pair(tmp, i+1));
    }
    sort(all(A));
    rep(i,N)
    {
        cout << A[i].second;
        if( i+1 != N ) cout << " ";
    }
    cout << endl;
}


Measured memory_bytes: 2544
#include <utility>
#include <stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<cmath>
#define REP(i, n) for (int i = 0; i < (n); i++)
#define YES(b) std::cout<< (b ? "YES" : "NO")
using namespace std;
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, m, k;
	cin >> n>>m>>k;
	cout << (n + m)*k/2;

}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

#include <bits/stdc++.h>
using namespace std;

const int MX=200005;
int a[MX];

bool ok(int x,int n,int k)
{
    int c=0;
    for(int i=0;i<n;i++){
        if(a[i]<=x) break;
        int p=a[i]/x;
        if(a[i]%x) p++;
        c+=p-1;
        if(c>k) return false;
    }
    return true;
}

int f(int l,int r,int n,int k)
{
    if(r-l<4){
        while(l<r){
            if(ok(l,n,k)) return l;
            l++;
        }
        return r;
    }
    int m=(l+r)>>1;
    if(ok(m,n,k)) return f(l,m,n,k);
    return f(m+1,r,n,k);
}

int main()
{
    int n,k,m=0;
    scanf("%d %d",&n,&k);
    for(int i=0;i<n;i++){
        scanf("%d",&a[i]);
        m=max(m,a[i]);
    }
    sort(a,a+n,greater<int>());
    printf("%d\n",f(1,m,n,k));
    return 0;
}

Measured memory_bytes: 4576
#include <bits/stdc++.h>
#define LLI long long int
#define FOR(v, a, b) for(LLI v = (a); v < (b); ++v)
#define FORE(v, a, b) for(LLI v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(LLI v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define RITR(it, c) for(auto it = (c).rbegin(); it != (c).rend(); ++it)
#define EXIST(c,x) ((c).find(x) != (c).end())
#define fst first
#define snd second
#define popcount __builtin_popcount
#define UNIQ(v) (v).erase(unique(ALL(v)), (v).end())
#define bit(i) (1LL<<(i))

#ifdef DEBUG
#include <Mylib/Debug/debug.cpp>
#else
#define dump(...) ((void)0)
#endif

using namespace std;

template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}
template <typename T> istream& operator>>(istream &is, vector<T> &v){for(auto &a : v) is >> a; return is;}
template <typename T> void puts_all(const T &value){std::cout << value << "\n";}
template <typename T, typename ...Args> void puts_all(const T &value, const Args&... args){std::cout << value << " ";puts_all(args...);}

template <typename T, typename U> bool chmin(T &a, const U &b){return (a>b ? a=b, true : false);}
template <typename T, typename U> bool chmax(T &a, const U &b){return (a<b ? a=b, true : false);}
template <typename T, size_t N, typename U> void fill_array(T (&a)[N], const U &v){fill((U*)a, (U*)(a+N), v);}
template <typename T> auto make_vector(int n, int m, const T &value){return vector<vector<T>>(n, vector<T>(m, value));}


struct Init{
  Init(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(12);
    cerr << fixed << setprecision(12);
  }
}init;


const LLI INF = 1000000000000000000;

int main(){
  dump(4 / (-3));
  
  LLI N, K;
  while(cin >> N >> K){
    vector<LLI> A(N); cin >> A;
    sort(ALL(A));
    

    auto check =
      [&](LLI v){
        LLI c = 0;

        for(auto &x : A){
          if(x == 0){
            if(v >= 0) c += N;
            continue;
          }
          
          if(x > 0){
            LLI t;
            if(v >= 0) t = v / x;
            else t = - ((-v + x - 1) / x);
            
            c += upper_bound(ALL(A), t) - A.begin();

          }else if(x < 0){
            LLI t;
            if(v >= 0) t = - (v / (-x));
            else t = ((-v) + (-x) - 1) / (-x);

            c += N - (lower_bound(ALL(A), t) - A.begin());
          }
        }

        for(auto &x : A){
          if(x * x <= v) --c;
        }

        c /= 2;

        return c >= K;
      };
    
    LLI lb = -INF - 100, ub = INF + 100;
    while(abs(lb-ub) > 1){
      auto mid = (lb + ub) / 2;

      if(check(mid)){
        ub = mid;
      }else{
        lb = mid;
      }
    }

    puts_all(ub);
  }

  return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
 
using lint=long long;
const int INF=1e9;

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

   int N; cin>>N;
   vector<int> x(N);
   for(int i=0;i<N;i++) cin>>x[i];

   int ans=INF;
   for(int i=1;i<=100;i++){
      int sum=0;
      for(int j=0;j<N;j++) sum+=(x[j]-i)*(x[j]-i);
      ans=min(ans,sum);
   }
   cout<<ans<<endl;
   return 0;
}


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

using namespace std;

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

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define MP make_pair
#define MT make_tuple
#define EACH(i,c) for(auto i: c)
#define SORT(c) sort((c).begin(),(c).end())

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()

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

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

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

	string S;
	cin >> S;
	map<char, int> m;
	EACH(c, S){
		m[c]++;
		//cout << c << " " << m[c] << endl;
	}

	bool ok = true;
	if(!(m['N'] == 0 && m['S'] == 0) && !(m['N'] > 0 && m['S'] > 0)) ok = false;
	if(!(m['W'] == 0 && m['E'] == 0) && !(m['W'] > 0 && m['E'] > 0)) ok = false;

	if(ok) cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}


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

#define FOR(i,l,r) for(int i = (l);i < (r);i++)
#define ALL(x) (x).begin(),(x).end()
template<typename T> bool chmax(T& a,const T& b){return a < b ? (a = b,true) : false;}
template<typename T> bool chmin(T& a,const T& b){return b < a ? (a = b,true) : false;}
typedef long long ll;

int W,N;

int main()
{
	scanf("%d%d",&W,&N);
	vector<int> A(W + 1);
	for(int i = 1;i <= W;i++){
		A [i] = i;
	}

	FOR(i,0,N){
		int x,y;
		char c;
		scanf("%d%c%d",&x,&c,&y);
		swap(A [x],A [y]);
	}
	for(int i = 1;i <= W;i++){
		printf("%d\n",A [i]);
	}

	return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi; 
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;

#define sz(a) int((a).size())
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define ini(a, i) memset(a, i, sizeof(a))
#define present(i, c) ((c).find(i) != (c).end())

#define for0(i, n) for(int i = 0; i < n; i++)
#define for1(i, n) for(int i = 1; i <= n; i++)
#define fora(i, a, b) for(int i = (a); i < (b); i++)
#define ford(i, n) for(int i = (n)-1; i >= 0; i--)

#define TRACE(x...) x
#define watch(x) TRACE(cerr << #x" = " << x << endl)
#define watch_all(x) TRACE(cerr << #x" = "; for(auto __i : x) cerr << __i << " "; cerr << endl)
	
#define INF 0x3F3F3F3F

//=========================

int H[100001];
int dp[100001];

void run_test() {
	int N; cin >> N;
    for0(i, N) cin >> H[i];
    dp[0] = 0, dp[1] = abs(H[1]-H[0]);
    fora(i, 2, N) dp[i] = min(dp[i-1] + abs(H[i]-H[i-1]), dp[i-2] + abs(H[i]-H[i-2]));
    cout << dp[N-1] << endl;
}

//=========================

ifstream infile;
clock_t start__;
void open_func();
void close_func();

int main() {
	ios::sync_with_stdio(0); cin.tie(0);
	open_func();
	//int t; cin >> t; while(t--) run_test();
	run_test();
	close_func();
	return 0;	
}

void open_func() {
	//infile = ifstream("input.in"); if(infile.good()) cin.rdbuf(infile.rdbuf());
	start__ = clock();
	cerr << "---" << endl;
}

void close_func() {
	clock_t elapsed = clock()-start__;
	cerr << "---" << endl << "(time " << fixed << setprecision(2) << elapsed * (1.0/CLOCKS_PER_SEC) << "s)" << endl;	
	//if(infile.good()) infile.close();
}


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

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef pair<ll, ll> P;
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)

/***** define constant start *******/
const ll MOD = 1000000007;
const double PI = 3.1415926535897932;
const ll INF = 10000000000;
/****** define constant end ********/

/****** define variable start ******/
ll h, w, n;
/******* define variable end *******/
ll solve(){
    cin >> h >> w >> n;
    if (h > w){
        cout << (ll)ceil((double)n / h) << endl;
    }else{
        cout << (ll)ceil((double)n / w) << endl;
    }
    return 0;
}
int main(){
    //clock_t start = clock();
    cout << std::fixed << std::setprecision(10);
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll end_solve = solve();
    /*
    clock_t end = clock();
    const double time = static_cast<double>(end - start) / CLOCKS_PER_SEC * 1000.0;
    printf("time %lf[ms]\n", time);
    */
    return (int)end_solve;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for (int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
 
int main(void){
    int n;
    cin>>n;
    vector<int> v10;
    vector<int> vno10;
    rep(i, n) {
        int a;
        cin>>a;
        if(a%10) vno10.push_back(a);
        else v10.push_back(a);
    }
    if(vno10.size() == 0) {
        cout<<0<<endl;
        return 0;
    }
    sort(vno10.begin(), vno10.end());
    int no10 = accumulate(vno10.begin(), vno10.end(), 0);
    int yes10 = accumulate(v10.begin(), v10.end(), 0);
    int ans = yes10+no10;
    if(no10%10 == 0) ans -=vno10[0];
    cout<<ans<<endl;
    return 0;
}

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

int main() {
  int K;
  cin >> K;
  
  if (K == 1){
  cout << 1 << endl;
  }
  
  else if (K == 2){
  cout << 1 << endl;
  }
  
  else if (K == 3){
  cout << 1 << endl;
  }
  
  else if (K == 4){
  cout << 2 << endl;
  }
  
  else if (K == 5){
  cout << 1 << endl;
  }
  
  else if (K == 6){
  cout << 2 << endl;
  }
    
  else if (K == 7){
  cout << 1 << endl;
  }
  
  else if (K == 8){
  cout << 5 << endl;
  }
  
  else if (K == 9){
  cout << 2 << endl;
  }
  
  else if (K == 10){
  cout << 2 << endl;
  }
  
  else if (K == 11){
  cout << 1 << endl;
  }
  
  else if (K == 12){
  cout << 5 << endl;
  }
  
  else if (K == 13){
  cout << 1 << endl;
  }
  
  else if (K == 14){
  cout << 2 << endl;
  }
  
  else if (K == 15){
  cout << 1 << endl;
  }
  
  else if (K == 16){
  cout << 14 << endl;
  }

  else if (K == 17){
  cout << 1 << endl;
  }
    
  else if (K == 18){
  cout << 5 << endl;
  }
    
  
  else if (K == 19){
  cout << 1 << endl;
  }
  
  else if (K == 20){
  cout << 5 << endl;
  }
  
  else if (K == 21){
  cout << 2 << endl;
  }
  
  else if (K == 22){
  cout << 2 << endl;   
  }  
    
  else if (K == 23){
  cout << 1 << endl;
  }
  
  else if (K == 24){
  cout << 15 << endl;
  }

  else if (K == 25){
  cout << 2 << endl;
  }
  
  else if (K == 26){
  cout << 2 << endl;
  }
  
  else if (K == 27){
  cout << 5 << endl;
  }
  
  else if (K == 28){
  cout << 4 << endl;
  }
  
  else if (K == 29){
  cout << 1 << endl;
  }
  
  else if (K == 30){
  cout << 4 << endl;
  }
  
  else if (K == 31){
  cout << 1 << endl;
  }
    
  else if (K == 32){
  cout << 51 << endl;
  }
  
  else{
  }
    
}

Measured memory_bytes: 256
S=input()
T=input()
dp=[ [0]*(len(T)+1) for i in range(len(S)+1) ]
for i in range(len(S)):
  for j in range(len(T)):
    if S[i]==T[j]:
      dp[i+1][j+1]=dp[i][j]+1
    else:
      dp[i+1][j+1]=max( dp[i+1][j], dp[i][j+1] )

i=len(S)
j=len(T)
ans=''
while(i>0 and j>0):
  if dp[i][j]==dp[i-1][j]:
    i-=1
  elif dp[i][j]==dp[i][j-1]:
    j-=1
  else:
    ans=S[i-1]+ans
    i-=1
    j-=1
print(ans)

Measured memory_bytes: 112220
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: 26160
n, m = map(int, input().split(" "))
oks, dp = [True] * (n + 1), [0] * (n+1)

for _ in range(m):
    a = int(input())
    oks[a] = False

dp[0] = 1
for now in range(n):
    for next in range(now+1, min(n+1, now + 3)):
        if oks[next]:
            dp[next] += dp[now]
            dp[next] %= 10 ** 9 + 7
print(dp[n])

Measured memory_bytes: 7700
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
//#define MOD 1000000007
#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;


int main(){
    int N,M; cin >> N >> M;
    vector<int> X(N);
    rep(i,N) cin >> X[i];
    sort(X.begin(),X.end());
    vector<int> v1(M),v2(M);
    rep(i,N-1){
        if(X[i] == X[i+1]){
            v1[X[i]%M]+=2;
            i++;
        }
    }
    rep(i,N){
        v2[X[i]%M]++;
    }
    int ans = 0;
    ans += v2[0]/2;
    if(M%2 == 0) ans += v2[M/2]/2;
    repr(i,1,M/2+1){
        if(M%2 == 0 && i == M/2) continue;
        int k = min(v2[i],v2[M-i]);
        ans += k;
        int d1 = v2[i]-v1[i];
        int d2 = v2[M-i]-v1[M-i];
        if(k > d1) v1[i] = v1[i]-(k-d1);
        if(k > d2) v1[M-i] = v1[M-i]-(k-d2);
    }
    repr(i,1,M){
        if(M%2 == 0 && i == M/2) continue;
        if(v1[i] > 0) ans += v1[i]/2;
    }
    cout << ans << endl;

}

    



Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp setprecision
#define pb(x) push_back(x)
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
const ll MOD = 1e9+7;
const ll MOD2 = 998244353;
const int inf = INT_MAX;
const ll INF = LLONG_MAX;
const string alpha = "abcdefghijklmnopqrstuvwxyz";

int main(){
    int D, G;
    cin >> D >> G;
    int p[D], c[D];
    rep(i, D) cin >> p[i] >> c[i];
    int ans = inf;
    rep(i, 1<<D){
        int tmp = 0, num = 0;
        rep(j, D){
            if(i & (1<<j)){
                tmp += 100*(j+1)*p[j] + c[j];
                num += p[j];
            }
        }
        rep3(j, D-1, 0){
            if(i & (1<<j)) continue;
            int cnt = 0;
            while(tmp < G && cnt < p[j]-1){
                tmp += 100*(j+1);
                num++;
                cnt++;
            }
        }
        if(tmp >= G) ans = min(ans, num);
    }
    cout << ans << endl;
}

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

l, r = a[:2]
m = 1
b = [(l,r)]
for i in range(2, n-2):
    r += a[i]
    for j in range(m, i):
        nl, nr = l+a[j], r-a[j]
        if abs(l-r) < abs(nl-nr): 
            break
        l, r = nl, nr
        m += 1
    b.append((l,r))

l, r = a[-2:]
m = n-2
c = [(l,r)]
for i in range(2, n-2)[::-1]:
    l += a[i]
    for j in range(i+1, m+1)[::-1]:
        nl, nr = l-a[j], r+a[j]
        if abs(l-r) < abs(nl-nr): 
            break
        l, r = nl, nr
        m -= 1
    c.append((l,r))

r = 10**9
for i in range(n-3):
    x = max(b[i]+c[-i-1])
    y = min(b[i]+c[-i-1])
    r = min(r, x-y)
print(r)


Measured memory_bytes: 56572
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const long double PI = 3.14159265358979323846;

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

    int n;
    cin >> n;
    vector<int> sub(n);
    for (int i = 1; i < n; ++i) {
        int x;
        cin >> x;
        ++sub[x - 1];
    }
    for (int i = 0; i < n; ++i) {
        cout << sub[i] << '\n';
    }

    return 0;
}


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

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
typedef long double ld;

const int INF = 1e9;
const ld EPS = 1e-8;
int MOD = 1e9 + 7;

ll extgcd(ll a, ll b, ll& x, ll& y) {
  ll g = a; x = 1; y = 0;
  if(b != 0) {
    g = extgcd(b, a % b, y, x);
    y -= (a / b) * x;
  }
  return g;
}

ll invMod(ll a, ll m) {
  ll x, y;
  if(extgcd(a, m, x, y) == 1) return (x + m) % m;
  else return 0;
}

struct comb{
  vector<ll> fct;
  vector<ll> inv;
  comb(int N){
    fct.assign(N + 1, 1);
    inv.assign(N + 1, 1);

    REP(i, N) fct[i + 1] = fct[i] * (i + 1) % MOD;
    REP(i, N) inv[i + 1] = invMod(fct[i + 1], MOD);
  }
  ll get(int n, int k) {
    if((k > n) || (k < 0)) return 0;
    ll ret = (fct[n] * inv[n - k] % MOD) * inv[k] % MOD;
    return ret;
  }
};

int main(){
  int n;
  cin >> n;
  vector<int> a(n + 1);
  REP(i,n + 1) {
    cin >> a[i];
    --a[i];
  }

  int d;
  vector<bool> flag(n, false);
  REP(i,n + 1) {
    if(flag[a[i]]) {
      d = a[i];
      break;
    }
    flag[a[i]] = true;
  }

  int p1 = -1, p2 = -1;
  REP(i, n + 1) {
    if((a[i] == d) && (p1 == -1)) {
      p1 = i;
    }else if(a[i] == d) {
      p2 = i;
    }
  }

  comb cmb(n + 2);

  for(int k = 1; k <= n + 1; ++k) {
    ll ret = (cmb.get(n + 1, k) - cmb.get(n - p2 + p1, k - 1) + MOD) % MOD;
    cout << ret << endl;
  }
  return 0;
}



Measured memory_bytes: 3200
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		sc.nextLine();
		String[] a = new String[n];
		String s = sc.nextLine();
		Map<String, Integer> idx = new HashMap<>();
		for (int i = 0; i < s.length(); i++) {
			a[i] = s.substring(i);
			idx.put(a[i], i);
		}
		Arrays.sort(a);

		int answer = 0;
		for (int i = 1; i < a.length; i++) {
			int current = 0;

			int l = 0;
			int r = i;
			while (l < r) {
				int mid = (l + r) / 2;
				if (a[mid].charAt(0) < a[i].charAt(0)) {
					l = mid + 1;
				} else {
					r = mid - 1;
				}
			}

			while (l < i) {
				int ai = Math.min(idx.get(a[l]), idx.get(a[i]));
				int bi = Math.max(idx.get(a[l]), idx.get(a[i]));

				while (current < Math.min(a[l].length(), a[i].length())) {
					if (a[l].charAt(current) != a[i].charAt(current)) break;
					if (ai + current >= bi) break;
					current++;
				}
				l++;
			}

			answer = Math.max(answer, current);
		}

		System.out.println(answer);
	}
}


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

int main()
{
	int a,b;
	cin>>a>>b;
	if(a>=13)
	{
		cout<<b<<endl;
		return 0;
	 } 
	 else if(a>=6&&a<=12){
	 	cout<<b/2<<endl;
	 	return 0;
	 }
	 else{
	 	cout<<"0"<<endl;
	 	return 0;
	 }
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define forn(i, n) for (llong i = 0ll; i < (llong) n; ++i)
#define fornn(i, l, r) for (llong i = (llong) l; i < (llong) r; ++i)
#define size(x) ((int) (x.size()))
 
using namespace std;
 
typedef long long llong;
const llong inf = (llong) 1e+9 + 7ll;
const llong linf = (llong) 1e+18 + 7ll;
const long double eps = (long double) 1e-9;
const long double pi = acosl((long double) -1.0);
const int alph = 26;

mt19937 mrand(random_device{} ()); 

template<typename T, typename U> inline llong umin(const T& a, const U& b) { return a < b ? a : b; }
template<typename T, typename U> inline llong umax(const T& a, const U& b) { return a > b ? a : b; }
 
static char buff[(int) 2e6 + 17]; // reads std::string
const int maxn = (int) 3e5 + 17;

int n;
llong a, b;
int x[maxn];

bool read()
{
	if (scanf("%d", &n) != 1)
		return false;
	
	scanf("%lld %lld", &a, &b);

	forn (i, n)
		scanf("%d", x + i);

	return true;
}

void solve()
{
	llong ans = 0;

	forn (i, n - 1)
		ans += min(a * (x[i + 1] - x[i]), b);

	printf("%lld\n", ans);
}

int main()
{
#if SEREZHKA
	freopen("file.in", "r", stdin);
#endif

	while (read())
		solve();

	return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <utility>
using namespace std;

#define FOR(i,a,b) for(long long int i=(a);i<(b);i++)
#define REP(i,N) for(long long int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()

typedef long long ll;

#define PI acos(-1.0);

int n;
int dp[20][20];

int main(){
	while (cin >> n){
		if (n == 0)break;
		int x = n / 2 + 2, y = n / 2 + 1;
		dp[x][y] = 1;
		FOR(i, 2, n*n + 1){
			x++;
			y++;
			if (x > n){
				x = 1;
			}
			if (y > n){
				y = 1;
			}
			while (dp[x][y] != 0){
				x++;
				y--;
				if (x > n){
					x = 1;
				}
				if (y == 0){
					y = n;
				}
			}
			dp[x][y] = i;
		}
		FOR(i, 1, n + 1){
			FOR(j, 1, n + 1){
				printf("%4d", dp[i][j]);
			}
			cout << endl;
		}
		REP(i, n+1){
			REP(j, n + 1){
				dp[i][j] = 0;
			}
		}
	}
}

Measured memory_bytes: 1192
#include <bits/stdc++.h>
//#include <tr1/unordered_map>
//#include"Bignum/bignum.h"
//#define big bignum
#define lowbit(x) (x & -x)
#define debug(x) (cout << "#x = " << (x) << endl)
#define Set(x, i) memset (x, i, sizeof(x))
#define R register
#define For(i, j, k) for(R int i = (j); i <= (int) (k); ++i)
#define Rep(i, j, k) for(R int i = (j); i >= (int) (k); --i)
#define Cross(i, j, k) for(R int i = (j); i; i = (k))
using namespace std;
typedef long long ll;
const ll N = 100011;
const ll INF = 5e16;

namespace IO {

	inline char gc() {
		static char buf[100000], *p1 = buf, *p2 = buf;
		return (p1 == p2) && (p2 = (p1 = buf) +
			fread(buf, 1, 100000, stdin), p1 == p2)? EOF: *p1++;
	}

	#define dd ch = getchar()
	inline ll read() {
		R ll x = 0; R int f = 0; R char dd;
		for (; !isdigit(ch); dd) f ^= (ch == '-');
		for (; isdigit(ch); dd)  x = x * 10 + (ch ^ 48);
		return f? -x: x;
	}
	#undef dd

	inline void write ( ll x ) {
		if (x < 0) x = -x, putchar('-');
		if (x > 9) write(x / 10); putchar(x % 10 | 48);
	}

	inline void wrn ( ll x ) { write(x), putchar(' '); }

	inline void wln ( ll x ) { write(x), putchar('\n'); }

	inline void wlnn ( ll x, ll y ) { wrn(x), wln(y); }

}

using IO::wln;
using IO::read;

namespace Cesare {
	
	int main() {
		ll n = read();
		if (n & 1) printf("%.8lf\n", 1.0 * (n / 2 + 1) / n);
		else printf("%.8lf\n", 0.5000000000000);
		return 0;
	}
	
}

int main()
{
//	freopen(".in", "r", stdin);
//	freopen(".out", "w", stdout);

	return Cesare :: main();
}

/*

*/






Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back 
#define pf push_front 
#define mp make_pair
#define fr first
#define sc second
#define Rep(i,n) for(int i=0;i<(n);i++)
#define All(v) v.begin(),v.end()
typedef pair<int, int> Pii; typedef pair<int, Pii> Pip;
const int INF = 1107110711071107;


main()
{
  int N;
  int data[1001];
  vector<Pip> v;

  cin >> N;
  Rep(i, N) cin >> data[i];

  for(int i=0; i<N-1; i++) {
    for(int j=i+1; j<N; j++) {
      v.pb( Pip( data[i] + data[j], Pii( i, j ) ) );
    }
  }

  sort( All( v ) );
  /*for(int i=0; i<v.size(); i++) {
    cout << v[i].fr << endl;
    }*/
  double mx = 0;
  for(int i=0; i<N; i++) {
    for(int j=0; j<N; j++) {
      if( i == j ) continue;
      if( data[i] - data[j] == 0 ) {
	continue;
      }
      else if( data[i] - data[j] > 0 ) {
	for(int k=v.size()-1; k>=0; k--) {
	  Pip p = v[k];
	  if( p.sc.fr == i || p.sc.fr == j || p.sc.sc == i || p.sc.sc == j ) continue;
	  else {
	    mx = max( mx, (double)((double)p.fr / (double)(data[i] - data[j])) );
	    break;
	  }
	}
      }     
    }
  }

  printf("%.7lf\n", mx);
}

Measured memory_bytes: 15152
#include<iostream>

int main(){
	int n,a,b;
	int i,j,sum,ans=0;
	std::cin >> n >> a >> b;
	for(i=1;i<=n;i++){
		j=i;
		sum=0;
		while(j!=0){
			sum+=j%10;
			j/=10;
		}
		if(sum>=a && sum<=b)ans+=i;
	}
	std::cout << ans;
	return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"container/heap"
	"fmt"
	"math"
	"os"
	"strconv"
)

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

// Priority Queue
type Item struct {
	priority, value, index int
}

type PQ []*Item

func (pq PQ) Len() int {
	return len(pq)
}

func (pq PQ) Less(i, j int) bool {
	return pq[i].priority < pq[j].priority
}

func (pq PQ) Swap(i, j int) {
	pq[i], pq[j] = pq[j], pq[i]
	pq[i].index = i
	pq[j].index = j
}

func (pq *PQ) Push(x interface{}) {
	n := len(*pq)
	item := x.(*Item)
	item.index = n
	*pq = append(*pq, item)
}

func (pq *PQ) Pop() interface{} {
	old := *pq
	n := len(old)
	item := old[n-1]
	item.index = -1
	*pq = old[0 : n-1]
	return item
}

// End Priority Queue

// Path
type Edge struct {
	to, cost int
}

type Path struct {
	edges []Edge
}

// Dijkstra
type Route struct {
	path []int
}

func Dijkstra(N, S int, path []Path) ([]int, []Route) {
	pq := make(PQ, 0)
	heap.Init(&pq)
	d := make([]int, N+1)
	r := make([]Route, N+1)
	// init
	for i := 0; i <= N; i++ {
		d[i] = math.MaxInt32
	}
	d[S] = 0
	r[S].path = []int{S}
	heap.Push(&pq, &Item{0, S, 0})
	for pq.Len() > 0 {
		item := heap.Pop(&pq).(*Item)
		v := item.value
		if d[v] < item.priority {
			continue
		}
		for _, e := range path[v].edges {
			if d[e.to] > d[v]+e.cost {
				d[e.to] = d[v] + e.cost
				r[e.to].path = append(r[v].path, e.to)
				heap.Push(&pq, &Item{d[e.to], e.to, 0})
			}
		}
	}
	return d, r
}

func main() {
	sc.Split(bufio.ScanWords)
	N, X, Y := getInt(), getInt()-1, getInt()-1

	path := make([]Path, N)
	for i := 0; i < N-1; i++ {
		f := i
		t := i + 1
		path[f].edges = append(path[f].edges, Edge{t, 1})
		path[t].edges = append(path[t].edges, Edge{f, 1})
	}
	path[X].edges = append(path[X].edges, Edge{Y, 1})
	path[Y].edges = append(path[Y].edges, Edge{X, 1})

	//out(path)
	m := make(map[int]int)
	for i := 0; i < N; i++ {
		d, _ := Dijkstra(N, i, path)
		//out(d, r)
		for j := 0; j < N; j++ {
			m[d[j]]++
		}
	}
	w := bufio.NewWriter(os.Stdout)
	defer w.Flush()
	for i := 1; i < N; i++ {
		out(m[i] / 2)
	}
}


Measured memory_bytes: 7704
#include<stdio.h>
#include<algorithm>
using namespace std;
int n,h;
int a[100100];
int b[100100];
int main(){
  scanf("%d%d",&n,&h);
  int maxa=-1;
  for (int i=1;i<=n;i++){
      scanf("%d%d",&a[i],&b[i]);
    maxa=max(maxa,a[i]);
  }
  sort(b+1,b+n+1);
  int curIdx=n;
  int t=0;
  while(h>0){
    if (curIdx && b[curIdx]>maxa){
      h-=b[curIdx--];
      t++;
    }else{
      t+=h/maxa;
      if (h%maxa) t++;
      break;
    }
  }
  printf("%d\n",t);
  return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using Graph = vector<vector<int>>;
ll gcd(ll a,ll b){
    if(b == 0) return a;
    return gcd(b,a%b);
}
bool palin(int N){//Nが回文数かどうか
    string S = to_string(N);
    int M = (S.size()-1)/2 + 1;
    int n = S.size();
    bool flag = true;

    for(int i = M;i<n;i++){
        if(S[i] != S[n-i-1]) flag = false;
    }
   return flag;
}
/*
*/
int main(){
  string s;
  cin >> s;
  vector<string> S = {"SUN","MON","TUE","WED","THU","FRI","SAT"};

  rep(i,7){
    if(s == S[i]){
      cout << 7-i << endl;
      break;
    }
  }

 }

Measured memory_bytes: 256
//============================================================================
// 
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <math.h>

//============================================================================
#define PI 3.14159265359
#define succ(x) ((x)+1)
#define pred(x) ((x)-1)
//============================================================================
void enter()
{
    double r;

    scanf("%lf", &r);
    printf("%.6lf ", r*r*PI);
    printf("%.6lf\n", r*2*PI);
}
//============================================================================
int main(void)
{
    enter();
    return 0;
}
//============================================================================

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

using namespace std;

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

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;

void sayYes() {puts("Yes");}
void sayNo() {puts("No");}
template<class T> bool chmin(T&a,T b) {if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b) {if(a<b){a=b;return true;}return false;}

class FastIO {
public:
    FastIO() {
        cin.tie(0);
        ios::sync_with_stdio(false);
    }
    ~FastIO() {}

    template <class T>
    void scan(T &v) {
        cin >> v;
    }
    template <class T, class... Rest>
    void scan(T &v, Rest&... rest) {
        scan(v);
        scan(rest...);
    }

    template <class T>
    void print(T v) {
        cout << v;
    }
    template <class T, class... Rest>
    void print(T v, Rest... rest) {
        print(v);
        print(" ");
        print(rest...);
    }
    template <class T>
    void prints(vector<T>& v) {
        for (T t: v) {
            print(t);
            print(" ");
        }
        print("\n");
    }
    template <class T>
    void prints(T v) {
        print(v);
        cout << "\n";
    }
    template <class T, class... Rest>
    void prints(T v, Rest... rest) {
        print(v);
        print(" ");
        prints(rest...);
    }
};

FastIO io;
void _main(FastIO&);
int main() {
    _main(io);
}

int getDigits(ll n) {
    ll c = 0;
    while (n > 0) {
        n >>= 1;
        c++;
    }
    return c;
}

void use(int N, int M, vector<ll>& A) {
    sort(ALL(A), greater<ll>());
    vector<ll> digits(N);
    REP(i, N) digits[i] = getDigits(A[i]);

    int diff, i;
    for (i=1; i<N; i++) {
        if (digits[i-1] == digits[i]) continue;

        diff = digits[i-1] - digits[i];
        if (M <= i * diff) break;

        M -= i * diff;
    }
    int restDiff = M / i;
    M -= restDiff * i;
    int targetDigit = digits[i-1] - restDiff;
    REP(j, i) {
        A[j] >>= digits[j] - targetDigit;
    }
    sort(A.begin(), A.begin()+i, greater<ll>());
    REP(j, M) {
        A[j] >>= 1;
    }
}

void _main(FastIO &io) {
    int N, M; io.scan(N, M);
    vector<ll> A(N);
    REP(i, N) io.scan(A[i]);
    
    use(N, M, A);
    
    ll sum = 0;
    REP(i, N) sum += A[i];

    io.print(sum);
}


Measured memory_bytes: 1792
# pragma GCC optimize("Ofast")
# include <bits/stdc++.h>
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size)
# define pb push_back
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
using namespace std;
using lint = long long;
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; }


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n,m; cin >> n;
    map<string, int> s;
    string tmp;
    rep(i,n){
        cin >> tmp;
        s[tmp]++;
    }
    cin >> m;
    map<string, int> t;
    rep(i,m){
        cin >> tmp;
        t[tmp]++;
    }
    int ans = 0;
    for(auto &d:s){
        ans = max(ans,d.second - t[d.first]);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256