akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("Ofast","inline")
#include <bits/stdc++.h>
#define clr(x) memset(x,0,sizeof x)
#define For(i,a,b) for (int i=(a);i<=(b);i++)
#define Fod(i,b,a) for (int i=(b);i>=(a);i--)
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define fi first
#define se second
#define next Next
#define outval(x) cerr<<#x" = "<<x<<endl
#define outtag(x) cerr<<"-----------------"#x"-----------------\n"
#define outarr(a,L,R) cerr<<#a"["<<L<<".."<<R<<"] = ";\
                    For(_x,L,R) cerr<<a[_x]<<" ";cerr<<endl;
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair <int,int> pii;
LL read(){
    LL x=0,f=0;
    char ch=getchar();
    while (!isdigit(ch))
        f=ch=='-',ch=getchar();
    while (isdigit(ch))
        x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
    return f?-x:x;
}
const int N=100005;
int n;
int a[N];
map <int,int> mp;
int main(){
	n=read();
	For(i,1,n)
		mp[a[i]=read()]++;
	sort(a+1,a+n+1);
	if (a[n]==0)
		return puts("Yes"),0;
	if (n%3)
		return puts("No"),0;
	if (a[1]==0&&mp[a[1]]==n/3&&mp[a[n]]==n/3*2)
		return puts("Yes"),0;
	if (mp[a[1]]!=n/3||mp[a[n]]!=n/3)
		return puts("No"),0;
	if (a[1]^a[n]^a[n/3+1])
		return puts("No"),0;
	puts("Yes");
	return 0;
}

Measured memory_bytes: 4224
#include <bits/stdc++.h>
using namespace std;
int t[200005];
int main()
{
    int n;
    cin>>n;
    for(int i=1;i<=n;i++)
        cin>>t[i];
    sort(t+1,t+n+1);
    int i;
    for(i=1;i<n;i++)
        if(t[i]==t[i+1])
        break;
    if(i==n)
        cout<<"YES"<<endl;
    else
        cout<<"NO"<<endl;
    return 0;
}


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

#define INF (INT64_MAX)
#define MOD (1000000000+7)
#define MAX 100000

int N, Q;
long long A[MAX];
long long x[MAX];

long long S[MAX + 1];
long long T[MAX + 1];

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

	for( int i = 1; i < N; i++ ) {
		S[i + 1] = S[i] + A[i];
	}
	T[1] = A[0];
	for( int i = 1; i < N; i++ ) {
		T[i + 1] = T[i - 1] + A[i];
	}

	for( int i = 0; i < Q; i++ ) {
		long long X = x[i];

		int l = 0;
		int h = N;
		while( h - l > 1 ) {
			int m = ( l + h ) / 2;
			if( A[m] < X ) {
				l = m;
				continue;
			}
			int acnt = upper_bound( A, A + N, A[m] ) - lower_bound( A, A + N, X - (A[m] - X) );
			if( acnt <  N - m ) {
				l = m;
			}
			else {
				h = m;
			}
		}
		l++;
		long long ans = S[N] - S[l];
		if( 2 * l >= N ) {
			ans += T[2 * l - N];
		}

		cout << ans << endl;
	}


	return 0;
}


Measured memory_bytes: 4864
#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>
#include<stdio.h>
#include<string.h>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const ll dx[4] = { -1, 0, 0, 1 };
const ll dy[4] = { 0, -1, 1, 0 };
const ll INF = 1e9 + 7;
const ll inf = 1LL << 50;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}
void mul(ll a, ll b) {
	a = a * b % INF;
}
struct Accelerate_Cin {
	Accelerate_Cin() {
		cin.tie(0);
		ios::sync_with_stdio(0);
		cout << fixed << setprecision(20);
	};
};
///////////////////////////////////////

//ラウンドiの直前の時点で脱落せず残っている子供の人数をXとする。
//ラウンドiの直後には何人残るか？
//作られるグループの個数は明らかにX/AiであるためX-X mod Ai人が残ることになる
//以後　fp(X)=X- X mod pと書く
//この問題では次のようなNの値を全て求めることが要求されている
//g(N)=fAk(fAk-1(...fA1(N)...))=2
//主に二つの方針が考えられる
//解法１
//操作を逆にして更新していく
//最終的に二人が生き残るようなラウンドiの直後での最小の生存人数をLiとし同様に
//最大の生存人数をRiとする。Lk=Rk=2であることがわかっていて求めたいものはL0,R0
//Li,RiからLi-1,Ri-1を復元する
//まずラウンドiの直後での生存人数はAiで割り切れなければいけないもしLiとRiの間に
//Aiの倍数が存在しない場合答えは-1となる。
//そうでない場合、区間[Li,Ri]内のAiの倍数の内最小のものと最大の物をそれぞれXi,Yiとすると
//Li=Xi,Ri=Yi+Ai-1となる
//ここでXi=[Li/Ai]*Ai,Yi=Ri/Ai*Aiであるため結局
//L(i-1)=[Li/Ai]*Ai
//R(i-1)=Ri/Ai+Ai-1
int main() {
	int K;
	cin >> K;
	int A[100100];
	REP(i, K)cin >> A[i];
	ll L = 2, R = 2;
	for (int i = K - 1; i >= 0; --i) {
		L = (L + A[i] - 1) / A[i] * A[i];
		if (R < L) {
			cout << -1 << endl;
			return 0;
		}
		R = (R / A[i] + 1)*A[i] - 1;
	}
	cout << L << " " << R << endl;
	return 0;
}


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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

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

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


Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(n); ++i)
#define repr(i, a, b) for (int i=a; i<(b); ++i)
#define reprev(i, n) for (int i=n-1; i>=0; --i)
#define reprrev(i, a, b) for (int i=b-1; i>=(a); --i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
    cout << fixed << setprecision(10);
    
    int N; cin >> N;

    vector<int> A(N);
    rep(i, N) cin >> A[i];
    
    ll ans = 0;
    rep(i, N - 1) {
        if (A[i] % 2 == 1 && A[i+1] > 0) {
            A[i] -= 1;
            A[i+1] -= 1;
            ans += 1;
        }
    }
    rep(i, N) {
        ans += A[i] / 2;
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

using ll = long long;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> b(n);
    for (int i = 0; i < n; i++) {
        cin >> b[i];
    }

    vector<int> ans(n);
    for (int i = n - 1; i >= 0; i--) {
        int idx = -1;
        for (int j = (int)b.size() - 1; j >= 0; j--) {
            if (b[j] == j + 1) {
                idx = j;
                break;
            }
        }

        if (idx == -1) {
            cout << -1 << endl;
            return 0;
        }

        ans[i] = b[idx];

        vector<int> v;
        for (int j = 0; j < b.size(); j++) {
            if (j == idx) continue;
            v.push_back(b[j]);
        }
        b = v;
    }

    for (int i = 0; i < n; i++) {
        cout << ans[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
using LL = long long;
constexpr int maxn = -1;
unordered_map<LL, LL> mp;
LL A, B, C, D, N, M;
constexpr LL inf = 1e18;
LL dp(LL N){
    if(mp.count(N)) return mp[N];
    LL& res = mp[N];
    res = inf;
    if(N <= inf / D) res = N * D;
    LL M = N / 2 * 2;
    if(N == M){
        if(A < res) res = min(res, dp(N / 2) + A);
    }
    else{
        if((N - M) * D + A < res) 
           res = min(res, (N - M) * D + dp(M / 2) + A);
        M += 2;
        if((M - N) * D + A < res)
            res = min(res, (M - N) * D + dp(M / 2) + A);
    }
    M = N / 3 * 3;
    if(N == M){
        if(B < res) res = min(res, dp(N / 3) + B);
        res = min(res, dp(N / 3) + B);
    }
    else{
        if((N - M) * D + B < res) 
            res = min(res, (N - M) * D + dp(M / 3) + B);
        M += 3;
        if((M - N) * D + B < res)
            res = min(res, (M - N) * D + dp(M / 3) + B);
    }
    M = N / 5 * 5;
    if(N == M){
        if(C < res) res = min(res, dp(N / 5) + C);
    }
    else{
        if((N - M) * D + C < res) 
            res = min(res, (N - M) * D + dp(M / 5) + C);
        M += 5;
        if((M - N) * D + C < res)
            res = min(res, (M - N) * D + dp(M / 5) + C);
    }
    return res;
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int T;
    for(cin >> T; T; T -= 1){
        cin >> N >> A >> B >> C >> D;
        mp.clear();
        cout << dp(N) << endl;
    }
    return 0;
}


Measured memory_bytes: 4136
from sys import stdin,stdout
#for _ in range(int(stdin.readline())):
n=int(stdin.readline())
#a=list(map(int,stdin.readline().split()))
dividend=7;ans=-1
for add in range(10**7):
    rem=dividend%n
    if rem==0:
        ans=add+1
        break
    dividend=rem*10+7
print(ans)


Measured memory_bytes: 9168
S=input()
T= input()

ans = len(T)

def n_gram(target, n):
  # 基準を1文字(単語)ずつ ずらしながらn文字分抜き出す
  return [ target[idx:idx + n] for idx in range(len(target) - n + 1)]

for s in n_gram(S,len(T)):
  mini = 0
  for s1,t1 in zip(s,T):
    if s1 != t1: mini+=1
  ans = min(ans,mini)
print(ans)

Measured memory_bytes: 9376
import numpy as np
D = int(input())
c = list(map(int,input().split()))
s=[]
f=[]
for i in range(D):
  if(i%26 == 0):
    f = [0]*26
  x = np.array(list(map(int, input().split())))
  for j in range(26):
    if(f[j]!=0):
      x.delete(1,j)
  s.append(x.argmax())
for i in range(D):
  print(s[i]+1)

Measured memory_bytes: 27108
#include <bits/stdc++.h>
#define BIT(n) (1LL << (n))
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPB(i, n) for (int i = 0; i < BIT(n); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORA(i, n) for (auto &&i : n)
#define FORS(i, m, n) for (int i = m; i <= n; i++)
#define DEBUG(x) cerr << #x << ": " << x << "\n"
#define PRINTALL(V)                                                            \
  for (auto v : (V)) {                                                         \
    cerr << v << " ";                                                          \
  }                                                                            \
  cerr << "\n";
#define ALL(v) v.begin(), v.end()
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define epb emplace_back
#define int long long
using namespace std;
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;
}
template < class T > using vec = std::vector< T >;
template < class T > void print(const T &x) { cout << x << "\n"; }
const int MOD = 1000000007, INF = 1061109567, INF2 = INF * INF;
const double EPS = 1e-10, PI = acos(-1.0);
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
signed main() {
  cin.tie(0), ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  int N, M;
  cin >> N >> M;
  int baseX, baseY;
  vec< int > x(N), y(M);
  REP(i, N) {
    cin >> x[i];
    if (i == 0) {
      baseX = x[0];
    }
    x[i] -= baseX;
  }
  REP(i, M) {
    cin >> y[i];
    if (i == 0) {
      baseY = y[0];
    }
    y[i] -= baseY;
  }
  int ans = 0;

  REPS(i, N - 1) {
    ans += i * (N - i) * (x[i] - x[i - 1]);
    ans %= MOD;
  }
  int sum = 0;
  REPS(i, M - 1) {
    int tmpsum = ans * i * (M - i);
    tmpsum %= MOD;
    tmpsum *= y[i] - y[i - 1];
    tmpsum %= MOD;
    sum += tmpsum;
    sum %= MOD;
  }
  print(sum);
}

Measured memory_bytes: 1792
import sys
from bisect import bisect


class BinaryIndexedTree:

    def __init__(self, n, MOD):
        self.size = n + 1
        self.tree = [0] * (n + 2)
        self.MOD = MOD

    def sum(self, i):
        i += 1
        s = 0
        while i > 0:
            s = (s + self.tree[i]) % self.MOD
            i -= i & -i
        return s

    def add(self, i, x):
        i += 1
        while i <= self.size:
            self.tree[i] = (self.tree[i] + x) % self.MOD
            i += i & -i

    def debug_print(self, limit=None):
        if limit is None:
            limit = self.size
        acc = [0] + [self.sum(i) for i in range(limit)]
        aaa = [a1 - a0 for a0, a1 in zip(acc, acc[1:])]
        print(aaa)


def solve(n, a, b, sss):
    if a > b:
        a, b = b, a

    for s0, s2 in zip(sss, sss[2:]):
        if s2 - s0 < a:
            return 0

    MOD = 10 ** 9 + 7

    bit = BinaryIndexedTree(n, MOD)
    bit.add(0, 1)
    bit.add(1, 1)

    sss.insert(0, -10 ** 18 - 1)
    pos = 0

    for i in range(1, n):
        s0 = sss[i]
        s1 = sss[i + 1]
        lim = bisect(sss, s1 - b) - 1
        if lim >= pos:
            bit.add(i + 1, bit.sum(lim))
        if s1 - s0 < a:
            bit.add(i - 1, -bit.sum(i - 1))
            pos = i - 1

    return bit.sum(n)


n, a, b, *sss = map(int, sys.stdin.read().split())
print(solve(n, a, b, sss))


Measured memory_bytes: 21744
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
using namespace std;

typedef long long ll;
typedef pair<int, int> pi;

int N, M;
vector<pi> D;

void input_init(void) {
	cin >> N >> M;
	D.resize(N);
	for (int i = 0; i < N; ++i)
		cin >> D[i].first >> D[i].second;
	sort(D.begin(), D.end());
}

ll solve(void) {
	ll cost = (ll)0;
	int rest = M;
	for (int i = 0; i < N; ++i) {
		if (rest <= D[i].second) {
			cost += (ll)D[i].first * rest;
			break;
		}
		else {
			cost += (ll)D[i].first * D[i].second;
			rest -= D[i].second;
		}
	}
	return cost;
}

int main(void) {
	input_init();
	ll ans = solve();

	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std;
const long long int INF = 1e18;
const long long int mod = 1e9+7;

typedef pair<ll, ll> pairs;
typedef vector<pairs> p;

struct Edge{
    ll to, weight;
    Edge(ll t, ll w) : to(t), weight(w){}
};
using graph = vector<vector<ll>>;
using Graph = vector<vector<Edge>>;


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

ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}

ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

// 回文
bool kai(string S){
    bool flag = true;
    for(ll i=0;i<S.size()/2;++i){
        if(S[i] != S[S.size()-i-1]){
            flag = false;
            break;
        }
    }
    return flag;
}
// ---------------------------------------------

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

    ll x = 0, y = 0;
    if(k % 2 == 1){
        for(ll i=1;i<=n;++i){
            if(i % k == 0){
                x++;
            }
        }
    }else if(k % 2 == 0){
        for(ll i=1;i<=n;++i){
            if(i % k == 0){
                x++;
            }else if(i % k == k / 2){
                y++;
            }
        }
    }
    ll ans = x * x * x + y * y * y;
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
   int a, b, r;
   while ( scanf("%d %d", &a, &b) != EOF ) {
      if ( a < b ) {
         r = a;
         a = b;
         b = r;
      }
      r = a % b;
      while ( r ) {
         a = b;
         b = r;
         r = a % b;
      }
      printf("%d\n", b);
   }
   return 0;
}

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

const int MAX = 60;

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

    int h, w, black = 0;
    cin >> h >> w;

    char C[MAX][MAX];
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            cin >> C[i][j];
            if(C[i][j] == '#'){
                black++;
            }
        }
    }

    int D[MAX][MAX];
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            D[i][j] = 1e9;
        }
    }

    D[0][0] = 0;

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

    queue<pair<int, int>> q;
    q.push({0, 0});
    while(!q.empty()){
        pair<int, int> p = q.front();
        q.pop();
        for(int i = 0; i < 4; i++){
            int nx = p.first + dx[i];
            int ny = p.second + dy[i];
            if(nx < 0 or ny < 0 or nx >= h or ny >= w){
                continue;
            }
            if(C[nx][ny] == '#'){
                continue;
            }
            if(D[p.first][p.second] + 1 < D[nx][ny]){
                D[nx][ny] = D[p.first][p.second] + 1;
                q.push({nx, ny});
            }
        }
    }

    if(D[h - 1][w - 1] == 1e9){
        cout << -1 << endl;
    }else{
        // -1はスタート地点
        cout << h * w - black - D[h - 1][w - 1] - 1 << endl;
    }




    return 0;
}

Measured memory_bytes: 256
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

//Tariquzzaman Faisal
//_Faisal101_
//IUT_CSE'19
//190041101

#include<iostream>
#include<stdio.h>
#include<vector>
#include<deque>
#include<map>
#include<stack>
#include<queue>
#include<algorithm>
#include<cstring>
#include<climits>
#include<cmath>
#include<iterator>
#include<set>
#define fileOut freopen("out.txt","w",stdout)
#define fileIn freopen("in.txt","r",stdout)
#define testcases ll TC,T; cin >> TC; for(T=1; T<=TC; T++)
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL)
#define INFLL 9223372036854775807
#define INF 2147483647
#define pi acos(-1.0)
#define ll long long
#define endll printf("\n")
#define CASE printf("Case %lld: ",T)
#define ff first
#define ss second
#define mem(ara,n) memset(ara,n,sizeof ara)
#define ull unsigned long long
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define mid3(a,b,c) min(max(a,b),max(b,c),max(a,b))
#define max4(a,b,c,d) max(max(a,b),max(c,d))
#define min4(a,b,c,d) min(min(a,b),min(c,d))
#define endl '\n'
#define ld long double


using namespace std;


int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int n;
	cin >> n;
	int a[n], b[n];
	for (int i = 0; i < n; ++i)
	{
		a[i] = i + 1;
		b[i] = n - i;
	}
	int p;
	for (int i = 0; i < n; ++i)
	{
		cin >> p;
		a[p - 1] += i;
		for (int j = p - 1; j < n; ++j)
		{
			a[j] += n;
			b[j] -= n;
		}
	}
	int x = 1 - b[n - 1];
	for (int i = 0; i < n; ++i)
	{
		a[i] += x;
		b[i] += x;
	}
	for (int i = 0; i < n; ++i)
	{
		cout << a[i] << " ";
	}
	endll;
	for (int i = 0; i < n; ++i)
	{
		cout << b[i] << " ";
	}
	endll;
	return 0;

}

Measured memory_bytes: 3740
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

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

#define ll long long
#define ld long double 
#define endl "\n"
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(a) (ll)(a.size())
#define all(a) a.begin(), a.end() 
#define fr(i,n) for(i=1;i<=n;i++)
#define rp(i,n) for(i=0;i<n;i++)
#define FIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// order_of_key (val): returns the no. of values less than val
// find_by_order (k): returns the iterator to kth largest element.(0-based)
typedef pair<ll, ll> ii;
typedef vector<ll> vl;
const ll N = 200010;
ll mod=1e9+7;

ll ffmod(ll x, ll y, ll mod)
{
    ll rt=1;
    while(y)
    {
        if(y&1ll) rt=(rt*x)%mod;
        x=(x*x)%mod, y/=2ll;
    }
    return rt;
}

ld dp[3010][3010];

int main()
{
    FIO;
    ll n,i,j;
    ld p;
    cin>>n>>dp[1][1];
    dp[1][0]=1-dp[1][1];
    for(i=2;i<=n;i++)
    {
        cin>>p;
        for(j=0;j<i;j++)
            dp[i][j]=dp[i-1][j]*(ld)(1-p);
        for(j=1;j<=i;j++)
            dp[i][j]=dp[i][j]+dp[i-1][j-1]*p;
    }
    p=0;
    for(i=n/2+1;i<=n;i++) p+=dp[n][i];
    cout<<fixed<<setprecision(10)<<p<<endl;
    return 0;
}


Measured memory_bytes: 139904
s = input()
res1, res2 = 0, 0
for i, j in enumerate(s):
    if i % 2 == 0:
        if j == '0':
            res1 += 1
    else:
        if j == '1':
            res1 += 1
for i, j in enumerate(s):
    if i % 2 == 1:
        if j == '0':
            res2 += 1
    else:
        if j == '1':
            res2 += 1
print(min(res1, res2))


Measured memory_bytes: 3188
while True:
    H,W = map(int, input().split())
    if H == 0 and W == 0:
        break

    for h in range(H):
        squad = ''
        for w in range(W):
            if h % 2 == 0:
                if w % 2 == 0:
                    squad += '#'
                else:
                    squad += '.'
            else:
                if w % 2 == 0:
                    squad += '.'
                else:
                    squad += '#'
        print(squad)
    print()


Measured memory_bytes: 5612
N = int(input())
A, B = [int(x) for x in input().split()]
Ps = [int(x) for x in input().split()]

n1 = len([x for x in Ps if x <= A])
n2 = len([x for x in Ps if A < x <= B])
n3 = len([x for x in Ps if B + 1 <= x])
ans = min(n1, n2, n3)

print(ans)


Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<climits>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define scan(arg) cin>>arg
#define prin(arg) cout<<arg<<"\n"
#define prin2(arg1,arg2) cout<<arg1<<" "<<arg2<<"\n"
using namespace std;
typedef long long ll;
const int NMAX=1<<17;
int h,w;
char s[55][55];
int main(){
  cin>>h>>w;
  rep(i,h){
    rep(j,w){
      scan(s[i][j]);
    }
  }
  rep(i,h){
    rep(j,w){
      int cnt=0;
      if(s[i][j]=='.'){
	for(int k=-1;k<=1;k++){
	  for(int l=-1;l<=1;l++){
	    if(i+k>=0&&j+l>=0&&i+k<h&&j+l<w&&s[i+k][j+l]=='#'){
	      cnt++;
	    }
	  }
	}
	char c='0'+cnt;
	s[i][j]=c;
      }
    }
  }
  
  rep(i,h){
    rep(j,w){
      cout<<s[i][j];
    }
    cout<<"\n";
  }
  
  return 0;
}


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

constexpr int INF = 1LL << 60;
constexpr int MOD = 1e9 + 7;
constexpr int MAX_N = 2 * 100000 + 5;

int n, pres[MAX_N], nxts[MAX_N], dp[MAX_N][2];
vector<int> c;

int solve(int k, bool sel) {
    if (dp[k][sel] != -1) return dp[k][sel];
    if (k == 0) return 1;

    int res = 0, nxt = nxts[k];
    if (nxt != -1) {
        if (sel) {
            res += solve(nxts[k], sel);
        } else {
            res += solve(nxts[k], true);
        }
    }
    res += solve(k - 1, false);
    res %= MOD;
    return dp[k][sel] = res;
}

signed main() {
    memset(dp[0], -1, sizeof(dp));
    memset(nxts, -1, sizeof(nxts));
    memset(pres, -1, sizeof(pres));

    cin >> n;
    for (int i = 0; i < n; i++) {
        int tmp;
        cin >> tmp;
        c.pb(tmp);
    }
    c.erase(unique(c.begin(), c.end()), c.end());

    for (int i = 0; i < c.size(); i++)  {
        nxts[i] = pres[c[i]];
        pres[c[i]] = i;
    }

    cout << solve(c.size() - 1, false) << endl;

    return 0;
}

Measured memory_bytes: 14448
#include <iostream>
#include <string>

using namespace std;

int main()
{
	int N;
	int A;
	double add = 0;
	double mul = 1;
	int i, j;

	cin >> N;

	for (i = 0; i < N; i++) {
		cin >> A;
		mul = 1.0 / A;
		add += mul;
	}

	cout << (1 / add);
//	cout << (mul / add);
	return 0;
}



Measured memory_bytes: 256
import math
from functools import reduce
from collections import deque
import sys
sys.setrecursionlimit(10**7)

# スペース区切りの入力を読み込んで数値リストにして返します。
def get_nums_l():
    return [ int(s) for s in input().split(" ")]

# 改行区切りの入力をn行読み込んで数値リストにして返します。
def get_nums_n(n):
    return [ int(input()) for _ in range(n)]

# 改行またはスペース区切りの入力をすべて読み込んでイテレータを返します。
def get_all_int():
    return map(int, open(0).read().split())

def log(*args):
    print("DEBUG:", *args, file=sys.stderr)

r = int(input())
print(2 * r * 3.141519)


Measured memory_bytes: 67812
#include <iostream>

using namespace std;

int main()
{
    int h, w, c[10][10];

    cin >> h >> w;
    for (int i = 0; i < 10; i++) {
        for (int j = 0; j < 10; j++) {
            cin >> c[i][j];
        }
    }

    for (int k = 0; k < 10; k++) {
        for (int i = 0; i < 10; i++) {
            for (int j = 0; j < 10; j++) {
                c[i][j] = min(c[i][j], c[i][k] + c[k][j]);
            }
        }
    }

    long long ans = 0;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            int x;
            cin >> x;
            if (x != -1) {
                ans += c[x][1];
            }
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 384
#include <iostream>
using namespace std;
int main()
{
	string str;
	cin>>str;str=" "+str;
	int len=str.size();
	bool ok=true;
	for(int i=1;i<len;i++)
	{
		if(i%2)
		{
			if(str[i]=='L'){ok=false;break;}
		}
		else
		{
			if(str[i]=='R'){ok=false;break;}
		}
	}
	if(ok)cout<<"Yes\n";
	else cout<<"No\n";
}

Measured memory_bytes: 256
#ABC-145-B
N = int(input())
S = input()
ans = ""
if N % 2 == 1:
    ans = "No"
half = N // 2
S1 = S[:half]
S2 = S[half:]

if S1 == S2:
    ans = "Yes"
else:
    ans = "No"
    
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
using ll = long long;
using P = pair<int,int>;
using PP = pair<int,pair<int,int>>;
using T = tuple<string,int,int>;
const ll INF = 1LL<<60;
const int ny[4] = {-1,1,0,0}, nx[4] = {0,0,-1,1};
int sy,sx,gy,gx;


int main(){
  int n; cin >> n;
  ll ans = 1;
  for(int i = 1; i <= n; i++){
    ans = ans * i % 1000000007;
  }
  cout << ans << endl;
  return 0;
}


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

long long mod = 1000000007LL;

typedef pair<long long, long long> ii;
int main(){
	//freopen("i.txt","r",stdin);
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	string s; int k;
	cin >> s;
	cin >> k;
	
	int nonzero = 0;
	
	int n = s.length();
	long long ans = 0;
	for(int i = 0;i < s.length();i++){
		int cur = s[i] - '0';
		
		//if(nonzero > k) break;
		if(i == 0){
			for(int d = 1;d < cur;d++){
				int target = k - nonzero;
				if(d != 0) target--;
				if(target < 0) continue;
				
				long long len = n - i  - 1;
				long long value = 1;
				for(long long j = 0;j < target;j++){
					value *= (len - j);
					value /= (j + 1);
				}
				for(long long j = 0;j < target;j++){
					value *= 9;
				}
				ans += value;
			}
		}
		else{
			for(int d = 0;d < cur;d++){
				int target = k - nonzero;
				if(d != 0) target--;
				if(target < 0) continue;
				
				long long len = n - i  - 1;
				long long value = 1;
				//cout << i << " " << d << " " << target << "\n";
				for(long long j = 0;j < target;j++){
					value *= (len - j);
					value /= (j + 1);
				}
				for(long long j = 0;j < target;j++){
					value *= 9;
				}
				ans += value;
			}
			
			for(int d = 1;d < 10;d++){
				int target = k;
				if(d != 0) target--;
				if(target < 0) continue;
				
				long long len = n - i  - 1;
				long long value = 1;
				for(long long j = 0;j < target;j++){
					value *= (len - j);
					value /= (j + 1);
				}
				for(long long j = 0;j < target;j++){
					value *= 9;
				}
				ans += value;
			}
		}
		if(cur != 0) nonzero++;
	}
	if(nonzero == k) ans++;
	cout << ans;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <utility>
#include <cstdio>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <cmath>
#include <set>
#include <map>
using ll = long long;
using itn = int;
using namespace std;
int main(){
    int n;
    cin >> n;
    int num = n;
    int sn=0;
    while(num!=0){
        sn+=num%10;
        num /= 10;
    }
    if(n%sn){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }
    return 0;
}


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

int main(void) {
  long K;
  cin >> K;
  if (K % 2 == 0) {
    cout << -1 << endl;
  } else {
    long count = 1;
    long start = 7;
    long r = 0;
    long rs[K]; for (long i = 0; i < K; i++) {rs[i] = 0;} //rs[i] = あまりがiの数
    while (true) {
      r = start % K;
      if (r == 0) {
        break;
      } else {
        count++;
        rs[r]++;
        if (rs[r] > 1) {count = -1; break;}
        start = r * 10 + 7;
      }
    }
    cout << count << endl;
  }

}

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


typedef long long ll;

int main(){
	ll x;
	cin >> x;
	ll ans = 0;
	ans += (x / 500) * 1000;
	x = x % 500;
	ans += (x / 5) * 5;
	cout << ans << endl;
}


Measured memory_bytes: 256
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use {
    proconio::{marker::*, *},
    std::{cmp::*, collections::*, mem::*},
};

#[fastout]
fn main() {
    input! {//
        n:usize,k:usize,
    }
    let mut iter = 0;
    let mut num = vec![0; MX];
    let mut dp = vec![vec![0; MX]; 111];
    let mut dp_sum = vec![0; MX];
    let mut i = 1;
    while i <= n {
        let j = n / i;
        if i <= j {
            num[iter] = 1;
            i += 1;
        } else {
            num[iter] = n / j - i + 1;
            i = n / j + 1;
        }
        iter += 1;
    }
    dp[0][0] = 1;
    for kk in 0..k {
        dp_sum = vec![0; MX];
        for j in 0..=iter {
            dp_sum[j + 1] = dp_sum[j] + dp[kk][j] % MOD;
        }
        for j in 0..iter {
            dp[kk + 1][j] = dp_sum[iter - j] * num[j] % MOD;
        }
    }
    let mut ans = 0;
    for i in 0..=iter {
        ans += dp[k][i];
        ans %= MOD;
    }
    println!("{}", ans);
}
const MOD: usize = 1000000007;
const MX: usize = 101101;


Measured memory_bytes: 91092
//This is getting accepted!
// I HATE BUG
// God Of The Bugs
// 12/11/2016
#include<bits/stdc++.h>

using namespace std;

#define ms(s, n) memset(s, n, sizeof(s))
#define FI first
#define SE second
#define pb push_back
#define mp make_pair
#define ll long long
#define sz(a) ((int)(a).size())
#define __builtin_popcount __builtin_popcounll
#define ld long double

typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<int, pii> ppi;

const double PI = acos(0) * 2;
const double EPS = 1e-8;
const ll MOD = 1e9 + 7;
const int MAXN = 1e5 + 5;
const int oo = 1e9;
const double foo = 1e30;

template<class T> int getbit(T s, int i) { return (s >> i) & 1; }
template<class T> T onbit(T s, int i) { return s | (T(1) << i); }
template<class T> T offbit(T s, int i) { return s & (~(T(1) << i)); }
template<class T> int cntbit(T s) { return __builtin_popcounll(s);}
template<class T> T sqr(T x) { return x * x; }

inline void addmod(int& a, int val, int p = MOD) {if ((a = (a + val)) >= p) a -= p;}
inline void submod(int& a, int val, int p = MOD) {if ((a = (a - val)) < 0) a += p;}
inline int mult(int a, int b, int p = MOD) {return (ll) a * b % p;}

int n;
ll fact[MAXN], a[MAXN], ans, cnt[MAXN];

int main() {
//#ifndef ONLINE_JUDGE
//    freopen("inp.txt", "r", stdin);
////    freopen("out.txt", "w", stdout);
//#endif

	cin >> n;
	fact[0] = 1;
	for (int i=1; i<MAXN; i++) fact[i] = fact[i - 1] * i % MOD;
	
	for (int i=0; i<n; i++) cin >> a[i];
	ll tot = a[0] - 1;
	cnt[0] = 1;
	int cur = 1;
	for (ll i=1; i<n; i++) {
		while (tot < i - (cur) - (cur - 1)) cur++;
		cnt[cur - 1]++;
		tot += (a[i] - a[i - 1] - 1);
	}
//	cout << cnt[0] << endl;
	for (int i=1; i<n; i++) cnt[i] += cnt[i - 1];
	ans = 1;
	for (int i=0; i<n; i++) ans = ans * (cnt[i] - i) % MOD;
	
	cout << ans;
}


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

int main() {  
  int n,cnt=0;
  cin >> n;
  int table[n];
  for (int i = 0; i < n; i++) {
    cin >> table[i];
  }

  bool check = 0;

  while (true) {

    for (int j = 0; j < n; j++) {
      if (table[j]%2 != 0) {
        check = 1;
      }
    }
    if (check) break;

    for (int k = 0; k < n; k++) {
      table[k]  /= 2; 
      }
      cnt++;
  }
  cout << cnt << endl;
}





Measured memory_bytes: 256
n = gets.to_i
a = gets.to_s
b = gets.to_s
c = gets.to_s

cnt = 0
for i in 0..n-1 do
  if ((a[i]== b[i]) && (a[i] != c[i])) or
     ((a[i]== c[i]) && (a[i] != b[i])) or
     ((b[i]== c[i]) && (a[i] != b[i]))
    cnt += 1
  elsif (a[i]!=b[i]) && (a[i]!=c[i])
    cnt += 2
  end
end
puts cnt

Measured memory_bytes: 1788
#include <iostream>
#include <cstdio>
#define N 100005
using namespace std;

typedef long long ll;
ll n, s, a[N];
int main()
{
	int i;
	cin >> n;
	for (i = 0; i < n; i++) {
		scanf("%lld", &a[i]);
		a[i] *= 2;
		s += a[i] * (1 - i % 2 * 2);
	}
	s /= 2;
	cout << s << ' ';
	for (i = 0; i < n - 1; i++) s = a[i] - s, printf("%lld ", s);
    return 0;
}

Measured memory_bytes: 2048
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define fr(i,j,n)   for(int i=j;i<(n);++i)
#define bk(i,j,n)   for(int i=j;i>n;--i)
#define mset(x,y) memset(x,y,sizeof(x))
#define pb push_back
#define pop pop_back
#define mod 1000000007
#define all(x) x.begin(),x.end()
#define inf 1e18
#define iosbase ios_base::sync_with_stdio(false); cin.tie(NULL);
#define F first
#define S second
#define bye return

int main()
{
    double R,pi;
    cin>>R;
    pi=3.1415926535897;
    double ans;
    ans= (pi*(2*R));
    cout<<ans<<endl;
}

Measured memory_bytes: 3776
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<algorithm>
#include<queue>
#include<map>
#include<set>
#include<vector>
#include<functional>
#include <random>
#include<iostream>
#include<iomanip>
using namespace std;

long long mod_inverse(long long a) {
	long long ret = 1;
	long long p = 998244351;
	while (p > 0) {
		if (p % 2 == 1) {
			ret = (ret * a) % 998244353;
		}
		a = (a * a) % 998244353;
		p = p / 2;
	}
	return ret;
}

int main() {
	long long N, M, K;
	cin >> N >> M >> K;

	long long ans = 0;
	long long summand = 1;

	if (M == 1) {
		if (K == N - 1) {
			cout << 1;
			return 0;
		}
		else {
			cout << 0;
			return 0;
		}

	}

	/*i=0*/
	summand = M;
	for (int i = 0; i < N - 1; i++) {
		summand = (summand * (M - 1)) % 998244353;
	}
	
	for (int i = 1; i <= K; i++) {
		ans = (ans + summand) % 998244353;
		summand = (summand * mod_inverse(M - 1)) % 998244353;
		summand = (summand * (N - i)) % 998244353;
		summand = (summand * mod_inverse(i)) % 998244353;
	}
	ans = (ans + summand) % 998244353;
	cout << ans;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = (ll)1e9 + 7;  
int n,k;
auto x = vector<ll>();

int main(){
  string s;
  cin >> s;

  bool flag = true;
  if(s[0]=='A'){
      int c = 0;
      for (int i = 1; i < s.size(); i++)
      {
          if(s[i]=='C'&&2<=i&&i<s.size()-1){
              c++;
              if(c>1) break;
          }else if(!islower(s[i])){
              flag = false;
              break;
          }
      }
      if(c!=1) flag = false;
      
  }else{
      flag = false;
  }
  cout << (flag ? "AC" : "WA");
}
  
  

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        String s = sc.next();
        String[] test = {"dreamer", "dream", "eraser", "erase"};
        boolean isAns = true;

        int index = s.length();
        while (index > 0) {
            boolean isCheck = false;
            for (int i = 0; i < 4; i++) {
                int start = Math.max(index-test[i].length(), 0);
                String sub = s.substring(start, index);
                if (sub.equals(test[i])) {
                    isCheck = true;
                    index = start;
                    break;
                }
            }

            if (!isCheck) {
                isAns = false;
                break;
            }
        }

        System.out.println(isAns ? "YES" : "NO");
    }
}


Measured memory_bytes: 30116
import itertools

s = input()

x = ['+','-']

l = list(itertools.product(x,x,x))

res = int(s[0])
for sign in l:
  res = int(s[0])
  for i in range(3):
    if sign[i] == '+':
      res += int(s[i+1])
    else:
      res -= int(s[i+1])
  if res == 7:
    print(s[0],end="")
    for i in range(3):
      print(sign[i],end="")
      print(s[i+1],end="")
    print("=7")
    exit(0)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
typedef long long ll;
typedef pair<int,int> pint;

int n;
ll a[100001],b[100001];
int main(){
    cin>>n;
    rep(i,n) cin>>a[i];
    ll sum=0,sum2=0;
    vector<ll> v;
    int ans=0;
    rep(i,n){
        cin>>b[i];
        if(b[i]>a[i]){
            sum+=b[i]-a[i];
            ++ans;
        }
        else if(a[i]>b[i]){
            v.pb(a[i]-b[i]);
            sum2+=a[i]-b[i];
        }
    }
    if(sum==0){
        cout<<0<<endl;
        return 0;
    }
    if(sum>sum2){
        cout<<-1<<endl;
        return 0;
    }
    sort(v.begin(),v.end(),greater<ll>());
    for(ll it:v){
        sum-=it;
        ++ans;
        if(sum<=0) break;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 2296
import sys
from collections import deque
import numpy as np
import math
sys.setrecursionlimit(10**6)
def S(): return sys.stdin.readline().rstrip()
def SL(): return map(str,sys.stdin.readline().rstrip().split())
def I(): return int(sys.stdin.readline().rstrip())
def IL(): return map(int,sys.stdin.readline().rstrip().split())

if __name__=='__main__':
    s,t,u = SL()
    x = s[0]+t[0]+u[0]
    print(x.upper())
    exit()

Measured memory_bytes: 26612
#include <bits/stdc++.h>
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = ((int)(n)-1); i >= 0; i--)
#define all(x) (x).begin(),(x).end()
 
using namespace std;
using ll = long long;
 
struct edge { int to, cost; };
 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> P;
 
const int INF = 1e9;
const double EPS = 1e-10;
const int MOD = 1e9+7;
const double PI = acos(-1.0);
 
const int mx4[] = {0,1,0,-1};
const int my4[] = {1,0,-1,0};
const int mx8[] = {0,1,1,1,0,-1,-1,-1};
const int my8[] = {1,1,0,-1,-1,-1,0,1};
 
int main()
{
	int n;
	cin >> n;
	vi a(n+1),b(n);
	rep(i,n+1) cin >> a[i];
	rep(i,n) cin >> b[i];
 
	ll ans = 0;
	for(int i = n-1; i >= 0; i--){
		ll num = min(a[i+1],b[i]);
		a[i+1] -= num;
		b[i] -= num;
		ans += num;
		if(b[i] > 0){
			num = min(a[i],b[i]);
			a[i] -= num;
			b[i] -= num;
			ans += num;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
/*
 * Author: RainAir
 * Time: 2019-10-08 16:16:32
 */
#include <algorithm>
#include <iostream>
#include <cstring>
#include <climits>
#include <cstdlib>
#include <cstdio>
#include <bitset>
#include <vector>
#include <cmath>
#include <ctime>
#include <queue>
#include <stack>
#include <map>
#include <set>

#define fi first
#define se second
#define P std::pair
#define LL long long
#define pb push_back
#define MP std::make_pair
#define all(x) x.begin(),x.end()
#define CLR(i,a) memset(i,a,sizeof(i))
#define FOR(i,a,b) for(int i = a;i <= b;++i)
#define ROF(i,a,b) for(int i = a;i >= b;--i)
#define DEBUG(x) std::cerr << #x << '=' << x << std::endl

const int MAXN = 40+5;
const int MAXM = 5+7+5+1;
const int ha = 1e9 + 7;

int f[MAXN][(1<<MAXM)+3];
int n,x,y,z;

int main(){
    scanf("%d%d%d%d",&n,&x,&y,&z);
    int fin = (1<<(x+y+z-1))|(1<<(x+y-1))|(1<<(x-1));
    f[0][0] = 1;int U = (1<<(x+y+z))-1;
    FOR(i,0,n-1){
        FOR(S,0,U){
            if(!f[i][S]) continue;
            FOR(k,1,10){
                LL T = U&((S<<k)|(1<<(k-1)));
                if((T&fin) != fin){
                    (f[i+1][T] += f[i][S]) %= ha;
                }
            }
        }
    }
    int ans = 0;
    FOR(S,0,(1<<(x+y+z))-1) (ans += f[n][S])%=ha;
    int t = 1;FOR(i,1,n) t = 1ll*t*10%ha;
    ans = ha-ans;
    printf("%d\n",(ans+t)%ha);
    return 0;
}


Measured memory_bytes: 41216
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

/**
 * 0002：Digit Number
 * 
 * @author MS14A
 * @version 2015/07/11
 */
public class Main {

    /** 区切り文字：スペース */
    private static final String DELIMITER_SPACE = " ";

    /**
     * 与えられた２つの整数 a と b の和の桁数を出力する。
     * 
     * @param args
     * @throws IOException
     * @throws NumberFormatException
     */
    public static void main(String[] args) throws NumberFormatException, IOException {

        // 各データセットの整数 a と b を取得
        List<Integer> a = new ArrayList<Integer>();
        List<Integer> b = new ArrayList<Integer>();
        getTarget(a, b);

        // データセット毎の a と b の和の桁数を出力
        for (int i = 0; i < a.size(); ++i) {
            System.out.println(getDigitNumber(a.get(i) + b.get(i)));
        }

    }

    /**
     * 与えられた数の桁数を求める
     * 
     * @param target 桁数を求める整数
     * @return 引数の桁数
     */
    private static int getDigitNumber(int target) {
        return String.valueOf(target).length();
    }

    /**
     * 標準入力を読み取り、データセットを取得する。
     * 
     * @param a 1つ目の整数
     * @param b 2つ目の整数
     * @throws NumberFormatException
     * @throws IOException
     */
    private static void getTarget(List<Integer> a, List<Integer> b) throws NumberFormatException, IOException {
        // 入力読取り
        InputStreamReader streamReader = new InputStreamReader(System.in);
        BufferedReader bufferedReader = new BufferedReader(streamReader);

        String line = null;

        try {
            while ((line = bufferedReader.readLine()) != null) {
                // 区切り文字により a と b に分けて格納
                String[] ab = line.split(DELIMITER_SPACE);
                a.add(Integer.parseInt(ab[0]));
                b.add(Integer.parseInt(ab[1]));
            }
        } finally {
            bufferedReader.close();
            streamReader.close();
        }
    }

}

Measured memory_bytes: 17016
# -*- coding: utf-8 -*-

import math
import sys
import heapq
from operator import itemgetter
import itertools
input = sys.stdin.readline

# a = int(input().rstrip())
# a, b = map(int, input().rstrip().split())
# D = list(map(int, input().rstrip().split()))
# H = [int(input().rstrip()) for _ in range(L)]
# DD = [[0 for j in range(100)] for i in range(200)]
# dict = {} ## dictionary

# a = sorted(a, key=lambda x: x[1]))
# if __name__ == '__main__':


def get_route(h, w):
	ret = []
	i = 0
	while i < h:
		## move right
		for j in range(w):
			ret.append([i, j])
		i += 1
		
		if i == h:
			return(ret)
		
		## move left
		for j in range(w-1, -1, -1):
			ret.append([i, j])
		i += 1
	return(ret)


if __name__ == '__main__':
	## input
	H, W = map(int, input().rstrip().split())
	coins_s = []
	for i in range(H):
		coins_s.append(list(map(int, input().rstrip().split())))
		for j in range(W):
			coins_s[i][j] = coins_s[i][j] % 2

	## solve
	route_s = get_route(H, W)[1:]
	ans_s = []

	i_prev, j_prev = [0, 0]
	for i, j in route_s:
		if coins_s[i_prev][j_prev] == 1:
			ans_s.append([i_prev, j_prev, i, j])
			coins_s[i][j] = (coins_s[i][j] + 1) % 2
		i_prev, j_prev = [i, j]

	print(len(ans_s))
	for a, b, c, d in ans_s:
		print(a+1, b+1, c+1, d+1)

Measured memory_bytes: 52536
fun main(args: Array<String>) {
    val n = readLine()?.toInt() ?: return
    val sMap = (0 until n).map { readLine()!! }.groupBy { it }.mapValues { it.value.count() }
    val m = readLine()?.toInt() ?: return
    val tMap = (0 until m).map { readLine()!! }.groupBy { it }.mapValues { it.value.count() }

    val resultMap = mutableMapOf<String, Int>().apply {
        sMap.forEach {
            this[it.key] = it.value
        }
    }

    for (entry in tMap) {
        if (entry.key in sMap.keys) {
            resultMap[entry.key] = (resultMap[entry.key]!! - entry.value)
        }
    }

    val max = resultMap.values.max()!!
    println(if (max >= 0) max else 0)
}

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

double dp[3000][3000], ans;

int main(){
	int N; cin >> N;
	double p[N+1];
	for(int i=1; i<=N; i++){
		cin >> p[i];
	}
	dp[1][0] = 1 - p[1]; dp[1][1] = p[1];
	for(int i=2; i<=N; i++){
		for(int j=0; j<=i; j++){
			dp[i][j] = p[i] * dp[i-1][j-1] + (1-p[i]) * dp[i-1][j];
		}
	}
	for(int i=(N/2)+1; i<=N; i++){
		ans += dp[N][i];
	}
	printf("%.16f\n", ans);
	return 0;
}

Measured memory_bytes: 68864
#include <bits/stdc++.h>
using namespace std;
int main() {
    vector<int> a(4);
    for(int i = 0;i < 4;i++) {
        cin >> a.at(i);
    }
    sort(a.begin(),a.end());
    if(a.at(0) == 1 && a.at(1) == 4 && a.at(2) == 7 && a.at(3) == 9) {
        cout << "YES" << endl;
    }else {
        cout << "NO" << endl;
    }
}


Measured memory_bytes: 384
#!/usr/bin/env ruby

require 'set'

class Hash
  def push(key, value)
    self[key] = [] if self[key] == nil
    self[key].push(value)
  end
end

class Array
  def lower_bound(value)
    left = -1;
    right = self.length;
    while left + 1 < right
      mid = left + (right - left) / 2;
      if self[mid] >= value
        right = mid
      else
        left = mid
      end
    end
    right
  end

  def unique
    res = [self.first]
    each_cons(2) do |a, b|
      if a != b
        res.push(b)
      end
    end
    res
  end
end

def get_ints
  gets.chomp.split.map(&:to_i)
end

def get_ints_minus_one
  get_ints.map { |x| x - 1 }
end

def get_int
  gets.chomp.to_i
end

N = get_int

test = N.to_s.split('').map do |n|
  if n == '9'
    '1'
  else
    '9'
  end
end

puts test.join


Measured memory_bytes: 14352
#define LOCAL
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rrep(i, n) for(int i=(n-1); i>=0; --i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)
#define ALL(v) (v).begin(), (v).end()
#define memr(dp, val) memset(dp, val, sizeof(dp))
using namespace std;
typedef long long ll;
static const int INTINF = (INT_MAX >> 1); // 10^9 + 10^7
static const ll LLINF = (LLONG_MAX >> 1);
static const int MAX = 1e5+1;
static const ll MOD = 1e9+7;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> inline bool int_ceil(T a, T b) { T res = a / b; if(a % b != 0) res++; return res; }
template<typename T>
using min_priority_queue = priority_queue<T, vector<T>, greater<T> >;
string to_string(string s) { return '"' + s + '"'; }
string to_string(bool b) { return b ? "true" : "false"; }
template <size_t N> string to_string(bitset<N> bs) {
  string res;
  for (size_t i = 0; i < N; ++i) res += '0' + bs[i];
  return res;
}
string to_string(vector<bool> v) {
  string res = "{";
  for (bool e : v) res += to_string(e) + ", ";
  return res += "}";
}
template <class T, class U> string to_string(pair<T, U> p);
template <class C> string to_string(C c) {
  string res = "{";
  for (auto e : c) res += to_string(e) + ", ";
  return res += "}";
}
template <class T, class U> string to_string(pair<T, U> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
void debug() { cerr << '\n'; }
template <class Head, class... Tail> void debug(Head head, Tail... tail) {
  cerr << '\t' << to_string(head), debug(tail...);
}
#ifdef LOCAL
#define print(...) cerr << "[" << #__VA_ARGS__ << "]:", debug(__VA_ARGS__)
#else
#define print(...)
#endif

int main(int argc, const char * argv[]) {
	std::cout << std::fixed << std::setprecision(15);

	bool ans = false;

	ll x, y; cin >> x >> y;

	rep(i, 101){
		rep(j, 101){
			if(i + j != x) continue;

			if((i) * 2 + (j) * 4 == y){
				ans = true;
			}
		}
	}
	if(ans){
		cout << "Yes" << endl;
	}
	else{
		cout << "No" << endl;
	}

	return 0;
}


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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ll long long
#define inf 1e18
#define pi acos(-1.0)

ll n,w,a[105],b[105],dp[105][100005];

ll solve()
{
    ll i,j;

    for(i=1;i<=n;i++)
    {
        for(j=1;j<=w;j++)
        {
            if(a[i]<=j)
            {
                dp[i][j]=max(dp[i-1][j-a[i]]+b[i],dp[i-1][j]);
            }
            else dp[i][j]=dp[i-1][j];
        }
    }

    return dp[n][w];
}

int main()
{
    fastio;

    cin >> n >> w;
    for(int i=1;i<=n;i++)cin >> a[i] >> b[i];
    cout << solve();

    return 0;
}


Measured memory_bytes: 81728
/*
     Author:Raghav Bansal
     IIIT Una
                  */
#include <bits/stdc++.h>
#define int long long int
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define BOLT ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define X first
#define Y second
#define endl "\n"
using namespace std;
void solve() {
    string s;
    cin >> s;
    if (s[1] == 'R') {
        cout << "ABC" << endl;
    } else {
        cout << "ARC" << endl;
    }
}
int32_t main() {
    BOLT;
    solve();
}


Measured memory_bytes: 3652