akhauriyash/Code-Regression huggingface dataset:
<?php
fscanf(STDIN, '%s', $org);
fscanf(STDIN, '%d', $cnt);
$headAdd = [];
$footAdd = [$org];
$revFlag = false;
$ans = '';
for ($i=0; $i < $cnt; $i++) { 
    $in = trim(fgets(STDIN));
    if ($in > 1) {
        $arr = explode(' ', $in);
        $mode = $arr[1];
        $char = $arr[2];
        if (!$revFlag) {
            if ($mode == 1) {
                $headAdd[] = $char;
            } else {
                $footAdd[] = $char;
            }
        } else {
            if ($mode == 1) {
                $footAdd[] = $char;
            } else {
                $headAdd[] = $char;
            }
        }
    } else {
        $revFlag = !$revFlag;
    }
}
$ans .= implode(array_reverse($headAdd));
$ans .= implode($footAdd);
echo $revFlag ? strrev($ans) : $ans;
echo "\n";


Measured memory_bytes: 27120
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,s,n) for(int i = s; i < n; i++)
	
int N;
vector<int> a;

int main(){
	cin>>N;
	rep(i,0,N){
		int x; cin>>x; a.push_back(x);
	}
	bool flag = true;
	for(int tmp: a){
		if(tmp%2!=0){
			flag=false;break;
		}
	}
	if(flag){
		puts("second");
	}else{
		puts("first");
	}
}

Measured memory_bytes: 892
#include <bits/stdc++.h>
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/adaptors.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/algorithm/string/classification.hpp> // is_any_of
#include <boost/algorithm/string/split.hpp>
#include <boost/algorithm/string/join.hpp>
#include <boost/algorithm/string/replace.hpp>
#include <boost/math/tools/minima.hpp>

const int MOD = 1e9+7;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = (n); i >= 0; --i)

namespace adaptor = boost::adaptors;
using namespace std;
using boost::math::tools::brent_find_minima;
using boost::irange;
using boost::algorithm::join;
using boost::algorithm::split;
using boost::algorithm::replace_all;
using boost::multiprecision::cpp_int;
using ll = long long;
using P = pair<int, int>;

// TOP
void	Main()
{
	ll n, x;
	cin >> n;
	vector<ll>	V(n + 1);

	cin >> V.at(n);
	rep(i, n)
		cin >> V.at(i);
	sort(V.begin(), V.end());
	rrep(i, n)
		V.at(i) -= V.at(0);
	ll	d;
	d = V.at(1);
	rep(i, n - 1)
	{
		d = __gcd(d, V.at(i + 2));
	}
	cout << d << endl;
}
// END

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


Measured memory_bytes: 1024
#include <stdio.h>
#define MAX 500000
#define SENTINEL 2000000000

  int L[MAX/2+2],R[MAX/2+2];
  int cnt;

  void merge(int a[],int n,int left,int mid,int right){
  int n1,n2,i,j,k;
  n1=mid-left;
  n2=right-mid;

  for(i=0;i<n1;i++){
    L[i]=a[left+i];
  }

  for(i=0;i<n2;i++){
    R[i]=a[mid+i];
  }

  L[n1]=R[n2]=SENTINEL;
  i=0;
  j=0;
  for(k=left;k<right;k++){
    cnt++;
    if(L[i]<=R[j]){
      a[k]=L[i++];
    }
    else{
      a[k]=R[j++];
    }
  }
}

void mergesort(int a[],int n,int left,int right){
  int mid;
  if(left+1<right){
    mid=(left+right)/2;
    mergesort(a,n,left,mid);
    mergesort(a,n,mid,right);
    merge(a,n,left,mid,right);
  }
}

int main(void)
{
  int a[MAX],n,i;
  cnt=0;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
  }
  mergesort(a,n,0,n);
  
  for(i=0;i<n;i++){
    if(i>0){
      printf(" ");
    }
    printf("%d",a[i]);
  }
  printf("\n");
  printf("%d\n",cnt);
  
  return 0;
}



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

typedef long long int ll;
typedef unsigned long long int ull;
#define rep(i,n) for(auto i=0;i<(n);i++)
#define rep1(i,n) for(auto i=1;i<=(n);i++)
#define all(x)(x).begin(),(x).end()

using namespace std;


struct init{ init(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20); }; }aaaaaaa;

int solve(int k, set<int, std::greater<int>> st, map<int, int> ma){
  priority_queue<int> que;
  for(auto e : st) que.push(e);
  int e = que.top();
  while(!que.empty()){
    e = que.top(), que.pop();
    if(ma[e] == 0) continue;
    if(k < ma[e])  break;
    int half = e / 2 + e % 2;
    ma[half] += 2*ma[e];
    k -= ma[e];
    ma[e] = 0;
    que.push(half);
  }
  
  return e;
}

bool check(int m, set<int, std::greater<int>>& st, map<int, int>& ma, int k){
  int kk = 0;
  for(auto e : st) kk += ((e - 1) / m) * ma[e];
  return kk <= k;
}

int main(){
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  sort(all(a));

  map<int, int> ma;
  set<int, std::greater<int>> st;
  rep(i, n){
    ma[a[i]]++;
    st.insert(a[i]);
  }
  
  int l = 1;
  int r = solve(k, st, ma);

  while(l != r){
    int m = (l+r) / 2;
    if(check(m, st, ma, k)) r = m;
    else                    l = m;
    if(l+1 == r) break;
  }

  
  cout << ((check(l, st, ma, k))? l:r) << endl;

  return 0;
}


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

int L, N;
struct Edge {
    int u, v, w;
};
vector<Edge> edge;

int main() {
    cin >> L;

    while((1 << N) <= L) N++;

    for(int i = 1; i < N; i++) {
        edge.push_back({ i, i + 1, (1 << (N - 1 - i)) });
        edge.push_back({ i, i + 1, 0 });
    }

    int sum = (1 << (N - 1));
    for(int i = N - 2; i >= 0; i--) {
        if(L & (1 << i)) {
            edge.push_back({ 1, N - i, sum });
            sum += (1 << i);
        }
    }

    printf("%d %d\n", N, edge.size());
    for(int i = 0; i < edge.size(); i++) {
        printf("%d %d %d\n", edge[i].u, edge[i].v, edge[i].w);
    }
}


Measured memory_bytes: 256
import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10**7)
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)

"""
N = 6**i + 9**j
とする。

"""

N = I()

smalls = []
bigs = []
for i in range(10**5):
    small = 6**i
    big = 9**i

    if small <= N:
        smalls.append(small)
    if big <= N:
        bigs.append(big)
    if small > N:
        break

smalls = sorted(smalls, reverse=True)
bigs = sorted(bigs, reverse=True)
#  print('smalls, bigs', smalls, bigs)

result = 10**13
for i in range(0, N+1):
    #  print('i', i)
    # i は6だけで払う分
    small_n = i
    big_n = N - i

    small_idx = 0
    big_idx = 0

    small_count, big_count = 0, 0
    while small_n != 0:
        if smalls[small_idx] > small_n:
            small_idx += 1
            continue
        small_n -= smalls[small_idx]
        small_count += 1

    while big_n != 0:
        if bigs[big_idx] > big_n:
            big_idx += 1
            continue
        big_n -= bigs[big_idx]
        big_count += 1
    #  print('small_count, big_count', small_count, big_count)
    result = min(result, small_count+big_count)

print(result)


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

# define rep(i, n) for(int(i)=0;(i)<(n);(i)++)
# define reps(i, n) for(int(i)=1;(i)<=(n);(i)++)
# define rrep(i, n) for(int i=((int)(n)); i>0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>=0; --i)
# define ALL(v) v.begin(), v.end()
template<class T>inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
typedef long long ll;

int main() {
    vector<int> V(3);
    rep(i,3) {
      cin >> V[i];
    }
    sort(V.begin(), V.end());
    cout << V[0] << " " << V[1] << " " << V[2] << endl;
}


Measured memory_bytes: 3168
loop do
    n, m = gets.split.map(&:to_i)
    break if n == 0 && m == 0
    p = gets.split.map(&:to_i).sort.reverse
    ans = 0
    p.each_slice(m) do |a|
        ans += a.inject(:+)
        ans -= a.pop if a.size == m
    end
    puts ans
end

Measured memory_bytes: 6312
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
using namespace std;

const int INF=1e9;
int cost[100][100];
bool used[100];
int mincost[100];
int N,M;

int main(){
    while(cin>>N,N){
        cin>>M;
        fill(cost[0],cost[0]+10000,INF);
        fill(used,used+100,false);
        fill(mincost,mincost+100,INF);

        for(int i=0;i<M;i++){
            int a,b,c;
            ((cin>>a).ignore()>>b).ignore()>>c;
            c=c/100-1;
            cost[a][b]=c;
            cost[b][a]=c;
        }

        mincost[0]=0;
        int res=0;

        //prim
        while(true){
            int v=-1;
            for(int i=0;i<N;i++)
                if(!used[i]&&(v==-1||mincost[i]<mincost[v]))v=i;

            if(v==-1)break;
            used[v]=true;
            res+=mincost[v];

            for(int i=0;i<N;i++)
                mincost[i]=min(mincost[i],cost[v][i]);
        }

        cout<<res<<endl;
    }
}

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

using namespace std;

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

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define print(a) {for (auto iiiiiiiiii : a) cout << iiiiiiiiii << ' '; cout << '\n';}
#define fi first
#define se second
#define all(x) (x).begin() , (x).end()

ll next() {ll x; cin >> x; return x;}

const ll inf = 1e18 , mod = 998244353;
const int intf = 2e9 , maxn = 3e5;
const double PI = 3.141592653589 , eps = 1e-9;


void solve(){
    int n , k;
    cin >> n >> k;
    if (k == 1){
        cout << "0";
    } else {
        cout << n - k;
    }
}


int main()
{
    #ifdef HERE
        freopen("input.txt" , "r" , stdin);
    #else
        //freopen(".in" , "r" , stdin); freopen(".out" , "w" , stdout);
        ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cout.precision(20);
    #endif

    for (int t = 1; t--;) solve();

    #ifdef HERE
        cout << setprecision(3) << fixed << "\n\nRuntime: " << (long double)(clock()) / CLOCKS_PER_SEC << " s.\n";
    #endif
    return 0;
}
/*

*/


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<algorithm>
#include<iostream>

using namespace std;
int main(void){
	int ans,tmp,A,B,C;
	vector<int> a;
	scanf("%d%d%d", &A,&B,&C);
	a.push_back(A);
	a.push_back(B);
	a.push_back(C);
	sort(a.begin(),a.end(),greater<int>());
	if(a[1] == a[2]){
		ans = a[0] - a[1];
	}else if((a[1] - a[2])%2 == 0){
		ans = a[0] - a[1] + (a[1] - a[2])/2; 
	}else{
		ans = a[0] - a[1] + (a[1] - a[2] + 1)/2 +1; 
	}
	printf("%d\n",ans);
	fflush(stdout);

	return 0;
}


Measured memory_bytes: 256
N,M=list(map(int,input().split()))
h_list=list(map(int,input().split()))
h2_list=[True]*N

for _ in range(M):
    A,B=list(map(int,input().split()))
    if h_list[A-1] < h_list[B-1]:
        h2_list[A-1] = False
    elif h_list[A-1] > h_list[B-1]:
        h2_list[B-1] = False
    else:
        h2_list[A-1] = False
        h2_list[B-1] = False


ans = 0
for h2 in h2_list:
    if h2:
        ans+=1
print(ans)

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

using namespace std;

typedef long long ll;

const int MOD = 1e9 + 7;
int n;
string s;

int main()
{
	cin >> n >> s;
	long long dp[n + 1][n + 1];
	long long prefix[n + 1][n + 1];
	memset(dp, 0, sizeof(dp));
	memset(prefix, 0, sizeof(dp));
	prefix[0][1] = dp[0][1] = 1;
	for (int i = 1; i < n; i++)
	{
		for (int j = 1; j <= i + 1; j++)
		{
			if (s[i - 1] == '>')
				dp[i][j] = (dp[i][j] + (prefix[i - 1][i] - prefix[i - 1][j - 1] + MOD) % MOD) % MOD;
			else
				dp[i][j] = (dp[i][j] + prefix[i - 1][j - 1]) % MOD;
			prefix[i][j] = (prefix[i][j - 1] + dp[i][j]) % MOD;
		}
	}
	ll ans = 0;
	for (int i = 1; i <= n; i++)
		ans = (ans + dp[n - 1][i]) % MOD;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 140928
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <limits.h>
#include <algorithm>
using namespace std;

int main(){
  string S, C ;
  int Q, T, count = 0, ans = -1;
  cin >> S >> Q ;
  string  Front = "", Behind = "";
  for(int i=0;i<Q;i++){
      cin >> T ;
      if(T == 1){
          count++ ;
      }
      else{
          cin >> T >> C ;
          if((count + T) % 2 == 0){
              Behind = Behind + C ;
          }
          else{
              Front = C + Front ;
          }
      }
  }
  S = Front + S + Behind ;
  if((count % 2) == 1 ) reverse(S.begin(),S.end()) ;
  
  cout << S << endl ;
  return 0 ;
}

Measured memory_bytes: 1464
S = list(input())
N = len(S)
a = 0
b = 0
c = 0
for i in range(N):
  if S[i] == 'a':
    a += 1
  elif S[i] == 'b':
    b += 1
  else:
    c += 1
if N == 1:
  ans = 'YES'
elif N == 2:
  if max(a, b, c) == 2:
    ans = 'NO'
  else:
    ans = 'YES'
else:
  if min(a, b, c) == 0:
    ans = 'NO'
  elif max(a, b, c) - min(a, b, c) < 2:
    ans = 'YES'
  else:
    ans = 'NO'
print(ans)

Measured memory_bytes: 10028
N = int(input())
A = list(map(int, input().split()))

last_value = A[0]
kabu = 0
money = 1000
for n in range(1, N):
    if A[n] > last_value:
        kabu = int(money / last_value)
        money -= last_value * kabu
        money += A[n] * kabu
        last_value = A[n]
    elif A[n] < last_value:
        last_value = A[n]

print(money)

Measured memory_bytes: 9212
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef vector<int> vi;
typedef pair<int,int> ii;
#define inf 1e9
#define F first
#define S second
#define dbg(x) cout<<#x<<" value : "<<x<<"\n";
#define rep(i,j,k) for(int i = (j); i <= (k); i++)
#define rep__(i,j,k) for(int i = (j); i < (k); i++)
#define per(i,j,k) for(int i = (j); i >= (k); i--)
#define per__(i,j,k) for(int i = (j); i > (k); i--)
#define mst(a,b) memset(a,b,sizeof(a))
#define sf(n) scanf("%d",&n)
#define stf(n,m) scanf("%d%d",&n,&m)
#define pf(n) printf("%d\n",n)
#define sllf(n) scanf("%lld",&n)
#define pllf(n) printf("%lld\n",n)
priority_queue<int,vector<int>,greater<int> > q;
const int N=1e5+10;
const int mod=1e9+7;
LL n,m,sum=1;

int main()
{
	cin>>n>>m;
	LL g=__gcd(n,m);
	for(LL i=2;i*i<=g;i++){
		if(g%i==0){
			sum++;
			while(g%i==0){
				g/=i;
				if(g==1)break;
			}
		}
	}
	if(g>1)sum++;
	cout<<sum;
	return 0;
}

Measured memory_bytes: 256
import sys
def I(): return int(sys.stdin.readline())
def LI(): return [int(x) for x in sys.stdin.readline().split()]

def main():
    N = I()
    ARM = []
    for i in range(N):
        X,L = LI()
        ARM.append([X-L,X+L])
    ARM.sort(key=lambda x: x[0])
    ARM.sort(key=lambda x: x[1])

    cur = -1 * (10**10)
    ans = 0

    for i in range(N):
        if cur <= ARM[i][0]:
            ans += 1
            cur = ARM[i][1]

    print(ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 62684
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;

class Program
{
    static int N;

    public static void Main(string[] args)
    {
        N = Input.NextInt();
        var x = new int[N];
        var y = new int[N];
        var h = new int[N];

        int samplex = 0, sampley = 0, sampleh = 0;
        foreach (var i in Enumerable.Range(0, N))
        {
            var xyh = Input.LineInt();
            x[i] = xyh[0];
            y[i] = xyh[1];
            h[i] = xyh[2];
            if (h[i] != 0)
            {
                samplex = x[i];
                sampley = y[i];
                sampleh = h[i];
            }
        }

        for (int cx = 0; cx <= 100; cx++)
        {
            for (int cy = 0; cy <= 100; cy++)
            {
                var hh = sampleh + Math.Abs(cx - samplex) + Math.Abs(cy - sampley);
                for (int i = 0; i < N; i++)
                {
                    var HC = Math.Max(hh - Math.Abs(cx - x[i]) - Math.Abs(cy - y[i]), 0);
                    if (HC != h[i])
                        goto L_nextcand;
                }
                Console.WriteLine($"{cx} {cy} {hh}");
                return;
            L_nextcand:
                ;
            }
        }

        throw new Exception();
    }
}

public static class Input
{
    private static Queue<string> q = new Queue<string>();
    private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); }
    public static string NextString() { Confirm(); return q.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
}

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

int main(){
	int n,m;
	cin>>n>>m;
	string a[n],b[m];
	for(int i=0;i<n;i++)cin>>a[i];
	for(int i=0;i<m;i++)cin>>b[i];
	
	for (int k = 0; k < n-m+1; k++){
		 for (int l = 0; l < n-m+1; l++){
		 	bool f1=1;
		 	for (int i = 0; i < m; i++){
                for (int j = 0; j < m; j++){
                   if(b[i][j]!=a[i+k][j+l])f1=0;
                }
            }
            if(f1) {cout<<"Yes";return 0;
			}
        }
    }
    cout<<"No";
	return 0;
} 

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


//c++ templte for help............................................................................................................................................
//typedef int ll;
//typedef unsigned long long ull;

//template<typename... T>
//void print1(T... t){
	//((cout<<t<<" "),...);
//}

//template<typename... T>
//void print2(T... t){
		//vector<vector<ll>> ans={t...};
		//for(ll i=0;i<(ll)ans.size();i++){
			//if(i!=0) cout<<"\t";
			//else cout<<"\t";
			//for(ll j=0;j<(ll)ans[i].size();j++){
				//cout<<ans[i][j]<<" ";
			//}
			//if(i!=(ll)ans.size()-1)
			//cout<<endl;
		//}
//}	
//#define deb(...) cout<<" [ "#__VA_ARGS__<<" : "; print1(__VA_ARGS__); cout<<"]"<<endl; 
//#define vdeb(...) cout<<" [ "#__VA_ARGS__<<" : "; print2(__VA_ARGS__); cout<<"]"<<endl;





	
 
//for loop
//#define fo(i,n) for(int i=0;i<(ll)n;i++)
//#define Fo(i,k,n) for(int i=k;i<n;i++)
 
 
//to print vector element 
//template<typename T>
//void printV(T vec){
	//fo(i,vec.size()) cout<<vec[i]<<" "<<flush;
	//cout<<endl;
	//}
	
 
//#define modulo 1000000007
//const int INF=1e9+5;
 
//iterate map
//template<typename T>
//void itR(T map){
	 //for(auto itr=map.begin();itr!=map.end();itr++){
				//deb(itr->first,itr->second);
			//}
	//cout<<endl;
//}
 
 
 
//c++ template for help...........................................................................................................................................

        
int solve(){
	int a,b;
	cin>>a>>b;
	return a*b;
}







int main() {
	//stringstream ss;
	//ss<<"akhil";
	//cout<<ss.str()<<endl;
	cout<<setprecision(50);
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	
	 // TESTCASE KO DEKH KA BHAUT SARA CONDITION GENERATE MAT KRO 
	 // PAPER PD CONFIRM HO JAO THORA JADA TIME HI KYU NA LGA
	 // greedy ma jadatr exceptional case check kr ke dekh lo
	 
	 // WHILE DOING THE QUESTION OF DYNAMIC PROGRAMMING GREEDY KA TRAH SOCHNA BAND KRO
	 // DP M DATA KA BHI USE KRNA PDTA HA BE BHULO MT 
	 // DP BHI WO LEETCODE WALE MATRIX KA QUESTION KI TARAH HA
	 // CONSTRAIN WILL BE THE DIMENSION OF DP
	 // DP MA STATE PTA KRO AUR PHIR FUNCTION GENERATE KRO
	 // OBJECT KO CHOOSE KIA YA NAE KIA AGAR KIA TO KYA HOGA AUR NAE KIA TO KYA HOGA
	 // KYA KYA CHEJ IMPORTANT HA WO STATE BN JYAGA AUR HUM LOG STATE KO CHANGE KR SKTA HA JYSA KNPSACK 2 WALE PROBLEM MA KIA THA
	 

	 
	//ll testCase;
	//cin>>testCase;
	//for(ll tt=0;tt<testCase;tt++){
		cout<<solve()<<endl;
	//}
	return 0;
}


Measured memory_bytes: 3648
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <functional>
#include <utility>
using i64 = long long;

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

    std::vector<std::pair<int, int>> r(n + 1), s;
    std::vector<int> ca(n + 1), cb(n + 1);
    for (int i = 0; i < n; i++) {
        int a;
        std::cin >> a;
        ca[a]++;
        if (ca[a] == 1) r[a] = std::make_pair(i, i + 1);
        else r[a].second++;
    }
    for (int i = 0; i < n; i++) {
        int b;
        std::cin >> b;
        cb[b]++;
    }

    for (int i = 1; i <= n; i++) {
        const int t = ca[i] + cb[i];
        if (t > n) {
            std::cout << "No" << std::endl;
            return 0;
        }
        if (t) s.emplace_back(t, i);
    }

    std::sort(s.begin(), s.end(), std::greater<>());

    std::vector<int> ret(n);
    try {
        std::set<int> ss;
        for (int i = 0; i < n; i++) ss.insert(i);
        std::vector<int> ex;
        for (const auto [c, i] : s) {
            const int bb = cb[i];
            for (int j = r[i].first; j < r[i].second; j++) {
                auto it = ss.find(j);
                if (it != ss.end()) {
                    ex.push_back(*it);
                    ss.erase(it);
                }
            }
            for (int j = 0; j < bb; j++) {
                if (ss.empty()) throw 0;
                auto it = ss.begin();
                ret[*it] = i;
                ss.erase(*it);
            }
            for (const int j : ex) ss.insert(j);
            ex.clear();
        }
    } catch (...) {
        std::set<int> ss;
        for (int i = 0; i < n; i++) ss.insert(i);
        std::vector<int> ex;
        for (const auto [c, i] : s) {
            const int bb = cb[i];
            for (int j = r[i].first; j < r[i].second; j++) {
                auto it = ss.find(j);
                if (it != ss.end()) {
                    ex.push_back(*it);
                    ss.erase(it);
                }
            }
            for (int j = 0; j < bb; j++) {
                if (ss.empty()) throw 0;
                auto it = ss.rbegin();
                ret[*it] = i;
                ss.erase(*it);
            }
            for (const int j : ex) ss.insert(j);
            ex.clear();
        }
    }

    std::cout << "Yes\n";
    for (const int e : ret) std::cout << e << ' ';
    std::cout << std::endl;

    return 0;
}


Measured memory_bytes: 18084
N = int(input())
key_value = []
for i in range(N):
  a, b = map(str,input().split())
  key_value += [[a, int(b), i+1]]
key_value.sort(key=lambda x:(x[0], -x[1]))

for i in range(N):
  print(key_value[i][2])

Measured memory_bytes: 3060
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define mod 1000000007
using namespace std;
typedef long long ll;
template<class T> using V=vector<T>;
using Graph = vector<vector<int>>;
using P=pair<ll,ll>;
typedef unsigned long long ull;
typedef long double ldouble;
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; }

ll n;
ll ans=0;

void f(ll x,ll y,bool a,bool b,bool c,ll n){
    if(y==3) a=1;
    if(y==5) b=1;
    if(y==7) c=1;
    if(x<=n&&a&&b&&c) ans++;
    if(x<n){
        f(10*x+3,3,a,b,c,n);
        f(10*x+5,5,a,b,c,n);
        f(10*x+7,7,a,b,c,n);
    }
}

int main(){
    cin>>n;
    f(3,3,0,0,0,n);
    f(5,5,0,0,0,n);
    f(7,7,0,0,0,n);
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
class disjoint_set {
  public:
  vector<int> rank, prt;
  disjoint_set (int size) {
    rank.resize(size);
    prt.resize(size);
    for (int i = 0; i < size; i++) {
      prt[i] = i;
      rank[i] = 0;
    }
  }
  int find (int x) {
    if (x == prt[x]){
      return x;
    } else {
      return prt[x] = find(prt[x]);
    }
  }
  bool is_equiv (int x, int y) {
    return find(x) == find(y);
  }
  bool unite (int x, int y) {
    x = find(x);
    y = find(y);
    if (x == y) {
      return false;
    }
    if (rank[x] > rank[y]) {
      swap(x, y);
    }
    prt[x] = y;
    if (rank[x] == rank[y]) {
      rank[y]++;
    }
    return true;
  }
};
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, k, l;
  cin >> n >> k >> l;
  vector<disjoint_set> djs(2, disjoint_set(n));
  int crr(0), nxt(1);
  for (int t = 0; t < 2; t++) {
    for (int i = 0; i < k; i++) {
      int s, t;
      cin >> s >> t;
      djs[crr].unite(--s, --t);
    }
    swap(crr, nxt);
    swap(k, l);
  }
  vector<int> a(n);
  vector<int> b(n);
  vector<pair<int, int>> lst(n);
  for (int i = 0; i < n; i++) {
    a[i] = djs[0].find(i);
    b[i] = djs[1].find(i);
    lst[i] = {a[i], b[i]};
  }
  sort(lst.begin(), lst.end());
  for (int i = 0; i < n; i++) {
    pair<int, int> tgt = {a[i], b[i]};
    int ret = upper_bound(lst.begin(), lst.end(), tgt) - lower_bound(lst.begin(), lst.end(), tgt);
    cout << ret;
    if (i < n - 1) {
      cout << ' ';
    } else {
      cout << '\n';
    }
  }
  return 0;
}

Measured memory_bytes: 6904
h, w, k = map(int, input().split())

c = []

for i in range(h):
	s = input()
	d = []
	for ch in s:
		d.append(ch)

	c.append(d)

result = 0

for m1 in range(1 << h):
	for m2 in range(1 << w):			
		d = []
		for i in range(h):
			x = []
			for j in range(w):
				x.append(c[i][j])
			d.append(x)


		for row in range(h):
			if (m1 >> row) % 2 == 1:
				for j in range(w):
					d[row][j] = '.'

		for col in range(w):
			if (m2 >> col) % 2 == 1:
				for i in range(h):
					d[i][col] = '.'

		count = 0
		for i in range(h):
			for j in range(w):
				if d[i][j] == '#':
					count += 1

		if count == k:
			result += 1

print(result)


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

using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;

struct fastio {
    fastio() {
        ios::sync_with_stdio(false);
        cout << setprecision(10) << fixed;
        cin.tie(0);
    }
};

fastio _fast_io;

int main() {
    int a;
    cin >> a;
    cout << a + a*a + a*a*a << endl;
    return 0;
}


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

using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
  for (auto val : array)
    std::cout << val << ", ";
  std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

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

  int h, w; std::cin >> h >> w;
  vector<vi> grid(h, vi(w));
  struct Move {
    int x, y, nx, ny;
  };
  rep(i, h) rep(j, w) {
    std::cin >> grid[i][j];
  }
  int cnt = 0;
  bool right = true;
  vector<Move> moves;
  rep(i, h) {
    if (right) {
      rep(j, w) {
        if (grid[i][j] % 2 == 0) continue;
        int nx = -1, ny = -1;
        if (j < w-1) ny = i, nx = j+1;
        else if (i+1 < h) ny = i+1, nx = j;
        if (nx == -1) continue;
        grid[i][j]--, grid[ny][nx]++;
        Move m;
        m.y = i, m.x = j, m.ny = ny, m.nx = nx;
        moves.pb(m);
      }
    } else {
      drep(j, w) {
        if (grid[i][j] % 2 == 0) continue;
        int nx = -1, ny = -1;
        if (j > 0) ny = i, nx = j-1;
        else if (i+1 < h) ny = i+1, nx = j;
        if (nx == -1) continue;
        grid[i][j]--, grid[ny][nx]++;
        Move m;
        m.y = i, m.x = j, m.ny = ny, m.nx = nx;
        moves.pb(m);
      }
    }
    right ^= 1;
  }
  std::cout << moves.size() << "\n";
  rep(i, moves.size()) {
    std::cout << moves[i].y+1 << " " << moves[i].x+1 << " ";
    std::cout << moves[i].ny+1 << " " << moves[i].nx+1 << "\n";
  }
}


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

int main()
{
  int n, m;
  string s;
  cin >> n >> m >> s;
  vector<int> ans;
  int ix = n;
  while (ix > 0) {
    int i;
    for (i = m; i > 0; i--) {
      if (ix - i < 0) continue;
      if (s[ix - i] == '0') {
        ix -= i;
        ans.push_back(i);
        break;
      }
    }
    if (i == 0) break;
  }
  reverse(begin(ans), end(ans));
  if (ix == 0) {
    string sp;
    for (auto&& e : ans) {
      cout << sp << e;
      sp = " ";
    }
    cout << endl;
  } else {
    cout << -1 << endl;
  }
}


Measured memory_bytes: 1144
#include <bits/stdc++.h>
#define rep(i,n) for(int i=(0);i<(n);i++)

using namespace std;

typedef long long ll;

int idx(int x){
	if(x <= 399) return 0;
	if(x <= 799) return 1;
	if(x <= 1199) return 2;
	if(x <= 1599) return 3;
	if(x <= 1999) return 4;
	if(x <= 2399) return 5;
	if(x <= 2799) return 6;
	if(x <= 3199) return 7;
	return 8;
}

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

	int N;
	cin >> N;

	vector<int> a(N);
	rep(i, N) cin >> a[i];

	vector<int> type(9, 0);
	rep(i, N){
		type[idx(a[i])]++;
	}

	int mn = 0;
	rep(i, 8){
		if(type[i] > 0) mn++;
	}

	cout << max(mn, 1) << " " << mn + type[8] << endl;
}


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

using namespace std;

int main() {
  std::cin.tie(nullptr);
  std::ios::sync_with_stdio(false);
  int n;
  std::cin >> n;
  switch (n) {
    case 25:
      std::cout << "Christmas" << std::endl;
      break;
    case 24:
      std::cout << "Christmas Eve" << std::endl;
      break;
    case 23:
      std::cout << "Christmas Eve Eve" << std::endl;
      break;
    case 22:
      std::cout << "Christmas Eve Eve Eve" << std::endl;
      break;
  }
  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<vector>
#include<string>
#include<deque>
#include<map>
#include<algorithm>

using namespace std;

int main(){
	while(1){
		int n;
		scanf("%d",&n);
		if(n==0){
			break;
		}
		int cont=0;
		for(int i=0;i<n-1;i++){
			for(int j=0;j<=i;j++){
				int a;
				scanf("%d",&a);
				cont+=a;
			}
		}
		printf("%d\n",cont/(n-1));
	}
}

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

using namespace std;

void solve() {
  string s, t, u;
  int a, b;
  cin >> s >> t;
  cin >> a >> b;
  cin >> u;

  if (s == u) {
    --a;
  }
  if (t == u) {
    --b;
  }
  cout << a << " " << b << endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  solve();
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
   int h,n;cin>>h>>n;
   int a=0;
   for(int i=0;i<n;i++){
       int x;cin>>x;a+=x;
   }
   if(a<h)cout<<"No"<<endl;
   else cout<<"Yes"<<endl;
}

Measured memory_bytes: 256
def main():
    k,n = map(int,input().split())
    pos = list(map(int, input().split()))
    dist = []
    for i in range(n-1):
        dist.append(pos[i+1] - pos[i])
    dist.append(k-pos[n-1]+pos[0])
    print(k - max(dist))

if __name__ == '__main__':
    main()

Measured memory_bytes: 86140
N = int(input())
A = list(map(int, input().split()))
min_a, max_a = min(A), max(A)
min_idx, max_idx = A.index(min_a)+1, A.index(max_a)+1

ans = []
if abs(min_a) <= abs(max_a):
  for i in range(1, N+1):
    ans.append([max_idx, i])
  for i in range(1, N):
    ans.append([i, i+1])
else:
  for i in range(1, N+1):
    ans.append([min_idx, i])
  for i in range(N, 1, -1):
    ans.append([i, i-1])

print(len(ans))
for a in ans:
  print(*a)

Measured memory_bytes: 3064
#pragma GCC optimize("O3")
#pragma GCC optimize("O1")
#pragma GCC optimize("O2")
#pragma GCC optimize("Os")
#pragma GCC optimize("Ofast")
#pragma GCC target("avx2")
#pragma GCC optimization("unroll-loops")
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);
#define FO cout.tie(NULL);
#define FI cin.tie(NULL);
#define IN cin>>
#define OUT cout<<
#define loop(i,a,n) for(ll i=a; i<n; i++)
#define rloop(i,a,n) for(int i=a; i>=n; i--)
#define endl "\n";
#define pb push_back
#define mp make_pair
#define set_bits(a) __builtin_popcountll(a)
#define ll long long int
#define ld long double
#define vll vector<long long int>
#define pll pair<long long int, long long int>
#define mod 1000000007
#define M 998244353
ll gcd(ll a, ll b)
{
    return (b?gcd(b,a%b):a);
}
ll P(ll B, ll power, ll modulo)
{
    ll ans=1LL;
    while(power>0LL)
    {
        if(power%2LL==1LL)
        {
            ans=(ans*B)%modulo;
        }
        B=(B*B)%modulo;
        power/=2LL;
    }
    return ans;
}
bool isPrime(ll n)
{
    if(n<=1LL)
    {
        return false;
    }
    if(n<=3LL)
    {
        return true;
    }
    if(n%2==0LL || n%3==0LL)
    {
        return false;
    }
    for(ll i=5LL; (i*i)<=n; i+=6LL)
    {
        if(n%i==0LL || n%(i+2LL)==0LL)
        {
            return false;
        }
    }
    return true;
}
using namespace std;
bool sortbysec(const pair<pair<int,int>,int> &a, const pair<pair<int,int>,int> &b)
{
    return (a.first.second<b.first.second);
}
bool sortbysecll(const pll &a, const pll &b)
{
    return (a.second<b.second);
}
ll modinv(ll x, ll y, ll modulo)
{
    return ((x%modulo)*(P(y,modulo-2LL,modulo)%modulo))%modulo;
}
void vok()
{
    FAST
    FO
    FI
    // #ifndef ONLINE_JUDGE
    //     freopen("input.txt","r",stdin);
    //     freopen("output.txt","w",stdout);
    // #endif
}
int main()
{
    vok();
    int n;
    set<string> s;
    IN n;
    loop(i,0,n)
    {
        string ss;
        IN ss;
        s.insert(ss);
    }
    OUT int(s.size())<<endl
    return 0;
}

Measured memory_bytes: 19288
#include <stdio.h>
int main() {
        double r,s,f;
	double x=3.141592653589;
        
        scanf("%lf",&r);
        
            //面積
            s = r * r * x;
            //円周
            f = r * 2 * x;

            printf("%f %f\n", s, f);
        return 0;
}


Measured memory_bytes: 2048
#include <iostream>

using namespace std;

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

    int i;
    int counter = 0;
    int arr[N];
    for(i = 0; i<N; i++){
	cin >> arr[i];
    }
    
    i=0;
    
    int prev_v;
    int curr_v;

    
    while(i<N){
	if(arr[i] == i+1){
	    i ++;
	    counter += 1;
	}
	i++;

    }
    cout << counter << endl;
}


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

int main() {
	ll N,ans = 0;
    cin >> N;
    for(int i = 1; i < N; i++){
        ans += i;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
//
// Created by Sakurayama Kazuhiro on 2020/08/02.
//


#include<iostream>
#include <math.h>       /* pow */
#include <set>

using namespace std;
int main(){
    unsigned int K;
    cin >> K;

    unsigned int cnt = 0;
    unsigned int a = 7;

    std::set<unsigned long long> myset;
    bool solved = false;

    while (true){
        unsigned int aa = a % K;
        if (aa == 0) {
            solved = true;
            break;
        }
        if (myset.find(aa) != myset.end()) break;
        myset.insert(aa);
        cnt++;
        a = (unsigned int) aa*10+7;
    }

    if (solved) {
        cout << cnt+1 << endl;
    } else {
        cout << -1 << endl;
    }
    return 0;
}


Measured memory_bytes: 50468
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a.at(i);
  vector<int> b(n);
  rep(i, n) cin >> b.at(i);
  vector<int> c(n);
  rep(i, n) cin >> c.at(i);
  sort(ALL(a)); sort(ALL(b)); sort(ALL(c));

  ll ans = 0;
  for(auto nb : b){
    int ca = lower_bound(ALL(a), nb) - a.begin();
    int cc = n - (upper_bound(ALL(c), nb) - c.begin());
    ans += (ll)ca * cc;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4584
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef double D;
typedef long double LD;
typedef long long LL;
typedef pair<int,int> PII;
typedef pair<LL,LL> PLL;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> opset;
#define SZ(X) ((int)X.size())
#define ALL(I) I.begin(), I.end()
#define PB push_back
#define F first
#define S second
#define MP make_pair
#define eps 1e-12
#define MXN 200005

int L, cnt, n;

int main(){
	cin >> L;
	while((1 << n) <= L) n ++;
	printf("%d %d\n", n, __builtin_popcount(L) + 2 * (n - 1) - 1);
	for(int i = 1; i <= n - 1; i ++){
		printf("%d %d %d\n", i, i + 1, (1 << (i - 1)));
		printf("%d %d 0\n", i, i + 1);
	}
	int tp = 0;
	for(int i = n - 1; i >= 0; i --){
		if(L & (1 << i)){
			if(i < n - 1){
				printf("%d %d %d\n", i + 1, n, tp);
			}
			tp |= (1 << i);
		}
	}
	//printf("%d\n", cnt);
	//assert(cnt == __builtin_popcount(L) + 38 - (L & (1 << 19) ? 1 : 0));
	
}



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

int main()
{
  ll ans = 0;
  ll n;
  cin >> n;

  for(int i = 1; i <= n; i++){
    if(i % 3 != 0){
      if(i % 5 != 0){
        ans += i;
      }
    }
  }

  cout << ans;
  
  return 0; 
}


Measured memory_bytes: 3676
#include <stdio.h>
#include <iostream>

using namespace std;

int N;


int main(){
    
    cin>>N;
    
    string W[110];

    //あああ文字列の入力仕方わかったけどうまくいかない
    
    //Nの個数分Wiの入力
    for (int i=0;i<N;i++){
        cin>>W[i];
    }
    
    
    //judge
    //おなじ文字列がないか調べる
    //文字数を調べる
    //直前の単語のけつと単語の頭の一致を確認
    
    for (int i=0;i<N;i++){
        for (int j=i+1;j<N;j++)
            if(W[i]== W[j]){
                cout<<"No"<<endl;
                return 0;
            }
    }
    for(int i=0;i<N-1;i++){
        if(W[i][W[i].length()-1] != W[i+1][0]){
            cout<<"No"<<endl;
            return 0;
        }
        
    }
        
    cout<<"Yes"<<endl;
    return 0;
    
        
    
    
    
}



Measured memory_bytes: 256
/*jai_ganeshdeva*/

#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define pu push  //  adds the value to the last of the queue 
#define lld long long int
#define ins insert /// used in set to insert the values 
#define adv advance  /// used to increment the iterator
#define mp make_pair
#define fi first
#define se second
#define all(c) c.begin(),c.end()
#define PI 3.1415926
#define INF (lld)1e18
#define vl  vector<long long int >
#define vpl vector< pair<lld ,lld> >
#define vvl vector<vector<lld> > 
#define pll pair <lld,lld>
#define modA(cccc,bbbb ,p) (((cccc+bbbb)%p+p)%p)
#define modS(cccc,bbbb ,p) (((cccc-bbbb)%p+p)%p)
#define modM(cccc,bbbb ,p) ((((cccc%p)*(bbbb%p))%p+p)%p)

long long int modp(lld a,lld p,lld n)
{
    lld d[100];
    lld i,j,k,l;
    if(n==0) return 1;
    for(i=0;n>=1;i++)
    {
        d[i]=n%2;
        n/=2;
    }
    l=i;
    long long int e=1;
    if(d[0]==1) e*=(a%p);
    for(i=1;i<l;i++)
    {
        a*=a;
        a=a%p;
        if(d[i]==1) 
        {
            e*=a;
            e=e%p;
        }
    }
    return e%p;
}
lld modInverse(lld n, lld p) 
{ 
    return modp(n, p, p-2); 
}

lld fac[500001]; 

void getfac(lld p)
{
    fac[0] = 1; 
    for (lld i=1 ; i<=500000; i++) 
        fac[i] = fac[i-1]*i%p; 
}    

long long int nCrmodp(lld n, lld r,lld p) 
{ 
   // Base case 
   if (r==0) 
      return 1; 
     
    return (fac[n]* modInverse(fac[r], p) % p * 
            modInverse(fac[n-r], p) % p) % p; 
}



lld p1=1e9 + 7,p2=998244353;
lld l,r,mid,ans=0;
lld n,i,j,k,m,g;
lld x,y,n1,a,b=0,n2,h,z,c;


void solve()
{
    string s;
    cin>>s;
    n=s.size();
    for(i=0;i<n;i++) 
    {
        if(s[i]=='?') s[i]='D';
    }
    cout<<s;
}


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    lld t=1;
    
    //cin>>t;
    //cout<<t;
   //  getfac(p2);
    //check the value by which modulo is to be taken
    
    for(int i=0;i<t;i++)
    {
   //     cout<<"Case #"<<i+1<<": ";
                  solve();
 
        cout<<"\n";
    }
    return 0;
}

Measured memory_bytes: 3744
#include <iostream>

//3を含むか判断
bool judgeIncludeThree(int);

int main(){
	int inputedNumber; //入力される数字
	std::cin >> inputedNumber;

	//1~30までで条件に合う数字を出力
	//条件1: 3の倍数か
	//条件2: 3を含む数か
	for (int i = 1; i < inputedNumber + 1; i++)
	{
		if (i % 3 == 0)  //条件１
			std::cout << " " << i;
		else if (judgeIncludeThree(i))  //条件２
			std::cout << " " << i;
	}
	std::cout << '\n';
	return 0;
}


//3を含むか判断
//1の位から順に、3を含んでいるか調べる
bool judgeIncludeThree(int number)
{
	if (number % 10 == 3) //3を含むならtrueを返す
		return true;
	else if (number == 0)  //すべての位を調べて、3を含まなかったならfalse
		return false;
	else
		return judgeIncludeThree(number / 10); //3を含まない位なら、一つ上のけたを調べる
}



Measured memory_bytes: 3088
N,K = map(int, input().split())
stone = []
for it in input().split():
    stone.append(int(it))
import sys
cost = [sys.maxsize]*len(stone)
cost[-1]=0
for i in range(len(stone)-1, 0, -1):
    h_now = stone[i]
    cost_now = cost[i]
    
    # one jump
    for jump in range(1,K+1):
        target = i - jump
        if target < 0:
            continue
        tmp_cost = abs(stone[i] - stone[target])+cost[i]
        if cost[target] > tmp_cost:
            cost[target] = tmp_cost

print(cost[0])

Measured memory_bytes: 52448
n = gets.to_i

a = []
n.times {a << gets.to_i}
a.sort!

m = n/2
if n.odd?
    x = -2 * a[0, m].inject(0, :+) + a[m] + a[m + 1] + 2 * a[m + 2, m - 1].inject(0, :+)
    y = -2 * a[0, m - 1].inject(0, :+) - a[m - 1] - a[m] + 2 * a[m + 1, m].inject(0, :+)
    puts x > y ? x : y
else
    puts -2 * a[0, m - 1].inject(0, :+) - a[m - 1] + a[n/2] + 2 * a[m + 1, m - 1].inject(0, :+)
end

Measured memory_bytes: 4016
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define ff first
#define ss second
#define quick                    \
    ios::sync_with_stdio(false); \
    cin.tie(0);
#define time cerr << (0.1 * clock()) / CLOCKS_PER_SEC << endl;
#define mod 1000000007
typedef long long ll;
typedef pair<ll, ll> pl;
#define forn(n) for (ll i = 0; i < ll(n); i++)

void solve() {
    ll n;
    cin >> n;
    if(n%10 == 3){
        cout << "bon\n";
    }
    else if(n%10 <= 1 or n%10 == 6 or n%10 == 8){
        cout << "pon\n";
    }
    else{
        cout << "hon\n";
    }
}

int main() {
    quick;
    solve();
    // ll t;
    // cin >> t;
    // while (t--) {
    //     solve();
    // }
}

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

int main() {
    int n, m, x;
    cin >> n >> m >> x;
    vector<int> c(n);
    vector<vector<int>> a(n, vector<int>(m));
    rep(i,n){
        cin >> c[i];
        rep(j, m) cin >> a[i][j];
    }
    int ans = 1e9;
    for (int bit = 0; bit < (1 << n); bit++) {
        vector<int> score(m, 0);
        int price = 0;
        for (int i = 0; i < n; i++) {
            if(bit & (1<<i)){
                for (int j = 0; j < m; j++){
                    score[j] += a[i][j];
                }
                price += c[i];
            }
        }
        bool can = true;
        rep(i, m) {
            if(score[i] < x){
                can = false;
            }
        }
        if(can){
            ans = min(ans, price);
        }
    }
    cout << (ans == 1e9 ? -1 : ans) << endl;
}

Measured memory_bytes: 3596
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
struct job{
  int va, d;  
};
bool compare(job a, job b){return a.d < b.d;}
int main()
{
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n, m;
    vector<job>v;
    job cu;
    cin >> n >> m;
    for(int i = 0; i < n; i++)
    {
        cin >> cu.d >> cu.va;
            v.push_back(cu);
    }
    sort(v.begin(), v.end(), compare);
    /*for(int i = 0; i < v.size(); i++)
        cout << v[i].va << ' ' << v[i].d << '\n';*/
    long long int money=0;
    priority_queue<int>pq;
    for(int i = 1, j = 0; i <= m ; i++)
    {
        while(j < v.size() && v[j].d==i)
        {
            pq.push(v[j].va);
            j++;
        }
        if(!pq.empty())
        {
            money+=pq.top();
            pq.pop();
        }
    }
    cout << money << '\n';
}

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

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

  // 制約が1 <= N <= 100なので、6パターンの出力しかない
  if (N >= 64) {
    cout << 64 << endl;
  } else if (32 <= N  && N < 64) {
    cout << 32 << endl;
  } else if (16 <= N  && N < 32) {
    cout << 16 << endl;
  } else if (8 <= N  && N < 16) {
    cout << 8 << endl;
  } else if (4 <= N  && N < 8) {
    cout << 4 << endl;
  } else if (2 <= N  && N < 4) {
    cout << 2 << endl;
  } else {  // N == 1
    cout << 1 << endl;
  }

  return 0;
}


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

using namespace std;

typedef long long int lli;

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

    lli l, r;

    cin >> l >> r;

    if (r-l+1 >= 2019) {
        cout << 0 << endl;
        return 0;
    }

    lli ans = 300000;
    for (lli i=l; i<=r; i++) {
        for (lli j=i+1; j<=r; j++) {
            ans = min(ans, (i*j)%2019LL);
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
def main():
    from collections import defaultdict
    import sys
    sys.setrecursionlimit(1000000)
    n, *rem = map(int, open(0).read().split())
    t = 3 * (n - 1)
    abc = rem[:t]
    q, k = rem[t], rem[t + 1]
    xy = rem[t + 2:]

    m = [[] for _ in range(n + 1)]
    dist = defaultdict(dict)
    for a, b, c in zip(*[iter(abc)] * 3):
        m[a].append(b)
        m[b].append(a)

        dist[a].update({b: c})
        dist[b].update({a: c})

    vis = [False] * (n + 1)
    cost = [0] * (n + 1)
    vis[k] = True

    def dfs(frm, to):
        if vis[to]:
            return
        vis[to] = True
        cost[to] = cost[frm] + dist[frm][to]
        frm = to
        for to in m[frm]:
            dfs(frm, to)

    frm = k
    for to in m[frm]:
        dfs(frm, to)

    tmp = []
    for x, y in zip(*[iter(xy)] * 2):
        tmp.append(cost[x] + cost[y])

    ans = "\n".join(map(str, tmp))
    print(ans)


if __name__ == '__main__':
    main()


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

int main(){
    int N; cin >> N;
    vector<int> vecA(N); for(int i=0; i<N; i++){ cin >> vecA[i]; }
    
    std::sort(vecA.begin(), vecA.end(), std::greater<int>());
    
    int Alice=0;
    int Bob  =0;
    for(int i=0; i<vecA.size(); i+=2){ Alice += vecA[i]; }
    for(int i=1; i<vecA.size(); i+=2){ Bob   += vecA[i]; }
    
    cout << (Alice-Bob);
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i < n; i ++)
#define rep1(i, n) for (int i=1; i <= n; i ++)
using namespace std;

typedef pair<int, int> P;

#define N_MAX 100000



int main() {
  int N;
  cin >> N;
  int ans = 0;

  rep(i, N) {
    int a;
    cin >> a;
    ans ^= a;
  }
  if (ans != 0) cout << "No" << endl;
  else cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 256