akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
using Graph = vector<vector<int>>;
using Graphl = vector<vector<ll>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Rep(i, k, n) for (int i = k; i < (int)(n); i++)
#define RRep(i, k, n) for (int i = k; i > (int)(n); i--)
#define FOR(itr, v) for (auto itr = (v).begin(); itr != (v).end(); ++itr)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define ALL(a)  (a).begin(),(a).end()
#define rALL(a)  (a).rbegin(),(a).rend()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> void PrintVector(const vector<T> &vec) {for (auto val : vec) cout << val << " "; cout << endl;}
const long long INF = 1LL << 60;
const long long minusINF = -(1LL << 40);
const int MOD = 1000000007;
const double PI = acos(-1); //3.14~
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main()
{
    int a, b; cin >> a >> b;
    if (a & 1 && b & 1) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int count(int a)
{
	int i,cnt=0;
	for(i=1;i<=a;i++){
		if(a%i==0)cnt++;
	}
	return cnt;
}

int main()
{
	int i,n,m=0,cnt;
	scanf("%d",&n);
	
	for(i=1;i<=n;i+=2)
	{
		cnt=count(i);
		if(cnt==8)m++;
	}
	printf("%d\n",m);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9+7;
int main() {
    long double n,m,d;
    cin >> n >> m >> d;
    long double ans;
    if(d==0){
        ans=(m-1)/n;
    }
    else{
        ans=2*(m-1)*(n-d)/(n*n);
    }
    cout << fixed << setprecision(10);
    cout << ans << endl;
}

Measured memory_bytes: 3784
#include "bits/stdc++.h"

using namespace std;

typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;

#define dump(x)  cerr << #x << " = " << (x) << endl
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back


int main(){
    int n;
    while(cin>>n){
        if(n==0)break;
        
        
        string name[30];
        int score[30]={};
        int m[30];
        vi in[30]={};

        rep(i,n){
            cin>>name[i]>>m[i];
        
            rep(j,m[i]){
                int a;
                cin>>a;
                in[i].pb(a);
            }
        }
        
        
        int time[50]={};
        
        rep(i,n){
            rep(j,m[i]){
                time[ in[i][j] ]++;
            }
        }
        
        rep(i,n){
            rep(j,m[i]){
                score[i]+=n-time[in[i][j]]+1;
            }
        }

        int minscore=99999999;
        string minname="";
        rep(i,n){
            if(minscore>score[i] || (minscore==score[i] && minname>name[i] )){
                minscore=score[i];
                minname=name[i];
            }
        }
        cout<<minscore<<" "<<minname<<endl;

    }
    
    return 0;
}

Measured memory_bytes: 1252
#include <stdio.h>
#include <vector>

using namespace std;

struct Node{
	Node(){
		parent = -1;
		depth = num_of_children = 0;
	}
	int parent;
	int depth;
	vector<int> children;
	int num_of_children;
};

void calcDepth(Node nodes[],int root_id){
	for(int i = 0;i < nodes[root_id].num_of_children;i++){
		nodes[nodes[root_id].children[i]].depth = nodes[root_id].depth+1;
		calcDepth(nodes,nodes[root_id].children[i]);
	}
}

int main(){
	int n,id,k,child_id,root_id;
	scanf("%d",&n);
	Node nodes[n];

	for(int i = 0; i < n; i++){
		scanf("%d %d",&id,&k);
		for(int j = 0; j < k; j++){
			scanf("%d",&child_id);
			nodes[id].children.push_back(child_id);
			nodes[id].num_of_children++;
			nodes[child_id].parent = id;
		}
	}

	for(root_id = 0; root_id < n; root_id++){
		if(nodes[root_id].parent == -1) break;
	}

	calcDepth(nodes,root_id);

	for(int i = 0; i < n; i++){
		if(nodes[i].parent == -1){
			printf("node %d: parent = -1, depth = 0, root, ",i);
		}else if(nodes[i].num_of_children == 0){
			printf("node %d: parent = %d, depth = %d, leaf, ",i,nodes[i].parent,nodes[i].depth);
		}else{
			printf("node %d: parent = %d, depth = %d, internal node, ",i,nodes[i].parent,nodes[i].depth);
		}
		printf("[");
		for(int j = 0; j < nodes[i].num_of_children-1; j++){
			printf("%d, ",nodes[i].children[j]);
		}
		if(nodes[i].num_of_children > 0){
			printf("%d",nodes[i].children[nodes[i].num_of_children-1]);
		}
		printf("]\n");
	}
}


Measured memory_bytes: 7372
import heapq
h, w = map(int, input().split())
c = [list(map(int, input().split())) for _ in range(10)]
a = [list(map(int, input().split())) for _ in range(h)]
flag = [[1 for _ in range(10)] for _ in range(10)]
for i in range(10):
    que = [[0, i]]
    while que:
        now = heapq.heappop(que)
        flag[i][now[1]] = 0
        for j in range(10):
            if flag[i][j]:
                heapq.heappush(que, [c[i][now[1]]+ c[now[1]][j], j])
                if c[i][now[1]]+c[now[1]][j] < c[i][j]:
                    c[i][j] = c[i][now[1]]+ c[now[1]][j]

ans = 0      
for i in range(h):
    for j in range(w):
        if a[i][j] != -1:
            ans += c[a[i][j]][1]
print(ans)

Measured memory_bytes: 9552
#include <stdio.h>
 
int main(){
    int n,i;
    long sum=0;
    scanf("%d",&n);
    for(i=1;i<=n;i++){
    if(i%3==0){}
    else if(i%5==0){}
    else sum=sum+i;
    }
    printf("%ld",sum);
    
    return 0;
}    

Measured memory_bytes: 1704
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define repr(i,n) for(ll i=(n-1);i>=0;i--)
#define all(x) x.begin(),x.end()
#define br cout << "\n";
using namespace std;
const int INF = 1e9;
const int MOD = 1e9+7;
using Graph = vector<vector<ll>>;
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;}

// 0 false, 1 true 
// string to int : -48
// a to A : -32
// ceil(a)  1.2->2.0
// c++17	g++ -std=c++17 a.cpp

vector<pair<long long, long long> > prime_factorize(long long N) {
    vector<pair<long long, long long> > res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0; // 指数

        // 割れる限り割り続ける
        while (N % a == 0) {
            ++ex;
            N /= a;
        }

        // その結果を push
        res.push_back({a, ex});
    }

    // 最後に残った数について
    if (N != 1) res.push_back({N, 1});
    return res;
}


int main() {
    std::cout << std::fixed << std::setprecision(15);
    ll N;
    cin >> N;
    const auto &res = prime_factorize(N);

    if(res.size() == 0){
        cout << 0 << endl;
        return 0;
    }
    
    map<ll,ll> mp;
    for (auto p : res) {
        for (int i = 0; i < p.second; ++i){
            //cout << " " << p.first;
            mp[p.first]++;
        } 
    }
    

    ll tmp = 0;
    vector<ll> two;
    rep(i, 100){
        //cout << tmp + i+1 << endl;
        tmp += i+1;
        two.push_back(tmp);
    }

    ll ans = 0;
    for(auto i: mp){
      // << i.first << " " << i.second << endl;  //key, value
      auto Iter = upper_bound(all(two), i.second);
      ans += (ll)(Iter - two.begin());
    }
    cout << ans << endl;



}

Measured memory_bytes: 3644
#include<iostream>                          
#include<vector>                    
 #include<bits/stdc++.h>

#define mod 998244353
#define pi 3.14159265358979
#define  PRE(x,p) cout<<setprecision(x)<<p; 
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define endl "\n"
#define high INT_MAX
#define low INT_MIN
#define ll long long int
using namespace std;
ll a[500005],n;
vector<ll>v; 
void solve() 
{ 
  ll n,x,t,sum=0;
  string s;
  cin>>s;
  n=s.size();
  for(ll i=0;i<n;i++)
  {
          
      sum+=((ll)(s[i]-48));
      
  }
//   cout<<sum<<endl;
  if(sum%9==0)
  cout<<"Yes";
  else
  cout<<"No";
 
}
 
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
ll t=1;
//cin>>t;
while(t--)
solve();
 
return 0;
}

Measured memory_bytes: 3704
//2020.1.16
//s1270188 xxxmk2
//alds1_09b

#include<stdio.h>
#define N 500000

//prototype
void maxheap(int);

//global
int data[N+1], num;

int main(){
  int i;

  //input
  scanf("%d",&num);
  for(i=1;i<=num;i++) scanf("%d",&data[i]);

  //max heap
  for(i=num/2;i>0;i--) maxheap(i);

  //output
  for(i=1;i<=num;i++) printf(" %d",data[i]);
  printf("\n");
  
  return 0;
}

void maxheap(int i){
  int l=i*2, r=i*2+1, max;

  //printf("\t%d %d %d",data[i],data[l],data[r]);
    
  if(l<=num && data[l]>data[i]) max=l;
  else max=i;
  if(r<=num && data[r]>data[max]) max=r;

  //printf("\t%d\n",data[max]);
  
  if(max!=i){
    l=data[i];
    data[i]=data[max];
    data[max]=l;

    maxheap(max);
  }
}



Measured memory_bytes: 3660
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define fi first
#define se second
int main(){
	ll a,b; cin>>a>>b;
	if(a>0 and a<10 and b>0 and b<10) cout<<a*b;
	else cout<<-1;
}


Measured memory_bytes: 3560
n, k, c = map(int, input().split())
s = list(input())

forward = []
backward = []
i = 0
while i < len(s) and len(forward) < k:
    if s[i] == 'x':
        i += 1
        continue
    forward.append(i)
    i += c + 1
i = len(s)-1
while i > -1 and len(backward) < k:
    if s[i] == 'x':
        i -= 1
        continue
    backward.append(i)
    i -= c
    i -= 1

for i in range(len(forward)):
    if forward[i] == backward[len(backward) - i - 1]:
        print(forward[i] + 1)

Measured memory_bytes: 22020
#include<iostream>
using namespace std;
typedef long long ll;
#define fr(i,n) for(int i=0;i<n;i++)

int main(){
  ll k,a[100010],m=2,M=2;
  cin>>k;
  fr(i,k) cin>>a[k-1-i];
  fr(i,k){
    if((m-1)/a[i]+1>M/a[i]){
      cout<<-1<<endl;
      return 0;
    }
    m=((m-1)/a[i]+1)*a[i];
    M=(M/a[i])*a[i]+a[i]-1;
  }
  cout<<m<<" "<<M<<endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
using namespace std;

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> ab(2*M);
  for (int i=0; i<2*M; i++) {
    cin >> ab.at(i);
  }
  
  vector<int> res(N);
  for (int i=0; i<2*M; ++i) {
    res.at(ab.at(i)-1)++;
  }
  
  for (int i=0; i<N; ++i) {
    cout << res.at(i) << endl;
  }
}

Measured memory_bytes: 256
n,m=map(int,input().split())
s=list(range(1,n+1))
for i in range(m):
    p=int(input())
    q=list(map(int,input().split()))
    for j in q:
        if j in s:
            s[s.index(j)]=0
k=0
for i in s:
    if i>0:
        k+=1
print(k)

Measured memory_bytes: 9128
S = input()
a, z = 0, 0
for i in range(len(S)):
    if S[i] == 'A':
        a = i
        break
for i in range(len(S)-1, -1, -1):
    if S[i] == 'Z':
        z = i
        break
print(z-a+1)


Measured memory_bytes: 40048
s = input()

b = s[2:len(s)-1]
c = s.replace('A','').replace('C','')

if s[0] != 'A' :
   print('WA')

elif b.count('C') != 1 :
   print('WA')

elif c!=c.lower() :
   print('WA')

else :
   print('AC')

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

const int N=1e+5+3;
int vis[N],n,m;
int main()
{
    cin>>n>>m;
    int a1=0,a2=0;
    for(int i=1;i<=m;i++)
    {
        int p;
        string s;
        cin>>p>>s;
        if(s.compare("AC")==0)
        {
            if(vis[p]<=0)
            {
                a2+=abs(vis[p]);
                vis[p]=1;
                a1++;
            }
        }
        else 
        {
          if(vis[p]<=0)
            vis[p]--;
        }
    }
    cout<<a1<<" "<<a2;
}

Measured memory_bytes: 640
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;

int N;
int M;
int solve(vector<int>costs, vector<int>powers) {
	vector<vector<int>>dp(N+1,vector<int>(M+1));
	for (int idle_id = 0; idle_id < N; ++idle_id) {
		for (int money = 0; money <= M; ++money) {
			const int nextmoney=money+costs[idle_id];
			if (nextmoney <= M) {
				dp[idle_id][nextmoney]=max(dp[idle_id][nextmoney],dp[idle_id][money]+powers[idle_id]);

			}
			dp[idle_id+1][money]=max(dp[idle_id+1][money],dp[idle_id][money]);
		}
	}
	return *max_element(dp[N].begin(),dp[N].end());
}

int main() {
	while (cin>>N>>M) {
		vector<int>costs(N);
		vector<vector<int>>powers(3,vector<int>(N));
		string st;
		for (int i = 0; i < N; ++i) {
			getline(cin, st);
			getline(cin, st);
			
			cin>>costs[i]>>powers[0][i]>>powers[1][i]>>powers[2][i];
		}
		int ans=0;
		for (int i = 0; i < 3; ++i) {
			ans=max(ans,solve(costs,powers[i]));
		}
		cout<<ans<<endl;
	}
	return 0;
} 

Measured memory_bytes: 3312
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fi(i,a,b) for(ll i=a;i>=b;i--)
#define endl '\n'
#define spc " "
#define pb push_back
#define mp make_pair
#define mod 1000000007b
#define pi 3.14159265358979323
#define sz(a) (int)((a).size())
#define len(a) (int)(a.length())
#define FOR(i,j,k,l) for(ll i=j;i<k;i+=l)

void Fast_IO() {
   ios::sync_with_stdio(0);
   cin.tie(0);
   #ifndef ONLINE_JUDGE
   freopen("input.in","r",stdin);
   freopen("out.txt","w",stdout); 
   #endif
} 
vector<vector<ll> >vii;

int main(){
   //Fast_IO();
   string s,t;
   cin>>s>>t;
   ll ans=0;
   f(i,0,s.length()){
      if(s[i]!=t[i]) ans++;
   }
   cout<<ans<<endl;

      
}

Measured memory_bytes: 3928
N=int(input())
a=[0]+[int(i) for i in input().split()]
par=[0 for i in range(N+1)]
size=[0 for i in range(N+1)]
def find(x):
    if (par[x]==x):
        return x
    par[x]=find(par[x])
    return par[x]
def unite(x,y):
    x=find(x)
    y=find(y)
    res=size[x]*size[y]
    size[x]+=size[y]
    par[y]=x
    return res
for i in range(N+1):
    par[i]=i
    size[i]=1
b=[0 for i in range(N+1)]
for i in range(N+1):
    b[a[i]]=i
ans=0
for j in range(1,N+1)[::-1]:
    i=b[j]
    ans+=a[i]
    if i-1>=1 and a[i-1]>a[i]:
        ans+=unite(i-1,i)*a[i]
    if i+1<=N and a[i+1]>a[i]:
        ans += unite(i+1,i)*a[i]
print(ans)


Measured memory_bytes: 107816
import java.io.*;
import java.util.*;

public class Main {

	void submit() {
		int q = nextInt();
		int h = nextInt();
		int s = nextInt();
		int d = nextInt();
		
		long n = nextLong() * 4;
		
		h = Math.min(h, 2 * q);
		s = Math.min(s, 2 * h);
		d = Math.min(d, 2 * s);
		
		long ans = 0;
		ans += (n / 8) * d;
		n %= 8;
		
		ans += (n / 4) * s;
		n %= 4;
		
		ans += (n / 2) * h;
		n %= 4;
		ans += n* q;
		
		out.println(ans);
	}

	void preCalc() {

	}

	void stress() {

	}

	void test() {

	}

	Main() throws IOException {
		br = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);
		preCalc();
		submit();
		//stress();
		//test();
		out.close();
	}

	static final Random rng = new Random();

	static int rand(int l, int r) {
		return l + rng.nextInt(r - l + 1);
	}

	public static void main(String[] args) throws IOException {
		new Main();
	}

	BufferedReader br;
	PrintWriter out;
	StringTokenizer st;

	String nextToken() {
		while (st == null || !st.hasMoreTokens()) {
			try {
				st = new StringTokenizer(br.readLine());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return st.nextToken();
	}

	String nextString() {
		try {
			return br.readLine();
		} catch (IOException e) {
			throw new RuntimeException(e);
		}
	}

	int nextInt() {
		return Integer.parseInt(nextToken());
	}

	long nextLong() {
		return Long.parseLong(nextToken());
	}

	double nextDouble() {
		return Double.parseDouble(nextToken());
	}
}


Measured memory_bytes: 23124
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define PI 3.141592653589793
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int main(){
    ll K,N;
    cin >> K >> N;
    vector<ll> A(N);
    for(int i = 0; i < N; i++){
        cin >> A[i];
    }
    ll maxdistance=0;
    for(int i = 1; i < N; i++){
        maxdistance = max(maxdistance, A[i]-A[i-1]);
        // cout << maxdistance  << endl;
    }
    maxdistance = max(maxdistance, K-A[N-1]+A[0]);
    // cout << maxdistance  << endl;
    cout << K-maxdistance  << endl;

}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mk make_pair
#define pb push_back
int main()
{
ios_base ::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int n;cin>>n;ll h[n+1];h[0]=0;int k;cin>>k;
for(int i=1;i<=n;i++)
{
    cin>>h[i];
}
ll dp[n+1];
for(int i=0;i<=n;i++){dp[i]=10000000000000000;}
dp[0]=0;dp[1]=0;
dp[2]=dp[1]+abs(h[2]-h[1]);
for(ll i=3;i<=n;i++)
{
    for(int j=1;j<=k;j++)
    {
        if(j>=i){break;}
        ll c=dp[i-j]+abs(h[i]-h[i-j]);
        dp[i]=min(c,dp[i]);

    }

}
cout<<dp[n];
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using vll = vector<ll> ;
#define all(v) v.begin(),v.end()


int main(){
  ll A,B,Q;cin>>A>>B>>Q;
  vll s(A),t(B),x(Q);
  rep(i,A)cin>>s[i];  sort(all(s));
  rep(i,B)cin>>t[i];  sort(all(t));
  rep(i,Q)cin>>x[i];
  rep(i,Q){
    int a = lower_bound(all(s),x[i]) - s.begin();
    int b = lower_bound(all(t),x[i]) - t.begin();
    ll tmp=1e12;
    //→→　←←　→←　←→
    if(a<A && b<B) tmp = min(tmp,max(s[a],t[b])-x[i]);
    if(a-1>=0 && b-1>=0) tmp = min(tmp,x[i]-min(s[a-1],t[b-1]));
    if(a<A && b-1>=0)tmp = min(tmp,s[a]-x[i]+s[a]-t[b-1]);
    if(b<B && a-1>=0)tmp = min(tmp,t[b]-x[i]+t[b]-s[a-1]);
    if(b<B && a-1>=0)tmp = min(tmp,x[i]-s[a-1]+t[b]-s[a-1]);
    if(a<A && b-1>=0)tmp = min(tmp,x[i]-t[b-1]+s[a]-t[b-1]);
    cout << tmp << endl;
  }
}

Measured memory_bytes: 3712
#include<bits/stdc++.h>
using namespace std;
const int N = 110;
int a[N], n;


int main()
{
	cin >> n;
	int sum = 0;
	for (int i = 1; i <= n; ++ i)
		cin >> a[i], sum += a[i];
	for (int i = 1; i <= n; ++ i)
		if (a[i] >= sum-a[i]){
			puts("No");
			return 0;
		}
	puts("Yes");
	return 0;
}

Measured memory_bytes: 256
import math

n, d = map(int, input().split())
l = []
for i in range(n):
    l.append(list(map(int, input().split())))

count = 0  
for i in range(len(l)):
    for j in range(i+1, len(l)):
        l1 = l[i]
        l2 = l[j]
        s = 0
        for k in range(d):
            s += (l1[k] - l2[k])**2
        if math.sqrt(s) == int(math.sqrt(s)):
            count += 1
            
print(count)

Measured memory_bytes: 3064
from bisect import bisect_right

N = int(input())
L = list(map(int, input().split()))
L.sort()
ans = 0
for i in range(N):
    for j in range(i + 1, N):
        b = L[i]
        c = L[j]
        M = L[i+1:j]
        ans += bisect_right(M, b + c - 1) - bisect_right(M, c - b)
print(ans)

Measured memory_bytes: 79896
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<deque>
#include<tuple>
#include<queue>
#include<map>
#include<cstdint>
#include<unordered_map>
#include<boost/multiprecision/cpp_int.hpp>


#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define Endl endl
#define F first
#define S second

namespace mp = boost::multiprecision;

using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;


int main() {
	int n;
	cin >> n;
	vector<int>a(n), b(n), c(n);
	rep(i, n) {
		scanf("%d", &a[i]);
	}
	rep(i, n) {
		scanf("%d",& b[i]);
	}
	rep(i, n) {
		scanf("%d",&c[i]);
	}
	sort(all(a));
	sort(all(b));
	sort(all(c));
	vector<int>biggerC(n);
	rep(i, n) {
		int tmp=upper_bound(all(c), b[i])-c.begin();
		if (tmp < b.size()) {
			biggerC[i] = b.size() - tmp;
		}
	}
	vector<int>smallerA(n);
	rep(i, n) {
		int tmp = lower_bound(all(a), b[i]) - a.begin();
		smallerA[i] = tmp;		
	}
	
	ll ans = 0;
	rep(i, n) {
		ans += (ll)smallerA[i] * biggerC[i];
	}
	cout << ans << endl;
}


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

typedef long long ll;
using namespace std;


int main(void) {
   ll N;
   cin>>N;
   multimap<int,int> A;
   ll a;
   rep(i,N) {
      cin>>a;
      A.insert(make_pair(a,i));
   }
   auto itr = A.end();
   itr--;
   rep(i,N) {
      if (i!= itr->second) cout<<itr->first<<endl;
      else {
         itr--;
         cout<<(itr)->first<<endl;
         itr++;
      }
   }






   return 0;
}

Measured memory_bytes: 11008
//26
#include<iostream>
#include<queue>
#include<set>
#include<complex>
#include<cmath>

using namespace std;

typedef complex<double> P;

struct S{
  double d;
  int l,r;
  bool operator<(S a)const{
    return d>a.d;
  }
};

int main(){
  for(int n;cin>>n,n;){
    int x[100],y[100];
    set<int> s;
    for(int i=0;i<n;i++){
      cin>>x[i]>>y[i];
      s.insert(y[i]);
    }
    vector<P>v;
    for(int i=0;i<n-1;i++){
      v.push_back(P(x[i],y[i]));
      set<int>::iterator l,h;
      l=s.find(y[i]);
      h=s.find(y[i+1]);
      bool f=*h>*l;
      if(l!=h){
	f?l++:l--;
	while(l!=h){
	  v.push_back(P((*l-y[i])*(x[i+1]-x[i])*1./(y[i+1]-y[i])+x[i],*l));
	  f?l++:l--;
	}
      }
    }
    v.push_back(P(x[n-1],y[n-1]));
    S is={0,0,v.size()-1};
    priority_queue<S> que;
    que.push(is);
    vector<vector<bool> > p(v.size(),vector<bool>(v.size()));
    for(;;){
      S c=que.top();
      if(c.l==c.r)break;
      que.pop();
      if(p[c.l][c.r])continue;
      p[c.l][c.r]=true;
      for(int i=-1;i<=1;i++){
	int nl=c.l+i;
	if(nl<0||v.size()<=nl)continue;
	for(int j=-1;j<=1;j++){
	  int nr=c.r+j;
	  if(nr<0||v.size()<=nr||1e-9<fabs(v[nl].imag()-v[nr].imag()))continue;
	  S ns={c.d+abs(v[c.l]-v[nl])+abs(v[c.r]-v[nr]),nl,nr};
	  que.push(ns);
	}
      }
    }
    cout<<fixed<<que.top().d<<endl;
  }
  return 0;
}
	  

Measured memory_bytes: 4332
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef pair<int, int> P;
typedef long long ll;
ll dp[410][410];
ll n;
ll a[410];
ll imos[410];
ll rec(int l, int r){
    if(dp[l][r]){
        return dp[l][r];
    }
    if(l+1==r){
        return dp[l][r] = a[l];
    }
    ll cost = 1e18;
    for(int i = l+1;i<r;i++){
        cost = min(rec(l,i)+rec(i,r),cost);
    }
    return dp[l][r] = cost+imos[r]-imos[l];
}
int main(){
    cin >> n;
    rep(i,n){
        cin >> a[i];
        imos[i+1] = imos[i]+a[i];
    }
    cout << rec(0,n) - imos[n] << endl;
    return 0;
}

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

int main() {
    string s;
    cin >> s;
    int a = s.size();
    for (int i = 0; i < a; i++)
    {
        cout << "x";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string.h>
#include <vector>
#include <algorithm>
using namespace std;

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

    if(s == "ABC"){
        printf("ARC\n");
    }
    else if(s == "ARC"){
        printf("ABC\n");
    }

    return 0;
    
}

Measured memory_bytes: 3596
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		new Main().execute();
	}

	public void execute() {
		Scanner sc = new Scanner(System.in);
		final int N = sc.nextInt();
		final int T = sc.nextInt();
		int totalTime = 0;
		int sos = -1; // start of shower
		int eos = -1; // end of shower
		for (int i = 0; i < N; i++) {
			int ti = sc.nextInt();
			if (ti > eos) {
				totalTime += eos - sos;
				sos = ti;
			}
			eos = ti + T;
		}
		totalTime += eos -sos;
		System.out.println(totalTime);
		sc.close();
	}

}


Measured memory_bytes: 62948
#include <iostream>
using namespace std;
int main(void)
{
    int n; cin >> n;
    int a[100001];
    for(int i=1;i<=n;i++){
        int x; cin >> x;
        a[x] = i;
    }
    for(int i=1;i<=n;i++) cout << a[i] << " ";
    puts("");
}


Measured memory_bytes: 1152
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>
#include<utility>
#include<queue>

using namespace std;

#define int long long
#define endl "\n"

constexpr long long INF = (long long)1e18;
constexpr long long MOD = 1'000'000'007; 

struct fast_io {
	fast_io(){
		std::cin.tie(nullptr);
		std::ios::sync_with_stdio(false);
	};
// } ;
} fio;

void dijkstra(int s, vector<int> &d, vector<vector<pair<int,int>>> &G){
	priority_queue<pair<int,int>,vector<pair<int,int>>,greater<pair<int,int>>> q;
	
	d.clear();
	d.resize(G.size(),INF);
	d[s] = 0;
	q.push(make_pair(0,s));
	
	while(!q.empty()){
		pair<int,int> p = q.top();q.pop();
		int v = p.second;
		
		if(d[v] < p.first) continue;
		
		for(pair<int,int> e : G[v]){
			if(d[e.first] > d[v] + e.second){
				d[e.first] = d[v] + e.second;
				q.push(make_pair(d[e.first],e.first));
			}
		}
	}	
}

signed main(){
	cout<<fixed<<setprecision(10);
	
	const int maxA = 52;
	int N, M, S;
	int Z;
	vector<int> d;
	vector<vector<pair<int,int>>> G;
	vector<vector<pair<int,pair<int,int>>>> g;
	
	cin>>N>>M>>S;
	
	Z = M * maxA;
	
	G.resize(N * Z);
	g.resize(N);
	
	
	for(int i = 0; i < M; i++){// cout<<i<<endl;
		int U, V, A, B;
		
		cin>>U>>V>>A>>B;
		
		U--, V--;
		
		g[U].push_back({V,{A,B}});
		g[V].push_back({U,{A,B}});
	}
	
	for(int i = 0; i < N; i++){
		int C, D;
		
		cin>>C>>D;
		
		for(int j = 0; j < Z; j++){
			for(int k = 0; k < g[i].size(); k++){
				int A = g[i][k].second.first;
				int B = g[i][k].second.second;
				if(j - A < 0) continue;
				G[i * Z + j].push_back({g[i][k].first * Z + j - A, B});
				// G[g[i][k].first * Z + j - g[i][k].second.first ].push_back({i * Z + j,g[i][k].second.second});
			}
		}
		
		for(int j = 0; j < Z; j++){
			G[i * Z + j].push_back({i * Z + min(Z-1, j + C),D});
		}
	}
	
	S = min(S, Z-1);
	
	dijkstra(Z * 0 + S, d, G);
	
	
	for(int i = 1; i < N; i++){
		int ans = INF;
		for(int j = 0; j < Z; j++){
			ans = min(ans, d[i * Z + j]);
		}
		
		cout<<ans<<endl;
	}
	
	return 0;
}

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

using namespace std;

int main(void)
{
	int n;
	cin >> n;
	vector<int> b(n+1);
	for (int i = 1; i <= n; i++) {
		cin >> b[i];
	}

	deque<int> a;

	while (b.size() != 1) {
		for (int i = b.size()-1; i >= 1; i--) {
			if (b[i] == i) {
				a.push_front(b[i]);
				b.erase(b.begin() + i);
				break;
			}
			if (i == 1) {
				cout << -1 << endl;
				return 0;
			}
		}
	}
	for (int i = 0; i < n; i++) {
		cout << a.front() << endl;
		a.pop_front();
	}

	return 0;
}

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

// DP テーブル
long long dp[3100][3100];

int main() {
    // 入力受け取り
    int N; cin >> N;
    vector<int> a(N);
    for (int i = 0; i < N; ++i) cin >> a[i];
    
    // 初期条件
    for (int i = 0; i < N; ++i) dp[i][i] = 0;
    
    // DP
    for (int len = 1; len <= N; ++len) {
        for (int i = 0; i + len <= N; ++i) {
            int j = i + len;

            // 先手番
            if ((N - len) % 2 == 0)
                dp[i][j] = max(dp[i + 1][j] + a[i], dp[i][j - 1] + a[j - 1]);
            
            // 後手番
            else
                dp[i][j] = min(dp[i + 1][j] - a[i], dp[i][j - 1] - a[j - 1]);
        }
    }
    
    // 答え
    cout << dp[0][N] << endl;
}

Measured memory_bytes: 73984
N = int(input())
A = [int(i) for i in input().split()]

B = sorted(A)
pivot = B[-1] / 2.0
min_diff = B[-1]
min_index = None
for i, b in enumerate(B):
    diff = abs(b - pivot)
    if diff < min_diff:
        min_diff = diff
        min_index = i

print(B[-1], B[min_index])


Measured memory_bytes: 14052
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <iomanip>
#include <climits>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<string> VS;
typedef vector< vector<int> > VVI;
typedef vector< vector<ll> > VVL;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define pf push_front
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ub upper_bound
#define lb lower_bound

int main(){
  int N,M;
  cin>>N>>M;
  VI A(N),B(M);
  rep(i,N) cin>>A[i];
  rep(i,M) cin>>B[i];
  VI NN(N*M+1),MM(N*M+1);
  rep(i,N) NN[A[i]]++;
  rep(i,M) MM[B[i]]++;
  rep(i,N*M){
    if(NN[i+1]>1 or MM[i+1]>1){
      cout<<0<<endl;
      return 0;
    }
  }
  VI NNN(N*M+1),MMM(N*M+1);
  rep(i,N*M+1) NNN[i]=NN[i];
  rep(i,N*M+1) MMM[i]=MM[i];
  rep(i,N*M) NN[N*M-1-i]+=NN[N*M-i];
  rep(i,N*M) MM[N*M-1-i]+=MM[N*M-i];
  ll ans=1;
  ll mod=1e9+7;
  rep(i,N*M){
    if(NNN[i+1] and MMM[i+1]) continue;
    else if(NNN[i+1]) (ans*=MM[i+1])%=mod;
    else if(MMM[i+1]) (ans*=NN[i+1])%=mod;
    else{
      ll tmp=1;
      (tmp*=NN[i+1])%=mod;
      (tmp*=MM[i+1])%=mod;
      (tmp+=mod-(N*M-i-1))%=mod;
      (ans*=tmp)%=mod;
    }
  }
  cout<<ans<<endl;
}

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

using namespace std;

typedef long long ll;

int main() {
    int n;
    cin >> n;
    vector<int> h(n);
    for (int i = 0; i < n; i++) {
        cin >> h[i];
    }
    vector<int> a(n), b(n);
    for (int i = 0; i < n; i++) {
        a[i] = h[i] + i;
        b[i] = h[i] - i;
    }
    unordered_map<int, vector<int>> indices;
    for (int i = 0; i < n; i++) {
        indices[b[i]].push_back(i);
    }

    ll ans = 0LL;
    // a[i] + b[j] = 0 (j > i)
    for (int i = 0; i < n; i++) {
        // index j where b[j] = -a[i]
        vector<int> index = indices[-a[i]];
        auto pointer = upper_bound(index.begin(), index.end(), i);
        ll d = (ll) distance(pointer, index.end());
        ans += d;
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

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

  int x;
  cin >> x;
  int ans = (x / 500) * 1000;
  x %= 500;
  cout << ans + x / 5 * 5;

  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
using namespace std;
int main() {
	int N;
	scanf("%d", &N);
	int X[N], ans = 1000000;
	for (int i = 0; i < N; ++i) scanf("%d", &X[i]);
	for (int i = 1; i <= 100; ++i) {
		int k = 0;
		for (int j = 0; j < N; ++j) k += (i - X[j]) * (i - X[j]);
		if (k < ans) ans = k;
	}
	printf("%d", ans);
	return 0;
}

Measured memory_bytes: 128
var
	x,y,xx,yy,n,i,a,b,c:Longint;
begin
	read(xx,yy,n);
	for i:=1 to n do begin
		read(a,b,c);
		if(c=1)and(x<a)then x:=a else if(c=2)and(a<xx)then xx:=a else if(c=3)and(y<b)then y:=b else if(c=4)and(b<yy)then yy:=b;
	end;
	x:=xx-x;
	if x<0 then x:=0;
	y:=yy-y;
	if y<0 then y:=0;
	write(x*y);
end.


Measured memory_bytes: 128
N,M=map(int,input().split())
list1=list(map(int,input().split()))
del list1[0]
set1=set(list1)
for i in range(N-1):
  list2=list(map(int,input().split()))
  del list2[0]
  set2=set(list2)
  set1=set1&set2
ans=len(set1)
print(ans)

Measured memory_bytes: 3064
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		String op = sc.next();
		int B = sc.nextInt();
		if(op.equals("+"))System.out.println(A + B);
		if(op.equals("-"))System.out.println(A - B);
	}
}

Measured memory_bytes: 21844
import sys
N = int(input())
arr = []

for i in range(N):
    arr.append(list(map(int, input().split())))

if N == 1:
    print(1)
    sys.exit()

d = {}

for i in range(N):
    for j in range(N):
        if i != j:
            x = arr[i][0] - arr[j][0]
            y = arr[i][1] - arr[j][1]
            if (x, y) in list(d.keys()):
                d[(x, y)] += 1
            else:
                d[(x, y)] = 1

print(N - max(list(d.values())))

Measured memory_bytes: 3444
#include <iostream>
#include <string>
#include <array>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
#include <cctype>
#include <map>
#include <stdio.h>
#include <string.h>


#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

using namespace std;

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

    string s;
    bool ans = true;
    map<char,int>mp;

    cin >> s;
    for(int i = 0; i < 26; i ++){
        mp[(char)('a'+i)] = 0;
    }
    for(int i = 0; i < s.length(); i ++){
        mp[s[i]] ++;
    }

    for(int i = 0; i < 26; i ++){
        if(mp[(char)('a'+i)]%2 != 0) ans = false;
    }

    if(ans == true) cout << "Yes";
    else cout << "No";
    return 0;
}









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

using namespace std;

#define deg_to_rad(deg) (((deg) / 360) * 2 * M_PI)
#define rad_to_deg(rad) (((rad) / 2 / M_PI) * 360)


int a, b, h, m;

double ma, ha, ang, ans;

void pre(){
    
 ma = m * 360.0 / 60.0;
  ha = h * 360.0 / 12.0;
  ha += m * 360.0 / 720.0;
  ang = max(ma, ha) - min(ma, ha);
  if (ang > 180) {
    ang = 360 - ang;
  }
  ang = deg_to_rad(ang);

  ans = sqrt((a * a) + (b * b) - (2 * a * b * cos(ang)));
}

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

  
  cin >> a >> b >> h >> m;
pre();
  
  cout << ans << '\n';

  return 0;
}

Measured memory_bytes: 4240
#include<queue>
#include<cstdio>
#include<cstring>
#include<algorithm>
#define key 2333
#define maxn 100005
#define uLL unsigned long long
using namespace std;
uLL hsh[maxn],bas[maxn];
char s[maxn];
int n;
priority_queue<int> hep;
inline int read(){
	int ret=0,f=1;char ch=getchar();
	while (ch<'0'||ch>'9'){if (ch=='-') f=-1;ch=getchar();}
	while (ch>='0'&&ch<='9') ret=ret*10+ch-'0',ch=getchar();
	return ret*f;
}
inline bool check(int p){
	for (int i=1;i<=n-p*2+1;i++)
	for (int j=i+p;j<=n-p+1;j++)
	if (hsh[i+p-1]-hsh[i-1]*bas[p]==hsh[j+p-1]-hsh[j-1]*bas[p]) return 1;
	return 0;
}
int main(){
	n=read();
	scanf("%s",s+1);
	bas[0]=1;
	for (int i=1;i<=n;i++) hsh[i]=hsh[i-1]*key+s[i]-'a',bas[i]=bas[i-1]*key;
	int L=0,R=n/2,ret=0;
	while (L<=R){
		int mid=(L+R)>>1;
		if (check(mid)) ret=mid,L=mid+1;
		else R=mid-1;
	}
	printf("%d\n",ret);
	return 0;
}

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

typedef long long ll;

void solve()
{
    ll n, x, t = INT_MIN;
    cin >> n;
    ll ans = 0;
    for (int i = 0; i < n; i++)
    {
        cin >> x;
        t = max(t, x);
        ans += max(0LL, t - x);
    }
    cout << ans << endl;
}

int main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int t = 1;
    // cin >> t;
    for (int i = 1; i <= t; i++)
    {
        // cout << "Case #" << i << ": ";
        solve();
    }
}

Measured memory_bytes: 3628
import java.lang.*;
import java.io.*;
import java.util.*;

class Main{
	public static void main(String args[]) throws FileNotFoundException{
		Scanner sc=new Scanner(System.in);
		
		String s=sc.nextLine();
		int w=Integer.parseInt(sc.nextLine());
		int br=1;
		System.out.print(s.charAt(0));
		
		for(int i=1; i<s.length(); i++){
			if(br==w){
				System.out.print(s.charAt(i));
			}
			br= (br==w)? 1: br+1; 
		}
	}

	static void disp(int[] data){
		for(int i=0; i<data.length; i++){
				System.out.printf("%d ",data[i]);
		}
			System.out.println();
	}
}


Measured memory_bytes: 22996
import kotlin.math.*

fun main(args: Array<String>) {
    val (a, b, h, m) = readLine()!!.split(" ").map { it.toInt() }

    // 時針角度
    val th: Double = (h*60.0 + m) / 720.0 * 2.0*PI
    // 時針の座標
    val xh: Double = a * cos(th)
    val yh: Double = a * sin(th)

    // 分針角度
    val tm: Double = m / 60.0 * 2.0*PI
    // 分針の座標
    val xm: Double = b * cos(tm)
    val ym: Double = b * sin(tm)

    // 2点間の座標の距離を求める

    // 各座標の差分
    val dx: Double = xh - xm
    val dy: Double = yh - ym

    val ans: Double = sqrt(dx*dx + dy*dy)
    println(ans)
}

Measured memory_bytes: 36608
n = int(input())
c = [1]
x = 6
while x <= n:
    c.append(x)
    x *= 6
x = 9
while x <= n:
    c.append(x)
    x *= 9
l = len(c)
dp = [[float("inf")]*(n+1) for _ in range(l+1)]
dp[0][0] = 0
for i in range(l):
    for yen in range(n+1):
        if yen - c[i] < 0: dp[i+1][yen] = dp[i][yen]
        else: dp[i+1][yen] =  min(dp[i][yen],dp[i+1][yen-c[i]]+1)
# for i in range(l+1): print(dp[i])
print(dp[l][n])

Measured memory_bytes: 23796
// ALDS_1_2_A.cpp
// Bubble Sort

#include <iostream>
#include <vector>
using namespace std;

void trace(vector<int> &nums, int N)
{
	for (int i = 0; i < N; i++) {
		if (i >= 1) cout << " ";
		cout << nums[i];
	}
	cout << endl;
}

void myswap(int &a, int &b)
{
	int t = a;
	a = b;
	b = t;
}

void bubbleSort(vector<int> &nums, int N, int &cnt)
{
	for (int i = N; i >= 0; i--) {
		for (int j = 0; j + 1 < i; j++) {
			if (nums[j] > nums[j+1]) {
				myswap(nums[j], nums[j+1]);
				cnt++;
			}
		}
	}
}

int main()
{
	int N;
	cin >> N;
	vector<int> nums(N);
	for (int i = 0; i < N; i++) {
		cin >> nums[i];
	}
	int cnt = 0;
	bubbleSort(nums, N, cnt);
	trace(nums, N);
	cout << cnt << endl;
	return 0;
}

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

using namespace std;

typedef long long ll;

const ll MOD = 1e9 + 7;

int main() {
    ll n, k;
    cin >> n >> k;
    ll ans = 0;
    for (ll i = k; i <= n + 1; i++) {
        ll mn = i * (i - 1) / 2;
        ll mx = (n + n - i + 1) * i / 2;
        ans += mx - mn + 1;
        ans %= MOD;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 3636
require 'prime'

N = gets.to_i
MOD = 10 ** 9 + 7

counter = Hash.new(0)

(1..N).each do |i|
  i.prime_division.each do |b, c|
    counter[b] += c
  end
end

ans = 1

counter.each do |k, v|
  ans = (ans * (v + 1)) % MOD
end

puts ans


Measured memory_bytes: 3964
#include <iostream>
#include <iomanip>
#include <string>
#include <string.h>
#include <math.h>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <deque>
#include <queue>
#include <functional>
//#include <boost/multiprecision/cpp_int.hpp>

#define rep(i, n) for(int i = 0; i < n; ++i)
#define REP(i, m, n) for(int i = m; i < n; ++i)
#define rrep(i,n) for(int i = n; i >= 0; --i)
#define RREP(i, m, n) for(int i = n; i >= m; --i)
#define llrep(i, n) for(ll i = 0; i < n; ++i)
#define llREP(i, m, n) for(ll i = m; i < n; ++i)
#define llrrep(i,n) for(ll i = n; i >= 0; --i)
#define llRREP(i, m, n) for(ll i = n; i >= m; --i)

using ll = long long;
using ull = unsigned long long;
using pii = std::pair<int, int>;
using pll = std::pair<long long, long long>;
using pil = std::pair<int, long long>;
using pli = std::pair<long long, int>;
using plpii = std::pair<long long, std::pair<int, int>>;
using pdd = std::pair<double, double>;

const long long INF = 1000000000000000001;
const long long _MOD = 1000000007;
const long long MOD = 998244353;
const int ALPHABET = 27;
const double pi = 3.14159265358979;

using namespace std;
//namespace mp = boost::multiprecision;

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

	string s;
	cin >> s;

	rep(i, s.length()) {
		if (s[i] == '?') {
			s[i] = 'D';
		}
	}

	cout << s << "\n";

	return 0;
}



Measured memory_bytes: 3780
using System;

 class test
{
	static void Main(string[] args)
	{
		int a,b;
		string[] str = getArgs(Console.ReadLine());
		a = int.Parse(str[0]);
		b = int.Parse(str[1]);
		Console.WriteLine("{0} {1}", a*b, a*2+b*2);
	}
	public static string[] getArgs(string line)
	{
		return line.Split(' ');
	}
}



Measured memory_bytes: 15952
from collections import deque
from collections import Counter
from itertools import product, permutations,combinations
from operator import itemgetter
from heapq import heappop, heappush
from bisect import bisect_left, bisect_right, bisect
#pypyではscipy, numpyは使えない
#from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson, minimum_spanning_tree
#from scipy.sparse import csr_matrix, coo_matrix, lil_matrix
#import numpy as np
from fractions import gcd
from math import ceil,floor, sqrt, cos, sin, pi, factorial
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**8)
INF = float('inf')
from datetime import datetime as dt

def main():
  x = int(input())
  if x==7 or x==5 or x==3:
    print('YES')
  else:
    print('NO')
  
  
  
if __name__ == '__main__':
  main()

Measured memory_bytes: 5344
#!/usr/bin/env python

import sys

v1mask= set()
v2mask= set()

def getVertex(i,e):
    global v1mask, v2mask
    v= set()
    for v1 in e[i]:
        if v1 in v1mask: continue
        v1mask.add( v1 )
        for v2 in e[v1]:
            if v2 in v2mask: continue
            v2mask.add( v2 )
            for v3 in e[v2]: v.add( v3 )
    #
    return v
#
n,m = [ int(x) for x in sys.stdin.readline().split() ]
e = { i:[] for i in range(n) }
for _ in range(m):
    u,v = [ int(x) for x in sys.stdin.readline().split() ]
    e[u-1].append( v-1 )
s,t = [ int(x)-1 for x in sys.stdin.readline().split() ]
#
hop= 0
now = {s}
visit = {s}
while True:
    hop+= 1
    n= set()
    for i in now:
        n |= getVertex(i,e) - visit
        if t in n: break
    #
    if t in n: break
    if not n:
        hop= -1
        break
    now = n
    visit|= n
#
print( hop )


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

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

    int r;
    cin >> r;

    double ans = (double)r * 2 * 3.141592;
    cout << ans << '\n';
    return 0;
}


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

int main(){
	/*input*/
	vector<string>integer(2);
	cin >> integer[0] >> integer[1];
	/*calculation*/
	string tmp = integer[0] + integer[1];
	int number = stoi(tmp);
	bool flag = false;	//true:Yes false:No
	for(int i = 1; i*i <= number && !flag; i++){
		if(i*i == number)flag = true;
	}
	/*output*/
	if(flag){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;
const int MAX_N = 100;

int main() {
  int n, b, f, r, v;

  int bill[4][3][10] = {};

  cin >> n;

  for (int i = 0; i < n; ++i)
    {
      cin >> b >> f >> r >> v;

      bill[b-1][f-1][r-1] = bill[b-1][f-1][r-1] +v;
    }

  for (int i = 0; i < 4; ++i)
    {
      for (int j = 0; j < 3; ++j)
        {
          for (int k = 0; k < 10; ++k)
            {
              cout << " " << bill[i][j][k];
            }
          cout << endl;
        }
      if (i != 3)
        {
          cout << "####################" << endl;
        }
    }

}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define zep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(ll i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

int main(){
	cin.tie(0); ios::sync_with_stdio(false);
	
	ll n, a;
	cin >> n >> a;
	if(n%500 <= a){
		print("Yes")
	}
	else{
		print("No")
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
// Welcome to my source code!

int main() {
    int n;
    cin >> n;
    int a[n];
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        a[i] -= i + 1;
    }
    sort(a, a+n);
    ll ans = 0;
    for (int i = 0; i < n; i++) {
        ans += abs(a[i] - a[n / 2]);
    }
    cout << ans << endl;
}

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

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

	vector<int> v(n);
	vector<int> c(n);
	rep(i, n) cin >> v.at(i);
	rep(i, n) cin >> c.at(i);

	int sum = 0;
	rep(i, n){
		if(v.at(i) > c.at(i)) sum += v.at(i)-c.at(i);
	}

	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
string xx[]={"7","5","3"};
int n,ans;
int main(){
	cin >> n;
	set<string> t;
	t.insert("");
	while(t.size()){
		set<string> p;
		for (auto y:t){
			if(y.size()>=9)continue;
			for(auto s:xx){
				string k = y+s;
				if(k.find('7')!=k.find('0'))
				if(k.find('5')!=k.find('0'))
				if(k.find('3')!=k.find('0'))
				if(stoi(k)<=n)ans++;
				p.insert(y+s);
			}
		}
		t = p;
	}
	cout << ans << endl;
}

Measured memory_bytes: 3328
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include<numeric>
#include <cmath>
#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(int i = m; i < n; i++)
//#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const ll INF = 1LL << 63;

int main(){
    cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	//cout << fixed << setprecision(15);
    ll x; cin >> x;
    ll a = 100;
    int itr = 0;
    //cout << a * 1.01<<endl;
    REP(i,4000){
        a = a * 1.01;
        if(x <= a){
            cout << i+1 << endl;
            break;
        }
    } 
    //cout << a * 1.01<<endl;
    
}

Measured memory_bytes: 3604
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int temp, x, y;
		while(true){
			x = sc.nextInt();
			y = sc.nextInt();
			if( x == 0 && y == 0 ){
				break;
			}
			if(x > y){
				temp = x;
				x = y;
				y = temp;
			}
			System.out.println(x + " " + y);
		}
	}
}

Measured memory_bytes: 36676
#include<iostream>

using namespace std;

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

	int n;
	cin >> n;
	int sum = 0; int max = -1;
	for(int i=0; i<n; i++){
		int side;
		cin >> side;
		if(side>max) max = side;
		sum += side;
	}
	if(sum-2*max>0) cout << "Yes";
	else cout << "No";
	return 0;
}

Measured memory_bytes: 3656
#include <cstdio>

double E[301][301][301];
int count[4];

int main()
{
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; ++i)
  {
    int a;
    scanf("%d", &a);
    count[a]++;
  }
  for (int k = 0; k <= n; ++k)
  {
    for (int j = 0; j <= n; ++j)
    {
      for (int i = 0; i <= n; ++i)
      {
        if (i + j + k == 0 || i + j + k > n) continue;
        E[i][j][k] = (n
          + (i > 0 ? i * E[i - 1][j][k] : 0)
          + (j > 0 ? j * E[i + 1][j - 1][k] : 0)
          + (k > 0 ? k * E[i][j + 1][k - 1] : 0)) / double(i + j + k);
      }
    }
  }
  printf("%.12f\n", E[count[1]][count[2]][count[3]]);
  return 0;
}

Measured memory_bytes: 213120
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n;
cin>>n;
if(n%10==2||n%10==4||n%10==5||n%10==7||n%10==9)
cout<<"hon";
else if(n%10==3)
cout<<"bon";
else
cout<<"pon";
}


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

int n;
int c[10][10];

int main() {
	cin >> n;
	for (int i = 1; i <= n; i++) {
		int lsd = i % 10;
		int msd = i;
		while (msd / 10 > 0) {
			msd /= 10;
		}
		c[lsd][msd]++;
	}
	long long res = 0;
	for (int i = 1; i <= 9; i++) {
		for (int j = 1; j <= 9; j++) {
			res += c[i][j] * c[j][i];
		}
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int MOD = (int)1e9 + 7;
const int INF = 100100100;
const double PI = 3.14159265358979323846;
typedef long long ll;
#define FOR(i, a, b) for (ll i = (a); i < (b); ++i)
#define REP(i, n) for (ll i = 0; i < (n); ++i)

int main() {
  ll x, m = 100;
  cin >> x;
  ll year;
  for (year = 0; m < x; ++year) {
    m *= 1.01;
  }
  cout << year << endl;
  return 0;
}

Measured memory_bytes: 3636
import math
A, B, H, M = map(int, input().split())
l = 6.0 * M
s = (30.0 * H) + (0.5 * M)
arg = abs(l - s)
cos = math.cos(math.radians(arg))
ans = math.sqrt(((A ** 2) + (B ** 2)) - 2*A*B*cos)
print(ans)

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

int main() {
  
  int N, K;
  int sum = 0;
  cin >> N >> K;
  vector<int> L(N);
  
  for(int i = 0; i < N; i++){
    cin >> L.at(i);
  }
  
  sort(L.begin(), L.end());
  reverse(L.begin(), L.end());
  
  for(int i = 0; i < K; i++){
    sum += L.at(i);
  }
  
  cout << sum << endl;
    
}

Measured memory_bytes: 256