akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader
import java.util.*

fun main() = abc138e()


@OptIn(ExperimentalStdlibApi::class)
fun abc138e() = SimpleFastIOWithToken_abc138e().exec {
    val s = readString()
    val t = readString()
    fun Char.toIndex() = this - 'a'

    val appearIndices = Array(26) { mutableListOf<Int>() }

    for ((index, sc) in s.repeat(2).withIndex()) {
        appearIndices[sc.toIndex()].add(index)
    }

    var currentIndex = s.lastIndex
    var answer = 0L

    for (tc in t) {
        val indices = appearIndices[tc.toIndex()]
        val lb = indices.upperBound(currentIndex)
        val nextIndex = indices.getOrNull(lb) ?: return@exec println(-1)
        answer += nextIndex - currentIndex
        currentIndex = nextIndex % s.length
    }

    println(answer)
}

// list must be sorted
private fun List<Int>.upperBound(key: Int): Int {
    var ng = -1
    var ok = size

    while (ok - ng > 1) {
        val mid = (ok + ng) / 2
        if (this[mid] > key) ok = mid else ng = mid
    }
    return ok
}

// region kokokara template dayo (^o^)
@Suppress("unused", "HasPlatformType", "MemberVisibilityCanBePrivate", "ClassName")
private class SimpleFastIOWithToken_abc138e(private val separator: String = System.lineSeparator()) {
    private val br: BufferedReader = System.`in`.bufferedReader()
    private var st: StringTokenizer = StringTokenizer("")
    private val sb: StringBuilder = StringBuilder()
    private fun prepareNext() = run { if (!st.hasMoreTokens()) st = StringTokenizer(br.readLine()) }

    fun readString(): String = run { prepareNext() }.run { st.nextToken() }
    fun readStringList(size: Int): List<String> = List(size) { readString() }
    fun readInt(): Int = Integer.valueOf(readString())
    fun readIntList(size: Int): List<Int> = List(size) { readInt() }
    fun readLong(): Long = java.lang.Long.valueOf(readString())
    fun readLongList(size: Int): List<Long> = List(size) { readLong() }
    inline fun <reified T> readArray(size: Int, init: () -> T) = Array(size) { init() }
    inline fun <T> readList(size: Int, init: () -> T) = List(size) { init() }

    fun println(): Unit = run { sb.append(separator) }
    fun print(any: Any): Unit = run { sb.append(any) }
    fun println(any: Any): Unit = print(any.toString() + separator)

    fun exec(action: SimpleFastIOWithToken_abc138e.() -> Unit) = run {
        Thread(null, { action() }, "(^o^)", 128 * 1024 * 1024).apply { start() }.join()
    }.run { kotlin.io.print(sb) }

    fun readLine(): Nothing = error("readLine is disabled.")
}
// endregion kokomade template dayo (^o^)


Measured memory_bytes: 47068
#include <stdio.h>
#include <stdlib.h>
#define MAX 2000005
#define VMAX 10005

int A[MAX], B[MAX];
int C[VMAX+1];

int main(){
  
  //unsigned short *A, *B;

  int n, i, j;

  scanf("%d", &n);

  //A = malloc(sizeof(short)*n+1);
  //B = malloc(sizeof(short)*n+1);

  for(i=1;i<=n;i++){
    //    scanf("%d",A+i);
     scanf("%d",&A[i]);
    // printf("%d ",*(A+i));
     //    C[i]=0;
  }
  //C[n]=0;

  //printf("\n");
  for(j=1;j<=n;j++){
    C[A[j]]++;
  }
  /*
  for(j=0;j<=n;j++){
    printf("%d ",j);
  }   
  printf("\n");
  
  for(j=0;j<=n;j++){
    printf("%d ",C[j]);
  }   
  printf("\n");
  */
  
  for(i=1;i<=VMAX;i++){
    C[i] += C[i-1];
  }
 
  
  /*

  for(j=0;j<=n;j++){
    printf("%d ",C[j]);
  }
  printf("\n");
  */
    
  for(j=n;j>0;j--){
    B[C[A[j]]]= A[j];
    C[A[j]]--;
  }
    
  for(j=1;j<=n;j++){
    printf("%d",B[j]);
    if(j!=n)printf(" ");
  }
  printf("\n");
  
  return 0;
}



Measured memory_bytes: 17360
import java.util.*;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int H = Integer.parseInt(sc.next());
        int W = Integer.parseInt(sc.next());
        int h = Integer.parseInt(sc.next());
        int w = Integer.parseInt(sc.next());
        System.out.println(H*W-h*W-w*H+h*w);
    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
#include <atcoder/all>
#define ll long long int
#define ld long double
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repi(i, n) for (ll i = 1; i < (ll)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) cout << x << endl;
#define println(x) cout << x << endl;
using namespace std;
using namespace atcoder;
void Main()
{
    ll T;
    cin >> T;

    rep(i, T) {
        ll n, m, a, b;
        cin >> n >> m >> a >> b;
        put(floor_sum(n, m, a, b))
    }
}
signed main(){ Main();return 0;}

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

ok = 1
tmp_list = []
for i in range(n):
    w = str(input())

    if i == 0:
        tmp = w
        tmp_list.append(w)
        continue

    else:
        if w[0] != tmp[-1] or w in tmp_list:
            ok = 0

        else:
            tmp_list.append(w)
            tmp = w

if ok == 1:
    print('Yes')
else:
    print('No')



Measured memory_bytes: 38384
//
//  sublime text 3,
//  emre yazicioglu
//

#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <iostream>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair <ll, ll> pll;
typedef vector <ll> vll;
typedef vector <pll> vpll;
#define pb push_back
#define fi first
#define se second
#define INF (ll) (1e18 + 7)
#define MOD (ll) (1e9 + 7)

const int N = 2e6 + 7;
ll mn = INF, mx = -INF;
ll n, m, k, s, q, t;
ll a[N], b[N], c, d, e;
ll ans, cur, sum, cnt;
ll ar[N], p[N], dp[N];
string str; bool h[N];
pll pp[N]; vll v;

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

  // freopen("../in.txt","r",stdin);
  // freopen("../out.txt","w",stdout);

  cin >> n >> k;
  for(int i = 1; i <= n; i++)
    cin >> a[i];
  for(int i = 1; i <= n; i++)
    cin >> b[i];
  sort(a + 1, a + n + 1);
  sort(b + 1, b + n + 1);
  reverse(b + 1, b + n + 1);
  ll l = 0, r = INF;
  while(l < r) {
    ll mid = l + (r - l) / 2;
    for(int i = 1; i <= n; i++)
      cnt += max(0ll, a[i] - mid / b[i]); 
    if(cnt <= k)
      r = mid;
    else
      l = mid + 1;
    cnt = 0;
  }
  cout << r;
}

Measured memory_bytes: 8448
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <string>

using namespace std;

int main(void)
{

    int a,b;
    cin >>a >>b;

    int tapct = 1;
    int ans = 0;

    for(int i = 0; i < 30; i++){
        if(tapct >= b){
            ans = i;
            break;
        }
        tapct += (a-1);
    }

    printf("%d\n", ans);

    return 0;
}

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

const int MOD_CONST = 1000000007;

using namespace std;

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

	return gcd(b%a, a);

}

int main() {
	long long a, b, c, d;
	
	cin >> a >> b >> c >> d;

	long long ans = b - a + 1;

	ans -= (b / c - a / c);
	if (a%c == 0) {
		ans--;
	}
	ans -= (b / d - a / d);
	if (a%d == 0) {
		ans--;
	}

	if (c > d) {
		swap(c, d);
	}
	long long lcm = c * d / gcd(c, d);
	ans += (b / lcm - a / lcm);
	if (a % lcm == 0) {
		ans++;
	}
	cout << ans << endl;

}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <numeric>
#include <cmath>

using namespace std;

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

#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 1e9;

int main()
{
	int n;
	cin>>n;
	vector<int> b(n);
	for(int i = 0; i < n; i++){
		cin>>b[i];
		b[i]--;
	}

	vector<int> ans,res=b;

	while(res.size()>0){
		vector<int> res2=res;
		int flag=-1;
		for(int i = res2.size()-1; i >=0; i--){
			if(res[i]==i){
				ans.push_back(res2[i]);
				flag=i;
				break;
			}
		}
		if(flag<0){
			cout << -1 << endl;
			return 0;
		}
		res.clear();
		for(int i = 0; i < res2.size(); i++){
			if(i!=flag) res.push_back(res2[i]);
		}
	}
	reverse(all(ans));
	for(int i = 0; i < n; i++){
		cout << ans[i]+1 << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <numeric>
#include <queue>
#include <numeric>
#include <iomanip>
#include <sstream>
#include <cmath>
#include <map>
#include <functional>
#include <limits>
#include <set>
#include <stack>
#include <cctype>
#define rep(i,a,b) for((i)=a;i<(int)(b);i++)

#define AAA (1000000007) 


using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pairII;


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

ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}
ll powD(ll a, ll b) {
	ll ans = 1;
	a %= AAA;
	for (int i = 0; i < b; i++)
	{
		ans *= a;
		ans %= AAA;
	}
	return ans;
}



int main() {
	int a;
	cin >> a;
	cout << a + a * a + a * a * a;


	return 0;
}


Measured memory_bytes: 3620
#include<iostream>
using namespace std;
int main(){
    string ans;
    char s[4];
    int sint;
    cin >> sint;
    s[0] = sint/1000;
    s[1] = (sint%1000)/100;
    s[2] = (sint%100)/10;
    s[3] = (sint%10);
    if(s[0]==s[1] || s[1]==s[2] || s[2]==s[3]){
        ans = "Bad";
    }else{
        ans = "Good";
    }
    cout << ans << endl;
    return 0;
}

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


int main() {
  string s,t;
  int flag = 0;
  cin >> s >> t;
  for(int i = 0; i < s.size(); i++){
    if (s.at(i) != t.at(i)) flag = 1;
  }
  if (flag == 0) cout << "Yes" << endl;
  else cout << "No" << endl; 


}

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

bool isSame(vector<int> a, vector<int> b) {
	for (int i = 0; i < 6; ++i) {
		if (a[i] != b[i]) return false;
	}
	return true;
}

bool areSame(vector<int> s, vector<int> b) {
	string com = "NNNNEEEE";
	int tmp;
	for (int n = 0; n < 8; ++n) {
		do {
			for (int i = 0; i < n; ++i) {
				if(isSame(s, b)) {
					return true;
				}

				if (com[i] == 'N') {
					tmp = s[5];
					s[5] = s[4];
					s[4] = s[0];
					s[0] = s[1];
					s[1] = tmp;
				}
				else if (com[i] == 'E') {
					tmp = s[5];
					s[5] = s[2];
					s[2] = s[0];
					s[0] = s[3];
					s[3] = tmp;
				}
			}
		} while (next_permutation(com.begin(), com.end()));
	}
	return false;
}

signed main() {
	vector<int> s(6), b(6);
	for (int i = 0; i < 6; ++i) {
		cin >> s[i];
	}
	for (int i = 0; i < 6; ++i) {
		cin >> b[i];
	}

	if (areSame(s, b)) cout << "Yes" << endl;
	else cout << "No" << endl;
}



Measured memory_bytes: 3224
import java.util.Scanner;

public class Main {

	static String[] alphabet = { "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q",
			"r", "s", "t", "u", "v", "w", "x", "y", "z" };

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s1 = sc.next();
		String s2 = sc.next();
		String s3 = sc.next();
		String S1 = String.valueOf(s1.charAt(0)).toUpperCase();
		String S2 = String.valueOf(s2.charAt(0)).toUpperCase();
		String S3 = String.valueOf(s3.charAt(0)).toUpperCase();
		System.out.println(S1 + S2 + S3);
	}

}

Measured memory_bytes: 23124
#include<bits/stdc++.h>
using namespace std;
int gcm(int n,int m);
int main(){
  int w,h,c;
  cin>>w>>h>>c;
  cout<<h/gcm(h,w)*w/gcm(h,w)*c<<'\n';
  return 0;
}
int gcm(int n,int m){
  int x,y,r;
  x=m;
  y=n;
  // ユークリッド互除法
  while(y>0){
    r=x%y;
    x=y;
    y=r;
  }
  return x;
}



Measured memory_bytes: 3128
#include <iostream>
using namespace std;
int main(void){
    int a, b;
    cin >> a >> b ;
   if(a==b){
       cout<< "Draw" <<endl;
   }
    else if(a==1){
       cout<< "Alice" <<endl;
   }
    else if(b==1){
       cout<< "Bob" <<endl;   
   }
    else if(a>b){
       cout<< "Alice" <<endl;   
    }
    else{
        cout<< "Bob" <<endl;
    }
    
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) {
		@SuppressWarnings("resource")
		Scanner sc = new Scanner(System.in);
		while (true) {
			int x = sc.nextInt();
			int y = sc.nextInt();
			if (x == 0 && y == 0)
				break;
			if (x < y)
				System.out.println(x + " " + y);
			else
				System.out.println(y + " " + x);
		}
	}
}

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

int main() {
  long N, K;
  cin >> N >> K;
  int A[100010], B[100010];
  for (int i = 0; i < N; i++)
    cin >> A[i] >> B[i];
  
  map<int, long> mp;
  for (int i = 0; i < N; i++)
    mp[A[i]] += B[i];
  
  int ans;
  for (auto p: mp) {
    int pf = p.first;
    long ps = p.second;
    K -= ps;
    if (K <= 0) {
      ans = pf;
      break;
    }
  }
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4992
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <sstream>
#include <queue> 
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm> 
#include <numeric>  
#include <functional>
#include <cassert>
#include <bitset>
#include <cctype>  
#include <iomanip> 
#include <limits>  
#include <regex>
// std::numeric_limits<int>::max(), min()
// std::setprecision(X)
// std::islower(), std::isupper(), std::tolower, std::toupper
// std::accumulate(m.begin(), m.end(), 0LL);
// std::sort(begin(),end()) // 0, 1, 2, 3 ,4 (default, less);
// std::priority_queue<int, vector<int>, less<int>> que; // 4, 3, 2, 1 (defualt, less) : 
// if ( std::regex_match(S, std::regex("(dream|dreamer|erase|eraser)*")) ) std::cout << "YES" << std::endl;
 
#define rep(i, n) for(int i = 0; i < (int)(n);    i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
typedef std::vector<int> vi;
typedef std::vector<std::vector<int>> vvi;

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


int main (void) {
  std::cin.tie(0);  std::ios::sync_with_stdio(false);
  ll N, A, B; std::cin >> N >> A >> B;
  ll k = N / (A+B);
  ll R = N - k*(A+B);
  std::cout << k*A + std::min(R, A) << std::endl;
  return 0;
}


Measured memory_bytes: 256
"""
双対セグ木
アクセスは0-indexed, 内部のツリーは 1-indexed
つまりすべての和は tree[0]
関数は閉区間
作用素は右から作用とする

引数：
    N: 処理する区間の長さ
    compose: 作用素を合成させる関数 (max, min, __add__,ラムダ式,関数定義など)
    UNIT: 恒等作用素
    funcval(x,f) = f(x)
"""

class segment_tree:
    def __init__(self, N, compose, funcval, UNIT=None):
        self.compose = compose
        self.UNIT = UNIT
        self.funcval = funcval

        self.h = (N-1).bit_length() #木の高さ
        self.N0 = 1<<self.h #木の横幅 >= N
        self.laz = [self.UNIT]*(2*self.N0) #作用素の木
        self.val = None #値の配列

    #初期値の配列を作る
    def build(self,initial):
        self.val = initial[:]

    #laz[k] を子に伝える、
    def propagate(self,k):
        if self.laz[k] == self.UNIT: return;
        if self.N0 <= k:
            self.val[k-self.N0] = self.funcval(self.val[k-self.N0], self.laz[k])
            self.laz[k] = self.UNIT
        else:
            self.laz[(k<<1)  ] = self.compose(self.laz[(k<<1)  ],self.laz[k]);
            self.laz[(k<<1)+1] = self.compose(self.laz[(k<<1)+1],self.laz[k]);
            self.laz[k] = self.UNIT;
    
    # laz[k]およびその上に位置する作用素をすべて伝播
    def thrust(self,k):
        for i in range(self.h,-1,-1): self.propagate(k>>i)

    # 区間[l,r]に関数 f を作用
    def update(self, L,R,f):
        L += self.N0; R += self.N0+1
        """まず伝播させる（オペレータが可換なら必要ない）"""
        #self.thrust(L)
        #self.thrust(R-1)
        #登りながら関数 f を合成
        while L < R:
            if R & 1:
                R -= 1
                self.laz[R] = self.compose(self.laz[R],f)
            if L & 1:
                self.laz[L] = self.compose(self.laz[L],f)
                L += 1
            L >>= 1; R >>= 1
    
    # values[k] を取得。
    def point_get(self, k):
        res = self.val[k]
        k += self.N0
        while k:
            res = self.funcval(res, self.laz[k])
            k //= 2
        return res
    
    # values[k] = x 代入する
    def point_set(self, k): 
        self.thrust(k)
        values[k] = x



###########################################################################
#日経2020予選D

###########################################################################

# coding: utf-8
# Your code here!
 
import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline 

n,m = [int(i) for i in readline().split()]
lrc = [tuple(int(i) for i in readline().split()) for _ in range(m)]
lrc.sort()

compose = lambda f,g: min(f,g)
funcval = lambda x,f: min(x,f)
UNIT = INF = 10**18

seg = segment_tree(n, compose, funcval, UNIT)
seg.build([0]+[INF]*(n-1))

for l,r,c in lrc:
    l -= 1
    r -= 1
    v = seg.point_get(l)
    seg.update(l+1,r,v+c)

ans = seg.point_get(n-1)

if ans != INF:
    print(ans)
else:
    print(-1)





Measured memory_bytes: 78044
// In the name of God

#include <bits/stdc++.h>

using namespace std;

const int N = 1e5+5;

int c[N];

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

	int n;
	cin >> n;

	long long sum = 0;

	for(int i = 0; i < n; i++) {
		int x;
		cin >> x;
		c[x]++;
		sum += x;
	}

	int q;
	cin >> q;

	while(q--) {
		int a, b;
		cin >> a >> b;

		sum += 1ll * c[a] * (b - a);
		
		cout << sum << "\n";
		
		c[b] += c[a];
		c[a] = 0;
	}



	return 0;
}


Measured memory_bytes: 3940
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#define rep(i, n) for(i = 0; i < (n); i++)
#define chmax(x, y) x = max(x, y)
#define MOD 1000000007
#define INF 1 << 30

using namespace std;
typedef long long ll;
typedef pair<int, int> pp;

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

int main(void) {
	int num, i, m, ans = 0;
	ll lcm = 1, g;
	cin >> num >> m;
	vector<ll> d(num);
	rep(i, num) {
		cin >> d[i];
		d[i] >>= 1;
	}
	g = d[0];
	rep(i, num)
		lcm = d[i] * lcm / gcd(d[i], lcm);
	rep(i, num) {
		if ((lcm / d[i]) % 2 == 0) {
			printf("0\n");
			return 0;
		}
	}
	m /= lcm;
	ans = (m >> 1) + (m & 1);
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 1024
from collections import *
from itertools import *
from bisect import *
from heapq import *
import copy
import math
from fractions import gcd

mod=10**9+7
#N=int(input())
S=input()
#A=list(map(int,input().split()))
if "A" in S and "B" in S:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 65132
#include <bits/stdc++.h>
#define int long long
using namespace std;

signed main() {
    int N, M;
    cin >> N >> M;
    vector<int> k(M);
    vector<vector<int>> s(M);
    for (int i = 0; i < M; i++) {
        cin >> k[i];
        s[i].resize(k[i]);
        for (int& x : s[i]) {
            cin >> x;
            --x;
        }
    }
    vector<int> p(M);
    for (int& x : p) cin >> x;

    int ans = 0;
    for (int i = 0; i < (1<<N); i++) {
        vector<bool> sw(N);
        for (int j = 0; j < N; j++) {
            sw[j] = (i >> j) & 1;
        }
        int cntLight = 0;
        for (int a = 0; a < M; a++) {
            int cnt = 0;
            for (int x : s[a]) {
                cnt += sw[x];
            }
            cntLight += (cnt % 2 == p[a]);
        }
        ans += (cntLight == M);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long LL;
#define SORT(c) sort((c).begin(),(c).end())

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

using namespace std;
int main(void)
{
  int n,m;
  cin >> n >> m;
  int bac[1024]={};
  REP(i,m){
    int c,d;
    cin >> c >> d;
    bac[d-1]++;
    bac[c-1]--;
  }
  for(int i=n;i>0;--i)
    bac[i-1]+=bac[i];
  int answer=0;
  REP(i,n+1)
    if(bac[i]) answer+=3;
    else answer+=1;
  cout << answer << endl;
  
  return 0;
}

Measured memory_bytes: 3108
import sys
from collections import deque
import copy
import math
def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline



def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [N] = [int(input_raw[0])]
    p_dic ={}
    for i in range(N):
        input_raw = read_func().strip().split()
        [S, P] = [(input_raw[0]), int(input_raw[1])]
        if S not in p_dic:
            p_dic[S] = [(P, i + 1)]
        else:
            p_dic[S].append((P, i + 1))

    dct = sorted(p_dic.keys())

    for d in dct:
        p_dic[d].sort(reverse=True)
        for p in p_dic[d]:
            print p[1]




if __name__ == '__main__':
    main()


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

int main() {
  int r;
  cin >> r;
  string ans;
  if (r < 1200) {
    ans = "ABC";
  } else if (r < 2800) {
    ans = "ARC";
  } else {
    ans = "AGC";
  }
  cout << ans << endl;
  return 0;
}

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  cin >> N;
  vector<int> X(N + 1, 1);
  for (int i = 2; i < N + 1; i++) {
    for (int k = i; k < N + 1; k += i) {
      X[k]++;
    }
  }
  int64_t res = 0;
  for (int i = 1; i < N + 1; i++) {
    res += static_cast<int64_t>(i) * X[i];
  }
  cout << res << '\n';
  return 0;
}


Measured memory_bytes: 42224
#include<iostream>
 #include<stdio.h>
 #include<cstdlib>
 #include<cstdio>
 #include<string>
 #include<math.h>
 #include<time.h>
 #include<iomanip>
 #include<algorithm>
 #include<string.h>
 #include<cctype>
 #include<fstream> 
 #include<map>
 #include<set>
 #include<vector>
 #include<sstream>
 #include<stack>
 #include<queue>
 #include<deque>
 #include<functional>
 #include<utility>
 #include<list>
 #include<memory>
 
 using namespace std;
 
 
 
 int main()
 {
   string s;
   while(cin>>s)
   {
     for(int i=0;i<(s.length()-8);i++)
     {
       cout<<s[i];        
     }      
     cout<<endl;
   }
   return 0;
 }
 

        

Measured memory_bytes: 256
N, M = map(int,input().split())
freq = [True]*N
for i in range(M):
    a,b = map(int,input().split())
    a-=1
    b-=1
    if freq[a]:
        freq[a] = False
    else:
        freq[a] = True

    if freq[b]:
        freq[b] = False
    else:
        freq[b] = True

ans = all(freq)
if ans:
    print('YES')
else:
    print('NO')


Measured memory_bytes: 3828
#include <iostream>
using namespace std;
int main(){
    int D,G,p[11],c[11],min_ca=1e9;
    cin >> D >> G;
    for(int i=0; i < D; ++i){
        cin >> p[i] >>c[i];
    }

    for (int mask=0; mask < (1 << D); ++mask){
        int score=0, max_rate=-1, ca=0;
        for(int i=0; i < D; i++){
            if(mask >> i & 1){
                score += p[i]*100*(i+1) + c[i];
                ca += p[i];
            }else{
                max_rate=i;//ボーナスを取らない最大のレート
            }
        }
        if ( score < G){
            int s1 = (max_rate+1) * 100;
            int required_ca = (G-score+ s1 -1) / s1;
            if(required_ca >= p[max_rate]){
                 continue;
            } 
            ca += required_ca;
        }
        min_ca = min(min_ca,ca);
    }
    cout << min_ca << endl;

}



Measured memory_bytes: 256
from collections import defaultdict
from decimal import Decimal
N = int(input())
T = defaultdict(int)
a = 0
b = 0
for i in range(N):
    A = Decimal((input()))
    A *= 10**9
    A = int(A)
    t = 0
    f = 0
    while(True):
        if A % 2 != 0:
            break
        A = A // 2
        t += 1
    while (True):
        if A % 5 != 0:
            break
        A = A // 5
        f += 1
    T[(t, f)] += 1
    a = max(a, t)
    b = max(b, f)

ans = 0
for k, v in T.items():
    for i in range(18-k[0], a+1):
        for j in range(18-k[1], b+1):
            if (i, j) in T:
                if k[0] == i and k[1] == j:
                    ans += v * (v-1)
                else:
                    ans += v * T[(i, j)]
print(ans//2)

Measured memory_bytes: 207900
#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)

ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
}

ll factorial(ll x){
	if (x==1) return 1;
	return (x * factorial(x-1))%mod;
}

int main(){
	ll N;
	cin >> N;
	vector<ll> A(N);
	REP(i, N) cin >> A[i];
	vector<ll> P(N), S(N+1);
	S[0] = 0;
	ll factN = factorial(N);
	REP(i, N){
		S[i+1] = S[i] + (factN*modinv(i+2, mod))%mod;
	}
	REP(i, N){
		P[i] = (factN + S[i] + S[N-i-1])%mod; 
	}
	ll res = 0;
	REP(i, N){
		res += (A[i]*P[i])%mod;
		res %= mod;
	}
	cout << res << endl;
    return 0;
}

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

int main() {
    int n;
    cin >> n;
    int p[n];
    int count = 0;
    for (int i = 0; i < n; i++) cin >> p[i];
    for (int i = 1; i < n - 1; i++) {
        if (p[i] != (std::max)({p[i - 1], p[i], p[i + 1]}) && p[i] != (std::min)({p[i - 1], p[i], p[i + 1]})) count++;
    }
    cout << count << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <cmath>
#include <set>
#include <stack>
#include <queue>
#include <numeric>
#include <deque>
#include <cstring>
#include <iterator>
#include <map>
#include <cstdlib>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <complex>
#include <bitset>
#include <chrono>
#include <random>
#include <assert.h>

using namespace std;

#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define eb emplace_back
#define el '\n'
typedef  long long  ll;
typedef  unsigned long long  ull;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<pll> vpll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<string> vs;

ll inf=(ll)2e18;
const int mod=1000000007;
//const int mod=998244353;

int n,m;



int main()
{   ios_base::sync_with_stdio(false);cin.tie(NULL);
    int q,t,k,u,v;
    ll x,a,b,c,d,y,l,p;
    cin >> n;
    a=0;
    for(int i=0; i<n; i++){
        cin >> b;
        if(!(i&1)&&b&1){
            a++;
        }
    }
    cout << a << el;
    return 0;
}

Measured memory_bytes: 3636
using System;
using System.Collections.Generic;
using System.Linq;

class Skip
{
    static int Divive(List<int> based)
    {
        int divived = based[0];
        for(int i=0;i<based.Count()-1;i++)
            divived = Divive2(divived,based[i+1]);
        return divived;
    }

    static int Divive2(int a,int b)
    {
        if(a<b)
        {
            int temp = a;
            a=b;
            b=temp;
        }

        int r = a%b;
        while(r!=0)
        {
            a=b;
            b=r;
            r=a%b;
        }
        return b;
    }

    static List<int> GetDistance(List<int> list)
    {
        list.Sort();
        List<int> result=new List<int>();
        for(int i=0;i<list.Count()-1;i++)
        {
            result.Add(list[i+1]-list[i]);
        }
        result.Sort();
        return result;
    }

    static void Main()
    {
        int x =  Console.ReadLine().Split(' ').Select(z => int.Parse(z)).ToList()[1];
        List<int> points = Console.ReadLine().Split(' ').Select(z => int.Parse(z)).ToList();
        points.Add(x);
        Console.WriteLine(Divive(GetDistance(points)));
    }
}

Measured memory_bytes: 20320
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

abc = list(map(int, readline().split()))
abc.sort()

ans = abc[2]-abc[1]
res = abc[1]-abc[0]
if res % 2 == 0:
    ans += res // 2
else:
    ans += res // 2 + 2

print(ans)

Measured memory_bytes: 3064
import scala.io.StdIn._
object Main extends App {

  val n = readInt()
  val stripes = Array.tabulate(n){_ ⇒
    readLine.trim.split(' ').tail.map(_.toInt).foldLeft(Stripe.default){case (acc, c) ⇒ acc.addBorder(c)}.toReplace
  }.groupBy(_.loopLength())
  if (stripes.contains(1) || stripes.get(2).exists(_.length > 3) || stripes.get(3).exists(_.length > 2)) {
    println("yes")
  }else {
    println(
      if (stripes.toArray.flatMap(_._2).permutations.exists(a ⇒ a.tail.scan(a.head){case (acc, r) ⇒ acc + r}.exists(_.isId))) "yes" else "no"
    )
  }
  object Stripe {
    def default: Stripe = Stripe(0, 1, 2)
  }
  case class Stripe(left: Int, mid: Int, right: Int) {
    def addBorder(position: Int): Stripe = position match {
      case 0 ⇒ Stripe(mid, left ,right)
      case 1 ⇒ Stripe(left, right, mid)
      case _ ⇒ ???
    }
    def toReplace = Replace(Array(left, mid, right))
  }
  case class Replace(array: Array[Int]) {
    def loopLength(): Int = {
      val isVisit = Array.fill(array.length){false}
      var max = 0
      for (i ← array.indices if !isVisit(i)) {
        var current = i
        var count = 0
        while(!isVisit(current)){
          count += 1
          isVisit(current) = true
          current = array(current)
        }
        if (max < count) max = count
      }
      max
    }
    def +(that: Replace): Replace = Replace(that.array.map(array))
    def isId: Boolean = array.indices.forall(i ⇒ array(i) == i)
  }
}


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


def solve(D: int):
    res = "Christmas"+" Eve"*(25-D)
    print(res)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    D = int(next(tokens))  # type: int
    solve(D)

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define ALL(v) v.begin(),v.end()
#define UN(v) v.erase(unique(ALL(v)),v.end())
#define EACH(v,it) for(__typeof(v.begin()) it=v.begin();it!=v.end();it++)
#define FILL(x,y) memset(x,y,sizeof(x))
#define FIO ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<int,string> pis;
typedef vector<string> vs;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<pii> vii;
typedef unsigned int uint;
int n,m,q;
int c[100005];
int call[100005][21];
vector<int> E[100005];
/*-------The Main Code-------*/

int main(int argv,char *argc[])
{
	FIO;
	cin>>n>>m;
	for(int i=0;i<m;i++)
	{
		int x,y;
		cin>>x>>y;
		E[x].push_back(y);
		E[y].push_back(x);
	}
	cin>>q;
	for(int i=1;i<=q;i++)
	{
		int x,d;
		cin>>x>>d>>c[i];
		call[x][d]=i;
	}
	for(int i=10;i>=0;i--)
	{
		for(int x=1;x<=n;x++)
		{
			EACH(E[x],it)
			{
				call[*it][i]=max(call[*it][i],call[x][i+1]);
			}
		}
	}
	for(int x=1;x<=n;x++)
	{
		int res=0;
		for(int d=0;d<11;d++)
		{
			res=max(res,call[x][d]);
		}
		cout<<c[res]<<'\n';
	}
	return 0;
}


Measured memory_bytes: 15096
n=int(input())
a=[]
for i in range(n):
   a.append(int(input()))
b=sorted(a,reverse=True)
tempa=b[0]
tempb=b[1]
for i in range(n):
    if a[i]<tempa:
        print(tempa)
    else:
        print(tempb)

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

int main(void){
  int N;
  cin >> N;
  vector<char> S(N);
  int count = 0;
  int flag = 0;
  for(int i = 0; i < N; i++){
    cin >> S[i];
    if(S[i] == 'A') flag = 1;
    else if(flag == 1 && S[i] == 'B') flag = 2;
    else if(flag == 2 && S[i] == 'C'){
      flag = 0;
      count++;
    }
    else{
      flag = 0;
    }
  }
  cout << count << endl;
 return 0; 
}

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

int main()
{
	int n;
	cin>> n;
	int a[n];
	int m=0,minn,maxn;
	while(m<n){
		scanf("%d",&a[m++]);
	}
	minn=a[0],maxn=a[0];
	for(int i=0;i<n-1;i++){
		if(a[i]-a[i+1]>=2){
			printf("No\n");
			return 0;
		}
		else if(a[i]-a[i+1]==1){
			swap(a[i],a[i+1]);
		}
	}
	printf("Yes\n");
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <algorithm>
#include <utility> 
#include <unordered_set>
#include <vector>
#include <list> 
#include <string>
#include <iterator> 
#include <deque>
#include <array>
#include <forward_list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <climits>
#include <bitset>
#include <numeric>
using namespace std;


const long double PI = 3.14159265358979323846264338327950;
const int N = 2 * 1e5;


template <class T>
T gcd(T a, T b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}


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

	int a, b, ans;
	cin >> a >> b;
	// cout << "n:" << n << " m:" << m << '\n';
	for (int i = 1; i <= 1000000; ++i) {
		if (2 * i / 25 == a && i / 10 == b) {
			cout << i << '\n';
			return 0;
		}
	}

	cout << -1 << '\n';
}


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

namespace ConsoleApplication35
{
    class Program
    {
        static void Main()
        {
            List<decimal> f = new List<decimal>();
            while (true)
            {
                string a = Console.ReadLine();
                if (a == null) break;
                f.Add(decimal.Parse(a));
            }
            f.Sort();
            Console.WriteLine(f[f.Count-1]-f[0]);
        }
    }
}

Measured memory_bytes: 9488
N, M = map(int, input().split())
S = []
for _ in range(M):
    ks = list(map(int, input().split()))
    S.append(ks[1:])
P = list(map(int, input().split()))

ans = 0
for i in range(2**N):
    bi = str(bin(i))[2:]
    bi = bi.zfill(N)
    isAddable = True
    for j in range(M):
        s_sum = 0
        for s in S[j]:
            if bi[s-1] == '1':
                s_sum += 1
        if s_sum % 2 != P[j]:
            isAddable = False
            break
    if isAddable:
        ans += 1
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    int s, w;
    cin >> s >> w;
    if (s <= w) cout << "unsafe" << '\n';
    else cout << "safe" << '\n';
}


Measured memory_bytes: 3592
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoderAGC033
{
    class Program
    {
        public struct point
        {
            public int h, w;
            public point(int h, int w)
            {
                this.h = h;
                this.w = w;
            }
        }
        static void Main(string[] args)
        {
            var HW = Console.ReadLine().Split().Select(int.Parse).ToList();
            var Masu = new char[HW[0] + 2, HW[1] + 2];
            var qu = new Queue<point>();
            for (int i=1;i<=HW[0];++i)
            {
                var line = Console.ReadLine();
                for (int j = 1; j <= HW[1]; ++j)
                {
                    Masu[i, j] = line[j - 1];
                    if ('#' == line[j - 1])
                    {
                        qu.Enqueue(new point(i, j));
                    }
                }
            }

            Func<int, int, Queue<point>, bool> act = (int h, int w, Queue<point> q) =>
            {
                if ('.' == Masu[h, w])
                {
                    q.Enqueue(new point(h, w)); Masu[h, w] = '#';
                    return true;
                }
                return false;
            };
            
            long count = 0;
            while (true)
            {
                var cnt = qu.Count();
                var qun = new Queue<point>();
                for (int i = 0; i < cnt; ++i)
                {
                    var pt = qu.Dequeue();
                    act(pt.h, pt.w + 1, qun);
                    act(pt.h, pt.w - 1, qun);
                    act(pt.h + 1, pt.w, qun);
                    act(pt.h - 1, pt.w, qun);
                }
                if (qun.Count() <= 0)
                { break; }
                qu = qun;
                ++count;
            }

            Console.WriteLine(count);
        }
    }
}


Measured memory_bytes: 34776
#include <bits/stdc++.h>
using namespace std;
int main () {
  long N, A, B;
  cin >> N >> A >> B;
  if((B - A) % 2 == 1)cout << min(min(B - 1, N - A), min((B - A - 1) / 2 + A, (B - A - 1) / 2 + N - B + 1)) << endl;
  else cout << (B - A) / 2 << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
using VS = vector<string>;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);--(i))
#define each(i, a) for(auto &i : a)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "-----------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause")
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10;
constexpr ld pi = 3.1415926535897932;
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; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T>inline istream& operator>>(istream& is, deque<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }

int main() {
    init();

    int n; ll k; cin >> n >> k;
    VL a(n), f(n); cin >> a >> f;
    SORT(a), rSORT(f, greater<ll>());

    function<bool(ll)> check = [&](ll x)->bool {
        ll cost = 0;
        FOR(i, 0, n)cost += max(a[i] - x / f[i], 0LL);
        return cost <= k;
    };

    ll ok = LLINF, ng = -1;
    while (ok - ng > 1) {
        ll mid = ok + ng >> 1;
        if (check(mid))ok = mid;
        else ng = mid;
    }

    cout << ok << "\n";
}

Measured memory_bytes: 3328
#include <iostream>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <cstdlib>

using namespace std;
//DP用
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;
}

//a^n mod を計算する関数
long long modpow(long long a,long long n,long long mod) {
    long long res = 1;
    while(n > 0) {
        if(n % 2 == 1) {
            res = res * a % mod;
        }
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

//a^(-1) mod すなわちaの逆元を返す関数
long long modinv(long long a,long long mod) {
    return modpow(a,mod-2,mod);
}

//最大公約数をを返す関数
long long gcd (long long a,long long b) {
    if(a % b == 0) {
        return b;
    }else {
        return (gcd(b,a%b));
    }
}

const long long INF = 1LL << 60;
const long long P = 1000000007;

//nCkを求める関数
long long conbi (long long n,long long k) {
    long long res = 1;
    long long inv;
    for(long long i = n-k+1; i <= n; i++) {
        res *= i;
        res %= P;
    }
    for(long long i = 1; i <= k; i++) {
        inv = modinv(i,P);
        res *= inv;
        res %= P;
    }
    return res;
}

int main() {
    int n;
    cin >> n;
    set<int> s;
    set<int>::iterator itr;
    int num;
    for(int i = 0; i < n; i++) {
        cin >> num;
        itr = s.find(num);
        if(itr == s.end()) {
            s.insert(num);
        }else {
            s.erase(itr);
        }
    }
    cout << s.size();
    return 0;
}



Measured memory_bytes: 4992
#include <iostream>
#include <string>

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i <= (n); ++i)
typedef long long ll;

using namespace std;
int f(int x)
{
  string s = to_string(x);
  int ret = 0;
  rep(i, s.length())
  {
    ret += ((char)s[i] - '0');
  }
  return ret;
}

int main()
{
  int n, a, b;
  cin >> n >> a >> b;
  int ans = 0;
  rep1(i, n)
  {
    int ketawa = f(i);
    if(ketawa >= a && ketawa <= b) ans += i;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
const ll INF = 1LL<<60;
const ll MOD = 1e9+7;


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,W;cin>>n>>W;
    vector<int> w(n),v(n);
    rep(i,n)cin>>w[i]>>v[i];
    vector<vector<ll>> dp(n+1,vector<ll>(W+1,0));
    for(int i=1; i<=n; i++){
        dp[i]=dp[i-1];
        for(int j=w[i-1]; j<=W; j++){
            dp[i][j]=max(dp[i-1][j-w[i-1]]+v[i-1],dp[i][j]);
        }
    }
    cout<<dp[n][W];


    return 0;
}

Measured memory_bytes: 80256
#include<bits/stdc++.h>
#define X first
#define Y second
#define pb emplace_back
#define FOR(i,a,b) for(int (i)=(a);i<(b);++(i))
#define EFOR(i,a,b) for(int (i)=(a);i<=(b);++(i))
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define REP rep
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define all(X) (X).begin(),(X).end()
#define eb emplace_back

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef ll LL;
typedef pii PII;
typedef pll PLL;
const ll MOD=1e9+7;

#define rall(X) (X).rbegin(),(X).rend()
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())
#define reps(X,S,Y) for (int (X) = S;(X) < (Y);++(X))
#define rreps(X,S,Y) for (int (X) = (Y)-1;(X) >= (S);--(X))
template<class T> inline bool MX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}

int K, N;

void Out(vector<int> &seq) {
  rep(i, seq.size()) {
    if (i) cout << " ";
    cout << seq[i];
  }
  cout << "\n";
}

signed main(){
  ios_base::sync_with_stdio(false);
  cout<<fixed<<setprecision(0);

  cin >> K >> N;
  if (K%2 == 0) {
    cout << K/2;
    rep(i, N-1) cout << " " << K;
    cout << endl;
    return 0;
  }

  vector<int> seq;
  rep(i, N) {
    seq.eb((K+1)/2);
  }

  rep(i, N/2) {
    //Out(seq);
    if (seq.back() == 1) {
      seq.pop_back();
      continue;
    }

    seq.back()--;
    while (seq.size() < N) seq.eb(K);
  }
  Out(seq);
}


Measured memory_bytes: 3568
#include <iostream>

int main(void) {
	int N, K, d;
	int sunu[100];

	scanf("%d %d\n", &N, &K);

	int i = 0;
	for (; i < N; i++) {
		sunu[i] = 1;
	}

	d = 0;
	int j;
	int dTemp;
	int su;
	char kai;
	while (d < K) {
		scanf("%d\n", &dTemp);
		for (j = 0; j < dTemp; j++) {
			scanf("%d ", &su);
			//printf("%d", su);
			sunu[su-1] = 0;
		}
		//printf("\n");
		scanf("\n");
		d++;
	}

	int sum = 0;

	for (i = 0; i < N; i++) {
		sum += sunu[i];
	}
	printf("%d\n", sum);
	return 0;
}

Measured memory_bytes: 3828
import numpy as np

n,s = map(int,input().split())
a = list(map(int,input().split()))
mod = 998244353

res = 0
dp = np.zeros(s + 1, dtype = int)

for i in range(n):
    dp[0] += 1
    dp[a[i]:] += dp[:-a[i]].copy()
    dp %= mod
    res += dp[s]
    res %= mod

print(res)


Measured memory_bytes: 12424
#include <bits/stdc++.h>
using namespace std;
// type alias
typedef long long LL;
typedef pair<int,int> II;
typedef tuple<int,int,int> III;
typedef vector<int> VI;
typedef vector<string> VS;
typedef unordered_map<int,int> MAPII;
typedef unordered_set<int> SETI;
template<class T> using VV=vector<vector<T>>;
// minmax
template<class T> inline T SMIN(T& a, const T b) { return a=(a>b)?b:a; }
template<class T> inline T SMAX(T& a, const T b) { return a=(a<b)?b:a; }
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// collection
#define ALL(c) (c).begin(),(c).end()
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// stdout
#define println(args...) fprintf(stdout, ##args),putchar('\n');
// debug cerr
template<class Iter> void __kumaerrc(Iter begin, Iter end) { for(; begin!=end; ++begin) { cerr<<*begin<<','; } cerr<<endl; }
void __kumaerr(istream_iterator<string> it) { (void)it; cerr<<endl; }
template<typename T, typename... Args> void __kumaerr(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<"="<<a<<", ",__kumaerr(++it, args...); }
template<typename S, typename T> std::ostream& operator<<(std::ostream& _os, const std::pair<S,T>& _p) { return _os<<"{"<<_p.first<<','<<_p.second<<"}"; }
#define __KUMATRACE__ true
#ifdef __KUMATRACE__
#define dump(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); __kumaerr(_it, args); }
#define dumpc(ar) { cerr<<#ar<<": "; FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }
#define dumpC(beg,end) { cerr<<"~"<<#end<<": "; __kumaerrc(beg,end); }
#else
#define dump(args...)
#define dumpc(ar)
#define dumpC(beg,end)
#endif

// $ cp-batch RedOrBlue | diff RedOrBlue.out -
// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG -fsanitize=address RedOrBlue.cpp && ./a.out

/*
 
 5/9/2019
 
 19:43-
 
 */

int N;
string S;

void solve() {
  map<char,int> cnt;
  REP(i,N) cnt[S[i]]++;
  cout<<(cnt['R']>cnt['B']?"Yes":"No")<<endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout<<setprecision(12)<<fixed;
  
  cin>>N>>S;
  solve();
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
const ll M = 1e15 + 7;
int si[] = {-1, 0, 1, 0};
int sj[] = {0, -1, 0, 1};

int n, A, B, C;
vector<int> l(10,0);

ll dfs(int cur, int a, int b, int c){
  if (cur == n) {
    if (a == 0 || b == 0 || c == 0) return M;
    else return abs(a-A) + abs(b-B) + abs(c-C) - 30;
  }
  ll ret0 = dfs(cur+1, a, b, c);
  ll ret1 = dfs(cur+1, a+l[cur], b, c) + 10;
  ll ret2 = dfs(cur+1, a, b+l[cur], c) + 10;
  ll ret3 = dfs(cur+1, a, b, c+l[cur]) + 10;
  
  return min(ret0,min(ret1,min(ret2,ret3)));
}

int main() {
  cin >> n >> A >> B >> C;
  rep(i,n) cin >> l[i];
  cout << dfs(0,0,0,0) << endl;
  return 0;
}


Measured memory_bytes: 3632