akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<pdd> vdd;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mem(a,b) memset(a, b, sizeof(a) )
#define all(x) (x).begin(),(x).end()
#define INF 1000000000000
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

int main(){
	int a,b;cin>>a>>b;
	if(a==0||b==0){
		cout<<"Zero"<<endl;
	}
	if(a<0&&b>0){
		cout<<"Zero"<<endl;
	}
	if(a<0&&b<0){
		if((b-a+1)%2==1){
			cout<<"Negative"<<endl;
		}
		else{
			cout<<"Positive"<<endl;
		}
	}
	if(a>0&&b>0){
		cout<<"Positive"<<endl;
	}
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <iomanip>

#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
const int inf = 1e9;
const ll linf = 1LL << 50;

int main(int argc, char const* argv[])
{
	ll x, y;
	cin >> x >> y;
	ll res = 0;
	ll curr = x;
	while(curr <= y){
			res++;
			curr *= 2;
	}
	cout << res << endl;
	return 0;
}


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

int main()
{
    int n, x, y, h, w;

    while( cin >> n )
    {
        if( n == 0 )
            break;
        
        int sum = 0;
        for( int i = 0; i < n; i++ )
        {
            cin >> x >> y >> h >> w;
            x += y + h;
            if( x <= 60 && w <= 2 )
                sum += 600;
            else if( x <= 80 && w <= 5 )
                sum += 800;
            else if( x <= 100 && w <= 10 )
                sum += 1000;
            else if( x <= 120 && w <= 15 )
                sum += 1200;
            else if( x <= 140 && w <= 20 )
                sum += 1400;
            else if( x <= 160 && w <= 25 )
                sum += 1600;
            else;
        }
        cout << sum << endl;
    }
    return 0;
}



Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pr pair<int,int>
#define mp make_pair
#define pb push_back
const int MAXN =1e6 + 5;
const ll INF = 0x3f3f3f3f3f3f3f;
const ll mod =1e9 + 7;
int main()
{
    int a,b;
    cin>>a>>b;
    cout<<a*b - (a + b) + 1<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main {
	public static void main(String[] args) {

		try (Scanner scanner = new Scanner(System.in)) {
			while (scanner.hasNextDouble()) {
				double weight = scanner.nextDouble();
				System.out.println(getWeightClass(weight));
			}
		}
	}

	private static String getWeightClass(double weight) {
		String weghitClass = null;

		if (weight <= 48.00) {
			weghitClass = "light fly";
		} else if (weight <= 51.00) {
			weghitClass = "fly";
		} else if (weight <= 54.00) {
			weghitClass = "bantam";
		} else if (weight <= 57.00) {
			weghitClass = "feather";
		} else if (weight <= 60.00) {
			weghitClass = "light";
		} else if (weight <= 64.00) {
			weghitClass = "light welter";
		} else if (weight <= 69.00) {
			weghitClass = "welter";
		} else if (weight <= 75.00) {
			weghitClass = "light middle";
		} else if (weight <= 81.00) {
			weghitClass = "middle";
		} else if (weight <= 91.00) {
			weghitClass = "light heavy";
		} else {
			weghitClass = "heavy";
		}
		return weghitClass;
	}
}

Measured memory_bytes: 28108
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,num,n) for(ll i=num, i##_len=(n); i<i##_len; ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define print(x) cout << (x) << endl;
#define sz(x) int(x.size())
 
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
const ll LLINF = 1LL<<60;
const int INF = 1<<29;
const int MOD = 1000000007;
 
void add(long long &a, long long b) {
  a += b;
  if (a >= MOD) a -= MOD;
}
 
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

ll num[30];
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    int N; string S; cin >> N >> S;

    for (auto c : S) num[c - 'a']++;
    long long res = 1;
    for (int i = 0; i < 26; ++i) {
        res *= num[i] + 1;
        res %= MOD;
    }
    cout << (res + MOD - 1) % MOD << endl;
}

Measured memory_bytes: 512
a, b, c = gets.split.map(&:to_f)
puts 0.5 * a * b * Math.sin(c * Math::PI / 180)
puts a + b + Math.sqrt(a ** 2 + b ** 2 - 2 * a * b * Math.cos(c * Math::PI / 180))
puts b * Math.sin(c * Math::PI / 180)

Measured memory_bytes: 8964
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x) x
#define rep(...) MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c) c.begin(),c.end()
#define mp make_pair
#define write(x) cout<<(x)<<"\n"
using namespace std; typedef long long ll;
typedef vector<int> vi; typedef vector<ll> vll; template<class T>using vv = vector<vector<T>>;
template<class T>vv<T> vvec(size_t n, size_t m, T v) { return vv<T>(n, vector<T>(m, v)); }
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; }
constexpr int INF = 1 << 28, MOD = 1e9 + 7; constexpr ll LINF = 1ll << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); }; }aaaa;
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

int main() {
    int N, X;
    cin >> N >> X;
    vi x(N);
    rep(i, N) cin >> x[i];

    ll d = abs(x[0] - X);
    rep(i, 1, N) {
        d = gcd(d, abs(x[i] - x[i - 1]));
    }
    write(d);
}

Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;

#define MAXN   10000001

// stores smallest prime factor for every number
long long int spf[MAXN];

// Calculating SPF (Smallest Prime Factor) for every
// number till MAXN.
// Time Complexity : O(nloglogn)
void sieve()
{
    spf[1] = 1;
    for (long long int i=1; i<MAXN; i++)

        // marking smallest prime factor for every
        // number to be itself.
        spf[i] = i;

    // separately marking spf for every even
    // number as 2
    for (long long int i=4; i<MAXN; i+=2)
        spf[i] = 2;

    for (long long int i=3; i*i<MAXN; i++)
    {
        // checking if i is prime
        if (spf[i] == i)
        {
            // marking SPF for all numbers divisible by i
            for (long long int j=i*i; j<MAXN; j+=i)

                // marking spf[j] if it is not
                // previously marked
                if (spf[j]==j)
                    spf[j] = i;
        }
    }
}

// A O(log n) function returning primefactorization
// by dividing by smallest prime factor at every step
vector<long long int> getFactorization(long long int x)
{
    vector<long long int> ret;
    while (x != 1)
    {
        ret.push_back(spf[x]);
        x = x / spf[x];
    }
    return ret;
}

// driver program for above function
int main()
{
    // precalculating Smallest Prime Factor
    sieve();
    long long int n;
    cin>>n;
    long long ans=0;
    for(long long int i=1;i<=n;i++)
    {
        vector <long long int> p = getFactorization(i);
        map<long long,long long>mp;
        for(auto itr : p)
        mp[itr]++;
        long long count=1;
        for(auto itr : mp)
        count=count*(itr.second+1);
        ans=ans+i*count;
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 81744
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int n;
    cin >> n;
    int a[n];
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    int all = 0;
    for(int i = 0; i < n; i++){
        all = all ^ a[i];
    }
    for(int i = 0; i < n; i++){
        cout << (all ^ a[i]) << " ";
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 4356
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x) cout << #x << ' ' << '=' << ' ' << (x) << endl;
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;
typedef vector<ll> vec;
typedef vector<P> pvec;
typedef vector<vector<ll>> vvec;
typedef vector<vector<P>> pvvec;
typedef priority_queue<ll> PQI;
typedef priority_queue<P> PQP;
typedef priority_queue<ll,vector<ll>,greater<ll>> PQIG;
typedef priority_queue<P,vector<P>,greater<P>> PQPG;
const vector<int> dx = {0, -1, 0, 1, 1, 1, -1, -1};
const vector<int> dy = {1, 0, -1, 0, 1, -1, 1, -1};
const int MOD = (1000000007);
// const int MOD = (998244353);
// const int INF = (1 << 30);
const int INF = (1LL << 60);
const double EPS = (1 >> 30);
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}
template< typename T1, typename T2 > istream &operator>>(istream &is, pair< T1, T2 > &p) { is >> p.first >> p.second; return is; }
template< typename T > istream &operator>>(istream &is, vector< T > &v) { for(T &in : v) is >> in; return is; }



signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);
    //---------------------------------------------
    
    int a,b,m;
    cin>>a>>b>>m;
    vector<int> c(a);
    REP(i,a) cin >> c[i];
    vector<int> d(b);
    REP(i,b) cin >> d[i];
    ll ans=INF;
    rep(i,m){
        int x,y,z;
        cin>>x>>y>>z;
        int memo=c[x-1]+d[y-1]-z;
        chmin(ans,memo);
    }
    sort(all(c));
    sort(all(d));
    chmin(ans,c[0]+d[0]);
    cout<<ans<<endl;
    
    
}

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

int main() {
  int H, W;
  cin >> H >> W;
  vector<vector<char>>A(H, vector<char>(W));
  
  for(int i = 0; i < H; i++){
    for(int j = 0; j < W; j++){
      cin >> A.at(i).at(j);
    }
  }
  
 for(int i = 0; i < H; i++){
    for(int j = 0; j < W; j++){
      if(A.at(i).at(j) == '#')
        j = W;
      if(j == W - 1){
        for(int k = 0; k < W; k++){
          A.at(i).at(k) = 'x';
        }
      }
    }
  }
  
   for(int i = 0; i < W; i++){
    for(int j = 0; j < H; j++){
      if(A.at(j).at(i) == '#')
        j = H;
      if(j == H - 1){
        for(int k = 0; k < H; k++){
          A.at(k).at(i) = 'x';
        }
      }
    }
  }
  
  for(int i = 0; i < H; i++){
    int C = 0;
    for(int j = 0; j < W; j++){
      if(A.at(i).at(j) != 'x')
        cout << A.at(i).at(j);
      else
        C++;
      if(j == W - 1 && C != W)
        cout << endl;
    }
  }
}


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

sys.setrecursionlimit(10 ** 8)
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N, M, K = map(int, readline().split())
MOD = 998244353

# Combination under a modulo: nCk % mod
# Modulo must be a prime number.
# Intermediate numerators and denominators are cached and reused.
def combmod(n, k, p=MOD, cache=collections.defaultdict(lambda: [(1, 1)])):
    if k > n:
        return 0
    if k > n - k:
        k = n - k
    # Reuse precalculated numerators and denominators.
    numden = cache[n]
    if k < len(numden):
        num, den = numden[k]
    else:
        # Resume from len(numden).
        num, den = numden[-1]
        for i in range(len(numden) - 1, k):
            num = num * (n - i) % p
            den = den * (i + 1) % p
            numden.append((num, den))
    # a^(p-1) ≡ 1 mod p (by Fermat's little theorem)
    # i.e. a^(p-2) ≡ a^(-1) mod p
    inv_dev = pow(den, p - 2, p)
    return num * inv_dev % p


def solve():
    ans = 0
    for i in range(K + 1):
        ans += combmod(N - 1, i) * M * pow(M - 1, N - 1 - i, MOD) % MOD
        ans %= MOD
    return ans


if __name__ == "__main__":
    print(solve())


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

int main(){
  int N;
  cin >> N;
  int a, b, c, d;
  a=N/1000;
  b=N%1000/100;
  c=N%100/10;
  d=N%10;
  //cout << a << b << c << d << endl;
  if(a+b+c+d==7) cout<<a<<'+'<<b<<'+'<<c<<'+'<<d<<'='<<7<<endl;
  else if(a+b+c-d==7) cout<<a<<'+'<<b<<'+'<<c<<'-'<<d<<'='<<7<<endl;
  else if(a+b-c+d==7) cout<<a<<'+'<<b<<'-'<<c<<'+'<<d<<'='<<7<<endl;
  else if(a+b-c-d==7) cout<<a<<'+'<<b<<'-'<<c<<'-'<<d<<'='<<7<<endl;
  else if(a-b+c+d==7) cout<<a<<'-'<<b<<'+'<<c<<'+'<<d<<'='<<7<<endl;
  else if(a-b+c-d==7) cout<<a<<'-'<<b<<'+'<<c<<'-'<<d<<'='<<7<<endl;
  else if(a-b-c+d==7) cout<<a<<'-'<<b<<'-'<<c<<'+'<<d<<'='<<7<<endl;
  else if(a-b-c-d==7) cout<<a<<'-'<<b<<'-'<<c<<'-'<<d<<'='<<7<<endl;
}

Measured memory_bytes: 256
from collections import deque

N = int(input())
S = input()

def isOk(leng):
    strList = set()
    que = deque([])
    for left in range(N - leng + 1):
        sub = S[left: left + leng]
        if sub in strList:
            return True
        que.append(sub)
        if len(que) >= leng:
            strList.add(que.popleft())
    return False

ok = 0
ng = N

while ng - ok > 1:
    mid = (ng + ok) // 2
    if isOk(mid):
        ok = mid
    else:
        ng = mid

print(ok)

Measured memory_bytes: 11124
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
#define in insert
#define mp make_pair
#define F first
#define pb push_back
#define speed ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define test ll t; cin>>t; while(t--)
ll exp(ll x,ll y,ll p){ ll res=1; while(y) {if(y%2) res=(res*x%p)%p; x=(x*x)%p; y/=2; } return res;}
ll exp(ll x,ll y){ ll res=1; while(y) {if(y%2) res=(res*x); x=(x*x); y/=2; } return res;}
bool is_prime (ll n) {
  if (n == 1) return false;
  if (n == 2) return true;
  if (n == 3) return true;

 
  for (ll i = 2; i < sqrt(n) + 1; i++) {
    if (n % i == 0) return false;
  }
 
  return true;
}
int main(){
    ll a,b; cin>>a>>b;
    set<ll> s1;
    set<ll> s2;
    
    for(ll i=1;i<=(ll)sqrt(a);i++){
        if(a%i==0 ){
            if(is_prime(i)==1)
                s1.in(i);
            if(is_prime(a/i)==1)
                s1.in(a/i);
        }
    }
    for(ll i=1;i<=(ll)sqrt(b);i++){
        if(b%i==0){
            if(is_prime(i)==1)
                s2.in(i);
            if(is_prime(b/i)==1)
                s2.in(b/i);
        }
    }
    set<ll> s3;
    set_intersection(s1.begin(),s1.end(),s2.begin(),s2.end(),inserter(s3,s3.begin()));
    cout<<s3.size()+1;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

#define N 100001

typedef struct{
  int p;
  int left;
  int right;
}Tree;

Tree T[N];
int depth(int);

int main(){
  int n,i,j,id,k,temp;

  scanf("%d ",&n);

  for(i=0;i<n;i++){
    T[i].p=-1;
    T[i].left=-1;
    T[i].right=-1;
  }

  for(i=0;i<n;i++){
    scanf("%d%d",&id,&k);
    for(j=0;j<k;j++){
      if(j==0){
        scanf("%d",&T[id].left);
        temp=T[id].left;
      }
      else{
        scanf("%d",&T[temp].right);
        temp=T[temp].right;
      }
T[temp].p=id;
    }

  }




  for(i=0;i<n;i++){
      printf("node %d: parent = %d, depth = %d, ",i,T[i].p,depth(i));
      if(T[i].p==-1){
        printf("root, ");
      }
      else if(T[i].left==-1){
        printf("leaf, ");
      }
      else{
        printf("internal node, ");
      }

      printf("[");
      if(T[i].left!=-1){
        printf("%d",T[i].left);
        temp=T[i].left;
        while(T[temp].right!=-1){
          printf(", %d",T[temp].right);
          temp=T[temp].right;
        }
      }
      printf("]\n");
  }
  return 0;
}

int depth(int id){
  int cnt=0;

  while(T[id].p!=-1){
    id=T[id].p;
    cnt++;
  }
  return cnt;
}



Measured memory_bytes: 2940
#include <stdio.h>
#include <string.h>
#include <math.h>
int main()
{
    long long int a,b,n;
    int s[100000];
    scanf("%lld %lld %lld",&a,&b,&n);
    if(b>n)
        printf("%lld",(a*n/b)-(a*(n/b)));

    else
        printf("%lld",(a*(b-1)/b)-(a*((b-1)/b)));

}

Measured memory_bytes: 1676
H, W = gets.split.map(&:to_i)
if H % 3 == 0 || W % 3 == 0
  p 0
  exit
end

ans = Float::INFINITY
ah = H / 2
bh = H - ah
(1..(W-1)).each do |cw|
  a = [ah * (W-cw), bh * (W-cw), H * cw]
  ans = [ans, a.max - a.min].min
end

aw = W / 2
bw = W - aw
(1..(H-1)).each do |ch|
  a = [aw * (H-ch), bw * (H-ch), W * ch]
  ans = [ans, a.max - a.min].min
end

aw = W / 3
bw = (W - aw) / 2
cw = W - aw - bw
a = [H*aw, H*bw, H*cw]
ans = [ans, a.max - a.min].min

ah = H / 3
bh = (H - ah) / 2
ch = H - ah - bh
a = [W*ah, W*bh, W*ch]
ans = [ans, a.max - a.min].min

p ans


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

int main() {
    string s;
    
    cin >> s;
    sort(s.begin(), s.end());
    
    if ((s[0] == s[1]) && (s[2] == s[3]) && (s[0] != s[2])) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B,k1,k2,k3,k4,k5,N;
  cin>>A>>B;
  int i,s;
  s=0;
  for(i=A;i<B+1;i++){
    k1=i%10;
    k2=(i/10)%10;
    k3=(i/100)%10;
    k4=(i/1000)%10;
    k5=(i/10000)%10;
    N=k1*10000+k2*1000+k3*100+k4*10+k5;
    if(i==N){
      s++;
    }
    else{
      continue;
    }
  }
  cout<<s<<endl;
}


Measured memory_bytes: 256
// https://atcoder.jp/contests/dp/tasks/dp_b
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
using namespace std;

#define fi first
#define se second
#define pb push_back
#define mp make_pair

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

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

const int N = int(1e5)+10;
const int MOD = int(1e9)+7;
const int INF = int(2e9)+5;
const ll INF64 = 1e18;

ll a[N],dp[N];

int main () {
    FastIO
    int n,k;cin>>n>>k;
    for (int i=1;i<=n;i++) {
        cin>>a[i];
        dp[i] = INF;
    }
    dp[1] = 0;
    for (int i=1;i<=n;i++) {
        int j = 1;
        while (j <= k && i + j <= n) {
            dp[i+j] = min(dp[i+j],dp[i] + abs(a[i]-a[i+j]));
            j++;
        }
    }
    cout<<dp[n]<<endl;
    return 0;
}

Measured memory_bytes: 1792
N = int(input())
masu_list = list(map(int, input().split()))

tmp_mas = 0
flag = True
for i in range(N):
    if masu_list[i] >= tmp_mas:
        tmp_mas = masu_list[i]
    elif tmp_mas - masu_list[i] == 1:
        tmp_mas = masu_list[i] + 1
    else:
        print('No')
        flag = False
        break

if flag:
    print('Yes')

Measured memory_bytes: 15020
N,K=list(map(int,input().split()))
A=[0]+list(map(int,input().split()))

visit=set()
order=[-1]*(N+1)
p=1
cnt=0

while not (p in visit):
    visit.add(p)
    order[cnt]=p
    p=A[p]
    cnt+=1

start=order.index(p)
end=cnt
if K>end:
    K-=(end-start)*max(0,(K-start)//(end-start)-1)
p=1
while K>0:
    p=A[p]     
    K-=1

print(p)

Measured memory_bytes: 121048
#include<stdio.h>

int main(void){

int a,b;
char op;

while( 1 ){
   scanf("%d %c %d",&a,&op,&b);
   if(op=='?'){break;}
   if(op=='+'){printf("%d\n",a+b);}
   if(op=='-'){printf("%d\n",a-b);}
   if(op=='*'){printf("%d\n",a*b);}
   if(op=='/'){printf("%d\n",a/b);}

   }
return 0;
}



Measured memory_bytes: 2048
/*{{{*/
//#define HOME
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;

#define MP make_pair
#define MT make_tuple
#define PB push_back
#define EB emplace_back
#define F first
#define S second

template<class T> void _R(T &_x) { cin >> _x; }
void _R(int &_x) { scanf("%d", &_x); }
void _R(int64_t &_x) { scanf("%" SCNd64, &_x); }
void _R(double &_x) { scanf("%lf", &_x); }
void _R(char &_x) { scanf(" %c", &_x); }
void _R(char *_x) { scanf("%s", _x); }
template<class T, class U> void _R(pair<T, U> &_x) {_R(_x.F); _R(_x.S);}
void R() {}
template<class T, class... U> void R(T &_head, U &... _tail) { _R(_head); R(_tail...); }

template<class T> void _W(const T &_x) { cout << _x; }
void _W(const int &_x) { printf("%d", _x); }
void _W(const int64_t &_x) { printf("%" PRId64, _x); }
void _W(const double &_x) { printf("%.16f", _x); }
void _W(const char &_x) { putchar(_x); }
void _W(const char *_x) { printf("%s", _x); }
template<class T, class U> void _W(const pair<T, U> &_x) {_W(_x.F); putchar(' '); _W(_x.S);}
template<class T> void _W(const vector<T> &_x) { for (auto i = _x.begin(); i != _x.end(); _W(*i++)) if (i != _x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &_head, const U &... _tail) { _W(_head); putchar(sizeof...(_tail) ? ' ' : '\n'); W(_tail...); }
template<class T, class... U> void DB(const T &_head, const U &... _tail) {
#ifdef HOME
    W('#', _head, _tail...);
#endif
}

#define SZ(x) (int)((x).size())
#define ALL(x) (x).begin(), (x).end()
#define RAN(x,n) (x).begin(), (x).begin()+(n)
#define UNIQUE(x) {sort(ALL(x)); (x).erase(unique(ALL(x)), (x).end());}

#define REP(i,a,b) for (int i = (a); i <= (b); ++i)
#define REPD(i,a,b) for (int i = (a); i >= (b); --i)
#define FORI(i,n) REP(i,1,n)
#define FOR(i,n) REP(i,0,int(n)-1)
//#define ITER(i,t) for (auto i = t.begin(); i != t.end(); ++i)
#define IT3(i,st,ed) for (auto i = st; i != ed; ++i)
#define IT2(i,range) IT3(i,range)

#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define MS(X, v) memset((X), (v), sizeof((X)))

template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;

typedef int64_t ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

inline int LG (const unsigned int &_x) { return 31-__builtin_clz(_x); }  // floor: LG(x), ceil: LG(x-1)+1
/*}}}*/

int n;
vector<vector<pii>> es;
vi color;

void go(int v, int fa, int skip){
    int c = 1;
    for(pii e: es[v]){
        if(e.F == fa) continue;
        if(c == skip) c++;
        color[e.S] = c;
        go(e.F, v, c);
        c++;
    }
}

int main(){
    R(n);
    es.assign(n, vector<pii>());
    FOR(i, n-1){
        int a, b; R(a, b); --a, --b;
        es[a].EB(b, i), es[b].EB(a, i);
    }

    color.assign(n-1, 0);
    go(0, -1, 0);

    W(*max_element(ALL(color)));
    W(color);

    return 0;
}


Measured memory_bytes: 8320
N = int(input())
S = input()

x = 0
ans = []  

for i in range(N):
    if S[i] == "I":
        x = x + 1
        ans.append(x)
    elif S[i] == "D":
        x = x - 1
        ans.append(x)

if max(ans) >= 0:
    print(max(ans))
else:
    print(0) 

        

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

template<typename T>
T lcs(T a, T b) {
    if (b.size() > a.size()) swap(a,b);
    int I = a.size();
    int J = b.size();
    vector<vector<int>> dp(I+1, vector<int>(J+1));
    for (int i = 1; i <= I; i++) {
        for (int j = 1; j <= J; j++) {
            if (a[i-1] == b[j-1]) dp[i][j] = dp[i-1][j-1] + 1;
            else dp[i][j] = max(dp[i][j-1], dp[i-1][j]);
        }
    }

    int cost = dp[I][J];
    T result;
    for (int i = I; i >= 1; i--) {
        for (int j = J; j >= 1; j--) {
            if(dp[i-1][j-1] == cost-1 && a[i-1] == b[j-1]) {
                result.push_back(a[i-1]);
                cost--;
                break;
            }
        }
    }
    reverse(result.begin(), result.end());
    return result;
}


int main(void){
    string a,b;
    cin >> a >> b;
    cout << lcs(a,b) << endl;
    return 0;
}


Measured memory_bytes: 35584
#include <iostream>
#include <vector>
#include <algorithm>

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

using namespace std;

typedef long long int lli;

int main () {
    int N;
    cin >> N;
    vector<int> a(N);
    REP (i, 0, N) cin >> a[i];
    int ans = 0;
    int cnt = 0;
    REP (i, 0, N) {
        if (a[i] == i + 1) {
            cnt++;
        } else {
            ans += (cnt + 1) / 2;
            cnt = 0;
        }
    }
    ans += (cnt + 1) / 2;
    cout << ans << endl;
    return 0;
}


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

int main(){
    string S, T;
    int Slen, Tlen;
    cin >> S >> T;
    Slen = S.length();
    Tlen = T.length();
    bool flag = false;

    for(int s=Slen-Tlen;s>=0;s--){
        int matchcount = 0;
        for(int t=0;t<Tlen;t++){
            if(S[s+t] == T[t] || S[s+t] == '?'){
                matchcount++;
            }
        }
        if(matchcount == Tlen){
            for(int t=0;t<Tlen;t++){
                S[s+t] = T[t];
            }
            flag = true;
            break;
        }
    }

    if(flag){
        for(int s=0;s<Slen;s++){
            if(S[s] == '?'){
                cout << 'a';
            }
            else{
                cout << S[s];
            }
        }
        cout << endl;
    }
    else{
        cout << "UNRESTORABLE" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
public class Hello{
   static void Main()
        {
            string a = Console.ReadLine();
            if(a == "Sunny"){
              Console.WriteLine("Cloudy");
            }else if(a == "Cloudy"){
              Console.WriteLine("Rainy");
            }else if(a == "Rainy"){
              Console.WriteLine("Sunny");
            }
        }    
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define vvi vector< vector<int> >
#define vi vector<int>
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define shosu(X) fixed << setprecision(X)
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
 
int parent[100000];
int members[100000];

int getroot(int p){
  if(p == parent[p]) return p;
  // if(parent[p] < 0) return p;
  else return parent[p] = getroot(parent[p]);
}
void unite(int a, int b){
  int x = getroot(a);
  int y = getroot(b);
  if (x == y) return;
  // if (x > y) { swap(x, y); }
  if(x != y) {
    parent[y] = x;
    members[x]+=members[y];
  }
}

bool issame(int a, int b){
  return (getroot(a) == getroot(b));
}

int main(){
  REP(i, 100000) parent[i] = i;
  REP(i, 100000) members[i] = 1;
  vector<pii> vp;
  int n, m;
  cin >> n >> m;
  REP(i, m){
    int a, b;
    cin >> a >> b;
    a--; b--;
    vp.pb(mp(a, b));
  }
  reverse(All(vp));

  vector<ll> data;
  REP(i, m){
    int a = vp[i].first;
    int b = vp[i].second;
    if(!issame(a, b)){
      ll int dif = (ll)members[getroot(a)] * (ll)members[getroot(b)];
      unite(a, b);
      data.pb(dif);
    }else{
      data.pb(0);
    }
  }
  ll int old = 0;
  reverse(All(data));
  REP(i, data.size()){
    old += data[i];
    cout << old << endl;
  }
}

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

using namespace std;
using ll = long long;

int main() {
    int N = 5;
    vector<int> A(N,0);
    for(int i = 0; i < N; i++) {
        cin >> A.at(i);
    }
    int ans = 10;
    for(int i = 0; i < N; i++) {
        ans = min(ans, (A.at(i) - 1)%10 + 1);
    }
    for(int i = 0; i < N; i++) {
        ans += ((A.at(i) + 9)/10)*10;
    }

    cout << ans - 10 << endl;
    

    return 0;
}

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

using namespace std;

int main(int argc, char const *argv[]) {
	int n,k,temp;
	std::cin >> n >> k;
	std::vector<int> a(n,0);
	for (size_t i = 0; i < n; i++) {
		std::cin >> temp;
		a[temp-1]++;
	}
	sort(a.begin(),a.end());

	long long ans = 0;
	for (size_t i = 0; i < n-k; i++) {
		ans += a[i];
	}
	std::cout << ans << '\n';

	return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>

int main(void)
{
	int a,b;
	scanf("%d%d",&a,&b);
	if(a<b){
	printf("a < b\n");
	}
	else if(a>b)
	{
	printf("a > b\n");
	}
	else if(a==b){
	printf("a == b\n");
	}
}


Measured memory_bytes: 2104
#include<cstdio>
#include<iostream>
#include<sstream>
#include<cmath>
#include<algorithm>
#include<map>
#include<set>
#include<list>
#include<vector>
#include<stack>
#include<queue>
#include<string>
#include<iomanip>
#include<fstream>
#include<ctime>
using namespace std;
typedef vector<int> VI;
typedef pair <int,int> ii;
typedef pair <int,ii> iii;
typedef long long LL;
#define pb push_back
const int INF = 2147483647;

vector<iii> wek;
int n, i, tab[200005], l, r, ind;

void print() {
	for (auto& w : wek) {
		for (int l = w.second.first;l<=w.second.second;l++) printf("%d", w.first);
	}
	printf("\n");
}

bool can(int a) {
	//cout << "check " << a << endl;
	int i, lo;
	iii p;
	wek.clear();
	wek.pb(iii(1, ii(1, tab[0])));
	for (i=1;i<n;i++) {
		if (tab[i] > tab[i - 1]) {
			if (wek.back().first == 1) {
				wek.back().second.second = tab[i];
			} else {
				wek.pb(iii(1, ii(tab[i - 1] + 1, tab[i])));
			}
		} else {
			lo = tab[i];
			while (wek.back().second.first > tab[i]) wek.pop_back();
			while (wek.size() > 0 && wek.back().first == a) {
				wek.pop_back();
				if (wek.size() > 0) lo = wek.back().second.second;
			}
			if (wek.size() == 0) return false;
			p = wek.back();
			wek.pop_back();
			if (p.second.first < lo) wek.pb(iii(p.first, ii(p.second.first, lo - 1)));
			wek.pb(iii(p.first + 1, ii(lo, lo)));
			if (tab[i] > lo) wek.pb(iii(1, ii(lo + 1, tab[i])));
		}
	}
	return true;
}

int main() {
scanf("%d", &n);
for(i=0;i<n;i++) scanf("%d", &tab[i]);
l = 1;
r = n;
while (l < r) {
	ind = (l + r) / 2;
	if (can(ind)) r = ind; else l = ind + 1;
}
printf("%d\n", l);
return 0;
}



Measured memory_bytes: 1152
import sys
input = sys.stdin.readline
n, m = map(int, input().split())
a = [int(_) for _ in input().split()]
cb = [0] * m
for i in range(m):
    bb, cc = map(int, input().split())
    cb[i] = (cc, bb)

cb.sort(reverse=True)

arr = []
l = 0
for i in range(m):
    if l + cb[i][1] > 10**5:
        add = 10**5 - l
        for j in range(add):
            arr.append(cb[i][0])
        break
    else:
        for j in range(cb[i][1]):
            arr.append(cb[i][0])
        l += cb[i][1]

a = a + arr
a.sort(reverse=True)
print(sum(a[0:n]))

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

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

Measured memory_bytes: 1192
#include <iostream>
#define int long long

using namespace std;



signed main(void){
    // Your code here!
    int n;
    int a[100001];
    int q;
    int b[100001];
    int c[100001];
    int num[100001];
    
    int sum[100001];
    
    for(int i = 0; i < 100001; i ++){
        sum[i] = 0;
        num[i] = 0;
    }
    cin >> n;
    for(int i = 0; i < n; i ++){
        cin >> a[i];
        sum[0] += a[i];
    }
    
    for(int i = 0;i <n; i ++){
        num[a[i]] ++;
    }
    cin >> q;
    for(int i = 0; i < q; i ++){
        cin >> b[i] >> c[i];
    }
    
    
   // cout << b[0] << " " << c[0];
   for(int j = 0; j < q; j ++){
       int tmp = 0;
       tmp = c[j] - b[j];
       sum[j+1] = sum[j] + tmp*num[b[j]];
       num[c[j]] += num[b[j]];
       num[b[j]] = 0;
   }    
    
    for(int i = 1; i <= q; i ++){
        cout << sum[i] << endl;
    }
    
}


Measured memory_bytes: 7540
#include <iostream>
#include <cassert>
#include <queue>

#define INF 922337203685477580
typedef long long ll;

using namespace std;

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

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

  for (int s = 0; s < N - 1; s++) {
    cout << A[s] << " ";
  }
  cout << A[N - 1] << endl;

  for (int i = 1; i < N; i++) {
    int key = A[i];
    int j = i - 1;
    while(j >= 0 && A[j] > key) {
      A[j + 1] = A[j];
      j--;
    }
    A[j + 1] = key;

    for (int s = 0; s < N - 1; s++) {
      cout << A[s] << " ";
    }
    cout << A[N - 1] << endl;
  }

  return 0;
}

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

vector<int> understanding(vector<bool> toBuy, vector<vector<int>> A, int N, int M)
{
    vector<int> ans;
    for (int i = 0; i < M; i++)
    {
        ans.emplace_back(0);
    }

    for (int i = 0; i < N; i++)
    {
        if (toBuy.at(i))
        {
            for (int j = 0; j < M; j++)
            {
                ans.at(j) += A.at(i).at(j);
            }
        }
    }

    return ans;
}

int getCost(vector<int> C, int N, vector<bool> toBuy)
{
    int ans = 0;
    for (int i = 0; i < N; i++)
    {
        if (toBuy.at(i))
        {
            ans += C.at(i);
        }
    }
    return ans;
}

bool canUnderstand(vector<int> understand, int M, int X)
{
    for (int i = 0; i < M; i++)
    {
        if (understand.at(i) < X)
        {
            return false;
        }
    }

    return true;
}

void helper(int N, int i, vector<bool> toBuy, vector<int> C, vector<vector<int>> A, int M, int X, int &min_cost)
{
    if (i == N)
    {
        if (canUnderstand(understanding(toBuy, A, N, M), M, X))
        {
            min_cost = min(min_cost, getCost(C, N, toBuy));
        }
        return;
    }

    toBuy.at(i) = true;
    helper(N, i + 1, toBuy, C, A, M, X, min_cost);

    toBuy.at(i) = false;
    helper(N, i + 1, toBuy, C, A, M, X, min_cost);
}

// void helper(int N, int i, vector<bool> toBuy)
// {
//     if (i == N)
//     {
//         return;
//     }

//     toBuy.at(i) = true;
//     helper(N, i + 1, toBuy);

//     toBuy.at(i) = false;
//     helper(N, i + 1, toBuy);
// }

void solve(std::istream &ist, std::ostream &ost)
{
    /* ------- 宣言と入力 ------- */

    int N, M, X;
    ist >> N >> M >> X;

    vector<int> C;
    vector<vector<int>> A;

    for (int i = 0; i < N; i++)
    {
        int input_C;
        ist >> input_C;
        C.emplace_back(input_C);

        A.emplace_back(0);
        for (int j = 0; j < M; j++)
        {
            int input_A;
            ist >> input_A;
            A.at(i).emplace_back(input_A);
        }
    }

    /* ------- 計算 ------- */

    int min_cost = INT_MAX;
    vector<bool> toBuy;
    for(int i= 0; i<N;i++){
        toBuy.emplace_back(0);
    }

    helper(N, 0, toBuy, C, A, M, X, min_cost);

    if (min_cost == INT_MAX)
    {
        ost << "-1" << endl;
        return;
    }

    ost << min_cost << endl;
}

#ifndef WOMAIN
int main()
{
    solve(std::cin, std::cout);
    return 0;
}
#endif


Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define rep(n) for(int i=0;i<n;i+=1)
#define prarr(a,n) rep(n) cout<<a[i]<<endl printf("%s\n"," " );
#define sc(a) scanf("%d",&a);
#define scl(a) scanf("%lld",&a);
#define scf(a) ascanf("%f",&a);
#define ff first
#define ss second
#define pu push_back
#define inf 1000000001
#define MOD 1000000007 
#define INF 100000000000001
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    int a[100010];
    cin>>n;
    int cnt =0,mi = INT_MAX;
    ll sum = 0;
    rep(n) 
    {
    cin>>a[i];
    if(a[i]<0)cnt++;
    mi = min({mi,abs(a[i])});
    sum+=abs(a[i]);
    }
    // cout<<mi<<endl;
    if(cnt%2==0)
    	cout<<sum;
    else
    	cout<<sum-2*mi;
    return 0;

}
    

Measured memory_bytes: 640
#include <bits/stdc++.h>  // g++ -std=c++14 -o a a.cpp

using namespace std;

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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repto(i, n) for(int i = 0; i <= (n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007
#define DEBUG(x) cout << #x << ": " << x << endl;

__attribute__((constructor))
void initial() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

int main() {
    int N, K;
    cin >> N >> K;
    int H[100001] = {0};
    int mincost[100001] = {INF};
    rep(i, N) {
        int hi;
        cin >> hi;
        H[i] = hi;
    }

    mincost[0] = 0;
    for (int i = 1; i < N ; i++) {
        int localmin = INF;
        for (int j = 1; (0 <= (i - j) && j <= K); j++) {
            localmin = min(
                localmin,
                mincost[i-j] + abs(H[i] - H[i-j])
            );
        }
        mincost[i] = localmin;
        // DEBUG(i);
        // DEBUG(mincost[i]);
    }

    cout << mincost[N-1] << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int c,a,b,x,ans;
int main()
{
    cin>>a>>b>>c>>x;
    for(int i=0;i<=a;i++)
    {
        for(int j=0;j<=b;j++)
        {
            for(int k=0;k<=c;k++)
            {
                if((500*i)+(100*j)+(50*k)==x)ans++;
            }
        }
    }
    cout<<ans;



    return 0;
}


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

using namespace std;

int main(){
  int n,count = 0;
  string s;
  char pref,next;
  cin >> s;
  n = s.size();
  for(int i = 0; i < n; i++){
	if(s[i] == '?')
      s[i] = 'D';
  }
  cout << s << endl;
  return 0;
}

Measured memory_bytes: 3748
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

typedef struct{
	int id,timeSum;
}data;

bool operator<(const data &a,const data &b){
	return (a.timeSum<b.timeSum);
}

int main(void){
	int n,m,s;
	
	while(cin>>n,n){
		vector<data> inp(n);
		
		for(int i=0;i<n;i++){
			cin>>inp[i].id;
			inp[i].timeSum=0;
			for(int j=0;j<4;j++){
				cin>>m>>s;
				inp[i].timeSum=inp[i].timeSum+m*60+s;
			}
		}
		sort(inp.begin(),inp.end());
		cout<<inp[0].id<<endl<<inp[1].id<<endl<<inp[n-2].id<<endl;
	}
	return 0;
}

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

int main() {
	int n, m, x; cin >> n >> m >> x;
	vector<bool>a(100,false);
	for (int i = 0; i < m; i++) {
		int tmp; cin >> tmp;
		a[tmp] = true;
	}

	int ans1 = 0;
	for (int i = x; i < n; i++) {
		if (a[i])ans1++;
	}

	int ans2 = 0;
	for (int i = x; i > 0; i--) {
		if (a[i])ans2++;
	}
	cout << min(ans1, ans2) << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define REP(i,st,ed) for(register int i=st,i##end=ed;i<=i##end;++i)
#define DREP(i,st,ed) for(register int i=st,i##end=ed;i>=i##end;--i)
typedef long long ll;
inline int read(){
	int x;
	char c;
	int f=1;
	while((c=getchar())!='-' && (c>'9' || c<'0'));
	if(c=='-') c=getchar(),f=-1;
	x=c^'0';
	while((c=getchar())>='0' && c<='9') x=(x<<1)+(x<<3)+(c^'0');
	return x*f;
}
inline ll readll(){
	ll x;
	char c;
	int f=1;
	while((c=getchar())!='-' && (c>'9' || c<'0'));
	if(c=='-') c=getchar(),f=-1;
	x=c^'0';
	while((c=getchar())>='0' && c<='9') x=(x<<1ll)+(x<<3ll)+(c^'0');
	return x*f;
}
int num(int x){
	int nn=0;
	while(x) nn+=x%10,x/=10;
	return nn;
}
int main(){
	int n=read();
	int l=read(),r=read();
	int sum=0;
	REP(i,1,n)
		if(num(i)>=l && num(i)<=r)
			sum+=i;
	printf("%d\n",sum);
	return 0;
}

Measured memory_bytes: 256
N=int(input())
P=list(map(int,input().split()))

a=0
cnt=0
for i in range(N):
   
    if P[i]!=i+1:
        if cnt==0:
            a=P[i]
            ai=i
            cnt=1
        elif cnt==1:
            P[ai]=P[i]
            P[i]=a
            break

for i in range(N):
    if P[i]!=i+1:
        print("NO")
        break
    if i+1==N:
        print("YES")
    

Measured memory_bytes: 3064
N, K = map(int, input().split())

mods = [0] * K
for i in range(N):
  mods[i%K] += 1
#print(mods)

ans = 0
if K % 2 == 0:
  ans += mods[K//2 -1] ** 3

ans += mods[K-1] ** 3

print(ans)

Measured memory_bytes: 4596
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}

int main() {
    // Write Your Code Below
    ll a, b, t;
    cin >> a >> b >> t;
    int times = t/a;
    int cnt;
    for(int i=0; i<times; i++){
        cnt++;
    }
    cout << cnt*b << endl;
}


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

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

Measured memory_bytes: 256
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);

    while(true){ 
    	
    	int n = scan.nextInt();
        int x = scan.nextInt();
    	if(n==0 && x==0){
	 		break;
	 	}
    	else{
        int first;
        int second;
        int third;
        int count = 0;

        for(first = 1; first <= (n-2); first++){
        	 for(second = (first+1); second <= (n-1); second++){
        	 	for(third = (second+1); third <= n; third++) {
      
        	 	if(n==0 && x==0){
        	 		break;
        	 	}
        		if((first + second + third) == x){
        			count++;
        		}
        		}
        	}
        }
        System.out.println(count);
    	}
    }
 	}
}

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

int main()
{
	long long x,a,b;
	cin>>x>>a>>b;
	long long ac,bc;
	if(x>a) ac=x-a;
	else ac=a-x;
	if(x>b) bc=x-b;
	else bc=b-x;
	if(ac>bc) cout<<"B";
	else cout<<"A";
	return 0;
}

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

int main()
{
    int n, k, l, tmp, res = 0;
    cin >> n >> k;
    vector<int> snu(n);

    for(int i = 0; i < k; ++i)
    {
        cin >> l;
        for(int j = 0; j < l; ++j)
        {
            cin >> tmp;
            snu[tmp - 1]++;
        }
    }

    for(auto i: snu)
    {
        res += i ? 0 : 1;
    }

    cout << res << "\n";
}

Measured memory_bytes: 3580
n,m=map(int,input().split())
swhich=[list(map(int,input().split())) for _ in range(m)]
p=list(map(int,input().split()))
ans=0
for i in range(2**n):
    cnt=[0]*m
    for j in range(n):
        if (i>>j)&1 == 1:
            for k in range(m):
                if j+1 in swhich[k][1:]:
                    cnt[k]+=1
    cnt=[i%2 for i in cnt]
    if cnt==p:
        ans+=1
print(ans)

Measured memory_bytes: 3064
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
from pprint import pprint
from copy import deepcopy
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce
from pprint import pprint


sys.setrecursionlimit(2147483647)
INF = 10 ** 20
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007


def gcd(i, j):
    while j:
        i, j = j, i % j
    return i


n, a_ratio, b_ratio = LI()
solution = LIR(n)
dp = {(0, 0): 0}
for a, b, c in solution:
    for (ai, bi), ci in list(dp.items()):
        # listにしないとduring iteration dictionary changeみたいなerrorでる。
        # メモ：defaultdictはもともと存在しないkeyを参照するだけでkey:valueが追加される。
        # これによって、key: INFが追加されるのはまずい。だからgetで
        dp[(ai + a, bi + b)] = min(dp.get((ai + a, bi + b), INF), ci + c)


ans = INF
for i in range(1, max(400 // a_ratio, 400 // b_ratio)):
    ans = min(ans, dp.get((a_ratio * i, b_ratio * i), INF))

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





Measured memory_bytes: 46300
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

const int MAXN = 1024;

int a[MAXN];

int main() {
    int n,d,x; cin>>n>>d>>x;
    for(int i = 0; i < n; ++i) cin>>a[i];
    int res = x;

    for(int i = 0; i < n; ++i) {
        for(int j = 0;; ++j) {
            if(j * a[i] + 1 > d) break;
            ++res;
        }
    }

    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
main()
{
    int temp1,temp2,n,flag=0;
    scanf("%d",&n);temp1=n;temp2=n;
    if(temp1>7)
   {  while(1)
    {
        if(temp1%7==0 && (n-temp1)%4==0)
        {  flag=1;
            break;
        }
        else
        {
            temp1--;
            if(temp1==0)break;
        }

    }
   }
   if(temp2>4)
   {
    while(1)
    {
        if(temp2%4==0&& (n-temp2)==0)
        {   flag=1;
            break;
        }
        else
        {
            temp2--;
            if(temp2==0)break;
        }

    } }

    if(flag==1 || n%7==0 || n%4==0)
    {
        printf("Yes\n");
    }
    else
    {
        printf("No\n");
    }
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
int main() {
    ll n, k; cin >> n >> k;
    ll ans = k;
    rep(i, n-1) ans *= k-1;
    cout << ans;
}


Measured memory_bytes: 256
using System;
using System.Linq;
class Test{
  public static void Main(){
    var SW = Console.ReadLine().Split(" ").Select(n => int.Parse(n)).ToList();
    if(SW[0]>SW[1]){
      Console.Write("safe");
    }else{
      Console.Write("unsafe");
    }
  }
}

Measured memory_bytes: 28312