akhauriyash/Code-Regression huggingface dataset:
import           Control.Monad
import           Control.Monad.ST
import qualified Data.Array                    as A
import qualified Data.Array.Unboxed            as AU
import qualified Data.Array.ST                 as ST
import qualified Data.ByteString.Char8         as BS
import           Data.Char
import           Data.Foldable                  ( toList )
import           Data.Int
import qualified Data.IntMap                   as IM
import           Data.List
import qualified Data.Map                      as M
import           Data.Maybe
import           Data.Ord
import qualified Data.Set                      as S
import qualified Data.Sequence                 as SQ
import           Data.Time
import qualified Data.Vector                   as V
import qualified Data.Vector.Mutable           as VM
import qualified Data.Vector.Unboxed           as VU
import qualified Data.Vector.Unboxed.Mutable   as VUM

readInt = map (fst . fromJust . BS.readInt) . BS.words <$> BS.getLine
readInts n = replicateM n readInt
readString = map BS.unpack . BS.words <$> BS.getLine
readStrings n = replicateM n readString
toPair [x, y] = (x, y)

main = do
  [k]<-readInt
  print $ [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51] !! (k-1)


Measured memory_bytes: 380
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define INF (1 << 30)
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
const long long mod = 1e9+7;

using namespace std;
using ll = __int64_t;
using ull = unsigned long long;

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

bool comp(const pair<int, ll>& p1, const pair<int, ll>& p2){
    //return p1.second > p2.second;
    return p1.second < p2.second;
}

//a, bの最大公約数．a > b
ull gcd(ull a, ull b){
    if(b == 0) return a;
    return gcd(b, a%b);
}
//a, bの最小公倍数
ull lcm(ull a, ull b) {
    return a*(b/gcd(a, b));
}

void solve(){
    int n;
    cin >> n;
    vector<pair<ull, ull>> v;

    for(int i = 0; i < n; i++){
        ull x, y;
        cin >> x >> y;
        v.push_back({x, y});
    }
    sort(v.begin(), v.end(), comp);
    ull time = 0;
    // for(auto i = v.begin(); i != v.end(); i++){
    //     cout << (*i).first << ", " << (*i).second << endl;
    // }
    for(int i = 0; i < n; i++){
        if(v[i].second >= time+v[i].first){
            time += v[i].first;
        }else{
            // cout << v[i].first << ", " << v[i].second << endl;
            // cout << time << endl;
            cout << "No" << endl;
            return;
        }
    }
    cout << "Yes" << endl;
}

int main() {
    solve();
    return 0;
}

Measured memory_bytes: 6512
""" #ミス
N = int(input())
L = len(str(N))

numbers = [int(l) for l in str(N)]
all, seven, five, three, seven_five, seven_three, five_three = 1, 1, 1, 1, 0, 0, 0
for i, l in enumerate(numbers):
    if l >= 7:
        all = all * 3
        seven_five += 1
        seven_three += 1
        five_three += 1
    elif 5 <= l < 7:
        all = all * 2
        seven = 0
        three = 0
        five_three += 1
    elif 3 <= l < 5:
        all = all * 1
        seven = 0
        three = 0


seven_five = 2 ** seven_five - 2
seven_three = 2 ** seven_three - 2
five_three = 2 ** five_three - 2
ans = all - (seven + five + three) + (seven_five + seven_three + five_three)
print(ans, all, seven, five, three, seven_five, seven_three, five_three)
"""

# take2
N = int(input())
L = len(str(N))
if N < 356:
    print(0)
    quit()


def Base_10_to_n(X, n):
    X_dumy = X
    out = ''
    while X_dumy>0:
        out = str(X_dumy%n)+out
        X_dumy = int(X_dumy/n)
    return out


numbers = []
for i in range(1, 4**L+1):
    num = Base_10_to_n(i, 4)
    number = ''
    for j in num:
        if j == '0':
            number += '0'
        elif j == '1':
            number += '3'
        elif j == '2':
            number += '5'
        elif j == '3':
            number += '7'
    numbers.append(int(number))


ans = 0
ans_list = []
for i, v in enumerate(numbers):
    if v <= N:
        if str(v).count('3') >= 1 and str(v).count('5') >= 1 and str(v).count('7') >= 1 and str(v).count('0') == 0:
            ans += 1
            ans_list.append(v)

print(ans)

Measured memory_bytes: 62300
#include <bits/stdc++.h>
using namespace std;
const int N = 100 * 1000 + 10;
int a[N], num[N];
int main() {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) 
		cin >> a[i];
	iota(num, num + n, 0);
	sort(num, num + n, [] (int x, int y) { return a[x] < a[y]; });
	int ans = 0;
	for (int i = 0; i < n; i++)
		if (num[i] % 2 != i % 2)	
			ans++;
	cout << ans / 2;
	return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
int main(void) {

  int ryohi, in, out, sum;
  int i, k;
  
  scanf("%d",&ryohi) ;
  
  while( ryohi ) {
    k = 0;
    sum = 0;
    for( i = 0; i < 12; i++ ) {
      scanf("%d",&in);
      scanf("%d",&out);
      sum += (in - out);

      if( sum < ryohi ) k++;
      
    }
    
    if(k == 12) {
      puts("NA");
    } else {
      printf("%d\n",k + 1);
    }
    
    scanf("%d",&ryohi);

  }
  return(0);
}

Measured memory_bytes: 612
#include <bits/stdc++.h>
using namespace std;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define bit_exist(x, n) ((x >> n) & 1)
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl;
#define mdebug(m) cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;}
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;

//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};

const int mod = 1000000007;
//const int mod = 998244353;
#define Add(x, y) x = (x + (y)) % mod
#define Mult(x, y) x = (x * (y)) % mod

signed main(){
    string S; cin>>S;
    string pre(1,S[0]);
    string now = "";
    int ans = 1;
    FOR(i,1,S.size()){
        now += S[i];
        if(now!=pre){
            ans++;
            pre = now;
            now = "";
        }
    }
    Out(ans);
}





Measured memory_bytes: 720
#pragma warning(disable:4996)
#include <bits/stdc++.h>

using namespace std;

//macro
#define FOR(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define EPS (1e-8)
#define equals(a,b)(fabs((a)-(b))<EPS)

using ll = long long;
using ull = unsigned long long;
using vb = vector<bool>;
using vi = vector<int>;
using vll = vector<ll>;
using vs = vector<string>;
using vvb = vector<vb>;
using vvi = vector<vi>;
using vvll = vector<vll>;
//func
template<typename A, typename T>void assign2d(A&arr, ll H, ll W, T t) { arr.resize(H); REP(i, H) arr[i].assign(W, t); }
template<class T> ostream &operator<<(ostream &os, const vector<T> &v) { int n = v.size(); REP(i, n)os << v[i] << (i == n - 1 ? "" : " "); return os; }
template <class T = int> inline T IN() { T x; cin >> x; return x; }
template<class T> inline void OUT(const T &x) { cout << x << "\n"; }
void YESNO(bool c) { OUT(c ? "YES" : "NO"); };
void YesNo(bool c) { OUT(c ? "Yes" : "No"); };
struct pre_ { pre_() { cin.tie(nullptr); ios::sync_with_stdio(false); /*cout << fixed << setprecision(6);*/ } } pre__;

int main() {
	int N, A;
	cin >> N >> A;
	YesNo(N % 500 <= A);
}

Measured memory_bytes: 892
import sys
import collections

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def main():
    H, W = [int(x) for x in input().split()]
    S = [list(input().strip()) for _ in range(H)]

    dp = [[10 ** 9] * W for _ in range(H)]
    dp[0][0] = int(S[0][0] == '#')

    for j in range(H):
        for i in range(W):
            if j != H - 1:
                dp[j + 1][i] = min(dp[j + 1][i], dp[j][i] + int(S[j + 1][i] == '#' and S[j][i] == '.'))
            if i != W - 1:
                dp[j][i + 1] = min(dp[j][i + 1], dp[j][i] + int(S[j][i + 1] == '#' and S[j][i] == '.'))
    print(dp[-1][-1])


if __name__ == '__main__':
    main()


Measured memory_bytes: 3436
#include <stdio.h>
#include <stdlib.h>

int main()
{ int n,m,t,a,b;
 while(~scanf("%d %d",&n,&m))
 { t=n*m;
   a=1*n+1*m;
   b=a-1*1;
   printf("%d\n",t-b);
 }
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define REP(i,n) for(int64_t i=0;i<(n);i++)
#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REV(c) reverse((c).begin(),(c).end())
#define YES cout << "YES" << endl;
#define NO cout << "NO" << endl;
#define Yes cout << "Yes" << endl;
#define No cout << "No" << endl;
#define COUTDOUBLE(d,i) cout << setprecision((i)) << (d) << endl;
#define VIN(v) for(int64_t i=0;i<(v).size();i++){cin >> (v).at(i);}
#define MREP(i,m) for(auto i=(m).begin(); i != (m).end(); ++i) // auto key = i->first;auto value = i->second;

using namespace std;
typedef int64_t I;
typedef pair<I,I> P;
typedef vector<I> V;

I MOD = pow(10,9)+7;
I MAX = LONG_MAX;
I MIN = LONG_MIN;

// 最大公約数
I gcd(I a, I b) {
  return b != 0 ? gcd(b, a % b) : a;
}

// 最小公倍数
I lcm(I a, I b) {
  return a * b / gcd(a, b);
}

int ctoi(char c){
  return c - '0';
}

I dp[100010];
int main(){
  I n,m;
  cin >> n >> m;
  V a(m);
  VIN(a);
  REP(i,m){
    if (i==0) continue;
    if (a.at(i) -1 == a.at(i-1)){
      cout << 0 << endl;
      return 0;
    }
  }
  if (n==1){
    cout << 1 << endl;
    return 0;
  }
  dp[0]=1;
  dp[1]=1;
  dp[2]=2;
  REP(i,100010){
    if (i==0) continue;
    if (i==1) continue;
    if (i==2) continue;
    dp[i] = (dp[i-1] + dp[i-2]) % MOD;
  }
  I t=0;
  if (m==0){
    t = dp[n] % MOD;
  }
  REP(i,m){
    if (i==0){
      if (a.at(i) == 1){
        t = 1;
      }else{
        t = dp[a.at(i)-1] % MOD;
      }
    }
    if (i >= m-1){
      t = (t * dp[n - a.at(i) -1]) % MOD;
    }else{
      t = (t * dp[a.at(i+1) - a.at(i) -2]) % MOD;
    }
  }
  cout << t % MOD << endl;
  return 0;
}



Measured memory_bytes: 1408
# coding: utf-8
# Your code here!

# ITP1_5_B

while(True):
    y,x=map(int,input().split())
    
    if x==0 and y==0:
        break
    
    else:
        for i in range(y):
            if i==0:
                print("#"*x)
            elif i==y-1:
                print("#"*x)
                print("")
            else:
                chuou="."*(x-2)
                print("#"+chuou+"#")
                


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

int main() {
  int N;
  cin >> N;
  vector<char> A = {'a','b','c','d','e','f','g','h','i','j'};
  vector<int> ans(N);
  
  for(int i=N-1; i>=0; i--){
    cout << A.at(ans.at(i));
    if(i==0){
      cout << endl;
    }
  }
  
  while(ans.at(0) != N-1){
    ans.at(0)++;
    
    for(int i=0; i<N-1; i++){
      int max=0;
      //max調べる
      for(int j=N-1; j>i; j--){
        int tmp=ans.at(j);
        if(tmp>max){
          max=tmp;
        }
      }
      if(ans.at(i)-max>1){
        ans.at(i)=0;
        ans.at(i+1)++;
      }
    }
      
    
    for(int i=N-1; i>=0; i--){
      cout << A.at(ans.at(i));
      if(i==0){
        cout << endl;
      }
    }
  }
  
      
 
}

// int型の2次元配列(3×4要素の)の宣言
  //vector<vector<int>> data(3, vector<int>(4));
 
  // 入力 (2重ループを用いる)
  //for (int i = 0; i < 3; i++) {
    //for (int j = 0; j < 4; j++) {
      //cin >> data.at(i).at(j);
   // }
  //}


Measured memory_bytes: 1536
#include <iostream>
#include <iomanip>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <numeric>
#include <set>

using namespace std;
struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}

using int64 = long long;

int main() {
    string s;
    cin >> s;
    sort(s.begin(), s.end());
    s.erase(unique(s.begin(), s.end()), s.end());

    if (s.size() == 26) {
        cout << "None" << endl;
        return 0;
    }

    for (int i=0; i<=26; i++) {
        if (s[i] != 'a' + i) {
            cout << (char)('a' + i) << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 512
N, K = map(int, input().split())
R, S, P = map(int, input().split())
T = input()
score = {"r":P, "s":R, "p":S} 
m = {"r":"p", "s":"r", "p":"s"}
command= []
mm = []
ans = 0


for i, t in enumerate(T):
    if t == "r":
      c = "p"
      point = P
    elif t == "s":
      c ="r" 
      point = R
    elif t == "p":
      c = "s"
      point = S
    
    if (i - K >= 0) and (command[i - K] == c):
        c = ""
        point = 0
    
    ans += point
    command.append(c)
print(ans)

Measured memory_bytes: 9944
#include<bits/stdc++.h>
using namespace std;
#define pii pair<int,int>
#define fir first
#define sec second
typedef long long ll;
const int maxn = 1e5 + 10;
const int inf = 0x3f3f3f3f;
int n,k,s;
ll sum[maxn],ans[maxn];
int main() {
	scanf("%d%d%d",&n,&k,&s);
	for(int i = 1; i <= n; i++) {
		if(i <= k) ans[i] = s;
		else {
			if(s == 1000000000) ans[i] = s - 1;
			else ans[i] = s + 1;
		}
	}
	for(int i = 1; i <= n; i++) {
		printf("%lld%s",ans[i], i == n ? "\n" : " ");
	}
	return 0;
}

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

int main(){
	int N, W;
	cin >> N >> W;
	int w[N], v[N];

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

	long long int dp[W+1][N] = {0};

	for(int j=0;j<W+1;j++){
		if(j>=w[0]){
			dp[j][0] = v[0];
		}else{
			dp[j][0] = 0;
		}
	}

	for(int i=1;i<N;i++){
		for(int j=0;j<W+1;j++){
			if(j-w[i]>=0){
				dp[j][i] = max(dp[j-w[i]][i-1] + v[i], dp[j][i-1]);
			}else{
				dp[j][i] = dp[j][i-1];
			}
		}		
	}
	cout << dp[W][N-1] << endl;
	return 0;
}

Measured memory_bytes: 78336
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long  ll;
typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef double ld;
typedef complex<ld> Point;
const ll INF = mod * mod;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
const ld eps = 1e-6;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;

typedef pair<string, P> speP;
bool comp(speP x, speP y) {
	if (x.first != y.first)return x.first < y.first;
	return x.second > y.second;
}
void solve() {
	int n; cin >> n;
	vector<speP> v(n);
	rep(i, n) {
		cin >> v[i].first;
		int p; cin >> p;
		v[i].second = { p,i+1 };
	}
	sort(v.begin(), v.end(),comp);
	rep(i, n)cout << v[i].second.second << endl;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	solve();
	//stop
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<queue>
#include<vector>
using namespace std;
const int N=500005;
const long long mod=1e9+7;
int n,h[N],cnt,x,id[N],tg[N],ans;
long long fac[N];
vector<int>de[N];
struct qwe
{
	long long x0,x1,x2;
};
typedef deque<qwe>di;
di d[N];
struct qw
{
	int ne,to;
}e[N];
void add(int u,int v)
{//cout<<u<<" "<<v<<endl;
	cnt++;
	e[cnt].ne=h[u];
	e[cnt].to=v;
	h[u]=cnt;
}
void pre(int u,int dep)
{//cout<<u<<endl;
	de[dep].push_back(u);
	for(int i=h[u];i;i=e[i].ne)
		pre(e[i].to,dep+1);
}
void hb(di &a,di &b,int &ta,int &tb,int cnt)
{
	if(a.size()==0||b.size()==0)  
		return;
	qwe x=a.front();
	a.pop_front();
	qwe y=b.front();
	b.pop_front();
	if(cnt==ta) 
	{
		++ta;
		x.x0=(x.x0+x.x2)%mod;
		x.x2=0;
	}
	if(cnt==tb) 
	{
		++tb;
		y.x0=(y.x0+y.x2)%mod;
		y.x2=0;
	}
	hb(a,b,ta,tb,cnt+1);
	qwe c;
	c.x0=x.x0*y.x0%mod;
	c.x1=(x.x0*y.x1%mod+x.x1*y.x0%mod)%mod;
	c.x2=(x.x0*y.x2%mod+x.x1*y.x2%mod+x.x2*y.x2%mod+x.x1*y.x1%mod+x.x2*y.x1%mod+x.x2*y.x0%mod)%mod;
	if(a.size()>b.size()) 
		a.push_front(c);
	else 
		b.push_front(c);
}
void dfs(int u)
{
	int t=n+1;
	for(int i=h[u];i;i=e[i].ne)
	{
		dfs(e[i].to);
		hb(d[t],d[id[e[i].to]],tg[t],tg[id[e[i].to]],0);
		if(d[t].size()<d[id[e[i].to]].size()) t=id[e[i].to];
	}
	if(t==n+1) 
		t=u;
	qwe s;
	s.x0=s.x1=1,s.x2=0;
	id[u]=t;
	d[t].push_front(s);
	tg[t]=0;
}
int main()
{
	scanf("%d",&n);
	n++;
	for(int i=1;i<n;i++)
	{
		scanf("%d",&x);
		add(x,i);
	}
	fac[0]=1ll;
	for(int i=1;i<=n+1;i++)
		fac[i]=fac[i-1]*2ll%mod;
	pre(0,0);//cout<<"????";
	dfs(0);
	di &s=d[id[0]];
	int now=0;
	while (!s.empty())
	{
		long long k=s.front().x1;
		s.pop_front();
		ans=(ans+fac[n-de[now].size()]*k%mod)%mod;
		++now;
	}
	printf("%lld\n",ans);
	return 0;
}

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

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

int n, m;
int a[20], b[20];

int solve()
{
	rep(i, n) rep(j, m){
		if (a[i] == b[j]){
			b[j] = 0;
			break;
		}
	}
	
	int res = 0;
	rep(i, n) res += a[i];
	rep(i, m) res += b[i];
	
	return res;
}

int main()
{
	while (cin >> n >> m, n){
		rep(i, n) cin >> a[i];
		rep(i, m) cin >> b[i];
		cout << solve() << endl;
	}
}

Measured memory_bytes: 1160
import sys

sys.setrecursionlimit(100010)
k = int(input())


def islunlun(l):
    for x in range(1,len(l)):
        if abs(ord(l[x])-ord(l[x-1])) > 1:
            return False
    return True

s = set()
mx = 3234566667
def generate(l):
    val = None
    if l == []:
        val = 0
    else:
        val = int("".join(list(map(str,l))))
    #print(l, val)
    if mx < val:
        return
    else:
        if l != []:
            s.add(val)
    if len(l) == 0:
        for x in range(1,10):
            l.append(x)
            generate(l.copy())
            l.pop(len(l)-1)
    else:
        #print(max(0, l[len(l) - 1] - 1), min(9,l[len(l)-1]+1)+1)
        for x in range(max(0,l[len(l)-1]-1), min(9,l[len(l)-1]+1)+1):
            l.append(x)
            generate(l)
            l.pop(len(l)-1)

"""def bt(l):
    for x in range(10):
        l.append()"""

generate([])
l = []
for x in s:
    l.append(x)
l.sort()
print(l[k-1])

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

int d[10][10];
int dp[10][10][51][10][10][2];
#define INF (1<<28)
int F,M,O,H,W;
int dfs(int x,int y,int o,int l,int r,int f){
	int prevo = o;
	if(y == H && o >= 0) return 0;
	if(o <= 0) return INF;
	if(dp[x][y][o][l][r][f] != -1) return dp[x][y][o][l][r][f];
	int base = 0;
	int ans = INF;
	if(f == 1){
		if(d[y][x] < 0) base += -(d[y][x]);
		else o = min(M,o+d[y][x]);
	}
	ans = min(ans,dfs(x,y+1,o-1,x,x,1));
	if(x>0)  ans = min(ans,dfs(x-1,y,o-1,min(l,x-1),r,l==x));
	if(x<W-1)ans = min(ans,dfs(x+1,y,o-1,l,max(r,x+1),r==x));
	return dp[x][y][prevo][l][r][f] = ans + base;
}
int main(){
	while(cin >> W >> H && W){
		memset(dp,-1,sizeof(dp));
		cin >> F >> M >> O;
		for(int i = 0 ; i < H ; i++) for(int j = 0 ; j < W ; j++) cin >> d[i][j];
		int ans = INF;
		dfs(0,0,O-1,0,0,1);
		for(int i = 0 ; i < W ; i++){
			ans = min(ans,dfs(i,0,O-1,i,i,1));
		}
		if(ans > F) cout << "NA" << endl;
		else cout << ans << endl;
	}
}

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

int main() {
	string s, t;
	cin>>s;
	cin>>t;
	
	int n=s.size();
	int res=0;
	for(int i=0;i<n;i++) {
		if(s[i]!=t[i])
			res++;
	}
	cout<<res<<endl;
	return 0;
}

Measured memory_bytes: 3856
#include <bits/stdc++.h>
#define FASTIO ios::sync_with_stdio(false);cin.tie(0);
#define ADD +
#define SUBTRACT -
#define MULTIPLY *
#define DIVIDE /
#define MOD %
#define INCREMENT(x) ++x
#define DECREMENT(x) --x
#define in(a,b) cin>>a>>b;
#define out(a,b) cout<<a<<endl<<b<<endl;
#define scan(a) scanf("%d",&a);
#define print(a) printf("%d\n",a);
#define scanii(a,b) scanf("%d %d",&a,&b);
#define printii(a,b) printf("%d\n%d\n",a,b);
#define scaniii(a,b,c) scanf("%d %d %d",&a,&b,&c);
#define pub push_back
#define pob pop_back
#define puf push_front
#define pof pop_front
#define ll long long
#define ull unsigned long long
#define sll signed long long
#define f1(i,a) for(int i=0;i<a;++i)
#define f2(i,a) for(int i=a-1;i>=0;--i)
#define pi acos(-1)
#define mod 1000000007
#define TRUE 1
#define FALSE 0
#define ZERO 0
#define MP make_pair
#define F first
#define S second

#define END puts("");
#define elif else if
typedef ll int lli;
typedef sll int slli;
typedef ull int ulli;
const int sz=10000;
using namespace std;

int clue();
int result();
void show();
bool check();

int main() {
    clue();
    return 0;
}
int clue() {


    //O(n^3) solution

    int n;
    cin>>n;
    lli a[n];
    f1(i,n) {
        cin>>a[i];
    }

    lli count=0;
    lli p,q,r;
    f1(i,n-2) {
        for(int j=i+1;j<n-1;++j) {
            for(int k=j+1;k<n;++k) {
                if(a[i]!=a[j]&&a[j]!=a[k]&&a[i]!=a[k]) {
                    p=a[i]+a[j];
                    q=a[j]+a[k];
                    r=a[k]+a[i];
                    if(p>a[k]&&q>a[i]&&r>a[j]) {
                        ++count;
                    }
                }
            }
        }
    }

    cout<<count<<endl;
    return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int n;
const int max_n = 1e6;
int main(){
  cin >> n;
  vector<ll> b(n+1);
  vector<ll> a(n);
  for(int i=0 ; i<n+1 ; i++){
    cin >> b[i];
  }
  for(int i=0 ; i<n ; i++){
    cin >> a[i];
  }
  ll sum = 0;
  for(int i=0 ; i<n ; i++){
    ll k = min(b[i], a[i]);
    sum += k;
    a[i] -= k;
    ll kk = min(a[i], b[i+1]);
    b[i+1] -= kk;
    sum += kk;
    a[i] -= kk;
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 1792
n=int(input())
s=input()
cnt=s.count('E') #西から0番目の人から見たときの向きを変える人数
m=cnt

#西からi番目の人がリーダーの時に向きを変える人の増減について
for i in range(n):
  if s[i]=='E':
    cnt-=1 
  else:
    cnt+=1
  m=min(m,cnt)
print(m)

Measured memory_bytes: 3672
#include<stdio.h>
#include<map>
using namespace std;
map<int,int> idx;
int bit[400005];
int data[400005];
int bit_n;
int q,lim;
int count;
void add(int i,int x){
	while(i<=bit_n){
		bit[i]+=x;
		i+=i&-i;
	}
}
int sum(int i){
	int s=0;
	while(i>0){
		s+=bit[i];
		i-=i&-i;
	}
	return s;
}
int find(int x){
	int l=0,r=count+1,mid;
	for(int i=0;i<20;i++){
		mid=(l+r)/2;
		int s=sum(mid);
		if(s>=x)r=mid+1;
		else l=mid;
	}
	return mid;
}
void enkan(int x){add(find(x),-1);}
void incubate(int x){
	idx[x]=++count;
	data[count]=x;
	add(count,1);
	if(sum(count)>lim)enkan(1);
}
int main(){
	int i,j;
	while(1){
	scanf("%d %d",&q,&lim);
	if(q==0)return 0;
	idx.clear();
	count=0;
	bit_n=q+3;
	for(i=0;i<=bit_n;i++)bit[i]=0;
	for(i=0;i<q;i++){
		int type,x;
		scanf("%d %d",&type,&x);
		if(type==0)incubate(x);
		if(type==1)enkan(x);
		if(type==2)printf("%d\n",data[find(x)]);
		if(type==3)add(idx[x],-1);
	}
	printf("end\n");
	}
}
	

Measured memory_bytes: 22920
n, y = map(int, input().split())
flag = False
for i in range(n+1):
    for j in range(n-i+1):
        k = n-i-j
        sum = i*10000 + j*5000 + k*1000
        if sum == y and flag == False:
            print(i, j, k)
            flag = True
if flag == False:
    print(-1, -1, -1)

Measured memory_bytes: 3060
#include<stdio.h>

typedef struct{
	int num;
	int depth;
}node;

int head=0;
int tail=0;
node queue[100];

int graph[100][100]={0};

int isEmpty(void){
	if(head==tail){
		return 1;
	}else{
		return 0;
	}
}

void enqueue(node n){
	queue[(head++)%100]=n;
}

node dequeue(void){
	return queue[(tail++)%100];
	
}

void init(int d[],int n){
	int i;
	d[0]=0;
	for(i=1;i<n;i++){
		d[i]=-1;
	}
}

int main(void){
	int n;
	int u,k,v;
	int i,j;
	int d[100];
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d %d",&u,&k);
		for(j=0;j<k;j++){
			scanf("%d",&v);
			graph[u-1][v-1]=1;
		}
	}
	init(d,n);
	node tmp;
	node next;
	tmp.num=0;
	tmp.depth=0;
	enqueue(tmp);
	while(!isEmpty()){
		tmp=dequeue();
		for(i=0;i<n;i++){
			if(graph[tmp.num][i]&&d[i]==-1){
				d[i]=tmp.depth+1;
				next.num=i;
				next.depth=d[i];
				enqueue(next);
			}
		}
	}
	for(i=0;i<n;i++){
		printf("%d %d\n",i+1,d[i]);
	}
	return 0;
}

Measured memory_bytes: 636
#include<bits/stdc++.h>
#define vi vector<int>
#define vvi vector<vector<int> >
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
using ll = long long;
using ld =long double;
//#define int ll
#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<int,pii> piii;
#define mp make_pair
signed main(){
    vector<vector<char>> wataamekunn(3,vc(3));
    rep(i,3)rep(j,3)cin>>wataamekunn[i][j];
    rep(i,3)cout<<wataamekunn[i][i];
    cout<<endl;
    
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define clr(a,b) memset(a,b,sizeof(a))
using namespace std;
typedef long long ll;
const int maxn=200010;
ll presum[maxn],sufsum[maxn],a[maxn],l;
int n;
int main(){
	while(cin>>l>>n)
	{
		sufsum[n+1]=0;
		for(int i=1;i<=n;i++)
		{
			scanf("%lld",&a[i]);
		}
		for(int i=1;i<=n;i++)
		{
			presum[i]=presum[i-1]+a[i]*2;
		}
		for(int i=n;i>0;i--)
		{
			sufsum[i]=sufsum[i+1]+(l-a[i])*2;
		}
		ll ans=0;
		for(int i=1;i<=n;i++)
		{
			ll tmp=0;
			int cnt=n-i;
			int cn1=cnt/2;
			int cn2=cnt-cn1;
			tmp+=presum[i+cn1]-presum[i-1]+sufsum[n-cn2+1];
			if(cnt%2==0){
				tmp-=a[i+cn1];
			}else{
				tmp-=(l-a[n-cn2+1]);
			}
			
		//	tmp+=a[i];
			
			ans=max(ans,tmp);
		//	printf("i:%d  ans:%lld  \n",i,ans);
		}
		for(int i=n;i>0;i--)
		{
			ll tmp=0;
			int cnt=i-1;
			int cn2=cnt/2;
			int cn1=cnt-cn2;
			tmp+=sufsum[i-cn2]-sufsum[i+1]+presum[cn1];
		//	tmp+=(l-a[i]);
			
			if(cnt%2==0){
				tmp-=(l-a[i-cn2]);
			}else{
				tmp-=a[cn1];
			}
			ans=max(ans,tmp);
		}
		cout<<ans<<endl;
		
	}
} 

Measured memory_bytes: 4992
'use strict';

Array.prototype._sort = Array.prototype.sort;
Array.prototype.sort = function (fn) {
	if (fn) {
		return this._sort(fn);
		
	} else if (typeof this[0] === 'number') {
		return this._sort((a, b) => a - b);
	
	} else {
		return this._sort();
	}
};

function gcd(a, b) {
	while (true) {
		if (a > b) {
			a = a % b;
			if (a === 0) return b;
		} else {
			b = b % a;
			if (b === 0) return a;
		}
	}
}

class Graph {
	constructor() {
		this.nodes = new Map();
		this.edges = [];
	}
	
	static fromNodePair(pairs) {
		let graph = new Graph(),
			nodes = graph.nodes,
			edges = graph.edges;
		
		for (let ab of pairs) {
			let a = ab[0], b = ab[1];
			
			if (!nodes.has(a)) nodes.set(a, []);
			if (!nodes.has(b)) nodes.set(b, []);
			
			let nodeA = nodes.get(a),
				nodeB = nodes.get(b);
			
			nodeA[nodeA.length] = b;
			nodeB[nodeB.length] = a;
			edges[edges.length] = [a, b];
		}
		
		return graph;
	}
}

const lines = require('fs').readFileSync('/dev/stdin', 'utf8').trim().split('\n');

const NK = lines[0].split(' ').map(Number);
const N = NK[0];
const K = NK[1];
const AB = lines.slice(1).map(l => l.split(' ').map(Number));
const R = Math.floor(K / 2);
const IS_ODD = !!(K & 1);

let graph = Graph.fromNodePair(AB),
	nodes = graph.nodes,
	edges = graph.edges;

let result = N;
for (let i = 0; i < N; i++) {
	let visited = new Set(),
		que = [],
		d = 0,
		isBust = 0;
	
	if (IS_ODD) {
		if (i >= N - 1) break;
		que[que.length] = edges[i][0];
		que[que.length] = edges[i][1];
		visited.add(edges[i][0]);
		visited.add(edges[i][1]);
	} else {
		que.push(i + 1);
		visited.add(i + 1);
	}
	
	while (que.length > 0) {
		if (d === R) {
			result = Math.min(result, N - visited.size);
			isBust = true;
			break
		}

		d++;
		
		let nextQue = [];

		for (let fromNode of que) {
			for (let nextNode of nodes.get(fromNode)) {
				if (visited.has(nextNode)) continue;
				
				nextQue[nextQue.length] = nextNode;
				visited.add(nextNode);
			}
		}
		
		que = nextQue;
	}
	
	if (!isBust) result = 0;
	if (result === 0) break;
}

console.log(result);

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

int main(){
	int N, i, j, k, a=0, b=0, factorial_temp;
	vector<int> P(8), Q(8);
	vector<int> Vec_ref_P={1,2,3,4,5,6,7,8}, Vec_ref_Q={1,2,3,4,5,6,7,8};
	
	cin >> N;
	for(i=0;i<N;i++){
		cin >> P.at(i);
	}
	for(i=0;i<N;i++){
		cin >> Q.at(i);
	}
	
	// aの計算
	for(i=0;i<N;i++){
		j=0;
		while(j<N){
			if(Vec_ref_P.at(j)==P.at(i)){
				Vec_ref_P.erase(Vec_ref_P.begin()+j);
				break;
			}else{
				j++;
			}
		}
		
		// 階乗の計算
		factorial_temp = 1;
		for(k=N-i-1;k>0;k--){
			factorial_temp *= k;
		}
		
		// aに加算
		a += j*factorial_temp;
	}
	a++;
	
	// bの計算
	for(i=0;i<N;i++){
		j=0;
		while(j<N){
			if(Vec_ref_Q.at(j)==Q.at(i)){
				Vec_ref_Q.erase(Vec_ref_Q.begin()+j);
				break;
			}else{
				j++;
			}
		}
		
		// 階乗の計算
		factorial_temp = 1;
		for(k=N-i-1;k>0;k--){
			factorial_temp *= k;
		}
		
		// bに加算
		b += j*factorial_temp;
	}
	b++;
	
	// 出力
	cout << abs(a-b) << endl;
	
	return 0;
}

Measured memory_bytes: 256
# 2020/03/28
# AtCoder Beginner Contest 160 - B

# Input
x = int(input())

# Calc
x500 = x // 500
wk_x = x % 500
x5 = wk_x // 5

ans = x500 * 1000 + x5 * 5

# Output
print(ans)


Measured memory_bytes: 2940
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef pair<int,int> Paint;

__attribute__((constructor))
void initial() {
 cin.tie(0);
 ios::sync_with_stdio(false);
}
int main(){
  //cout << fixed << setprecision(n)

  string s;cin>>s;
  int ans = 0;
  if(s == "SUN")ans = 7;
  else if(s=="MON")ans = 6;
  else if(s == "TUE")ans = 5;
  else if(s == "WED")ans = 4;
  else if(s == "THU")ans = 3;
  else if(s == "FRI")ans = 2;
  else if(s == "SAT")ans = 1;
  cout << ans << endl;

}

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

#define iota(i,n,b,s) for(int i=int(b);i!=int((b)+(s)*(n));i+=(s))
#define range(i,n,m) iota(i,(((n)>(m))?((n)-(m)+1):((m)-(n)+1)),(n),((n)>(m)?-1:1))
#define rep(i,n) iota(i,(n),0,1)

#define INF (1e9)
#define EPS (1e-9)
#define cons(a,b) (make_pair(a,b))
#define car(a) (a.first)
#define cdr(a) (a.second)
#define cadr(a) (car(cdr(a)))
#define cddr(a) (cdr(cdr(a)))
#define all(a) a.begin(), a.end()
#define trace(var) cerr<<">>> "<<#var<<" = "<<var<<endl;

typedef long long INTEGER;
typedef double FLOAT;

template<class S, class T>
ostream& operator<<(ostream& os, pair<S,T> p) {
  os << '(' << car(p) << ", " << cdr(p) << ')';
  return os;
}

template<class T>
ostream& operator<<(ostream& os, vector<T> v) {
  os << v[0];
  for (int i=1, len=v.size(); i<len; ++i) os << ' ' << v[i];
  return os;
}

void swap(int*a, int*b) {
  int t = *b;
  *b = *a;
  *a = t;
}

int main() {

  int hs[4];
  hs[3] = -1;

  rep (i, 10) {
    int h; cin >> h;
    if (i < 3) {
      hs[i] = h;
    } else {
      hs[3] = h;
      sort(hs, hs + 4);
      swap(hs, hs + 3);
      swap(hs + 1, hs + 2);
    }
  }

  rep (i, 3) {
    cout << hs[i] << endl;
  }

  return 0;
}

Measured memory_bytes: 1172
#include<bits/stdc++.h>
#define ll long long int
#define MOD 1e7
using namespace std;

int main(){
	ll n;
	cin >> n;
	ll a[n+1],b[n+1],c[n+1],dp[n+1][2][2][2];
	for(int i=1;i<=n;i++){
		cin >> a[i] >> b[i] >> c[i];
	}
	dp[1][1][0][0] = a[1];
	dp[1][0][1][0] = b[1];
	dp[1][0][0][1] = c[1];
	for(int i=2;i<=n;i++){
		dp[i][1][0][0] = max(dp[i-1][0][1][0],dp[i-1][0][0][1]) + a[i];
		dp[i][0][1][0] = max(dp[i-1][1][0][0],dp[i-1][0][0][1]) + b[i];
		dp[i][0][0][1] = max(dp[i-1][0][1][0],dp[i-1][1][0][0]) + c[i];
	}
	cout << max(dp[n][1][0][0],max(dp[n][0][1][0],dp[n][0][0][1])) << endl;
}

Measured memory_bytes: 8832
#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<iostream>
using namespace std;
long long int lcm(long long int a,long long int b){
  long long int n;
  n=a*b/__gcd(a,b);
  return n;
}
using ll =long long int;
#define ci(a) cin>>a
#define co(a) cout<<a<<endl
#define gcd(a,b) __gcd(a,b)
#define vec vector<ll>
#define For(i,a,b) for(int i=a;i<b;i++)
#define rFor(i,a,b) for(int i=a;i>b;i--)
#define sort(a,b) sort(a.begin(),b.end())
#define reverse(a,b) reverse(a.begin(),b.end())
//gcd 最大公約数
//lcm 最小公倍数
//double 少数（変数）
//string 文字列（変数）
//sqrt 平方根
//ceil 天井関数
//floor 床関数
//abs 絶対値
//pow 累乗
//cbrt  立方根
//hypot 平方和の平方根
//(string-'0') 文字列を数字に変換
//vector<vector<int>> data(a,vector<b>(b)) a×b行列
//for(int i=0;i<a;i++)
//for(int j=0;j<b;j++)
//cin>>data.at(i).at(j)  a×b行列の入力
//floor(log10(a)+1) aの10進法での桁数
//ceil(log10(a)) aの10進法での桁数

int main() {
  ll a;
  ci(a);
  vec b(a);
  For(i,0,a)
    ci(b[i]);
  sort(b,b);
  ll ans=0;
  For(i,0,a)
    ans+=b[i]-1;
  co(ans);
}

Measured memory_bytes: 256
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def LS(): return list(map(list, input().split()))
def S(): return list(input().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = 1e10

#solve
def solve():
    n = II()
    l = LI()
    l.sort()
    print(sum(l[::2]))
    return


#main
if __name__ == '__main__':
    solve()


Measured memory_bytes: 38512
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>
#include <iomanip>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) unique(v.begin(), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
#define all(v) (v).begin(), (v).end()
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1ll << 60;

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}

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

    string s;
    cin >> s;
    if(s[5] == '1') {
        cout << "TBD" << endl;
        return 0;
    }

    if(s[6] == '1' or s[6] == '2' or s[6] == '3' or s[6] == '4') {
        cout << "Heisei" << endl;
        return 0;
    }

    cout << "TBD" << endl;





}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] S = sc.next().toCharArray();
		sc.close();
		// System.out.println("S :" + Arrays.toString(S));

		int[] r = new int[S.length];
		char R = 'R', L = 'L';

		// RからLへまでの距離
		int cnt = 0;
		int[] LL = new int[S.length];
		for(int i = 0; i < S.length; i++) {
			if(S[i] == L) LL[i] = ++cnt;
			else cnt = 0;
		}
		// System.out.println("LL:" + Arrays.toString(LL));

		// LからRへまでの距離
		cnt = 0;
		int[] RR = new int[S.length];
		for(int i = S.length - 1; i >= 0; i--) {
			if(S[i] == R) RR[i] = ++cnt;
			else cnt = 0;
		}
		// System.out.println("RR:" + Arrays.toString(RR));

		// 移動距離の計算
		for(int i = 0; i < S.length; i++) {
			if(RR[i] == 0) {
				if(LL[i] % 2 == 0) ++r[i - LL[i]];
				else ++r[i - LL[i] + 1];
			}
			if(LL[i] == 0) {
				if(RR[i] % 2 == 0) ++r[i + RR[i]];
				else ++r[i + RR[i] - 1];
			}
			// System.out.println(i + ":" + Arrays.toString(r));
		}
		// System.out.println("");

		// 結果の出力
		for(int i = 0; i < S.length; i++) {
			System.out.print(r[i] + " ");
		}
		System.out.println("");
	}
}


Measured memory_bytes: 45500
#include <iostream>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <cstring>
using namespace std;

int main(int argc, char *argv[])
{
	char a, b;
	cin >> a >> b;

	if (a == 'H') {
		cout << b << endl;
	} else {
		if (b == 'H')
			cout << a << endl;
		else
			cout << 'H' << endl;
	}

	return 0;
}


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;

int main() {
    ll n, ans = 0;
    cin >> n;
    for (int i = 1; i <= n; i++)
    {
        if (i % 3 == 0 || i % 5 == 0) continue;
        ans += i;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3600
#include<cstdio>

using namespace std;

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

int main()
{
    int a,b;
    scanf("%d%d",&a,&b);
    printf("%d\n",gcd(a,b));
    return 0;
}


Measured memory_bytes: 2756
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 1000000000
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
typedef long long int ll;

#define ARRAY_MAX 101
#define MOD 1000000007

int main(){

    string s;
    cin >> s;
    reverse(s.begin(),s.end());
    bool ans = true;

    string str[4] = {"maerd","remaerd","esare","resare"};

    for(int i = 0;i < s.length();){

        if(s[i] == 'm'){
            if(i+5 > s.length()){
                ans = false;
                break;
            }
            if(s.substr(i,5) != str[0]){
                ans = false;
                break;
            }else{
                i+=5;
            }
        }else if(s[i] == 'r' && s[i+2] == 'm'){
            if(i+7 > s.length()){
                ans = false;
                break;
            }
            if(s.substr(i,7) != str[1]){
                ans = false;
                break;
            }else{
                i+=7;
            }
        }else if(s[i] == 'e'){
            if(i+5 > s.length()){
                ans = false;
                break;
            }
            if(s.substr(i,5) != str[2]){
                ans = false;
                break;
            }else{
                i+=5;
            }
        }else if(s[i] == 'r' && s[i+2] == 's'){
            if(i+6 > s.length()){
                ans = false;
                break;
            }
            if(s.substr(i,6) != str[3]){
                ans = false;
                break;
            }else{
                i+=6;
            }
        }else{
            ans = false;
            break;
        }
    }
    if(ans){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }


    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i];if(i<len-1) s<<" ";
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i]<<endl;
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){
	s<<"{ ";
	for(auto itr=v.begin();itr!=v.end();++itr) {
		if (itr!=v.begin()) {s<< ", ";}
		s<<(*itr);
	}
	s<<" }";
	return s;
}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){
	s<<"{"<<endl;
	for(auto itr=m.begin();itr!=m.end();++itr){
		s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;
	}
	s<<"}"<<endl;
	return s;
}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double PI=acos(-1);
const double EPS=1e-10;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin>>n;
	map<int,int> mp;
	vector<ll> b;
	rep(i,n){
		int a;
		cin>>a;
		mp[a]++;
	}
	for(auto itr:mp){
		b.push_back(itr.se);
	}
	sort(begin(b),end(b));
	int m=b.size();
	vector<ll> sum(m+1,0);
	rep(i,m){
		sum[i+1]=sum[i]+b[i];
	}
	auto solve=[&](ll x,ll k){
		auto itr=lower_bound(begin(b),end(b),x);
		ll ret=sum[itr-begin(b)]+x*(end(b)-itr);
		return ret>=k*x;
	};
	FOR(k,1,n+1){
		ll ok=0,ng=INF,mid;
		while(ng-ok>1){
			mid=(ok+ng)/2;
			if(solve(mid,k)) ok=mid;
			else ng=mid;
		}
		cout<<ok<<endl;
	}
}

Measured memory_bytes: 19308
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

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






int main() {
    ll n, W;
    cin >> n >> W;
    vector<ll> w(n), v(n);
    REP(i, n){
        cin >> w[i] >> v[i];
    }
    
    vector<vector<ll>> dp(n + 1, vector<ll>(W + 1));
    REP(i, n){
        REP(j, W + 1){
            if(j + w[i] <= W){
                dp[i + 1][j + w[i]] = max(dp[i + 1][j + w[i]], dp[i][j] + v[i]);
            }
            dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);
        }
    }
    cout << dp[n][W] << endl;
}


Measured memory_bytes: 80256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;


int main(){
  int N;
  cin >> N;
  vector<int> v;
  rep(i,N){
    int a;
    cin >> a;
    v.push_back(a);
  }

  {
    bool flg = true;
    rep(k,v.size()-1){
      if(v[k] > v[k+1]) flg = false;
    }
    if(flg){
      cout << "YES" << endl;
      return 0;
    }
  }
  
  rep(i,v.size()){
    REP(j,i+1,v.size()){
      swap(v[i], v[j]);
      bool flg = true;
      rep(k,v.size()-1){
        if(v[k] > v[k+1]) flg = false;
      }
      if(flg){
        cout << "YES" << endl;
        return 0;
      }
      swap(v[i], v[j]);
    }
  }
  cout << "NO" << endl;
  
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int a = scanner.nextInt(), b = scanner.nextInt();
			System.out.println(((a % 3 == 0) || (b % 3 == 0) || ((a + b) % 3 == 0)) ? "Possible" : "Impossible");
		}
	}
}


Measured memory_bytes: 35772
N=list(map(int, input().split()))
if 1 in N:
    if 9 in N:
        if 7 in N:
            if 4 in N:
                print("YES")
            else:
                print("NO")
        else:
            print("NO")
    else:
        print("NO")
else:
    print("NO")


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

using vec = vector<int64_t>;
using mat = vector<vec>;

mat mul(mat &a, mat &b){
	mat c(a.size(), vec(b[0].size()));
	for(int k = 0; k < b.size(); k++){
		for(int i = 0; i < a.size(); i++){
			for(int j = 0; j < b[0].size(); j++){
				c[i][j] += a[i][k] * b[k][j];
			}
		}
	}
	return c;
}

int main(){
	int n, m, l;
	cin >> n >> m >> l;
	mat a(n, vec(m)), b(m, vec(l));
	for(auto &aa:a) for(auto &aaa:aa) cin >> aaa;
	for(auto &bb:b) for(auto &bbb:bb) cin >> bbb;
	mat c = mul(a, b);
	for(int i = 0; i < c.size(); i++){
		for(int j = 0; j < c[i].size(); j++){
			if(j) cout << ' ';
			cout << c[i][j];
		}
		cout << endl;
	}
}

Measured memory_bytes: 3168
#include <iostream>
#include <vector>

#include <iostream>
#include <cmath>
#include <algorithm>
#include <unordered_map>
#include <map>
#include <vector>
#include <unordered_set>
#include <cstdio>
#include <cstdlib>
#include <set>
#include <cstring>
#include <stack>
#include <queue>
#include <numeric>
 
 
//#include <bits/stdc++.h>
typedef long long ll;
#define nl "\n"
#define fast ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

using namespace std;

/*
 
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }
 
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};


*/

int main(){
    int n ;  cin>>n;
    if( n>= 30 ) cout<<"Yes";
    else cout<<"No";
}


Measured memory_bytes: 3648