akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;

static const int INTINF = (2147483647 >> 1); // 10^9 + 5000
static const ll LLINF = (9223372036854775807 >> 1);
static const int MAX = 1e5+1;
static const ll MOD = 1e9+7;

namespace Kunitaka{
    template<
        typename TYPE,
        std::size_t SIZE
    >
    std::size_t array_length(const TYPE (&array)[SIZE])
    {
        return SIZE;
    }
}
using namespace Kunitaka;
namespace Printer{
    void br(){
        cout << endl;
    }

    void loop_cnt(int i){
        cout << "i = " << i << endl;
    }

    void loop_cnt(int i, int j){
        cout << "i = " << i << ", " << "j = " << j << endl;
    }

    template<class T>
    void print(T x){
        cout << x << endl;
    }

    template<class T, class S>
    void print(T x, S y){
        cout << x << "," << y << endl;
    }

    template<class T, class S, class U>
    void print(T x, S y, U z){
        cout << x << "," << y << "," << z << endl;
    }

    template<class T, class S>
    void print(pair<T, S> p){
        cout << p.first << ", " << p.second << endl;
    }

    template<
        typename TYPE,
        std::size_t SIZE
    >
    void print(const TYPE (&array)[SIZE]){
        int lim = array_length(array);
        for(int i=0; i<lim; i++){
            if(i) cout << " ";
            cout << array[i];
        }
        cout << endl;
    }

    template<class S>
    void print(vector<S> v){
        for(int i=0; i<v.size(); i++){
            if(i) cout << " ";
            cout<< v[i];
        }
        cout << endl;
    }

    template<class S>
    void print(vector<vector<S> > vv){
        for(int i=0; i<vv.size(); i++){
            for(int j=0; j<vv[i].size(); j++){
                if(j) cout << " ";
                cout << vv[i][j];
            }
            cout << endl;
        }
    }

    void yesno(bool x){
        if(x) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
};
using namespace Printer;

int main(int argc, const char * argv[]) {
    //提出時、消す----//
    //--------------//


    // input
    cout << fixed << setprecision(10);
    int N; cin >> N;
    int K; cin >> K;
    vector<int> v(K);
    rep(i, K) cin >> v[i];

    rep(i, 1e6+1){
        if(i < N) continue;
        string num = to_string(i);
        bool flag = true;
        rep(j, num.size()){
            int a = num[j] - '0';
            for(auto b : v){
                if(a==b){
                    flag = false;
                }
            }
        }
        if(!flag) continue;
        else{
            cout << i << endl;
            return 0;
        }
    }
    
    
    return 0;
}


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

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

  vector<int> A(N);

  for(int i = 0; i < N; ++i){
    cin >> A.at(i);
  }

  bool f = true;
  for(int i = 0; i < N; ++i){
    if(A.at(i) % 2 == 0){
      if(A.at(i) % 3 != 0 && A.at(i) % 5 != 0){
        f = false;
        break;
      }
    }
  }
  if(f){
    cout << "APPROVED" << endl;
  }else{
    cout << "DENIED" << endl;
  }

}


Measured memory_bytes: 256
import sys
IS = lambda: sys.stdin.readline().rstrip()
II = lambda: int(IS())
MII = lambda: list(map(int, IS().split()))

def main():
    n = II(); t, a = MII(); hh = MII()
    d = [(i+1, abs(a-(t-h*0.006))) for i,h in enumerate((hh))]
    d.sort(key=lambda x: x[1])
    print(d[0][0])

if __name__ == '__main__':
    main()


Measured memory_bytes: 3188
//minamoto
#include<bits/stdc++.h>
#define R register
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
template<class T>inline bool cmin(T&a,const T&b){return a>b?a=b,1:0;}
using namespace std;
int P;
inline void upd(R int &x,R int y){(x+=y)>=P?x-=P:0;}
inline int inc(R int x,R int y){return x+y>=P?x+y-P:x+y;}
inline int dec(R int x,R int y){return x-y<0?x-y+P:x-y;}
inline int mul(R int x,R int y,R int P){return 1ll*x*y-1ll*x*y/P*P;}
int ksm(R int x,R int y,R int P){
	R int res=1;
	for(;y;y>>=1,x=mul(x,x,P))(y&1)?res=mul(res,x,P):0;
	return res;
}
const int N=3005;
int c[N][N],s[N][N],n,res;
void init(){
	s[0][0]=c[0][0]=1;
	fp(i,1,n+1){
		c[i][0]=1;
		fp(j,1,i){
			c[i][j]=inc(c[i-1][j],c[i-1][j-1]);
			s[i][j]=(1ll*j*s[i-1][j]+s[i-1][j-1])%P;
		}
	}
}
int main(){
//	freopen("testdata.in","r",stdin);
	scanf("%d%d",&n,&P);
	init();
	fp(i,0,n){
		R int ret=0,fn=ksm(2,ksm(2,n-i,P-1),P),bs=ksm(2,n-i,P);
		fp(j,0,i)upd(ret,1ll*s[i+1][j+1]*fn%P),fn=1ll*fn*bs%P;
		ret=1ll*ret*c[n][i]%P;
		upd(res,i&1?P-ret:ret);
	}
	printf("%d\n",res);
	return 0;
}

Measured memory_bytes: 69504
#include<iostream>
using namespace std;
long long mod=1e9+7;
long long qpow(long long a,long long b)
{
	long long ans=1;
	while(b)
	{
		if(b&1) ans=(ans*a)%mod;
		a=(a*a)%mod;
		b>>=1;
	}
	return (ans+mod)%mod;
}
long long po[200005];
int main()
{
	long long n,a,b,ans,sum1=1,sum2=1;
	cin>>n>>a>>b;
	ans=qpow(2,n);
	for(int i=1;i<=200000;i++) po[i]=qpow(i,mod-2);
	for(int i=1;i<=a;i++)
	{
		sum1*=(n-i+1);
		sum1%=mod;
		sum1*=po[i];
		sum1%=mod;
	}
	for(int i=1;i<=b;i++)
	{
		sum2*=(n-i+1);
		sum2%=mod;
		sum2*=po[i];
		sum2%=mod;
	}
	cout<<((ans-sum1-1-sum2)%mod+mod)%mod<<endl;
	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <iomanip>
using namespace std;

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

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<long double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

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

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }
#define INF 1LL<<60

int main() {
    int A, B;
    cin >> A >> B;
    cout << A * B << endl;
    return 0;
}

Measured memory_bytes: 3568
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef vector<pii> vp;

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

vs f(string s){
    vs ret;
    int l = 0;
    rep(r,s.size())if(s[r] == '"'){
        ret.push_back(s.substr(l,r-l));
        l = r+1;
    }
    ret.push_back(s.substr(l));
    return ret;
}

signed main(void) {
    string in;
    while(cin >> in, in != "."){
        vs s = f(in);
        cin >> in;
        vs t = f(in);
        //rep(i,s.size())cout << s[i] << endl;
        //rep(i,t.size())cout << t[i] << endl;
        int ans = 0;
        if(s.size() != t.size()){
            ans = 2;
        }else{
            rep(i,s.size())if(s[i] != t[i]){
                if(i%2)ans++;
                else ans = 2;
            }
        }
        if(ans >= 2){
            cout << "DIFFERENT" << endl;
        }else if(ans == 1){
            cout << "CLOSE" << endl;
        }else{
            cout << "IDENTICAL" << endl;
        }
    }
}



Measured memory_bytes: 3176
from math import factorial

N, A, B = map(int, raw_input().split())
v = map(int, raw_input().split())

C = [[0 for i in range(51)] for j in range(51)] #C[n][k] => nCk

for i in range(51):
    for j in range(i+1):
        if (j == 0 or j == i):
            C[i][j] = 1
        else:
            C[i][j] = C[i-1][j-1] + C[i-1][j]

v.sort(reverse = True)

t = v[A-1]

ans = 0
X, Y = v.count(t), v[:A].count(t)

if (v[0] != v[A-1]):
    ans = C[X][Y]

else:
    for i in range(A, B+1):
        if(i <= X):
            ans += C[X][i]

print float(sum(v[0:A]))/A
print ans

Measured memory_bytes: 2696
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef map<int,int> mii;
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef vector<long long> vl;
typedef vector<vector<ll>> vll;
typedef vector<bool> vb;
typedef set<int> si; 
typedef queue<int> qi;
typedef stack<int> sti;
typedef priority_queue<int> pqi;
#define fori(i,a,b) for(int i = (a); i < (b); ++i)
#define rep(i,b,a) for(int i = (b); i >= (a); --i)
#define all(a) (a).begin(), (a).end()
//#define __builtin_popcountll bitCountLL
//#define __builtin_popcount bitCount
//__builtin_ctz 末尾0的个数, __builtin_clz 前导0的个数
//__builtin_ffs 最后一个1的位置
mt19937 mt_rand(chrono::high_resolution_clock::now().time_since_epoch().count());
//std::uniform_int_distribution<long long> rg(1,1e18);
#define maxn 100005
#define Mod 1000000007
const int INF = 2e9;
const ll ML = 4e18;
    
void solve() {
    int d, t, s;
    cin >> d >> t >> s;
    if(t * s >= d) cout << "Yes\n";
    else cout << "No\n";
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
	//cout.precision(30); cout << fixed;
//	freopen("D:\\data_in.txt", "r", stdin);
   
    solve();
   
    /*
    clock_t start,finish;
    start = clock();
    
    finish = clock();
    cout << "\n" << (double)(finish - start) / (double)(CLOCKS_PER_SEC) * 1000 << "ms" << endl;
    */
    return 0;
}

/***************************************************************
 question:
 idea:
 tag:
 record:
 ***************************************************************/


Measured memory_bytes: 3652
l = list(int(input()) for i in range(5))
nlist = []
Sum = 0

for i in range(5):
    if l[i]%10 == 0:
        nlist.append(0)
    else:
        nlist.append(10 - (l[i]%10))
        
if nlist[0] == nlist[1] == nlist[2] == nlist[3] == nlist[4] == 0:
    print(l[0]+l[1]+l[2]+l[3]+l[4])
else:
    #リストlにリストnlistをそれぞれ加える
    for i in range(5):
        Sum += l[i] + nlist[i]
    print(Sum - max(nlist))

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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;
typedef pair<ll, ll> PL;
typedef pair<P, ll> PPL;

#define INF INT_MAX/3

#define MAX_N 1000

struct dice{
	int d[6];
	void rotation(int& w,int& x,int& y,int& z){
		int tmp=w; w=x; x=y; y=z; z=tmp;
	}
	void n(){rotation(d[4],d[0],d[1],d[5]);}
	void e(){rotation(d[2],d[0],d[3],d[5]);}
	void w(){rotation(d[3],d[0],d[2],d[5]);}
	void s(){rotation(d[1],d[0],d[4],d[5]);}
	void spin(){rotation(d[1],d[2],d[4],d[3]);}
	int query(int a,int b){
		string ss="WWWWSWW";
		rep(i,ss.length()){
			if(ss[i]=='W')w();
			if(ss[i]=='S')s();
			if(d[0]==a)break;
		}
		if(d[0]!=a)return -1;
		rep(i,4){
			if(d[1]==b)break;
			spin();
		}
		if(d[1]!=b)return -1;
		return d[2];
	}
	bool equal(dice a){
		return a.d[2]==query(a.d[0],a.d[1]);
	}
};

dice dic1,dic2;

int main(){
	cin.sync_with_stdio(false);
	rep(i,6){
		cin>>dic1.d[i];
	}
	rep(i,6){
		cin>>dic2.d[i];
	}
	if(dic1.equal(dic2))cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 3220
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
int main(){
    string n;
    cin>>n;
    int x=0,a=0;
    rep(i,n.size()-1) if(n[i+1]=='9') a++;
    if(a==n.size()-1) x=1;
    if(x==0) cout<<n[0]-'0'-1+(n.size()-1)*9;
    else cout<<n[0]-'0'+(n.size()-1)*9;
}

Measured memory_bytes: 256
import java.util.*;

class Main{
    public static void main(String argv[]) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();
        String[] str = sc.next().split("");
        str[K-1] = str[K-1].toLowerCase();
        for(String x:str){
            System.out.print(x);
        }
    }
}

Measured memory_bytes: 21716
S=list(input())
S_=[]
S__=[]
K=int(input())
ans=0
i=0
if S[0]==S[-1]:
    s=S[0]
    S_.append(S.pop(0))
    while len(S)>0:
        if s==S[0]:
            S_.append(S.pop(0))
        else:
            break
    while len(S)>0:
        if s==S[-1]:
            S__.append(S.pop(-1))
        else:
            break
if len(S)>0:
    while i<len(S)-1:
        if S[i+1]==S[i]:
            ans+=K
            i+=1
        i+=1
if len(S)>0:
    ans+=(K-1)*((len(S_)+len(S__))//2)
    ans+=len(S_)//2
    ans+=len(S__)//2
else:
    ans+=K*(len(S_)+len(S__))//2
print(ans)

Measured memory_bytes: 3064
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

int d,n,m;
vector<int> shop(200000);

main(){
  shop.clear();

  scanf("%d%d%d", &d, &n, &m);
  
  if(d == 0) return 0;

  shop.push_back(0);
  shop.push_back(d);
  --n;

  int k;
  while(n--){
    scanf("%d", &k);
    shop.push_back(k);
    shop.push_back(k+d);
  }

  sort(shop.begin(), shop.end());

  vector<int>::iterator it;
  int u,l,r=0;
  while(m--){
    scanf("%d", &k);

    it = lower_bound(shop.begin(), shop.end(), k);

    if(it == shop.begin()) continue;

    u = *it;
    l = *(it-1);

    r += min(u-k, k-l);
  }

  printf("%d\n", r);

  main();
}
    

Measured memory_bytes: 1584
#include<stdio.h>

#define N 100000

typedef struct
{
    int parent;
    int left;
    int right;
} node;

int finddepth(int);
void preorder(int);
void inorder(int);
void postorder(int);

node T[N];

int main()
{
    int pa, x, y, i, j, n, k, c, root;
    
    scanf("%d", &n);
    for(i=0; i<n; i++)
    {
        T[i].parent = -1;
        T[i].left = -1;
        T[i].right = -1;
    }
    
    
    for(i=0; i<n; i++)
    {
        scanf("%d", &pa);
        
        scanf("%d%d", &x, &y);
        if(x!=-1)T[x].parent = pa;
        if(y!=-1)T[y].parent = pa;
        T[pa].left = x;
        T[pa].right = y;
        
    }
    
    for(i=0; i<n; i++)
    {
        if(T[i].parent == -1)
        {
            root = i;
            break;
        }
    }
    
    printf("Preorder\n");
    preorder(root);
    printf("\n");
    
    printf("Inorder\n");
    inorder(root);
    printf("\n");
    
    printf("Postorder\n");
    postorder(root);
    printf("\n");
    
    return 0;
}
int finddepth(int x)
{
    int c=0;
    while(T[x].parent >= 0)
    {
        c++;
        x = T[x].parent;
    }
    return c;
}
void preorder(int root)
{
    if(root == -1) return;
    
    printf(" %d", root);
    preorder(T[root].left);
    preorder(T[root].right);
}
void inorder(int root)
{
    if(root == -1) return;
    
    inorder(T[root].left);
    printf(" %d", root);
    inorder(T[root].right);
}
void postorder(int root)
{
    if(root == -1) return;
    
    postorder(T[root].left);
    postorder(T[root].right);
    printf(" %d", root);
}

Measured memory_bytes: 616
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){for(auto &e:t) fill_v(e,v);}
/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */
const ll MOD = 1e9+7;
// a^b % MOD;
ll powmod(ll a,ll b) {ll res=1;a%=MOD; for(;b;b>>=1){if(b&1)res=res*a%MOD;a=a*a%MOD;}return res;}

template<class Type>
Type solve(Type res = Type()){
    int N,K; cin >> N >> K;
    
    vector<ll> cnt(K+1);
    for(ll x = K; x >= 1; x--){
        ll S = powmod(K/x,N);
        for(ll y = 2; y*x <= K; y++){
            S = (S - cnt[y*x] + MOD) %MOD;
        }
        cnt[x] = S;
        res += x*cnt[x];
        res %= MOD;
    }

    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    // solve(0);
    cout << fixed << setprecision(15) << solve<ll>() << endl;
    return 0;
}


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

int main() {
  int n;
  string res;
  map<string,int> result = {
    {"AC", 0},
    {"WA", 0},
    {"TLE", 0},
    {"RE", 0}
  };

  cin >> n;

  for (int i=0; i<n; ++i) {
    cin >> res;
    result[res]++;
  }

  cout << "AC x " << result["AC"] << "\n";
  cout << "WA x " << result["WA"] << "\n";
  cout << "TLE x " << result["TLE"] << "\n";
  cout << "RE x " << result["RE"] << "\n";
}


Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <ctime>
#include <list>
#include <numeric>
#include <utility>
#include <ctime>
#define INF 1000000000
#define LINF 9000000000000000000
#define mod 1000000007
 
#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair
#define MOD(x) (x%(mod))
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool debug=false;
 
/*---------------------------------------------------*/

int main(){
    string s;
    cin >> s;
    rep(i,s.size()){
        if(i % 2 == 0)cout << s[i];
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 512
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <tuple>
# include <unordered_map>
# include <numeric>
# include <complex>
# include <bitset>
# include <random>
# include <chrono>
# include <cstdlib>
# include <tuple>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr int INF = 2147483647;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr double HDINF = 50000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
const double PI = acos(-1);
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
# define ALL(x)      (x).begin(),(x).end()
# define UNIQ(c)     (c).erase(unique(ALL((c))),(c).end())
# define LOWER(s)    transform(ALL((maze)),(maze).begin(),TL<char>)
# define UPPER(s)    transform(ALL((maze)),(maze).begin(),TU<char>)
# define FOR(i,a,b)  for(LL i=(a);i<(b);i++)
# define RFOR(i,a,b) for(LL i=(a);i>=(b);i--)
# define REP(i,n)    FOR(i,0,n)
# define INIT        std::ios::sync_with_stdio(false);std::cin.tie(0)

int n;
int x[202020];
int sorter[202020];
bool calc(int a, int b) {
	return x[a] < x[b];
}
int ans[202020];
int main() {
	cin >> n;
	REP(i, n)cin >> x[i];
	REP(i, n)sorter[i] = i;
	sort(sorter, sorter + n, calc);
	REP(i, n) {
		if ((i + 1)*2 <= n) {
			ans[sorter[i]] = x[sorter[n / 2]];
		}
		else {
			ans[sorter[i]] = x[sorter[n / 2 - 1]];
		}
	}
	REP(i, n) {
		cout << ans[i] << endl;
	}
	//system("pause");
}

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

using namespace std;

int N;
string S;

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

	long long int ans = 0;

	vector<bool> hash1(10, false);
	for (int i1 = 0; i1 < N; i1++) {
		int c1 = S[i1] - '0';
		if (hash1[c1]) { continue; }
		hash1[c1] = true;

		vector<bool> hash2(10, false);
		for (int i2 = i1 + 1; i2 < N; i2++) {
			int c2 = S[i2] - '0';
			if (hash2[c2]) { continue; }
			hash2[c2] = true;

			vector<bool> hash3(10, false);
			for (int i3 = i2 + 1; i3 < N; i3++) {
				int c3 = S[i3] - '0';
				if (hash3[c3]) { continue; }
				hash3[c3] = true;
				ans++;
			}
		}
	}
	cout << ans << endl;
}

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

signed main(void)
{
	string s;
	cin >> s;
	rep(i, 3)
	{
		if (s[i] == '9')
			s[i] = '1';
		else if (s[i] == '1')
			s[i] = '9';
	}
	cout << s << endl;
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <bitset>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <queue>

using namespace std;

struct BoolName : numpunct<char> {
  string t, f;
  BoolName (string t = "Yes", string f = "No") : t(t), f(f) {}
  string do_truename() const {return t;}
  string do_falsename() const {return f;}
};

struct Initializer {
  Initializer() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(15) << boolalpha;
    cout.imbue(locale(cout.getloc(), new BoolName));
  }
} initializer;

template<typename T> istream& operator>>(istream &s, vector<T> &v) {
  for (T &t : v) s >> t;
  return s;
}

template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
  for (const T &t : v) s << t << endl;
  return s;
}

void set_bool_name(string t, string f) {
  cout.imbue(locale(cout.getloc(), new BoolName(t, f)));
}

int main() {
  string a, b;
  cin >> a >> b;
  while (a.size() < b.size()) a = '0' + a;
  while (a.size() > b.size()) b = '0' + b;
  cout << (a > b ? "GREATER" : a < b ? "LESS" : "EQUAL") << endl;
}



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

using namespace std;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<int> cnt(4, 0);
	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;
		cnt[a % 4]++;
	}
	if (cnt[2]) {
		n -= cnt[2];
		if (cnt[0] >= (n + 1) / 2) cout << "Yes" << endl;
		else cout << "No" << endl;
	} else {
		n -= cnt[2];
		if (cnt[0] >= n / 2) cout << "Yes" << endl;
		else cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp(aa,bb) make_pair(aa,bb)
#define _for(i,b) for(int i=(0);i<(b);i++)
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,b,a) for(int i=(b);i>=(a);i--)
#define mst(abc,bca) memset(abc,bca,sizeof abc)
#define X first
#define Y second
#define lowbit(a) (a&(-a))
typedef long long ll;
typedef pair<int,int> pii;
typedef unsigned long long ull;
typedef long double ld;
const int N=100010;
const int INF=0x3f3f3f3f;
const int mod=1e9+7;
const double eps=1e-6;


void solve(){
	string s;
	cin>>s;
	int ans=0,ts=0;
	for(auto x:s){
		if(x=='R') ts++;
		else ans=max(ans,ts),ts=0;
	}
	ans=max(ans,ts);
	cout<<ans<<"\n";
}


int main(){
	ios::sync_with_stdio(0);
    cin.tie(0);
#ifdef DEBUG
    freopen("F:/laji/1.in", "r", stdin);
//	freopen("F:/laji/2.out", "w", stdout);
#endif
//	int t;cin>>t;while(t--)
	solve();
    return 0;
}



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

int main(void) {
	int n; cin >> n;
	vector<llong> A(n), B(n), C(n);
	for (int i = 0; i < n; i++) scanf("%lld", &A[i]);
	for (int i = 0; i < n; i++) scanf("%lld", &B[i]);
	for (int i = 0; i < n; i++) scanf("%lld", &C[i]);

	sort(A.begin(), A.end());
	sort(C.begin(), C.end());

	llong res = 0;
	llong low, up;
	for (int j = 0; j < n; j++) {
		low = lower_bound(A.begin(), A.end(), B[j]) - A.begin();
		up = (C.end() - upper_bound(C.begin(), C.end(), B[j]));
		res += (up * low);
	}

	cout << res << endl;

	return 0;
}

Measured memory_bytes: 2560
using System;
using System.Collections.Generic;

namespace B_010_51
{
    internal class Program
    {
        private static void Main(string[] args)
        {

            new Logic_B().Start();//
          
        }

        public class Logic_B
        {
            public void Start()
            {
                var str = Console.ReadLine().Split(' ');
                var K = Convert.ToInt32(str[0]);
                var S = Convert.ToInt32(str[1]);

                var count = 0;
                for (int x = 0; x <= K; x++)
                {
                    for (int y = 0; y <= K; y++)
                    {
                        var z = S - x - y;
                        if (z >= 0 && z <= K)
                        {
                            //Console.WriteLine(x.ToString() + ' ' + y.ToString() + ' ' + z.ToString());
                            count++;
                        }
                    }
                }
                Console.WriteLine(count);
            }
        }

    }
}

Measured memory_bytes: 13268
from math import ceil, sqrt


def eratosthenes(n):
    hurui = [i for i in range(n + 1)]
    for i in range(2, ceil(sqrt(n)) + 1):
        for j in range(2, ceil(sqrt(i)) + 1):
            if i == 2:
                continue
            if i % j == 0:
                break
        else:
            for k in range(i + i, n, i):
                if hurui[k] != k:
                    continue
                hurui[k] = 0
        continue
    return hurui


n = 10**5 + 200
hurui = eratosthenes(n)
hurui = [bool(i) for i in hurui]
poi = [False] * (n + 1)
for i in range(n + 1):
    poi[i] = (i % 2 == 1 and hurui[i] and hurui[(i + 1) // 2])
poi[1] = False
sa = [0]
for i in range(n + 1):
    sa.append(sa[i] + poi[i])
q = int(input())
lr = [tuple(map(int, input().split())) for i in range(q)]
for li, ri in lr:
    print(sa[ri + 1] - sa[li])


Measured memory_bytes: 27228
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 1e18
#define ceill(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
#define sp << " " <<
ll mod = 1e9+7;
void ans(bool b, ostream& out=cout){ out << (b ? "Yes" : "No") << endl; }
void ans2(bool b, ostream& out=cout){ out << (b ? "YES" : "NO") << endl; }
template<typename T> inline bool chmax(T &a, T b){ if(a<b) a=b; return a<b; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a) a=b; return b<a; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){fill((T*)array, (T*)(array+N), val);}
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};

#ifndef INCLUDE_DEBUG_HPP
#define INCLUDE_DEBUG_HPP

class debug
{
public:
    template<typename T> void vdeb(T vec);
    template<typename T1, typename T2> void adeb(T1 *arr, T2 n);
    template<typename T> void mdeb(T mp);
};

#endif //INCLUDE_DEBUG_HPP

template<typename T> void debug::vdeb(T vec)
{
    cout << "#vector set debug" << endl;
    for(auto vv : vec) cout << vv << " ";
    cout << endl;
}

template<typename T1, typename T2> void debug::adeb(T1 *arr, T2 n)
{
    cout << "#adebug" << endl;
    for(int i=0; i<=n; i++) cout << arr[i] << " ";
    cout << endl;
}

template<typename T> void debug::mdeb(T mp)
{
    cout << "#map pair debug" << endl;
    for(auto const& m : mp) cout << m.first sp m.second << endl;
}

debug dbg;

class BCanYouSolveThis {
public:
	void solve(std::istream& in, std::ostream& out)
	{
	    int n, m, c;
	    in >> n >> m >> c;
	    vector<int> b(m);
	    vector<vector<int>> a(n, vector<int>(m));
	    for(int i=0; i<m; i++){
	        in >> b[i];
	    }

	    for(int i=0; i<n; i++){
	        for(int j=0; j<m; j++){
	            in >> a[i][j];
	        }
	    }

	    ll res = 0;
	    for(int i=0; i<n; i++){
	        ll sum = 0;
	        for(int j=0; j<m; j++){
                sum += a[i][j] * b[j];
	        }
	        if(sum + c > 0) res++;
	    }

	    out << res << endl;
	}
};


int main() {
	BCanYouSolveThis solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long av[100100];

int main(void)
{
  long long n,i, c[5]={0},c0,c2,c4;
  cin >> n;
  for(i=0;i<n;i++){
    cin>>av[i];
    c[av[i]%4]++;
  }
  c0=c[1]+c[3]+((c[2]>0)?1:0);
  c2=c[2];
  c4=c[0];
  cout<<((c0-c4<2)?"Yes":"No");
  
 
  //スマホから提出

}

Measured memory_bytes: 1024
import sys
from io import StringIO
import unittest

def resolve():
    n = int(input())

    ans = n * (n - 1) // 2
    print(int(ans))

class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)
    def test_入力例_1(self):
        input = """2"""
        output = """1"""
        self.assertIO(input, output)
    def test_入力例_2(self):
        input = """13"""
        output = """78"""
        self.assertIO(input, output)
    def test_入力例_3(self):
        input = """1"""
        output = """0"""
        self.assertIO(input, output)

if __name__ == "__main__":
    # unittest.main()
    resolve()

Measured memory_bytes: 5724
n, k, q = map(int, input().split())

a = []

#p = np.zeros((n))
#p += k

p = [0] * n

for i in range(q):
    a = int(input())
    p[a-1] += 1

    #p -= 1
    #p[a-1] += 1

for i in range(n):
    if p[i] > (q-k):
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 4680
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Math;
using static System.Console;
using System.Text;

class Program
{
    static void Main(string[] args)
    {
        solve();
    }
    static Scanner cin;
    static int N;
    static int[] v;
    static void input()
    {
        cin = new Scanner();
        N = cin.nextInt();
        v = cin.ArrayInt(N);
    }
    static void solve()
    {
        input();
        Array.Sort(v);
        Double ans = (v[0] + v[1]) / 2d;
        for(int i = 2; i < N; i++)
        {
            ans = (ans + v[i]) / 2d;
        }
        WriteLine(ans);
    }
    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }
        
        public string next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return next();
            i = 0;
            return s[i++];
        }

        public int nextInt()
        {
            return int.Parse(next());
        }

        public int[] ArrayInt(int N, int add = 0)
        {
            int[] Array = new int[N];
            for(int i = 0; i < N; i++)
            {
                Array[i] = nextInt() + add;
            }
            return Array;
        }

        public long nextLong()
        {
            return long.Parse(next());
        }

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for(int i = 0; i < N; i++)
            {
                Array[i] = nextLong() + add;
            }
            return Array;
        }

        public double nextDouble()
        {
            return double.Parse(next());
        }

        public double[] ArrayDounble(int N, int add = 0)
        {
            double[] Array = new double[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextDouble() + add;
            }
            return Array;
        }
    }
}

Measured memory_bytes: 13268
#include <iostream>
#include <algorithm>
#include <utility>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <math.h>
#include <string.h>
#include <iomanip>
#include <numeric>
#include <cstdlib>
#include <cstdint>
#include <cmath>
#include <functional>
#include <limits>
#include <cassert>
#include <bitset>
//#include <atcoder/all>
 
using namespace std;
//using namespace atcoder;
 
/* template */
 
using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vll = vector<vl>;
using vpll = vector<pll>;

void debug_out() { std::cout << std::endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}
 
#ifdef LOCAL
#define debug(...) cout << "debug: "; debug_out(__VA_ARGS__)
#else
#define debug(...) 
#endif
 
#define rep(i, a, n) for (int i = (int)(a); i < (int)(n); i++)
#define rrep(i, a, n) for (int i = ((int)(n-1)); i >= (int)(a); i--)
#define Rep(i, a, n) for (long long i = (long long)(a); i< (long long)(n); i++)
#define RRep(i, a, n) for (long long i = ((long long)(n-1ll)); i>=(long long)(a); i--)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
 
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (std::size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}
 
struct Edge{
    int to;
    ll weight;
    Edge(int t, ll w) : to(t), weight(w){ }
};
 
struct edge{
    int from;
    int to;
    ll weight;
    edge(int f,int t,ll w) : from(f), to(t), weight(w){ }
};
 
using Graph = vector<vector<Edge>>;
using graph = vector<vector<int>>;
using edges = vector<edge>;

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 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: return 0;
	}
}
 
constexpr ll LNF = 1LL<<50;
 
constexpr int INF = 1e9+7;
 
const long double PI=acos(-1);

vector<int> dx = {1,0,-1,0};
vector<int> dy = {0,1,0,-1};

/* template */

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll n; cin >> n;
    ll ans = 0;
    rep(i,1,n){
        if(n%i==0){
            ans += n/i;
            ans--;
        }
        else{
            ans += n/i;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3652
/*
貪欲
後ろから見る
DP
順位表をチェック
二分探索
不変なもの・偶奇に注目

*/
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
#include <cmath>
#include <limits>
#include <iostream>
#include <map>
#include<tuple>
#include<set>
using namespace std;
#define INF 1LL<<60
#define MAX 100000
#define MOD 1000000007
typedef long long ll;
typedef pair<int,int> P;
//typedef pair< pair<int,int>,pair<int,int> > p;
//#define int ll int main->signed main
#define bit(n,k) ((n>>k)&1) /*nのk bit目*/
#define rad_to_deg(rad) (((rad)/2/M_PI)*360)
struct edge{ll to,cost,val;};
template<class T,class U>bool chmin(T&a,const U&b){if(a<=b)return false;a=b;return true;}
template<class T,class U>bool chmax(T&a,const U&b){if(a>=b)return false;a=b;return true;}
//__builtin_popcount(S);
//C.erase(unique(C.begin(),C.end()),C.end());


int main(){
    ll T1,T2,A1,A2,B1,B2;
    cin>>T1>>T2>>A1>>A2>>B1>>B2;
    if(T1*A1+T2*A2==T1*B1+T2*B2){
        if(A1==B1 && A2==B2){
            cout<<0<<endl;
        }else{
            cout<<"infinity"<<endl;
        }
        return 0;
    }
    if(T1*A1+T2*A2<T1*B1+T2*B2){
        swap(A1,B1);
        swap(A2,B2);
    }

    if(A1>=B1){
        cout<<0<<endl;
        return 0;
    }
    ll dis=(B1-A1)*T1;
    ll sa=T1*A1+T2*A2-T1*B1-T2*B2;
    ll count=dis/sa+1; //Aがぬかす回数
    count=count*2-1;
    //cout<<dis<<" "<<sa<<endl;
    if(dis%sa==0){
        count=(dis/sa)*2;
    }
    cout<<count<<endl;
}


Measured memory_bytes: 256
C,D = [int(e) for e in input().split()]

if C <= D:
    m = D
    n = C
else:
    m = C
    n = D

while  n != 0 :
    a = m%n
    m = n
    n = a

J = []

for i in range(1,int(m**0.5)+1):
    if m % i == 0:
        J.append(i)
        if i != m//i:
            J.append(m//i)


J.sort()

N = int(len(J))
M = [1]
I = []

for i in range(1,N):
    for p in range(1,int(J[i]**0.5)+1):
        if J[i]%p == 0:
            I.extend([J[i]])
            if int(len(I)) >=2:
                break
    if int(len(I)) == 1:
        M.extend([J[i]])
    I = []


M = int(len(M))

print(M)

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

typedef long long ll;
const int N = 100054;

int n, cnt = 0;
int x[N], a[N];
ll p[N];

int main() {
	int i, j, s = 0, v = 0; ll ans = 0;
	scanf("%d%d", &n, x);
	for (i = 1; i <= n; ++i) scanf("%d%lld", x + i, p + i), (x[i] -= *x) < 0 && (s = i); *x = 0;
	for (i = 1, j = n; i <= s && j > s; a[cnt++] = p[i] >= p[j] ? (p[i] += p[j], j--) : (p[j] += p[i], i++));
	for (a[cnt++] = (i <= s ? i : j); cnt; ans += abs(x[ a[--cnt] ] - x[v]), v = a[cnt]);
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<algorithm>
using namespace std;
static const int MAX = 100;

int main(){
	int n;
	cin >> n;
	int A[MAX];
	for (int i = 0; i < n; i++) {
		cin >> A[i];
	}

	for (int i = 0; i < n - 1; i++) {
		cout << A[i] << ' ';
	}
	cout << A[n - 1] << endl;

	for (int i = 1; i < n; i++) {
		int v = A[i];
		int j = i - 1;

		while (j >= 0 && A[j] > v) {
			A[j + 1] = A[j];
			j--;
		}
		A[j + 1] = v;

		for (int k = 0; k < n - 1; k++) {
			cout << A[k] << ' ';
		}
		cout << A[n - 1] << endl;
	}

	return 0;
}


Measured memory_bytes: 3100
# -*- coding: utf-8 -*-
# B

import sys
from collections import defaultdict, deque
from heapq import heappush, heappop
import math
import bisect
input = sys.stdin.readline

# 再起回数上限変更
# sys.setrecursionlimit(1000000)

N = int(input())
d = defaultdict(int)
for i in range(N):
    s = input()[:-1]
    d[s] += 1


print(f"AC x {d['AC']}")
print(f"WA x {d['WA']}")
print(f"TLE x {d['TLE']}")
print(f"RE x {d['RE']}")

Measured memory_bytes: 68428
L = input()
N = len(L)
MOD = 10**9 + 7

smaller = [0] * N
not_smaller = [0] * N

smaller[0] = 1
not_smaller[0] = 2

for i in range(1, N):
    if L[i] == "1":
        smaller[i] = 3 * smaller[i - 1] + not_smaller[i - 1]
        not_smaller[i] = 2 * not_smaller[i - 1]
    elif L[i] == "0":
        smaller[i] = 3 * smaller[i - 1]
        not_smaller[i] = not_smaller[i - 1]

    smaller[i] %= MOD
    not_smaller[i] %= MOD

ans = (smaller[-1] + not_smaller[-1]) % MOD
print(ans)


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

#define int long long
#define rep(i, a, n) for (int i = a; i < n; i++)
#define pb push_back
#define eb emplace_back
#define dump(x) cout << #x << " = " << (x) << endl
#define chk() cout << "now" << endl;
#define ALL(x) (x).begin(), (x).end()
#define SORT(c) sort((c).begin(), (c).end())
#define SORTG(c) sort(ALL(c), greater<int>());
#define fi first
#define se second
int INF = 1e9 + 7;

typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vector<int>> mat;

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

void solve() {
  string t;
  cin >> t;

  rep(i, 0, t.length()) {
    if (t[i] == '?') {
      cout << 'D';
    } else {
      cout << t[i];
    }
  }
  cout << endl;
}

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

  // cout << fixed << setprecision(10);

  solve();

  return 0;
}


Measured memory_bytes: 3768
#include<stdio.h>
long long MAX(long long a,long long b){return a<b?b:a;}
long long MIN(long long a,long long b){return a<b?a:b;}
long long d[310][310][310],c[310]={};
int main(){
  int n,m,i,j,k;
  scanf("%d %d",&n,&m);
  for(i=0;i<n;i++)scanf("%lld",&c[i+1]);
  n++;
  for(i=0;i<=n;i++){
    for(j=0;j<=n;j++){
      for(k=0;k<=m;k++)d[i][j][k]=1e18;
    }
  }
  d[0][0][0]=0;
  for(i=1;i<=n;i++){
    for(j=0;j<=i;j++){
      for(k=0;k<=m;k++){
	d[i][i][k  ]=MIN(d[i][i][k  ],d[i-1][j][k]+MAX(c[i]-c[j],0));
	d[i][j][k+1]=MIN(d[i][j][k+1],d[i-1][j][k]);
      }
    }
  }
  /*for(i=0;i<=n;i++){
    for(j=0;j<=n;j++){
      for(k=0;k<=m;k++)printf("%20lld ",d[i][j][k]);
      printf("\n");
    }
    printf("\n");
    }
    printf("\n");//*/
  printf("%lld\n",d[n][n][m]);
  return 0;
}


Measured memory_bytes: 227456
#![allow(unused_imports, unused_macros, dead_code)]

macro_rules! min {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| min!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = min!($($ys),*);
        if $x < t { $x } else { t }
    }}
}
macro_rules! max {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| max!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = max!($($ys),*);
        if $x > t { $x } else { t }
    }}
}


macro_rules! ewriteln {
    ($($args:expr),*) => { let _ = writeln!(&mut std::io::stderr(), $($args),*); };
}
macro_rules! trace {
    ($x:expr) => { ewriteln!(">>> {} = {:?}", stringify!($x), $x) };
    ($($xs:expr),*) => { trace!(($($xs),*)) }
}
macro_rules! put {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        if let Some(x) = it.next() { print!("{}", x); }
        for x in it { print!(" {}", x); }
        println!("");
    }};
    ($x:expr) => { println!("{}", $x) };
    ($x:expr, $($xs:expr),*) => { print!("{} ", $x); put!($($xs),*) }
}

const M: i64 = 1_000_000_007;

fn ex_gcd(x: i64, y: i64) -> (i64, i64) {
    let mut r0 = x;
    let mut a0 = 1;
    let mut b0 = 0;

    let mut r = y;
    let mut a = 0;
    let mut b = 1;

    while r > 0 {
        let r2 = r0 % r;
        let a2 = a0 - r0 / r * a;
        let b2 = b0 - r0 / r * b;
        r0 = r; r = r2;
        a0 = a; a = a2;
        b0 = b; b = b2;
    }
    (a0, b0)
}

fn mod_inv(x: i64, m: i64) -> i64 {
    let mut a = ex_gcd(x, m).0;
    while a < 0 { a += m; }
    a
}

fn comb(n: i64, k: i64, m: i64) -> i64 {
    if k == 0 { return 1; }
    if k == 1 { return n % m; }
    if n - k < k { return comb(n, n - k, m); }
    let mut c = 1;
    for i in 0..k {
        c *= n - i; c %= m;
        c *= mod_inv(k - i, m); c %= m;
    }
    c
}

fn main() {
    let mut sc = Scanner::new();
    let x: i64 = sc.cin();
    let y: i64 = sc.cin();
    if (x + y) % 3 != 0 {
        put!(0);
        return;
    }
    let m1 = (2 * x - y) / 3;
    let m2 = (2 * y - x) / 3;
    if m1 < 0 || m2 < 0 {
        put!(0);
        return;
    }
    put!(comb(m1 + m2, m1, 1_000_000_007));
}

use std::io::{self, Write};
use std::str::FromStr;
use std::collections::VecDeque;

struct Scanner { stdin: io::Stdin, buffer: VecDeque<String>, }
impl Scanner {
    fn new() -> Self { Scanner { stdin: io::stdin(), buffer: VecDeque::new() } }
    fn cin<T: FromStr>(&mut self) -> T {
        while self.buffer.len() == 0 {
            let mut line = String::new();
            let _ = self.stdin.read_line(&mut line);
            for w in line.split_whitespace() {
                self.buffer.push_back(String::from(w));
            }
        }
        self.buffer.pop_front().unwrap().parse::<T>().ok().unwrap()
    }
    fn chars(&mut self) -> Vec<char> { self.cin::<String>().chars().collect() }
    fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T> { (0..n).map(|_| self.cin()).collect() }
}


Measured memory_bytes: 4352
import java.util.*;

public class Main {
    private static Scanner sc;

    public static void main(String[] args) {
        sc = new Scanner(System.in);
        // 整数の入力
        String a = sc.nextLine();
        char b = a.charAt(a.length() - 1);
        String c;

        if (b == 's') {
            c = a + "es";
        } else {
            c = a + "s";
        }

        // 出力
        System.out.println(c);
    }
}

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

int main(){
    int N;
    scanf("%d", &N);

    int ans=0;

    for(int j=1; j<=N;j++){
        if(j%2==0)  continue;
        int cnt = 0;
        for(int i=1; i<=j;i++){
            if(j%i==0) cnt++;
        }
        if(cnt==8){
            ans++;
        }
    }
    printf("%d\n", ans);
    return 0;
}

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

public class Main {
    public static void main(String[] args) {
        try {
            // 標準入力
            InputStreamReader isr = new InputStreamReader(System.in);
            BufferedReader br = new BufferedReader(isr);
            int n = Integer.parseInt(br.readLine());
            String aStr[] = br.readLine().split(" ");
            int oddCount = 0;
            for (int i = 0; i < aStr.length; i++) {
                int tmp = Integer.parseInt(aStr[i]);
                if (tmp % 2 != 0) {
                    oddCount++;
                }
            }
            if (oddCount % 2 == 0) {
                System.out.println("YES");
            } else {
                System.out.println("NO");
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}

Measured memory_bytes: 25428
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll limit=1e18;
int main()
{
    ll n;
    cin>>n;
    ll i,arr[n];
    int f=0;
    for(i=0;i<n;i++)
    {
        cin>>arr[i];
        if(arr[i]==0)
        f=1;
    }
    if(f)
    {
        cout<<"0\n";
        return 0;
    }
    ll p=1;
    for(i=0;i<n;i++)
    {
        if(p<=limit/arr[i])
        p*=arr[i];
        else{
            cout<<"-1\n";
            return 0;
        }
    }
    cout<<p<<"\n";
    return 0;
}

Measured memory_bytes: 4404