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

const int64_t MOD = 1000000007;
typedef long long ll;
typedef unsigned long long ull;

#define FOR(i, start, end) for(uint64_t i=start; i<end; i++)
#define REP(i, n) FOR(i, 0, n)

// 最大公約数gcd
// 最小公倍数lcm=m*n/gcd
uint64_t gcd(uint64_t m, uint64_t n) {
  uint64_t temp;
  while (m % n != 0){
    temp = n;
    n = m % n;
    m = temp;
  }
  return n;
}

uint64_t lcm(uint64_t m, uint64_t n) {
  return (m*n)/gcd(m,n);
}

// vector<vector<uint64_t> > v(n+1, vector<uint64_t>(n+1, 0))
// v[n][k]に組み合わせ数が入る。
void comb(vector<vector <uint64_t> > &v){
  for(uint64_t i = 0;i <v.size(); i++){
    v[i][0]=1;
    v[i][i]=1;
  }
  for(uint64_t k = 1;k <v.size();k++){
    for(uint64_t j = 1;j<k;j++){
      v[k][j]=(v[k-1][j-1]+v[k-1][j]);
    }
  }
}

// 掛け算オーバーフロー判定
bool is_product_overflow(uint64_t a, uint64_t b) {

	uint64_t prod = a * b;
	
	return (prod / b != a);
}

//素因数分解
void primeFactorization(uint64_t a, list<uint64_t> &factors){ //素因数分解を出力するプログラム
  long i,sq;
  if(a%2==0){ //偶数の場合
    factors.push_back(2);
    primeFactorization(a/2,factors); //2で割った値で再帰
    return;
  }
  sq = sqrt(a);
  for(i=3;i<=sq;i+=2){ //3以上√a以下の奇数の場合
	if(a%i==0){
	  factors.push_back(i);
      primeFactorization(a/i,factors); //割れた値で再帰
      return;
	}
  }
  //偶数でも3以上√a以下の奇数の場合でも割り切れない場合
  if(a!=1){ //aが1でないなら、a自身は素数
    factors.push_back(a);
  }
}

// フェルマーの小定理
// mod. m での a の逆元 a^{-1} を計算する
// (a/b)%m = a*movinv(b,m)%m  
int64_t modinv(int64_t a, int64_t m) {
    int64_t b = m, u = 1, v = 0;
    while (b) {
        int64_t t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

// 円周率
// M_PI

// #include <iomanip> // setprecisionを使用するのに必要
// cout << std::fixed << std::setprecision(15) << y << endl;

// 昇順
// priority_queue<int, vector<int>, greater<int> > queue;

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

  int count = 0;
  int maxCount = 0;
  for(auto c:s){
    if('R'==c){
      count++;
      maxCount = max(maxCount,count);
    }
    else{
      count = 0;
    }
  }

  cout << maxCount << endl;
  return 0;
}



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

const int size = 1000001;
bool a[size];
int n;

void eratos(){
	if(size>=1)
		a[0] = false;
	if(size>=2)
		a[1] = false;
	for(int i=2; i<size; i++)
		a[i] = true;
	for(int i=2; i*i<size; i++)
		if(a[i])
			for(int j=i*i; j<size; j+=i)
				a[j] = false;
}

int main(){
	eratos();
	while(true){
		cin >> n;
		if(!n)
			return 0;
		int ans = 0;
		for(int i=3; i<=n/2; i+=2){
			if(!a[i])
				continue;
			if(a[n-i])
				ans++;
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 0
int main (void){
 int a = 0;
 int b = 0;
 int c = 0;
 int d = 0;
 scanf("%d %d %d",&a , &b , &c);
 if (b<a){
  d = a;
  a = b;
  b = d;
 }
 if(c<b){
  d = b;
  b = c;
  c = d;
 }
 if (b<a){
  d = a;
  a = b;
  b = d;
 }
 printf("%d %d %d\n",a,b,c);
 return 0;
}

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

int a[50], b[50], c[50], d[50];
int p[10];
int n, m, q;

int dfs(int pos, int k) {
  if(pos == n) {
    int r = 0;
    rep(i,q) {
      if(p[b[i]]-p[a[i]] == c[i]) r += d[i];
    }
    return r;
  }
  int ans = 0;
  for(int i = k; i <= m; i++) {
    p[pos] = i;
    ans = max(ans,dfs(pos+1,i));
  }
  return ans;
}

int main(){
  cin >> n >> m >> q;
  rep(i,q) {
    cin >> a[i] >> b[i] >> c[i] >> d[i];
    a[i]--; b[i]--;
  }
  cout << dfs(0,1) << endl;
  return 0;
}


Measured memory_bytes: 3636
#include <stdio.h>
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const int N = 3e5 + 7;
int32_t main(){
    IOS;
    int d,t,s; 
    cin>>d>>t>>s;
    int p = d/s;
    if(p<t) cout << "Yes" << endl;
    else if(p == t && d%s==0) cout << "Yes" << endl;
    else cout <<"No" << endl;
     
    return 0;
}



Measured memory_bytes: 3688
S = input()
def kaibun(st):
    stre = st[::-1]
    if st == stre:
        return 1
    else:
        return 0

if kaibun(S[0:(len(S)-1) // 2]) and kaibun(S) and kaibun(S[(len(S)+3) // 2-1:len(S)]):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 38256
#include<bits/stdc++.h>
using namespace std;
#define INFTY 1<<20
typedef long long int ll;
const int MOD=1000000007;

int main(){
   int n,r,ans;
   cin>>n>>r;
   if(n>10) ans = r;
   else {
       ans = r+100*(10-n);
   }
   cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
/* template.cpp [[[ */
#include <bits/stdc++.h>
using namespace std;
#define get_macro(a, b, c, d, name, ...) name
#define rep(...) get_macro(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
#define rrep(...) get_macro(__VA_ARGS__, rrep4, rrep3, rrep2, rrep1)(__VA_ARGS__)
#define rep1(n) rep2(i_, n)
#define rep2(i, n) rep3(i, 0, n)
#define rep3(i, a, b) rep4(i, a, b, 1)
#define rep4(i, a, b, s) for (ll i = (a); i < (ll)(b); i += (ll)s)
#define rrep1(n) rrep2(i_, n)
#define rrep2(i, n) rrep3(i, 0, n)
#define rrep3(i, a, b) rrep4(i, a, b, 1)
#define rrep4(i, a, b, s) for (ll i = (ll)(b) - 1; i >= (ll)(a); i -= (ll)s)
#define each(x, c) for (auto &&x : c)
#define fs first
#define sc second
#define all(c) begin(c), end(c)
using ui = unsigned;
using ll = long long;
using ul = unsigned long long;
using ld = long double;
const int inf = 1e9 + 10;
const ll inf_ll = 1e18 + 10;
const ll mod = 1e9 + 7;
const ll mod9 = 1e9 + 9;
const int dx[]{-1, 0, 1, 0, -1, 1, 1, -1};
const int dy[]{0, -1, 0, 1, -1, -1, 1, 1};
template<class T, class U> void chmin(T &x, const U &y){ x = min<T>(x, y); }
template<class T, class U> void chmax(T &x, const U &y){ x = max<T>(x, y); }
struct prepare_ { prepare_(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(12); } } prepare__;
ll in(){ ll x; cin >> x; return x; }
vector<ll> in(size_t n){ vector<ll> v(n); each(x, v) cin >> x; return v; }
/* ]]] */

int n, d;
int a[1000];

int main(){
  cin >> n >> d;
  rep(i, n) cin >> a[i];
  int s = 0;
  rep(i, n) s += max(0, a[i] - d);
  if (s <= 0) cout << "kusoge\n";
  else cout << s << endl;
}

Measured memory_bytes: 3228
#!usr/bin/env python3
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop
from itertools import permutations
import sys
import math
import bisect


def LI(): return [int(x) for x in sys.stdin.readline().split()]


def I(): return int(sys.stdin.readline())


def LS(): return [list(x) for x in sys.stdin.readline().split()]


def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res


def IR(n):
    return [I() for i in range(n)]


def LIR(n):
    return [LI() for i in range(n)]


def SR(n):
    return [S() for i in range(n)]


def LSR(n):
    return [LS() for i in range(n)]


sys.setrecursionlimit(1000000)
mod = 1000000007


def solve():
    a, b, c = LI()
    k = I()
    for i in range(k):
        if a >= b:
            b *= 2
        elif b >= c:
            c *= 2
    if a < b < c:
        print('Yes')
    else:
        print('No')
    return


# Solve
if __name__ == "__main__":
    solve()


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

template<class T> void vin(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
}

int main() {
    int N;
    cin >> N;
    vector<int> W(N);
    rep(i, N) cin >> W[i];
    int s1 = 0, s2 = 0;
    rep(i, N) s2 += W[i];
    int ans = s2;
    rep(i, N) {
        s1 += W[i];
        s2 -= W[i];
        ans = min(ans, abs(s1- s2));
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <map>

using namespace std;
#define int long long
map <int,int> Num;
int q,a[100010],n;
signed main(){
    scanf("%lld",&n);
    int sum=0;
    for(int i=0;i<n;i++){
        scanf("%lld",&a[i]);
        sum+=a[i];
        Num[a[i]]++;
    }
    scanf("%lld",&q);
    while(q--){
        int c,d;
        scanf("%lld%lld",&c,&d);
        if(Num[c]>0){
            sum=sum+(Num[c]*(d-c));
            Num[d]+=Num[c];
            Num[c]=0;
        }
        printf("%lld\n",sum);
    }
    return 0;
}

Measured memory_bytes: 9712
taka_hp, taka_atk, aoki_hp, aoki_atk = [int(x) for x in input().split()]
a = False
while a == False:
    aoki_hp -= taka_atk
    if aoki_hp <= 0:
        a = True
        print('Yes')
        break
    taka_hp -= aoki_atk
    if taka_hp <= 0:
        a = True
        print('No')
        break

Measured memory_bytes: 9152
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <sstream>
#include <utility>
#define ll long long int
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()

using namespace std;
int main(){
	int H,W;
	cin >> H >> W;
	char S[H][W];
	rep(i,0,H){
		cin >> S[i];
	}
	int L[H][W] = {},R[H][W] = {},D[H][W] = {},U[H][W] = {};
	rep(i,0,H){
		rep(j,0,W){
			if(S[i][j] == '.'){
				if(j == 0){
					L[i][j] = 1;
				}else{
					L[i][j] = 1 + L[i][j-1];
				}
				if(i == 0){
					U[i][j] = 1;
				}else{
					U[i][j] = 1 + U[i-1][j];
				}
			}
		}
	}

	rel(i,H,0){
		rel(j,W,0){
			if(S[i][j] == '.'){
				if(j == W-1){
					R[i][j] = 1;
				}else{
					R[i][j] = 1 + R[i][j+1];
				}
				if(i == H-1){
					D[i][j] = 1;
				}else{
					D[i][j] = 1 + D[i+1][j];
				}
			}
		}
	}
	int maxi = 0;
	rep(i,0,H){
		rep(j,0,W){
			if(maxi < L[i][j]+R[i][j]+U[i][j]+D[i][j] - 3){
				maxi = L[i][j]+R[i][j]+U[i][j]+D[i][j] - 3;
			}
		}
	}
	cout << maxi << endl;
}

Measured memory_bytes: 66688
#include <bits/stdc++.h>
using namespace std;
int main(){
	int N, K; cin >> N >> K; 
	long long H[310] = {}; 
	for(int i = 1; i <= N; i++) cin >> H[i]; 
	long long dp[310][310][310] = {}; // dp[i列目まで見て][j列変えていて][最後に残したのがk列目]
	for(int i = 0; i <= N; i++){
		for(int j = 0; j <= N; j++){
			for(int k = 0; k <= N; k++){
				dp[i][j][k] = 1e12; 
			}
		}
	}
	dp[0][0][0] = 0LL; 
	for(int i = 0; i < N; i++){
		for(int j = 0; j <= i; j++){
			for(int k = 0; k <= i; k++){
				dp[i+1][j+1][k] = dp[i][j][k]; 
			}
		}
		for(int j = 0; j <= i; j++){
			for(int l = 0; l <= i; l++){
				long long tmp = dp[i][j][l] + max(H[i+1] - H[l], 0LL); 
				dp[i+1][j][i+1] = min(dp[i+1][j][i+1], tmp); 
			}
		}
	}
	long long ans = 1e12; 
	for(int j = 0; j <= K; j++){
		for(int k = 0; k <= N; k++){
			ans = min(ans, dp[N][j][k]); 
		}
	}
	cout << ans << endl; 
}

Measured memory_bytes: 232960
#include<iostream>
using namespace std;
int t[10001];
int n,q,a,b,ans=0;
int main(){
  cin>>n;
  for(int i=0;i<n;i++)cin>>t[i];
  cin>>q;
  for(int i=0;i<q;i++){
    cin>>a;
    t[n]=a;
    for(b=0;t[b]!=a;b++);
    if(b!=n)ans++;
  }
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 3132
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

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

using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repr(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define EPS (1e-10)
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}


const long long MOD = 1000000007;
const long long INF = 1LL << 60;


const int MAX_N = 100010;
signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n; cin >> n;
	VE a(n); rep(i, n)cin >> a[i];
	sort(ALLR(a));
	int ans = 0;
	rep(i, n) {
		ans += a[i] - (i + 1);
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 3624
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<algorithm>
#include<map>
#include<cstdlib>
#include<cmath>
using namespace std;
using ll =long long;
int main() {
	unsigned long long  a, b, c;
	cin >> a >> b >> c;
	if (a > c || b > c) {
		cout << "No";
		return 0;

	}
	2*(a*b+b*c+c*a)<a*a+b*b+c*c? cout << "Yes" : cout << "No";
}

Measured memory_bytes: 256
/*
　　こんにちは。あたしはｶｳｶﾞｰﾙ。
　　redcoderになるためAtCoderを巡る旅をしてます。

　　　 　 ＿_
　　　 ヽ|＿_|ノ　　　　ﾓｫ
　　　　||‘‐‘||ﾚ　　_)_, ―‐ 、
　　　　/(Ｙ (ヽ＿ /・ ヽ　　 ￣ヽ
　　　　∠ ＿ ゝ　 ｀^ヽ ﾉ.::::_(ノヽ
　　　　 _/ヽ　 　　  /ヽ￣￣/ヽ
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define dump(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl

#define rep(i, n) REP(i, 0, n)                              // 0, 1, ..., n-1
#define REP(i, x, n) for(int i = x; i < n; i++)             // x, x + 1, ..., n-1
#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(v) (v).begin() , (v).end()
#define RALL(v) (v).rbegin(), (v).rend()

#define COUT(x) cout << (x) << endl

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; }

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

    ll ans = 0, n; cin >> n;
    for(n++; n > 9; n /= 10) {
        ans += 9;
    }
    cout << n + ans - 1 << endl;
}


Measured memory_bytes: 256
n, m = map(int, input().split())
a_ls = list(map(int, input().split()))
a_ls.sort(reverse = True)
#print(a_ls)
all_sum = sum(a_ls)
#print(all_sum)
#print(all_sum/(4*m))
if a_ls[m-1] >= (all_sum/(4*m)):
    print("Yes")
else:
    print("No")


Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define ll long long int
#define inf 1e9 + 10
using namespace std;
unordered_map<ll,vector<ll>> ma;
ll dp[100005];
ll sol(ll src)
{
    if(dp[src]!=-1)
        return dp[src];
    ll maxlen=0;
    bool child=false;
    for(auto i:ma[src])
    {
        child=true;
        maxlen=max(maxlen,sol(i));
    }
    if(child==false)
        dp[src]=0;
    else
    {
        dp[src]=1+maxlen;
    }
    return dp[src];
}
int main()
{
    ll n,m;
    cin>>n>>m;

    for(ll i=0;i<m;i++)
    {
      ll x,y;
      cin>>x>>y;
      ma[x].push_back(y);
    }
      for(ll i=0;i<=n;i++)
        dp[i]=-1;
        ll ans=0;
      for(ll i=1;i<=n;i++)
      {
          ans=max(ans,sol(i));
      }
      cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 15484
#include<bits/stdc++.h>
using namespace std;
#define inf 1e9
#define ll long long 
#define M 1000000007
#define P pair<int,int>
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define rep(i,n) FOR(i,0,n)
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265

int a[3];
int sum;

int main(){

  rep(i,3){
    cin>>a[i];
  }
  sort(a,a+3);

  if(a[0]%2==a[1]%2&&a[0]%2!=a[2]%2){
    a[0]++;
    a[1]++;
    sum++;
  }
  if(a[0]%2==a[2]%2&&a[0]%2!=a[1]%2){
    a[0]++;
    a[2]++;
    sum++;
  }
  if(a[1]%2==a[2]%2&&a[0]%2!=a[1]%2){
    a[1]++;
    a[2]++;
    sum++;
  }

  sum+=(a[2]-a[0])/2;
  sum+=(a[2]-a[1])/2;

  cout<<sum<<endl;

  return 0;
}


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

int main() {
    char s[15]; scanf("%s", s);
    int res = 3;

    if (s[0] > '1') {
        res ^= 2;
    } else if (s[0] == '1' && s[1] > '2') {
        res ^= 2;
    } else if (s[0] == '0' && s[1] == '0') {
        res ^= 2;
    }

    if (s[2] > '1') {
        res ^= 1;
    } else if (s[2] == '1' && s[3] > '2') {
        res ^= 1;
    } else if (s[2] == '0' && s[3] == '0') {
        res ^= 1;
    }

    if (res == 3){
        printf("AMBIGUOUS\n");
    } else if (res == 2) {
        printf("MMYY\n");
    } else if (res == 1) {
        printf("YYMM\n");
    } else {
        printf("NA\n");
    }

    return 0;
}


Measured memory_bytes: 256
char s[2];m[21][21];main(n,x,y,c){for(;scanf("%d",&n),n;){for(memset(m,0,sizeof(m));n--;m[x][y]=1)scanf("%d%d",&x,&y);for(scanf("%d",&n),x=y=10;n--;)for(scanf("%s%d",s,&c),m[x][y]=0;c--;m[x][y]=0)*s=='W'?x--:*s=='E'?x++:*s=='S'?y--:y++;for(x=0;x<21;x++)for(y=0;y<21;y++)if(m[x][y])goto z;z:puts(x==21?"Yes":"No");}exit(0);}

Measured memory_bytes: 584
#include <stdio.h>
#include <stdlib.h>
#define max(a, b) ((a) > (b) ? (a) : (b))
 
int main(void)
{
    int n, wSum, w[100], v[100];
    scanf("%d%d", &n, &wSum);
    for(int i=0; i<n; i++) {
        scanf("%d%d", &w[i], &v[i]);
    }
 
    long dp[101][100001] = {};
    for (int i = 1; i <= n; i++) {
	    for (int j = 1; j <= wSum; j++) {
          	if(j >= w[i-1]) {
		        dp[i][j] = max(dp[i - 1][j-w[i-1]] + v[i-1], dp[i - 1][j]);
            } else {
		        dp[i][j] = dp[i - 1][j];              
            }
        }
    }
 
    printf("%ld\n", dp[n][wSum]);
    return 0;
}

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


int main() {
    
    string t;
    cin >> t;
    rep(i,t.size()) {
        if(t[i] == '?') {
            t[i] = 'D';
        }
        cout<<t[i];
    }

 return 0;
}


Measured memory_bytes: 3724
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

const int mod = 1e9 + 7;
using M = vector<vi>;
M operator*(const M &a, const M &b){
	M c(a.size(), vi(b[0].size()));
	rep(i, a.size()) rep(j, b.size()) rep(k, b[0].size()) (c[i][k] += (ll)a[i][j] * b[j][k] % mod) %= mod;
	return c;
}
M pow(M a, ll m){
	M res(a.size(), vi(a[0].size()));
	rep(i, a.size()) res[i][i] = 1;
	for(; m; m /= 2){
		if(m & 1) res = res * a;
		a = a * a;
	}
	return res;
}

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	int n;
	ll k; cin >> n >> k;
	M a(n, vi(n));
	rep(i, n) rep(j, n) cin >> a[i][j];
	M res = pow(a, k);
	ll ans = 0;
	rep(i, n) rep(j, n) ans += res[i][j];
	cout << ans % mod << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int  main (){
  int n;
  int s=0;
  int a;
  cin>>n;
  a=n;
  for(int i=0;i>-1;i++){
    s=s+(n%10);
    n/=10;
    if(n==0){
      break;
    }
  }
  if(a%s==0){
    cout<<"Yes"<<"\n";
    return(0);
  }
  cout<<"No"<<"\n";
  return(0);
}


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

int a[40];

int main(){
    string s; cin>>s;
    for(auto c:s)a[c-'a']++;
    for(int i=0;i<='z'-'a';i++){
        if(a[i]==0){
            cout<<(char)(i+'a')<<endl;
            return 0;
        }
    }
    cout<<"None"<<endl;
}


Measured memory_bytes: 512
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

typedef long long lint;

using namespace std;
lint p=1e9+7;
int main(){
  int N,M;
  cin>>N>>M;
  int a[M];
  REP(i,M)cin>>a[i];
  set<int> s;
  s.insert(a,a+M);
  s.insert(-1);
  s.insert(-2);
  lint dp[N+1];
  dp[0]=1;
  FOR(i,1,N+1){
    dp[i]=0;
    if(s.find(i)!=s.end())continue;
    if(s.find(i-1)==s.end())dp[i]+=dp[i-1];
    if(s.find(i-2)==s.end())dp[i]+=dp[i-2];
    dp[i]%=p;
  }
  // REP(i,N+1)cerr<<dp[i]<<endl;
  cout<<dp[N]<<endl;
  return 0;
}


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

import sys

dic = {}
for line in sys.stdin:
    i = int(line)
    if i not in dic:
        dic[i] = 1
    else:
        dic[i] += 1
Max = 0
for i in dic:
    Max = max(Max, dic[i])
ans = []
for i in dic:
    if dic[i] == Max:
        ans.append(i)
ans.sort()
for i in ans:
    print i

Measured memory_bytes: 6288
#include<stdio.h>
             
            int main()
            {
            	char S[10];
            	scanf("%s", S);
             
            	int ans = 0;
            	for (int i = 0; i < 4; ++i) {
            		if (S[i] == '+') ++ans;
            		else --ans;
            	}
            	printf("%d\n", ans);
            	return 0;
            }

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


typedef long long ll;
typedef pair<int,int> pii;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define FORR(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)

#define MOD 1000000007

int n;
char s[2521];
ll dp[2521][2521];

set<int> cs[26];

int main(){
  scanf("%s",s);
  n = strlen(s);
  REP(i,n)cs[s[i]-'a'].insert(i);

  dp[0][n] = 1;
  ll ans = 0;
  FORR(len,0,n+1)REP(l,n){
    int r = l+len;
    if(r>n)break;
    ll cnt = dp[l][r];
    if(cnt==0)continue;
    // step
    REP(i,26){
      auto it1 = cs[i].lower_bound(l);
      auto it2 = cs[i].lower_bound(r);
      if(it1==cs[i].end())continue;
      if(it2==cs[i].begin())continue;
      it2--;
      int x = *it1;
      int y = *it2;
      if(x>=y)continue;
      if(x>=r)continue;
      if(y<l)continue;
      ans += cnt;
      ans %= MOD;
      (dp[x+1][y] += cnt) %= MOD;
      // printf("%c(%d-%d)%c: %lld\n",'a'+i,x+1,y-1,'a'+i,cnt);
    }
    // finish
    REP(i,26){
      auto it = cs[i].lower_bound(l);
      if(it==cs[i].end())continue;
      int x = *it;
      if(x<r){
        // printf("%c single\n",'a'+i);
        ans += cnt;
        ans %= MOD;
      }
    }
  }
  printf("%lld\n",ans);
  return 0;
}



Measured memory_bytes: 24720
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <map>
#include <set>
using _loop_int = int;
#define REP(i,n) for(_loop_int i=0; i<(_loop_int)(n); i++)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a); i<(_loop_int)(b); i++)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1; i>=(_loop_int)(a); i--)
using namespace std;
typedef pair<int,int> P;
typedef long long ll;

const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;

int main(){
    int N, M, tmp, num;
    ll ans=0;
    cin >> N >> M;
    multiset<int> st;
    REP(i, N){
        cin >> tmp;
        st.insert(tmp);
    }
    multiset<int>::iterator j;
    while(M > 0){
        j = st.end();
        j--;
        tmp = *j;
        num = st.erase(tmp);
        if(M-num > 0){
            tmp = tmp/2;
            REP(i, num){
                st.insert(tmp);
            }
        } else {
            REP(i, num-M){
                st.insert(tmp);
            }
            tmp = tmp/2;
            REP(i, M){
                st.insert(tmp);
            }
        }
        M -= num;
    }
    for(multiset<int>::iterator itr = st.begin(); itr != st.end(); ++itr) {
        // std::cout << *itr << "\n";
        ans += *itr;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4992
n,m=map(int,input().split())
roads=[]
for i in range(m):
    road=list(map(int,input().split()))
    roads+=[road]

for i in range(n):
    ans=0
    for j in range(m):
        if roads[j][0]==i+1:
            ans+=1
        elif roads[j][1]==i+1:
            ans+=1
    print(ans)

Measured memory_bytes: 3060
N = int(input())
A = [int(input()) for _ in range(N)]

def is_prime(a):
    for i in range(2,int(a**0.5)+1):
        if a%i==0:
            return False
    return True

ans = 0
for i in A:
    if is_prime(i):
        ans += 1
print(ans)


Measured memory_bytes: 5992
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <string>
#include <queue>
#include <numeric>
#include <ctype.h>
#include <limits>
#include <iomanip>

#define rep(i,n) for (int i = 0; i < n; i++)
#define all(x) (x).begin(),(x).end()
using namespace std;

typedef long long ll;

int main()
{
	int r;
	cin >> r;
	cout << 2 * r * acos(-1);
	return 0;
}

Measured memory_bytes: 3784
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<time.h>
#include<random>
#include<array>
#include <regex>
#include <functional>
#include <algorithm>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;



int main(void) {
	int n;
	long long int sum = 0;
	cin >> n;
	for(int i = 1; i <= n; i++){
		if (i % 15 != 0 && i % 5 != 0 && i % 3 != 0) {
			sum += i;
		}
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 3636
#include <iostream>
using namespace std;
int main(void){
  while(true){
    int x,y;
    int rnt = 0;
    cin >> x >> y;
    if(!x){
      break;
    }
    for(int i = 0; x > i; i++){
      for(int j = 0; y > j; j++){
        if((rnt + j) % 2 == 0){
          cout << "#";
        } else {
          cout << ".";
        }
      }
      cout << endl;
      rnt++;
    }
    cout << endl;
  }
  return 0;
}


Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
char s[N];
int dp[N][3];

int main()
{
	scanf("%s", s + 1);
	int n = strlen(s + 1);
	dp[1][1] = 1;
	for (int i = 2; i <= n; i++) {
		for (int j = 1; j <= 2; j++) {
			if (i - j == 0)
				dp[i][j] = 1;
			else {
				for (int k = 1; k <= 2; k++) {
				//	if (i - j - k > 0) {
						if (j == k) {
							int flag = 0;
							for (int kk = k; kk > 0; kk--) {
								if (s[i - kk + 1] != s[i - j - kk + 1]) {
									flag = 1;
									break;
								}
							}
							if (flag)
								dp[i][j] = max(dp[i][j], 1 + dp[i - j][k]);
						} else
							dp[i][j] = max(dp[i][j], 1 + dp[i - j][k]);
				//	}
				}
			}
		}
	}
	printf("%d\n", max(dp[n][1], dp[n][2]));
	return 0;
}

Measured memory_bytes: 2816
/*
          , -- 、
        /;;;;;;', 　　　
        i二二二i
      , ' 　    ヽ ???
     i　ﾉﾉﾉﾉﾉﾍ .', 　　
     〉ﾘi' ﾟ ヮﾟﾉﾚく　 WAyon..........
  ○⊂}〈lﾄ--ｲl〉{つ● 　　
      ,ｒ/ー i-ヽヽ 　　　
     ｀｀i_ﾗi_ﾗ
*/

#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define int long long
const int INF=(int)1e12;
const int mod=(int)1e9+7;
#define all(a) (a).begin(),(a).end()
typedef vector<vector<int>> graph;

#define pb push_back

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

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


signed main() {
    int x;cin >>x;
    rep(i,2000)rep(j,2000)rep(a,2)rep(b,2){
        if(i*i*i*i*i*(a?1:-1)-j*j*j*j*j*(b?1:-1)==x){
            cout <<i*(a?1:-1)<<" "<<(b?1:-1)*j<<endl;
            return 0;
        }
    }
}

















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

int main(){
    char inp;

    cin >> inp;

    if (inp == 'A')
        cout << 'T';
    if (inp == 'T')
        cout << 'A';
    if (inp == 'C')
        cout << 'G';
    if (inp == 'G')
        cout << 'C';

    return 0;
}


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

#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>
namespace adaptor = boost::adaptors;

// 多倍長テンプレ
/* ---------------------- ここから ---------------------- */
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)
using Real = mp::number<mp::cpp_dec_float<1024>>;
/* ---------------------- ここまで ---------------------- */

void Main()
{
	string s, t;
	cin >> s >> t;

	if (s.length() + 1 != t.length()) {
		cout << "No";
		return;
	}
	if (t.find(s) != 0) {
		cout << "No";
		return;
	}
	cout << "Yes";
	return;
}

int main()
{
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
}

Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n,k;
    cin >> n>>k;
    int a[n+1];
    for(int i=1;i<=n;i++){
        cin >> a[i];
    }
    int dp[n+1]={};
    for(int i=2;i<=n;i++){
     int x=INT_MAX;
     for(int j=1;j<=k;j++){
        if(i-j>0){
            x=min(x,dp[i-j]+abs(a[i-j]-a[i]));
        }
     }
     dp[i]=x;
    }
    cout << dp[n] << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

int main(int argc, char const *argv[]) {
    int n; cin>>n;
    vector<ll> place(n+1);
    rep(i,n) {
        ll a; cin>>a;
        place[a]=i;
    }
    
    multiset<ll> used;
    used.insert(-1); used.insert(-1);
    used.insert(n); used.insert(n);

    // 1 2 3 4 5
    //       4 5

    ll ans = 0ll;
    for (int i = n; i >= 0; --i) {
        int ind = place[i];
        auto pre = used.lower_bound(ind);
        auto nxt = pre;
        --pre;
        ans += (*next(nxt) - *nxt) * (ind - *pre) * i;
        ans += (*pre - *prev(pre)) * (*nxt - ind) * i;
        used.insert(ind);
    }
    cout << ans << endl;
    return 0;
}


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

int main(){
  ll n;  cin >> n;n--;
  ll a;
  ll minnum=INF;
  map<ll,ll>mp;
  ll ans = -1;
  for(int i=0;i<5;i++){
     cin >> a;
     ans = max(ans,n/a);
  }
  cout << 5 + ans << endl;

}

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

int main(){

  string s;
  int c;

  cin>>s;

  if((s[0]==s[1]&&s[1]==s[2])||(s[1]==s[2]&&s[2]==s[3])) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

struct node{
  unsigned int key;
  struct node *next;
  struct node *prev;
};

typedef struct node * NodePointer;

NodePointer nil;

NodePointer listSearch(int key){

  NodePointer p = nil->next;

  while(p != nil && p->key != key){
    p = p->next;
  }
  return p;
}

void init(){

  nil = malloc(sizeof(struct node));
  nil->next = nil;
  nil->prev = nil;
}

void printList(){

  NodePointer cur = nil->next;
  int isf = 1;

  while(1){
    if ( cur == nil ) break;
    if ( isf == 0)  printf(" ");
    printf("%d", cur->key);
    cur = cur->next;
    isf = 0;
  }
  printf("\n");
}

void deleteNode(NodePointer t){

  if(t == nil)
    return;
  t->prev->next = t->next;
  t->next->prev = t->prev;
  free(t);
}

void deleteFirst(){

  NodePointer t = nil->next;
  if ( t == nil ) return;
  deleteNode(t);
}

void deleteLast(){

  deleteNode(nil->prev);
}

void delete(int key){

  deleteNode(listSearch(key));
}


void insert(int key){

  NodePointer x;
  x = malloc(sizeof(struct node));
  x->key = key;

  x->next = nil->next;
  nil->next->prev = x;

  nil->next = x;
  x->prev = nil;
}

int main(){
  int key, n, i;
  int size = 0;
  char com[20];
  int np = 0, nd = 0;
  scanf("%d", &n);
  init();
  for ( i = 0; i < n; i++ ){
    scanf("%s%d", com, &key);
    if ( com[0] == 'i' ) {insert(key); np++; size++;}
    else if ( com[0] == 'd' ) {
      if (strlen(com) > 6){
        if ( com[6] == 'F' ) deleteFirst();
        else if ( com[6] == 'L' ) deleteLast();
      } else {
        delete(key); nd++;
      }
      size--;
    }
  }

  printList();
  return 0;
}


Measured memory_bytes: 32936
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <stdio.h>
#include <ctype.h>
#include <random>
#include <string.h>
#include <cmath>
#include <unordered_map>
#include <cstdio>
using namespace std;
#define all(vec) vec.begin(),vec.end()
typedef long long ll;

ll gcd(ll x, ll y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
ll lcm(ll x, ll y) {
	return x / gcd(x, y)*y;
}
ll kai(ll x, ll y, ll m) {
	ll res = 1;
	for (ll i = x - y + 1; i <= x; i++) {
		res *= i; res %= m;
	}
	return res;
}
ll mod_pow(ll x, ll y, ll m) {
	ll res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}

ll comb(ll x, ll y, ll m) {
	if (y > x)return 0;
	return kai(x, y, m) * mod_pow(kai(y, y, m), m - 2, m) % m;
}

int n, c[30], s[400][30];
int d[30];

signed main() {
	std::random_device rnd;
	cin >> n;
	for (int i = 1; i <= 26; i++)cin >> c[i];
	for (int i = 1; i <= n; i++)for (int j = 1; j <= 26; j++)cin >> s[i][j];
	for (int i = 1; i <= n; i++) {
		int ma = -1000000000, p = 0;
		for (int j = 1; j <= 26; j++) {
			int cnt = 0;
			for (int k = 1; k <= 26; k++)if (j != k)cnt -= c[k] * (i - d[k]);
			cnt += s[i][j];
			if (ma < cnt) {
				ma = cnt;
				p = j;
			}
		}
		cout << p << endl;
		d[p] = i;
	}
}

Measured memory_bytes: 3676
#include "bits/stdc++.h"
using namespace std;

// GNU C Compiler
//template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

// type
using ll = int_fast64_t;
using ull = uint_fast64_t;
using LL = long long;
using ULL = unsigned long long;
using PII = pair<int, int>;
//using pair<T1, T2> = p12;

//container
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())
#define ALL(v) v.begin(),v.end()

//repetition
#define REP(n) for(int i=0; i<(n); i++)
#define REPj(n) for(int j=0; j<(n); j++)
#define REPinit(i,a,n) for(int i=(a); i<(n); i++)
#define REPinitj(j,a,n) for(int j=(a); j<(n); j++)

//algorithm
//#define SORT(c) sort((c).begin(),(c).end())

//constant

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//Optimizer
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

/* 
	add utility Algorithm
*/

int main(int argc, char const *argv[])
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int N;
    cin >> N;

    vector<ull> a(N,0);
    REPinit(i,0,N) {
        cin >> a[i];
        if (a[i] == 0) {
            cout << (0) << endl;
            return 0;
        }
    }

    ull ans = 1;
    const ull boundary = 1000000000000000000;
    REPinit(i,0,N) {
        if (a[i] <= boundary / ans) {
            ans *= a[i];
        }
        else{
            cout << (-1) << endl;
            return 0;
        }
    }

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


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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) (x).begin(),(x).end()

using ll = long long;
using P = pair<int,int>;

const int MOD = 1e9 + 7;
const int INF = 1001001001;

ll a[55], p[55];

ll f(ll n, ll x){
    if(n == 0){
        return ((x <= 0) ? 0 : 1);
    }else if(x <= 1 + a[n-1]){
        return f(n-1, x-1);
    }else{
        return p[n-1]+1 + f(n-1, x-a[n-1]-2);
    }
}


int main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

    ll N, X;
    cin >> N >> X;

    a[0] = 1;
    p[0] = 1;
    for (int i = 1; i <= N; ++i) {
        a[i] = a[i-1] * 2 + 3;
    }

    for (int i = 1; i <= N; ++i) {
        p[i] = p[i-1] * 2 + 1;
    }

    cout << f(N, X) << "\n";

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
// #include <atcoder/all>
#define ll long long int
#define rep(i,n) for(ll i=0;i<n;i++)
#define vec vector<ll>
#define mat vector<vector<ll>>

using namespace std;
// using namespace atcoder;

const ll mod=1000000007;//998244353;
const ll inf=LONG_LONG_MAX;
ll dx4[4]={1,0,-1,0};
ll dy4[4]={0,-1,0,1};
ll dx8[8]={1,0,-1,1,-1,1,0,-1};
ll dy8[8]={1,1,1,0,0,-1,-1,-1};

int main(){

    ll n,k;
    cin >> n >> k;

    vec a,b,c;
    for(ll i=0;i<n;i++){
        ll x;
        cin >> x;
        if(x<0)a.emplace_back(-x);
        else if(x>0)c.emplace_back(x);
        else b.emplace_back(x);
    }

    sort(a.begin(),a.end());
    sort(c.begin(),c.end());

    ll x,y,z;
    x=a.size();
    y=b.size();
    z=c.size();

    if(x*z>=k){
        //k番目は負の数
        ll m=x*z;
        ll r=inf,l=0,h;
        while(abs(r-l)>1){
            h=(r+l)/2;
            ll s=0;
            for(ll i=0;i<x;i++){
                ll p=upper_bound(c.begin(),c.end(),h/a[i])-c.begin();
                s+=p;
            }
            if(s>=m-k+1)r=h;
            else l=h;
        }
        cout << -r << endl;
    }
    else if(x*z+y*(y-1)/2+y*(x+z)>=k){
        //k番目は0
        cout << 0 << endl;
    }
    else{
        //k番目は正
        ll m=x*z+y*(y-1)/2+y*(x+z);
        k-=m;
        ll r=inf,l=0,h;
        while(abs(r-l)>1){
            h=(r+l)/2;
            ll s=0,t=0;
            for(ll i=0;i<x;i++){
                ll p=upper_bound(a.begin(),a.end(),h/a[i])-a.begin();
                if(a[i]*a[i]<=h)p--;
                s+=p;
            }
            for(ll i=0;i<z;i++){
                ll p=upper_bound(c.begin(),c.end(),h/c[i])-c.begin();
                if(c[i]*c[i]<=h)p--;
                t+=p;
            }
            if(s/2+t/2>=k)r=h;
            else l=h;
        }
        cout << r << endl;
    }

  return 0;
}

Measured memory_bytes: 5456
#include <stdio.h>
#include <algorithm>

int pos[100] = {};
int main() {
  int N;
  scanf("%d", &N);

  for (int i = 0; i < N; i++) {
    scanf("%d", pos + i);
  }

  std::sort(pos, pos + N);

  printf("%d\n", pos[N - 1] - pos[0]);

  return 0;
}


Measured memory_bytes: 128
#!/usr/bin python3
# -*- coding: utf-8 -*-

import sys
input = sys.stdin.readline
N, K = map(int, input().split())
md = pow(10,9) + 7

cnt_memo = [0]*(K+1)
cnt_R_memo = [0]*(K+1)

def main():
    ret = 0
    for k in range(1,K+1):
        cnt_R_memo[k]=pow(K//k,N,md)
    for k in range(K,0,-1):
        cnt_memo[k]=(cnt_R_memo[k] - sum(cnt_memo[2*k::k]))%md
        ret += (cnt_memo[k]*k)%md
    print(ret%md)

if __name__ == '__main__':
    main()

Measured memory_bytes: 14364
#include <bits/stdc++.h>
#include <stdio.h>
#include <math.h>
#include <cmath>
using namespace std;
#define vsort(vec) sort(vec.begin(), vec.end())
#define vreverse(vec) reverse(vec.begin(), vec.end())
using ll =long long;
using ull =unsigned long long;
const ll INF =1001001001;

//10億7。　　　100000007

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


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

int A,B,C,D;
  cin>>A>>B>>C>>D;
   int X,Y;
  X=A/D;
  Y=C/B;
  
  
  for(int i=0;i<101;i++){
    C-=B;
    if(C<=0){
      cout<<"Yes"<<endl;
      break;
    }
    A-=D;
    if(A<=0){
      cout<<"No"<<endl;
      break;
    }
  }

}



Measured memory_bytes: 3624
/*
            _           __                _      _____ _____ _____ 
  ___ _   _| |__   ___ / _|_ __ ___  __ _| | __ |___  |___  |___  |
 / __| | | | '_ \ / _ \ |_| '__/ _ \/ _` | |/ /    / /   / /   / / 
| (__| |_| | |_) |  __/  _| | |  __/ (_| |   <    / /   / /   / /  
 \___|\__,_|_.__/ \___|_| |_|  \___|\__,_|_|\_\  /_/   /_/   /_/   

*/
#include<bits/stdc++.h>
using namespace std;
typedef long long ll ;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<ll> vi;
typedef vector<pll> vpll;
typedef unordered_map <ll,ll> umap ; 
//#pragma GCC optimize "trapv"
#define loop(i,a,b) for(ll i=a ;i<b;i++)
#define For(i,n) for(int i=0;i<(ll)n;i++)
#define Rev(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,n) for(int i=1;i<=n;++i)
#define F first
#define S second
#define pb push_back
#define em emplace_back
#define all(v) (v).begin(),(v).end()
#define mems(x, y) memset(x, y, sizeof(x))
#define sz(v) (v).size()
#define mp(a,b) make_pair(a,b)
#define pf(n) cout<<n<<"\n"
#define pff(n) cout << n << " " ; 
#define ar array
#define endl "\n" 
#define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
long const M=1e9+7;
const long mxN =1e5+2 ;
const long mxNN =1e6+2 ;
void solve(){
    int s,w ; cin >> s >> w ;
    cout << (w>=s?"unsafe":"safe") << endl ;
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //cout << setprecision(20) << fixed ;
    solve() ;
    //ll t ; cin >> t ; while(t--)solve();
	return 0;
}


Measured memory_bytes: 3656
S = input()

is_YY = lambda string: True
is_MM = lambda string: 1 <= int(string) <= 12

is_YYMM = lambda string: is_YY(string[0:2]) and is_MM(string[2:4])
is_MMYY = lambda string: is_MM(string[0:2]) and is_YY(string[2:4])

answer = ''
if is_YYMM(S) and not is_MMYY(S):
    answer = 'YYMM'
elif not is_YYMM(S) and is_MMYY(S):
    answer = 'MMYY'
elif is_YYMM(S) or is_MMYY(S):
    answer = 'AMBIGUOUS'
else:
    answer = 'NA'

print(answer)


Measured memory_bytes: 3064
#UnionFind木
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
        return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
                x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def nums(self,x):
        return abs(self.parents[self.find(x)])

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

N, M = map(int, input().split())
edges = []*M
for i in range(M):
    a,b,w = map(int, input().split())
    edges.append((w,a,b))

edges.sort()

uf = UnionFind(N)
ans = 0
for i in range(M):
    u,x,y = edges[i]
    if not uf.same(x,y):
        uf.union(x,y)
        ans += u
print(ans)



Measured memory_bytes: 23192
#include <iostream>
 
int main()
{
  int N, alice = 0, bob = 0, cards[100];
  std::cin >> N;
  
  int num = 0, i = 0;
  while(std::cin >> num)
  {
    cards[i] = num;
    i++;
  }

  for(int i = 0; i < N; i++)
  {
    for(int k = 0; k < N; k++)
    {
      if(cards[i] > cards[k])
      {
        int temp = cards[i];
        cards[i] = cards[k];
        cards[k] = temp;
      }
    }
  }

  for(int i = 0; i < N; i++)
  {
    if(i % 2 == 0)
    {
      alice += cards[i];
    }
    else
    {
      bob += cards[i];
    }
  }  
  
  std::cout << alice - bob;
  return 0;
}

Measured memory_bytes: 3184
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Math;

class AtCoder{
  public static void Main(){

    var input = Console.ReadLine().Split();
    int a = int.Parse(input[0]);
    int b = int.Parse(input[1]);

    if(a + b >= 10){
        Console.WriteLine("error");
    }
    else{
        Console.WriteLine(a + b);
    }
  }
}


Measured memory_bytes: 11092
#include<bits/stdc++.h>
#define crap ios_base::sync_with_stdio(0);cin.tie(0)
#define ll long long
#define pb push_back
#define ff first
#define ss second
using namespace std;

#define int ll



int32_t main()
{
    
    crap;
  
   int n,p;
   cin>>n>>p;
   string s;
   cin>>s;
   int ans=0;

   if(p==2){

    for(int i=0;i<n;i++){
        if((s[i]-'0')%2==0)
            ans+=i+1;
    }
   }
   else if(p==5){
    for(int i=0;i<n;i++){
        if((s[i]-'0')%5==0)
            ans+=i+1;
        
    }
   }
   else{
    map<int,int> mp;

    mp[0]++;
    int t=0,p2=1;
    for(int i=n-1;i>=0;i--){
        t = t+(s[i]-'0') * p2;
        t =t%p;
        ans+= mp[t];
        mp[t]++;
        p2 = (p2*10)%p;
    }
   }

   cout<<ans<<endl;
 
} 

Measured memory_bytes: 1044
N = int(input())
num = list(map(int, input().split()))

tot = 0
num2 = [0]*(N-1)
numtot = sum(num)

for i in range(len(num)-1):
  numtot -= num[i]
  num2[i] = numtot % (10**9+7)
  
  num1 = num[i] % (10**9+7)
  
  tot += num1 * num2[i]
  
  if tot >= (10**9+7): tot = tot % (10**9+7)

print(tot)

Measured memory_bytes: 31384
S = input()
ls = ['01','02','03','04','05','06','07','08','09','10','11','12']

if S[:2] in ls:
    if S[2:] in ls:
        print('AMBIGUOUS')
    else:
        print('MMYY')
else:
    if S[2:] in ls:
        print('YYMM')
    else:
        print('NA')

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int mod = 1e9+7;
//繰り返し二乗法
ll ex(ll x,ll n){
    if(n==0)return 1;
    else if(n%2==1)return ex(x,n-1)*x;
    else return ex(x*x,n/2);
};
int main(){
    int n,k;
    cin >> n >> k;
    ll ans = 0;
    int m = n/k;
    bool flag = true;
    if(k == 1) flag = false;
    for(int a = 1; a <= n; a++){
        if(!flag) break;
        if(2*a%k != 0) continue;
        ans += ex((n+a)/k-(a+k)/k+1,2);
    }
    if(flag) cout << ans << endl;
    else cout << ex(n,3);
}

Measured memory_bytes: 256