akhauriyash/Code-Regression huggingface dataset:
count_500 = int(input())
count_100 = int(input())
count_50 = int(input())
target = int(input())
count = 0

for num_50 in range(0, count_50 + 1):
    total = num_50 * 50
    if total == target:
        count += 1
        continue
    for num_100 in range(0, count_100 + 1):
        total_2 = num_50 * 50 + num_100 * 100
        if total_2 == target:
            count += 1
            continue
        for num_500 in range(0, count_500+1):
            total_3 = num_50 * 50 + num_100 * 100 + num_500 * 500
            if total_3 == target:
                count += 1
                continue
print(count)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using pint = pair<int,  int>;
using pll = pair<ll, ll>;
using edge = pair<int, ll>;
using Graph = vector<vector<int>>; 
using WeightedGraph = vector<vector<edge>>;
const ll INF = 1LL << 60;
const int INF32 = 1 << 29;
const ll MOD = 1000000007;

int main(){
  string s;cin >> s;
  int ans= 700;
  for(int i = 0; i < 3; ++i){
    if(s[i]=='o')ans += 100;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<vector<int> > Graph;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

    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;}
const ll INF = 1e16;

int main(){
    int n;
    cin >> n;
    vector<ll>ans;
    vector<ll>late;
    rep(i,n){
        ll a;
        cin >> a;
       
        if(i%2==1){
            ans.push_back(a);
        }
        else{
            late.push_back(a);
        }
    }
    if(n%2==0){
        reverse(ans.begin(),ans.end());
        ans.insert(ans.end(),late.begin(),late.end());
        rep(i,n){
            cout << ans[i] << endl;
        }
    }
    else{
        reverse(late.begin(),late.end());
        late.insert(late.end(),ans.begin(),ans.end());
        rep(i,n){
            cout << late[i] << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 4700
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
#define rep(i,n) for(int i = 0;i < (n);i++)
using namespace std;

int main(){
    long int N;
    cin >> N;
    
    long int A = 1;
    long int B = N;
    for(long int i = 0; i*i <= N;i++){
        if(i > 1){
            if(N % i == 0){
                if(i > N / i){
                    break;
                }
                else{
                 A = i;
                 B = N / (long)i;
                }
            }
        }
    }
    cout << A + B - 2<< endl;
}

Measured memory_bytes: 256
#!/usr/bin/python3

from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def main():
    N, C = map(int, input().split())

    sushi = []
    for _ in range(N):
        x, v = map(int, input().split())
        sushi.append((x, v))

    cs_x, cs_v, cs_p = [0] * (N + 1), [0] * (N + 1), [0] * (N + 1)
    for i in range(N):
        cs_x[i + 1] = sushi[i][0]
        cs_v[i + 1] = cs_v[i] + sushi[i][1]
        cs_p[i + 1] = max(cs_p[i], cs_v[i + 1] - cs_x[i + 1])

    cs_x_rev, cs_v_rev, cs_p_rev = [0] * (N + 1), [0] * (N + 1), [0] * (N + 1)
    for i in range(N):
        cs_x_rev[i + 1] = C - sushi[-i - 1][0]
        cs_v_rev[i + 1] = cs_v_rev[i] + sushi[-i - 1][1]
        cs_p_rev[i + 1] = max(cs_p_rev[i], cs_v_rev[i + 1] - cs_x_rev[i + 1])


    # print(cs_x)
    # print(cs_v)
    # print(cs_x_rev)
    # print(cs_v_rev)

    # right
    ans = 0
    for i in range(1, N + 1):
        total_x = cs_x[i]
        total_v = cs_v[i]
        profit = total_v - total_x
        ans = max(ans, profit)

        profit -= total_x
        profit += cs_p_rev[N - i]
        ans = max(ans, profit)

    # left
    for i in range(1, N + 1):
        total_x = cs_x_rev[i]
        total_v = cs_v_rev[i]
        profit = total_v - total_x
        ans = max(ans, profit)

        profit -= total_x
        profit += cs_p[N - i]
        ans = max(ans, profit)

    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 39584
#include <unordered_map>
#include <functional>
#include <algorithm>
#include <iostream>
#include <climits>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#define mod 1000000007
using namespace std;
#define ll long long int
int main()
{
  // while(t--){
    int n;
    cin>>n;
    ll a[n];
    for(int i=0;i<n;i++)
    {
      cin>>a[i];
    }
    sort(a,a+n);
    ll cnt=0;
    for(int i=0;i<n;i++){
      for(int j=i+1;j<n;j++){
        for(int k=j+1;k<n;k++){
          if(a[i]!=a[j] and a[j]!=a[k])
          {
            if(a[i]+a[j]>a[k])
              cnt++;
          }
        }
      }
    }
    cout<<cnt<<endl;
}



Measured memory_bytes: 3616
x, n=map(int, input().split())
p=list(map(int, input().split()))

i=0

while i<200:
    
    jud=1
    con=x-i

    for j in range(n):

        if con==p[j]:
            jud=0
            break

    if jud==1:
        print(con)
        break

    jud=1
    con=x+i

    for k in range(n):

        if con==p[k]:
            jud=0
            break

    if jud==1:
        print(con)
        break

    i+=1

Measured memory_bytes: 9208
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <vector>
#include <sstream>
#include <string>
#include <cstdio>
#include <array>

using namespace std;

//???????????°??????TEST????????????????????¬???????????????????????????????????¢????????????
//#define TEST //*******************************************************************************************************************************************

//?????????????????¨??§?????\????????????????????????????????°?????????????¨???????????????????dout???????????????????????§???????????¬??????????????????????????????????????????
#ifdef TEST
    #define dout cout
#else
    stringstream dummy; //???????????°??????dout?????????????????????????????????
    #define dout dummy
#endif


int main(void) {
    int NumOfData;
    cin >> NumOfData;
    
    int cnt = 0; //swap?????°??????????????¨
    
    int a[NumOfData];
    for(int i=0; i<NumOfData; i++) {
        cin >> a[i];
    }
    
    //display a[]
    for(int k=0; k<NumOfData; k++) {
        if(k==0) dout << a[k];
        else dout << " " << a[k];
    }
    dout << endl;
    
    
    
    //selection sort procedure
    
    for(int i=0; i<NumOfData-1; i++){
        
        //i??????????????????i???????°????????????????????????§??????????°???????j_min?????¢???
        int j_min = i;
        for(int j=i+1; j<NumOfData; j++){
            if(a[j_min]>a[j]){
                j_min = j;
            }
        } //end of j-loop
        
        //swap i & j_min
        if( i != j_min ) cnt++; //?????????swap???????????¨?????????swap?????°????????????
        int tmp = a[i];
        a[i] = a[j_min];
        a[j_min] = tmp;

        //display a[]
        for(int k=0; k<NumOfData; k++) {
            if(k==0) dout << a[k];
            else dout << " " << a[k];
        }
        dout << endl;
        
    } //end of i-loop
    
    
    //display a[]
    for(int k=0; k<NumOfData; k++) {
        if(k==0) cout << a[k];
        else cout << " " << a[k];
    }
    cout << endl;
    
    cout << cnt << endl;
    
    return 0;
}

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

int main() {
    char n[4];
    cin >> n;
    for (int i = 0; i < 3; ++i) {
        if (n[i] == '1') n[i] = '9';
        else if (n[i] == '9') n[i] = '1';
    }
    cout << n;
}

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

#define rep(i,n) for(i = 0;i < n;++i)
#define all(v) v.begin(), v.end()
using ll = long long;

int main()
{
    ll i,j;
    ll n,k,r,s,p;
    string t;
    cin >> n >> k >> r >> s >> p >> t;
    auto score = [&](ll ind){
        if(t.at(ind) == 'r') return p;
        else if(t.at(ind) == 's') return r;
        else return s;
    };
    ll ans = 0;
    for(i = 0;i < k;++i){
        bool last = false;
        for(j = i;j < n;j += k){
            if(j >= k && t.at(j-k) == t.at(j) && last) last = false;
            else{
                ans += score(j);
                last = true;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vll vector<ll>
#define rep(c, a, b) for(ll c=a;c<b;c++)
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;

int main(int argc, char const *argv[]) {
  ll a, b, c;std::cin >> a>> b >> c;
  for(int i=1;i<=1000;i++){
    if((i*a)%b==c){
      std::cout << "YES" << '\n';
      return 0;
    }
  }
  std::cout << "NO" << '\n';
  return 0;
}


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

#define int long long

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

#define endl '\n'
#define fi first
#define se second
#define all(v) v.begin(), v.end()

#define print(x)    cout << #x << " : " << x << endl;
#define darr(a,n)   for(int i=0; i<n; i++) cout << a[i] <<' '; cout<< '\n';
#define fast        ios_base::sync_with_stdio (false); cin.tie (nullptr);
#define dvec(vct)   for(auto i : vct) cout << i << " "; cout << endl;

const int maxn = 1e6;
const int mod = 1e9 + 7;
// const int mod = 998244353;


/*****************************************************************************/



void solve() {
    int L; cin >> L;
    cout << fixed << setprecision(20) << (pow(L/3.0, 3)) << endl;
}



/*****************************************************************************/



int32_t main() {
    fast;
    // #ifndef ONLINE_JUDGE
    //     freopen("input.txt", "r", stdin);
    //     freopen("output.txt", "w", stdout);
    // #endif
    auto start = chrono::steady_clock::now();
    solve();

    auto end = chrono::steady_clock::now();
    auto diff = end - start;
    // #ifndef ONLINE_JUDGE
    //     cout << "\n\n";
    //     cout << "TIME : " << chrono::duration<double, milli> (diff).count() << " ms" << endl;
    // #endif
}


Measured memory_bytes: 256
# p = list(map(int, input().split()))
# a, b, c = map(int, input().split())
# n = int(input())
# s = input()
# print(i, end=" ")


n = int(input())
a = list(map(int, input().split()))
ans = 0
mod = 1000000007
sum = 0
for i in range(n):
    sum = sum + a[i]
    sum = sum % mod
    
for i in range(n):
    sum = sum - a[i]
    if sum < 0:
        sum = sum + mod
    ans = ans + a[i] * sum
    ans = ans % mod
print(ans)

Measured memory_bytes: 31344
#include<cstdio>

const int MAX = 105;
int A[MAX];

int main(){
        int N, i;
        scanf("%d", &N);
        for(i=0; i<N; i++){
                scanf("%d", &A[i]);
        }
        int a = A[0], b = A[0];
        for(i=1; i<N; i++){
                if(A[i] < a){
                        a = A[i];
                }
                if(A[i] > b){
                        b = A[i];
                }
        }
        printf("%d", b-a);
        return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
#include <iomanip>
#include <iostream>
#include<string>
#include<vector>
#include<map>
#include<queue>
#include<algorithm>
#include <random>
#include <chrono>

#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;

int main() {
	int n;
	cin >> n;
	long long tmp,cnt=0;
	vector<long long> a(n+1);
	rep(i, n + 1) {
		cin >> a[i];
	}
	int p1,p2;
	rep(i, n) {
		cin >> tmp;
		p1= min(tmp, a[i]);
		tmp -= p1;
		p2 = min(tmp, a[i + 1]);
		a[i + 1] -= p2;
		cnt = cnt + p1 + p2;

		//cout << a[i] << " " << a[i + 1] << " " << cnt << endl;
	}
	cout << cnt;
}

Measured memory_bytes: 1024
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    if len(x) == 0:
        return []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False

def pow_k(x, n):
    ans = 1
    while n:
        if n % 2:
            ans *= x
        x *= x
        n >>= 1
    return ans

"""
def nibu(x,n,r):
    ll = 0
    rr = r
    while True:
        mid = (ll+rr)//2

    if rr == mid:
        return ll
    if (ここに評価入れる):
        rr = mid
    else:
        ll = mid+1
"""

a,b,c,d = m()

aa = -(-c//b)
cc = -(-a//d)
if aa <= cc:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 65372
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,-1,sizeof(x))
const int INF = 1000000001;

int main(){
  int a;
  cin >> a;
  if(a<= 999) cout << "ABC" <<endl;
  else cout << "ABD" <<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <queue>
#include <map>
using namespace std;
typedef long long ll;
const int INF = 1<<30; 
const int MOD = 1e9 + 7;
const int dy[] = {1, 0, -1, 0};
const int dx[] = {0, 1, 0, -1};
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    while(cin >> n, n)
    {
        vector<int> v(n);
        for (int i = 0; i < n; i++) cin >> v[i];
        sort(v.begin(), v.end());
        ll t = 0, ans = 0;
        vector<ll> s;
        for (int i = 0; i < n - 1; i++)
        {
            t += v[i];
            s.push_back(t);
        }
        for(int i = 0; i < s.size(); i++) ans += s[i];
        cout << ans << endl;
    }
    return 0;
}




Measured memory_bytes: 3192
#include<iostream>
#include<iomanip>
//#include<cstdio>
#include<vector>
#include<map>
#include<deque>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cassert>
using namespace std;
typedef long long ll;
const int Nmax=200000;
int N;
ll A[Nmax];

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

	deque<ll> deq;
	for(int i=0; i<N; i++){
		if(i%2==1){
			deq.push_back(A[i]);
		}
		else{
			deq.push_front(A[i]);
		}
	}

	if(N%2==0){
		reverse(deq.begin(), deq.end());
	}

	for(int i=0; i<N; i++){
		cout << deq[i] << (i==N-1 ? '\n' : ' ');
	}
	cout << flush;

	return 0;
}


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

#define PI 3.14159265358979323846264338327950

int main()
{
    int a, b;
    cin >> a >> b;
    int sockets = 1;
    int c = 0;
    while(sockets < b) {
        sockets--;
        c++;
        sockets += a;
    }
    cout << c;
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace abc139_a
{
    class Program
    {
        static void Main(string[] args)
        {
            string S = Console.ReadLine();
            string T = Console.ReadLine();

            int cnt = 0;
            for (int i = 0; i < 3; i++)
            {
                if (S[i] == T[i])
                {
                    cnt++;
                }
            }
            Console.WriteLine(cnt);
        }
    }
}


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

using namespace std;
/**
********************************************************************
******************* Author:Bisnu sarkar ****************************
********************************************************************
**/

#define ull            unsigned long long
#define ll             long long
#define vi             vector<int>
#define pb             push_back
#define mp             make_pair
#define pii            pair<int,int>
#define vit            vector<int> :: iterator
#define sit            set<int> :: iterator
#define vrit           vector<int> :: reverse iterator
#define ff             first
#define ss             second

#define what_is(x)     cerr << #x << " is " << x << endl;

///*....Debugger....*/

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it)
{
    cout << endl ;
}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args)
{
    cerr << *it << " = " << a << ' ' ;
    err(++it, args...);
}

int dx[8]= {1,0,-1,0,-1,-1,1,1};
int dy[8]= {0,1,0,-1,-1,1,-1,1};
int ini()
{
    int x;
    scanf("%d",&x);
    return x;
}
long long inl()
{
    long long x;
    scanf("%lld",&x);
    return x;
}

const int N = (int) 2e5 + 5;
const int inf = (int) 1e9 + 7;
const double pi=2* acos(0.0);
int res[N],a[N];

int main()
{

    int n,i,j,k;
    n=ini();
    k=ini();

    for(int i=1; i<=n; i++)
    {
        cin>>a[i];
        res[i]=inf;
    }
    res[1]=0;
    for(int i=2; i<=n; i++)
    {
        for(int j=i-1,c=1; c<=k and j>=1; j--,c++)
        {
            res[i]=min(res[i],res[j]+abs(a[i]-a[j]));
          //  error(i,res[i])
        }
    }
    cout<<res[n]<<endl;

    return 0;
}






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

using namespace std;
using ll = long long;
using P = pair<int,int>;
#define rep(i,n) for(ll i = 0;i < (ll)n;i++)



int main(){
  
  ll a,b,bb;
  char dust;
  cin >> a >> b >> dust >> bb;
  cout << fixed << setprecision(20);
  cout << a*b+a*bb/100 << endl;
  
  
  
  
  return 0;
}

Measured memory_bytes: 3600
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<functional>
#include<cstring>
using namespace std;
int main(void){
	int i,j,len,flg[26],f;
	char s[100001],al[]="abcdefghijklmnopqrstuvwxyz";
	cin>>s;
	for(i=0;i<26;i++)flg[i]=1;
	len=strlen(s);
	for(i=0;i<len;i++){
		for(j=0;j<26;j++){
			if(s[i]==al[j]){
				flg[j]=0;
				break;
			}
		}
	}
	f=0;
	for(i=0;i<26;i++){
		if(flg[i]==1){
			cout<<al[i]<<endl;
			f=1;
			break;
		}
	}
	if(f==0) cout<<"None"<<endl;
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;

int main(){
  int a,b;
  cin>>a>>b;
  if (a*b%2==0){
    cout<<"Even"<<endl;
  }else{
    cout<<"Odd"<<endl;
  }
  return 0;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<typename S, typename T>
void xmin(S&a, T const&b){if(b<a) a=b;}
template<typename S, typename T>
void xmax(S&a, T const&b){if(b>a) a=b;}

signed main()
{
    #ifdef LOCAL_RUN
    freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false);
    int TTT; cin >> TTT; while(TTT--){
    #else
    cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false);
    #endif // LOCAL_RUN
    int T; cin >> T; while(T--){

        ll a, b, c, d;
        cin >> a >> b >> c >> d;
        ll g = __gcd(b, d);
        ll n = c - (c%g) + a%g;
        if(n <= c) n+=g;
        if(n-g > c) n-=g;
        if(a>=b && n >= b && d>=b){
            cout << "Yes\n";
        } else {
            cout << "No\n";
        }
    }


    #ifdef LOCAL_RUN
    cout << endl;
    }
    #endif // LOCAL_RUN
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
using namespace std;
#define x first
#define y second
#define dbg(x) cout << #x << '=' << x << '\n';
#define ll long long
#define pi pair<int,int>
#define pl pair<ll,ll>
#define pd pair<double,double>
#define ld long double
#define pld pair<ld,ld>
#define lg length()
#define sz size()
#define pb push_back
#define MAXN 100005
#define INF 1000000005
#define LINF 1000000000000000005
#define x1 xdddddddddddddddddd
#define y1 ydddddddddddddddddd
#define eps 0.0000000000000000001

ll n,m,x,y,v[705],a,b,pos=1,t[705][705];

vector <ll> g[705],h[705];

vector <pi> s;

set <int> f;

void DFS(int nod, int p){
    if(v[nod]){
        if(v[nod]!=p) pos=0;
        return;
    }
    v[nod]=p;
    int k;
    if(p==1) k=2,a++;
    else k=1,b++;
    for(int i : h[nod]) DFS(i,k);
}

int c(int x){
    return x*(x-1)/2;
}

int32_t main(){
    ios_base :: sync_with_stdio(0); cin.tie(); cout.tie();
    cin >> n >> m;
    for(int i=1;i<=m;i++){
        cin >> x >> y;
        g[x].pb(y);
        g[y].pb(x);
    }
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++) f.insert(j);
        for(int j : g[i]) f.erase(j);
        f.erase(i);
        for(int j : f) h[i].pb(j);
    }
    for(int i=1;i<=n;i++){
        if(!v[i]) a=0,b=0,DFS(i,1),s.pb({a,b});
    }
    if(!pos){
        cout << -1;
        return 0;
    }
    t[0][0]=1;
    for(int i=1;i<=s.sz;i++){
        for(int j=s[i-1].x;j<=n;j++){
            t[j][i]=max(t[j][i],t[j-s[i-1].x][i-1]);
        }
        for(int j=s[i-1].y;j<=n;j++){
            t[j][i]=max(t[j][i],t[j-s[i-1].y][i-1]);
        }
    }
    for(int i=n/2;i>=0;i--){
        if(t[i][s.sz]){
            cout << c(i)+c(n-i);
            return 0;
        }
    }
}


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

int main(){
    bool nonprime[10001] = {};
    nonprime[0] = nonprime[1] = true;
    int sum[10001] = {}, pos = 0;
    for(int i = 2; i < 10001; i++){
        if(nonprime[i]) continue;
        sum[pos+1] = sum[pos] + i;
        pos++;
        for(int j = i+i; j < 10001; j+=i)   nonprime[j] = true;
    }

    int ans[10001] = {};
    for(int i = 0; i < pos; i++){
        for(int j = i; j < pos; j++){
            if(sum[j]-sum[i] > 10000)   break;
            ans[sum[j]-sum[i]]++;
        }
    }

    int n;
    while(cin >> n, n)  cout << ans[n] << endl;
    
    return 0;
}


Measured memory_bytes: 3168
/* ---------- STL Libraries ---------- */
// IO library
#include <cstdio>
#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>
#include <random>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>

/* ---------- Namespace ---------- */
using namespace std;

/* ---------- Type ---------- */
using ll = long long;
#define int ll
#define P pair<ll, ll>

/* ---------- Constants  */
const ll MOD = 1e9 + 7;
const int INF = 1LL << 55;
// const double PI = acos(-1);
// const double EPS = 1e-10;
// mt19937 mert(LL(time(0)));

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */
int dfs(int rank, int cnt) {
    if (rank == 0) return 1;

    int total_cnt = (int) pow(2, rank + 2) - 3;
    int part_cnt = (total_cnt - 3) / 2;

    if (cnt == 1) return 0;
    if (cnt <= 1 + part_cnt) return dfs(rank-1, cnt - 1);
    if (cnt == 1 + part_cnt + 1) return dfs(rank-1, part_cnt) + 1;
    if (cnt <= 2 + part_cnt * 2) return dfs(rank-1, part_cnt) + 1 + dfs(rank-1, cnt - 2 - part_cnt);
    return dfs(rank-1, part_cnt) * 2 + 1;
}

signed main() {
    int L, X;
    cin >> L >> X;
    cout << dfs(L, X);

    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
 
using ll=long long;
 
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define pb push_back
#define eb emplace_back
#define a first
#define b second
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed
const ll MOD = 998244353;


int main() {
    string s;
    cin >> s;
    int eidx = s.size();
    vector<string> words{"dream", "dreamer", "erase", "eraser"}; 
    while (eidx > 0) {
        bool check = true; 
        for (const auto& c : words) {
            int ws = c.size();
            if (check && eidx >= ws && s.compare(eidx-ws, ws, c) == 0) {
                eidx -= ws;
                check = false;    
            }  
        }
        if (check) break;
    } 
    string ret = (eidx == 0 ? "YES" : "NO");
    cout << ret << endl;
    return 0;
}

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

int main(){
	ll n,m;
	while(cin>>n>>m){
		if(n==0&&m==0)break;
		ll s[m+5],k[m+5];
		ll c[m+5][n+5];
		for(ll i=0;i<m;i++){
			cin>>s[i]>>k[i];
			for(ll j=0;j<k[i];j++){
				cin>>c[i][j];
//				c[i][j]--;
			}
		}
		ll maxans[n+5];
		ll minans[n+5];
		memset(maxans,0,sizeof(maxans));
		memset(minans,0,sizeof(minans));
		for(ll i=0;i<m;i++){
			for(ll j=0;j<k[i];j++){
				maxans[c[i][j]]+=s[i];
				//cout<<maxans[c[i][j]]<<endl;
			}
		}

		ll M=0;
		ll v=0;
		bool isok=false;
		for(ll i=1;i<n+1;i++){
			if(M<=maxans[i]){
				M = maxans[i];
				v = i;
				if(M==maxans[i])isok=true;
			}
		}
		ll mm=1e9;
		bool flag=false;
		for(ll i=0;i<m;i++){
			if(k[i]==1)minans[c[i][0]]+=s[i];
		//	cout<<minans[c[i][0]]<<endl;
		}
		for(ll i=1;i<n+1;i++){
			if(i==v)continue;
			mm = min(minans[i],mm);
		}
		//cout<<"M:"<<M<<" m:"<<mm<<endl;
		cout<<M-mm+1<<endl;
	}
}



Measured memory_bytes: 22580
N = int(input())
S = sorted([int(input()) for i in range(N)])

sum_s = sum(S)
if sum_s % 10 != 0:
        print(sum_s)
        exit()
else:
        for i in range(N):
                if S[i] % 10 != 0:
                        print(sum_s-S[i])
                        exit()

print(0)

Measured memory_bytes: 2940
import java.util.*;
 
public class Main{
     public static void main(String[] args){
         Scanner in = new Scanner(System.in);
        int n=in.nextInt();
        int[] b = new int[n];
        int[] c=new int[n];
       int[] used=new int[n];
      int ans=0;
       HashMap<Integer,Integer> map1=new HashMap<Integer,Integer>();
       HashMap<Integer,Integer> map2=new HashMap<Integer,Integer>();
       for(int i=0;i<n;i++){
         int a = in.nextInt();
         b[i]=in.nextInt();
        map1.put(b[i],a);
      }
 for(int i=0;i<n;i++){
       c[i]=in.nextInt();
         int d = in.nextInt();
        map2.put(c[i],d);
      }
     Arrays.sort(b);
     Arrays.sort(c);
    for(int i=0; i<n;i++){
      for(int j=n-1;j>=0;j--){
         if(c[i]>map1.get(b[j]) && map2.get(c[i])>b[j]&&used[j]==0){
          ans++;
          used[j]=1;
           break;
       }
     }
}
 System.out.println(ans);
    }}

Measured memory_bytes: 22228
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
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce


sys.setrecursionlimit(2147483647)
INF = 10 ** 13
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


n, k = LI()
acc = [[0] * 3 * k for _ in range(2 * k)]
for _ in range(n):
    x, y, c = LS()
    x = int(x); y = int(y)
    if c == 'W':
        x += k
    x %= 2 * k
    y %= 2 * k
    acc[y][x] += 1
    for i, j in ((1, 1), (1, -1), (-1, 1), (-1, -1), (0, 2)):
        if 0 <= y + k * i < 2 * k and 0 <= x + k * j < 3 * k:
            acc[y + k * i][x + k * j] += 1



acc = [[0] * (3 * k + 1)] + [list(accumulate([0] + acc[y])) for y in range(2 * k)]
for y in range(2 * k):
    for x in range(3 * k + 1):
        acc[y + 1][x] += acc[y][x]


ans = 0
for y in range(k + 1):
    for x in range(2 * k + 1):
        ans = max(ans, acc[y + k][x + k] - acc[y][x + k] - acc[y + k][x] + acc[y][x])


print(ans)

Measured memory_bytes: 137736
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  vector<ii> a;
  int x;
  int64 ret = 0;
  for (int i = 0; i < n; ++i) {
    scanf("%d", &x);
    a.push_back({x, 0});
    ret += (int64)x * (m + 1);
  }
  for (int i = 0; i < m; ++i) {
    scanf("%d", &x);
    a.push_back({x, 1});
    ret += (int64)x * (n + 1);
  }
  sort(a.begin(), a.end(), [](const ii x, const ii y) {
      return x.first < y.first;
    });
  int cnt[2] = {0};
  for (auto& it : a) {
    int x = it.first, k = it.second;
    ret -= (int64)cnt[1 - k] * x;
    ++cnt[k];
  }
  printf("%lld\n", ret);
  return 0;
}


Measured memory_bytes: 3444
using System;

class Program
{
    static void Main()
    {
        string[] input = Console.ReadLine().Split(' ');

        int a = int.Parse(input[0]);
        int b = int.Parse(input[1]);
        int c = int.Parse(input[2]);

		if (a < b && b < c)
		{
			Console.WriteLine("Yes");
		} else
			Console.WriteLine("No");
    }
}


Measured memory_bytes: 8832
#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 <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
using namespace std;
using ll = long long;

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

int main () {
  int a, p;
  cin >> a >> p;
  cout << (3*a+p)/2;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <stack>
#include <complex>
#include <stdlib.h>
#include <stdio.h>
#include <functional>
#include <cfloat>
#include <math.h>


#define fs first
#define sc second

using namespace std;


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


int a[510][510];

void draw(vector<int> v, int n, int level){
    for(int i = 0; i < n; i++){
        for(int j = i+1; j < n; j++){
            if((j - i) % 2 == 1){
                a[v[i]][v[j]] = level;
                a[v[j]][v[i]] = level;
            }
        }
    }
    if(n <= 2){
        return;
    }

    int n2 = 0;
    vector<int> v2;
    for(int i = 0; i < n; i+=2){
        v2.push_back(v[i]);
        n2++;
    }
    draw(v2, n2, level+1);

    int n3 = 0;
    vector<int> v3;
    for(int i = 1; i < n; i+=2){
        v3.push_back(v[i]);
        n3++;
    }
    draw(v3, n3, level+1);
}


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

    vector<int> v;
    for(int i = 1; i <= N; i++){
        v.push_back(i);
    }

    draw(v, N, 1);

    for(int i = 1; i <= N-1; i++){
        for(int j = i+1; j <= N; j++){
            cout << a[i][j] << " ";
        }
        cout << endl;
    }



    return 0;
}


Measured memory_bytes: 1536
import java.io.PrintWriter;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		PrintWriter pr = new PrintWriter(System.out);
		int m = sc.nextInt();
		while(m-->0){
			String t = sc.next();
			if(t.length()==1) pr.println(1);
			Set<String> train = new HashSet<String>();
			train.add(t);
			for(int k=0;k<t.length();k++){
				String d1 = t.substring(0, k);
				String d2 = t.substring(k, t.length());
				StringBuilder sb1 = new StringBuilder(d1);
				StringBuilder sb2 = new StringBuilder(d2);
				String rd1 = sb1.reverse().toString();
				String rd2 = sb2.reverse().toString();
				train.add(d2+d1);
				train.add(d1+rd2);
				train.add(rd2+d1);
				train.add(rd1+d2);
				train.add(d2+rd1);
				train.add(rd1+rd2);
				train.add(rd2+rd1);
			}
			pr.println(train.size());
		}
		pr.flush();
		sc.close();
	}
}

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

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'
#define rep(i,n) for(int_fast32_t i = 0; i < ((int_fast32_t)(n)); i++)   // 0-indexed昇順
#define rep1(i,n) for(int_fast32_t i = 1; i <= ((int_fast32_t)(n)); i++) // 1-indexed昇順
#define rrep(i,n) for(int_fast32_t i = ((int_fast32_t)(n)-1); i >= 0; i--)  // 0-indexed降順
#define rrep1(i,n) for(int_fast32_t i = ((int_fast32_t)(n)); i >= 1; i--)   // 1-indexed降順
#define all(x) (x).begin(),(x).end()

using namespace std;

template<typename T>
using vec = vector<T>;
using i32 = int_fast32_t;
using i64 = int_fast64_t;
using u32 = uint_fast32_t;
using u64 = uint_fast64_t;
using ll = long long;
using ld = long double;
using vi = vec<int_fast32_t>;
using vl = vec<int_fast64_t>;
using vld = vec<ld>;
using vii = vec<vi>;  // 2次元配列
using PII = pair<int_fast32_t, int_fast32_t>;

template<class T>
using maxheap = std::priority_queue<T>;
template<class T>
using minheap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

template<class T,class U> inline bool chmax(T &a, const U &b){if(a<b){a=b;return 1;}return 0;}
template<class T,class U> inline bool chmin(T &a, const U &b){if(a>b){a=b;return 1;}return 0;}

const ld Pi = std::acos(-1.0L);
constexpr ll infll = (1LL<<62)-1;
constexpr int inf = (1<<30)-1;
const int mod = 1000000007;
// const int mod = 998244353;


/*FUNCs=================================================*/


/*MAIN==================================================*/
signed main(){
    int START_TIME = clock();
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化
//    cout << fixed << setprecision(15);

    i32 h1,m1, h2, m2, k;
    string s,t;

    cin >> h1>> m1>> h2 >> m2 >> k;
    i32 ans1 = h2 * 60 + m2 - k - h1 * 60 - m1;

    cout << max<i32>(ans1, 0) << '\n';




    // printf("ExecutionTime: %d /ms\n",1000*(int)((clock()-START_TIME)/CLOCKS_PER_SEC));
}


Measured memory_bytes: 3672
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#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>

using namespace std;

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

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

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long ll;

//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) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) 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(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

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

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

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

int main() {
    ll c_num, s_num;
    ll N, M;
    cin >> N >> M;
    if( 2 * N  > M) {
            cout << M / 2;
        
    } else if(2 * N <= M) {
        cout << N + (M - 2 * N) / 4;
    }
    return 0;
}


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


int main() {
    int k,a,b,i;
    cin >> k  >> a >> b;
    bool flg = false;
    for(i=a;i<=b;i++){
        if(i%k == 0){
            flg = true;
            break;
        }
    }
    cout<<(flg ? "OK":"NG")<< endl;
    return 0;
}

Measured memory_bytes: 3624
#include <stdio.h>

int main(void){
  
  int n , m , Q;
  scanf("%d %d %d",&n,&m,&Q);
  
  int a[Q],b[Q],c[Q],d[Q];
  for(int i = 0;i < Q;i ++){
    scanf("%d %d %d %d",&a[i],&b[i],&c[i],&d[i]);
  }
 
  int A[11] , max = 0 ,count = 0;
  
  for(int i = 1;i <=m;i ++){
   A[1] = i;
    for(int j = i;j <=m;j ++){
       A[2] = j;
       for(int k = j;k <=m;k++){
         A[3] = k;
        for(int l = k;l <=m;l++){
          A[4] = l;
          for(int o = l;o <=m;o++){
            A[5] = o;
            for(int q= o;q<=m;q++){
              A[6] = q;
              for(int r = q;r<=m;r++){
                A[7] = r;
                for(int s = r;s<=m;s++){
                  A[8] = s;
                  for(int t =s;t <=m;t++){
                    A[9] = t;
                    for(int u =t;u<=m;u++){
                      A[10] = u;
                      count = 0;
                      for(int v = 0;v < Q;v ++){
                        if(A[b[v]] - A[a[v]] == c[v]){
                          count += d[v];
                        }
                      }
                        if(max<count){
                          max = count;
                        }
                     }}}}}}}}}}
  printf("%d",max);
  
  return 0;
}


Measured memory_bytes: 1732
#include <stdio.h>

int abs(int X){
	if(X>0){
		return X;
	}else{
		return -X;
	}
	
}

int main(void) {
	int A, B, C, D; // D is distance
	int OK[3]={0,0,0};
	
	
	scanf("%d %d %d %d",&A,&B,&C,&D);
	
	if(abs(A-B)<D+1){
		OK[0]=1;
	}
	if(abs(A-C)<D+1){
		OK[2]=1;
	}
	if(abs(B-C)<D+1){
		OK[1]=1;
	}
	
	if(OK[2]==1){
		printf("Yes\n");
	}else if(OK[0]==1&&OK[1]==1){
		printf("Yes\n");
	}else{
		printf("No\n");
	}
	
	
	return 0;
}


Measured memory_bytes: 128
#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <complex>
#include <iterator>
#include <array>
#include <memory>
#include <stack>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<double,double>pdd;
#define int ll
signed main(){
        int n; cin>>n;
    int ans=0;
    for(int i=1;i*i<=n;i++){
        cmax(ans,i);
    
    }
    cout<<ans*ans<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>

#define MAX 100005
#define N 100

typedef struct{
  char name[N];
  int t;
}P;

P Q[MAX+1];
int head, tail;

void Enqueue(P x){
  if(MAX==tail) tail=0;
  Q[tail]=x;
  tail++;
}

P Dequeue(void){
  if(head==MAX) head=0;
  return Q[head++];
}


int main(){
  int i,q,n,T=0;
  P a;
  scanf("%d %d", &n, &q);

  for (i=0;i<n;i++){
    scanf("%s%d",a.name,&a.t);
    Enqueue(a);
  }

  while(n!=0){
    a=Dequeue();
    if(a.t>q){
      a.t=a.t-q;
      T+=q;
      Enqueue(a);
    }
    else{
      T=T+a.t;
      printf("%s %d\n",a.name,T);
      n--;
    }
  }

  return 0;
}



Measured memory_bytes: 11904
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>

#define FAST ios_base::sync_with_stdio(false); cin.tie(0)
#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<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
typedef long long int ll;
#define iceil(a,b) (x+y-1)/y
#define min(x,y)(x<y?x:y)
 
using namespace std;

ll S(ll x){
	ll sum = 0;
	while(x > 0){
		sum += x%10;
		x /= 10;
	}
	return sum;
}

long long len(long long x)
{
	ll sum=0;
	while (x) {sum++; x/=10;}
	return sum;
}

int main() {
	FAST;
	
	ll n,i,j,f[100005];

	cin>>n;
	int m=0,m2;
	for (i=1;i<=1e15;i*=10)
	{
		// cout << "f["<<m<<"]="<<i-1<<"\n";
		f[++m]=i-1;
	}

	m2=m;
	// cout << "m2="<<m2<<"\n";

	for (i=1;i<=m;i++)
	{
		long long x=1;
		while (x<f[i]) x*=10;
		for (j=1;j<=1000&&j*x+f[i]<=1e15;j++)
		{
			// cout << "f["<<m2<<"]="<<j*x+f[i]<<"\n";
			f[++m2]=j*x+f[i];
		}
	}
	sort(f+1,f+m2+1);
	m2=unique(f+1,f+m2+1)-f-1;
	// cout << "m2=" << m2 <<"\n";
	for (i=1;i<=m2;i++)
	{
		for (j=i+1;j<=m2;j++)
		{
			if (f[i]*S(f[j])>f[j]*S(f[i])) f[i]=0;
			if (f[i]==0) break;
		}
	}
	for (i=2;i<=m2;i++) {
		if (f[i]&&(n--)>0) {
			cout<<f[i]<<endl;
		}
	}
}

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


class Program
{
    static void Main(string[] args)
    {
        // 入力
        //var s = Console.ReadLine();
        //var n = int.Parse(Console.ReadLine());
        int[] nm = Console.ReadLine().Split().Select(int.Parse).ToArray();
        var n = nm[0];
        var m = nm[1];

        int[] a = new int[n];
        int[] b = new int[n];
        for (int i = 0; i < n; i++)
        {
            int[] tmp = Console.ReadLine().Split().Select(int.Parse).ToArray();
            a[i] = tmp[0];
            b[i] = tmp[1];
        }

        int[] c = new int[m];
        int[] d = new int[m];
        for (int i = 0; i < m; i++)
        {
            int[] tmp = Console.ReadLine().Split().Select(int.Parse).ToArray();
            c[i] = tmp[0];
            d[i] = tmp[1];
        }

        int[] ans = new int[n];
        for (int i = 0; i < n; i++)
        {
            var l = int.MaxValue;
            var index = 0;
            for (int j = 0; j < m; j++)
            {
                var tmp = Math.Abs(a[i] - c[j]) + Math.Abs(b[i] - d[j]);
                if (l > tmp)
                {
                    l = tmp;
                    index = j;
                }
            }

            ans[i] = index + 1;
        }

        // 出力
        foreach (var item in ans)
        {
            Console.WriteLine(item);
        }
    }
}

Measured memory_bytes: 28308
//submitted by Himj
#include<bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define pb push_back
#define fi first
#define se second
#define fr(i,s,e) for(i=s;i<e;i++)
#define ms(arr,val) memset(arr,val,sizeof(arr))
using namespace std;

const int mxn=2e5+1;

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

  int t=1;
  //cin>>t;
    while(t--){
      ll n,a,b,i,ans;
      vector<int> arr[3];
      cin>>n>>a>>b;
      fr(i,0,n)
      {
        ll x;
        cin>>x;
        if(x<=a)
          arr[0].pb(x);
        else if(x>a and x<=b)
          arr[1].pb(x);
        else arr[2].pb(x);
      }
      ans=arr[0].size();
      fr(i,0,3)
      ans=min(ans,(ll)arr[i].size());
      cout<<ans;
      
       
    }
  return 0;
  }



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

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

  string s;
  cin >> s;

  string ans = "";
  for (int i = 0; i < s.size(); i++) {
    char c = s[i];

    switch (c) {
      case '0':
        ans += '0';
        break;
      case '1':
        ans += '1';
        break;
      case 'B':
        if (ans.size() > 0) {
          ans.pop_back();
          break;
        }
    }
  }

  cout << ans << endl;

  return 0;
}

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

#define rep(i, n) for(int (i) = 0; i < (n); ++(i))

typedef long long ll;
const ll MOD = 1e9 + 7;

int main() {
  int N;
  std::string S;
  std::cin >> N >> S;

  int ans = 0;
  for(int i = 0; i <= 999; ++i) {
    int v = i;
    std::vector<char> V(3);
    V[0] = '0' + v / 100; v %= 100;
    V[1] = '0' + v / 10; v %= 10;
    V[2] = '0' + v;

    int t = 0;
    for(int j = 0; j < N; ++j) {
      if(S[j] == V[t]) {
        ++t;
      }
      if(t == 3) {
        ++ans;
        break;
      }
    }
  }

  std::cout << ans << '\n';
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define max 1000000
#define pb push_back
#define pairs pair<int, int>
#define vi vector<int>
#define vb vector<bool>
#define vii vector<pairs>
#define lb lower_bound
#define ub upper_bound
#define lli long long int
#define endl '\n'
#define FastInput ios_base::sync_with_stdio(false), cin.tie(NULL);
#define Cases  cout << "Case " << ++Case << ": ";
#define __test int tt; int Case=0; cin >> tt; while(tt--)
#define read(x) freopen(x, "r", stdin)
#define write(x) freopen(x, "w", stdout)
#define InputArray(a,n) for(int i=0;i<n;i++) cin >> a[i];
#define CopyArray(a,temp,n) for(int i=0;i<n;i++) temp[i]=a[i];
#define PrintArray(a,n) for(int i=0;i<n;i++) cout << a[i] << " "; cout << endl;
using namespace std;
#define PI 3.14159265358979323846264338327950L


void solve() {
	int a, b, h, m;
	cin >> a >> b >> h >> m;

	long double angle = PI * 2 * ((long double) h / 12.0 + ((long double) (m / 60.0)) / 12.0 - (long double) m / 60.0);

	long double res = (long double) (a * a + b * b) - (long double) (2 * a * b * cosl(angle));

	printf("%20.20Lf\n", sqrtl(res));
}

int main() {
#ifdef Niloy
	read("input.txt");
	write("output.txt");
#endif
	FastInput;
	solve();

	cerr << "time = " << (clock() / CLOCKS_PER_SEC) << " sec" << '\n';
	return 0;
}

Measured memory_bytes: 4088