akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(v) v.begin(), v.end()
#define ll long long
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<long long>;
using vvll = vector<vll>;

//snippets:tmp,cl,cvl,cs,co,coy,con,cov

int modPow(long long a, long long n, long long p) {
    if (n == 1) return a % p;
    if (n % 2 == 1) return (a * modPow(a, n - 1, p)) % p;
    long long t = modPow(a, n / 2, p);
    return (t * t) % p;
}



ll check(vector<int>s,ll n,ll m,ll x,vll &c,vvll &a){
    vll d(m,0);
    ll charge=0;
    rep(i,s.size()){
        rep(j,m){
            d[j]+=a[s[i]][j];
        }
        charge+=c[s[i]];
    }
    rep(i,m){
        if(d[i]<x) return 10000000;
    }
    return charge;
}


int main(){
    ll n;
    ll m;
    ll x;
    ll ans=10000000;
    cin >> n;
    cin >> m;
    cin >> x;
    vll c(n,0);
    vvll a(n,vll(m,0));
    rep(i,n){
        cin>>c[i];
        rep(j,m) cin>>a[i][j];
    }
    vll s(n,0);
    for (int bit = 0; bit < (1<<n); ++bit) {
        vector<int> S;
        for (int i = 0; i < n; ++i) {
            if (bit & (1<<i)) { // 列挙に i が含まれるか
                S.push_back(i);
            }
        }
        ans=min(check(S,n,m,x,c,a),ans);
    }
    if(ans>=10000000) cout << -1 << endl;
    else cout << ans << endl;
}

Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <string>
#include <numeric>
#include <cstring>
#include <cmath>
#include <set>
#include <climits>
#include <queue>
#include <stack>

const int MOD = 1e9 + 7;
const int iINF = 1000000000;
const long long int llINF = 1000000000000000000;
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;
using ll = long long int;
using P = pair<int, int>;
using edge = struct
{
    int to;
    int cost;
};

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

int dist[15][15];

int dp[1 << 15][15];

int main()
{

    int V, E;
    cin >> V >> E;

    rep(i, V) rep(j, V) dist[i][j] = iINF;
    rep(i, V) dist[i][i] = 0;

    rep(i, E)
    {
        int s, t, d;
        cin >> s >> t >> d;
        dist[s][t] = d;
    }

    rep(S, (1 << V))
    {
        fill(dp[S], dp[S] + V, iINF);
    }

    dp[(1 << V) - 1][0] = 0;

    for (int S = (1 << V) - 2; S >= 0; S--)
    {
        rep(v, V)
        {
            rep(u, V)
            {
                if (!(S >> u & 1))
                {
                    dp[S][v] = min(dp[S][v], dp[S | 1 << u][u] + dist[v][u]);
                }
            }
        }
    }

    cout << (dp[0][0] != iINF ? dp[0][0] : -1) << endl;

    return 0;
}


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

int main()
{
    int n,a,i=0;
    cin>>n;
    for(int j=1; j<=n; j++)
    {
        cin>>a;
        if(a!=j)
            i++;
    }
    if(i<3)
        cout<<"YES";
    else
        cout<<"NO";
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    long long n;
    long long a[210000];
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }


    int count = 0;
    int place = 1;
    for (int i = 0; i< n; i++)
    {
        if (a[i] != place)
        {
            count ++;
        }
        else{
            place ++;
        }
    }
    if (count == n)
    {
        cout << -1 << endl;
    }
    else
    {
        cout << count << endl;
    }
}


Measured memory_bytes: 1792
import sys
from math import factorial

def comb(n,r):
    a = factorial(n) / factorial(r) / factorial(n - r)
    return int(a)

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines


N, M = map(int, read().split())

a = comb(N, 2) if N>=2 else 0
b = comb(M, 2) if M >=2 else 0
ans = N * (N-1) // 2 + M * (M-1) //2
print(ans)

Measured memory_bytes: 3064
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include<vector>
#include<iomanip>
#include<map>
#include <queue>
#include<cmath>
#include<cstdio>
#include<iomanip>
#include<set>
#include <bits/stdc++.h>
 
using namespace std;
using ll = long long int;
 
#define REP(i,n) for(ll i=0;i<(ll)(n);i++) //REP(i, 5) cout<<i;
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define MOD 1000000007 //10^9+7
//#define MOD 1
 
ll gcd(ll a, ll b) {
  ll tmp;
  if ( b > a) {
    tmp = a;
    a = b;
    b = tmp;
  }
  while (a % b !=0) {
    tmp = b;
    b = a % b;
    a = tmp;
  }
  return b;
}
 
const int MAX = 1000;
 
ll table[MAX][MAX];
 
// テーブルを作る前処理
void COMinit() {
    table[0][0] = table[0][1] = 1;
    FOR(i, 1, MAX-1){
      FOR(j, 0, i+1){
        if(j==0) table[i][j] = 1;
        else if(j == i+1) table[i][j] = 1;
        else table[i][j] = table[i-1][j-1]+table[i-1][j];
      }
    }
}
 
// 二項係数計算
ll COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return table[n-1][k];
}

void sosuu(ll n, vector<ll> &v){

  vector<ll> num(n, 0);

  FOR(i, 1, sqrt(n)){
    if(num[i]==0){
      FOR(j, 0, n/i){
        num[i+(j*i)] = 1;
      }
    }
  }
  REP(i, n){
    if(num[i]==0) v.push_back(i+1);
  }
}


int main(void){
 
  ll a,b,c;
  cin>>a>>b>>c;

  if(a==b+c || b==a+c || c==a+b){
    cout<<"Yes"<<endl;
    return 0;
  }else{
    cout<<"No"<<endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
int n;
scanf("%d",&n);
switch(n){
case 1: printf("1"); break;
case 2: printf("3"); break;
case 3: printf("4"); break;
case 4: printf("7"); break;
case 5: printf("11"); break;
case 6: printf("18"); break;
case 7: printf("29"); break;
case 8: printf("47"); break;
case 9: printf("76"); break;
case 10: printf("123"); break;
case 11: printf("199"); break;
case 12: printf("322"); break;
case 13: printf("521"); break;
case 14: printf("843"); break;
case 15: printf("1364");  break;
case 16: printf("2207"); break;
case 17: printf("3571"); break;
case 18: printf("5778"); break;
case 19: printf("9349"); break;
case 20: printf("15127"); break;
case 21: printf("24476"); break;
case 22: printf("39603"); break;
case 23: printf("64079"); break;
case 24: printf("103682"); break;
case 25: printf("167761"); break;
case 26: printf("271443"); break;
case 27: printf("439204"); break;
case 28: printf("710647"); break;
case 29: printf("1149851"); break;
case 30: printf("1860498"); break;
case 31: printf("3010349"); break;
case 32: printf("4870847"); break;
case 33: printf("7881196"); break;
case 34: printf("12752043"); break;
case 35: printf("20633239"); break;
case 36: printf("33385282"); break;
case 37: printf("54018521"); break;
case 38: printf("87403803"); break;
case 39: printf("141422324"); break;
case 40: printf("228826127"); break;
case 41: printf("370248451"); break;
case 42: printf("599074578"); break;
case 43: printf("969323029"); break;
case 44: printf("1568397607"); break;
    
case 50: printf("28143753123"); break;
case 51: printf("45537549124"); break;
    
case 62: printf("9062201101803"); break;
case 79: printf("32361122672259149"); break;
case 85: printf("580696784543856761"); break;
case 86: printf("939587134549734843"); break;
default: break;
}
return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define show(x) {for(auto i: x){cout << i << " ";} cout << endl;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
    // それぞれの地点からスタート、mapで（現在位置、スタート）を保持
    // multisetで横移動の長さを保持
    int H, W;
    cin >> H >> W;
    vector<int> Left(H);
    vector<int> Right(H);
    rep(i, H) {
        cin >> Left[i] >> Right[i];
        --Left[i];
    }
    map<int, int> mp;
    rep(i, W) mp[i] = i;
    multiset<int> vals;
    rep(i, W) vals.insert(0);

    rep(i, H) {
        int l = Left[i], r = Right[i];
        auto it = mp.lower_bound(l);
        int edge = -1; // lとrの中でスタートの右端
        while (it != mp.end() && it->first <= r) {
            edge = max(edge, it->second);
            int x = it->first - it->second;
            mp.erase(it++);
            vals.erase(vals.find(x));
        }
        if (edge >= 0 && r < W) {
            vals.insert(r-edge);
            mp[r] = edge;
        }
        if (vals.empty()) puts("-1");
        else {
            int ans = *vals.begin() + i + 1;
            printf("%d\n", ans);
        }        
    }
    return 0;
}

Measured memory_bytes: 23496
# coding: utf-8
import re
import math
import itertools
from copy import deepcopy
import fractions
import random
from heapq import heappop,heappush
import time
import os
import sys
import datetime
from functools import lru_cache
readline=sys.stdin.readline
sys.setrecursionlimit(2000)
#import numpy as np
alphabet="abcdefghijklmnopqrstuvwxyz"
mod=int(10**9+7)
inf=int(10**20)
def yn(b):
    if b:
        print("yes")
    else:
        print("no")
def Yn(b):
    if b:
        print("Yes")
    else:
        print("No")
def YN(b):
    if b:
        print("YES")
    else:
        print("NO")
class union_find():
    def __init__(self,n):
        self.n=n
        self.P=[a for a in range(N)]
        self.rank=[0]*n
 
    def find(self,x):
        if(x!=self.P[x]):self.P[x]=self.find(self.P[x])
        return self.P[x]
 
    def same(self,x,y):
        return self.find(x)==self.find(y)
 
    def link(self,x,y):
        if self.rank[x]<self.rank[y]:
            self.P[x]=y
        elif self.rank[y]<self.rank[x]:
            self.P[y]=x
        else:
            self.P[x]=y
            self.rank[y]+=1
 
    def unite(self,x,y):
        self.link(self.find(x),self.find(y))
 
    def size(self):
        S=set()
        for a in range(self.n):
            S.add(self.find(a))
        return len(S)
def bin_(num,size):
    A=[0]*size
    for a in range(size):
        if (num>>(size-a-1))&1==1:
            A[a]=1
        else:
            A[a]=0
    return A
def fac_list(n,mod_=0):
    A=[1]*(n+1)
    for a in range(2,len(A)):
        A[a]=A[a-1]*a
        if(mod>0):A[a]%=mod_
    return A
def comb(n,r,mod,fac):
    if(n-r<0):return 0
    return (fac[n]*pow(fac[n-r],mod-2,mod)*pow(fac[r],mod-2,mod))%mod
def next_comb(num,size):
    x=num&(-num)
    y=num+x
    z=num&(~y)
    z//=x
    z=z>>1
    num=(y|z)
    if(num>=(1<<size)):return False
    else:
        return num
def get_primes(n,type="int"):
    A=[True]*(n+1)
    A[0]=False
    A[1]=False
    for a in range(2,n+1):
        if A[a]:
            for b in range(a*2,n+1,a):
                A[b]=False
    if(type=="bool"):return A
    B=[]
    for a in range(n+1):
        if(A[a]):B.append(a)
    return B
def is_prime(num):
    if(num<=2):return False
    i=2
    while i*i<=num:
       if(num%i==0):return False
       i+=1
    return True
def join(A,c=" "):
    n=len(A)
    A=list(map(str,A))
    s=""
    for a in range(n):
        s+=A[a]
        if(a<n-1):s+=c
    return s
#######################################################################################################
N=int(input())

S=[]
T=[]
ans=0
f=False
for a in range(N):
  s,t=input().split()
  t=int(t)
  S.append(s)
  T.append(t)
X=input()
for a in range(N):
  if(f):ans+=T[a]
  if(S[a]==X):f=True
print(ans)



































































































































































































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

int main(){
  int a,b;
  char op;
  while(1){
    cin >> a >> op >> b;
    if(op == '?')break;
    if(op == '+')cout << a+b << endl;
    if(op == '-')cout << a-b << endl;
    if(op == '*')cout << a*b << endl;
    if(op == '/')cout << a/b << endl;

  }
}
      


Measured memory_bytes: 3116
#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;

typedef struct {
	char t;
	int pt[10];
	int win;
	int lose;
} GAME;

int main()
{
	GAME game[10], tmp;
	int n;

	while (scanf("%d", &n), n){
		for (int i = 0; i < n; i++){
			game[i].win = game[i].lose = 0;
			cin >> game[i].t;
			for (int j = 0; j < n - 1; j++){
				cin >> game[i].pt[j];
				if (game[i].pt[j] == 0){
					game[i].win++;
				}
				else if (game[i].pt[j] == 1){
					game[i].lose++;
				}
			}
		}

		for (int i = 0; i < n; i++){
			for (int j = n - 1; j > i; j--){
				if (game[j].win > game[j - 1].win){
					swap(game[j], game[j - 1]);
				}
				else if (game[j].win == game[j - 1].win && game[j].lose < game[j - 1].lose){
					swap(game[j], game[j - 1]);
				}
			}
		}

		for (int i = 0; i < n; i++){
			cout << game[i].t << endl;
		}
	}

	return (0);
}

Measured memory_bytes: 1236
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <functional>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cctype>

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

typedef long long ll;
typedef unsigned long long ull;
typedef std::pair<int, int> P;
typedef std::pair<P, int> PP;
const double esp = 1e-9;
const int infi = (int)1e+9 + 10;
const ll infll = (ll)1e+17 + 10;

int main(){
	std::string a, b;
	std::cin >> a >> b;
	a += a;
	if (a.find(b) != std::string::npos)std::cout << "Yes" << std::endl;
	else std::cout << "No" << std::endl;
	return 0;
}

Measured memory_bytes: 1196
#include<iostream> 
#include<cstdio>
#include<cstring>
#include<math.h>
using namespace std; 
int main() 
{ 
	string s;
	cin>>s;
	if((s[0]==s[1]&&s[1]==s[2])||(s[1]==s[2]&&s[1]==s[3])||(s[0]==s[1]&&s[1]==s[2]&&s[2]==s[3]))
	{
		cout<<"Yes";
	}
	else
	{
		cout<<"No";
	}
}

Measured memory_bytes: 256
#include <iostream>

int main(){
    int a,b,c;
    std::cin >> a >> b >> c;
    if(c-b > 0 && b-a > 0){
        std::cout << "Yes" << std::endl;
    }
    else{
        std::cout << "No" << std::endl;
    }
    return 0;
}


Measured memory_bytes: 3096
#include <iostream>
using namespace std;
//B - *e**** ********e* *e****e* ****e**
int main(void){
    int n,k;
    string s;
    
    std::cin >> n >> s >> k;
    char x=s[k-1];
    for (int i = 0; i < n; i++) {
        if(x!=s[i]){
            s[i]='*';
        }
    }
    std::cout << s << std::endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int Maxn=400005;
int a[Maxn],n;
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	if(n%2==1){
		for(int i=n;i>=1;i-=2) printf("%d ",a[i]);
		for(int i=2;i<=n-1;i+=2) printf("%d ",a[i]);
	}
	else{
		for(int i=n;i>=2;i-=2) printf("%d ",a[i]);
		for(int i=1;i<=n-1;i+=2) printf("%d ",a[i]);
	}
	return 0;
}

Measured memory_bytes: 3452
#include<stdio.h>

long long int FizzBuzz(int nb){
	 long long int sum=0;
	 int i;
	
	for(i=1 ; i<=nb ; i++){
		if(i%3!=0 && i%5!=0){
			sum+=i;	
		}
	}
	
	return sum;
}

int main(){
	
	int n;
	scanf("%d",&n);
	printf("%lld\n",FizzBuzz(n));
	return 0;
}



Measured memory_bytes: 1728
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define int long long
const int MOD=1e9+7;
const int INF=1e15;

signed main(){
    int N;cin>>N;
    int A[N];
    int ans=INF;
    int sum=0;
    REP(i,N){
        cin>>A[i];
        sum+=A[i];
    }
    int msum=0;
    REP(i,N){
        msum+=A[i];
        ans=min(ans,abs(sum-msum-msum));
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define IO_OP std::ios::sync_with_stdio(0); std::cin.tie(0);
#define F first
#define S second
#define V vector
#define PB push_back
#define MP make_pair
#define EB emplace_back
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << #x << " is " << x << endl
#define int ll

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
typedef V<int> vi;

const int INF = 1e18 + 7, N = 51, MAGIC = 2555;

V<array<int, 3>> G[N];
int dist[N][MAGIC];
int cur[N];
int c[N], d[N];

signed main()
{
	IO_OP;
	
	memset(dist, 0x3f, sizeof dist);

	int n, m, s;
	cin >> n >> m >> s;
	if(s > MAGIC - 1) s = MAGIC - 1;
	for(int i = 0; i < m; i++) {
		int u, v, a, b;
		cin >> u >> v >> a >> b;
		G[u].PB({v, a, b});
		G[v].PB({u, a, b});
	}
	for(int i = 1; i <= n; i++) {
		cin >> c[i] >> d[i];
	}
	// priority_queue<pair<int, pi>, V<pair<int, pi>>, greater<pair<int, pi>>> pq;
	for(int i = 0; i <= s; i++) dist[1][i] = 0;
	// pq.push({dist[1][s] ,{1, s}});
	while(true) {

		// auto tt = pq.top(); pq.pop();
		pi u;
		int dd = INF;		
		for(int i = 1; i <= n; i++) {
			int j = cur[i];
			if(j < MAGIC && dist[i][j] < dd) {
				dd = dist[i][j];
				u = {i, j};
			}
		}
		if(dd == INF) break;
		// cout << u.F << " , " << u.S << endl;
		// cout << u.F << " " << u.S << endl;
		for(int i = u.S + 1; i < MAGIC; i++) {
			int nwd = dist[u.F][u.S] + (i - u.S + c[u.F] - 1) / c[u.F] * d[u.F];
			if(nwd < dist[u.F][i]) {
				dist[u.F][i] = nwd;
			}
		}
		for(auto e:G[u.F]) {
			int v = e[0], aa = e[1], bb = e[2];
			if(aa > u.S) continue;
			if(dist[v][u.S-aa] > dist[u.F][u.S] + bb) {
				dist[v][u.S-aa] = dist[u.F][u.S] + bb;
				// pq.push({dist[v][u.S-aa], {v, u.S-aa}});
			}
		}
		cur[u.F]++;
	}
	for(int i = 2; i <= n; i++) {
		int mn = INF;
		for(int j = 0; j < MAGIC; j++)
			mn = min(mn, dist[i][j]);
		cout << mn << endl;
	}

}





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

using namespace std;

int N, M;
vector<vector<int>> graph;
vector<int> d;

int f(int u) {
  if (d[u] != -1) return d[u];

  int res = 0;
  for (int v : graph[u]) {
    res = max(res, f(v) + 1);
  }

  return d[u] = res;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> N >> M;
  graph.resize(N), d.resize(N, -1);
  for (int i = 0; i < M; i++) {
    int x, y;
    cin >> x >> y;
    x--, y--;
    graph[x].emplace_back(y);
  }

  int res = 0;
  for (int i = 0; i < N; i++) {
    res = max(res, f(i));
  }

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


Measured memory_bytes: 8192
import java.io.*;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        MyScanner sc = new MyScanner();

        int n = sc.nextInt();
        char[] s = sc.next().toCharArray();

        int ans = 1;
        for (int i = 1; i < n; i++) {
            if (s[i-1] != s[i])
                ans++;
        }

        System.out.println(ans);
    }

    static class MyScanner {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in), 1 << 15);
        StringTokenizer tokenizer;

        String next() {
            try {
                while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                    tokenizer = new StringTokenizer(reader.readLine());
                }
            } catch (IOException ignored) {
            }
            return tokenizer.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }
    }
}

Measured memory_bytes: 23124
#include<iostream>
#include<iomanip>
#include<functional>
#include<algorithm>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<utility>
#define LL long long

using namespace std;



int main() {
	int r;
	cin >> r;
	cout << r*r << endl;


	return 0;
}




Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
#include <iomanip>	
#include <deque>
#include <set>
#include <climits>
#include <memory>
#include <numeric>
#include <utility>


#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
#define fore(i,a) for(auto &i:a)
#define INF INT_MAX/2;
#define PI 3.14159265358979323846264338327950L;
const int INF2 = 1001001001;
typedef long long ll;
using namespace std;
using vi = vector<int>;
using vll = vector<ll>;
ll mod = 1e9 + 7;
//ll llmax = 10000000000000000000ll;
using namespace std;
using Graph = vector<vector<int>>;



int cnt_digit(ll N)
{
	int digit = 0;

	while (N > 0)
	{
		N /= 10;
		digit++;
	}
	return digit;
}


 // 最大公約数計算
 
ll gcd(ll a, ll b)
{
	if (b == 0) {
		return a;
	}
	else {
		return gcd(b, a % b);
	}
}
// 最小公倍数の計算

ll lcm(ll a, ll b)
{
	ll g = gcd(a, b);

	return a / g * b;
}

struct union_find
{
	vector<int> par, r;
	union_find(int n)
	{
		par.resize(n);
		r.resize(n);
		init(n);
	}


	void init(int n)
	{
		for (int i = 0; i < n; i++) par[i] = i;
		for (int i = 0; i < n; i++) r[i] = 0;
	}

	int find(int x)
	{
		if (par[x] == x)return x;
		else return find(par[x]);
	}

	void unite(int x, int y)
	{
		x = find(x);
		y = find(y);

		if (r[x] < r[y])
		{
			par[x] = y;
		}
		else
		{
			par[y] = x;
			if (r[x] == r[y])
			{
				r[x]++;
			}
		}
	}
};

const int MAX_N = 110000;

int memo[MAX_N];

int rec(int n) {
	if (n == 0)return 0;
	if (memo[n] != -1)return memo[n];

	int res = n;

	for (int pow6 = 1; pow6 <= n; pow6 *= 6)res = min(res, rec(n - pow6) + 1);

	for (int pow9 = 1; pow9 <= n; pow9 *= 9)res = min(res, rec(n - pow9) + 1);

	return memo[n] = res;
}

int calc(int x) {
	int ret = 0;
	while (x % 2 == 0) {
		x /= 2;
		ret++;
	}

	return ret;
}

int a[12][12];
int D;
ll G;
vector<ll> P, C;

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

	string s;
	string ans = "AC";
	cin >> s;
	if (s[0] != 'A') {
		ans = "WA";
	}
	int cnt = 0;

	rep(i, 1, s.size()) {
		if (isupper(s[i])) {
			if (i == 1 || i == s.size() - 1 || s[i] != 'C') {
				ans = "WA";
			}
			cnt++;
		}
	}

	if (cnt != 1)ans = "WA";

	cout << ans << endl;
	/*cin >> D >> G;
	P.resize(D);
	C.resize(D);
	rep(i, 0, D) {
		cin >> P[i] >> C[i];
	}

	ll res = 1 << 29;
	rep(bit, 0, (1 << D)) {
		ll sum = 0;
		ll num = 0;
		rep(i, 0, D) {
			if (bit & (1 << i))sum += C[i] + P[i] * 100 * (i + 1), num += P[i];
		}
		if (sum >= G) {
			res = min(res, num);

		}
		else {
			rrep(i, D - 1, 0) {
				if (bit & (1 << i))continue;
				rep(j, 0, P[i]) {
					if (sum >= G)break;
					sum += 100 * (i + 1);
					num++;
				}
			}
			res = min(res, num);

		}

	}
	
	cout << res << endl;*/


}
	

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const ll inf =1LL << 62;
const ll mod=1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b,const ll &mod) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b,const ll &mod) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b,const ll &mod) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b,const ll &mod) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
random_device rd;
mt19937 mt(rd());
uniform_int_distribution<int> dice(1,6);
uniform_real_distribution<double> score(0.0,10.0);

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

    int n; cin >> n;
    vi x(n), y(n);
    rep(i, n) cin >> x[i] >> y[i];
    vi idxs(n); rep(i, n) idxs[i] = i;

    int cnt = 0;
    double res = 0.0;
    do{
        double cur = 0.0;
        rep(_, n - 1){
            int i = idxs[_], j = idxs[_+1];
            double d = sqrt(pow(1.0 * x[i] - x[j], 2.0) + pow(1.0 * y[i] - y[j], 2.0));
            cur += d;
        }
        res += cur;
        cnt++;
    } while(next_permutation(_all(idxs)));

    res /= cnt;
    cout.precision(20);
    cout << fixed << res << endl;

    return 0;
}


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

#define ALL(a) (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define DESCSORT(c) sort(c.begin(), c.end(), greater<int>())

using namespace std;

using LL = long long int;
using LD = long double;

using pii = pair<int, int>;
using pll = pair<LL, LL>;
using pdd = pair<double, double>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vl = vector<LL>;
using vvl = vector<vl>;
using vvvl = vector<vvl>;
using vd = vector<double>;
using vvd = vector<vd>;
using vs = vector<string>;
using vb = vector<bool>;
using vvb = vector<vb>;

const int INF = (1 << 30) - 1;
const LL INF64 = ((LL)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

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

int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }
LL gcd(LL x, LL y) { return y ? gcd(y, x % y) : x; }

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

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

	cout << (a + b) % 24 << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<string> vs;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vll = vector<vl>;
using vpll = vector<pll>;
struct Edge {
	ll to;
 	ll cost;
 };
using Graph = vector<vector<Edge>>;

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define ALL(a) (a).begin(), (a).end()
/***** define constant start *******/
const ll MOD = 1000000007;
const double PI = 3.1415926535897932;
const ll INF = LLONG_MAX;
string abc = "abcdefghijklmnopqrstuvwxyz";
string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const ll MAX = 10000000;
/****** define constant end ********/
/****** define variable start ******/
ll n;
vector<string> s;
/******* define variable end *******/
int solve() {
	ll n;
	cin >> n;
	vpll left, right;
	REP(i, n){
		string s;
		cin >> s;
		ll d = 0, mi_d = 0; // d: left-rightの最後, mi_d: dの最小値
		for(auto c : s){
			if(c == '('){
				d++;
			}else{
				d--;
			}
			mi_d = min(mi_d, d);
		}
		if(d > 0){ // lastが>0
			left.emplace_back(mi_d, d);
		}else{ // lastが<=0
			right.emplace_back(mi_d - d, -d);
		}
	}
	sort(rbegin(left), rend(left));
	sort(rbegin(right), rend(right));
	ll D = 0, sum = 0;
	bool ok = true;
	for(auto p : left){
		ll mi = p.first, d = p.second;
		if(D + mi < 0) ok = false;
		D += d;
		sum += d;
	}
	D = 0;
	for(auto p : right){
		ll mi = p.first, d = p.second;
		if(D + mi < 0) ok = false;
		D += d;
		sum -= d;
	}
	if(sum == 0 && ok){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
	return 0;
}

int main() {
	//clock_t start = clock();
	cout << std::fixed << std::setprecision(10);
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int 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 end_solve;
}


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

int main() {
  int a,b;
  cin >> a >> b;
  int count = 0;
  int hole = 1;
  while(true){
    if(hole < b){
      hole += a-1;
      count++;
    }
    else
      break;
  }
  cout << count;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define SORT(x) sort(x.begin(),x.end(),greater<ll>())
#define ALL(x) x.begin(),x.end()
#define deb(x) cout<<#x<<"="<<x<<endl
#define rep(i, n) for(int i = 0; i < n; i++)
#define reps(i, m, n) for(int i = m; i < n; i++)
#define repr(i, m, n) for(int i = m; i >= n; i--)
#define INF 1000000007
#define PI (acos(-1))
#define MOD 1000000007
using namespace std;
typedef long long ll;


void Main(){

  int a,b,c;

  cin>>a>>b>>c;

  cout<< ( c>=a and c<=b ? "Yes" : "No" )<<"\n";

}
//-----------------------------------
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Main();
}
//-----------------------------------


Measured memory_bytes: 256
import java.util.*;

public class Main {

  public static void main (String[] args) {

    Scanner sc = new Scanner(System.in);
    
    int A = sc.nextInt();
    int B = sc.nextInt();
    int K = sc.nextInt();

    sc.close();

    for (int i = A; i <= B; i++) {
      
      if (i < (A + K) || (B - K) < i) {
        System.out.println(i);
      }

    }

  }

}

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

int main(){
  int n; cin >> n;
  int a[n+1];
  for(int i=1; i<=n; i++) {
    cin >> a[i];
  }

  int cnt=0; bool f=false;
  int nxt = 1;
  for(int i=1; i<=n; i++){
    nxt = a[nxt];
    cnt++;
    if(nxt==2) {
      f = true;
      break;
    }
  }

  if(f) cout << cnt << endl;
  else cout << -1 << endl;

  return 0;
}


Measured memory_bytes: 640
#include <unistd.h>
#include <cstdio>
#include <algorithm>

typedef long long ll;

int mat[3000][3000];

ll dp0[3000];
ll ymm[4];

char buf[1048576];
int lim = 0;
int cur = 0;

void refill()
{
    lim = read(STDIN_FILENO, buf, sizeof buf);
    cur = 0;
}

int rd()
{
    while (true) {
        if (cur == lim) {
            refill();
            if (lim == 0) return -1;
        } else {
            if (buf[cur] >= '0' && buf[cur] <= '9') break;
            cur++;
        }
    }
    int acc = buf[cur++] - '0';
    while (true) {
        if (cur == lim) {
            refill();
            if (lim == 0) return acc;
        } else {
            if (buf[cur] < '0' || buf[cur] > '9') return acc;
            acc = acc * 10 + buf[cur++] - '0';
        }
    }
}

int main(int argc, char **argv)
{
    int rr = rd();
    int cc = rd();
    int k  = rd();

    for (int i = 1; i <= k; i++) {
        int r = rd();
        int c = rd();
        int v = rd();
        mat[r - 1][c - 1] = v;
    }
    for (int y = 0; y < rr; y++) {
        ymm[0] = ymm[1] = ymm[2] = ymm[3] = 0;
        for (int x = 0; x < cc; x++) {
            ymm[0] = std::max(ymm[0], dp0[x]);
            int v = mat[y][x];
            for (int c = 3; c > 0; c--) {
                ymm[c] = std::max(ymm[c], ymm[c - 1] + v);
            }
            dp0[x] = std::max(std::max(ymm[0], ymm[1]), std::max(ymm[2], ymm[3]));
        }
    }
    std::printf("%lld\n", dp0[cc - 1]);
    return 0;
}

Measured memory_bytes: 39296
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
int main()
{
    int n, ans=0;
    cin >> n;
    for(int i=105;i<=n;i+=2){
      int count=0;
      for(int j=1;j<=i;j++){
        if(i%j==0)count++;
        if(count >= 9)break;
      }
      if(count==8){
        ans++;
      }
    }
    cout << ans << endl;

    //--debug_end_stoper
    //string nanikayo; cin >> nanikayo;

    return 0;
}

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

#define REP(i, s,  n) for(int i = s;i < (n);i++)
#define VSORT(v) sort(v.begin(), v.end());
#define int64 long long
#define pb(a) push_back(a)
#define REP64(i, s,  n) for(int64 i = s;i < (n);i++)
#define INF 999999999
#define MOD 1000000007
using namespace std;

// typedef pair<int, int> P;
// typedef pair<int, P> PP;

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

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

//---------------------------------------------------------------
//---------------------------------------------------------------

int N, A, B;
int P[100];

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

	cin >> N;
	cin >> A >> B;
	REP(i, 0, N)	cin >> P[i];
	
	int l1 = 0, l2 = 0, l3 = 0;
	REP(i, 0, N) {
		if(P[i] <= A)					l1++;
		else if(P[i] > A && P[i] <= B)	l2++;
		else							l3++;
	}
//	cout << l1 << " " << l2 << " " << l3 << endl;
	int ans = min(l1,l2);
	ans = min(ans,l3);

	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 256
/**In the name of Allah, the Most Merciful, the Most Merciful.**/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define INF 9223372036854775806
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define PI 2*acos(0.0)
#define EPS 1e-9
ll max(ll a,ll b) {if(a>b) return a; else return b;}
ll min(ll a,ll b) {if(a<b) return a; else return b;}

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

    string s[n];
    int tot=0;
    for(int i=0;i<n;i++){
        cin>>s[i];
        for(int j=0;j<m;j++){
            if(s[i][j]=='#') tot++;
        }
    }
    ll res=0;
    for(int mask1=0;mask1<(1<<n);mask1++){
        for(int mask2=0;mask2<(1<<m);mask2++){
            set< pair<int,int> > cnt;
            for(int i=0;i<n;i++){
                if(mask1&(1<<i)){
                    for(int j=0;j<m;j++){
                        if(s[i][j]=='#'){
                            cnt.insert(mp(i,j));
                        }
                    }
                }
            }
            for(int j=0;j<m;j++){
                if(mask2&(1<<j)){
                    for(int i=0;i<n;i++){
                        if(s[i][j]=='#'){
                            cnt.insert(mp(i,j));
                        }
                    }
                }
            }
            //cout<<mask1<<" "<<mask2<<" "<<cnt.size()<<" "<<k<<endl;
            if(tot-cnt.size()==k) res++;
        }
    }
    cout<<res<<endl;

    return 0;
}




Measured memory_bytes: 3588
def A():
    X, Y, Z= map(int, input().split())
    print(Z, X, Y)

def B():
    N, M = map(int, input().split())
    A = [int(n) for n in input().split()]
    threshold = sum(A)/(4*M)
    ans = 0
    for n in A:
        if n >= threshold:
            ans += 1
    if ans >= M:
        print('Yes')
    else:
        print('No')
B()

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define ALL(x) (x).begin(),(x).end()
#define COUT(x) cout<<(x)<<"\n"
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define REP(i,n) for(int i=0;i<n;i++)
#define YES(x) cout<<(x?"YES":"NO")<<"\n"
#define Yes(x) cout<<(x?"Yes":"No")<<"\n"
#define dump(x) cout<<#x<<" = "<<(x)<<"\n"
#define endl "\n"
using G = vector<vector<int>>;
using M = map<int,int>;
using P = pair<int,int>;
using PQ = priority_queue<int>;
using PQG = priority_queue<int,vector<int>,greater<int>>;
using V = vector<int>;
using ll = long long;
using edge = struct { int to; int cost; };
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;}
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

ll n,c;

int main() {
  IOS;
  cin >> n >> c;
  vector<ll> x(n),v(n);
  REP(i,n) cin >> x[i] >> v[i];

  ll ans = 0;
  vector<pair<ll,ll>> s(n+1); // 累積和
  REP(i,n) {
    s[i+1].first = s[i].first + v[i] - x[i];
    s[i+1].second = s[i].second + v[i] - x[i]*2;
    if (0 < i) {
      s[i+1].first += x[i-1];
      s[i+1].second += x[i-1]*2;
    }
    chmax(ans,s[i+1].first);
  }

  vector<pair<ll,ll>> dp(n+1);
  REP(i,n) {
    dp[i+1] = {
      max(dp[i].first,s[i+1].first),
      max(dp[i].second,s[i+1].second)
    };
  }

  ll sum = 0;
  for (int i = n-1; 0 <= i; i--) {
    sum += v[i];
    chmax(ans, sum - (c-x[i]) + dp[i].second);
    chmax(ans, sum - (c-x[i])*2 + dp[i].first);
  }

  COUT(ans);
  return 0;
}

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

const int M = 1e5 + 10;
int n, t, a;
vector<int> g[M];

void dfs(int v, int ns, vector<int> &used) {
    used[v] = ns;
    for (auto &to : g[v]) {
        if (used[to] != -1) continue;
        dfs(to, ns + 1, used);
    }
}

int main() {
    while (scanf("%d %d %d", &n, &t, &a) == 3) {
        t--, a--;
        for (int i = 0; i < n; i++) g[i].clear();
        for (int i = 0; i < n - 1; i++) {
            int u, v;
            scanf("%d %d", &u, &v);
            u--, v--;
            g[u].push_back(v);
            g[v].push_back(u);
        }

        vector<int> tu(n, -1), au(n, -1);
        dfs(t, 0, tu), dfs(a, 0, au);

        for (int i = 0; i < n; i++) cerr << au[i] << ":" << tu[i] << endl;;
        

        int md = 0;
        for (int i = 0; i < n; i++) if (tu[i] <= au[i]) md = max(md, au[i]);

        cout << md - 1 << endl;
    }
    return 0;
}


Measured memory_bytes: 10368
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)

int main(){
  string S; cin >> S;
  if(S == "Sunny") cout << "Cloudy" << endl;
  else if(S == "Cloudy") cout << "Rainy" << endl;
  else cout << "Sunny" << endl;
}

Measured memory_bytes: 256
#ifdef _MSC_VER
#define _CRT_SECURE_NO_WARNINGS
#endif

#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <cassert>
#include <string.h>
#include <unordered_set>
#include <unordered_map>

using namespace std;

typedef long long int64;
typedef unsigned long long uint64;
#define two(X) (1<<(X))
#define twoL(X) (((int64)(1))<<(X))
#define contain(S,X) (((S)&two(X))!=0)
#define containL(S,X) (((S)&twoL(X))!=0)
const double pi=acos(-1.0);
const double eps=1e-11;
template<class T> inline void ckmin(T &a,T b){if(b<a) a=b;}
template<class T> inline void ckmax(T &a,T b){if(b>a) a=b;}
template<class T> inline T sqr(T x){return x*x;}
typedef pair<int,int> ipair;
#define SIZE(A) ((int)A.size())
#define LENGTH(A) ((int)A.length())
#define MP(A,B) make_pair(A,B)
#define PB(X) push_back(X)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,a) for(int i=0;i<(a);++i)
#define ALL(A) A.begin(),A.end()

int64 c[128][128];

int main()
{
#ifdef _MSC_VER
	//freopen("input.txt","r",stdin);
#endif
	std::ios::sync_with_stdio(false);
	memset(c,0,sizeof(c));
	REP(i,128) REP(j,i+1) c[i][j]=(j==0?1:c[i-1][j-1]+c[i-1][j]);
	int n,p;
	int c0=0,c1=0;
	cin>>n>>p;
	REP(i,n)
	{
		int d;
		cin>>d;
		if (d%2==0) c0++;
		else c1++;
	}
	int64 ret=0;
	REP(i,c1+1) if (i%2==p) ret+=c[c1][i];
	ret<<=c0;
	cout<<ret<<endl;
	return 0;
}



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

/* REPmacro */
#define REP(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define REPR(i,n) for(int i=((int)(n)-1);i>=0;--i)
#define FOR(i,m,n) for(int i=(int)(m);i<(int)(n);++i)

/*alias*/
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define F first
#define S second
#define PB push_back
#define MP make_pair 

#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev

/*using*/
using ll = long long;
using ull = unsigned long long;
using unsi = unsigned;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using db = double;
using plex = complex<double>;
using vs = vector<string>;

/*template*/
template<class T>inline bool amax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>inline bool amin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

/* func */

/*struct*/
struct aaa{
    aaa(){
        cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);
    };
}aaaaaaa;

/* const */
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7; //10^9
const db EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

//#define int ll
//#define int long long

signed main()
{
  int n,a,b;
  cin >> n >> a >> b;
  int ans = 0;
  
  for(int i = 1; i <= n; ++i){
   int sum = 0;
    int x = i;
    for(int j = 0; j < 5; ++j){//たかだか5桁（10000）なので五回
      sum += x % 10; //一の位が求まる。
      x /= 10;  //139 becomes 13 
    }
      if(a <= sum && sum <= b)
        ans += i;
  }
  
  cout << ans;
  
  
  return 0;
}

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

#define REP(i, n) for(int i = 0;i < n;i++)
#define ll long long

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll sx, sy, tx, ty;
	cin >> sx >> sy >> tx >> ty;
	ll dx = tx-sx; ll dy = ty-sy;
	REP(i, dx){ cout << "R"; }
	REP(i, dy){ cout << "U"; }
	REP(i, dx){ cout << "L"; }
	REP(i, dy){ cout << "D"; }
	cout << "D";
	REP(i, dx+1){ cout << "R"; }
	REP(i, dy+1){ cout << "U"; }
	cout << "L";
	cout << "U";
	REP(i, dx+1){ cout << "L"; }
	REP(i, dy+1){ cout << "D"; }
	cout << "R" << endl;
}


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

#ifdef LOCAL
#define debug(var) cerr << (#var) << " = " << (var) << endl;
#else
#define debug(var)
#endif

void init() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}

const int N = 432;

char s[N][N];
bool bio[N][N];

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

void solve() {
  int h, w; scanf("%d%d", &h, &w);
  for (int i = 0; i < h; ++i) {
    for (int j = 0; j < w; ++j) {
      scanf(" %c", s[i]+j);
    }
  }
  long long ans = 0;
  queue<pair<int, int>> q;
  for (int i = 0; i < h; ++i) {
    for (int j = 0; j < w; ++j) {
      if (bio[i][j]) continue;
      q.emplace(i, j);
      bio[i][j] = true;
      long long black = 0, white = 0;
      while (!q.empty()) {
	const auto &p = q.front();
	if (s[p.first][p.second] == '#') ++black;
	else ++white;
	for (int i = 0; i < 4; ++i) {
	  int y = p.first+dy[i], x = p.second+dx[i];
	  if (x < 0 || x >= w || y < 0 || y >= h) continue;
	  if (bio[y][x]) continue;
	  if (s[p.first][p.second] == s[y][x]) continue;
	  q.emplace(y, x);
	  bio[y][x] = true;
	}
	q.pop();
      }
      ans += black*white;
    }
  }
  printf("%lld", ans);
}

int main() {
  init();
  int t = 1; //scanf("%d", &t);
  while (t--) {
    solve();
  }
  return 0;
}


Measured memory_bytes: 4144
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
//問題文および制約はちゃんと確認しよう！
//サイズは10^5じゃなくて2×10^5とかかもしれないし、重要な制約・条件を見落としているかも
//とりあえずサンプルを読んでから解法を考えよう？
lint inf=1001001001;
vector<lint> x,y;
int xn,ynum;
lint a[1010],b[1010],c[1010],d[1010],e[1010],f[1010];
bool xb[3010][3010],yb[3010][3010],sumi[3010][3010];
/*void dfs(int u,int v){
	sumi[u][v]=true;
	//cout<<"("<<x[u]<<","<<y[v]<<")-("<<x[u+1]<<","<<y[v+1]<<")"<<endl;
	if(u>0 && !xb[u][v] && !sumi[u-1][v]) dfs(u-1,v);
	if(v>0 && !yb[u][v] && !sumi[u][v-1]) dfs(u,v-1);
	if(u<xn-2 && !xb[u+1][v] && !sumi[u+1][v]) dfs(u+1,v);
	if(v<ynum-2 && !yb[u][v+1] && !sumi[u][v+1]) dfs(u,v+1);
}*/
int main()
{
	int n,m;
	x.pb(0);y.pb(0);x.pb(inf);y.pb(inf);x.pb(-inf);y.pb(-inf);
	cin>>n>>m;
	rep(i,n){
		cin>>a[i]>>b[i]>>c[i];
		x.pb(a[i]);x.pb(b[i]);y.pb(c[i]);
	}
	rep(i,m){
		cin>>d[i]>>e[i]>>f[i];
		x.pb(d[i]);y.pb(e[i]);y.pb(f[i]);
	}
	sort(All(x));x.erase(unique(All(x)),x.end());
	sort(All(y));y.erase(unique(All(y)),y.end());
	xn=x.size();ynum=y.size();
	memset(xb,false,sizeof(xb));
	memset(yb,false,sizeof(yb));
	rep(i,n){
		int xs=lower_bound(All(x),a[i])-x.begin();
		int xg=lower_bound(All(x),b[i])-x.begin();
		int ys=lower_bound(All(y),c[i])-y.begin();
		REP(j,xs,xg) yb[j][ys]=true;
	}
	rep(i,m){
		int xs=lower_bound(All(x),d[i])-x.begin();
		int ys=lower_bound(All(y),e[i])-y.begin();
		int yg=lower_bound(All(y),f[i])-y.begin();
		REP(j,ys,yg) xb[xs][j]=true;
	}
	memset(sumi,false,sizeof(sumi));
	queue<pint> q;
	q.push(mp(lower_bound(All(x),0L)-x.begin(),lower_bound(All(y),0L)-y.begin()));
	while(!q.empty()){
		pint p=q.front();q.pop();
		int u=p.fi,v=p.se;
		sumi[u][v]=true;
		if(u>0 && !xb[u][v] && !sumi[u-1][v]) q.push(mp(u-1,v)),sumi[u-1][v]=true;
		if(v>0 && !yb[u][v] && !sumi[u][v-1]) q.push(mp(u,v-1)),sumi[u][v-1]=true;
		if(u<xn-2 && !xb[u+1][v] && !sumi[u+1][v]) q.push(mp(u+1,v)),sumi[u+1][v]=true;
		if(v<ynum-2 && !yb[u][v+1] && !sumi[u][v+1]) q.push(mp(u,v+1)),sumi[u][v+1]=true;
	}
	lint out=0;
	rep(i,xn-1) rep(j,ynum-1){
		if(sumi[i][j]){
			if(i==0 || j==0 || i==xn-2 || j==ynum-2){
				cout<<"INF"<<endl;return 0;
			}
			out+=(x[i+1]-x[i])*(y[j+1]-y[j]);
		}
	}
	//if(out>4E18L) cout<<"INF"<<endl;
	cout<<out<<endl;
}


Measured memory_bytes: 30304
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;

//typedef
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

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

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

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

//repetition
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define UNTIL(p) while(!(p))

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

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

#define PUTS(x) cout << (x) << endl;

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    LL n;
    cin>>n;
    VL a(n);
    REP(i,n)cin>>a[i];
    VL ans(n);

    LL l = 0;
    LL r = a[0]+1;

    while(l < r){
        LL x = (l+r)/2;
        ans[0] = x*2;
        FOR(k,1,n){
            ans[k] = (a[k-1] - ans[k-1]/2) * 2;
        }
        LL z = (a[n-1] - ans[n-1]/2)*2;
        if(ans[0] == z){
            break;
        }
        else if(ans[0] < z){
            l = x;
        }
        else{
            r = x;
        }
    }


    REP(i,n)cout<<ans[i]<<" ";
    cout<<endl;
}

Measured memory_bytes: 2944
#include "bits/stdc++.h"
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;

typedef long long ll;

int main() {
    int H, W, a = 0;
    string S;
    cin >> H >> W;
    rep(i, H) {
        cin >> S;
        rep(j, W) {
            if (S[j] == '#') a++;
        }
    }
    if (a == H + W - 1) cout << "Possible\n";
    else cout << "Impossible\n";
}

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

using namespace std;

int main()
{
	int n; cin >> n;
	
	int h[n];
	
	for (int i = 0; i < n; ++i) cin >> h[i];
	
	int dp[n];
	
	dp[0] = 0;
	dp[1] = abs(h[0] - h[1]);
	
	for (int i = 2; i < n; ++i)
	{
		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;
	
	return 0;
}

Measured memory_bytes: 1024
import collections
N = int(raw_input())
inList = map(int, raw_input().split(" "))
c = collections.Counter()
d = collections.Counter()
for i in inList:
    if(c[i] == 1):
        d[i] += 1
    else:
        c[i] += 1
ans = len(c.keys())
if(sum(d.values()) % 2 != 0):
    ans = ans - 1
print ans

Measured memory_bytes: 16488