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

#define REP(i,n) for(int i=0;i<(n);i++)
#define REAP(i,a,n) for(int i=(a);i<(n);i++)
#define YES cout<<"Yes"<<endl
#define NO cout<<"No"<<endl
#define fr first
#define sc second
#define pb push_back
#define All(v) v.begin(),v.end()
typedef long long ll;

int h,w;
int block[51][51];
int s[51][51];

int check(int i,int j){
    if(i>0&&j>0)return 0;
    else if(i>0)return 1;
    else return 2;
}

int solve(){
    REP(i,h){
        REP(j,w){
            if(i==0&&j==0)continue;
            int ch=check(i,j);
            if(ch==0){
                s[i][j]=block[i][j]+min(s[i][j-1],s[i-1][j]);
            }else if(ch==1){
                s[i][j]=block[i][j]+s[i-1][j];
            }else if(ch==2){
                s[i][j]=block[i][j]+s[i][j-1];
            }
        }
    }
    return s[h-1][w-1];
}


int main(){
    cin >> h >> w;

    char c;
    REP(i,h){
        REP(j,w){
            cin >> c;
            block[i][j]=c-'0';
        }
    }
//    REP(i,51){
//        REP(j,51){
//            s[i][j]=INT_MAX;
//        }
//    }
    s[0][0]=0;
    int ans=solve();

//    REP(i,h){
//        REP(j,w){
//            cout << s[i][j] << " ";
//        }
//        cout << endl;
//    }
    cout << ans << endl;
}



Measured memory_bytes: 3124
#include<bits/stdc++.h>
using namespace std;
int main(){
	ios_base::sync_with_stdio(0);
	int a[10000],x;
	char b[10001];
	cin>>x>>b;
	for(int i=0;i<strlen(b);i++){
		a[i]=b[i]-'A';
		a[i]=(a[i]+x)%26;
		b[i]=a[i]+'A';
	}
	cout<<b<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define deb(x)     cerr << (#x) << " is " << (x) << "\n"
#define ll long long int
#define ld long double
using namespace std;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;

ll powmod(ll a, ll b){
	ll res = 1ll;
	while(b){
		if(b%2 == 1)	res = (res * a) % MOD;
		a = (a * a) % MOD;
		b /= 2;
	}
	return res;
}

int main(){

 
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	
	string s;
	cin >> s;
	int n = s.length();

	n++;
	ll arr[n+10];
	arr[0] = 0;
	ll x = 0;
	ll sum = 0;
	memset(arr, -1, sizeof(arr));
	for(int i = 0; i < n-1; i++){
		int j;
		if(s[i] == '>')	continue;
		arr[i] = 0;
		for(j = i; j < n-1 and s[j] == '<'; j++)	arr[j+1] = arr[j] + 1;
		i = j;
	}

	if(arr[n-1] == -1)	arr[n-1] = 0;

	for(int i = n-1; i > 0; i--){
		if(arr[i] == 0){
			for(int j = i - 1; j >= 0 and s[j] == '>'; j--)	arr[j] = max(arr[j], arr[j + 1] + 1);
		}
	}

	sum = 0;
	for(int i = 0; i < n; i++)	sum += arr[i];

	cout << sum;
}

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

#define NDEBUG
#include <cassert>

typedef long long ll;
typedef long double Double;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef pair<ll,ll> llll;
typedef pair<double,double> dd;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<long double> vD;

#define sz(a)  int((a).size())
#define pb  push_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c)  (c).rbegin(),(c).rend()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define found(s,e)  ((s).find(e)!=(s).end())
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))
#define cons make_pair


ll gcd(ll a, ll b) { while(a) swap(a, b%=a); return b; }

const ll MOD=1000000007LL;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }


int N, Q;
string S;

vi acc_m;

void prepare() {
    acc_m.assign(N+1, 0);

    rep(i,N) {
        acc_m[i+1] = acc_m[i] + (S[i] == 'M' ? 1 : 0);
    }
}

ll query(int k){
    ll ans = 0;

    deque<int> resv;
    ll dp[2][2];
    dp[0][0] = dp[0][1] = 0;

    rep(i,N) {
        int i0 = i%2, i1 = 1-i0;
        while (!resv.empty() && resv.front() <= i-(k-0)) {
            int expired_d = resv.front();
            dp[i0][0]--;
            int cnt_m = acc_m[i] - acc_m[expired_d];
            dp[i0][1] -= cnt_m;
            resv.pop_front();
        }

        dp[i1][0] = dp[i0][0];
        dp[i1][1] = dp[i0][1];

        switch (S[i]) {
            case 'D':
                dp[i1][0]++;
                resv.push_back(i);
                break;
            case 'M':
                dp[i1][1] += dp[i0][0];
                break;
            case 'C':
                ans += dp[i0][1];
                break;
            default:
                break;
        }
    }

    return ans;
}


int main() {
    cin >> N;
    cin >> S;
    cin >> Q;
    prepare();
    rep(i,Q) {
        int ki; cin >> ki;
        cout << query(ki) << endl;
    }
    return 0;
}


Measured memory_bytes: 9196
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
using ll = long long;
using ull = unsigned long long;

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

    if (s[0] == s[1] && s[1] == s[2]) {
        cout << "No" << endl;
        return 0;
    }
    if (s[0] == s[1]) {
        if (s[2] == s[3]) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    if (s[0] == s[2]) {
        if (s[1] == s[3]) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    if (s[0] == s[3]) {
        if (s[1] == s[2]) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
using System;

class AdditionAndSubtractionEasy {
    static void Main() {
        string input = Console.ReadLine();

        int value1   =  int.Parse(input.Split(' ')[0]);
        char op      = char.Parse(input.Split(' ')[1]);
        int value2   =  int.Parse(input.Split(' ')[2]);

        int answer = 0;
        if (op == '+') {
            answer = value1 + value2;
        } else if (op == '-') {
            answer = value1 - value2;
        }

        Console.WriteLine(answer);
    }
}

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

long long int gcd(long long int x, long long int y){
    if( y > x) return gcd(y, x);
    else if( y == 0) return x;
    else return gcd(y, x%y); 
}

int main(void)
{
    int N;
    cin >> N;
    long long int T[N];

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

    long long int ans = T[0];
    for( int i = 1; i < N; i++){
        ans *= T[i] / gcd(ans,T[i]);
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
  val N = readInt()
  val A = (1..2).map { readInts() }
  val dp = Array(2) { Array(N) { 0 } }
  dp[0][0] = A[0][0]
  dp[1][0] = A[0][0] + A[1][0]
  for (i in 1 until N) {
    dp[0][i] = dp[0][i - 1] + A[0][i]
  }
  for (i in 1 until N) {
    dp[1][i] = Math.max(dp[1][i - 1], dp[0][i]) + A[1][i]
  }

//  for (i in 0 until 2) {
//    for (j in 0 until N) {
//      print(dp[i][j])
//      print(" ")
//    }
//    println()
//  }
  println(dp[1][N - 1])
}

fun readString() = readLine()!!
fun readStrings() = readString().split(" ")
fun readInt() = readString().toInt()
fun readInts() = readStrings().map { it.toInt() }
fun readLongs() = readStrings().map { it.toLong() }


Measured memory_bytes: 36076
#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main(int argc, char* argv[]) {
    string input_string;
    cin >> input_string;
    for(int i = 0; i < input_string.size()-1; i++) {
        if(input_string[i] == 'A')
            if(input_string[i+1] == 'C'){
                cout << "Yes" << endl;
                return 0;
            }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
int main(){
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i,n) {
        cin >> a[i];
        a[i] %= mod;
    }
    vector<ll> s(n); //s[i] : iまでの和
    s[0] = a[0];
    rep(i,n-1) {
        s[i+1] = s[i] + a[i+1];
        s[i+1] %= mod;
    }
    mint ans = 0;
    for(int i = 1; i < n; i++) {
        ans += a[i] * s[i-1];
    }
    cout << ans << endl;
}


Measured memory_bytes: 6424
#include<stdio.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<queue>
#include<map>
#include<algorithm>
#include<string.h>
#include<functional>
#include<limits.h>
#include<stdlib.h>
#include<string>
#include<unordered_map>
#include<set>
using namespace std;

#define intmax INT_MAX
#define lmax LONG_MAX
#define uintmax UINT_MAX
#define ulmax ULONG_MAX
#define llmax LLONG_MAX
#define ll long long
#define rep(i,a,N) for((i)=(a);(i)<(N);(i)++)
#define rrp(i,N,a) for((i)=(N)-1;(i)>=(a);(i)--)
#define llfor ll i,j,k
#define sc(a) cin>>a
#define pr(a) cout<<a<<endl
#define pY puts("YES")
#define pN puts("NO")
#define py puts("Yes")
#define pn puts("No")
#define pnn printf("\n")
#define sort(a) sort(a.begin(),a.end())
#define push(a,b) (a).push_back(b)
#define llvec vector<vector<ll>>
#define charvec vector<vector<char>>
#define sizeoof(a,b) (a,vector<ll>(b))
#define llpvec vector<pair<ll,ll>>
/*繰り上げ除算*/ll cei(ll x,ll y){ll ans=x/y;if(x%y!=0)ans++;return ans;}
/*最大公約数*/ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
/*最小公倍数*/ll lcm(ll x,ll y){return x/gcd(x,y)*y;}
/*n乗*/ll llpow(ll x,ll n){ll i,ans=1;rep(i,0,n)ans*=x;return ans;}
/*階乗*/ll fact(ll x){ll i,ans=1;rep(i,0,x)ans*=(x-i);return ans;}
/*nCr*/ll ncr(ll n,ll r){return fact(n)/fact(r)/fact(n-r);}
/*nPr*/ll npr(ll n,ll r){return fact(n)/fact(n-r);}
/*primejudge*/bool prime(ll a){if(a<=1)return false;ll i;for(i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
llfor;///////////////////////////////////////////////////////////
int main(){
 ll n,k;
 sc(k);sc(n);
 char s[150][150];
 rep(i,0,k){
  rep(j,0,n){
   sc(s[i][j]);
  }
 }
 ll x;ll y=0;
 while(y<10){
 //まず行で探します
 rep(i,0,k){
  rep(j,0,n){
   if(s[i][j]=='#')break;
   if(j==n-1){
    rep(x,0,n){
     s[i][x]='a';
    }
   }
  }
 }
 
 //次に列で探します
 rep(i,0,n){
  rep(j,0,k){
   if(s[j][i]=='#')break;
   if(j==k-1){
    rep(x,0,k){
     s[x][i]='a';
    }
   }
  }
 }
  y++;
 }
 ll cnt=0;
 bool flag;
 rep(i,0,k){
  cnt=0;
  rep(j,0,n){
   if(s[i][j]!='a'){
    cout<<s[i][j];
    cnt++;
   }
  }
  if(cnt!=0)pnn;
 }  
return 0;}

Measured memory_bytes: 3652
N = input()
N = int(N)

allsum = int( (N + 1) * N / 2 )
#print(allsum)

f = int(N / 3)
b = int(N / 5)
fb = int(N / 15)


#print(f)
#print(b)
#print(fb)

fsum = int((f+1)*f/2)*3
bsum = int((b+1)*b/2)*5
fbsum = int((fb+1)*fb/2)*15

print(allsum - fsum - bsum + fbsum)

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

using namespace std;

typedef long long ll;

#define sz(x) ((int)(x).size())
#define in(x) int x;cin>>x
#define inn(x, y) int x,y;cin>>x>>y
#define innn(x, y, z) int x,y,z;cin>>x>>y>>z
#define bit(n) (1<<(n))

#define out(x) cout<<(x)<<endl;
#define outt(x,y) cout<<(x)<<" "<<(y)<<endl;
#define err(x) cerr<<(x)<<endl;
#define errr(x,y) cerr<<(x)<<" "<<(y)<<endl;
#define errrr(x,y,z) cerr<<(x)<<" "<<(y)<<" "<<(z)<<endl;

#define rep(i,n) for (int i=0;i<(n);i++)
#define repp(i,n) for (int i=1;i<=(n);i++)
#define reppp(j, i, n) for (int j=i+1; j<n; j++)

#define lim5 200010
#define lim9 1000000010

#define deg(rad) (((rad)/2/M_PI)*360)
#define mid(min, max) ((min + max) / 2)

int main() {
    in(k);
    inn(a, b);
    for(int i = a; i <= b; i++) {
        if (i % k == 0) {
            out("OK");
            return 0;
        }
    }
    out("NG");
    return 0;
}


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

int main(){
  int high,width;
  cin >> high >> width;
  vector<string> word(high);
  for(int i = 0; i < high; i++){
    cin >> word.at(i);
  }
  std::string str = std::string((width + 2), '#');
  cout << str << endl;
  for(int i = 0; i < high; i++){
    cout << '#';
    cout << word.at(i);
    cout << '#' << endl;
  }
  
  cout << str << endl;
}

Measured memory_bytes: 256
import heapq
# 単一始点最短経路。2地点間ではなく、始点が一つで各点へのコストを計算する
# eは隣接リストでe[v] = [(u1,cost1), (u2,cost2)]みたいな形を想定
# 辺の重みは正である必要がある
# O(ElogV)
def dijkstra(e,n,s):
    inf = 10**18
    d = [inf]*n
    d[s] = 0

    q = [(d[s],s)] # priority queueのソートキーが第一要素
    heapq.heapify([q])
    while len(q)>0:
        _,v = heapq.heappop(q)
        for u,c in e[v]:
            if d[v]+c>=d[u]:
                continue
            d[u] = d[v] + c
            heapq.heappush(q, (d[u],u))
    return d

n,x,y = map(int, input().split())

g = [[] for _ in range(n)]
for i in range(n-1):
    g[i].append((i+1,1))
    g[i+1].append((i,1))
g[x-1].append((y-1,1))
g[y-1].append((x-1,1))
    

res = [0]*n
for i in range(n):
    d = dijkstra(g,n,i)
    for j in range(i+1,n):
        res[d[j]] += 1

for i in range(1,n):
    print(res[i])


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

typedef long long ll;
const ll INF = 1e9, MOD = 1e9 + 7;
const double EPS = 1e-9, PI = 3.141592653589793;
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define REPR(i,a,b) for(ll i=b;i>=a;i--)
#define repr(i,n) REPR(i,0,n)
#define all(v) (v).begin(), (v).end()
#define pb push_back
#define fi first
#define se second
#define m_p make_pair

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

    ll n;
    cin >> n;
    vector<ll> a(5);
    rep(i,5) cin >> a[i];
    sort(all(a));
    cout << (n+a[0]-1) / a[0] + 4 << "\n";
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Competitive
{
    internal class Solution
    {
        public int N;
        public long MOD = 1000000007;

        public void Run()
        {
            N = Input.ReadInt();
            double ret = 0;

            for (int i = 0; i < N; i++)
            {
                var line = Console.ReadLine().Split(' ');
                double x = double.Parse(line[0]);
                string s = line[1];

                if (s == "JPY")
                {
                    ret += x;
                }
                else
                {
                    ret += x * 380000;
                }
            }

            Console.WriteLine(ret);

        }
    }

    // libs ----------
    

    // common ----------

    internal static class Input
    {
        public static string ReadString()
        {
            string line = Console.ReadLine();
            return line;
        }

        public static int ReadInt()
        {
            string line = Console.ReadLine();
            return int.Parse(line);
        }

        public static int[] ReadIntArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(int.Parse).ToArray();            
        }

        public static long ReadLong()
        {
            string line = Console.ReadLine();
            return long.Parse(line);
        }

        public static long[] ReadLongArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(long.Parse).ToArray();
        }

        public static double[] ReadDoubleArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(double.Parse).ToArray();
        }
    }
    
    internal class Program
    {
        public static void Main(string[] args)
        {
            var s = new Solution();
            s.Run();
        }
    }
}

Measured memory_bytes: 11092
n, k = map(int, input().split())
s = list(list(map(int, input().split())) for _ in range(2*k))

a = []
for i in range(1, k+1):
    a += s[2*i-1]
    
lis = [None]*n
for i in range(n):
    lis[i] = i+1

cnt = 0
for i in lis:
    if i not in a:
        cnt += 1
        
print(cnt)

Measured memory_bytes: 9140
#include "bits/stdc++.h"
using namespace std;
#define long int64_t

int main() {
	ios_base::sync_with_stdio( false );

	string n;
	for( int i = 0; i < 4; ++i ) {
		char c;
		cin >> c;
		n += c;
	}
	sort( n.begin(), n.end() );
	cout << (n == "1479" ? "YES" : "NO") << endl;

	return 0;
}


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

using namespace std;

int main(){
    long long n, h;
    cin >> h >> n;
    
    long long sol;
    
    for(int i = 0; i < n; ++i){
    	long long a;
    	cin >> a;
    	sol += a;
	}
	
	if(sol >= h)
	    cout << "Yes";
	else
	    cout << "No";
    

	return 0;
}



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

using namespace std;

typedef long long ll;
#define fi first
#define se second
#define pb push_back

int main() {
    set <int> st;
    int x, y;
    scanf("%d %d", &x, &y);
    st.insert(1);
    st.insert(2);
    st.insert(3);
    st.erase(x);
    st.erase(y);
    printf("%d\n", *st.begin());
    return 0;
}


Measured memory_bytes: 3760
def func():
    A, B, C = map(str, input().split())
    cand1 = int(A + B) + int(C)
    cand2 = int(B + C) + int(A)
    cand3 = int(A + C) + int(B)
    cand4 = int(B + A) + int(C)
    cand5 = int(C + B) + int(A)
    cand6 = int(C + A) + int(B)
    print(max(cand1, cand2, cand3, cand4, cand5, cand6))


if __name__ == '__main__':
    func()


Measured memory_bytes: 3064
#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma comment(linker, "/stack:200000000")

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;

#define X first
#define Y second

//#include <boost/unordered_map.hpp>
//using namespace boost;

/*
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> rbtree;
rbtree T;
*/

namespace io{
    const int L = (1 << 20) + 1;

    char buf[L], *S , *T, c;

    char getchar() {
        if(__builtin_expect(S == T, 0)) {
            T = (S = buf) + fread(buf, 1, L, stdin);
            return (S == T ? EOF : *S++);
        }
        return *S++;
    }

    int inp() {
        int x = 0, f = 1; char ch;
        for(ch = getchar(); !isdigit(ch); ch = getchar())
            if(ch == '-') f = -1;
        for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
        return x * f;
    }

    unsigned inpu()
    {
        unsigned x = 0; char ch;
        for(ch = getchar(); !isdigit(ch); ch = getchar());
        for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
        return x;
    }

    ll inp_ll() {
        ll x = 0; int f = 1; char ch;
        for(ch = getchar(); !isdigit(ch); ch = getchar())
            if(ch == '-') f = -1;
        for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
        return x * f;
    }

    char B[25], *outs=B+20, *outr=B+20;
    template<class T>
    inline void print(register T a,register char x=0){
        if(x) *--outs = x, x = 0;

        if(!a)*--outs = '0';
        else
            while(a)
                *--outs = (a % 10) + 48, a /= 10;

        if(x)
            *--outs = x;

        fwrite(outs, outr - outs , 1, stdout);
        outs = outr;
    }
};

using io :: print;
using io :: inp;
using io :: inpu;
using io :: inp_ll;

using i32 = int;
using i64 = long long;
using u8 = unsigned char;
using u32 = unsigned;
using u64 = unsigned long long;
using f64 = double;
using f80 = long double;

ll power(ll a, ll b, ll p)
{
    if (!b) return 1;
    ll t = power(a, b/2, p);
    t = t*t%p;
    if (b&1) t = t*a%p;
    return t;
}

ll exgcd(ll a, ll b, ll &x, ll &y)
{
    if (b == 0)
    {
        x = 1;
        y = 0;
        return a;
    }
    ll px, py;
    ll d = exgcd(b, a%b, px, py);
    x = py;
    y = px-a/b*py;
    return d;
}

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

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

const int MAXN = 100010;
const int MOD = 998244353;
const f80 MI = f80(1)/MOD;
const ll INF = 1000000000000000000;

int main()
{
    
    string s;
    cin >> s;
    puts(s <= "2019/04/30" ? "Heisei" : "TBD");

    return 0;
}


Measured memory_bytes: 256
s = input()
ls = len(s)
mod = 10**9+7

dp = [[0]*5 for _ in range(ls+1)]

dp[0][0] = 1

for i in range(ls):
    if s[i] == 'A':
        for j in range(4):
            dp[i+1][j] += dp[i][j] % mod
        dp[i+1][1] += dp[i][0] % mod
    elif s[i] == 'B':
        for j in range(4):
            dp[i+1][j] += dp[i][j] % mod
        dp[i+1][2] += dp[i][1] % mod
    elif s[i] == 'C':
        for j in range(4):
            dp[i+1][j] += dp[i][j] % mod
        dp[i+1][3] += dp[i][2] % mod
    else:
        for j in range(4):
            dp[i+1][j] += dp[i][j]*3 % mod
            dp[i+1][j+1] += dp[i][j]

print(dp[ls][3] % mod)

        
    

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

int main(){
    int a,b,c;
    cin >> a >> b >> c;
    set<int> mod;
    for(int i=1;;i++){
        if(mod.find((a*i)%b) != mod.end())break;
        mod.insert((a*i)%b);
    }
    if(mod.find(c)!=mod.end())cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
    
}


Measured memory_bytes: 256
a,b,c,d=map(int,input().split())
if a%d>0:
   a=a//d+1
elif a%d==0:
   a=a//d
if c%b>0:
  c=c//b+1
elif c%b==0:
  c=c//b
if a>=c:
  print("Yes")
else:
  print("No")
  
  


Measured memory_bytes: 9040
#include<stdio.h>
int main(void)
{
	int a,b;
	scanf("%d",&a);
	scanf("%d",&b);

	
	if(a==b){printf("a == b\n");}
	else if(a<b){printf("a < b\n");}
	else{printf("a > b\n");}
	
	return(0);
}

Measured memory_bytes: 580
MOD = 10**9 + 7
def comb(n, k, MOD):
    if n < k or n < 0 or k < 0:
        return 0
    if k == 0:
        return 1
    iinv = [1] * (k + 1)
    ans = n
    for i in range(2, k + 1):
        iinv[i] = MOD - iinv[MOD % i] * (MOD // i) % MOD
        ans *= (n + 1 - i) * iinv[i] % MOD
        ans %= MOD
    return ans
n, a, b = map(int, input().split())
print((pow(2,n,MOD)-1-comb(n,a,MOD)-comb(n,b,MOD)+MOD*10)%MOD)

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

using namespace std;

typedef long long ll;
typedef vector<ll> vl;
typedef long double ld;
typedef vector<ld> vd;
typedef bool bl;
typedef vector<bl> vb;
typedef vector<vl> mt;
typedef unordered_map<ll,unordered_map<ll,ll>> graph;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
typedef vector<string> vs;
typedef vector<vs> table;


const ll e5 = 1 << 20;
const ll mod = 1000000007;
const ll e3 = 1 << 13;
const ll INF = 1ll << 50;

ll n,d;

int main(){
  cin >> n >> d;
  cout << (n-1)/(1+d+d)+1 << endl;

}


Measured memory_bytes: 256
#include<cstdio>
#include<vector>
#include<algorithm>
#include<functional>
using namespace std;
int main()
{
	int a[100],N,M,i,j,k,s,h;
	while(scanf("%d%d",&M,&N),N)
	{
		vector<int>v;
		for(i=0;i<N;++i)scanf("%d",&a[i]);
		for(i=0;i<N;++i)
			for(j=0;j+i<N;v.push_back(s),++j)
				for(s=k=0;k<=i;++k)
					s+=a[j+k];
		sort(v.begin(),v.end(),greater<int>());
		v.erase(unique(v.begin(),v.end()),v.end());
		s=*max_element(a,a+N);
		for(i=v.size()-1;;--i)if(v[i]>=s)break;
		v.erase(v.begin()+i+1,v.end());
		for(i=v.size()-1;;--i)
		{
			for(h=s=j=0;j<N;++j)
			{
				if(s+a[j]>v[i])
				{
					s=a[j];++h;
					if(h>=M)goto E;
				}
				else s+=a[j];
			}
			printf("%d\n",v[i]);
			goto N;
E:;
		}
N:;
	}
	return 0;
}

Measured memory_bytes: 0
"use strict";
var input=require("fs").readFileSync("/dev/stdin","utf8");
var cin=input.split(/ |\n/),cid=0;
function next(){return +cin[cid++];}
function nextstr(){return cin[cid++];}
function nextbig(){return BigInt(cin[cid++]);}
function nexts(n,a){return a?cin.slice(cid,cid+=n):cin.slice(cid,cid+=n).map(a=>+a);}
function nextm(h,w,a){var r=[],i=0;if(a)for(;i<h;i++)r.push(cin.slice(cid,cid+=w));else for(;i<h;i++)r.push(cin.slice(cid,cid+=w).map(a=>+a));return r;}
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill().map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill().map(x=>"+r+")";return eval(r);}

var myOut = main();
if(myOut !== undefined)console.log(String(myOut));

function main(){
  var x = nextbig(), y = nextbig();
  if(x-y < 2 && y-x < 2)return "Brown";
  return "Alice";
}

Measured memory_bytes: 29420
/* ---------- STL Libraries ---------- */
// IO library
#include <cstdio>

#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>

#include <cmath>
#include <numeric>
#include <random>
#include <cstring>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>
#include <stack>

// type
#include <cstdint>

/* ---------- Namespace ---------- */
using namespace std;

/* ---------- Type ---------- */
using ll = long long;
#define int ll
#define P pair<ll, ll>

/* ---------- Constants  */
const double PI = 3.141592653589793238462643383279;
const ll MOD = 1e9 + 7;
const int INF = 1LL << 55;

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */
signed main() {
    int N;
    string S;
    cin >> N >> S;

    int ret = 0;
    char before = '*';
    for (int i = 0; i < N; i++) {
        if (S[i] != before) {
            ++ret;
            before = S[i];
        }
    }
    cout << ret << endl;
    return 0;
}

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

ANS = [0] * (n+1)
for x in range(1, 101):
    for y in range(1, 101):
        for z in range(1, 101):
            tmp = (x + y + z)**2 - z*(x + y) - (x*y)
            if tmp > n: continue
            ANS[tmp] += 1

for ans in ANS[1:]:
    print(ans)

Measured memory_bytes: 74888
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include <map>
#include <cmath>
#include <string>
using namespace std;

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

const ll INF = 1000000007;

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; } ll lcm(ll c, ll d) { return c / gcd(c, d) * d; } 

int main() {
  int n, m;
  cin >> n >> m;
  vector<ull> dp(n+2, 1);
  vector<ull> broken(m, INF);
  rep(j, m) {
    cin >> broken.at(j);
    dp.at(broken.at(j)) = 0;
  }

  ull ans = 1;
  for (ll i = n; i >= 0; i--)
  {
      if (i < n-1 && dp[i] != 0)
      {
          /* code */
          dp[i] = (dp[i+1] + dp[i+2])%INF; 
          ans = dp[i];
      }
    //   cout << i << " " << ans << endl;
  }
  
  cout << ans%INF << endl;
}

Measured memory_bytes: 1792
N = gets.chomp!.to_i
P = gets.chomp!.split.map(&:to_i)
Q = gets.chomp!.split.map(&:to_i)
a = 0
b = 0

arr = (1..N).to_a.permutation.to_a
arr.each_with_index do |ar, i|
  a = i if ar == P
  b = i if ar == Q
end
puts (a - b).abs

Measured memory_bytes: 8828
import sys

class Node:
    __slots__ = ['key', 'left', 'right']
    def __init__(self, key):
        self.key = key
        self.left = self.right = None

root = None

def insert(key):
    global root
    x, y = root, None
    while x != None: x, y = x.left if key < x.key else x.right, x
    if y == None: root = Node(key)
    elif key < y.key: y.left = Node(key)
    else: y.right = Node(key)

def find(target):
    result = root
    while result and target != result.key:
        result = result.left if target < result.key else result.right
    return result == None

def inorder(node):
    return inorder(node.left) + f' {node.key}' + inorder(node.right) if node else ''
def preorder(node):
    return f' {node.key}' + preorder(node.left) + preorder(node.right) if node else ''

input()
for e in sys.stdin:
    if e[0] == 'i': insert(int(e[7:]))
    elif e[0] == 'f': print(['yes','no'][find(int(e[5:]))])
    else: print(inorder(root)); print(preorder(root))


Measured memory_bytes: 55684
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
	int n;
	cin>>n;
	vector<ll>a(n);
	for(int i=0;i<n;i++)
	cin>>a[i];
	if(n<=2)
	{
		cout<<"0\n";
		return 0;
	}
	int ans=0;
	for(int i=0;i<n;i++)
	{
		for(int j=i+1;j<n;j++)
		{
			for(int k=j+1;k<n;k++)
			{
				if(a[i]!=a[j] && a[i]!=a[k] && a[j]!=a[k])
				{
					ll s1=a[i]+a[j];
					ll s2=a[i]+a[k];
					ll s3=a[j]+a[k];
					
					if(s1>a[k] && s2>a[j] && s3>a[i])
					{
						ans+=1;
						//cout<<i+1<<" "<<j+1<<" "<<k+1<<endl;
					}
				}
			}
		}
	}
	cout<<ans<<endl;
		
	
}


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

int main() {
  int N;
  cin >> N;
  vector<int> V(N), C(N);
  for (int i = 0; i < N; i++)
  {
    cin >> V[i];
  }
  for (int i = 0; i < N; i++)
  {
    cin >> C[i];
  }
  
  int ans = 0;
  for (int bit = 0; bit < (1 << N); bit++)
  {
    int X = 0, Y = 0;
    for (int i = 0; i < N; i++)
    {
      if (bit & (1 << i)) {
        X += V[i];
        Y += C[i];
      }
    }
    ans = max(ans, X - Y);
  }
  cout << ans << endl;
  return 0;
}


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

using namespace std;
#define int long long

signed main(){	
	int s1=0,s2=0,s3=0,s4=0;
	int T;cin>>T;
	while(T--){
		string str;
		cin>>str;
		if(str=="AC") s1++;
		else if(str=="WA") s2++;
		else if(str=="TLE") s3++;
		else s4++;
 	}
 	cout<<"AC x "<<s1<<'\n';
 	cout<<"WA x "<<s2<<'\n';
 	cout<<"TLE x "<<s3<<'\n';
 	cout<<"RE x "<<s4<<'\n';
	return 0;
}

Measured memory_bytes: 3608
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdint>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
// clang-format off
using i64 = int64_t;
using i32 = int32_t;
#define all(x) x.begin(), x.end()
#define int i64
template <class T, typename U> constexpr inline bool exist(const T &s, const U &e) { return s.find(e) != s.end(); }
template <class T> constexpr inline i32 SZ(const T &x) { return x.size(); }
template <class T> constexpr inline bool rmn(T &a, T b) { return a > b ? (a = b, true) : false; }
template <class T> constexpr inline bool rmx(T &a, T b) { return a < b ? (a = b, true) : false; }
const char el = '\n'; const i32 MOD = 1e9 + 7, INF = 0x3f3f3f3f; const i64 INFLL = ((i64)INF << 32) | INF;

#ifdef LOCAL // debugging swiss knife
template <typename Ostream, typename Cont> enable_if_t<is_same<Ostream, ostream>::value, Ostream &> operator<<(Ostream &os, const Cont &v) { os << "{"; for (const auto &x : v) os << x << ", "; return os << "}"; }
template <typename Ostream, typename... Ts> Ostream &operator<<(Ostream &os, const pair<Ts...> &p) { return os << "(" << p.first << ", " << p.second << ")"; }
template <class... Args> void dbg_out(Args... args) { ((std::cerr << "\033[32m" << args << "\033[37m, "), ...); }
#define dbg(...) cerr << "\033[1;31m" << __LINE__ << ": [" << #__VA_ARGS__ << "]\033[37m  = ", dbg_out(__VA_ARGS__), cerr << "\033[0m" << endl;
#else
#define dbg(...) ;
#endif
// clang-format on
////////////////////////////////// TEMPLATE ENDS /////////////////////////////////
vector<vector<i32>> adj;
vector<i32> vis, color;

int32_t main() {
    ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
    cout << fixed << setprecision(13), cerr << fixed << setprecision(3);

    int n;
    cin >> n;
    int ans = n * (n + 1) / 2;
    for (i64 i = 1; i < n; ++i) {
        ans += i * (i + 1) / 2;
        int l, r;
        cin >> l >> r;
        if (l > r) swap(l, r);
        ans -= l * (n + 1 - r);
    }
    cout << ans << el;

    return 0;
}

Measured memory_bytes: 3640
import sys
S=input()
T=input()
sl=len(S)
tl=len(T)
init=(['z']*sl)
init=''.join(init)
ans=init
for i in range(sl-tl+1):
    st=S[i:i+tl]
    flag=False
    for j in range(tl):
        if st[j]==T[j] or st[j]=='?':
            flag=True
        else:
            flag=False
            break
    if flag:
        anst=list(S)
        anst[i:i+tl]=T[:]
        anst=''.join(anst)
        anst=anst.replace('?','a')
        if anst<ans:
            ans=anst
if ans == init:
    print('UNRESTORABLE')
else:   
    print(ans)
        
                 

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;

#define INF (1<<28)

vector<int> v;

int memo[100001];
int solve(int now) {
  if (now == 0)
    return memo[now] = 0;
  if (now < 0)
    return INF;
  if (memo[now] != 0)
    return memo[now];
  int ret = INF;
  for (int i = 0; i < v.size(); i++)
    ret = min(ret, solve(now - v[i]) + 1);
  return memo[now] = ret;
}

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

  v.push_back(pow(6, 6));
  for (int i = 5; i >= 1; i--) {
    v.push_back(pow(9, i));
    v.push_back(pow(6, i));
  }
  v.push_back(1);

  cout << solve(n) << endl;
}


Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <utility>
#include <cmath>
#include <map>
#include <set>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
using namespace std;

#define INF_LL (ll)1e18
#define INF (int)1e9
#define REP(i, n) for(int i = 0;i < (n);i++)
#define FOR(i, a, b) for(int i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
using ll = long long;
using PII = pair<int, int>;

#define fs first
#define sc second

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

int N, M;
vector<PII> G[114514], rG[114514];
vector<int> ord;
int visited[114514] = {};

int visit(int v){
	if(visited[v] == 1)
		return -1;
	else if(visited[v] == 0){
		visited[v] = 1;
		REP(i, G[v].size()){
			visit(G[v][i].sc);
		}
		visited[v] = 2;
		ord.push_back(v);
	}
	return 0;
}

ll d[114514] = {};

int dfs(int v){
	int ret = 0;
	REP(i, G[v].size()){
		if(visited[G[v][i].sc]){
			if(d[G[v][i].sc] != d[v]+G[v][i].fs)
				return 1;
		}else{
			visited[G[v][i].sc] = 1;
			d[G[v][i].sc] = d[v]+G[v][i].fs;
			ret = ret | dfs(G[v][i].sc);
		}
	}
	REP(i, rG[v].size()){
		if(visited[rG[v][i].sc]){
			if(d[rG[v][i].sc] != d[v]+rG[v][i].fs)
				return 1;
		}else{
			visited[rG[v][i].sc] = 1;
			d[rG[v][i].sc] = d[v]+rG[v][i].fs;
			ret = ret | dfs(rG[v][i].sc);
		}
	}
	return ret;
}

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> N >> M;
	REP(i, M){
		int u, v, d;
		cin >> u >> v >> d; u--; v--;
		G[u].push_back({d, v});
		rG[v].push_back({-d, u});
	}
	REP(i, N){
		if(!visited[i]){
			if(visit(i) == -1){
				cout << "No" << endl;
				return 0;
			}
		}
	}
	fill(d, d+114514, -1);
	fill(visited, visited+114514, 0);
	REP(i, N){
		if(!visited[i]){
			visited[i] = 1;
			d[i] = 0;
			if(dfs(i)){
				cout << "No" << endl;
				return 0;
			}
		}
	}
	cout << "Yes" << endl;
	return 0;
}


Measured memory_bytes: 18300
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader input =new BufferedReader (new InputStreamReader (System.in));
		String str = input.readLine( );
		int x = str.indexOf("A");
		int y = str.lastIndexOf("Z");

		System.out.println(y-x+1);

	}

}


Measured memory_bytes: 11600
/**Bismillahir Rahmanir Rahim.**/

/**
 *    author:  nasimnoob
**/

#include<bits/stdc++.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<math.h>
using namespace std;

//----------------------------------------------------------//

typedef long long int                        ll;
typedef unsigned long long int              ull;
typedef long double                          ld;

//-----------------------------------------------------------//
#define      test                       int t; cin>>t;  while(t--)

#define      cube(x)                    (x*x*x)
#define      sqr(x)                     (x*x)

#define      sc1(x)                     scanf("%lld",&x);
#define      sc2(x,y)                   scanf("%lld %lld", &x, &y)
#define      scf1(x)                    scanf("%lf",&x)
#define      scf2(x,y)                  scanf("%lf %lf", &x, &y)

#define      srev                       reverse(s.begin(),s.end())
#define      sortstr                    sort(s.begin(), s.end());
#define      gtl(x)                     getline(cin, (x))

#define      PI                         acos(-1) // 3.1415926535897932
#define      MIN                        9999999

#define      Faster                     ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

//scanf("%[^\n]%*c", str);
//sort(s,s+n,greater<int>());

//-----------------------------------------------------------//

int main()
{
    Faster;
    char s;
    cin >> s;
    if(s >= 'A' && s <= 'Z')
        cout << "A" << endl;
    else if (s >= 'a' && s <= 'z')
        cout << "a" << endl;
    return 0;
}






Measured memory_bytes: 3644
//
// Created by yuu on 2019-04-17.
//

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <utility>
#include <math.h>
#include <stack>
#include <queue>

using namespace std;


int main(void){
    int H,W;
    int h,w;

    cin>>H>>W;
    cin>>h>>w;

    cout<<(H-h)*(W-w)<<endl;
    

    return 0;
}

Measured memory_bytes: 256
n=int(input())
a=[int(i)//400 for i in input().split()]

cnt=0
q=set()
for num in a:
    if num>=8:
        cnt+=1
    else:
        q.add(num)
        
ans=len(q)
if ans==0:
    print(1,cnt)
else:
    print(ans,ans+cnt)
      

Measured memory_bytes: 3060
program fairness
  implicit none
  integer(8) :: a,b,c,k,i, a1,b1,c1
  read(*,*) a,b,c,k

  if (abs(a-b)>=1.0d+18) then
     write(*,*) 'Unfair'
     stop
  end if
  if (mod(k,2)==0) then
     write(*,*) a-b
  else
     write(*,*) b-a
  end if
  stop
end program fairness


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

#define for_(i,a,b) for(int i=(a);i<(b);++i)
#define for_rev(i,a,b) for(int i=(a);i>=(b);--i)
#define allof(a) (a).begin(),(a).end()
#define size_of(a) (int)(a).size()
#define minit(a,b) memset(a,b,sizeof(a))

int N, M, L, P[110], T[110], V[110];
double RP[110][55], RT[110][55];

int main() {
	cin >> N >> M >> L;
	for_(i,0,N) cin >> P[i] >> T[i] >> V[i];
	
	minit(RP, 0);
		
	for_(i,0,N) {
		RT[i][0] = V[i] > 0 ? (double)L / (double)V[i] : 1e9;
		for_(j,0,M) RT[i][j + 1] = RT[i][j] + (double)T[i];
	}
	
	for_(i,0,N) {
		vector< double > p(M+1, 1.0), pm(M+1, 1.0);
		
		for_(k,0,M) {
			p[k + 1] = p[k] * (double)P[i] / 100.0;
			pm[k + 1] = pm[k] * (1.0 - (double)P[i] / 100.0);
		}
		
		long long mCk = 1;
		
		for_(k,0,M + 1) {
			RP[i][k] =  (double)mCk * p[k] * pm[M - k];
			mCk *= (M - k);
			mCk /= k + 1;
		}
		
		for_rev(k,M,1) RP[i][k-1] += RP[i][k];
	}
		
	for_(i,0,N) {
		if (V[i] == 0) {
			cout << "0.000000000" << endl;
			continue;
		}
		
		double ans = 0.0;
		
		for_(k,0,M+1) {
			double t = RT[i][k];
			double p = RP[i][k] - RP[i][k + 1];
						
			for_(ii,0,N) {
				if (ii == i || V[ii] == 0) continue;
				int id = upper_bound(RT[ii], RT[ii] + M + 1, t) - RT[ii];
				p *= RP[ii][id];
			}
			
			ans += p;
		}
		
		cout << setprecision(9) << setiosflags(ios::fixed) << ans << endl;
	}
}

Measured memory_bytes: 1372
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a,b,c,k;
  cin >> a >> b >> c;
  cin >> k;
  for(int i=0;i<k;i++){
    if(a>b &&a>c){
      a *= 2;
    }else if(b>c && b>a){
      b *= 2;
    }else{
      c *= 2;
    }
  }
  cout << a+b+c << endl;
}




Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#include <bits/stdc++.h>
using namespace std;
 
const double TL = 1.5 * CLOCKS_PER_SEC;
mt19937 rng((unsigned int) chrono::steady_clock::now().time_since_epoch().count());
#define clr(x, y) memset(x, y, sizeof(x))
#define forn(i, n) for (int i = 0; i < n; i++)
#define LL long long
const double pi = acos(-1.0);


LL n, a, b, c, d;
map<LL, LL> mp;

LL dis(LL x, LL y) {
  LL dif = abs(x - y);
  if (dif > 1e16 / d) return 1e16;
  return dif * d;
}

LL dfs(LL x) {
  if (x == 0) {
    return 0;
  }
  if (x == 1) {
    return d;
  }
  if (mp.find(x) != mp.end()) {
    return mp[x];
  }
  //cout << x << endl;


  LL ans = 1e16;
  LL y = x % 2;
  LL z = (x - y) / 2;
  ans = min(ans, dfs(z) + min(d * y + a, dis(z, x)));
  if (y != 0) {
    z += 1;
    ans = min(ans, dfs(z) + min(d * (2 - y) + a, dis(z, x)));
  }


  y = x % 3;
  z = (x - y) / 3;
  ans = min(ans, dfs(z) + min(d * y + b, dis(z, x)));
  if (y != 0) {
    z += 1;
    ans = min(ans, dfs(z) + min(d * (3 - y) + b, dis(z, x)));
  }

  y = x % 5;
  z = (x - y) / 5;
  ans = min(ans, dfs(z) + min(d * y + c, dis(z, x)));
  if (y != 0) {
    z += 1;
    ans = min(ans, dfs(z) + min(d * (5 - y) + c, dis(z, x)));
  }

  mp[x] = ans;
  return ans;
}

LL dfs1(LL x) {
  multimap<LL, LL> p;
  map<LL, LL> vis;

  p.insert({0, 0});
  while(p.size() > 0) {
    auto iter = p.begin();
    LL w = iter->first;
    LL u = iter->second;
    p.erase(iter);
    if (vis.find(u) != vis.end()) {
      continue;
    }
    vis[u] = w;
    //cout << u << " " << w << endl;
    if (u == x) return w;

    LL v = u * 2;
    if (v < n + 10000 && vis.find(v) == vis.end()) {
      p.insert({w + a, v});
    }
    v = u * 3;
    if (v < n + 10000 && vis.find(v) == vis.end()) {
      p.insert({w + b, v});
    }
    v = u * 5;
    if (v < n + 10000 && vis.find(v) == vis.end()) {
      p.insert({w + c, v});
    }
    v = u + 1;
    if (v < n + 10000 && vis.find(v) == vis.end()) {
      p.insert({w + d, v});
    }
    v = u - 1;
    if (v > 0 && vis.find(v) == vis.end()) {
      p.insert({w + d, v});
    }
  }
  return -1;
}

int main() {
#ifdef LOCAL
  auto start_clock = clock();
  freopen("in", "r", stdin);
#endif
  int T;
  scanf("%d", &T);
  while (T--) {
    mp.clear();
    //n = rng() % 100000 + 1;
    //a = rng() % 100 + 1 ;
    //b = rng() % 100 + 1;
    //c = rng() % 100 + 1;
    //d = rng() % 100 + 1;
    //LL r0 = dfs(n);
    //LL r1 = dfs1(n);
    ////cout << r0 << " " << r1 << endl;
    //if (r0 != r1) {
    //  cout << n << " " << a << " " << b << " " << c << " " << d << endl;
    //}
    cin >> n >> a >> b >> c >> d;
    cout << dfs(n) << endl;
  }

#ifdef LOCAL
 auto end_clock = clock();
 cout << "Time:" << (end_clock - start_clock) / CLOCKS_PER_SEC << endl;
#endif
  return 0;
}

Measured memory_bytes: 4436
#include <bits/stdc++.h>
#include<stdio.h>
using namespace std;
#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) begin(a),end(a)
#define MS(m,v) memset(m,v,sizeof(m))
#define D10  fixed<<setprecision(10)
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> P;
typedef long long ll;
const ll INF = 114514810;
const ll MOD = 1000000007;
const double EPS = 1e-8;
const double PI = acos(-1.0);
struct edge
{
	int from, to, cost;
	bool operator < (const edge& e) const { return cost < e.cost; }
	bool operator >(const edge& e) const { return cost > e.cost; }
};
//int dx[] = { -1, 0, 0, 1 }; int dy[] = { 0, -1, 1, 0 };
bool valid(int x, int y, int h, int w) { return (x >= 0 && y >= 0 && x < h&&y < w); }
///*************************************************************************************///
///*************************************************************************************///
///*************************************************************************************///


int main()
{
	int n;
	cin >> n;
	while (n--)
	{
		int l = 0, r = 0;
		bool f = true;
		REP(i, 10)
		{
			int t;
			cin >> t;
			if (t > l) l = t;
			else if (t > r) r = t;
			else f = false;
		}
		puts(f ? "YES" : "NO");
	}
}

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

int main() {
  int N;
  cin >> N;
  
  int a = N / 100;
  int b = (N - a * 100) / 10;
  int c = N % 10;
  
  if (a == 7 || b == 7 || c == 7){
  cout << "Yes" << endl;
  }
  
  else{
  cout << "No" << endl;
  }
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
    set<char>s;
    int n;
    cin>>n;
    while(n--){
        char x;
        cin>>x;
        s.insert(x);
    }
    if(s.size()==3)
        cout<<"Three"<<endl;
    else
        cout<<"Four"<<endl;

    return 0;
}


Measured memory_bytes: 3620
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <iomanip>
using namespace std;
#define int long long


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

    int n; cin >> n;
    vector<int> a(n);

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

    for(int i = 0;i < n;i ++) cin >> a.at(i);

    int ans = 1;

    int hantei;
    if(a.at(1) - a.at(0) > 0) hantei = 2;
    else if(a.at(1) - a.at(0) == 0) hantei = 1;
    else hantei = 0;

    for(int i = 1;i < n-1;i ++){
        if(a.at(i) - a.at(i-1) > 0) hantei = 2;
        else if(a.at(i)- a.at(i-1) < 0)hantei = 0;

        if(hantei == 2 && a.at(i+1) - a.at(i) < 0){
            ans ++;
            i ++;
            hantei = 1;
        }
        else if(hantei == 0 && a.at(i+1) - a.at(i) > 0){
            ans ++;
            i ++;
            hantei = 1;
        }
        else if(hantei == 1){
            if(a.at(i+1) - a.at(i) > 0) hantei = 2;
            if(a.at(i+1) - a.at(i) < 0) hantei = 0;
        }
    }

    cout << ans << endl;
}



Measured memory_bytes: 1024