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

#define rep(i, n) for(long long i=0;i<(long long)(n);i++)
#define rep2(i, s, n) for(long long i=(s);i<(long long)(n);i++)
#define repi(i, n) for(int i=0;i<(int)(n);i++)
#define rep2i(i, s, n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define chmax(s, t) s=max(s,t);
#define chmin(s, t) s=min(s,t); 

#define deg2rad(deg) (((deg)/360)*2*M_PI)
#define rad2deg(rad) (((rad)/2/M_PI)*360)

using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;

const ll INF = (1LL<<60);
const int INFi = (1<<29);

/*素数判定*/
bool is_prime(ll n){
    if(n==1) return false;
    for(ll i=2;i*i<=n;i++){
        if(n%i==0) return false;
    }
    return true;
}

/*約数列挙*/
vll enum_divisors(ll n){
    vll l;
    for(ll i=1;i*i<=n;i++){
        if(n%i==0){
            l.push_back(i);
            if(n/i != i) l.push_back(n/i);
        }
    }
   sort(all(l));
   return l;
}

/*素因数分解*/
vector<P> prime_factorize(ll n){
    vector<P> l;
    for(ll i=2;i*i<=n;i++){
        if(n%i!=0) continue;
        ll e = 0;
        while(n%i==0){
            e++;
            n /= i;
        }
        l.push_back({i, e});
    }
    if(n!=1) l.push_back({n, 1});
    return l;
}

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

/*最大公約数*/
ll gcd(ll a, ll b){
    return __gcd(a,b);
}

/*組み合わせ(Combination)*/
const ll CMAX = 1010000;
const ll CMOD = 1e9+7;
ll fac[CMAX], finv[CMAX], inv[CMAX];
// テーブルを作る前処理
void combinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (ll i = 2; i < CMAX; i++) {
		fac[i] = fac[i - 1] * i % CMOD;
		inv[i] = CMOD - inv[CMOD%i] * (CMOD / i) % CMOD;
		finv[i] = finv[i - 1] * inv[i] % CMOD;
	}
}
// 二項係数計算
ll comb(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % CMOD) % CMOD;
}

/*階乗*/
ll factorial(ll n){
    const ll FMOD = 1e9+7;
    ll ret = n;
    for(ll i=n-1;i>0;i--){
        ret*=i;
        ret%=FMOD;
    }
    return (ret?ret:1);
}


int main(){

    ll n; cin >> n;
    string s; cin >> s;

    if(n >= 3200){
        cout << s << endl;
    }
    else{
        cout << "red" << endl;
    }    


    return 0;
}

Measured memory_bytes: 3612
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        a: usize,
        b: usize,
    }

    let ans = if a <= 8 && b <= 8 {
        "Yay!"
    } else {
        ":("
    };

    println!("{}", ans);
}


Measured memory_bytes: 2160
N,M=[int(i) for i in input().split()]
A=[int(i) for i in input().split()]

cup={}


s=0
cup[s]=1
for num in A:
	s+=num
	s%=M
	if s in cup.keys():
		cup[s]+=1
	else:
		cup[s]=1

res=0
for num in cup.values():
	res+=num*(num-1)//2
print(res)


Measured memory_bytes: 14224
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for(int i=0;i<(int)n;i++)
#define PI acos(-1)
#define fast_io ios_base::sync_with_stdio(false) ; cin.tie(0); cout.tie(0);
ll mod=1e9+7;

ll rep_pow(ll a, ll b){//繰り返し2乗法
    if(b==0) return 1;
    else if(b%2==0){
        ll memo = rep_pow(a, b/2);
        return memo*memo%mod;
    }else{
        return rep_pow(a, b-1)*a%mod;
    }
}
ll nCr(ll n, ll r){//mod逆元使ったnCr
    ll ret=1;
    rep(i,r){
        ret *= n-i;//分子
        ret %= mod;
        ret *=rep_pow(r-i, mod-2);//mod逆元によりr!で割ると同値
        ret %= mod;
    }
    return ret;
}
ll gcd(ll a, ll b){if(b==0) return a; return gcd(b, a%b);}
bool isPrime(int x){
    if(x==1) return false;
    else if(x==2) return true;
    else if(x%2==0) return false;
    for(int i=3;i<=sqrt(x);i+=2){
        if(x%i==0){
            return false;
        }
    }
    return true;
}
int dp[9]={};
int main(){
    fast_io
    
    int n;
    cin>>n;
    int a[n];
    rep(i,n) {
        cin>>a[i];
        if(a[i]>=3200) dp[8]++;
        else dp[a[i]/400]++;
    }
    int ans=0;
    rep(i,8) if(dp[i]!=0) ans++;
    if(ans==0) cout<<1<<" "<<dp[8]<<endl;
    else cout<<ans<<" "<<ans+dp[8]<<endl;
    return 0;
}

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

int a, b, c, k;

int main(void){
    cin >> a >> b >> c >> k;
    bool ans = false;
    for(int v = 0; v <= k; v++){
        for(int i = 0; i <= v; i++){
            for(int j = 0; j <= v; j++){
                for(int l = 0; l <= v; l++){
                    if(i+j+l > k) continue;
                    if((a << i) < (b << j) && (b << j) < (c << l)) ans = true;
                }
            }
        }
    }
    if(ans) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)n; ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cout<<*i<<" "; cout<<endl; }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;

int main(){
  int M;
  cin>>M;
  while(M--){
    int L; cin>>L;
    string s; cin>>s;
    //cout<<s<<endl;
    int N = s.size();
    int ans = 0;
    for(int i = 0; i < N; i++){
      int round = 0;
      int idx = 0;
      bool exist[200];
      REP(j, N)exist[j] = true;
      while(true){
        bool BG[2] = {};
        REP(j, N)if(exist[j]){
          BG[(s[j]=='B')?0:1] = true;
        }
        if(!BG[0] || !BG[1]) break;

        int sec = (L - 1) % (N - round);
        if(round == i) sec = L % (N - round);
        //cout<<sec<<" ";
        while(sec){
          do{
            idx = (idx + 1) % N;
          }while(!exist[idx]);
          sec--;
        }
        exist[idx] = false;
        do{
          idx = (idx + 1) % N;
        }while(!exist[idx]);
        /*
        REP(i, N){
          if(exist[i]) cout<<s[i];
          else cout<<"*";
        }
        cout<<endl;
        */
        round ++;
      }
      int countB = 0;
      REP(i, N) if(exist[i] && s[i] == 'B') countB++;
      //cout<<countB<<endl;
      ans = max(ans, countB);
    }
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 924
# coding: utf-8
#Problem Name: Debt Hell
#ID: tabris
#Mail: t123037@kaiyodai.ac.jp

n = float(raw_input())
dept = 100000
for i in range(int(n)):
    dept *= 1.05
    if not (dept/1000).is_integer():
        dept /= 1000
        dept = __import__('math',fromlist=['floor']).floor(dept)*1000+1000
print int(dept)

Measured memory_bytes: 4368
#include<cstdio>
#include<cstring>
int main(){
    int a[]={
      0,  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
    };
    int x;scanf("%d",&x);
    printf("%d\n",a[x]);
    return 0;
}

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

int main() {
  int n,y; cin >>n >>y;
  y /= 1000; // 10円札、5円札、1円札の問題にする。1<=y<=20000
  int ansi = -1, ansj = -1, ansk = -1;
  bool ok = false;
  
  for (int i=0; i<=y/10; i++){
    for (int j=0; j<=(y-10*i)/5; j++){
      int k = n - i - j;
      if (10*i+5*j+k == y){
        ansi = i; ansj = j; ansk = k;
        ok = true; break;
      }
    if (ok) break;
    }
  }
  
  cout <<ansi <<" " <<ansj <<" " <<ansk;
  //cout <<ans;
  cout <<endl;
}


Measured memory_bytes: 256
#pragma gcc optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort(ALL(V)) //小さい方からソート
#define REV(V) reverse(ALL(V)) //リバース
#define RSORT(V) SORT(V);REV(V) //大きい方からソート
#define NPN(V) next_permutation(ALL(V)) //順列
#define pb(n) push_back(n)
#define endl '\n'
#define Endl '\n'
#define DUMP(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define Yay(n) cout << ((n) ? "Yay!": ":(") << endl
#define RAPID cin.tie(0);ios::sync_with_stdio(false)
#define IN(n) cin >> n
#define IN2(a,b) cin >> a >> b
#define IN3(a,b,c) cin >> a >> b >> c 
#define IN4(a,b,c,d) cin >> a >> b >> c >> d
#define VIN(V) for(int i = 0; i < (V).size(); i++) {cin >> (V).at(i);}
#define OUT(n) cout << n << endl
#define VOUT(V) REP(i, (V).size()) {cout << (V)[i] << endl;}
#define VOUT2(V) REP(i, (V).size()) {cout << (V)[i] << " ";} cout<<endl;

// 型マクロ定義
#define int long long
#define P pair<ll,ll>
#define Vi vector<ll>
#define Vd vector<double>
#define Vs vector<string>
#define Vc vector<char>
#define M map<ll,ll>
#define S set<ll>
#define PQ priority_queue<ll>
#define PQG priority_queue<ll,V,greater<ll>
//

const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);

int gcd(int a,int b){return b?gcd(b,a%b):a;} //最小公倍数

// デフォルト変数定義
int n,m,a,b,c,d,x,y,z;
string s,t,u;
string rs="";
//

signed main() {
  RAPID;
  IN3(s,t,u);
  rs.pb(s[0]);
  rs.pb(t[1]);
  rs.pb(u[2]);
  OUT(rs);
}

Measured memory_bytes: 256
K = int(input())
seq = list(map(str, range(1, 10)))
answer = seq[:]
while True:
    tmp = []
    for i in seq:
        if i[-1] == '0':
            tmp.append(i + '0')
            tmp.append(i + '1')
        elif i[-1] == '9':
            tmp.append(i + '8')
            tmp.append(i + '9')
        else:
            t = ord(i[-1])
            tmp.append(i + chr(t - 1))
            tmp.append(i + i[-1])
            tmp.append(i + chr(t + 1))
    seq = tmp[:]
    answer.extend(seq[:])
    if len(seq) > K:
        break

answer = list(map(int, answer))
answer.sort()
print(answer[K - 1])


Measured memory_bytes: 27696
#include<stdio.h>

int main() {
  int i, j, a[100], n, temp, cnt=0;

  scanf("%d", &n);
  for(i = 0; i < n; i++) scanf("%d", &a[i]);

  for(i = 0; i < n; i++){
    for(j = n - 1; j != i; j--){
      if(a[j] < a[j - 1]){
        temp = a[j];
        a[j] = a[j-1];
        a[j-1] = temp;
        cnt++;
      }
    }
  }
  for(i = 0; i < n; i++){
      printf("%d", a[i]);
      if(i < n-1) printf(" ");
      else printf("\n%d\n", cnt);
  }
  return 0;
}


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


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

    string ans;
    if(d == 25) ans = "Christmas";
    else if(d == 24) ans = "Christmas Eve";
    else if(d == 23) ans = "Christmas Eve Eve";
    else if(d == 22) ans = "Christmas Eve Eve Eve";

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define mod (int)(1e9+7)
#define inf (int)(3e18)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P std::pair<int,int>
#define PiP std::pair<int,std::pair<int,int>>
#define all(v) v.begin(),v.end()
#define mkp std::make_pair
#define prique(T) std::priority_queue<T,vector<T>,greater<T>>
using namespace std;
template<class T> inline void chmax(T& a, T b) { a = std::max(a, b); }
template<class T> inline void chmin(T& a, T b) { a = std::min(a, b); }

bool prime(int x) {
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0)return false;
	}
	return x != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}
int get_rand(int MIN, int MAX) {
	std::random_device rnd;
	std::mt19937 mt32(rnd());
	std::uniform_int_distribution<int>engine(MIN, MAX);
	return engine(mt32);
}
/*--------Library Zone!--------*/

int n, k, q;
int a[2005];
bool ng[2005];
P p[2005];
signed main() {
	cin >> n >> k >> q;
	rep(i, n) {
		cin >> a[i];
		p[i] = { a[i],i };
	}
	sort(p, p + n);
	int ans = inf;
	vector<int>ngs = { -1,n };
	rep(i, n + 1) {
		vector<int>v;
		rep(j, ngs.size() - 1) {
			if (ngs[j + 1] - ngs[j] - 1 < k)continue;
			vector<int>v2;
			for (int l = ngs[j] + 1; l < ngs[j + 1]; l++)v2.push_back(a[l]);
			sort(all(v2));
			rep(l, (ngs[j + 1] - ngs[j]) - k) {
				v.push_back(v2[l]);
			}
		}
		if (v.size() < q)break;
		sort(all(v));
		chmin(ans, v[q - 1] - v[0]);
		ngs.push_back({ p[i].second });
		sort(all(ngs));
	}
	cout << ans << endl;
}


Measured memory_bytes: 384
from heapq import heappush, heappop
n, k = map(int, input().split())

H = []
for i in range(n):
    t, d = map(int, input().split())
    heappush(H, (- d, t))

Q = []
used = {}
dsum = 0
for i in range(k):
    d, t = heappop(H)
    if t not in used:
        used[t] = 1
    else:
        heappush(Q, (- d, t))
    dsum += - d
    
ans = len(used) ** 2 + dsum
        
#print(H)
#print(Q)
#print(used)
#print(dsum)
#print(ans)

while H and Q:
    d, t = heappop(H)
    if t not in used:
        used[t] = 1
        m, _ = heappop(Q)
        dsum = dsum - m - d
        ans = max(ans, len(used) ** 2 + dsum)
        
print(ans)

Measured memory_bytes: 21280
#include<iostream>
#include <stdio.h>
using namespace std;
 int main(void){
	int n;
    cin>>n;
    if (n == 1){
      cout<<"Hello World"<<endl;
    }
    if (n == 2){
      int a;
      int b;
      cin>>a;
      cin>>b;
     cout<<a + b<<endl ;
   }
}

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

/* set使用 */
int main(){
  int N;
  cin >> N;

  set<int> mochi;
  int size;
  while(N--){
    cin >> size;
    mochi.insert(size);
  }
  
  cout << mochi.size() << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
typedef long long ll;
typedef pair<int,int> ip;
typedef pair<ll,ll> lp;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

int main(){
	int N,a,b;
	cin>>N>>a>>b;
	int ans = 0;
	for(int cnt = 1; cnt<=N; ++cnt){
		int i = cnt;
		int sum = i%10;
		while(i/10 != 0){
			i /= 10;
			sum += i%10;
		}
		if(a <= sum && sum <= b)ans += cnt;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#C
import sys
n, m = map(int, input().split())
sc = [list(map(int, input().split())) for _ in range(m)]
sc.sort(key=lambda x: x[0])
ans = [-1] * n
for i in range(m):
    #すでに値が入っているAND値が同じではない
    if ans[sc[i][0]-1] != -1 and ans[sc[i][0]-1]!=sc[i][1]:
        print(-1)
        sys.exit() 
    ans[sc[i][0] - 1] = sc[i][1]
#1桁目が-1未定義 =>0はダメ
if ans[0] == -1 and n >= 2:
    ans[0] = 1

if ans[0] == 0 and n>=2:
    print(-1)
    sys.exit()
for i in ans:
    if i == -1:
        print(0, end="")
    else:
        print(i,end="")

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

using namespace std;

typedef unsigned uint;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ldbl;
typedef pair<int, int> pii;
typedef pair<uint, uint> puu;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pull;
typedef pair<double, double> pdd;
typedef vector<int> vi;
typedef vector<uint> vu;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<pii> vpii;
typedef vector<puu> vpuu;
typedef vector<pll> vpll;
typedef vector<pull> vpull;
typedef vector<string> vstr;
typedef vector<double> vdbl;
typedef vector<ldbl> vldbl;
#define pb push_back
#define ppb pop_back
#define pfr push_front
#define ppfr pop_front
#define emp emplace
#define empb emplace_back
#define be begin
#define rbe rbegin
#define all(x) (x).be(), (x).end()
#define rall(x) (x).rbe(), (x).rend()
#define fir first
#define sec second
#define mkp make_pair
#define brif(cond) if (cond) break
#define ctif(cond) if (cond) continue
#define retif(cond) if (cond) return
void canhazfast() {ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);}
template<typename T> T gcd(T a, T b) {return b ? gcd(b, a%b) : a;}
template<typename T> T extgcd(T a, T b, T &x, T &y)
{
    T x0 = 1, y0 = 0, x1 = 0, y1 = 1;
    while (b) {
        T q = a/b; a %= b; swap(a, b);
        x0 -= q*x1; swap(x0, x1);
        y0 -= q*y1; swap(y0, y1);
    }
    x = x0; y = y0; return a;
}
int ctz(uint x) {return __builtin_ctz(x);}
int ctzll(ull x) {return __builtin_ctzll(x);}
int clz(uint x) {return __builtin_clz(x);}
int clzll(ull x) {return __builtin_clzll(x);}
int popcnt(uint x) {return __builtin_popcount(x);}
int popcntll(ull x) {return __builtin_popcountll(x);}
int bsr(uint x) {return 31^clz(x);}
int bsrll(ull x) {return 63^clzll(x);}

#define MX 200016


int main()
{
    canhazfast();

    int q, xm = 0;
    ll sl = 0, sh = 0, sb = 0;
    priority_queue<int> ql;
    priority_queue<int, vi, greater<int>> qh;

    cin >> q;
    for (int i = 0; i < q; ++i) {
        int t, a, b;
        cin >> t;
        if (t == 1) {
            cin >> a >> b;
            sb += b;
            if (ql.empty() || a < ql.top()) ql.push(a), sl += a;
            else qh.push(a), sh += a;
            while (qh.size() > ql.size()) {
                int x = qh.top();
                qh.pop();
                sh -= x;
                sl += x;
                ql.push(x);
            }
            while (qh.size()+1 < ql.size()) {
                int x = ql.top();
                ql.pop();
                sl -= x;
                sh += x;
                qh.push(x);
            }
            xm = ql.top();
            //assert(ql.empty() || qh.empty() || ql.top() <= qh.top());
        } else {
            ll ans = sb+sh-sl;
            if (ql.size() > qh.size()) ans += xm;
            cout << xm << ' ' << ans << '\n';
        }
    }

    return 0;
}


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

int main(){
 int n;
 cin >> n;
 vector<int> p(n);
 for(int i=0;i<n;i++){
    cin >> p.at(i);
 }
 int count = 0;
 for(int k=2;k<n;k++){
    if((p[k-2]>p[k-1]&&p[k]<p[k-1])||(p[k-2]<p[k-1]&&p[k]>p[k-1])) count++;
 }
 cout << count << endl;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"log"
	"math"
	"os"
	"strconv"
)

func main() {
	n := readInt()
	d := readInt()
	points := make([][]int, n)
	
	for i := range points {
		point := make([]int, d)
		for j := range point {
			point[j] = readInt()
		}
		points[i] = point
	}
	
	counter := 0
	for i := 0; i < n; i++ {
		for j := i + 1; j < n; j++ {
			iList := points[i]
			jList := points[j]
			distance := 0.0
			for k := 0; k < d; k++ {
				distance += math.Pow(float64(iList[k]-jList[k]), 2)
			}
			if math.Pow(distance, 0.5) == math.Ceil(math.Pow(distance, 0.5)) {
				counter++
			}
		}
	}
	
	fmt.Println(counter)
}

func checkErr(err error) {
	if err != nil {
		log.Fatal(err)
	}
}

func toInt(s string) int {
	i, e := strconv.Atoi(s)
	checkErr(e)
	return i
}

func nextLine(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func readInt() int {
	var num int
	_, e := fmt.Scan(&num)
	checkErr(e)
	return num
}

func readStr() string {
	var str string
	_, e := fmt.Scan(&str)
	checkErr(e)
	return str
}

func readLine() string {
	var scanner = bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanLines)
	return nextLine(scanner)
}


Measured memory_bytes: 640
N, K = map(int, input().split())
have_sweets = []
for i in range(K):
    d = int(input())
    have_sweets += list(map(int, input().split()))
have_sweets = set(have_sweets)
print(len(list(set([i for i in range(1, N+1)])-have_sweets)))


Measured memory_bytes: 9120
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
typedef long long ll;
typedef pair<int, int> P;
typedef pair<pair<int, int>, int> PP;
const ll INFL = 1LL << 60;
const ll MOD = 1000000007;
const int INF = 1000000005;
const int MAX = 300000;
ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
ll LCM(ll a, ll b) { return (a * b) / GCD(a, b); }
//------------------------------------------------------------------------------------------------------------------------------

int main(void) {
    // code here
    string s;
    cin >> s;
    if(s[2]==s[3]&&s[4]==s[5]){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cassert>
#include<cstring>
using namespace std;

#define sz(x) (int)(x.size())
#define fi(a,b) for(int i=a;i<b;++i)
#define fj(a,b) for(int j=a;j<b;++j)
#define fo(a,b) for(int o=a;o<b;++o)
#define fdj(a,b) for(int j=a-1;j>=b;--j)
#define pb push_back
typedef long long ll;
/////////////////////

int const N = 5e5 + 41;

int l[N];

string str;
int n;

vector<int> getdivisors(int n){
	vector<int> res;
	res.pb(1);
	while(n > 1){
		int m = sz(res);
		fdj(m, 0) res.pb(res[j] * l[n]);
		n /= l[n];
	}
	return res;
}

void init(){
	for(int i=2;i<N;++i){
		if(!l[i]){
			for(int j=i;j<N;j+=i){
				if(l[j] == 0 || l[j] > i) l[j] = i;
			}
		}
	}
}

namespace Hash{
	static int const K = 2;
	int h[K][N], d[K][N];
	static int const P[K] = {63, 61};
	static int const MOD[K] = {1000001531, 1000002187};//, 1000000007, 1000002277};

	int mul(int a, int b, int mod){
		return (ll) a * b % mod;
	}

	int sum(int a, int b, int mod){
		a %= mod;
		while(a < 0) a += mod;
		b %= mod;
		while(b < 0) b += mod;
		return (a + b) % mod;
	}

	void build(){
		fi(0, K) d[i][0] = 1;
		fi(1, N) fj(0, K){
			d[j][i] = mul(d[j][i-1], P[j], MOD[j]);
		}
		fi(0, sz(str)) fj(0, K){
			h[j][i] = mul( (i ? h[j][i-1] : 0), P[j], MOD[j]);
			h[j][i] = sum(h[j][i], (str[i] - 'a' + 1), MOD[j]);
		}
	}

	vector<int> gethash(int l, int r){
		vector<int> res;
		fi(0, K){
			int x = h[i][r];
			if(l) x = sum(x, -mul(h[i][l-1], d[i][r-l+1], MOD[i]), MOD[i]);
			res.pb(x);
		}
		return res;
	}
};

bool checkone(){
	fi(1, n){
		if(n % i == 0){
			vector<int> h = Hash::gethash(0, i-1);
			bool ok = true;
			for(int j=0;j<n;j+=i){
				vector<int> h0 = Hash::gethash(j, j+i-1);
				if(h0 != h){
					ok = false;
					break;
				}
			}
			if(ok) return false;
		}
	}	
	return true;
}

bool checkall(){
	fi(0, sz(str)) if(str[i] != str[0]) return false;
	return true;
}

int p[N], s[N];

void build(){
	fi(0, n+1) p[i] = s[i] = 1;
	fi(1, n+1){
		vector<int> h = Hash::gethash(0, i-1);
		for(int j=i+i;j<=n;j+=i){
			vector<int> h0 = Hash::gethash(j-i, j-1);
			if(h != h0) break;
			p[j-1] = 0;
		}
	}
	fi(1, n+1){
		vector<int> h = Hash::gethash(n-i, n-1);
		for(int j=i+i;j<=n;j+=i){
			vector<int> h0 = Hash::gethash(n-j, n-j+i-1);
			if(h != h0) break;
			s[n-j] = 0;
		}
	}
}

int checktwo(){
	int res = 0;
	fi(0, n-1){
		res += (p[i] && s[i+1]);
	}
	return res;
}

void solve(){
	n = sz(str);
	Hash::build();
	if(checkall()){
		cout << n << " " << 1 << endl;
		return;
	}
	if(checkone()){
		cout << 1 << " " << 1 << endl;
		return;
	}
	
	build();
	
	if(checktwo() > 0){
		cout << 2 << " " << checktwo() << endl;
		return;
	}

	cout << 3 << " " << 1 << endl;

	/*int ans = 0;

	fi(0, n) fj(i+1, n-1){
	if(!p[i]) continue;
	if(!s[j+1]) continue;
	string s = str.substr(i+1, j-i);
	if(!checkstring(s)) ++ans;
	}
	if(ans > 1){
	cerr << str << " " << ans << endl;
	exit(0);
	}*/
}

int main(){
#ifdef _DEBUG
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif

	init();

	cin >> str;

	solve();


	return 0;
}

Measured memory_bytes: 14596
#include <bits/stdc++.h>
#include <math.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1001001001;
const int mINF = -1001001001;

int main() {
char s[6];
cin >> s;
int flg=-1;
if(s[2]==s[3])  flg++;
if(s[4]==s[5]) flg++;

if(flg==1) {
  cout << "Yes" << endl;
} else {
  cout << "No" << endl;
}
return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define int long long
struct UnionFind{
  vector<int> r,p;
  UnionFind(){}
  UnionFind(int size){init(size);}
  void init(int size){
    r.resize(size,0);
    p.resize(size,0);
    for(int i=0;i<size;i++) r[i]=1,p[i]=i;
  }
  int find(int x){
    return (x==p[x]?x:p[x]=find(p[x]));
  }
  bool same(int x,int y){
    return find(x)==find(y);
  }
  void unite(int x,int y){
    x=find(x);y=find(y);
    if(x==y) return;
    if(r[x]<r[y]) swap(x,y);
    r[x]+=r[y];
    p[y]=x;
  }
};
bool solve(int odd,int eve){
  int msz=odd+eve;
  if(!odd) return 1;
  if(msz==2) return odd==0;
  if(msz%2==0) return 1;
  if((msz-2)/2>=odd/2) return 1; 
  return 0;
}
signed main(){
  int n;
  cin>>n;
  string s[n];
  for(int i=0;i<n;i++) cin>>s[i];
  UnionFind uf(n);
  int cnt=0;
  for(int i=0;i<n;i++)
    for(int j=i+1;j<n;j++)
      if(s[i][j]=='Y') uf.unite(i,j),cnt++;
  map<int,int> m;
  for(int i=0;i<n;i++) m[uf.find(i)]++;
  int step=n*(n-1)/2;
  int sz=0;
  for(int i=0;i<n;i++) if(uf.find(i)==i) sz++;
  //step-=(cnt+(sz-2));
  step-=cnt;
  //cout<<step<<":"<<sz<<":"<<cnt<<endl;
  if(n%2){
    cout<<(step%2==1?"Taro":"Hanako")<<endl;
    return 0;
  }
  int odd=0,eve=0,flg=0;
  for(auto p:m){
    if(p.second%2) odd++;
    else eve++;
  }
  
  map<int,int> c;
  for(int i=0;i<n;i++)
    for(int j=i+1;j<n;j++)
      if(s[i][j]=='Y') c[uf.find(i)]++;
  for(auto p:c){
    int k=m[p.first];
    flg|=k*(k-1)/2>p.second;
    //cout<<k*(k-1)/2<<" "<<p.second<<endl;
  }
  //cout<<step<<" "<<sz<<":"<<odd<<" "<<eve<<":"<<flg<<endl;
  if(step%2==0){
    cout<<(solve(odd,eve)==0?"Taro":"Hanako")<<endl;
  }else{
    bool f=(odd==0&&eve==2);
    f|=solve(odd,eve);
    if(eve>=1&&odd+eve-1>=2) f|=solve(odd,eve-1);
    if(odd>=2&&odd+eve-1>=2) f|=solve(odd-2,eve+1);
    cout<<(f?"Taro":"Hanako")<<endl;
  }
  return 0;
}

Measured memory_bytes: 4224
import sys
input=sys.stdin.readline

N,M = (int(x) for x in input().rstrip('\n').split())
As = [int(x) for x in input().rstrip('\n').split()]
As = sorted(As,reverse = True)
rest = M
for _ in range(M):
  if rest == 0:
    break
  d = As[0]
  b = d//2 - d//4
  for i in range(N):
    a = As[i]
    check = 0
    if a-a//2<b:
      if rest > i:
        ad = [x//2 for x in As[:i]]
        As = As[i:]
        As.extend(ad)
        rest -= i
        check += 1
        As = sorted(As,reverse = True)
        break
      else:
        ad = [x//2 for x in As[:rest]]
        As = As[rest:]
        As.extend(ad)
        check += 1
        rest = 0
        break
    if i == N-1:
      if check == 0:
        if rest > N:
          As = [x//2 for x in As]
          rest -= N
        else:
          ad = [x//2 for x in As[:rest]]
          As = As[rest:]
          As.extend(ad)
          rest = 0
          break
print(sum(As))


Measured memory_bytes: 20160
/* ex5_3.c Grid Compression
    dada__              */
#include<stdio.h>

int main(void){
    int row, col, i, j;
    scanf("%d %d", &row, &col); //行と列の数の入力
    int judge_row[row], judge_col[col];
    char grid[row][col];

    for(i=0;i<row;i++){
        judge_row[i]=0;
    }
    for(j=0;j<col;j++){
        judge_col[j]=0;
    }

    //各マス目の記号の入力
    for(i=0;i<row;i++){
        for(j=0;j<col;j++){
            scanf(" %c", &grid[i][j]);
            if(grid[i][j]=='#'){
                judge_row[i]=1;
                judge_col[j]=1;
            }
        }
    }

    //各判定に基づいた出力
    for(i=0;i<row;i++){
        if(judge_row[i]==1){ //行の判定が1の場合に出力
            for(j=0;j<col;j++){
                if(judge_col[j]==1){//列の判定が1の場合に出力
                    printf("%c", grid[i][j]);
                }
            }
            printf("\n");
        }
    }
    return 0;
}

Measured memory_bytes: 128
/// Containers Start
#include <algorithm>
#include <bitset>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <regex>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
/// C Header Files
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <math.h>
#include <stdio.h>
/// Containers End

using namespace std;

/// Math Start
#define PI acos(-1.0)
#define Pi 3.141592653589793
#define EPS (1e-7)
#define INF (0x3f3f3f3f)
/// Math End

/// Extra Start
#define nn '\n'
#define pb push_back
#define ull unsigned long long
#define ll long long
#define MOD 1000000007
#define sz(a) int((a).size())
#define space " "
#define All(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
/// Extra End

#define rep(i, n) for (int i = 0; i < n; i++)
#define Cini(a)                                                                \
    int a;                                                                     \
    cin >> a;
#define Cinii(a, b)                                                            \
    int a, b;                                                                  \
    cin >> a >> b;
#define Ciniii(a, b, c)                                                        \
    int a, b, c;                                                               \
    cin >> a >> b >> c;
#define Cins(s)                                                                \
    string s;                                                                  \
    cin >> s;
#define Cinss(s1, s2)                                                          \
    string s1, s2;                                                             \
    cin >> s1 >> s2;
#define Cinc(c)                                                                \
    char c;                                                                    \
    cin >> c;
/// Functions End

/// Debug Start
#define deb(x) cout << #x << ": " << x << endl
#define deb2(x, y) cout << #x << ": " << x << '\t' << #y << ": " << y << endl;
#define deb3(x, y, z)                                                          \
    cout << #x << ": " << x << '\t' << #y << ": " << y << '\t' << #z << ": "   \
         << z << endl;
/// Debug End

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

/**>>>>>>>>>>>>>>>>>>> END <<<<<<<<<<<<<<<<<<**/

/// template

signed main(void) {
    cin.sync_with_stdio(false);
    cin.tie(0);
    Cinc(c);
    if(c>='A' && c<='Z') cout << 'A' << nn;
    else cout << 'a' << nn;
    return 0;
}

Measured memory_bytes: 3064
s = int(input())
ans = [s]
i = 0
while True:
  if ans[i] %2 == 0:
    ans.append(int(ans[i]/2))
  else:
    ans.append(3*ans[i] + 1)
  if ans.count(ans[i]) == 2:
    print(i+1)
    exit()
  else:
    i += 1

Measured memory_bytes: 3060
using System;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        string input1 = Console.ReadLine();
        var numbers = Console.ReadLine()
            .Split(' ')
            .Select(t => int.Parse(t))
            .ToList();

        var dup = numbers.GroupBy(n => n)
            .Any(grp => grp.Count() > 1);

        Console.WriteLine(dup ? "NO" : "YES");
    }
}

Measured memory_bytes: 51764
import sys
n=int(input())
a=list(map(int,sys.stdin.read().split()))
a.sort()

ptr,res=0,0
while ptr < n:
  cc=a[ptr]
  f=0
  while ptr < n and a[ptr]==cc:
    f+=1
    ptr+=1
  res+=f%2
print(res)


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

using namespace std;

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

	long u,v;
	long  nn;

	vector<vector<int>> g(n + 1, vector<int>(n + 1,0));
	for (int i = 1; i <= n; i++) {

		cin >> u;
		cin >> nn;
		for (int j = 1; j <= nn; j++) {

			cin >> v;
			g[u][v] = 1;
		}
	}
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= n-1; j++) {
			cout << g[i][j] << " ";
		}
		cout << g[i][n] << endl;
	}

	return 0;

}


Measured memory_bytes: 3168
a = int(input())
b = int(input())
c = int(input())
d = int(input())

if a >=  b :
    if c >= d : 
        print(b+d)
    else :
        print(b+c)
else :
    if c >= d : 
        print(a+d)
    else :
        print(a+c)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main(){
    #define int long long
	int n, x=1000, b;
	cin >> n;
	int a[n+1];
	for (int i=1; i<=n; i++) cin >> a[i];
	for (int i=1; i<n; i++)
		if (a[i+1]>a[i]){
			b=x/a[i];
			x%=a[i];
			b*=a[i+1];
			x+=b;
		}
	cout << x << endl;
	return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define cool ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
int main()
{ 
    cool;
    int ab,bc,ca;
    cin>>ab>>bc>>ca;
    cout<<((ab*bc)/2)<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int M = scanner.nextInt();

        int[][] a = new int[N][N];
        int[][] b = new int[N][N];
        for (int i = 0; i < N; i++) {
            for (int j = 0; j < N; j++) {
                if (i!=j)
                    b[i][j] = Integer.MAX_VALUE/4;
            }
        }

        for (int i = 0; i < M; i++) {
            int v1 = scanner.nextInt() - 1;
            int v2 = scanner.nextInt() - 1;
            int c = scanner.nextInt();
            a[v1][v2] = a[v2][v1] = b[v1][v2] = b[v2][v1] = c;
        }

        for (int k = 0; k < N; k++) {
            for (int i = 0; i < N; i++) {
                for (int j = 0; j < N; j++) {
                    b[i][j] = Math.min(b[i][j],b[i][k]+b[k][j]);
                }
            }
        }
        int ret = 0;
        for (int i = 0; i < N; i++) {
            for (int j = i+1; j < N; j++) {
                if (a[i][j]>b[i][j])
                    ret++;
            }
        }
        System.out.println(ret);
    }
}

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

//dijkstraでsから0=>N-1迄のa_nに関する最短経路問題を解く
//dijkstraで0=>N-1からt迄のb_nに関する最短経路問題を解く

vector<ll> dijkstra(int s, vector<vector<pair<int, int>>> G) {
    const ll INF = numeric_limits<ll> :: max();
    using P = pair<int, int>;
    //vec[i] := sからiへ行くまでの最短距離
    priority_queue<P, vector<P>, greater<P>> pq;
    int N = G.size();
    vector<ll> dist(N, INF);
    dist[s] = 0;
    pq.emplace(P(dist[s], s));
    while(pq.size()) {
        P p = pq.top();
        pq.pop();
        int v = p.second;
        ll d = p.first;
        if (d > dist[v]) {
            continue;
        }
        for (int i = 0; i < G[v].size(); i++) {
            P e = G[v][i];
            int nv = e.first; //nv := vから次に行く点
            ll c = dist[v] + e.second; //c := sからnvまでの暫定最短距離（？）
            if (dist[nv] > c) {
                dist[nv] = c;
                pq.emplace(P(dist[nv], nv));
            }
        }
    }
    return dist;
}

int main() {
    int N, M;
    cin >> N >> M;
    int s, t; cin >> s >> t; s--; t--;
    vector<vector<pair<int, int>>> Ga;
    vector<vector<pair<int, int>>> Gb;
    Ga.resize(N);
    Gb.resize(N);
    vector<ll> yen(N), snu(N);
    for (int i = 0; i < M; i++) {
        int u, v, a, b; cin >> u >> v >> a >> b;
        u--; v--;
        Ga[u].push_back(make_pair(v, a));
        Ga[v].push_back(make_pair(u, a));
        Gb[u].push_back(make_pair(v, b));
        Gb[v].push_back(make_pair(u, b));
    }

    //ダイクストラで配列を生成
    yen = dijkstra(s, Ga); //yen[i] := sから円のみを用いてi番目の都市へ行く最短距離
    snu = dijkstra(t, Gb); //snu[i] := tからすぬーくのみを用いてi番目の都市へ行く最短距離
    //MAX[i]がsからtへ移動した際に所持できるすぬーくの最大値
    vector<ll> MAX(N, 0);
    for (int i = 0; i < N; i++) {
        MAX[i] = 1e15 - yen[i] - snu[i];
    }
    reverse(MAX.begin(), MAX.end());
    vector<ll> ans(N, 0);
    ans[0] = MAX[0];
    for (int i = 1; i < N; i++) {
        ans[i] = max(MAX[i], ans[i-1]);
    }
    reverse(ans.begin(), ans.end());
    for (int i = 0; i < N; i++) {
        cout << ans[i] << endl;
    }
}

Measured memory_bytes: 21724
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define ll          long long
#define pb          push_back
#define mp 			make_pair
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define mod        1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
using namespace std;

ll fun(ll x,ll n,bool p,bool q,bool r)
{
    if(x>n)
    return 0;
    ll a,b,c,s=0;
    if(x<=n and p and q and r)
    {
        s=1;
    }
    a=x*10+3;
    if(a<=n)
    s+=fun(a,n,1,q,r);
    b=x*10+5;
    if(b<=n)
    s+=fun(b,n,p,1,r);
    c=x*10+7;
    if(c<=n)
    s+=fun(c,n,p,q,1);
    return s;
}

void solve()
{
    ll n;
    cin>>n;
    cout<<fun(0ll,n,0,0,0);
}

signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int t=1;
	//cin>>t;
	while(t--)
	{
		solve();
	}
	return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
)

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)

	var N, K int
	scanner.Scan()
	fmt.Sscanf(scanner.Text(), "%d", &N)
	scanner.Scan()
	fmt.Sscanf(scanner.Text(), "%d", &K)

	xs := make([]int, N)
	for i := 0; i < N; i++ {
		scanner.Scan()
		fmt.Sscanf(scanner.Text(), "%d", &xs[i])
	}

	if xs[0] >= 0 {
		fmt.Println(xs[K-1])
		return
	}
	if xs[len(xs)-1] <= 0 {
		fmt.Println(abs(xs[len(xs)-K]))
		return
	}

	fstPosIndex := 0
	for i := 0; i < len(xs); i++ {
		if xs[i] > 0 {
			fstPosIndex = i
			break
		}
	}

	left := max(fstPosIndex-K, 0)
	right := min(fstPosIndex+K-1, N-1)
	//fmt.Println("range", left, right)

	ans := math.MaxInt64
	for i := left; i+K-1 <= right; i++ {
		cost := min(2*abs(xs[i])+abs(xs[i+K-1]),
			abs(xs[i])+2*abs(xs[i+K-1]))
		//fmt.Print(i, i+K-1)
		//fmt.Println(" => cost", cost)
		ans = min(ans, cost)
	}

	if ans == math.MaxInt64 {
		ans = 0
	}
	fmt.Println(ans)

}

func min(ns ...int) int {
	ret := math.MaxInt64
	for _, n := range ns {
		if n < ret {
			ret = n
		}
	}
	return ret
}

func max(ns ...int) int {
	ret := math.MinInt64
	for _, n := range ns {
		if n > ret {
			ret = n
		}
	}
	return ret
}

func abs(n int) int {
	if n >= 0 {
		return n
	}
	return -n
}


Measured memory_bytes: 5504
#include <algorithm>
#include<iostream>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<string>
#include <sstream>

#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<limits.h>
#define INF 1 << 30
using namespace std;


int dp[21][50001];

int main(){

  int ii,jj,kk;
  vector<int> ret;
  int n,m;


  cin >> n >> m;

  vector<int> coin(m);
  //int coin[m];
  
  for(ii=0;ii<m;ii++){
    cin >> coin[ii];
  }

  //sort(coin.begin(),coin.end(), std::less<int>());
  //  cout << "input end" << endl;
  for(ii=0;ii<=n;ii++){
    for(jj=0;jj<=m;jj++){
      dp[jj][ii] = INF;
    }    
  }


  dp[0][0] = 0;
  
  for(ii=0;ii<m;ii++){
    for(jj=0;jj<=n;jj++){
      if(jj-coin[ii] >= 0){
        dp[ii+1][jj] = min(dp[ii][jj]
                           ,dp[ii+1][jj-coin[ii]] + 1);
      }
      else{
        dp[ii+1][jj] = dp[ii][jj];
      }
      
    }    
  }

  //for(ii=0;ii<m;ii++){
  //  cout << coin[ii] << ",";
  //}
  //cout << endl;
  //
  //for(jj=0;jj<=n;jj++){
  //  for(ii=0;ii<=m;ii++){      
  //    cout << dp[ii][jj] << "," ;
  //  }
  //  cout << endl;
  //}
  
  cout << dp[m][n] << endl;
  
  return 0;

}



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

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

void ABC136D()
{
	string S;
	cin >> S;
	int N = S.size();
	vector<int> x;
	for (int i = 0; i < N-1; ++i)
	{
		if (S[i] == 'R' && S[i + 1] == 'L')
			x.push_back(i);
	}
	vector<int> ret(N);
	for (int i = 0; i < N; ++i)
	{
		if (S[i] == 'R')
		{
			auto j = *lower_bound(x.begin(), x.end(), i);
			if ((j - i) % 2 == 0)
			{
				++ret[j];
			}
			else
			{
				++ret[j + 1];
			}
		}
		else
		{
			auto j = *(--lower_bound(x.begin(), x.end(), i));
			if ((i - j) % 2 == 0)
			{
				++ret[j];
			}
			else
			{
				++ret[j + 1];
			}
		}
	}
	for (int i = 0; i < N; ++i)
	{
		cout << ret[i];
		if (i < N - 1)
			cout << ' ';
	}
	cout << endl;
}

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

Measured memory_bytes: 1280
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <math.h>
#define mod 1000000007
typedef long long ll;
using namespace std;

#define N 100010
ll inv[N],fac[N],ifac[N];

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

  int first=0,second=0;
  for(int i=0;i<=n;i++){
    cin>>a[i];
    if(p[a[i]]>=0){
      first=p[a[i]];
      second=i;
    }else{
      p[a[i]]=i;
    }
  }

  inv[0]=1;inv[1]=1;fac[1]=1;ifac[1]=1;fac[0]=1;ifac[0]=1;
  for(int i=2;i<=n+2;i++){
    inv[i]=(-mod/i)*inv[mod%i]%mod;
    fac[i]=fac[i-1]*i%mod;
    ifac[i]=ifac[i-1]*inv[i]%mod;
    //cout<<inv[i]<<" "<<fac[i]<<" "<<ifac[i]<<endl;
  }

  cout<<n<<endl;
  ll num=first+n-second;
  //cout<<num<<endl;
  for(int i=2;i<=n+1;i++){
    ll ans=0,sum=0;
    if(num>=i-1) ans=fac[num]*ifac[i-1]%mod*ifac[num-i+1]%mod;
    sum=fac[n+1]*ifac[i]%mod*ifac[n+1-i]%mod;
    ans=(ans+mod)%mod;
    sum=(sum+mod)%mod;
    //cout<<i<<" "<<ans<<" "<<sum<<endl;
    //if(num==0) cout<<sum<<endl;
    cout<<(sum-ans+mod)%mod<<endl;
  }

  return 0;
}


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

int main() {
    int m, f, r;
    string rank;

    while (cin >> m >> f >> r) {
        if (m == -1 && f == -1 && r == -1) return 0;

        if (m == -1 || f == -1) {
            rank = 'F';
        } else if (m + f >= 80) {
            rank = 'A';
        } else if (m + f >= 65) {
            rank = 'B';
        } else if (m + f >= 50) {
            rank = 'C';
        } else if (m + f >= 30) {
            if (r >= 50) {
                rank = 'C';
            } else rank = 'D';
        } else {
            rank = 'F';
        }
        cout << rank << endl;
    }
}


Measured memory_bytes: 3160
#include<stdio.h>

int main()
{
	int n,sum=0,a=1;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		a*=2;
		if(a>n) break;
		
	}
	printf("%d",a/2);
	return 0;
}

Measured memory_bytes: 128
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    n,k=map(int,input().split())
    AB=[tuple(map(int,input().split())) for _ in range(n)]
    AB.sort()
    for a,b in AB:
        k-=b
        if(k<=0):
            print(a)
            return
resolve()

Measured memory_bytes: 56184
using System;

class AOJ {
  static void Main(string[] args)
  {
    int a, b;
    string s;
    string[] str;

    while ((s = Console.ReadLine()) != null) {
      str = s.Split(' ');

      a = int.Parse(str[0]);
      b = int.Parse(str[1]);

      Console.WriteLine(a + b);
    }
  }
}

Measured memory_bytes: 9124
N = int(input())
XYs = [[],[]]
for _ in range(N):
  x,y = map(int, input().split())
  XYs[0].append(x-y)
  XYs[1].append(x+y)
  
print(max(max(XYs[0])-min(XYs[0]), max(XYs[1])-min(XYs[1])))  


Measured memory_bytes: 100532
import itertools

N = int(input())
P = [int(x) for x in input().split()]
P = tuple(P)
Q = [int(x) for x in input().split()]
Q = tuple(Q)
N_ = list(range(1, N+1))

R = list(itertools.permutations(N_))

Pflg = Qflg = False
Pcnt = Qcnt = -1
for i, r in enumerate(R):
    if P==r:
        Pflg = True
        Pcnt = i
    if Q==r:
        Qflg = True
        Qcnt = i
    if Pflg and Qflg:
        break

print(abs(Pcnt - Qcnt))

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

using namespace std;

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

int memo[1200][1200];

int center[1200];
int center2[1200][1200];

typedef pair<int, int> Pii;
map<int, Pii> mp1;
map<Pii, Pii> mp2;

int N;
string line;

bool is_palindrome(int L, int R) {
  if(L >= R) return 1;

  if(memo[L][R] != -1) {
    return memo[L][R];
  }
  
  int SIZE = R-L;
  
  if(line[L] == line[R-1]) {
    memo[L][R] = is_palindrome(L+1, R-1);

    if(memo[L][R] == 1) {
      if(R-L > 2) {
	if(SIZE % 2 == 0) {
	  int l = (L+R)/2, r = (L+R)/2+1;
	  if(center2[l][r] < R-L) {
	    mp2[Pii(l, r)] = Pii(L, R);
	    center2[l][r] = R-L;
	  }
	}
	else {
	  int m = (L+R)/2;
	  if(center[m] < R-L) {
	    mp1[m] = Pii(L, R);
	    center[m] = R-L;
	  }
	}
      }
      return 1;
    }
    else if(memo[L][R] == 0) return 0;
    else assert(false);
  }
  memo[L][R] = 0; return 0;
}

void kirei() {
  string ret;
  int const N = line.size();
  rep(i, N) {
    if(isalpha(line[i])) { ret += toupper(line[i]); }
  }
  line = ret;
}

bool cmp(string const& a, string const& b) {
  return a.size() < b.size();
}

vector<string> contains_remove(vector<string>& vec) {
  
  vector<bool> retbool(vec.size());
  vector<string> ret;
  sort(vec.begin(), vec.end(), cmp);
  
  rep(i, vec.size()) {
    int ISize = vec[i].size();
    REP(j, i+1, vec.size()) {
      int JSize = vec[j].size();
      if(ISize % 2 != JSize % 2) continue;
      if(ISize % 2 == 0) {
	if(vec[i] == string(vec[j].begin()+(JSize/2-ISize/2), vec[j].begin()+(JSize/2+ISize/2))) {
	  retbool[i] = 1;
	}
      }
      else {
	if(vec[i] == string(vec[j].begin()+(JSize/2-ISize/2), vec[j].begin()+(JSize/2+ISize/2+1))) {
	  retbool[i] = 1;
	}
      }
    }
  }
  
  for(int i=0; i<(int)vec.size(); i++) {
    if(!retbool[i]) {
      ret.push_back(vec[i]);
    }
  }
  
  return ret;
}


int main() {
  
  while(getline(cin, line)) {
    rep(i, 1200) {
      rep(j, 1200) {
	memo[i][j] = -1;
	center2[i][j] = -1;
      }
      center[i] = -1;
    }
    mp1.clear(), mp2.clear();
    
    kirei();
    N = line.size();
    
    rep(i, N) REP(j, i+1, N+1) {
      memo[i][j] = is_palindrome(i, j);
    }
    
    vector<string> vec;
    {
      map<int, Pii>::iterator it = mp1.begin();
      for(; it!=mp1.end(); it++) {
	int L = it->second.first;
	int R = it->second.second;
	vec.push_back(string(line.begin()+L, line.begin()+R));
      }
    }
    {
      map<Pii, Pii>::iterator it = mp2.begin();
      for(; it!=mp2.end(); it++) {
	int L = it->second.first;
	int R = it->second.second;
	vec.push_back(string(line.begin()+L, line.begin()+R));
      }
    }
    
    sort(vec.begin(), vec.end());
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    vec = contains_remove(vec);

    for(int i=0; i<(int)vec.size(); i++) {
      if(i) cout << " ";
      cout << vec[i];
    }
    cout << endl;
  }
  
  return 0;
}

Measured memory_bytes: 12476
#include <iostream>
#include <cctype>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <string>
#include <functional>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <bitset>

#define PB push_back
#define MP make_pair
#define YES cout<<"YES"<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define No cout<<"No"<<endl
#define INF (1<<30)
#define LLINF (1LL<<60)
#define MOD 1000000007
#define REP(i, n) for(int i=0;i<n;i++)
using ll = long long;
using namespace std;

int main() {
    int n, k, x, y;
    cin >> n >> k >> x >> y;
    if (n <= k)cout << x * n << endl;
    else cout << x * k + (n - k)*y << endl;
    return 0;
}


Measured memory_bytes: 256
import collections

def main():
    n = int(input())
    s = collections.Counter(input())
    cnt = {x:s[x] for x in s}
    for i in range(n-1):
        if len(cnt) == 0:
            break
        s = collections.Counter(input())
        for x in s:
            if x in cnt:
                cnt[x] = min(cnt[x], s[x])
        for x in list(cnt):
            if x not in s:
                cnt.pop(x)
    ans = ""
    for x in sorted(cnt):
        ans += x*cnt[x]
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3316
n = int(input())

if (n < 105):
    ans = 0
elif (n == 105):
    ans = 1

else:
    ans = 0
    for i in range(105, n + 1, 2):
        data = [1]
        for j in range(2, i+1):
            if (i % j == 0):
                data.append(j)

        if (len(data) == 8):
            ans += 1

print(ans)


Measured memory_bytes: 3064