akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define MOD (1000000007)
#define INF (1e9)
#define INFL (1e12)
 
typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
template<class T>using arr=vector<vector<T>>;
template<class T>void pr(T x){cout << x << endl;}
template<class T>void prvec(vector<T>& a){rep(i, a.size()-1){cout << a[i] << " ";} cout << a[a.size()-1] << endl;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
 
int main()
{
    int n; cin >> n;
    arr<int> a(n, vector<int>(n));
    rep(i, n) rep(j, n) cin >> a[i][j];

    vector<int> dp(1<<n, 0);
    dp[0] = 1;
    FOR(S, 1, 1<<n){
        int i = bitset<32>(S).count();
        rep(j, n){
            // もし女jがすでにマッチしており、今また男i-1とマッチできるならば
            // それはSからjがマッチしていない場合の数を、dp[S]に足すことができる。
            if(a[i-1][j]==1 && (S>>j)&1){
                dp[S] = (dp[S]+dp[S^(1<<j)])%MOD;
            }
        }
    }

    pr(dp[(1<<n)-1]);
    return 0;}

Measured memory_bytes: 11424
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
using vs = vector<string>;
using vpii = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvs = vector<vector<string>>;
using pii = pair<int, int>;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define reps(i,n) for(int i = 1; i <= (int)(n); i++)
#define rrep(i,n) for(int i = (int)(n) - 1; i >= 0; i--)
#define rreps(i,n) for(int i = (int)(n); i > 0; i--)
#define FOR(i,a,b) for(int i = (int)(a); i <= (int)(b); i++)
#define RFOR(i,a,b) for(int i = (int)(a); i >= (int)(b); i--)
#define all(x) (x).begin(), (x).end()
#define MAX(x) *max_element(all(x))
#define MIN(x) *min_element(all(x))
template <class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template <class T> bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int INF = INT_MAX;
const int MOD = 1000000007;

int main() {
    int N;
    cin >> N;
    vi A(N);
    vvi x(N, vi(20)), y(N, vi(20));
    rep(i, N) {
        cin >> A[i];
        rep(j, A[i]) {
            cin >> x[i][j] >> y[i][j];
            x[i][j]--;
        }
    }
    int ans = 0;
    rep(bits, 1<<N) {
        bool flag = true;
        rep(i, N) {
            rep(j, A[i]) {
                if (bits & 1<<i) {
                    if ((bits>>x[i][j] & 1) ^ y[i][j]) flag = false;
                }
            }
        }
        if (flag) chmax(ans, __builtin_popcount(bits));
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <limits.h>
#include <queue>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)

ll N,A,B,C,D;
int main(){
    cin >> N >> A >> B >> C >> D; 
    B -= A;
    A = 0;
    //printf("B:%lld\n", B);

    bool ans = false;
    REP(i,N){
       ll high = -C*i + D*(N-1-i);
       ll low = C*(N-1-i) - D*i;
       //printf("[%lld %lld]\n", low, high);
       if(low <= B && B <= high){
            ans = true;
            break;
       }
    }

    if(ans)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
    return 0;
}


Measured memory_bytes: 256
def merge(left, mid, right):
    L = S[left:mid]
    R = S[mid:right]
    lp, rp, xp = 0, 0, 0
    a, b = L[0], R[0]
    c = right - left
    x = [0] * c
    flg = True
    while flg:
        while flg and a <= b:
            x[xp] = a
            lp += 1
            xp += 1
            try:
                a = L[lp]
            except:
                for e in R[rp:]:
                    x[xp] = e
                    xp += 1
                flg = False
        while flg and a >= b:
            x[xp] = b
            rp += 1
            xp += 1
            try:
                b = R[rp]
            except:
                for e in L[lp:]:
                    x[xp] = e
                    xp += 1
                flg = False
    S[left:right] = x
    return c

def mergesort(left, right):
    c = 0
    if left + 1 < right:
        mid = (left + right)/2
        c += mergesort(left, mid)
        c += mergesort(mid, right)
        c += merge(left, mid, right)
    return c

global S
n = int(raw_input())
S = map(int, raw_input().split())

c = mergesort(0, n)
print " ".join(map(str,S))
print c

Measured memory_bytes: 52880
#include<bits/stdc++.h>
#define pb           push_back
#define pii          pair<int,int>
#define vi           vector<int>
#define vpii         vector<pair<int,int>>
#define gph          map<int, vector<int>>
#define mp           make_pair
#define FOR(i, n) for (int i = 0; i <  (int)(n); i++)
#define FOR1(i, n) for (int i = 1; i <= (int)(n); i++)
#define FORD0(i, n) for (int i = (int)n; i >= 0; i--)
#define FORD1(i, n) for (int i = (int)n; i >= 1; i--)
#define FORS(i, n) for(; i < (int)(n); i++)
#define debug(X) { cout << #X << " = " << (X) << endl; }
#define printArr(A,n) { cout << #A << " = "; FOR(i,n) cout << A[i] << ' '; cout << endl; }
using namespace std;
#define int long long int

const int mod = (int)1e9 + 7;
int a, b, c, d;
int dp[1010][1010];
bool vis[1010][1010];
int fac[1010];
int infac[1010];
int p(int base, int ex){
    if(ex == 0)return 1;
    int sub = p(base, ex/2);
    sub *= sub;
    sub %= mod;
    if(ex & 1)sub *= base;
    sub %= mod;
    return sub;
}
long long inv(long long a, long long b = mod){
 return 1<a ? b - inv(b%a,a)*b/a : 1;
}
int sol(int cnt, int len){
    if(cnt == 0)return 1;
    if(len > b)return 0;
    if(len * c > cnt)return 0;
    if(vis[cnt][len])return dp[cnt][len];
    vis[cnt][len] = true;
    int& ans = dp[cnt][len];
    ans = 0;
    int temp = p(fac[len], c);
    temp = inv(temp);
    int mult = infac[len];
    for(int num = c; num <= d; num++){
        if(num * len > cnt)break;
        int sub= sol(cnt - num*len, len+1) * temp; 
        sub %= mod;
        sub *= infac[num];
        sub %= mod;
        ans += sub;
        ans %= mod;
        temp *= mult;
        temp %= mod;
    }
    ans += sol(cnt, len + 1);
    ans %= mod;
//    cout << cnt << " " << len << " " <<ans <<endl;
    return ans;
}
signed main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    fac[0] =1;
    infac[0] = 1;
    FOR1(i, 1001)fac[i] = fac[i-1]*i, fac[i] %= mod, infac[i] = inv(fac[i]), infac[i] %= mod; 
    
    int n;cin >> n >> a >> b >> c >> d;
    int temp = sol(n, a);
    temp *= fac[n];
    temp %= mod;
    cout << temp;
}




Measured memory_bytes: 8832
import java.util.Scanner;
class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    if(a < b && b < c)
      System.out.println("Yes");
    else
      System.out.println("No");
  }
}


Measured memory_bytes: 26204
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
#include<stack>
#include<climits>
#include<set>
#include<utility>
#include<typeinfo>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef set<int> S;
#define rep(i, n) for(int i=0; i<n; i++)
const ll MOD=1e9+7;

int main(){

  string s;
  cin >> s;
  if((s[0]=='A' && s[1]=='A' && s[2]=='A') || (s[0]=='B' && s[1]=='B' && s[2]=='B')){
    cout << "No" << endl;
  } else {
    cout << "Yes" << endl;
  }

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<cmath>
 
using namespace std;
int main () {
    int n;
    double x[99],y[99],p1=0,p1check=0,p2=0,p3=0,pinfty=0;
    cin >> n;
    for(int i=0;n>i;i++) cin >> x[i];
    for(int i=0;n>i;i++) cin >> y[i];
    for(int i=0;n>i;i++){
        p1+=abs(x[i]-y[i]);
        p2+=(x[i]-y[i])*(x[i]-y[i]);
        p3+=abs((x[i]-y[i])*(x[i]-y[i])*(x[i]-y[i]));
        if(abs(x[i]-y[i])>pinfty) pinfty=abs(x[i]-y[i]);
    }
    printf("%.6f\n",p1);
    printf("%.6f\n",sqrt(p2));
    printf("%.6f\n",cbrt(p3));
    printf("%.6f\n",pinfty);
}


Measured memory_bytes: 3392
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s1,s2,s3;
  cin>>s1>>s2>>s3;
  char A,B,C;
  A = toupper(s1.at(0));
  B = toupper(s2.at(0));
  C = toupper(s3.at(0));
  cout<<A<<B<<C<<endl;
return 0;
}


Measured memory_bytes: 256
N,M = list(map(int,input().split()))
Kl = []
for i in range(M):
    Kl.append(list(map(int,input().split())))
P = list(map(int,input().split()))
ans = 0

for i in range(2**N):
    onoff = [False for i in range(M)]
    b = format(i, 'b').zfill(N)
    for k in range(M):
        cnt = 0
        for l in range(Kl[k][0]):
            if b[Kl[k][l+1]-1] == "1":
                cnt += 1

        if int(cnt % 2) == int(P[k]):
            onoff[k] = True
    if False not in onoff:
        ans+=1

print(ans)

Measured memory_bytes: 3064
N , M = map ( int , input().strip().split(" ") ) ;

if N == 1  :
	arr = [ x for x in range ( 0 , 10 ) ] ;
elif N == 2 : 
	arr = [ x for x in range ( 10 , 100 ) ] ;
elif N == 3 :
	arr = [ x for x in range ( 100 , 1000 ) ] ;

L = []; 
for x in arr :
	L.append ( str ( x ) ) ;

q = [] ;
for r in range ( M ) :
	s , c = map ( int , input().strip().split(" ") ) ;
	q.append ( (s ,c  ) ) ;

L2 = [] ;
for r in L :
	b1 = True ;
	for q1 in q :
		if int(r[q1[0]-1]) != q1[1] :
			b1 = False ;
			break ;
	if b1 : 
		L2.append( r ) ; 
if len( L2 ) == 0 :
	print ( -1 ) ;
else :
	print ( min( L2 ) ) ;



Measured memory_bytes: 3064
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>
#include <cstring>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//ここから編集する
class Solve {
public:
    void input() {

    }

    // 文字列, レベル
    pair<char, int> parse(string s) {
        int lv = s.size();
        char c = s.back();
        return make_pair(c, lv);
    }

    bool isDigit(char c) {
        return c >= '0' && c <= '9';
    }

    bool solve() {
        int n;
        cin >> n;
        if (n == 0) return false;
        input();

        vector<pair<char, int>> input;
        for (int i = 0; i < n; ++i) {
            string s;
            cin >> s;
            input.push_back(parse(s));
        }
        reverse(all(input));

        stack<pair<int, int>> st; //(value(int), level)
        for (int i = 0; i < n; ++i) {
            if (isdigit(input[i].first)) {
                st.emplace(input[i].first - '0', input[i].second);
            } else {
                vector<int> values;
                while (!st.empty() && st.top().second == input[i].second + 1) {
                    values.push_back(st.top().first);
                    st.pop();
                }
                int val;
                if (input[i].first == '+') {
                    val = accumulate(all(values), 0);
                } else {
                    val = 1;
                    for (auto e : values) {
                        val *= e;
                    }
                }
                pair<int, int> p(val, input[i].second);
                st.push(p);
            }
        }
        cout << st.top().first << endl;
        return true;
    }
};


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    while (Solve().solve()) {}

    return 0;
}



Measured memory_bytes: 3164
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
#include <iomanip>
using namespace std;
#define MOD int(1e9 + 7)

long long gcd(long long a, long long b)
{
    while (1)
    {
        if (a < b)
            swap(a, b);
        if (!b)
            break;
        a %= b;
    }
    return a;
}

int main()
{
    long long K;
    cin >> K;

    long long total = 0;
    for (long long i = 1; i < K + 1; i++)
    {
        for (long long j = 1; j < K + 1; j++)
        {
            for (long long k = 1; k < K + 1; k++)
            {
                total += gcd(gcd(i, j), k);
            }
        }
    }

    cout << total << endl;
}

Measured memory_bytes: 3636
import sys
s = input()

l = len(s)
if s[0] != "A":
    print("WA")
    sys.exit()
ss =  s[2:l-1]
if ss.count("C") != 1:
    print("WA")
    sys.exit()

cidx = ss.find("C")+2
sss = s[1:cidx]+s[cidx+1:]
if sss.islower():
    print("AC")
    sys.exit()

print("WA")


Measured memory_bytes: 3060
/********************************************************
  **░██████╗██╗░░░░░░█████╗░██╗░░░██╗██╗░█████╗░░██████╗░**
  **██╔════╝██║░░░░░██╔══██╗██║░░░██║██║██╔══██╗██╔════╝░**
  **╚█████╗░██║░░░░░███████║╚██╗░██╔╝██║██║░░╚═╝██║░░██╗░**
  **░╚═══██╗██║░░░░░██╔══██║░╚████╔╝░██║██║░░██╗██║░░╚██╗**
  **██████╔╝███████╗██║░░██║░░╚██╔╝░░██║╚█████╔╝╚██████╔╝**
  **╚═════╝░╚══════╝╚═╝░░╚═╝░░░╚═╝░░░╚═╝░╚════╝░░╚═════╝░**
  *********************************************************/

#include <bits/stdc++.h>
using namespace std;


#define ll                          long long
#define ld                          long double

#define forn(i,n)                   for(int i=0;i<n;++i)
#define all(v)                      v.begin(), v.end()
#define rall(v)                     v.rbegin(),v.rend();
#define isSubstring(s1,s2)          s1.find(s2) != std::string::npos
	
#define pb                          push_back
#define pf                          push_front
#define mp                          make_pair
#define fr                          first
#define sc                          second

#define vpi                         vector<pair<int,int>>
#define vi                          vector<int>
#define sz(a)                       (int)a.size()

#define   endl                       "\n"
#define     nl                       cout<<"\n";
#define fastio                       ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

#define MN                           INT_MIN
#define MX                           INT_MAX

bool isPrime(ll n){if(n<2)return false;for(ll x = 2;x*x <=n;x++){if(n%x == 0)return false;}return true;}
bool isPerfectSquare(long double x){long double sr=sqrt(x);return((sr-floor(sr))==0);}
int gcd(int a, int b){if(a==0)return b;if(b==0) return a;if(a==b)return a;if(a>b)return gcd(a-b,b);return gcd(a,b-a);}

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

Measured memory_bytes: 3636
# coding: utf-8
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

S, T = sr().split()
A, B = lr()
U = sr()
if S == U:
    A -= 1
else:
    B -= 1

print(A, B)
# 18

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

using namespace std;

#define USE_IOSTREAM \
{\
	ios::sync_with_stdio(false);\
	cin.tie(0);\
	cout.tie(0);\
}

#define pii pair<int, int>
#define mp make_pair

typedef long long ll;

const int N = 1e5 + 100;

int a[N];
ll sum[N];
ll cnt[N];
ll ans[N];

vector<pii> vec;

int main()
{
	USE_IOSTREAM;
	
	int n, i, j;
	cin >> n;
	
	vec.push_back({0, 0});
	for (i = 1; i <= n; i++)
	{
		cin >> a[i];
		if (a[i] > vec.back().first)
		{
			vec.push_back({a[i], i});
		}
	}
	
	for (i = 1; i <= n; i++)
	{
		int idx = lower_bound(vec.begin(), vec.end(), mp(a[i], 0)) - vec.begin();
		sum[idx] += a[i] - vec[idx - 1].first;
		cnt[idx - 1]++;
	}
	
	for (i = vec.size() - 1; i > 0; i--)
	{
		sum[i] += cnt[i] * (vec[i].first - vec[i - 1].first);
		cnt[i - 1] += cnt[i];
	}
	
	for (i = 1; i < vec.size(); i++)
	{
		ans[vec[i].second] = sum[i];
	}
	
	for (i = 1; i <= n; i++)
	{
		cout << ans[i] << endl;
	}
	
	
	return 0;
}

Measured memory_bytes: 4724
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define rep(i, n) for(ll i = 0;i < n;i++)
template<class T, class U> void cmax(T& a, U b) { if (a<b) a = b; }
template<class T, class U> void cmin(T& a, U b) { if (a>b) a = b; }

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

  int n, a, b;
  cin >> n >> a >> b;
  if (n > a+b) {
    cout << min(a, b) << " " << 0 << endl;
  } else {
    cout << min(a, b) << " " << a+b-n << endl;
  }
}


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
//const ull mod = 1e9 + 7;
const ll mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

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

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

// conversion number to bit
string num2bit(ll num, ll len){
  string bit = "";
  REP(i, len){
    bit += char('0'+(num>>i & 1));
  }
  return bit;
}

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

    ll N, K;
    cin >> N >> K;
    vector<ll> x(N);
    REP(i, N) cin >> x[i];

    ll mi = (1ll<<60);
    REP(i, N-K+1){
    	if(x[i]<0 && x[i+K-1]<0) chmin(mi, -x[i]);
    	if(x[i]<0 && x[i+K-1]>=0) chmin(mi, min(2*x[i+K-1]-x[i], x[i+K-1]-2*x[i]));
    	if(x[i]>=0 && x[i+K-1]>=0) chmin(mi, x[i+K-1]);
    }
    cout << mi << endl;
    return 0;
}

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

int main() {
	string S;
	cin >> S;
	char c = S[0];
	int res = 0;
	for (int i = 1; i < S.length(); i++) {
		if (c != S[i]) {
			res++;
			c = S[i];
		}
	}
	cout << res << endl;
}

Measured memory_bytes: 512
from numba import njit

@njit
def calc(A):
    B = [0] * len(A)
    for i in range(len(A)):
        B[max(0,i - A[i])] += 1
        if i + A[i] + 1 < len(A):
            B[i + A[i] + 1] -= 1
    for i in range(1,len(B)):
        B[i] = B[i - 1] + B[i]
    return B

@njit
def solve(N,K,A):
  
  for i in range(K):
    A = calc(A)
    if len(set(A)) == 1 and A[0] == N:
      break
  return A
  
import sys
readline=sys.stdin.readline
  
N,K = map(int,readline().split())
A = list(map(int,readline().split()))

ans = solve(N,K,A)
print(*ans)

Measured memory_bytes: 141016
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int i,j,n,m,count=0;
    string str1,str2;
    getline(cin,str1);
    getline(cin,str2);
    n=str1.length();
    for(i=0;i<n;i++)
    {
        if(str1[i]==str2[i])
        {
            count++;
        }
    }
    cout<<count<<endl;
}


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

typedef long long ll;
typedef unsigned long long ull;

int main()
{   
    ll R, G, B, N;
    cin >> R >> G >> B >> N;

    ll res=0;
    for(int i=0;i*R<=N;i++){
        for(int j=0;i*R+j*G<=N;j++){
            if( (N-R*i-G*j)%B ==0 ) res++;
        }
    }
    cout<<res<<endl;

    return 0;
}

Measured memory_bytes: 256
# coding: UTF-8
import sys
#sys.setrecursionlimit(n)
import heapq
import re
import bisect
import random
import math
import itertools
from collections import defaultdict, deque
from copy import deepcopy
from decimal import *

readl= lambda: list(map(int, sys.stdin.readline().split()))
readt= lambda: tuple(map(int, sys.stdin.readline().split()))
read = lambda: sys.stdin.readline().rstrip()
readi = lambda: int(read())
readmi = lambda: map(int, sys.stdin.readline().split())
readms = lambda: map(str, sys.stdin.readline().split())

s = read()
s = list(s)
length = len(s)
t = [0] * length
index = 0
r = 0
l = 0
flg = False
rindex = 0
lindex = 0
for i in range(length):
    if s[i] == 'R':
        if flg:
            k = r + l
            div = k // 2
            t[rindex] = div
            t[lindex] = div
            if k % 2 == 1:
                if l % 2 == 0:
                    t[rindex] += 1
                else:
                    t[lindex] += 1
            r = 0
            l = 0
            rindex = i
            lindex = i
            flg = False
        r += 1
        rindex = i
        lindex = i
    else:
        if flg == False:
            flg = True
            l = 0
            lindex = i
        l += 1
if r >= 1 or l >= 1:
    k = r + l
    div = k // 2
    t[rindex] = div
    t[lindex] = div
    if k % 2 == 1:
        if l % 2 == 0:
            t[rindex] += 1
        else:
            t[lindex] += 1
for i in t:
    print(i, end=" ")

Measured memory_bytes: 7876
def main():
    N = int(input())
    A = list(map(int, input().split()))

    C = [0] * N
    for ai in A:
        C[ai] += 1
    # print(C)
    flag = True
    if N % 2 == 1:
        for i, n in enumerate(C):
            if i == 0:
                if n != 1:
                    flag = False
            elif i % 2 == 0:
                if n != 2:
                    flag = False
            else:  # 奇数の時
                if n != 0:
                    flag = False
        if not flag:
            ans = 0
        else:
            ans = 2 ** ((N - 1)//2)
    else:
        for i, n in enumerate(C):
            if i % 2 == 1:
                if n != 2:
                    flag = False
            else:
                if n != 0:
                    flag = False
        if not flag:
            ans = 0
        else:
            ans = 2 ** (N // 2)

    ans = ans % (10 ** 9 + 7) 
    print(ans)




if __name__ == "__main__":
    main()

Measured memory_bytes: 14008
// created by mtnshh
 
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;

#define ll long long
#define ld long double
 
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define repb(i,a,b) for(ll i=a;i>=b;i--)
 
#define err() cout<<"=================================="<<endl;
#define errA(A) for(auto i:A)   cout<<i<<" ";cout<<endl;
#define err1(a) cout<<#a<<" "<<a<<endl
#define err2(a,b) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<endl
#define err3(a,b,c) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<endl
#define err4(a,b,c,d) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<" "<<#d<<" "<<d<<endl

#define pb push_back
#define all(A)  A.begin(),A.end()
#define allr(A)    A.rbegin(),A.rend()
#define ft first
#define sd second
 
#define pll pair<ll,ll>
#define V vector<ll>
#define S set<ll>
#define VV vector<V>
#define Vpll vector<pll>
 
#define endl "\n"
 
const ll logN = 20;
const ll M = 1000000007;
const ll INF = 1e12;
#define PI 3.14159265
 
const ll N = 100005;

void solve(){
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    bool f=0;
    while(a!=0 and c!=0){
        if(!f){
            c -= b;
            if(c<0) c=0;
        }
        else{
            a -= d;
            if(a<0) a=0;
        }
        f^=1;
    }
    if(a==0)    cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
    return;
}

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

Measured memory_bytes: 3632
#                         author:  kagemeka 
#                         created: 2019-11-08 14:51:29(JST)
## internal modules
import sys
# import collections
# import math
# import string
# import bisect
# import re
# import itertools
import statistics
# import functools
# import operator
## external modules
# import scipy.special   # if use comb function on AtCoder, 
# import scipy.misc      # select scipy.misc.comb (old version) 

def main():
    n, *a = (int(x) for x in sys.stdin.read().split())
    
    for i in range(n):
        a[i] -= (i + 1)

    if n % 2 != 0:
        b = statistics.median(a)
    else:
        if a.count(statistics.median_high(a)) >= a.count(statistics.median_low(a)):
            b = statistics.median_high(a)
        else:
            b = statistics.median_low(a)
    
    ans = sum([abs(a[i] - b) for i in range(n)])
    print(ans)


if __name__ == "__main__":
    # execute only if run as a script
    main()




Measured memory_bytes: 27268
import java.io.*;

class Main{
	public static void main(String[] args){
		try{
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			String str;
			int i,sum;
			while(true){
				str = br.readLine();
				if(str.equals("0")) break;
				for( i=0, sum=0; i<str.length(); i++ ){
					sum += Integer.parseInt(""+str.charAt(i));
				}
				System.out.println(sum);
			}
		} catch(IOException e){
			System.out.println("Exception :" + e);
		}
	}
}

Measured memory_bytes: 17360
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        String[] O = sc.next().split("");
        String[] E = sc.next().split("");
        
        String[] password = new String[O.length + E.length];
        
        
        int O_count = 0;
        int E_count = 0;
        for(int i=0; i<password.length; i++){
            if(i % 2 == 0){
                password[i] = O[O_count];
                O_count++;
            }else{
                password[i] = E[E_count];
                E_count++;
            }
            System.out.print(password[i]);
        }
    }
}

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

#define FOR(i,a,b)  for(ll i=a;(i)<(b);++(i))
#define RFOR(i,a,b) for(ll i=a;(i)>=(b);--(i))
#define REP(i,n)    FOR(i,0,n)
#define RREP(i,n)   RFOR(i,n,0)
#define ALL(v)      v.begin(), v.end()
#define UNIQ(v)     sort(ALL(v)); v.erase(unique(ALL(v)), v.end())
#define BIT(n)      (1LL<<(n))
#define DEBUG(a)    cerr << #a << " = " << a << endl

const int inf = 1001001001;
const int mod = (int)1e9+7;
//const ll inf = 1e15;
//const ll mod = 1e9+7;

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

int main() {
    string s;
    cin >> s;
    string rs = s;
    int l = s.size();
    reverse(ALL(rs));

    string kai = s.substr(0, (l-1)/2);
    while (kai.size() > 1) {
        if (kai.back() != kai.front()) {
            cout << "No" << endl;
            return 0;
        }
        kai.pop_back();
        kai.erase(0, 1);
    }

    if (s.substr(0, (l-1)/2) == rs.substr(0, (l-1)/2)) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, i321) => {
        read_value!($next, i32) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

//
// # Examples
//
// # integers
// input! { n: i32, m: i32, ... }
//
// # array
// input! { n: i32, v: [i32; n], }
//
// # matrix
// input! { n: i32, m: i32, mat: [[]] }
//
// # string
// input! { s: chars }
//
// 3 4
// ####
// #..#
// .#.#
//
// input!{
//     h: i32,
//     w: i32,
//     board: [chars; h],
// }

// https://practice.contest.atcoder.jp/tasks/practice_1
//fn main() {
//    input!{
//        a: i32, b: i32, c: i32,
//        foo: chars,
//    }
//    let s: String = foo.into_iter().collect();
//    println!("{} {}", a+b+c, s);
//}
fn main() {

    input! { si: chars, ti: chars }
    let  s :String = si.into_iter().collect();
    let  t :String = ti.into_iter().collect();
    let mut sm : Vec<_> = s.chars().collect();
    let mut tm : Vec<_> = t.chars().collect();
    sm.sort();
    tm.sort();
    tm.reverse();
    let s :String = sm.into_iter().collect();
    let t :String = tm.into_iter().collect();
    if s < t {
        println!("Yes");
    }else{
        println!("No");
    }

}



Measured memory_bytes: 4352
#include <iostream>
#include <vector> 
#include <set>
using namespace std ;
#define endl "\n"
#define int long long int 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);


int32_t main()
{
  IOS;

/* #ifndef ONLINE_JUDGE 
    freopen("input.txt","r",stdin) ;
    freopen("output.txt","w",stdout) ;
  #endif*/
  
  int x , a ;
  cin >> x >> a ;
  if(x < a ){
    cout<<0<<endl;
  }else cout<<10<<endl;
  return  0 ;
} 


Measured memory_bytes: 256
import java.util.*;
     
class Main{
    public static void main(String[] args) {
        
        try(Scanner sc = new Scanner(System.in)){
            int n = Integer.parseInt(sc.next());
            int m = Integer.parseInt(sc.next());

            for(int i = 0; i < m; i++){
                n -= Integer.parseInt(sc.next());
            }

            if(n < 0) System.out.println(-1);
            else System.out.println(n);
            
        }catch(Exception e){
            e.printStackTrace();
        }        
    }
}

Measured memory_bytes: 41544
/* おまじない　*/
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
typedef long long ll;
typedef long double ld;
using namespace std;
const ll MOD=pow(10,9)+7;
const ll INF=(1LL<<62);
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const int ddx[8]={1,0,-1,-1,-1,0,1,1};
const int ddy[8]={1,1,1,0,-1,-1,-1,0};

int main(){
    ll n;cin>>n;
    vector<ll>A(n);
    for(int i=0;i<n;i++)cin>>A[i];
    sort(A.begin(),A.end());

    ll maxnum=*(A.end()-1);
    ll num=0;
    if(maxnum%2==0)num=maxnum/2;
    if(maxnum%2==1)num=(maxnum+1)/2;

    //出来るだけ真ん中に近いやつを選ぶ
    ll ans=pow(10,10);
    for(int i=0;i<n-1;i++){
        if(abs(num-ans)>abs(num-A[i]))ans=A[i];
    }
    cout<<maxnum<<" "<<ans<<endl;
}

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

using ll = long long;

int X, Y, Z, K;
vector<ll> A, B, C;

void solve1() {
    vector<ll> E(X*Y);
    int e = 0;
    for (int i = 0; i < X; i++) {
        for (int j = 0; j < Y; j++) {
            E[e++] = A[i] + B[j];
        }
    }
    sort(E.begin(), E.end(), greater<ll>());
    int lim = min((int)E.size(), K);
    vector<ll> EC(lim*Z);
    int ec = 0;
    for (int i = 0; i < lim; i++) {
        for (int j = 0; j < Z; j++) {
            EC[ec++] = E[i] + C[j];
        }
    }
    sort(EC.begin(), EC.end(), greater<ll>());
    for (int i = 0; i < K; i++) {
        cout << EC[i] << endl;
    }
}

void solve1a() {
    if (X > K) {
        sort(A.begin(), A.end(), greater<ll>());
    }
    if (Y > K) {
        sort(B.begin(), B.end(), greater<ll>());
    }
    int lim_a = min(K, X);
    int lim_b = min(K, Y);
    vector<ll> E(lim_a * lim_b);
    int e = 0;
    for (int i = 0; i < lim_a; i++) {
        for (int j = 0; j < lim_b; j++) {
            E[e++] = A[i] + B[j];
        }
    }
    sort(E.begin(), E.end(), greater<ll>());
    int lim_e = min((int)E.size(), K);
    vector<ll> EC(lim_e*Z);
    int ec = 0;
    for (int i = 0; i < lim_e; i++) {
        for (int j = 0; j < Z; j++) {
            EC[ec++] = E[i] + C[j];
        }
    }
    sort(EC.begin(), EC.end(), greater<ll>());
    for (int i = 0; i < K; i++) {
        cout << EC[i] << endl;
    }

}

void solve2() {
    sort(A.begin(), A.end(), greater<ll>());
    sort(B.begin(), B.end(), greater<ll>());
    sort(C.begin(), C.end(), greater<ll>());

    vector<ll> E;
    for (int i = 0; i < X; i++) {
        int j_lim = min(Y, K / (i+1));
        for (int j = 0; j < j_lim; j++) {
            int k_lim = min(Z, K / ((i+1) * (j+1)));
            for (int k = 0; k < k_lim; k++) {
                E.push_back(A[i] + B[j] + C[k]);
            }
        }
    }

    sort(E.begin(), E.end(), greater<ll>());
    for (int i = 0; i < K; i++) {
        cout << E[i] << endl;
    }
}

void solve2a() {
    sort(A.begin(), A.end(), greater<ll>());
    sort(B.begin(), B.end(), greater<ll>());
    sort(C.begin(), C.end(), greater<ll>());

    vector<ll> E;
    for (int i = 0; i < X; i++) {
        for (int j = 0; j < Y; j++) {
            for (int k = 0; k < Z; k++) {
                if ((i+1) * (j+1) * (k+1) <= K) {
                    E.push_back(A[i] + B[j] + C[k]);
                } else {
                    break;
                }
            }
        }
    }

    sort(E.begin(), E.end(), greater<ll>());
    for (int i = 0; i < K; i++) {
        cout << E[i] << endl;
    }
}

int main() {
    cin.tie(nullptr); ios::sync_with_stdio(false);
    
    cin >> X >> Y >> Z >> K;
    A.resize(X); for (auto& a : A) cin >> a;
    B.resize(Y); for (auto& b : B) cin >> b;
    C.resize(Z); for (auto& c : C) cin >> c;

    solve2a();
}


Measured memory_bytes: 1532
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int a,b;
    cin >> a >> b;
    if(a <= 8){
        if(b <= 8){
            cout << "Yay!" << endl;
        }else{
            cout << ":(" << endl;
        }
    }else{
        cout << ":(" << endl;
    }
    return 0;
}


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

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 = 1e18;

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

	int N;
	cin >> N;
	map<int, int> m;
	rep(i, 0, N) {
		int a;
		cin >> a;
		if(m[a] == 0) m[a]++;
		else m[a]--;
	}

	int rsl = 0;
	for(map<int, int>:: iterator it = m.begin(); it != m.end(); it++) {
		if(it->second > 0) rsl++;
	}

	cout << rsl << endl;


}


Measured memory_bytes: 4992
N=io.read"*n"
A=io.read"*n"
B=io.read"*n"
C=io.read"*n"
io.read()
s={}
for i=1,N do
	table.insert(s,io.read())
end
 
r={}
for i=1,N do
	if(s[i]=="AB")then
		if(A==0 and B==0)then
			print("No") return
		elseif(A==1 and B==1)then
			if(s[i+1]=="AC")then
				A=A+1 B=B-1 table.insert(r,"A")
			else
				A=A-1 B=B+1 table.insert(r,"B")
			end
		else
			if(A<B)then
				A=A+1 B=B-1 table.insert(r,"A")
			else
				A=A-1 B=B+1 table.insert(r,"B")
			end
		end
	elseif(s[i]=="AC")then
		if(A==0 and C==0)then
			print("No") return
		elseif(A==1 and C==1)then
			if(s[i+1]=="AB")then
				A=A+1 C=C-1 table.insert(r,"A")
			else
				A=A-1 C=C+1 table.insert(r,"C")
			end
		else
			if(A<C)then
				A=A+1 C=C-1 table.insert(r,"A")
			else
				A=A-1 C=C+1 table.insert(r,"C")
			end
		end
	else
		if(B==0 and C==0)then
			print("No") return
		elseif(B==1 and C==1)then
			if(s[i+1]=="AB")then
				B=B+1 C=C-1 table.insert(r,"B")
			else
				B=B-1 C=C+1 table.insert(r,"C")
			end
		else
			if(B<C)then
				B=B+1 C=C-1 table.insert(r,"B")
			else
				B=B-1 C=C+1 table.insert(r,"C")
			end
		end
	end
end
print("Yes")
for _,v in ipairs(r)do
print(v)
end

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

int main(){
  int a[5];
  
  int min = 10;
  int last_index;
  int ans = 0;
  
  for(int i = 0 ; i < 5; ++i){
  	cin >> a[i];
    if(a[i] % 10 < min && a[i]%10 != 0){
    	min = a[i]%10;
      last_index = i;
    }
  }
  
  for(int i = 0; i < 5; ++i){
    if(i != last_index){
      if(a[i]%10 != 0){
     	ans += a[i] + (10 - a[i]%10); 
      }
      else if(a[i]%10 == 0){
     	ans += a[i]; 
      }
    }
    
    else{
     ans += a[i]; 
    }
    
  }
  
  cout << ans << endl;
  
  
  return 0; 
}

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

#define REP(i, n) for(int i=0; i<n;i++)
#define REPR(i, n) for(int i=n-1 ; i>=0; i--)
#define FOR(i, m, n) for(int i=m; i<n; i++)

#define INF 2e9
#define ll long long

int main(){
    int a, b;
    cin>>a>>b;
    int i, j;

    int ans = 0;
    for(i=a; i<=b; i++){
        if(i%10==i/10000 && i/10%10 == i/1000%10){
            ans++;
        }
    }

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < n; i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
typedef long long ll;

/*
1, 2, 3
2, 5

5, 2, 3 = 10
2, 5, 3 = 10
*/
int main() {
    int N, M; cin >> N >> M;
    vector<int> A(N);
    REP(i, 0, N) cin >> A[i];

    vector<pair<int, int>> CB(M);
    REP(i, 0, M) cin >> CB[i].second >> CB[i].first;

    sort(ALL(A), greater<int>());
    sort(ALL(CB), greater<pair<int, int>>());

    ll ans = 0; int ai = 0, cbi = 0;
    REP(i, 0, N) {
        if (cbi == M || A[ai] > CB[cbi].first) {
            ans += A[ai++];
        } else {
            ans += CB[cbi].first;
            CB[cbi].second--;
            if (CB[cbi].second == 0) cbi++;
        }
    }

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

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

int main()
{
  int a, b;
  cin >> a >> b;
  int ans(0);
  for (int i = a; i <= b; i++) {
    if (i / 10000 == i % 10 && i % 10000 / 1000 == i % 100 / 10)
      ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<string.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
int main(){
	int n,k;
	cin>>n>>k;
	vector<int>pl,ml;
	int tmp;
	rep(i,n){
		cin>>tmp;
		if(tmp>=0){
			pl.push_back(tmp);
		}else{
			ml.push_back(-tmp);
		}
	}
	sort(pl.begin(),pl.end());
	sort(ml.begin(),ml.end());

	long long int j,min=3e8+1;
	if(k>pl.size()){
		j=k-pl.size();
	}else{
		j=0;
	}
	while(j<=k && j<=ml.size()&&pl.size()>0){
		if(j==0){
			tmp=pl[k-j-1];
		}else{
			tmp=pl[k-j-1]+2*ml[j-1];
		}
		if(min>tmp)min=tmp;
		j+=1;
	}
	if(k>ml.size()){
		j=k-ml.size();
	}else{
		j=0;
	}
	while(j<=k && j<=pl.size()&&ml.size()>0){
		if(j==0){
			tmp=ml[k-j-1];
		}else{
			tmp=ml[k-j-1]+2*pl[j-1];
		}
		if(min>tmp)min=tmp;
		j+=1;
	}
	cout<<min<<endl;


	return 0;
}

Measured memory_bytes: 1020
package main

import (
	"fmt"
)

func main() {
	a := 0
	b := 0
	n := 0

	fmt.Scanf("%d %d", &a, &b)

	if a <= 5 {
		n = 0
	} else if a >= 13 {
		n = b
	} else {
		n = b / 2
	}

	fmt.Printf("%d", n)

}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <cstdlib>  
#include <algorithm>
#include <string>

using namespace std;
 
int main() {
    int a[3];
    for(int i = 0;i<3;i++) cin>>a[i];
    sort(a,a+3);
    cout<<a[2]*10+a[0]+a[1];
    return 0;
}

Measured memory_bytes: 3552
#include<cstdio>

#define t(a) ((a == 'S') ? (0) : (1))

using namespace std;

int N;
char S[100001];
char ans[100001];
char sw[3] = "SW";
bool f1 = true;

char dp(short int b, short int t, char r);

int main(){

  scanf("%d", &N);
  scanf("%s", S);

  for(int l = 0; l < 4 && f1; l++){
    ans[0] = sw[l/2];//ssww
    ans[1] = sw[l%2];//swsw
    for(int m = 1; m < N && f1; m++){
      if(m < N-1 ){
        ans[m+1] = dp(t(ans[m-1]), t(ans[m]), S[m]);//1 <= m <= N-2, ans[N-1]まで求める
      }else if(ans[0] == dp(t(ans[N-2]), t(ans[N-1]), S[N-1])){//m = N-1, ans[0]に入るべき値を確認
        if(ans[1] == dp(t(ans[N-1]), t(ans[0]), S[0])){
          f1 = false;
        }
      }
    }
  }

  if(f1){
    printf("-1");
  }else{
    /*
    for(int i = 0; i < N; i++){
      printf("%c", ans[i]);
    }
    */
    
    ans[N] = '\0';
    printf("%s", ans);
    
  }

  return 0;

}

char dp(short int b, short int t, char r){

  if((b+t)%2 == 0){
    if(r == 'o'){
      return 'S';
    }else{//r == 'x'
      return 'W';
    }
  }else{//(a+b)%2 == 1
    if(r == 'o'){
      return 'W';
    }else{//r == 'x'
      return 'S';
    }
  }

  /*
  if( b == 's' && t == 's' && r == 'o') return 's';
  if( b == 's' && t == 'w' && r == 'o') return 'w';
  if( b == 'w' && t == 's' && r == 'o') return 'w';
  if( b == 'w' && t == 'w' && r == 'o') return 's';
  if( b == 'w' && t == 'w' && r == 'x') return 'w';
  if( b == 'w' && t == 's' && r == 'x') return 's';
  if( b == 's' && t == 'w' && r == 'x') return 's';
  if( b == 's' && t == 's' && r == 'x') return 'w';
  */
  return '\0';

}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const ll mod = 1000000007;
const int INF = 1001001001;

int main(){
    ll n; cin >> n;
    rep(i,n){
        ll x; cin >> x;
        if(x%2 == 0){
            if(x%3!=0 && x%5!=0){
                cout << "DENIED" << endl;
                return 0;
            }
        }
    }
    cout << "APPROVED" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const long double PI  = acos(-1.0L);
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef pair<double,double> PDD;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
#define chmax(a,b) a = (((a)<(b))?(b):(a))
#define chmin(a,b) a = (((a)>(b))?(b):(a))

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

ll dp[1000010][2];

signed main(){
	string s; cin>>s;
	s = '0'+s;
	int n=s.size();
	rep(i,n)rep(j,2) dp[i][j]=LINF; dp[0][0]=0;
	rep(i,n){
		int ni=s[n-1-i]-'0';
		dp[i+1][0]=min(dp[i][0]+ni, dp[i][1]+ni+1);
		dp[i+1][1]=min(dp[i][0]+10-ni, dp[i][1]+10-(ni+1));
	}
	cout<<dp[n][0]<<endl;


	return 0;
}


Measured memory_bytes: 16968
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define pob pop_back
#define ff first
#define ss second
#define endl "\n"
#define all(a) a.begin(),a.end()
#define debug(x) cout << x << endl;
#define int long long
#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
/* 	1) order_of_key (k) : Number of items strictly smaller than k .
	2) find_by_order(k) : K-th element in a set (counting from zero).
*/
using namespace __gnu_pbds;
using namespace std;
using LD = long double;

const int N = 1e4+2;
const int mod = 1e9+7;
const int INF = 1e18;
int row[8] = {1,1,0,-1,-1,-1,0,1};
int col[8] = {0,-1,-1,-1,0,1,1,1};

void solve() {
	int n,d;
	cin >> n >> d;
	int cnt = 0;
	for(int i=0;i<n;i++) {
		int p,q;
		cin >> p >> q;
		if(sqrt((p*p) + (q*q)) <= d)
			cnt++;
	}
	cout << cnt;
}
 
signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int t = 1,i = 1;
    //cin >> t;
    while(t--) {
        //cout << "Case #" << i << ": ";
        solve();
        //i++;
    }
    return 0;
}


Measured memory_bytes: 3664
#include <bits/stdc++.h>
#define SZ(x) ((int)(x).size())
typedef long long ll;
typedef long double ld;
using namespace std;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cout.setf(ios::fixed); cout.precision(20);
    int n, k; cin >> n >> k;
    int res = 0;
    vector<int> a(n);
    for (int &x : a) {
        cin >> x;
        if (x >= k) {
            res++;
        }
    }
    cout << res << "\n";
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <ctime>
#include <list>
#include <numeric>
#include <utility>
#include <ctime>
#define INF 1000000000
#define LINF 9000000000000000000
#define mod 1000000007
 
#define rep(i,n) for(int i=0;i<int(n);i++)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair
#define MOD(x) (x%(mod))
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;
 
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool debug=false;
 
/*---------------------------------------------------*/

vi List;

void make_list(){
  for(ll i=0;;i++){
    if(i*i<=1000000000)List.pb(i*i);
    else break;
  }
}

int main(){
  make_list();
  int n;
  cin>>n;
  int ans=0;
  rep(i,List.size()){
    if(List[i]<=n)ans=List[i];
    else break;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 512
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int day = sc.nextInt();
    String ans = new String();

    switch (day) {
    case 25:
      ans = "Christmas";
      break;
    case 24:
      ans = "Christmas Eve";
      break;
    case 23:
      ans = "Christmas Eve Eve";
      break;
    case 22:
      ans = "Christmas Eve Eve Eve";
      break;
    }
    System.out.println(ans);
  }

}

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

int main() {

    // 1. input.
    int n;
    cin >> n;
    int a[n];
    for(int i = 0; i < n; i++) cin >> a[i];
    
    // 3. output answer.
    for(int i = n - 1; i > 0; i--) cout << a[i] << " ";
    cout << a[0] << endl;
    return 0;
    
}


Measured memory_bytes: 3108
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
const int INF = 1e9;
int main() {
	int N, K;
	cin >> N >> K;
	int a;
	vector<int>v(N);
	vector<int>flag(N+1,0);
	for (int i = 0; i < N; ++i) {
		cin >> a;
		v.at(i) = a;
		flag.at(a)++;
	}
	sort(v.begin(), v.end());
	sort(flag.begin(), flag.end());
	int sum = 1;
	int count = 0;
	for (int i = 0; i < N-1; ++i) {
		if (v[i] != v[i + 1])
			sum++;
	}
	if (sum <= K) {
		cout << 0 << endl;
	}
	else {
		for (int i = 0; i < N ; ++i) {
			if (flag[i] > 0) {
				sum--;
				count += flag[i];
			}
			if (sum <= K) {
				break;
			}
		}
		cout << count << endl;
	}
	return 0;
}

Measured memory_bytes: 1792