akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<map>
#include<string>
#include<utility>
#include<algorithm>
using namespace std;
bool comp(const string& ls, const string& rs){
  if(ls.length() < rs.length())
    return true;
  else if(ls.length() > rs.length())
    return false;
  else
    return ls < rs;
}
int main(){
  int n,num;
  string str;
  map<string,int> m;
  cin >> n;
  string strs[n];
  for(int i = 0 ; i < n ; i++){
    cin >> str;
    cin >> num;
    m[str] += num;
  }
  int j = 0;
  for(auto itr = m.begin(); itr != m.end(); itr++)
    strs[j++] = itr->first;
  sort(strs,strs+j,comp);
  for(int i = 0 ; i < j ; i++)
    cout << strs[i] << " " << m[strs[i]] << endl;
}



Measured memory_bytes: 3208
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(void) {
	int n,x;
	while (cin >> n >> x, n||x) {
		int res = 0;
		for (int i = 1; i < n+1; ++i) {
			for (int j = i+1; j < n+1; ++j) {
				for (int k = j+1; k < n+1; ++k) {
					if (i+j+k == x) {
						++res;
					}
				}
			}
		}
		cout << res << endl;
	}
	return 0;
}



Measured memory_bytes: 3016
#include<stdio.h>
int main(void){
  int a[5];
  int num[5];
  int i;
  int max = 0;
  int sum = 0;
  int soezi;
  
  scanf("%d %d %d %d %d", &a[0], &a[1], &a[2], &a[3], &a[4]);
  
  for(i = 0; i < 5; i++){
    num[i] = (130 - a[i]) % 10;
    if(max < num[i]){
      max = num[i];
      soezi = i;
    }
  }
  
  for(i = 0; i < 5; i++){
    if(i == soezi){
      sum += a[i];
    }
    else{
      sum += num[i] + a[i];
    }
  }
  
  printf("%d\n", sum);
  return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <ctype.h>

int main(void) {
	char s[12];
	int ans = 0, count;

  if(scanf("%s", s) == 1);

	for(int i = 0; i < strlen(s); i++) {
		count = 0;
		for(int j = i; j < strlen(s) + 1; j++) {
			if(s[j] != 'A' && s[j] != 'C' && s[j] != 'G' && s[j] != 'T') {
				if(ans < count) {
					ans = count;
				}
				break;
			}
			count++;
		}
	}

  printf("%d", ans);

  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
 
#define endl '\n'
#define fi first
#define se second
#define MOD(n,k) ( ( ((n) % (k)) + (k) ) % (k))
#define forn(i,n) for (int i = 0; i < n; i++)
#define forr(i,a,b) for (int i = a; i <= b; i++)
#define all(v) v.begin(), v.end()
#define pb(x) push_back(x)
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;

const int MX = 200005;
int n, m, k, res;
ll a[MX], b[MX];

int main () {
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	cin >> n >> m >> k;
	
	forn (i, n) {
		cin >> a[i];
		if (i) a[i] += a[i - 1]; 
	}

	forn (i, m) {
		cin >> b[i];
		if (i) b[i] += b[i - 1];
		if (b[i] <= k) res = max(res, i + 1);
	}

	forn (i, n) {
		if (a[i] > k) break;
		int j = upper_bound(b, b + m, k - a[i]) - b;
		res = max(res, 1 + i + j);
	}

	cout << res << endl;

	return 0;
}


Measured memory_bytes: 6776
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define bit(n,m)(((n)>>(m))&1)
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}
ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
//#define MOD 998244353
#define MOD 1000000007
#define invp(a,p)pom(a,p-2,p)

int main(){
	int a,b,c,k;
	scanf("%d%d%d%d",&a,&b,&c,&k);
	int cnt=0;
	while(a>=b)b*=2,cnt++;
	while(b>=c)c*=2,cnt++;
	puts(cnt<=k?"Yes":"No");
}

Measured memory_bytes: 1644
#include <bits/stdc++.h>
using namespace std;
struct person{
  bool a=false;
  bool b=false;
  bool c=false;
};
int main(){
  int n,x,y,z;
  int num=0;
  cin >>n>>x;
  person per[n+1];
  int xper[101];
  for(int i=1;i<=x;i++){
    cin >>xper[i];
  }
  cin >>y;
  int yper[101];
  for(int i=1;i<=y;i++){
    cin >>yper[i];
  }
  cin >>z;
  int zper[101];
  for(int i=1;i<=z;i++){
    cin >>zper[i];
  }
  for(int i=1;i<=x;i++){
    per[xper[i]].a=true;
  }
  for(int i=1;i<=y;i++){
    per[yper[i]].b=true;
  }
  for(int i=1;i<=z;i++){
    per[zper[i]].c=true;
  }
  for(int i=1;i<=n;i++){
    if((per[i].c==true)&&(per[i].b==false)&&(per[i].a==true))num++;
  }
  cout << z-num <<endl;
  return 0;
}

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

int main() {
  int N;
  cin >> N;
  int M;
  cin >> M;
  
  int p[M];
  string s[M];
  for (int i = 0; i < M; i++) {
    cin >> p[i] >> s[i];
  }
  
  int ans[N];
  int pen[N];
  int pf[N];
  
  for (int i = 0; i < N; i++) {
    ans[i] = 0; 
    pf[i] = 0;
    pen[i] = 0;
  }
  
  for (int i = 0; i < M; i++) {
    if (s[i] == "AC") {ans[p[i]-1] = 1; 
                       pen[p[i]-1] = pf[p[i]-1];}
    else if (s[i] == "WA" && ans[p[i]-1] == 0) {pf[p[i]-1]++;}
  }
  
  int outa = 0;
  int outp = 0;
  
  for (int i = 0; i < N; i++) {
    outa = outa + ans[i];
    outp = outp + pen[i];
  }
  
  cout << outa << ' ' << outp << endl;
  
  
}


Measured memory_bytes: 7296
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

void Main() {
  string s;
  cin >> s;
  if(s[0]!='A') {
    pr("WA");
    return;
  }
  bool f=0;
  REP(i,2,(int)s.size()-1) {
    if(s[i]=='C') f=1;
  }
  if(!f) {
    pr("WA");
    return;
  }
  int cnt=0;
  rep(i,s.size()) {
    if(isupper(s[i])) cnt++;
  }
  if(cnt==2) pr("AC");
  else pr("WA");
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<algorithm>
#include<stdint.h>
#include<vector>
#include<deque>
#include<stack>
#include<string>
#include<cstring>
#include<time.h>
#include<array>
#include<iomanip>
#include<list>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<random>
#include<bitset>
#include <queue>
#include <map>


using namespace std;
using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using ldouble = long double;


//BDD,ZDD,kdtree, bdtree,bicalc, bolonoy, doloney,chinesemod,segmenttree,daikusutora, saidairyuu, 2bugurahu, heirokenshutu, topologicalsort, kyourenketuseibun


#define PRI(s) cout << s << endl
#define PRIY PRI("Yes")
#define PRIN PRI("No")

int ctoi(char c) {
	switch (c)
	{
	case '0': return 0;
	case '1': return 1;
	case '2': return 2;
	case '3': return 3;
	case '4': return 4;
	case '5': return 5;
	case '6': return 6;
	case '7': return 7;
	case '8': return 8;
	case '9': return 9;
	default:
		cout << "ERR_ctoi" << endl;
		return -1;
	}
}
int main() {
	int x;
	cin >> x;
	PRI((double)x * 2.0 *3.1415926535);
	return 0;
}

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

int main(){
  int x[10005], i, end;
  for(i=0; i<10005; i++){
    cin>>x[i];
    if (x[i] ==0){
      end = i;
      break;
    }
  }
  for(i=0; i<end; i++){
    cout<<"Case "<<i+1<<": "<<x[i]<<endl;
  }
  return 0;
}


Measured memory_bytes: 3004
import sys
sys.setrecursionlimit(10 ** 9)
input = sys.stdin.readline
from itertools import permutations,  combinations, accumulate
from functools import *
from collections import deque, defaultdict, Counter
from heapq import heapify, heappop, heappush, heappushpop

INF = float('inf')
NIL = - 1


N = input().rstrip()
n_digits = list(map(int, list(N)))

print('Yes' if 7 in n_digits else 'No')


Measured memory_bytes: 9568
#include <stdio.h>
#include <stdlib.h>
int main()
{
    int N,a,b;
    scanf("%d",&N);
    if(10<=N&&N<=99)
    {
    a=N/10;
    b=N%10;
    if(a==9||b==9){printf("Yes");}
    else{printf("No");}
            }
    return 0;
}


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

ll wa(ll X){
  ll res=0;
  while(X>0){
    res+=X%10;
    X/=10;
  }
  return res;
}

ll f(ll X){
  double MI=1.0*X/wa(X);
  ll mi=X,k=1;
  string S=to_string(X);
  reverse(S.begin(),S.end());
  rep(i,16){
    int num;
    if(i<S.length()){
      num=S[i]-'0';
      X-=num*k;
    }else{
      num=1;
    }
    for(int j=num+1;j<=9;j++){
      X+=j*k;
      if(1.0*X/wa(X)<MI){
        MI=1.0*X/wa(X);
        mi=X;
      }
      X-=j*k;
    }
    X+=9*k;
    k*=10;
  }
  return mi;
}

int main(){
  int K; cin>>K;
  ll x=1;
  rep(i,K){
    cout<<x<<endl;
    x=f(x+1);
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define SZ(x) ((int)(x).size())
#define debug(x) cerr << #x << ": " << x << '\n'
#define INF 999999999
typedef long long int Int;
using ll = long long;
using VI = vector<int>;

int main(){
  string s;cin >> s;
  cout << s[0] << s.size()-2 << s[s.size()-1] << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
int sumOfDigits(int n) {
	int sum = 0;
	while (n > 0) {
		sum += n % 10;
		n /= 10;
	}
	return sum;
}

int main() {
	int n;
	cin >> n;
	int  ans = 1e9;
	for (int a = 1; a <= n/2; a++) {
		int b = n - a;
		ans = min(ans, sumOfDigits(a) + sumOfDigits(b));
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<algorithm>
#include<map>
#include<set>
#include<cmath>
#include<iomanip>
#include<stack>
#include<string.h>
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define sz(a) (int)a.size()
using namespace std;

int main() {
	ll n;
	cin >> n;
	vector<char> ans;
	while (n > 0) {

		if ((n % (ll)26) != 0) {
          int a=n % (ll)26;
			ans.pb('a' + a-1);
          n/=(ll)26;
		}
		else{
          ans.push_back('z');
		n /= (ll)26;
          n--;
        }
	}
	reverse(ans.begin(), ans.end());
	rep(i, sz(ans)) cout << ans[i];
	cout << endl;
}


Measured memory_bytes: 3628
#include<cstdio>
#include<algorithm>
using namespace std;
const int maxn = 200000 + 7;
int c1[maxn],c2[maxn];
int max1,max2,mac1,mac2,ans;
int k1,k2;
int main() {
    int n,x;
    scanf("%d",&n);
    for(int i = 1; i <= n; i++) {
        scanf("%d",&x);
        if(i % 2 == 1) c1[x]++;
        else c2[x]++;
    }
    for(int i = 1; i <= 100000; i++) {
        if(max1 < c1[i]) {
            mac1 = max1; k1 = i;
            max1 = c1[i];
        }else if(mac1 <= c1[i]) mac1 = c1[i];
        if(max2 < c2[i]) {
            mac2 = max2; k2 = i;
            max2 = c2[i];
        }else if(mac2 <= c2[i]) mac2 = c2[i];
    }
    if(k1 == k2) ans = max(max1 + mac2, max2 + mac1);
    else ans = max1 + max2;
    printf("%d\n",n - ans);
    return 0;
}

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

A = [int(input()) for _ in range(N)]
A_sort = sorted(A, reverse=True)

A_max = A_sort[0]
A_max_ = A_sort[1]

for i in range(N):
    if A[i] != A_max:
        print(A_max)
    else:
        print(A_max_)



Measured memory_bytes: 14176
#include <algorithm>
#include <iostream>
#include <string>
#include <cstdio>
#include <cstring>
#include <cctype>

using namespace std;

int main(void) {

    char cards[201];
    int N;
    while (true) {
        cin >> cards;
        if (cards[0] == '-') { break; }
        cin >> N;

        int total = 0;
        for (int _ = 0, n; _ < N; ++_) {
            cin >> n;
            total += n;
        }
        size_t len = strlen(cards);
        rotate(cards, cards + total % len, cards + len);

        printf("%s\n", cards);
    }

    return 0;
}

Measured memory_bytes: 1140
package main

import (
	"fmt"
	"math"
)

func main() {
	var X, N int
	const zei = 1.08

	fmt.Scan(&N)

	X = int(math.Ceil(float64(N)/zei))

	if N == int(math.Trunc(float64(X) * zei)) {
		fmt.Println(X)
	} else {
		fmt.Println(":(")
	}
}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;

int main() {
    int y, m, d;
    char c1, c2;
    cin >> y >> c1 >> m >> c2 >> d;
    int flag = 0;

    if(4 < m) {
        flag = 1;
    }

    if(flag == 0) {
        cout << "Heisei";
    }
    else {
        cout << "TBD";
    }
    
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
import Control.Applicative
import Control.Monad
import Control.Monad.ST
import Data.Functor
import Data.Function
import Data.Monoid
import Data.Maybe
import Data.List
import qualified Data.Foldable as Foldable
import qualified Data.Set as Set
import qualified Data.Sequence as Sequence
import Data.List.Split
import Data.Bits
import Data.Char
import Data.Ix
import Data.Ratio
import Data.Ord
import Data.Tuple
--import Data.Array
import Data.Array.IArray
--import Data.Array.Unboxed
import Data.Array.MArray
import Data.Array.IO
import Data.Array.ST
import Data.IORef
import Data.STRef
-- import System.IO.Unsafe
 
readInt = read :: String -> Int
readInteger = read :: String -> Integer
readDouble = read :: String -> Double
getInt = readLn :: IO Int
getInts = map readInt . words <$> getLine
getInteger = readLn :: IO Integer
getIntegers = map readInteger . words <$> getLine
getDouble = readLn :: IO Double
sjoin :: (Show a) => [a] -> String
sjoin = unwords . map show
cond :: a -> a -> Bool -> a
cond t f c = if c then t else f
apply2 :: (a -> a -> b) -> [a] -> b
apply2 f [x,y] = f x y
apply3 :: (a -> a -> a -> b) -> [a] -> b
apply3 f [x,y,z] = f x y z
apply4 :: (a -> a -> a -> a -> b) -> [a] -> b
apply4 f [x,y,z,w] = f x y z w
fnBin :: (b -> c -> d) -> (a -> b) -> (a -> c) -> a -> d
fnBin op f g x = op (f x) $ g x
fnTuple :: (a -> b, a -> c) -> a -> (b, c)
fnTuple (f,g) a = (f a, g a)
replace :: (Eq a) => a -> a -> [a] -> [a]
replace x y = map (\z -> if z==x then y else z)
modifyArray :: (Ix i, MArray a e m) => a i e -> i -> (e -> e) -> m ()
modifyArray arr ix f = readArray arr ix >>= writeArray arr ix . f
dictCompare :: [a -> a -> Ordering] -> a -> a -> Ordering
dictCompare [] _ _ = EQ
dictCompare (f:fs) x y = let c = f x y in if c==EQ then dictCompare fs x y else c
binMap :: (a -> a -> b) -> [a] -> [b]
binMap f (x:xs@(y:_)) = f x y : binMap f xs
binMap _ _ = []
splitRec :: Int -> [a] -> [[a]]
splitRec _ [] = []
splitRec n xs = let (y,ys) = splitAt n xs in y : splitRec n ys
infixl 7 `divCeil`
divCeil :: Integral a => a -> a -> a
x `divCeil` y = (x+y-1) `div` y
-- end of templete


main = do
    [n,h] <- getInts
    xs <- map (apply2 (,)) <$> replicateM n getInts
    print $ let da = maximum $ map fst xs in let fd = scanl (-) h $ sortBy (flip compare) $ filter (>=da) $ map snd xs in let r = last fd in if r>0 then length fd - 1 + r `divCeil` da else length $ filter (>0) fd


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

int main() {
    int K;
    cin>>K;
    queue<long> que;
    que.push(1);
    que.push(2);
    que.push(3);
    que.push(4);
    que.push(5);
    que.push(6);
    que.push(7);
    que.push(8);
    que.push(9);
    int num = 0;
    long state;
    long ans;
    int ten;
    while(!que.empty()){
        state = que.front();que.pop();
        num++;
        if(num==K){
            ans = state;
            break;
        }
        ten = state % 10;
        if(ten==0){
            que.push(state*10+(ten));
            que.push(state*10+(ten+1));
        }
        else if(ten==9){
            que.push(state*10+(ten-1));
            que.push(state*10+(ten));
        }
        else{
            que.push(state*10+(ten-1));
            que.push(state*10+(ten));
            que.push(state*10+(ten+1));
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <algorithm>
using i64 = long long;

int main() {
    constexpr i64 mod = 1000000007;
    int n;
    std::cin >> n;
    if (n <= 2) {
        std::cout << 0 << std::endl;
        return 0;
    }

    i64 ret = 0;
    std::vector<i64> v(n + 1);
    v[n] = 1;
    for (int i = 0; i < n; i++) {
        for (int j = 3; j <= n; j++) ret = (ret + v[j]) % mod;
        std::vector<i64> next(n + 1);
        i64 t = v[n];
        for (int i = n - 3; i >= 0; i--) {
            next[i] = t;
            t = (t + v[i + 2]) % mod;
        }
        std::swap(v, next);
    }

    std::cout << ret << std::endl;

    return 0;
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9+7;
char s[100005];
int dp[100005][13];
int main(){
    scanf("%s",s+1);
    int n=strlen(s+1);
    memset(dp,0,sizeof(dp));
    dp[0][0]=1;
    for(int i=1;i<=n;i++){
    	if(s[i]=='?'){
    		for(int k=0;k<10;k++){
	    		for(int j=0;j<13;j++){
	    			dp[i][(j*10+k)%13]=(dp[i][(j*10+k)%13]+dp[i-1][j])%mod;
				}	
			}
		}
		else{
			int x=s[i]-'0';
			for(int j=0;j<13;j++){
    			dp[i][(j*10+x)%13]=(dp[i][(j*10+x)%13]+dp[i-1][j])%mod;
			}
		}
	}
	printf("%d\n",dp[n][5]);
}


Measured memory_bytes: 5376
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <iostream>
using namespace std;
#define ll long long

int main() {
  string s;
  cin >> s;
  int N = 1 << 3;  // 1000  この前は **111**
  int mask, i;

  int sum = 0;
  for (mask = 0; mask < N; mask++) {
    sum = (int)s[0] - (int)'0';

    for (i = 0; i < 3; i++) {
      if ((mask >> i) & 1) {
        sum += s[i + 1] - '0';
      } else {
        sum -= s[i + 1] - '0';
      }
    }

    if (sum == 7) {
      cout << s[0];
      for (int i = 0; i < 3; i++) {
        if ((mask >> i) & 1)
          cout << '+';
        else
          cout << '-';
        cout << s[i + 1];
      }
      cout << "=7" << endl;
      return 0;
    }
  }
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int n,a[100001],mycount,output;
bool flag[100001];

int fun(int i){
	if(flag[i]==true) return -1;
	flag[i]=true;
	int mynext;
	mynext=a[i];
	mycount++;
	if(mynext==2) return mycount;
	else fun(mynext);
}

int main(){
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i+1];
	}
	output=fun(1);
	cout<<output<<endl;
	return 0;
}

Measured memory_bytes: 768
n=int(input())
s=list(input())
e=s.count("E")
w=n-e
ans=e
nume=0
numw=0
for i in range(n):
    if s[i]=="E":
        nume+=1
    else:
        numw+=1
    ans=min(ans,numw+e-nume)
print(ans)


Measured memory_bytes: 11580
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0; i<(n); i++)
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; }
int main(){
    ll n,m,v,p; cin>>n>>m>>v>>p;
    vector<ll> a(n);
    rep(i,n) cin>>a[i];
    sort(a.begin(),a.end(),greater<ll>());
    vector<ll> tmp={};
    ll tmp_sum=0;
    ll res=p;
    for(ll i=p; i<n; i++){
        tmp.push_back(a[i-1]);
        tmp_sum+=a[i-1];
        if(i-p+1<=n-v){
            if(a[p-1]-a[i]<=m) res++;
        }else{
            ll thre=a[i]+m;
            ll add=v-n+i-p+1;
            if(tmp[0]>thre) break;
            ll sum=thre*tmp.size()-tmp_sum;
            if(sum>=add*m) res++;
            else break;
        }
    }
    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 2168
N = int(input())
ret = N
lst1 = list(map(int, input().split()))
lst2 = list(map(int, input().split()))

for x in range(N):
    n = sum(lst1[: N - x]) + sum(lst2[N - x - 1 :])
    ret = max(ret, n)
print(ret)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define SZ(v) int((v).size())
#define ALL(vec) begin(vec), end(vec)
typedef long long i64;
template<typename T> inline bool uax(T &x, T y) {return (y > x) ? x = y, true : false;}
template<typename T> inline bool uin(T &x, T y) {return (y < x) ? x = y, true : false;}
#ifdef Rahul
# define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); \
  stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
#else
# define error(...) 42;
#endif
string to_string(char c) { return "'" + string(1, c) + "'";}
string to_string(string s) { return '"' + s + '"';}
string to_string(const char* s) { return to_string((string) s);}
template<typename A> string to_string(A);
template<typename A, typename B> string to_string(pair<A, B> p){
  return "(" + to_string(p.first) + ": " + to_string(p.second) + ")";}
template<typename A> string to_string(A v) {bool f = false; string r = "{"; 
  for (auto x: v) {if (f) r += ", "; r += to_string(x); f = true;} return r += "}";}
template<typename A> string to_string(vector<vector<A>> v) {string r; 
  for (auto x: v) r += "\n" + to_string(x); return r;}
int Nerr;
template<typename A> string to_string(A *p) {return to_string(vector<A>(p, p + Nerr));}
void err(istream_iterator<string>) { cerr << endl; }
template<typename T,typename... Args> void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " =: " << to_string(a) << "; "; err(++it, args...); }
template<typename T> void kek(T ans) {cout << ans << endl; exit(0);}
#define Lu(...) [&] (auto &&u) { return __VA_ARGS__; }
#define Luv(...) [&] (auto &&u, auto &&v) { return __VA_ARGS__; }
int const MOD = 1e9 + 7;
i64 const INF = 1e18 + 42;
/***********************************************************************/

int32_t main() {
  cin.tie(nullptr) -> sync_with_stdio(false);
  
  int x, y, a, b, c;
  cin >> x >> y >> a >> b >> c;
  vector<i64> p(a), q(b), r(c);
  for (auto &x : p) cin >> x;
  for (auto &x : q) cin >> x;
  for (auto &x : r) cin >> x;
  sort(ALL(p));
  sort(ALL(q));
  sort(ALL(r));
  reverse(ALL(p));
  reverse(ALL(q));
  reverse(ALL(r));
  p.resize(x);
  q.resize(y);
  i64 ans = 0;
  ans += accumulate(ALL(p), 0LL);
  ans += accumulate(ALL(q), 0LL);
  multiset<i64> A(ALL(p)), B(ALL(q));
  for (int i = 0; i < c; ++i) {
    if (*A.begin() > *B.begin()) swap(A, B);
    if (r[i] > *A.begin()) {
      ans -= *A.begin();
      A.erase(A.begin());
      A.insert(r[i]);
      ans += r[i];
    } else {
      break;
    }
  }
  kek(ans);
}


Measured memory_bytes: 11008
#include <iostream>
#include <vector>
#include <algorithm>
#define f first
#define s second
#define pb push_back
#define ENDL '\n'
#define all(a) begin(a),end(a)
#define sz(a) (int)(a.size())
#define deb(a) cout << #a << " = " << a << ENDL;
#define fore(i, a, b) for(int i(a), ThkMk(b); i < ThkMk; ++i)
#define _ ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

using namespace std;

typedef long long lli;
typedef long double ld;
typedef pair<lli, lli> ii;


int main()
{   _
    lli n, m, k; cin >> n >> m >> k;
    vector<lli> a(n);
    cin >> a[0];
    fore(i, 1, n) {
        cin >> a[i];
        a[i] += a[i - 1];
    }
    vector<lli> b(m);
    cin >> b[0];
    fore(i, 1, m) {
        cin >> b[i];
        b[i] += b[i - 1];
    }
    lli cnt = 0;
    lli cur = 0;
    int ans = 0;
    fore(i, 0, n + 1) {
        cnt = (i == 0 ? 0 : a[i-1]);
        if(cnt > k) break;
        lli rem = k - cnt;
        int pos = upper_bound(all(b), rem) - b.begin();
        ans = max(ans, i + pos);
    }
    cout << ans << ENDL;
    return 0;
}


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

int cost[200][200];
signed main(){
	int n,m,s,g1,g2;
	while(scanf("%lld%lld%lld%lld%lld",&n,&m,&s,&g1,&g2),n){
		s--;g1--;g2--;
		rep(i,n)rep(j,n){
			cost[i][j]=LLONG_MAX/3;
		}
		rep(i,n)cost[i][i]=0;
		rep(i,m){
			int b1,b2,c;scanf("%lld%lld%lld",&b1,&b2,&c);b1--;b2--;
			cost[b1][b2]=c;
		}
		rep(k,n)rep(i,n)rep(j,n){
			cost[i][j]=min(cost[i][j],cost[i][k]+cost[k][j]);
		}
		int Min=LLONG_MAX;
		rep(i,n){
			Min=min(Min,cost[s][i]+cost[i][g1]+cost[i][g2]);
		}
		printf("%lld\n",Min);
	}
}

Measured memory_bytes: 3240
#include<iostream>
#include<vector>
#include<cmath>
#include<string>
#include<algorithm>
#include<map>
#include<utility>
#include<cstdio>
#include <bits/stdc++.h>

using namespace std;

typedef pair<long long,bool> Pair;
const long long INF = 1LL<<60;

int main(){

long long N,M;
long long cnt = 0;
long long sum = 0;

cin >> N >> M;

vector<long long> A(N);

for(long long i = 0;i < N;++i){
    
    cin >> A[i];
    sum+=A[i];

}

for(long long i = 0;i < N;++i){
    
    if( 4*M*A[i] >= sum) cnt++;

}


if(M <= cnt) cout << "Yes" << endl;
else cout << "No" << endl;

return 0;

}   


Measured memory_bytes: 256
n, t = map(int, input().split())
a = list(map(int, input().split()))

mini = 10**9+1
diff = 0
ans = 1
for i in range(n):
    if a[i] <= mini:
        mini = a[i]

    if diff == a[i] - mini:
        ans += 1
    elif diff < a[i] - mini:
        ans = 1
        diff = a[i] - mini
print(ans)


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


int main() {
  vector<int> a(20000);
  vector<string> op(20000);
  vector<int> b(20000);
  
  bool ans = true;
  int i = 0;
  while(ans){
    cin >> a.at(i);
    cin >> op.at(i);
    cin >> b.at(i);
    
    if(op.at(i)=="+"){
      cout << a.at(i)+b.at(i) << endl;
    }
    if(op.at(i)=="-"){
      cout << a.at(i)-b.at(i) << endl;
    }
    if(op.at(i)=="*"){
      cout << a.at(i)*b.at(i) << endl;
    }
    if(op.at(i)=="/"){
      cout << a.at(i)/b.at(i) << endl;
    }
    if(op.at(i)=="?"){
      ans = false;
    }
    i++;
  }
  
}


Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (int)(k); i < (int)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
#define D10 fixed<<setprecision(10)
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1000000007;
const int INF = MOD + 1;
const ld EPS = 1e-12;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }

/*--------------------template--------------------*/

vi right(vi& v)
{
	vi res(8);
	REP(i, 4)
	{
		res[i] = v[(i + 3) % 4];
		res[i + 4] = v[(i + 3) % 4 + 4];
	}
	return res;
}

vi forward(vi& v)
{
	vi res(v);
	res[0] = v[3];
	res[1] = v[2];
	res[2] = v[6];
	res[3] = v[7];
	res[4] = v[0];
	res[5] = v[1];
	res[6] = v[5];
	res[7] = v[4];
	return res;
}

int main()
{
	string s[8];
	while (cin >> s[0])
	{
		REP(i, 7) cin >> s[i + 1];
		map<string, int> mp;
		REP(i, 8) mp[s[i]]++;
		vi v;
		int t = 0;
		for (auto i : mp)
		{
			REP(j, i.second) v.push_back(t);
			t++;
		}
		sort(ALL(v));
		set<vi> st;
		ll cnt = 0;
		do
		{
			if (st.count(v)) continue;
			cnt++;
			st.insert(v);
			vi tv = v;
			queue<vi> que;
			que.push(v);
			while (!que.empty())
			{
				vi tmp = que.front();
				que.pop();
				auto r = right(tmp);
				auto f = forward(tmp);
				if (!st.count(r))
				{
					st.insert(r);
					que.push(r);
				}
				if (!st.count(f))
				{
					st.insert(f);
					que.push(f);
				}
			}
		} while (next_permutation(ALL(v)));
		cout << cnt << endl;
	}
	return 0;
}

Measured memory_bytes: 7580
#include <stdio.h>
#include <iostream>
#include <string>
using namespace std;

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

  for(int j = 0; j < N; j++){
    for(int i = 0; i < S.size(); i++){
      if(S.at(i) == 'Z'){
        S.at(i) = 'A';
      } else{
      char c = S.at(i);
      c++;
      S.at(i) = c;
      }
    }
  }
  cout << S << endl;

  return 0;
}

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

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define fst first
#define snd second
#define pb push_back
#define ALL(x) x.begin(),x.end()
#define EPS (1e-9)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

bool LT(double a,double b) { return !equals(a,b) && a < b; }
bool LTE(double a,double b) { return equals(a,b) || a < b; }

const string YES = "";
const string NO  = "";

typedef long long ll;

void solve() {

}

int main() {
  int N,M;
  cin >> N >> M;
  vector<int> A(N);
  int sum = 0;
  rep(i,N) { cin >> A[i]; sum += A[i]; }
  int cnt = 0;
  rep(i,N) {
    if( A[i] * 4 * M >= sum ) ++cnt;
  }
  if( cnt >= M ) puts("Yes");
  else puts("No");
			     
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int a = scanner.nextInt();
        int b = scanner.nextInt();

        String judge = a*b % 2 == 0 ? "Even" : "Odd";
        System.out.println(judge);
    }
}

Measured memory_bytes: 21332
N = int(input())
P = [int(x) - 1 for x in input().split()]
A = [0] * N
B = [0] * N
D = [0] * N
for i, p in enumerate(P):
  D[p] = i
for i in range(P[0] + 1, N):
  if D[i] > D[i - 1]:
    B[i] = B[i - 1] - 1
    A[i] = D[i] - B[i]
  else:
    A[i] = A[i - 1] + 1
    B[i] = D[i] - A[i]
for i in range(P[0] - 1, -1, -1):
  if D[i] > D[i + 1]:
    A[i] = A[i + 1] - 1
    B[i] = D[i] - A[i]
  else:
    B[i] = B[i + 1] + 1
    A[i] = D[i] - B[i]
_a = 1 - A[0]
_b = 1 - B[-1]
print(' '.join([str(a + _a) for a in A]))
print(' '.join([str(b + _b) for b in B]))

Measured memory_bytes: 7952
# ABC129C

def fib(m):
    if m < 0:
        return 0
    elif m == 0 or m == 1:
        return 1
    elif m == 2:
        return 2
    else:
        a, b = 1, 1
        for i in range(m - 1):
            a, b = b, a + b
        return b
#
n, m = map(int, input().split())
ans = 1
begin = 0
for i in range(m):
    a = int(input())
    end = a - 1 - begin
    #print("@", begin, end)
    begin = a+1
    ans = ans * (fib(end) % 1000000007) % 1000000007
#print("#", begin, end)
end = n - begin
ans = ans * (fib(end) % 1000000007) % 1000000007
print(ans)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,i,p;
  string s;
  cin>>n;
  vector<tuple<string,int,int>> t(n);
  for(i=0;i<n;i++){
    cin>>s>>p;
    t.at(i)=make_tuple(s,-p,i+1);
  }
  sort(t.begin(),t.end());
  for(auto z:t) cout<<get<2>(z)<<endl;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
PY = [[i,0] + list(map(int, input().split())) for i in range(M)]
# [index, nth city, pref num, birth year]

PY.sort(key=lambda x:(x[2],x[3]))

p = -1
num = 1
for i,py in enumerate(PY):
  if p != py[2]:
    p = py[2]
    num = 1
    PY[i][1] = num
  else:
    num += 1
    PY[i][1] = num

PY.sort(key=lambda x:x[0])

for py in PY:
  print('{:0=6}{:0=6}'.format(py[2], py[1]))


Measured memory_bytes: 38396
#include <iostream>
#include <set>
#include <vector>
#include <string>
#include <algorithm>
#include <iterator>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i, n) for(auto i = (n).begin(); i != (n).end(); i++)
#define in_arr(type, a, n) copy_n(istream_iterator<type>(cin), n, (a).begin());

using ll = long long int;
string s;

void print_str(int n, int i, int num, char c, set<string>* cont);

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

    s.resize(n);
    rep(i, n) {
        s[i] = 'a';
    }
    set<string> cont;
    print_str(n, 0, 1, 'a', &cont);
    repi(i, cont) {
        cout << *i << endl;
    }
    return 0;
}

void print_str(int n, int i, int num, char c, set<string>* cont) {
    //printf("%d, %d, %c\n", i, num, c);
    if (n == i) {
        cont->insert(s);
        /*
        for(int j = 0; j < n; ++j) {
            printf("%c", s[j]);
        }
        printf("\n");
        */
        return;
    }

    s[i] = c;
    //printf("%c\n", c);

    for(int j = 0; j <= num; ++j) {
        print_str(n, i + 1, (j < num ? num : num + 1), j + 'a', cont);
    }
}



Measured memory_bytes: 12416
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#include <regex>
#include <map>
#include <set>
using namespace std;
using ll = long long;

int main() {
    int N;
    cin >>N;
    int v[N];
    vector<double> V;
    for(int i=0;i<N;i++){
        cin >> v[i];
        V.push_back(v[i]);
    }
    for(int i=0;i<N;i++){
        sort(V.begin(),V.end());
        V.push_back((V[0]+V[1])/2);
        V.erase(V.begin());
        V.erase(V.begin());
    }
    

    cout << V[0] << endl;
}



Measured memory_bytes: 256
// 2分ヒープ
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<stack>
#include<algorithm>
#include<iostream>
#include<cmath>
#include<vector>

using namespace std;

#define MAX_H 500000
// 無効な値の定義
const int INV = -2147483645;

int parent(int i);
int leftNode(int i);
int rightNode(int i);

void buildMaxHeap(int heap[], int size);
void maxHeapify(int heap[], int size, int top);

int main(void)
{
    int H;
    int BinaryHeap[MAX_H];

    for(int i = 0; i < MAX_H; i++)
    {
        BinaryHeap[i] = INV;
    }

    cin >> H;

    for(int i = 1; i <= H; i++)
    {
        cin >> BinaryHeap[i];
    }

    // maxヒープを作成する
    buildMaxHeap(&BinaryHeap[0], H);

    for(int i = 1; i <= H; i++)
    {
        printf(" %d", BinaryHeap[i]);
    }

    printf("\n");

    return 0;
}

// 節点の親のNo.を返す関数
int parent(int i)
{
    return i / 2;
}

// 節点の左の子のNo.を返す関数
int leftNode(int i)
{
    return 2 * i;
}

// 節点の右の子のNo.を返す関数
int rightNode(int i)
{
    return ( 2 * i ) + 1;
}

// maxヒープを構成するための関数
void buildMaxHeap(int heap[], int size)
{
    for(int i = size / 2; i > 0; i--)
    {
        // 節点 i を頂点とするmaxヒープを作成する
        maxHeapify(&heap[0], size, i);
    }

    return;
}

// 節点 node を根とする部分木が max-ヒープになるように A[i] の値を
// max-ヒープの葉へ向かって下降させる関数
// heap[] : ヒープの値を保持する配列
// size : ヒープサイズ
// top : maxヒープの頂点
void maxHeapify(int heap[], int size, int top)
{
    int largest = top;
    int left = leftNode(top);
    int right = rightNode(top);

    // 部分木の中の最大値を検索する
    if( left <= size && heap[left] > heap[top] )
    {
        largest = left;
    }

    if( right <= size && heap[right] > heap[largest] )
    {
        // [top] or [left] の要素と比較する
        largest = right;
    }

    if( largest != top )
    {
        // 新しい最大値が見つかったら, 値を交換する
        swap(heap[top], heap[largest]);
        // 再帰的にCallする
        maxHeapify(&heap[0], size, largest);
    }

    return;
}



Measured memory_bytes: 5064
# D - Knapsack Queries on a tree

from sys import stdin
import bisect

readline = stdin.readline
bisect_right = bisect.bisect_right

n = int(readline())

v = [0] * n
w = [0] * n
for i in range(n):
    v[i], w[i] = map(int, readline().split())

max_l = 10 ** 5
vshift = 21
mask = (1 << vshift) - 1

# dp table (for some amount)
dp = [None] * min(n, 2 ** 12)

# dp[vertex] = list of (weight, value)
dp[0] = [(0 << vshift) + 0, (w[0] << vshift) + v[0]]

for u in range(1, len(dp)):
    parent = (u - 1) // 2

    ls = dp[parent][:]
    ls.extend(x + (w[u] << vshift) + v[u] for x in dp[parent]
              if (x >> vshift) + w[u] <= max_l)
    ls.sort()

    # remove unnecessary entries
    tail = 0
    for i in range(1, len(ls)):
        if (ls[tail] >> vshift) == (ls[i] >> vshift):
            ls[tail] = ls[i]
        elif (ls[tail] & mask) < (ls[i] & mask):
            tail += 1
            ls[tail] = ls[i]
    del ls[tail + 1:]
    dp[u] = ls

def solve(u, l):
    if u < len(dp):
        x = bisect_right(dp[u], (l << vshift) + mask) - 1
        return dp[u][x] & mask

    parent = (u - 1) // 2
    s = solve(parent, l)
    if l >= w[u]:
        s = max(s, v[u] + solve(parent, l - w[u]))
    return s

q = int(readline())
for i in range(q):
    u, l = map(int, readline().split())
    print(solve(u - 1, l))


Measured memory_bytes: 176984
#include<bits/stdc++.h>
using namespace std;
#define int long long int
// #define lli llong int 
#define ld long double
#define ff first
#define ss second
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define pb push_back
#define pii pair<int, int>
#define all(x) x.begin(),x.end()
#define f(i,j,l) for(i=j;i<l;i++)
#define scan(n) scanf("%lld",&n)
#define endl "\n"
ld const pi = 3.141592653589793238462;

int const mod = 1e9+7;
int const mod1 = 1e9+6;

int power(int a,int b){
    	int f=1;
    	while(b>0){
		if(b&1){
			f=f*a;
			f%=mod;
		}
		a=a*a;
		a%=mod;
		b=b/2;
	}
	return f;
}

int inverse_mod(int x){
    	return power(x,mod-2);
}

int const N = 1e5+5;
vector<int> adj[N];


int32_t main(){
	IOS;
	int n,i,j,l;
	cin>>n;
	if(n < 3){
		cout<<"No"<<endl;
		return 0;
	}
	int is = 1;
	i = 1;
	while((1<<i) <= n){
		if(n == (1<<i)){
			is = 0;
		}
		i++;
	}
	if(is == 0){
		cout<<"No"<<endl;
		return 0;
	}
	cout<<"Yes"<<endl;
	
	for(i=1;i<3;i++){
		cout<<i<<" "<<i+1<<endl;
	}
	cout<<"3 "<<n+1<<endl;
	cout<<n+1<<" "<<n+2<<endl;
	cout<<n+2<<" "<<n+3<<endl;
	if(n%2 == 0){
		for(i=4;i<n;i+=2){
			cout<<i<<" 1"<<endl;
			cout<<"1 "<<n+i+1<<endl;
			cout<<n+i+1<<" "<<n+i<<endl;
			cout<<i<<" "<<i+1<<endl;
		}
		for(i=0;;i++){
			if(n&(1<<i)){
				j = n^(1<<i);
				l = (1<<i);
				cout<<n<<" "<<l<<endl;
				cout<<2*n<<" "<<n+j+1<<endl;
				break;
			}
		}
	}
	else{
		for(i=4;i<=n;i+=2){
			cout<<i<<" 1"<<endl;
			cout<<"1 "<<n+i+1<<endl;
			cout<<n+i+1<<" "<<n+i<<endl;
			cout<<i<<" "<<i+1<<endl;
		}
	}
 	return 0;
}

/*

1 0 1 0 1




*/

Measured memory_bytes: 4736
#include <iostream>
#include <map>

using namespace std;

int T;
map<int, bool> d;

main(){
  for(int i=0;i<143;i++){
    for(int j=0;j<143;j++){
      int t = i * i + j * j;
      if(1 < t && t < 20000) d[t] = true;
    }
  }
  map<int, bool>::iterator iti, itj;
  for(iti=d.begin();iti!=d.end();iti++){
    if(!iti->second) continue;
    for(itj=iti;itj!=d.end();itj++){
      int t = iti->first * itj->first;
      if(t >= 20000) break;
      d[t] = false;
    }
  }
  cin >> T;
  for(int i=0;i<T;i++){
    int m, n, t;
    cin >> m >> n;
    t = m * m + n * n;
    cout << (d[t] ? "P" : "C") << endl;
  }
}

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

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

    int n = s.length();

    string ans;

    for(int i = 0; i < n; i++){
        if(s[i] == '?'){
            ans += 'D';
        }else{
            ans += s[i];
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 3920
#include <bits/stdc++.h>
using namespace std;
using ll = int;
using ld = long double;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
using Edge = pair<int, ll>;
using Graph = vector<vector<int>>;
using WeightedGraph = vector<vector<Edge>>;
const ll INF64 = 1LL << 60;
const int INF32 = 1 << 29;
const ll MOD = 1000000007;

const int CASES = 3;

vector<long long> calc_divisor(long long n) {
    vector<long long> res;
    for (long long i = 1LL; i*i <= n; ++i) {
        if (n % i == 0) {
            res.push_back(i);
            long long j = n / i;
            if (j != i) res.push_back(j);
        }
    }
    sort(res.begin(), res.end());
    return res;
}

void solve() {
    int N; cin >> N;
    vector<int> a(N);

    for (int i = 0; i < N; ++i) cin >> a[i];
    sort(a.begin(), a.end());

    ll ans = 0;
    unordered_set<ll> se;
    for (int i = 0; i < N; ++i){
        if(a[i] == a[i+1] || a[i] == a[i-1]){
            se.insert(a[i]); continue;
        }
        auto vec = calc_divisor(a[i]);
        bool f = true;
        for(auto val : vec){
            if(se.count(val)){
                f = false; break;
            }
        }
        if(f){
            ++ans;
            se.insert(a[i]);
        }
    }
    cout << ans << endl;
}

int main() {
#ifdef MYLOCAL
    vector<string> filenames {"input1.txt", "input2.txt", "input3.txt", "input4.txt", "input5.txt"};
    cout << "------------\n";
    for(int i = 0; i < CASES; ++i){
        ifstream in(filenames[i]);
        cin.rdbuf(in.rdbuf());
        solve();
        cout << "------------\n";
    }
#else

    solve();

#endif
    return 0;
}


Measured memory_bytes: 12152
N = int(input())
H = list(map(int, input().split()))

max_len = 0
pointer = 0
for i in range(1, N):
    if H[i-1] >= H[i]:
        pointer += 1
    else:
        max_len = max(max_len, pointer)
        pointer = 0
max_len = max(max_len, pointer)
print(max_len)

Measured memory_bytes: 14252
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T,class U> using P = pair<T,U>;
template<class T> using vec = vector<T>;
template<class T> using vvec = vector<vec<T>>;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,U,V;
    cin >> N >> U >> V;
    U--; V--;
    vvec<int> g(N);
    for(int i=0;i<N-1;i++){
        int a,b;
        cin >> a >> b;
        a--; b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    vec<int> distU(N,0),distV(N,0);
    auto dfs = [&](auto& self,int cur,int par,vec<int>& dist)-> void{
        for(auto& e:g[cur]) if(e!=par){
            dist[e] = dist[cur]+1;
            self(self,e,cur,dist);
        }
    }; 

    int inf = 1e9;
    int ans = 0,ans2 = inf;
    dfs(dfs,V,-1,distV);
    dfs(dfs,U,-1,distU);
    for(int i=0;i<N;i++){
        if(distU[i]<distV[i]){
            int d = distV[i]-distU[i];
            ans = max(ans,distU[i]+d-1);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 9216
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <tuple>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <cstdio>
#define REP(i, n) for(LL i = 0;i < n;i++)
#define REPR(i, n) for(LL i = n;i >= 0;i--)
#define FOR(i, m, n) for(LL i = m;i < n;i++)
#define FORR(i, m, n) for(LL i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()
#define INF 999999999
#define MOD 1000000007
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
typedef pair<LL, LL> LP;
typedef pair<int, P> PP;
typedef pair<LL, LP> LPP;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

/*************** using variables ***************/
vector<int> a;
/**********************************************/

int main(){
    a.resize(3);
    cin >> a[0] >> a[1] >> a[2];
    
    VSORT(a);
    if(a[0] != a[1]) cout << a[0] << endl;
    else cout << a[2] << endl;
}


Measured memory_bytes: 256
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**5) 
 
def ii(): return int(stdin.readline())
def li(): return map(int, stdin.readline().split())
A, B, C = tuple(li())
A, B = sorted([A, B])
if C in range(A, B):
    print("Yes")
else:
    print("No")


Measured memory_bytes: 2940
package main
import (
  "bufio"
  "os"
  "strconv"
  "strings"
  "fmt"
)

func Solve() {
  var N, Q, v, L int
  NextInt(&N)
  V := make([]int, N + 1)
  W := make([]int, N + 1)
  for i := 1; i <= N; i++ { NextInt(&V[i], &W[i]) }
  U := MinInt(N + 1, 512)
  DP := make([][]int, U)
  L = 100001
  for i := range DP { DP[i] = make([]int, L) }
  for v := 1; v < U; v++ {
    for j, dp := range DP[v / 2] {
      if j >= W[v] {
        DP[v][j] = Max(DP[v / 2][j - W[v]] + V[v], dp)
      } else {
        DP[v][j] = dp
      }
    }
  }
  var F func(int, int) int
  F = func(v, L int) int {
    if v < U { return DP[v][L] }
    a := F(v / 2, L)
    if W[v] <= L { a = Max(F(v / 2, L - W[v]) + V[v], a) }
    return a
  }
  NextInt(&Q)
  for i := 0; i < Q; i++ {
    NextInt(&v, &L)
    Write(F(v, L))
  }
}

func main() {
  Solve()
  Output()
}

var reader = bufio.NewReaderSize(os.Stdin, 1000000)
var writer = bufio.NewWriter(os.Stdout)
func NextLine() string {
  buffer := make([]byte, 0)
  for true {
    line, isPrefix, err := reader.ReadLine()
    if err != nil { panic(err) }
    buffer = append(buffer, line...)
    if !isPrefix { break }
  }
  return string(buffer)
}
func NextInt(A ...*int) {
  L := strings.Split(NextLine(), " ")
  for i, a := range A {
    *a, _ = strconv.Atoi(L[i])
  }
}
func NextIntVec(A *[]int) {
  L := strings.Split(NextLine(), " ")
  (*A) = make([]int, len(L))
  for i, l := range L {
    (*A)[i], _ = strconv.Atoi(l)
  }
}
func NextFloat(A ...*float64) {
  L := strings.Split(NextLine(), " ")
  for i, a := range A {
    *a, _ = strconv.ParseFloat(L[i], 64)
  }
}
func NextFloatVec(A *[]float64) {
  L := strings.Split(NextLine(), " ")
  (*A) = make([]float64, len(L))
  for i, l := range L {
    (*A)[i], _ = strconv.ParseFloat(l, 64)
  }
}
func Write(s interface{}) {
  fmt.Fprintln(writer, s)
}
func WriteIntVec(A []int) {
  S := make([]string, len(A))
  for i, a := range A {
    S[i] = strconv.Itoa(a)
  }
  Write(strings.Join(S, " "))
}
func Output() {
  _ = writer.Flush()
}
func Max(a, b int) int {
  if a < b { return b }
  return a
}
func MaxInt(A ...int) int {
  max := A[0]
  for _, a := range A {
    if max < a { max = a }
  }
  return max
}
func MinInt(A ...int) int {
  min := A[0]
  for _, a := range A {
    if a < min { min = a }
  }
  return min
}
func SumInt(A ...int) int {
  sum := 0
  for _, a := range A {
    sum += a
  }
  return sum
}
func AbsInt(x int) int {
  if x < 0 { x = -x }
  return x
}
func Ceil(x, y int) int {
  a := x / y
  if x % y > 0 { a++ }
  return a
}

Measured memory_bytes: 429440
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <locale>
#include <iostream>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

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

using namespace std;

using ll = long long;
using ld = long double;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template <typename T> int len(const T &x) { return x.size(); }

template<typename T>
vector<T> table(int n, T v) { return vector<T>(n, v); }

template <class... Args>
auto table(int n, Args... args) {
  auto val = table(args...);
  return vector<decltype(val)>(n, move(val));
}

struct yes_no : numpunct<char> {
  string_type do_truename()  const { return "Yes"; }
  string_type do_falsename() const { return "No"; }
};

void solve(ll X, ll Y, ll Z) {
  cout << (X - Z) / (Y + Z) << endl;
}

int main() {
  locale loc(locale(), new yes_no);
  cout << boolalpha << setprecision(12) << fixed;
  cout.imbue(loc);
	ll Y;
	ll Z;
	ll X;
	scanf("%lld", &X);
	scanf("%lld", &Y);
	scanf("%lld", &Z);
	solve(X, Y, Z);
	return 0;
}


Measured memory_bytes: 256
from bisect import bisect_right, bisect_left
from itertools import groupby, permutations, combinations
from fractions import gcd
import numpy as np
from sys import stdin, stderr


def lcm(x, y):
    return (x * y) // gcd(x, y)


def main():
    N = int(input())
    P = [int(x) for x in input().split()]
    max_P = P[0]
    min_P = P[0]
    ret = 0
    for i in range(N):
        if min_P >= P[i]:
            ret += 1
            min_P = P[i]
    return ret


if __name__ == "__main__":
    print(main())

Measured memory_bytes: 35020