akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#define MAX 15
#define OUT -9999
int main(void){
	int i,j;
	int ci, cj, cn;
	int counter;
	int sq[MAX+2][MAX+2];
	/*
		[0]ツづ㎆16]ツづ債氾板閉コ
	*/
	int n;
	while(1){
		scanf("%d",&n);
		if(n == 0){break;}
		counter = 0;
		/*init*/
		for(j = 0; j <= MAX+1; j++){
			for(i = 0; i <= MAX+1; i++){
				sq[i][j] = OUT;
			}
		}
		for(j = 1; j <= n; j++){
			for(i = 1; i <= n; i++){
				sq[i][j] = 0;
			}
		}

		/*Process*/
		ci = (n+1)/2;
		cj = (n+1)/2+1;
		cn = 1;
		sq[ci][cj] = cn;
		counter++;

		while(counter < n * n){
			ci++;
			cj++;
			cn++;
			if(ci > n){
				ci = 1;
			} 
			if(cj > n){
				cj = 1;
			}
			while(sq[ci][cj] != 0){
				ci--;
				cj++;
				if(ci < 1){
					ci = n;
				}
				if(cj > n){
					cj = 1;
				}
			}
			sq[ci][cj] = cn;
			counter++;
		}

		/*Output*/
		for(j = 1; j <= n; j++){
			for(i = 1;i <= n; i++){
				if(sq[i][j] == OUT){
					printf("  ##");
				}else{
					printf("%4d",sq[i][j]);
				}
			}
			putchar('\n');
		}
	}

	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#include <iomanip>
#include <map>
#include <cstdlib>
using namespace std;
int main()
{
    string s, ss;
    cin >> s >> ss;
    if (s[0] == ss[2] && s[1] == ss[1] && s[2] == ss[0])
    {
        cout << "YES" << endl;
    }
    else
    {
        cout <<"NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 764
#pragma comment (linker, "/STACK:256000000")
#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 BUGAVOID(x) x
#define rep(...) BUGAVOID(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define sz(c) (int)(c.size())
#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, class U>using vp = vector<pair<T, U>>;
template<class T>using vv = vector<vector<T>>; template<class T, class U>using vvp = vv<pair<T, U>>;
template<class T>vv<T> vvec(const size_t n, const size_t m, const T v) { return vv<T>(n, vector<T>(m, v)); }
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; }
constexpr ll pow2(const int n) { return 1ll << n; }
constexpr int INF = 1 << 28; constexpr ll LINF = 1ll << 60;
constexpr int MAX = 1e5 + 5; constexpr int MOD = 1e9 + 7; constexpr double EPS = 1e-6;
constexpr int dy[4] = { 0,1,0,-1 }; constexpr int dx[4] = { 1,0,-1,0 };
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); }; }aaaa;

string Sd, T;
const string UR = "UNRESTORABLE";

int main() {
    cin >> Sd >> T;
    int Sdsize = Sd.size();
    int Tsize = T.size();

    if (Tsize > Sdsize) {
        write(UR);
        return 0;
    }

    bool replaced = false;
    for (int i = Sdsize - Tsize; i >= 0; --i) {
        bool adj = true;
        for (int j = 0; j < Tsize; ++j) {
            if (Sd[i + j] != T[j] && Sd[i + j] != '?') adj = false;
        }

        if (adj) {
            Sd.replace(i, Tsize, T);
            replaced = true;
            break;
        }
    }

    if (replaced) {
        replace(all(Sd), '?', 'a');
        write(Sd);
    }
    else {
        write(UR);
    }
}

Measured memory_bytes: 256
import Data.Char
import Control.Applicative
page :: [(Int, Char)]
page = [
         (11, 'a'), (12, 'b'), (13, 'c'), (14, 'd'), (15, 'e')
       , (21, 'f'), (22, 'g'), (23, 'h'), (24, 'i'), (25, 'j')
       , (31, 'k'), (32, 'l'), (33, 'm'), (34, 'n'), (35, 'o')
       , (41, 'p'), (42, 'q'), (43, 'r'), (44, 's'), (45, 't')
       , (51, 'u'), (52, 'v'), (53, 'w'), (54, 'x'), (55, 'y')
       , (61, 'z'), (62, '.'), (63, '?'), (64, '!'), (65, ' ')
       ]

solver :: [String] -> [String]
solver [] = []
solver (x:xs) =
  if odd (length x)
    then "NA" : solver xs
  else
    converter x : solver xs

pager :: Int -> Char
pager n = snd . head $ filter (\x -> fst x == n) page

block :: String -> [Int]
block [] = []
block [_] = []
block (x:y:xs) =
  let a = digitToInt x
      b = digitToInt y
  in
      if a < 1 || 6 < a || b < 1 || 5 < b
        then -1 : block xs
      else
        10 * a + b : block xs

converter :: String -> String
converter xs =
  let ys = block xs
  in
      if -1 `elem` ys
        then "NA"
      else
        map pager ys

main :: IO()
main = do
  contents <- lines <$> getContents
  mapM_ putStrLn $ solver contents

Measured memory_bytes: 4028
#include <stdio.h>
int main(void){
    int a, b;
    char c;
    while((scanf("%d %c %d", &a, &c, &b))&&(c != '?')){
        if(c == '+')
            printf("%d\n", a + b);
        else if(c == '-')
            printf("%d\n", a - b);
        else if(c == '*')
            printf("%d\n", a * b);
        else if(c == '/')
            printf("%d\n", a / b);
        else
            return 0;
    }
    return 0;
}


Measured memory_bytes: 600
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using uint = unsigned int;
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printe) FUNC(printw) FUNC(printew) FUNC(printb) FUNC(printd);
#endif

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int w1, w2;
    cin >> w1 >> w2;
    int s1, s2;
    cin >> s1 >> s2;
    int e; cin >> e;
    int lim; cin >> lim;
    vector<int> dp(4001);
    dp[0] = 1;
    for(int i = 0; i <= 3000; i++){
        if(dp[i]){
            dp[i + s1] = dp[i + s2] = 1;
        }
    }
    int a1 = w1 * 100, a2 = 0;
    double maxi = 0;
    for(int i = 0; i <= 30; i++){
        for(int j = 0; j <= 30; j++){
            for(int k = 0; k <= 3000; k++){
                if(dp[k] == 0){ continue; }
                int water = 100 * (w1 * i + w2 * j);
                int sugar = k;
                if(water == 0 || water + sugar > lim){ continue; }
                if(water * e / 100 < sugar){ continue; }
                double d = 100.0 * sugar / (water + sugar);
                if(d > maxi){
                    maxi = d;
                    a1 = water + sugar;
                    a2 = sugar;
                }
            }
        }
    }
    cout << a1 << ' ' << a2 << '\n';
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<string>
using namespace std;
int main()
{
	string s;
	int n;
	cin>>s;
	if(s=="SUN")n=0;
	  else if(s=="MON")n=1;
	  else if(s=="TUE")n=2;
	  else if(s=="WED")n=3;
	  else if(s=="THU")n=4;
	  else if(s=="FRI")n=5;
	  else if(s=="SAT")n=6;
	cout<<7-n;
	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int K = scan.nextInt();
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < K; i++) {
            sb.append("ACL");
        }
        System.out.println(sb.toString());
    }
}


Measured memory_bytes: 35756
#include<bits/stdc++.h>
#include<string>
using namespace std;
#define int long long
#define pb push_back
#define mod 1000000007



int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, d;
    cin>>n>>d;
    d=d<<1|1;
    cout<<(n/d+(n%d>0));
    return 0;
}

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

const int INF = 1<<30;
int pp[3][30];
int a[3] = {2, 3, 5};
int p[3] = {380, 550, 850};
int u[3] = {5, 4, 3};
int d[3] = {80, 85, 88};
int dp[3][51];

void set(){
    int i,j,k;
    for(i = 0; i < 3; i++){
        int price = 0;
        for(j = 0;j < 30; j++){
            if( j%u[i] == 0 ) price = p[i]*j*d[i]/100; 
            else price += p[i];
            pp[i][j] = price;
        }
    }
    for(i = 0; i < 3; i++){
        for(j = 0; j <= 50; j++){
            dp[i][j] = INF;
        }
    }
    for(i = 0; a[0]*i <= 50; i++){
        dp[0][ a[0]*i ] = pp[0][i];
    }
    for(i = 1; i < 3; i++){
        for(j = 0; j <= 50; j++){
            for(k = 0; j-a[i]*k >= 0;k++){
               dp[i][j] = min(dp[i][j], dp[i-1][j-a[i]*k]+pp[i][k]);
            }
        }
    }
}

int main(){
    int n;
    set();
    while(cin>>n,n) cout << dp[2][n/100] << endl;
    return 0;
}

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

int main() {
  int N, K; cin >> N >> K;
  vector<int> A(N);
  for (int i = 0; i < N; i++) cin >> A.at(i);
  vector<long long> B;
  for (int i = 0; i < N-1; i++) {
    long long tmp = 0;
    for (int j = i; j < N; j++) {
      tmp += A.at(j);
      B.push_back(tmp);
    }
  }
  long long ans = 0;
  for (int i = 0; i < 40; i++) {
    vector<long long> cands;
    for (long long v : B) {
      bitset<40> s(v);
      if (s.test(39 - i)) cands.push_back(v);
    }
    if (cands.size() >= K) {
      ans += (1LL << (39 - i));
      B.swap(cands);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 6516
a,b,c=map(int,input().split())
k=int(input())
s=0
if a<=b:
    if b<=c:
        s=c*2**k+a+b
    else:
        s=b*2**k+a+c

if b<=a:
    if a<=c:
        s=c*2**k+a+b
    else:
        s=a*2**k+b+c

if c<=a:
    if a<=b:
        s=b*2**k+a+c
    else:
        s=a*2**k+b+c
print(s)


Measured memory_bytes: 3060
#include <iostream>
#include <cstring>
#include <cstdio>
#include<utility>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
typedef pair<double,double>P_D;
#define PI 3.1415926535897932384626433832795
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define reprev(i, n) for (int i = (int)n - 1; i >= 0; i--)
#define ALL(a)  (a).begin(),(a).end()
#define MAX 100100
#define MAX_N 200100
#define SENTINEL 2000000000
#define NIL -1
const int MOD = 1e9+7;
const int INF = 1 << 29;
const ll INFTY=1000000000000000000LL;
ll n,a[MAX_N];
int main(){
    cin>>n;rep(i,n)cin>>a[i];
    ll sum=0;
    rep(i,n)sum+=a[i];
    ll left[n];
    left[1]=a[0];
    for(int i=1;i<n;i++){
        left[i+1]=left[i]+a[i];
    }
    ll min=INFTY;
    for(int i=1;i<n;i++){
        ll dif=abs(sum-left[i]-left[i]);
        if(min>dif)min=dif;
    }
    cout<<min<<endl;
}

Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define pii pair<int, int>
#define pll pair<long long , long long>
#define pb push_back
#define ll long long
#define ld long double
#define precision(x,d) cout<<fixed<<setprecision(d)<<x
#define fill(a,b) memset((a),(b),sizeof((a)))
#define FAST ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);srand(time(NULL));
ll power(ll x,ll y,ll m){ll r=1;for(;y;y>>=1){if(y&1)r=r*x%m;x=x*x%m;}return r;}
const ll mod = 1e9 + 7;
const ld pi = 3.14159265358979;
    
map<pii, int> mp;

void dfs(int node, int p, vector<int> v[], int prev_c){
    int color = 1;
    for(auto to: v[node]){
        if(to == p) continue;
        if(color == prev_c) color++;
        mp[{node, to}] = color;
        mp[{to, node}] = color;
        dfs(to, node, v, color);
        color++;
    } 
    return;
}

int run_test(){
    int n;
    cin >> n;
    pii arr[n + 1];
    vector<int> v[n + 1];
    for(int i=0; i<n-1; i++){
        int a, b;
        cin >> a >> b;
        arr[i] = {a, b};
        v[a].pb(b);
        v[b].pb(a);
    }
    dfs(1, 1, v, 0);
    int ans =0;
    for(auto x: mp){
        ans = max(ans, x.ss);
    }
    cout << ans << "\n";
    for(int i=0; i<n-1; i++){
        cout << mp[arr[i]] << "\n";
    }
    return 0;
}
    
int main(){
   FAST;
    ll t;
    t = 1;
     
    while(t--){
        run_test();
    }
}

Measured memory_bytes: 22716
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i,n) for (int i = 1; i <= (n); i++)
#define repm(i,m,n) for (int i = m; i < (n); i++)
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;

int main() {
  int N;
  cin >> N;
  
  vi d(N);
  rep(i,N) cin >> d.at(i);
  
  sort(d.begin(), d.end());
  
  int ans = 0;
  
  if (d.at(N/2-1) == d.at(N/2)) {
    cout << 0 << endl;
  }
  else {
    cout << d.at(N/2) - d.at(N/2-1) << endl;
  }
  
  /*
  //int flag = false;
  rep1(K,100000) {
    int N_ABC = 0;
    rep(i,N) {
      if (d.at(i) >= K) break;
      N_ABC++;
    }
    
    if (N_ABC == N - N_ABC) {
      ans++;
    }
    else if (N_ABC > N - N_ABC) {
      //flag = true;
      break;
    }
  }
  
  cout << ans << endl;
  */
}



Measured memory_bytes: 640
x = int(input())
if 400 <= x < 600:
    ans = 8
elif 600 <= x < 800:
    ans = 7
elif 800 <= x < 1000:
    ans = 6
elif 1000 <= x < 1200:
    ans = 5
elif 1200 <= x < 1400:
    ans = 4
elif 1400 <= x < 1600:
    ans = 3
elif 1600 <= x < 1800:
    ans = 2
else:
    ans = 1
print(ans)

Measured memory_bytes: 61628
#include <bits/stdc++.h>
using namespace std;
int main()
{
  string p;
  string s;
  int point;
  getline(cin, p);
  getline(cin, s);
  for (int j = 0; j < p.size(); j++)
  {
    for (int i = 0; i < s.size(); i++)
    {
      // cout << p.at((i+j)%(p.size())) << " " << s.at(i) << "\n";
      if (p.at((i + j) % (p.size())) == s.at(i))
      {
        point++;
      }
    }
    if (point == s.size())
    {
      cout << "Yes"
           << "\n";
      return 0;
    }
    // cout << "------" << "\n";
    point = 0;
  }
  cout << "No"
       << "\n";
}


Measured memory_bytes: 3196
s = input()

ans = 0
for bit in range(2 ** (len(s) - 1)):
    cnt = 0
    now = int(s[0])
    for i in range(len(s) - 1):
        if bit >> i & 1:
            cnt += now
            now = int(s[i + 1])
        else:
            now = now * 10 + int(s[i + 1])
    
    cnt += now
    ans += cnt

print(ans)

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

int main() {
  int64_t N, K;
  cin >> N >> K;
  int64_t n = (N + 1) * (N * N + 2 * N + 6);
  int64_t k = (K - 1) * (2 * K * K - (3 * N + 4) * K - 6);
  int64_t a = (n + k) / 6;
  cout << a % 1000000007 << endl;                                                        
}

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

    typedef long long int ll;
    #define pb         push_back
    #define mp         make_pair
    #define F          first
    #define S          second
    #define fl(i,a,b)  for(ll i=a;i<b;i++)
    #define pll        pair<ll,ll>
    #define pii        pair<int,int>
    #define all(v)     v.begin(),v.end()
    #define M 1000000007
    #define tr(v, it) for(auto it = v.begin(); it != v.end(); it++)
    using namespace std;

    ll solve( vector<int>& val, vector<int>& weight,vector<vector<ll> >& dp, int W, int i, int n)
    {
        if(W<0)
        return INT_MIN;
       if(i>n)
        return 0;
       if(dp[i][W]!=-1)
        return dp[i][W];

       ll result = INT_MIN;
       result = max(result, val[i]+solve(val, weight,dp, W-weight[i], i+1, n));
       result= max(result, solve(val, weight,dp, W, i+1, n));
       return dp[i][W]=result;
    }

    int main()
    {

    ios_base::sync_with_stdio(false);
	cin.tie(NULL);

       int n,w;
       cin>>n>>w;
       vector<int> val(n+1,0);
       vector<int> weight(n+1,0);
       for(int i=1; i<=n; i++)
       {
           cin>>weight[i]>>val[i];
       }
       vector<vector<ll> > dp(n+1, vector<ll>(w+1,-1));
       ll result = solve(val, weight,dp,w,1,n);
       cout<<result;
        return 0;

    }



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

int main(){
	int a,b;

	while(scanf("%d %d",&a,&b) !=EOF){
	
		int tag = (a+b)/1000000;
		int keta = 7;
		if(tag==0){
			tag = (a+b)/100000;
			keta = 6;
		}
		if(tag==0){
			tag = (a+b)/10000;
			keta = 5;
		}
		if(tag==0){
			tag = (a+b)/1000;
			keta = 4;
		}
		if(tag==0){
			tag = (a+b)/100;
			keta = 3;
		}
		if(tag==0){
			tag = (a+b)/10;
			keta = 2;
		}
		if(tag==0){
			tag = (a+b)/1;
			keta = 1;
		}

		cout << keta << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1208
import math
from itertools import permutations

N = int(input())
xy = [tuple(map(int, input().split())) for _ in range(N)]

d = [[0]*N for _ in range(N)]
for i in range(N):
    for j in range(i, N):
        dx = xy[i][0] - xy[j][0]
        dy = xy[i][1] - xy[j][1]
        d[i][j] = math.sqrt(dx**2 + dy**2)
        d[j][i] = math.sqrt(dx**2 + dy**2)

sum_ = 0
count = 0
for order in permutations(range(N)):
    for i in range(len(order)-1):
        sum_ += d[order[i]][order[i+1]]
    count += 1

print(sum_/count)

Measured memory_bytes: 3064
let data = readLine()!
            let values = data.characters.split{ x in x == " "}.map{Int(String($0))!}
            let N = values[0]

            var S = [String]()
            (0 ..< N).forEach { (i) in
                S.append(readLine()!)
            }
            S.sortInPlace()

            print(S.reduce("", combine: +))

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

int main(){
    int a;
    char op;
    int b;

    while(1){
        cin >> a >> op >> b;

        if('?' == op){
            break;
        }

        switch(op){
            case '+':
                cout << (a + b) << endl;
                break;
            case '-':
                cout << (a - b) << endl;
                break;
            case '*':
                cout << (a * b) << endl;
                break;
            case '/':
                cout << (a / b) << endl;
                break;
        }
    }



    return 0;
}


Measured memory_bytes: 3100
#include <iostream>
#include <set>
#include <map>

using namespace std;

const int Maxn = (int)1e5;

int main() {
    int n;
    cin >> n;
    set<int> s;
    map<int, int> mp;
    for (int i = 0; i < n; ++i) {
        int a;
        cin >> a;
        s.insert(a);
        ++mp[a];
    }

    int ans = 0;
    for(auto x : s){
        if (mp[x] >= x) ans += mp[x] - x;
        else ans += mp[x];
    }

    cout << ans << endl;
}

Measured memory_bytes: 9216
#include<stdio.h>
#include<algorithm>
#include<string>
#include<string.h>
using namespace std;
string dp[100][100];
char in[100];
bool gt(string a,string b){
	if(a[0]=='i')return false;
	if(b[0]=='i')return true;
	if(a.size()!=b.size())return a.size()>b.size();
	for(int i=0;i<a.size();i++)if(a[i]!=b[i])return a[i]>b[i];
	return false;
}
string calc(int a,int b){
	if(dp[a][b].size())return dp[a][b];
	string ret="invalid";
	bool on=true;
	string cur="";
	for(int i=a;i<b;i++){
		if(in[i]=='?')cur+='9';
		else if('0'<=in[i]&&in[i]<='9')cur+=in[i];
		else on=false;
	}
	if(cur.size()>1&&cur[0]=='0')on=false;
	if(on)ret=cur;
	bool L=true;
	bool R=true;
	if(b-a<6||(in[a+1]!='?'&&in[a+1]!='(')||(in[b-1]!='?'&&in[b-1]!=')'))L=R=false;
	if(in[a]!='L'&&in[a]!='?')L=false;
	if(in[a]!='R'&&in[a]!='?')R=false;
	for(int i=a+3;i<b-2;i++){
		if(in[i]!='?'&&in[i]!=',')continue;
		if(L){
			string left=calc(a+2,i);
			string right=calc(i+1,b-1);
			if(left[0]!='i'&&right[0]!='i'){
				if(gt(left,ret))ret=left;
			}
		}
		if(R){
			string left=calc(a+2,i);
			string right=calc(i+1,b-1);
			if(left[0]!='i'&&right[0]!='i'){
				if(gt(right,ret))ret=right;
			}
		}
	}
	//printf("%d %d: %s\n",a,b,ret.c_str());
	return dp[a][b]=ret;
}
int main(){
	scanf("%s",in);
	for(int i=0;i<100;i++)for(int j=0;j<100;j++)dp[i][j]="";
	int n=strlen(in);
	printf("%s\n",calc(0,n).c_str());
}

Measured memory_bytes: 1160
A = []
def svt(now, count):
    A.append(now)
    if count > 10:
        return
    else:
        svt(now * 10 + 7, count + 1)
        svt(now * 10 + 5, count + 1)
        svt(now * 10 + 3, count + 1)

svt(3, 1)
svt(5, 1)
svt(7, 1)

A.sort()
N = int(input())
ans = 0
for i in A:
    j = str(i)
    a = 0
    b = 0
    c = 0
    for k in range(len(j)):
        if j[k] == "3":
            a = 1
        elif j[k] == "5":
            b = 1
        elif j[k] == "7":
            c = 1
    if a == 1 and b == 1 and c == 1 and i <= N:
        ans += 1
print(ans)


Measured memory_bytes: 17480
#include<bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
const int N = 3e6 + 11;
int fac[N], inv[N];
int x[5], y[5];
long long C(int n, int m){
    if(n < m || n < 0 || m < 0)return 0;
    return 1ll * fac[n] * inv[m] % mod * inv[n-m] % mod;
}
int Fr(int X, int Y){
    return ((C(x[6] + 1 - X + y[6] + 1 - Y, x[6] + 1 - X) - C(x[5] - X + y[6] + 1 - Y, x[5] - X) - C(x[6] + 1 - X + y[5] - Y, x[6] + 1 - X) + C(x[5] - X + y[5] - Y, x[5] - X)) % mod + mod) % mod;
}
int Fl(int X, int Y){
    return ((C(X + 1 - x[1] + Y - y[1] + 1, X + 1 - x[1]) - C(X - x[2] + Y - y[1] + 1, X - x[2]) - C(X - x[1] + 1 + Y - y[2], X - x[1] + 1) + C(X - x[2] + Y - y[2], X - x[2])) % mod + mod) % mod;
}
int main(){
    inv[0] = inv[1] = fac[0] = fac[1] = 1;
    for(int i = 2;i <= 3e6; i++){
        fac[i] = 1LL * fac[i-1] * i % mod;
        inv[i] = mod - 1LL * mod / i * inv[mod%i] % mod;
    }
    for(int i = 2;i <= 3e6; i++)inv[i] = 1ll * inv[i-1] * inv[i] % mod;
    for(int i = 1;i <= 6; i++)cin>>x[i];
    for(int i = 1;i <= 6; i++)cin>>y[i];
    int ans = 0;
    for(int v = y[3];v <= y[4]; v++){
        int u = x[4];
        (ans += 1LL * Fr(u + 1, v) * (u + v) % mod * Fl(u, v) % mod) %= mod;
    }
    for(int u = x[3];u <= x[4]; u++){
        int v = y[4];
        (ans += 1LL * Fr(u, v + 1) * (u + v) % mod * Fl(u, v) % mod) %= mod;
    }
    for(int p = x[3];p <= x[4]; p++){
        int q = y[3] - 1;
        (ans += mod - 1LL * Fl(p, q) * (p + q) % mod * Fr(p, q + 1) % mod) %= mod;
    }
    for(int q = y[3];q <= y[4]; q++){
        int p = x[3] - 1;
        (ans += mod - 1LL *  Fl(p, q) * (p + q) % mod * Fr(p + 1, q) % mod) %= mod;
    }
    cout<<ans<<endl;
    return 0;
}


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

using namespace std;

#define MAX_N 10000

int main() {
    int N, K, b = 0, c = 0;

    scanf("%d %d", &N, &K);
    int buf, aidx = -1;
    for(int i = 0; i < N; i++) {
        scanf("%d", &buf);
        if(buf == 1) aidx = i;
        else {
            if(aidx >= 0) {
                c++;
            }
            else {
                b++;
            }
        }
    }

    int cnd1 = (b % (K - 1) == 0 ? b / (K - 1) : b / (K - 1)) + 1 + ((c % (K - 1) == 0) ? c / (K - 1) : c / (K - 1) + 1);
    int cnd2 = (b + c - K + 1) % (K - 1) == 0 ? (b + c - K + 1) / (K - 1) + 1 : (b + c - K + 1) / (K - 1) + 2;

    printf("%d\n", min(cnd1, cnd2));

    return 0;
}


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

using namespace std;

long long int MOD = 1000000007;

long long int C[2050][2050];

int N, K;

int main(void) {

	for (int i = 0; i <= 2010; i++) { C[i][0] = 1; C[0][i] = 1; C[i][i] = 1; }

	for (int i = 2; i <= 2010; i++) {
		for (int j = 1; j <= i - 1; j++) {
			C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]) % MOD;
		}
	}

	/*for (int i = 1; i <= 4; i++) {
		for (int j = 0; j <= i; j++) {
			cout << "C[" << i << "][" << j << "]= " << C[i][j] << endl;
		}
	}*/

	cin >> N >> K;

	for (int i = 1; i <= K; i++) {
		long long int ans = 0;

		long long int B = C[K - i + (i - 1)][i - 1];

		long long int A = 0;
		
		/*if ((N-K)>=(i+1) && N - K - 1 >= 0 ) { A = C[N - K - (i + 1) + i][i]; }
		if ((N-K)>=i && N - K - 1 >= 0) { A += C[N - K - i + (i - 1)][i - 1] * 2; A %= MOD; }
		if ((N-K)>=(i-1)  && N - K - 1 >= 0 && i >= 2) { A += C[N - K - (i - 1) + i - 2][i - 2]; A %= MOD; }
		*/

		if (N - K >= (i - 1)) { A = C[N - K - (i - 1) + i][i]%MOD; }

		ans = (B*A) % MOD;
		//cout << "B= " << B << endl;
		//cout << "A= " << A << endl;
		cout << ans << endl;
	}


	return 0;
}

Measured memory_bytes: 31488
#include<iostream>
#include<cmath>
#include<vector>
#include<set>
#include<algorithm>
#include<tuple>
#include<utility>
#include<cctype>
#include<climits>
#include<map>
#include<queue>
#include<functional>
#include<stack>
#include<iomanip>

using namespace std;

#define REP(i,a,n) for(int i=a;i<n;++i)
#define REPL(i,a,n) for(ll i=a;i<n;++i)
#define RUP(a,b) ((a+b-1)/(b))
#define ENT "\n"
#define SRTVG(v) sort(v.begin(),v.end(),greater<>())
#define SRTV(v) sort(v.begin(),v.end())
#define SRTAG(a,n) sort(a,a+n,greater<>())
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define INF LLONG_MAX/2

typedef long long ll;
typedef tuple<int,int,bool> Tb;
typedef pair<int,int> Pii;
typedef vector<int> Vi;

template<class T> void chmax(T& a, T b) {if(a < b){a=b;}}
template<class T> void chmin(T& a, T b) {if(a > b){a=b;}}
template<class T> void YesNo(T& a) {if(a){cout << "Yes" << ENT;}else{cout << "No" << ENT;}}
template<class T> void YESNO(T& a) {if(a){cout << "YES" << ENT;}else{cout << "NO" << ENT;}}

const int MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];


int atcoder(){
    int n,h;
    cin>>n>>h;
    Vi a(n),b(n);
    REP(i,0,n) cin>>a[i]>>b[i];
    int maxa = *max_element(ALL(a));
    int ans = 0;
    SRTVG(b);
    REP(i,0,n){
        if(b[i]>=maxa){
            h -= b[i];
            ans++;
        }
        if(h<=0){cout<<ans<<ENT;return 0;}
    }
    ans += RUP(h,maxa);
    cout<<ans<<ENT;
    return 0;
}


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


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int a[4][4];
    for(int i=1;i<=3;i++)
        for(int j=1;j<=3;j++)
        scanf("%d",&a[i][j]);
     bool flag=true;
     int n1=a[1][1]-a[2][1];
     int n2=a[1][2]-a[2][2];
     int n3=a[1][3]-a[2][3];
     if(n1!=n2 || n2!=n3) flag=false;
//     cout<<n1<<" "<<n2<<" "<<n3<<endl;
     int n4=a[3][1]-a[2][1];
     int n5=a[3][2]-a[2][2];
     int n6=a[3][3]-a[2][3];
     if(n4!=n5 || n5!=n6)
     {
         flag=false;
     }
//     cout<<n4<<" "<<n5<<" "<<n6<<endl;
     if(flag) cout<<"Yes"<<endl;
     else cout<<"No"<<endl;
}


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

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

int main() {
  int64 A, B, C;
  cin >> A >> B >> C;
  if (A == B && B == C) {
    if (A % 2) {
      cout << 0 << endl;
    } else {
      cout << -1 << endl;
    }
    return 0;
  }
  int ret = 0;
  while (A % 2 == 0 && B % 2 == 0 && C % 2 == 0) {
    int64 x = (B + C) / 2;
    int64 y = (A + C) / 2;
    int64 z = (A + B) / 2;
    A = x;
    B = y;
    C = z;
    trace(A, B, C);
    ++ret;
  }
  cout << ret << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FAST ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
#define pb push_back
#define MOD 1000000007
#define sz5 100005
#define sz6 1000005
#define UP upper_bound
#define LB lower_bound
#define F first
#define S second
#define PI pair<int,int>
#define PL pair<ll,ll>
#define VI vector<int>
#define VL vector<ll>

VI gr[sz5];
int up[sz5], dwn[sz5];

void dfs(int idx, int l, bool mk[]){
    // cout<<' '<<idx<<' '<<l<<endl;
    mk[idx]=true;
    up[idx]=l;
    int mx=0;
    for(auto it: gr[idx]){
        if(!mk[it])
            dfs(it, l+1, mk);
        up[it]=max(up[it], l+1);
        mx=max(mx, dwn[it]);
    }

    dwn[idx]=1+mx;
}

int main() {
    FAST

    int n,m,x,y,la,lb;
    cin>>n>>m;
    for(la=1;la<=m;la++){
        cin>>x>>y;
        gr[x].pb(y);
    }

    bool mk[n+4]={0};
    for(la=1;la<=n;la++)
    if(!mk[la])
        dfs(la, 0, mk);

    int mx=0;
    for(la=1;la<=n;la++)
        mx=max(mx, up[la]+dwn[la]);

    // cout<<endl<<endl;
    // for(la=1;la<=n;la++)
    //     cout<<up[la]<<' '<<dwn[la]<<endl;

    cout<<mx-1<<endl;

    return 0;
}

Measured memory_bytes: 13936
#include <bits/stdc++.h>
#define rep3(i, s, n, a) for (int i = (s); i < (int)(n); i += a)
#define rep2(i, s, n) rep3(i, s, n, 1)
#define rep(i, n) rep2(i, 0, n)

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;

struct UnionFind {
  vector<int> par;

  UnionFind(int n) : par(n, -1) {}
  void init(int n) { par.assign(n, -1); }

  int root(int x) {
    if (par[x] < 0)
      return x;
    else
      return par[x] = root(par[x]);
  }

  bool issame(int x, int y) { return root(x) == root(y); }

  bool merge(int x, int y) {
    x = root(x);
    y = root(y);
    if (x == y) return false;
    if (par[x] > par[y]) swap(x, y);  // merge technique
    par[x] += par[y];
    par[y] = x;
    return true;
  }

  int size(int x) { return -par[root(x)]; }
};

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

  UnionFind uf(n);
  vector<int> frnum(n, 0);

  rep(i, m){
    int a, b;
    cin >> a >> b;
    uf.merge(a-1, b-1);
    frnum[a-1]++;
    frnum[b-1]++;
  }

  vector<int> tmp;
  vector<vector<int>> bl(n, tmp);
  rep(i, k){
    int c, d;
    cin >> c >> d;
    bl[c - 1].push_back(d - 1);
    bl[d - 1].push_back(c - 1);
  }

  rep(i, n){
    int ans = uf.size(i) - frnum[i] - 1;
    int blsize = bl[i].size();
    rep(j, blsize){
      if(uf.issame(i, bl[i][j])){
        ans--;
      }
    }
    cout << ans << " ";
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 6784
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REPS(i,n) for(ll (i)=1;(i)<=(n);(i)++)
#define RREP(i,n) for(ll (i)=(n-1);(i)>=0;(i)--)
#define RREPS(i,n) for(ll (i)=(n);(i)>0;(i)--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());

template<class T> inline void chmin(T& a, T b){
    if (a > b){
        a = b;
    }
}

template<class T> inline void chmax(T& a, T b){
    if (a < b){
        a = b;
    }
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(12);
    int X,N;
    cin >> X >> N;
    vector<bool> there(101);
    REP(i,N){
        int in;
        cin >> in;
        there[in] = 1;
    }
    REP(i,200){
        if(!there[X-i]){
            cout << X-i << "\n";
            break;
        }
        if(!there[X+i]){
            cout << X+i << "\n";
            break;
        }
    }
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
using PP = pair<long, long>;
const int INF = 1e9;
template <class T> T Next() { T buf; cin >> buf; return buf; }

int n;
int a[200000];
int b[200000];
int main() {
  cin >> n;
  for (int i = 0; i < n; ++i) cin >> a[i];
  for (int i = 0; i < n; ++i) b[i] = a[i];
  sort(b, b + n);
  for (int i = 0; i < n; ++i) {
    if (a[i] == b[n - 1]) {
      cout << b[n - 2] << endl;
    } else {
      cout << b[n - 1] << endl;
    }
  }
}

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

using namespace std;

typedef long long ll;
typedef long double ld;

//#define int ll
#define ld double
#define loop(i, n) for(int i = 0; i < (int)n; ++i)
#define loop1(i, n) for(int i = 1; i <= (int)n; ++i)
#define F first
#define S second
#define pb push_back
#define pi pair <int, int>
#define len length()
#define all(x) begin(x), end(x)
#define ti tuple <int, int, int>
#define Point Vect

void solve() {
    int x;
    cin >> x;
    cout << (x % 100 <= x / 100 * 5);
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    solve();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
using pii = pair<int, int>;
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  int ans = 0;
  set<int> hako;
  map<int, int> s;

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

  for (auto it = s.begin(); it != s.end(); it++) {
    if ((it->second % 2) != 0) {
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 8244
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <set>
using namespace std;

int main()
{
    int n,i;
    cin >> n;
    vector<int> h(n);
    for(i = 0;i < n;++i){
        cin >> h.at(i);
    }
    int ans = 0;
    bool flag = true;
    while(true){
        for(i = 0;i < n;++i){
            if(h.at(i) != 0){
                --h.at(i);
                flag = false;
            }else{
                if(flag){
                    continue;
                }else{
                    ++ans;
                    flag = true;
                    break;
                }
            }
        }
        if(flag == false){
            flag = true;
            ++ans;
            continue;
        }
        if(i == n && flag){
            break;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
# input
from collections import deque
import itertools

n, m = map(int, input().split())
path = [[] for _ in range(n)]
for i in range(m):
    a,b = map(int, input().split())
    a -= 1
    b -= 1
    path[a].append(b)
    path[b].append(a)
# n-1 ! を全探索する
all_lis = itertools.permutations(range(1, n))  # 1(0)は出発点なので除く
# print(all_lis)

ans = 0
for i in all_lis:
    start = 0# これをfor の外においていて爆死。
    ok = 1
    for j in range(n - 1):
        if i[j] not in path[start]:
            ok = 0
            break
        else:
            start = i[j]
    if ok:
        ans += 1
print(ans)


Measured memory_bytes: 3316
// यथा चतुर्भिः कनकं परीक्ष्यते निघर्षणच्छेदनतापताडनैः।
// तथा चतुर्भिः पुरुषः परीक्ष्यते त्यागेन शीलेन गुणेन कर्मणा॥
#include <bits/stdc++.h>
using namespace std;
#define lld long long int
#define M 1000000007
#define fors(i,n) for(int i=0;i<n;++i)
#define fore(i,a,b) for(int i=a;i<=b;++i)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define vv std::vector<int>
#define mapii std::map<int,int>
#define mpaci std::map<char,int>
#define umapii std::unordered_map<int,int>
#define umapci std::unordered_map<char,int>
#define seti std::set<int>
#define useti std::unordered_set<int>
#define qi std::queue<int>
#define qc std::queue<char>
#define sti std::stack<int>
#define stc std::stack<char>
#define endl "\n"
#define test(i) cout<<i<<endl
#define tests(i) cout<<"i: "<<i<<endl;
#define itrt int t; cin>>t; fors(i,t)
#define itr1 int t; cin>>t;
#define ff first
#define ss second
#define pb push_back
#define vmp make_pair
#define ppb pop_back
#define sorta(a,n) sort(arr,arr+n)
#define sortv(x) sort(x.begin(),x.end())
#define all(x) x.begin(),x.end() 
#define printv(v) for(auto x: v){ cout<< x << " ";}
#define pi 3.14159265358979323846
#define setprc(x) setprecision(x)
void file(){
    #ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}
bool sortdesk(const pair<int,int> &a, const pair<int,int> &b){return a.ff>b.ff;}
bool sortdesv(const pair<int,int> &a, const pair<int,int> &b){return a.ss>b.ss;}
bool sortascv(const pair<int,int> &a, const pair<int,int> &b){return a.ss<b.ss;}
bool sortasck(const pair<int,int> &a, const pair<int,int> &b){return a.ff<b.ff;}
bool is_prime(int n){if(n==1){return false;}int i=2;while(i*i<=n){if(n%i==0){return false;}i+=1;}return true;}
int gcd(int a, int b){if (b == 0){return a;} return gcd(b, a % b);}
int cntdiv(int n){int cnt=0;for(int i=1;i<=sqrt(n);++i){if(n%i==0){if(n/i==i)++cnt;else{cnt = cnt + 2;}}}return cnt;}
lld posnegmod(lld x,lld mod){return (x%mod+mod)%mod;}
// cout<<fixed<<setprecision(20)
// lld fact(lld n);
// lld nCr(lld n,lld r){return fact(n) / (fact(r) * fact(n - r));}
// lld fact(lld n){ lld res = 1; for(lld i = 2; i <= n; i++){res = res * i;}return res;} 
// const int maxi = 1e6+10;
// vector<int> v[maxi];
// vector<long long> a(maxi,0);
// void dfs(int x){
//     if(a[x]){return;}
//     a[x]=1;
//     for(int i=0;i<v[x].size();++i){
//         dfs(v[x][i]);
//     }
// }

void test_case(){
    int n;
    cin>>n;
    if(n%1000==0){
        cout<<0<<endl;
        return;
    }
    // cout<<ceil(n/1000.0)*1000<<endl;
    cout<<ceil(n/1000.0)*1000-n;
}

int main(){
    fastio;
    file();
    int T=1;
    // int T;
    // cin>>T;
    for(int nr=1;nr<=T;++nr) {
        // cout<<"Case #"<<nr<<": ";
        test_case();
    }
}


Measured memory_bytes: 3840
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){for(auto &e:t) fill_v(e,v);}
/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

template<class Type>
Type solve(Type res = Type()){
    int x; cin >> x;
    if(x) return 0;
    else return 1;
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    // solve(0);
    cout << fixed << setprecision(15) << solve<ll>() << endl;
    return 0;
}


Measured memory_bytes: 3632
//想的时间太长了，打表不能一下找到规律的话，还是手推吧，不要浪费时间 
#include <cstdio>
#include <cstring>
long long k, ans, x, y, n, m;

int main(){
	//freopen("atcoderarc091b.out", "w", stdout);
	scanf("%lld%lld", &n, &k);
	if (k == 0){
		printf("%lld", n * n);
		return 0;
	}
	ans = 0;
	ans += (n - k) * (n - k + 1) / 2;
	//printf("%d\n", ans);
	for (int i=k+1; i<=n-1; i++){
		x = n / i;
		y = n % i;
		ans += (x - 1) * (i - k);
		if (y >= k) ans += y - k + 1;
	} 
	printf("%lld", ans);
	
	//以下为打表找规律（其实最后也没找到，还是手推的） 
	/*n = 100;
	for (int i=1; i<=n; i++){
		for (int j=0; j<=i-1; j++){
			ans = 0;
			for (int a=1; a<=i; a++){
				for (int b=1; b<=i; b++) 
					if (a % b >= j) ans++;
			}
			printf("%d %d %d\n", i, j, ans); 
			//ans = 0;
		}
	}*/
	
	return 0;
} 

Measured memory_bytes: 128
from typing import List


def counting_sort(elements: List[int]) -> List[int]:
    C = [0] * (max(elements) + 1)
    B = [0] * (len(elements) + 1)

    for elem in elements:
        C[elem] += 1
    for i in range(1, len(C)):
        C[i] += C[i - 1]
    for elem in elements[::-1]:
        B[C[elem]] = elem
        C[elem] = C[elem] - 1
    return B[1:]


if __name__ == "__main__":
    _ = int(input())
    elements = list(map(lambda x: int(x), input().split()))

    sorted_elements = counting_sort(elements)

    print(" ".join([str(elem) for elem in sorted_elements]))



Measured memory_bytes: 247480
#include<bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define NO do{cout << "No\n";return 0;}while(1);
int main(){
    string s, t;
    cin >> s >> t;
    map<char, char> f;
    for(ll i = 0; i < s.size(); i++){
        if(f.find(s[i]) != f.end() && f[s[i]] != t[i]) NO;
        f[s[i]] = t[i];
    }
    bool used[26] = {};
    for(auto x : f){
        if(used[x.second - 'a']) NO;
        used[x.second - 'a'] = 1;
    }
    cout << "Yes\n";
    return 0;
}


Measured memory_bytes: 776
n, k = map(int, input().split())
ab = [tuple(map(int, input().split())) for _ in range(n)]

# そのままの　ｋ
ans = 0
for a, b in ab:
    if k & a == a:
        ans += b

for i in range(31):
    # 上からi桁目までいっち、あとは1111
    if k >> i & 1 == 0:
        continue
    nk = k
    nk &= ~(1 << i)
    for j in range(i - 1, -1, -1):
        nk |= 1 << j

    cnt = 0
    for j in range(n):
        a, b = ab[j]
        if (a & nk) == a:
            cnt += b
    ans = max(ans, cnt)
print(ans)


Measured memory_bytes: 22452
#include<stdio.h>
int main() {
    int a, b,ans=1,i;
    scanf("%d%d", &a, &b);
    for (i = 0; i < a; i++) {
        ans = ans * 100;
    }
if(b==100)
ans=ans*101;
else
    ans = ans * b;
printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 128
a=int(input())
if a<600:
  print('8')
elif a<800:
  print('7')  
elif a<1000:
  print('6')
elif a<1200:
  print('5')   
elif a<1400:
  print('4') 
elif a<1600:
  print('3') 
elif a<1800:
  print('2') 
elif a<2000:
  print('1') 

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

int main() {
  int K, S;
  cin >> K >> S;

  int ans = 0;
  for (int x = 0; x <= K; x++) {
    for (int y = 0; y <= K; y++) {
      int rest = S - (x + y);
      // z が表現できる値の範囲であれば、カウントアップする
      if (rest >= 0 && rest <= K) {
        ans++;
      }
    }
  }

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

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <functional>
#include <numeric>
#include <iostream>
#include <string>
#include <time.h>

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }

int N,M;

int main() {

	scanf("%d%d", &N,&M);

	if ((N + M) % 2) {
		printf("IMPOSSIBLE\n");
	}
	else
	printf("%d\n", (N + M) / 2);

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<bitset>
#include<algorithm>

int main(){
  std::ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  int h,w,m; std::cin >> h >> w >> m;
  int br[300000];
  int bc[300000];
  int cntr[300000] = {};
  int cntc[300000] = {};
  int maxr=0,maxc=0;
  for(int i = 0; i < m; ++i){
    std::cin >> br[i] >> bc[i];br[i]--;bc[i]--;
    maxr = std::max(maxr,++cntr[br[i]]);
    maxc = std::max(maxc,++cntc[bc[i]]);
  }
  std::bitset<300000>r,c;
  int cr=0,cc=0,cntd=0;
  for(int i = (h<w?w:h)-1; i >= 0; --i){
    cr+=r[i] = maxr == cntr[i];
    cc+=c[i] = maxc == cntc[i];
  }
  cntd = cr*cc;
  for(int i = 0; i < m; ++i)
    cntd -= c[bc[i]]&r[br[i]];
  std::cout << maxr + maxc - (!cntd) << '\n';
}


Measured memory_bytes: 8412
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, n) for(int i=0; i<int(n); i++)
#define RNG(i, f, t) for(int i=int(f); i<=int(t); i++)
#define REV(i, f, t) for(int i=int(f); i>=int(t); --i)
#define ALL(v) (v).begin(), (v).end()
bool RELAXED = false;
template<int,typename T> struct MINMAX{ T val; MINMAX(T val) : val(val) {} };
template<typename T> MINMAX<1,T> MAX(T val) { return MINMAX<1,T>(val); };
template<typename T> MINMAX<2,T> MIN(T val) { return MINMAX<2,T>(val); };
template<typename T, typename U> inline T& operator|=(T &lhs, MINMAX<1,U> rhs) { return lhs = (rhs.val > lhs ? (RELAXED=true,rhs.val) : (RELAXED=false,lhs)); }
template<typename T, typename U> inline T& operator|=(T &lhs, MINMAX<2,U> rhs) { return lhs = (rhs.val < lhs ? (RELAXED=true,rhs.val) : (RELAXED=false,lhs)); }
template<typename T> inline vector<T> readVector(int n) { vector<T> vec(n); FOR(i,n) cin>>vec[i]; return vec; }
template<typename T> void EXIT(T answer) { cout<<answer<<endl; exit(0); }
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pii> vpii;
typedef signed long long int ll;

typedef vector<pair<int,ll>> vpil;

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

    int m; cin>>m;
    vpil dc(m);
    FOR(i,m)
    cin>>dc[i].first>>dc[i].second;

    ll ans=0;
    vpil next;
    while(dc.size()>1 || dc.size()>0&&dc[0].second>1) {
        FOR(i, dc.size()) {
            int d = dc[i].first;
            ll c = dc[i].second;

            ll dig=d;
            ll cnt=c;

            if(cnt==1 && next.size()>0 && next.back().second==1) {
                dig += next.back().first;
                ans++;
                while(dig>=10) {
                    dig = dig%10 + dig/10;
                    ans += 1;
                }
                next.back().first=dig;
                continue;
            }
            else if(c==1) {
                next.push_back({dig, 1});
                continue;
            }

            dig *= 2;
            cnt/=2;
            ans += cnt;
            while(dig>=10) {
                dig = dig%10 + dig/10;
                ans += cnt;
            }
            next.push_back({dig, cnt});
            if(c%2)
                next.push_back({d, 1});
        }
        dc = next;
        next.clear();
    }
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 27100
def main():
  K, S = map(lambda i: int(i), input().split(' '))
  count = 0
  for X in range(K + 1):
    for Y in range(K + 1):
      Z = S - X - Y
      if Z >= 0 and Z <= K:
        count += 1
  print(count)

main()


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const ll mod = 1e9 + 7;
int N;
vector<int> C;
vector<int> nc[200010];
ll dp[200010] = {1};
int nxt[200010];
int main(){
    cin >> N;
    for(int i = 0; i < N; i++){
        int c;
        cin >> c;
        C.push_back(c);
        nxt[i] = N;
    }
    C.erase(unique(C.begin(), C.end()), C.end());
    for(int i = 0; i < (int)C.size(); i++){
        nc[C[i]].push_back(i);
    }
    for(int i = 0; i <= 2e5; i++){
        for(int j = 0; j < (int)nc[i].size() - 1; j++){
            nxt[nc[i][j]] = nc[i][j + 1];
        }
    }
    for(int i = 0; i < C.size(); i++){
        dp[i + 1] += dp[i];
        dp[i + 1] %= mod;
        dp[nxt[i]] += dp[i];
        dp[nxt[i]] %= mod;
    }
    cout << dp[C.size() - 1] << endl;
}

Measured memory_bytes: 14324