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

using namespace std;

string str;
int n;

long long solve(vector <int> a) {
	int pos = 0;	
	long long ans = 0;
	for (int i = 0; i < (int)a.size(); i++) {
		long long sum = 0;
		for (int j = pos; j <= a[i]; j++) {
			sum = sum * 10 + (str[j] - '0');			
		}	
		pos = a[i] + 1;
		ans += sum;
	}
	long long sum = 0;
	for (int i = pos; i < n; i++) {
		sum = sum * 10 + (str[i] - '0');	
	}
	ans += sum;
	return ans;
}

int main() {
	cin >> str;
	n = str.size();
	long long ans = 0;
	for (int i = 0; i < (1 << (n - 1)); i++) {
		vector <int> pos;
		int cnt = 0;
		for (int j = 0; j < n; j++) {
			if (i & (1 << j)) {
				pos.push_back(j);
				cnt++;									
			}	
		}  
		ans += solve(pos);
	}
	cout << ans << endl;
	return 0;
}                     

Measured memory_bytes: 256
/**Bismillahir Rahmanir Raheem
    Author:Refatul Fahad**/

#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define ull unsigned long long
#define ff first
#define ss second
#define pb push_back
#define vi vector<int>
#define pii pair<int,int>
#define pil pair<int,ll>
const int N = 1e6 + 5;
const ll M = (ll)1e8 + 7;
const double pi=2*acos(0.0);
const double esp=1e-9;
int Set(int N,int pos) {
    return N=N | (1<<pos);
}
int reset(int N,int pos) {
    return N= N & ~(1<<pos);
}
bool check(int N,int pos) {
    return (bool)(N & (1<<pos));
}

int dx[]= {0,0,1,-1};
int dy[]= {1,-1,0,0};

queue<pii>q;
int main() {

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    /// freopen("input.txt","r",stdin);
    /// freopen("output.txt","w",stdout);

    int test=1;
    ///cin>>test;
    for(int cs=1; cs<=test; ++cs) {
        int h,w,k,x1,y1,x2,y2;
        cin>>h>>w>>k>>x1>>y1>>x2>>y2;
        --x1,--y1,--x2,--y2;
        string s[h+5];
        bool visit[h+5][w+5];
        for(int i=0; i<h; ++i) {
            cin>>s[i];
        }
        vector<vi>dis(h+5,vi(w+5,M));
        memset(visit,0,sizeof(visit));
        dis[x1][y1]=0;
        q.push({x1,y1});
        while(!q.empty()) {
            pii p=q.front();
            q.pop();
            if(!visit[p.first][p.second]) {
                visit[p.first][p.ss]=true;
                for(int i=0; i<4; ++i) {
                    for(int j=1; j<=k; ++j) {
                        int x=p.first+(j*dx[i]),y=p.second+(j*dy[i]);
                        if(x<0||x>=h||y<0||y>=w)break;
                        if(s[x][y]=='@'||dis[x][y]<=dis[p.ff][p.ss])break;
                        if(dis[x][y]>dis[p.first][p.second]+1) {
                            dis[x][y]=dis[p.first][p.second]+1;
                        }
                        q.push({x,y});
                    }
                }
            }
        }
        if(dis[x2][y2]==M) {
            cout<<-1<<endl;
        } else {
            cout<<dis[x2][y2]<<endl;
        }

    }
    return 0;
}



Measured memory_bytes: 33744
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,n) for(int i=1;i<=n;i++)
const ll MOD = 1000000007;
long long modinv(long long a, long long m=MOD) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
    /*MODの割り算の際に
    a/＝b;
    を
    a *= modinv(b,MOD);
    とする。
        */
}

const int MAXN = 200001;
int Sur[MAXN];
int main(){
    string S;
    cin >> S;
    int N = S.length();
    int tmp = 0;
    ll cou = 1;
    for(int i=N-1;i>=0;i--){
        tmp += ((S[i]-'0')*cou)%2019;
        cou *= 10;
        cou %= 2019;
        tmp %= 2019;
        Sur[N-i] = tmp;
        Sur[N-i] %= 2019;
    }
    map<int,int> ma;
    int ans = 0;
    Rep(i,N){
        if(ma[Sur[i]]>0){
            ans+=(ma[Sur[i]]);
            ma[Sur[i]]++;
        }else ma[Sur[i]] = 1;
    }
    Rep(i,N){
        if(Sur[i]==0)ans++;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 4464
x=int(input())

dp=[[0]*(x+1) for _ in range(7)]
dp[0][0]=1
price=list(range(100,106))

for i in range(6):
    p=price[i]
    for j in range(x+1):
        dp[i+1][j]=dp[i][j]

        if j>=p:
            dp[i+1][j]+=dp[i+1][j-p]

print(1 if dp[6][x] else 0)

Measured memory_bytes: 71284
package main

import "fmt"

var A, B, N int

func main() {
	fmt.Scan(&A, &B, &N)
	ans := (min(N, B-1) * A) / B
	fmt.Println(ans)
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}


Measured memory_bytes: 1756
#include <bits/stdc++.h>
#define LOCAL
using namespace std;
template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
out << "(" << a.first << "," << a.second << ")";
return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');
cerr.write(names, comma - names) << ": " << arg1 << " |";
__f(comma + 1, args...);
}
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
//#########################################
signed main(){
	int k,s;cin >> k >> s;
	int ret = 0;
	rep(x,k+1)rep(y,k+1){
		int z = s-x-y;
		if(z >= 0 && z <= k)ret++;
	}
	cout << ret << endl;
	return 0;
}

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

public class Main{


	int w, h; //yoko tate
	String[] board;

	int kx,ky;
	int mx,my;

	void solve(){

		Scanner cin = new Scanner(System.in);
		while(true)
		{
			w = cin.nextInt();
			h = cin.nextInt();
			if(w==0 && h==0) return;
			board = new String[h];
			for(int i=0;i<h;i++) board[i] = cin.next();
			for(int i=0;i<h;i++){
				for(int j=0;j<w;j++){
					if(board[i].charAt(j)=='K'){
						ky = i;
						kx = j;
					}
					else if(board[i].charAt(j)=='M'){
						my = i;
						mx = j;
					}
				}
			}
			int ret = bfs(ky,kx,my,mx);
			if(ret == 0){
				System.out.println("He cannot bring tea to his master.");
			}
			else if(ret == 1){
				System.out.println("He cannot return to the kitchen.");
			}
			else{
				System.out.println("He can accomplish his mission.");
			}
		}
	}

	HashSet<Integer> hs;
	int[] vy = new int[]{1,0,-1,0};
	int[] vx = new int[]{0,1,0,-1};

	int[] next = new int[]{1,3}; //1(left) and -1(right)

	int bfs(int sy, int sx, int gy, int gx){
		hs = new HashSet<Integer>();
		Queue<Integer> q = new LinkedList<Integer>();
		int sk = 0;
		int gk = 0;

		for(int k=0;k<4;k++){
			if(board[sy+vy[k]].charAt(sx+vx[k])!='#') sk = k;
			if(board[gy+vy[k]].charAt(gx+vx[k])!='#') gk = k;
		}
		for(int k2=0;k2<4;k2++){
			int hash = encode(sy,sx,sy,sx,sk,k2);
			q.add(hash);
			hs.add(hash);
		}

		int ret = 0;
		while(!q.isEmpty()){
			int[] now = decode(q.poll());
			int y1 = now[0];
			int x1 = now[1];
			int y2 = now[2];
			int x2 = now[3];
			int k = now[4];
			int k2 = now[5];
			//if(x1!=5 && x2!=5 && x2!=0) System.out.println(y1 + " " + x1 + " " + y2 + " " + x2 + " " + k);
			while(board[y1 + vy[k]].charAt(x1 + vx[k]) != '#'){
				y1 += vy[k];
				x1 += vx[k];
			}
			if(true){
				if(y1==gy && x1 == gx){
					ret = 1;
				}
				for(int vk : next){
					int nk = (k + vk) % 4;
					int nk2 = (k2+vk)%4;
					int hash = encode(y1,x1,0,0,nk,nk2);
					if(!hs.contains(hash)){
						q.add(hash);
						hs.add(hash);
					}
				}
			}
			if(y2!=0){
				do{
					for(int vk : next){
						int nk = (k + vk) % 4;
						int nk2 = (k2 + vk)%4;
						if(board[y2+vy[(nk2+2)%4]].charAt(x2+vx[(nk2+2)%4])!='#') continue;

						if(y1==gy && x1==gx){
							if(y2==gy && x2==gx){
								if(k2==(gk+2)%4)return 2;
							}
							ret = 1;
						}
						int hash = encode(y1,x1,y2,x2,nk,nk2);
						if(!hs.contains(hash)){
							q.add(hash);
							hs.add(hash);
						}
					}
					y2 += vy[k2];
					x2 += vx[k2];
				}while(board[y2].charAt(x2) != '#');
			}
		}
		return ret;
	}

	int encode(int y1, int x1, int y2, int x2, int k, int k2){
		int ret = 0;
		ret += y1;
		ret *= w;
		ret += x1;
		ret *= h;
		ret += y2;
		ret *= w;
		ret += x2;
		ret *= 4;
		ret += k;
		ret *= 4;
		ret += k2;
		return ret;
	}

	int[] decode(int hash){
		int[] ret = new int[6];
		ret[5] = hash % 4;
		hash /= 4;
		ret[4] = hash % 4;
		hash /= 4;
		ret[3] = hash % w;
		hash /= w;
		ret[2] = hash % h;
		hash /= h;
		ret[1] = hash % w;
		hash /= w;
		ret[0] = hash;
		return ret;
	}



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

Measured memory_bytes: 34000
#include <iostream>
#include <string>
using namespace std;
int main(int argc, char* argv[])
{
	int N;
	string s,t;
	cin>>N;
	cin>>s;
	cin>>t;
	int i=0;
	int j=0;
	for (;;){
		if (s[i]==t[j]){
			j++;
		}
		i++;
		if (i==N){
			cout<<2*N-j<<endl;
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 256
class Stack:
    def __init__(self):
        self.stack = []

    def push(self, value):
        self.stack.append(value)

    def pop(self):
        return self.stack.pop(-1)

    @property
    def isEmpty(self):
        if len(self.stack) == 0:
            return True
        else:
            return False

def main():
    s = input()
    stack_grad = Stack()
    stack_vol = Stack()
    sum_vol = 0

    for i, c in enumerate(s):
        if c == '\\':
            stack_grad.push(i)
        elif c == '/':
            if not stack_grad.isEmpty:
                previ = stack_grad.pop()
                vol = i - previ
                sum_vol += vol
                while not stack_vol.isEmpty:
                    tpl = stack_vol.pop()
                    if previ < tpl[0]:
                        vol += tpl[1]
                    else:
                        stack_vol.push(tpl)
                        break
                stack_vol.push((previ, vol))

    print(sum_vol)
    stack_vol.stack.reverse()
    out = str(len(stack_vol.stack))
    while not stack_vol.isEmpty:
        out += ' {}'.format(stack_vol.pop()[1])
    print(out)


if __name__ == '__main__':
    main()

Measured memory_bytes: 7892
#include<iostream>
#include<vector>
#include<bits/stdc++.h>
#define lli long long int
#define mod 1000000007
#define pb push_back
#define mk make_pair
#define fastio ios_base::sync_with_stdio(false); cout.tie(NULL);
using namespace std;

int main()
{
	fastio;
	lli a,b,i,k,f=0;
	cin>>k>>a>>b;
//	if(k==1)
//		cout<<"OK";
//	else
//	{
		for(i=a;i<=b;i++)
		{
			if(i%k==0)
			{
				f=1;
				break;
			}
		}
		if(f)
			cout<<"OK";
		else
			cout<<"NG";
//	}
	return 0;
}


Measured memory_bytes: 3652
def solve(S):
    N = len(S)
    # N <= 10**5
    if N == 2:
        if S[0] == S[1]:
            return 1, 2
    for i in range(0, N-2):
        if S[i] == S[i+2]:
            return i+1, i+3
        if S[i] == S[i+1]:
            return i+1, i+3
        if S[i+1] == S[i+2]:
            return i+1, i+3
    return -1, -1
S = input()
print(*solve(S))







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

public class Main {
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        String p=sc.next();
        String s=sc.next();
        String t;
        boolean loopflag=false;
        boolean flag=false;
        int i;
        for(i=0;i<p.length()-s.length();i++){
            if(p.substring(i,i+s.length()).equals(s)) flag=true;
        }
        for(i=0;i<s.length();i++){
            t=s.substring(i,s.length());
            if(p.startsWith(t)){
                loopflag=true;
                break;
            }
        }
        if(loopflag){
            loopflag=false;
            t=s.substring(0,i);
            if(i==0) loopflag=true;
            else if(p.endsWith(t)) loopflag=true;
        }
        if(flag || loopflag) System.out.println("Yes");
        else System.out.println("No");
    }
}



Measured memory_bytes: 26348
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define INF 1000000000
#define MOD 1000000007
#define EPS 0.00000001


int main(){
    int V, E, S; cin >> V >> E >> S;
    struct edge {
        int from, to, cost;
    };

    vector<edge> es(E);
    vector<int> d(V, INF);
    
    for(edge &e:es){
        int f, t, c; cin >> f >> t >> c;
        e.from = f;
        e.to = t;
        e.cost = c;
    }
    
    d[S] = 0;
    bool negativ_cycle = false;
    for(int i=0; i<V; i++){
        bool updated = false;
        for(int i=0; i<E; i++){
            edge e = es[i];
            if(d[e.from]!=INF && d[e.to] > d[e.from] + e.cost){
                d[e.to] = d[e.from] + e.cost;
                updated = true;
            }
        }
        if(!updated) break;
        if(i==V-1) negativ_cycle = true;
    }
    
    if(negativ_cycle){
        cout << "NEGATIVE CYCLE" << endl;
        return 0;
    }
    for(int i=0; i<V; i++){
        if(d[i]==INF) cout << "INF" << endl;
        else cout << d[i] << endl;
    }
    return 0;
}



Measured memory_bytes: 8876
def main():
    n = int(input())
    a = [int(i) for i in input().split()]
    a.append(0)
    pre = 10**9
    kabu = 0
    ans = 1000
    flag1,flag2 = False,False
    if a[0]<a[1]:
        flag2 = True
    else:
        flag1 = True
    for i in range(n+1):
        if flag1==True and a[i]> pre:
            kabu += ans//pre
            ans -= kabu*pre
            flag1,flag2 = False,True
        elif flag2==True and a[i]<pre:
            ans += kabu*pre
            kabu = 0
            flag1,flag2 = True,False
        pre = a[i]
        #print(ans,kabu)
    print(ans)

main()

Measured memory_bytes: 9216
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pb push_back
#define f(i,x,n) for(int i=x;i<n;i++)
#define all(c) c.begin(),c.end()
#define int ll
using ll = long long;
using pii = pair<int,int>;
const int MOD = 1e9+7, N = 1e5 + 10; 

int32_t main(){
   ios::sync_with_stdio(false);
   cin.tie(NULL);
   int h,n;
   cin >> h >> n;
   int s = 0,x;
   f(i,0,n){
      cin >> x;
      s += x;
   }
   if(s>=h){
      cout << "Yes\n";
   }else{
      cout << "No\n";
   }
   return 0;
} 

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

using namespace std;

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

template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }

typedef long long ll;
typedef pair<int, int> pii;
const ll INF = 1ll<<29;
const bool debug = 0;

int p[5] = {1868, 1912, 1926, 1989, 2017};
char c[4] = {'M', 'T', 'S', 'H'};
int E, Y;

int main() {
	cin >> E >> Y;
	if (E == 0) {
		int idx;
		REP(i, 4) {
			if (p[i] <= Y && Y < p[i + 1]) {
				idx = i;
				break;
			}
		}
		
		printf("%c%d\n", c[idx], Y - p[idx] + 1);
	}
	else {
		printf("%d\n", Y + p[E-1] - 1);
	}
	return 0;
}

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

#define int ll

#define pb push_back
#define all(v) (v).begin(), (v).end() 
#define sz(v) (int)((v).size())
#define fs first
#define sd second

typedef long long ll;

typedef pair < int, int > pi;
typedef pair < pi, int > ppi;

typedef vector < int > vi;
typedef vector < vector < int > > vvi;
typedef vector < pi > vpi;
typedef vector < vpi > vvpi;
typedef vector < ppi > vppi;

void fast() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

vector<string> vec_splitter(string s) {
	s += ',';
	vector<string> res;
	while(!s.empty()) {
		res.push_back(s.substr(0, s.find(',')));
		s = s.substr(s.find(',') + 1);
	}
	return res;
}

void debug_out(
vector<string> __attribute__ ((unused)) args,
__attribute__ ((unused)) int idx, 
__attribute__ ((unused)) int LINE_NUM) { cerr << endl; } 
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
	if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
	stringstream ss; ss << H;
	cerr << args[idx] << " = " << ss.str();
	debug_out(args, idx + 1, LINE_NUM, T...);
}

#ifdef LOCAL
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define debug(...) 42
#endif

double get_time() {
	return 1.0 * clock() / CLOCKS_PER_SEC;
}

const int INF = 1E12;

int32_t main() {
	int n;
	cin >> n;
	vi s(n), w(n);
	vpi v;
	for(int i = 0; i < n; i++) {
		int S, W;
		cin >> S >> W;
		s[i] = S, w[i] = W;
		v.pb({S + W, i});
	}
	sort(all(v));
	vvi dp(n + 1, vi(n + 1, INF));
	dp[0][0] = 0;
	for(int i = 1; i <= n; i++) {
		int idx = v[i - 1].sd;
		dp[i] = dp[i - 1];
		for(int j = 1; j <= n; j++) {
			if(dp[i - 1][j - 1] <= s[idx])
				dp[i][j] = min(dp[i][j], dp[i - 1][j - 1] + w[idx]);
		}
	}	
//	cout << -1 << '\n';
	for(int j = n; j >= 0; j--) {
		if(dp[n][j] < INF) {
			cout << j << '\n';
			return 0;
		}
	}
}


Measured memory_bytes: 195968
#include<iostream>
#include<algorithm>
using namespace std;
const int N=1e5+10;
typedef long long LL;

pair<int,int> a[N];

int main()
{
    int n;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        a[i].second=i;
        cin>>a[i].first;
    }
    sort(a+1,a+1+n);
    for(int i=1;i<=n;i++)
    {
        cout<<a[i].second<<" ";
    }
    cout<<endl;
    //system("pause");
}

Measured memory_bytes: 4380
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
void solve();
main { solve(); return 0; }
// clang-format on

void solve() {
  int n;
  while (cin >> n, n) {
    vpii v(n);
    rep(i, n) {
      int h, m, d;
      char gomi;
      cin >> h >> gomi >> m >> gomi >> d;
      int l = h * 3600 + m * 60 + d;
      cin >> h >> gomi >> m >> gomi >> d;
      int r   = h * 3600 + m * 60 + d;
      v[i].fi = l;
      v[i].se = r;
    }
    sort(all(v));
    priority_queue<int, vector<int>, greater<int>> q;
    q.push(v[0].se);
    loop(i, 1, n) {
      if (q.top() <= v[i].fi) q.pop();
      q.push(v[i].se);
    }
    cout << q.size() << endl;
  }
}

Measured memory_bytes: 3276
#include <bits/stdc++.h>
using namespace std;
#define all int i=0; i<n; i++
#define pb push_back
typedef long long int ll;

#define FAST_IO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define endl '\n'
#define mod 1000000007

bool sortinrev(const pair<ll,ll> &a,  
               const pair<ll,ll> &b) 
{ 
       return (a.first > b.first); 
}
int ans = 0; int a,b,c;
void solve(){
	while(true){
		if(b>=1 && c>=2){
			ans+=3;
			b--;
			c-=2;
		}
		else break;
	}
	while(true){
		if(a>=1 && b>=2){
			ans+=3;
			b-=2;
			a--;
		}
		else break;
	}
	cout<<ans<<endl;
}
ll power(ll x, ll y, ll p) 
{ 
    ll res = 1;
  
    x = x % p;
  
    while (y > 0) 
    { 
        if (y & 1){
			res = (res*x) % p; 
			y--;
		}
        y = y>>1;
        x = (x*x) % p;   
    } 
    return res; 
}
int main(){ 
	int n;
	string k;
	cin>>n;
	cin>>k;
	int ans = 1;
	for(int i=1; i<n; i++){
		if(k[i]!=k[i-1])ans++;
	}
	cout<<ans<<endl;
}



Measured memory_bytes: 512
n = int(input())
ans = []
for i in range(1, n + 1):
  temp = []
  for j in range(1, i + 1, 2):
    if i % j == 0:
      temp.append(j)
  if len(temp) == 8:
    ans.append(i)
    
print(len(ans))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define v(T) vector<T>
#define yn {puts("Yes");}else{puts("No");}
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
const double eps = 1e-10;

void solve() {
  ll a, b, c, d;
  cin >> a >> b >> c >> d;

  ll ab[2] = {a, b};
  ll cd[2] = {c, d};

  ll ans = LONG_MIN;
  for (int i = 0; i < 2; i++) {
    ll x = ab[i];
    for (int j = 0; j < 2; j++) {
      ll y = cd[j];
      ll g = x * y;
      if (ans < g) {
        ans = g;
      }
    }
  }
  cout << ans << endl;
}

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


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define debug(x) cerr << "[(" << __LINE__ << ") " << (#x) << "]: " << x << endl;

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

    int k;
    string s;
    cin >> k >> s;

    if (s.size() <= k)
        cout << s;
    else {
        for (int i=0; i<k; i++) cout << s[i];
        cout << "...";
    }
    cout << "\n";
}


Measured memory_bytes: 3648
#include<cstdio>

int a[10];

bool dfs(int k, int B,int C)

{

if(k == 10)

return true;

if(a[k]>B)

{

if(dfs(k+1,a[k],C)) return true;

}

if(a[k]>C)

{

if(dfs(k+1,B,a[k]))return true;

}

return false;

}



void slove()

{

if(dfs(0,0,0))printf("YES\n");

else printf("NO\n");

}



int main()

{

int t;

scanf("%d",&t);

while(t--)

{

for(int i = 0 ; i  < 10; i++)

scanf("%d",&a[i]);

slove();

}

return 0;

}

Measured memory_bytes: 1008
i;main(w){
  scanf("%*d%d",&w);
  for(;i++<w+1;)putchar_unlocked('#');
  for(;~(i=getchar_unlocked());){
    if(i==10)putchar_unlocked('#');
    putchar_unlocked(i);
    if(i==10)putchar_unlocked('#');
  }
  for(;i++<w;)putchar_unlocked('#');
}

Measured memory_bytes: 128
L, R = map(int,input().split())

x = []
for i in range(L,R+1):
    if i % 2019 in x:
        break

    x.append(i % 2019)

ans = 9999
for i in range(len(x)):
    for j in range(i+1,len(x)):
        ans = min(ans, x[i] * x[j] %2019)

print(ans)

Measured memory_bytes: 9192
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<queue>
using namespace std;

int main(){

    int n;
    cin >> n;
    vector<int> a(n);
    int m = 0;
    for (int i = 0; i < n; ++i)
    {
        cin >> a[i];
        if(m<a[i]){
            m = a[i];
        }
    }



        vector<bool> pr(m + 1, true);

    for (int i = 0; i < n;++i){
        int x = a[i] * 2;
        while (x <= m)
        {
     //       cout << "x = " << x << " ,  m = " << m << endl;
            pr[x] = false;
            x += a[i];
        }
    
    }


    vector<bool> kaburi(m + 1, false);

    for (int i = 0; i < n;++i){

        if(kaburi[a[i]]){
            pr[a[i]] = false;
        }
        kaburi[a[i]] = true;
    }

    int ans = 0;
    for (int i = 0; i < n;++i){
        if(pr[a[i]]){
            ans++;
        }
    }

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

Measured memory_bytes: 4132
n, k = list(map(int, input().split()))
xy = [list(map(int, input().split())) for _ in range(n)]

xy = sorted(xy)
ans = 4*10**18
for i in range(n-k+1):
    x_left = xy[i][0]
    for j in range(i+k-1, n):
        x_right = xy[j][0]
        y_mid = sorted([y for x, y in xy[i:j+1]])
        for k_ in range(len(y_mid)-k+1):
            y_bottom = y_mid[k_]
            y_top = y_mid[k_+k-1]
            ans = min(ans, (x_right-x_left)*(y_top-y_bottom))
print(ans)


Measured memory_bytes: 3064
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    String ans = "Yes";

    // 配列は0から始まってるから1文字目が「i=0」になる。
    // 感覚的に添え字と偶奇が逆になる。ややこしや。
    for(int i=0; i<s.length(); ++i) {
      if(i%2 == 0 && s.charAt(i)=='L')
        ans = "No";
      if(i%2 == 1 && s.charAt(i)=='R')
        ans = "No";
    }

    System.out.println(ans);
  }
}

Measured memory_bytes: 23892
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
using ll = long long;
using vin=vector<int>;
using vll=vector<ll>;
using P = pair<int, int>;
const int inf=1e9+7;
const ll INF=1e18;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

int main() {
  int n,q;
  cin>>n>>q;
  int ans[220000];
   int c[220000];
  rep(i,0,220000){
   ans[i]=-1; 
    c[i]=0;
  }
 
  vector<vin> G(n,vector<int> ());
  rep(i,0,n-1){
   int a,b;
    cin>>a>>b;
    a--;b--;
    G[a].push_back(b);
    G[b].push_back(a);
   // cout<<a<<b<<endl;
  }
  rep(i,0,q){
    int p,x;
    cin>>p>>x;
    p--;
    
    c[p]+=x;
   // cout<<c[p]<<endl;
  }
  
  queue<int> bfs;
  bfs.push(0);
  ans[0]=c[0];
  while(!bfs.empty()){
    int v=bfs.front();
    bfs.pop();
    
    for(auto nv:G[v]){
      if(ans[nv]!=-1) continue;
      ans[nv]=ans[v]+c[nv];
      //cout<<v<<" "<<nv<<endl;
      bfs.push(nv);
    }
  }
  
  rep(i,0,n) cout<<ans[i]<<endl;
}






//木に情報を持たせておく

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

X = [[0] * 10 for _ in range(10)]

for i in range(1, N + 1):
	s = str(i)
	a = int(s[0])
	b = int(s[-1])
	X[a][b] += 1

ans = 0
for i in range(10):
	for j in range(10):
		ans += X[i][j] * X[j][i]
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + (ll)b) % mod
#define MUL(a, b) a = (a * (ll)b) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = (a); i < (b); i++)
#define rer(i, a, b) for(int i = (a) - 1; i >= (b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef pair<int, int> pi;
typedef pair<int, pi> ppi;
typedef vector<ll> vi;
typedef complex<double> comp;
void Debug() {cout << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest) { 
	cout << arg << " "; Debug(rest...); }
template<class T>ostream& operator<< (ostream& out, const vector<T>& v) {
	out << "[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<< ", ";out<<v.back();}out << "]";return out;}
template<class S, class T>ostream& operator<< (ostream& out, const pair<S, T>& v) {
	out << "(" << v.first << ", " << v.second << ")";return out;}
const int MAX_N = 200010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 30;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
///////////////////////////////////////////////////////////////////////////////////////////////////

int N, M;
int dp[(1 << 16)][16];
int cost[(1 << 16)];
int A[500], B[500], C[500];
int E[50];
int D[50][50];

void solve() {
	cin >> N >> M;
	memset(D, -1, sizeof(D));
	int res = 0;
	rep(i, 0, M) {
		cin >> A[i] >> B[i] >> C[i];
		A[i]--; B[i]--;
		D[A[i]][B[i]] = C[i];
		D[B[i]][A[i]] = C[i];
		res += C[i];
	}
	rep(bit, 0, (1 << N)) {
		rep(j, 0, M) {
			if((bit & (1 << A[j])) && (bit & (1 << B[j]))) {
				cost[bit] += C[j];
			}
		}
	}
	rep(bit, 0, (1 << N)) 
		rep(j, 0, N) dp[bit][j] = -inf;

	dp[1][0] = 0;


	rep(bit, 0, (1 << N)) {
		rep(i, 0, N) {
			if(!(bit & (1 << i)) || dp[bit][i] < 0) continue;
			rep(j, 0, N) {
				if(!(bit & (1 << j)) && D[i][j] != -1) {
					MAX(dp[bit | (1 << j)][j], dp[bit][i] + D[i][j]);
				}
			}
			int n = 0;
			rep(j, 0, N) {
				if(!(bit & (1 << j))) {
					E[n++] = j;
				}
			}
			rep(mask, 0, (1 << n)) {
				int nbit = 0;
				rep(k, 0, n) {
					if(mask & (1 << k)) {
						nbit |= (1 << E[k]);
					}
				}
				MAX(dp[nbit | bit][i], dp[bit][i] + cost[nbit | (1 << i)]);
			}
		}
	}
	int tmp = dp[(1 << N) - 1][N - 1];
	cout << res - tmp << "\n";

}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(5);
#ifdef LOCAL
    freopen("in.txt", "rt", stdin);
#endif	
	solve();
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}






Measured memory_bytes: 4224
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
LL n,a[1000]={0},q;
string s;
int main()
{
	cin>>n>>s>>q;
	while(q--)
	{
		LL DMnum=0,Dnum=0,Mnum=0,DMCnum=0,k;
		cin>>k;
		for(LL i=0;i<s.length();i++)
		{
			if(i-k>=0&&s[i-k]=='D')
			{
				Dnum--;
				DMnum-=Mnum;
			}
			if(i-k>=0&&s[i-k]=='M')
			{
					Mnum--;	
				
			}
			if(s[i]=='D')
			{
					Dnum++;
			}
			if(s[i]=='M')
			{
				Mnum++;
				DMnum+=Dnum;
			}
			if(s[i]=='C')
			{
			DMCnum+=DMnum;
			 } 
				
		}
		cout<<DMCnum<<endl;
	}
	return 0;
}


Measured memory_bytes: 1412
k, n = map(int, input().split())
lst = []
lst = list(map(int, input().split()))

# if lst[-1] != k:
#     lstap = lst.append(k)
# An < kだからいらない
wmax = 0

for i in range(len(lst) - 1):
    w = lst[i + 1] - lst[i]
    if w > wmax:
        wmax = w

judge = [lst[0] + k - lst[-1], wmax]
# print(judge)
print(k - max(judge))

# if k - lst[-1] <= lst[0]:
#     print(lst[-1] - lst[0])

# elif k - lst[-1] > lst[0]:
#     print

# # elif k - lst[-1] < lst[0]:
# #     lst[-1] - 

Measured memory_bytes: 26436
#include <stdio.h>
#include <stdlib.h>

int panel[3][3];
int temp[3][3];
int XX[4] = {0,1,0,-1};
int YY[4] = {1,0,-1,0};

int DFS(int,int,int,int,const int);
int Calc();
void empty(int *,int *);
void swap(int *,int *);

int main()
{
	int i,j;
	int x,y;
	int A,l;
	for(i=0; i<3; i++)
	{
		for(j=0; j<3; j++) scanf("%d",&panel[i][j]);
	}

	empty(&x,&y);
	for(l=0; l<100; l++)
	{
		for(i=0; i<3; i++)
		{
			for(j=0; j<3; j++) temp[i][j] = panel[i][j];
		}

		A = DFS(x,y,-1,0,l);

		if(A != -1)
		{
			printf("%d\n",A);
			break;
		}

		for(i=0 ; i<3 ; i++)
		{
			for(j=0 ; j<3 ; j++) panel[i][j] = temp[i][j];
		}
		A = -1;
		if(l == 99) printf("%d\n",A);
	}
	return 0;
}

void empty(int *x,int *y)
{
	int i,j;
	for(i=0; i<3; i++)
	{
		for(j=0; j<3; j++)
		{
			if(!panel[i][j])
			{
				*x = j;
				*y = i;
				return;
			}
		}
	}
}

void swap(int *a,int *b)
{
	int temp;
	temp = *a;
	*a = *b;
	*b = temp;
}

int Calc()
{
	int i,x,sum=0;
	for(i=0; i<9; i++)
	{
		x = panel[i/3][i%3];
		if(x)
		{
			x--;
			sum += abs(i/3 - x/3) + abs(i%3 - x%3);
		}
	}
	return sum;
}

int DFS(int x,int y,int p,int Depth,const int Limit)
{
	int i;
	int h,res;
	int X,Y;

	h = Calc();
	if(h == 0) return Depth;
	if(Depth+h>Limit) return -1;

	for(i = 0; i < 4; i++)
	{
		X = x + XX[i];
		Y = y + YY[i];

		if(~p && i == (p+2)%4) continue;
		if(!(0 <= X && X<3 && 0 <= Y && Y<3)) continue;

		swap(&panel[y][x],&panel[Y][X]);
		res = DFS(X,Y,i,Depth+1,Limit);
		if(~res) return res;

		swap(&panel[y][x],&panel[Y][X]);
	}

	return -1;
}



Measured memory_bytes: 2084
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<string>
using namespace std;
int land[205][205],sea[205][205],tar[1005],dp[1005][205];
int main()
{
    int n,m,i,j,k,r;
    while(cin>>n>>m&&(n+m)){
        memset(land,0x3f,sizeof(land));memset(sea,0x3f,sizeof(sea));memset(dp,0x3f,sizeof(dp));
        for(i=1;i<=m;i++){
            int a,b,c;string str;
            cin>>a>>b>>c>>str;
            if(str=="S")
                sea[a][b]=sea[b][a]=c;
            else
                land[a][b]=land[b][a]=c;
        }
        for(i=1;i<=n;i++)land[i][i]=sea[i][i]=0;//不要忘了这个..
        cin>>r;for(i=1;i<=r;i++)cin>>tar[i];
        for(k=1;k<=n;k++)//floyd初始化,至于那些不可能的,初始化完了肯定还是无穷大不可能
            for(i=1;i<=n;i++)
                for(j=1;j<=n;j++){
                    land[i][j]=min(land[i][j],land[i][k]+land[k][j]);
                    sea[i][j]=min(sea[i][j],sea[i][k]+sea[k][j]);
                }
        dp[1][tar[1]]=0;//初始化
        for(i=1;i<=r;i++)//从2开始也没问题
            for(j=1;j<=n;j++){
                dp[i][j]=min(dp[i][j],dp[i-1][j]+land[tar[i-1]][tar[i]]);//单纯走陆路的情况,从tar[i-1]到tar[i]
                for(k=1;k<=n;k++){//回到船停的j镇,水路从j到k,陆路k到tar[i],枚举k
                    dp[i][k]=min((long long)dp[i][k],(long long)dp[i-1][j]+land[tar[i-1]][j]+sea[j][k]+land[k][tar[i]]);
                 
                }
            }
        int ans=0x7f7f7f7f;
        for(i=1;i<=n;i++)
            ans=min(ans,dp[r][i]);
        cout<<ans<<endl;
    }

    return 0;
}


Measured memory_bytes: 4276
n = int(input())
a = list(map(int,input().split()))
colors = set()
kami = 0
for i in range(n):
    if 1 <= a[i] <= 399:
        colors.add('hai')
    elif 400 <= a[i] <= 799:
        colors.add('cha')
    elif 800 <= a[i] <= 1199:
        colors.add('midori')
    elif 1200 <= a[i] <= 1599:
        colors.add('mizu')
    elif 1600 <= a[i] <= 1999:
        colors.add('ao')
    elif 2000 <= a[i] <= 2399:
        colors.add('kiiro')
    elif 2400 <= a[i] <= 2799:
        colors.add('daidai')
    elif 2800 <= a[i] <= 3199:
        colors.add('aka')
    else:
        kami += 1
if kami == 0:
    print(len(colors),len(colors))
else:
    print(max(len(colors), 1), len(colors)+kami)


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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define UB upper_bound
#define LB lower_bound
#define PB push_back
#define mp make_pair
#define F first
#define S second
#define be(a) (a).begin(),(a).end()
#define deb(x) cout<< #x <<" "<<endl;
#define deb2(x, y) cout<< #x <<" "<< x <<endl<< #y <<" "<<y<<endl
#define fo(i, n) for(long long i=0; i<n; i++)
#define Fo(i, n, k) for(long long i=k; i<n; i++)
#define mod 1000000007
#define int long long

typedef long long ll;

void fileIO()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}
 
typedef vector<pair<int, int>> vll;
typedef unordered_map<int, int> ump;



bool sortbysecdesc(const pair<int, int> &a, 
                    const pair<int, int> &b) 
{ 
    return a.second>b.second;
}



int32_t main()
{
    IOS;
    fileIO();
    int T;
    T = 1;
    //cin>>T;

    while(T--)
    {
        string s, t;
        cin>>s>>t;

        int m = s.size();
        int n = t.size();
        int dp[m+1][n+1];
        for(int i = 0; i<=m; i++) dp[i][0] = 0;
        for(int j = 0; j<=n; j++) dp[0][j] = 0;

        for(int i = 1; i<=m; i++)
        {
            for(int j = 1; j<=n; j++)
            {
                if(s[i-1] == t[j-1])dp[i][j] = 1 + dp[i-1][j-1];
                else dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
            }
        }

        string ans = "";
        int i = m, j = n;
        while(i>0 && j>0)
        {
            if(s[i-1] == t[j-1])
            {
                ans += s[i-1];
                i--;
                j--;
            }
            else if(dp[i-1][j]>=dp[i][j-1])
            {
                i--;
            }
            else
            {
                j--;
            }
        }

        reverse(ans.begin(), ans.end());
        cout<<ans;
    }
    
    return 0;
}



Measured memory_bytes: 73968
#pragma GCC optimize(3, "Ofast", "inline")

#include <bits/stdc++.h>

#define start ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
#define int ll
#define ls st<<1
#define rs st<<1|1
#define pii pair<int,int>
#define rep(z, x, y) for(int z=x;z<=y;++z)
#define com bool operator<(const node &b)
using namespace std;
mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
const int maxn = (ll) 3e5 + 5;
const int mod = 998244353;
const int inf = 0x3f3f3f3f;
int T = 1;

void solve() {
    int n;
    cin >> n;
    vector<int> v;
    while (n) {
        v.push_back(n % 26);
        if (n % 26 == 0)
            n = (n - 26) / 26;
        else
            n /= 26;
    }
    for (int i = v.size() - 1; i >= 0; --i) {
        if (v[i] == 0)
            cout << 'z';
        else
            cout << (char) (v[i] + 'a' - 1);
    }
}

signed main() {
    start;
    while (T--)
        solve();
    return 0;
}

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

macro_rules! min {
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = min!($($ys),*);
        if $x < t { $x } else { t }
    }}
}
macro_rules! max {
    ($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) => { println!("{}", $x) };
    ($x:expr, $($xs:expr),*) => { print!("{} ", $x); put!($($xs),*) }
}

const M: i64 = 1_000_000_007;

fn main() {
    let mut sc = Scanner::new();
    let n: usize = sc.cin();
    let mut works: Vec<_> = (0..n).map(|_| {
        let a: u64 = sc.cin();
        let b: u64 = sc.cin();
        (b, a)
    }).collect();
    works.sort();
    let res = works.iter().fold(Some(0), |t, &(b, a)| {
        match t {
            Some(c) => {
                if b < c + a {
                    None
                } else {
                    Some(c + a)
                }
            }
            None => None
        }
    });
    put!(if res.is_none() { "No" } else { "Yes" });

}

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()
    }
}


Measured memory_bytes: 10492
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define rep(i,m,n) for(int (i)=(m);(i)<(n);++(i))
#define rREP(i,m,n) for(int (i)=(n)-1;(i)>=(m);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 1000000001;
constexpr ll mod = 1000000007;
constexpr double PI = 3.1415926535897932;
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;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

int main() {
	init();

	string s; cin >> s;
	rep(i, 0, s.size()) {
		if (s[i] == '?')s[i] = 'D';
	}
	cout << s << "\n";

	return 0;
}

Measured memory_bytes: 3768
#include <iostream>
#include <fstream>
#include <string>
#include <unordered_map>
#include <stdio.h>
#include <list>
#include <vector>
#include <algorithm>
#include <stack>
#include <climits>
#include <cmath>
#include <map>
#include <queue>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; ++i)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

struct csf
{
	ll c,s,f;
};


int main()
{
	ll n;cin >> n;
	vector<csf> t(n);
	rep(i,n-1)
	{
		cin >> t[i].c >> t[i].s >> t[i].f;
	}

	rep(i,n)
	{
		ll start = i;
		ll now = 0;
		for(int j = i;j<n-1;j++)
		{
			if(now<t[j].s)now = t[j].s;
			if(now%t[j].f!=0)now+=t[j].f-now%t[j].f;
			now+=t[j].c;
			//cout<<' '<<now<<endl;
		}
		cout<<now<<endl;
	}
	return 0;
}

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

int main(){
  int n;
  cin >> n;
  vector<int> l;
  for(int i=0; i<n; i++){
    int m;
    cin >> m;
    l.push_back (m);
  }
  sort(l.begin(),l.end()); 
  int ans=0;
  for(int i=0; i<n; i++){
    for(int j=i+1; j<n; j++){
      if(l[i] != l[j]){
	for(int k=j+1; k<n; k++){
	  if(l[i] + l[j] > l[k] && l[j] != l[k])ans++;
	}
      }
    }
  }
  cout << ans << endl;
}


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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	string s; cin>>s;
	for(int i=s.size()-1;i>=0;--i){
		if((i+1)%2==0)continue;
		bool yes=true;
		for(int j=0,k=i/2;k<i;++j,++k){
			if(s.at(j)!=s.at(k)){
				yes=false;
				break;
			}
		}
		if(yes){
			cout<<i<<"\n"s;
			return 0;
		}
	}
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N=100005;
int n;
LL a[N],psqr[N];
int vis[N],prime[N],pcnt;
void Get_Prime(int n){
	pcnt=0;
	memset(vis,0,sizeof vis);
	for (int i=2;i<=n;i++){
		if (vis[i])
			continue;
		prime[++pcnt]=i;
		for (int j=i<<1;j<=n;j+=i)
			vis[j]=1;
	}
}
map <LL,int> cubic,sqr,cnt;
int check_cubic(){
	int f=0;
	int _n=0;
	for (int i=1;i<=n;i++)
		if (cubic[a[i]])
			f=1;
		else
			a[++_n]=a[i];
	n=_n;
	return f;
}
LL Get(LL x){
	LL res=1;
	for (int i=1;i<=pcnt;i++)
		if (x%prime[i]==0){
			LL cnt=1;
			x/=prime[i];
			if (x%prime[i]==0)
				x/=prime[i],cnt++;
			cnt=3-cnt;
			while (cnt>0){
				cnt--,res*=prime[i];
				if (res>1e11)
					return -1;
			}
		}
	if (x>1){
		LL t=x;
		if (sqr[x]>0)
			t=sqr[x];
		else {
			if (x>1e8)
				return -1;
			t=x*x;
		}
		if (t>1e11/res)
			return -1;
		res*=t;
	}
	return res>1e10?-1:res;
}
int main(){
	scanf("%d",&n);
	for (int i=1;i<=n;i++)
		scanf("%lld",&a[i]);
	cubic.clear(),sqr.clear();
	for (int i=1;i<=2500;i++)
		cubic[1LL*i*i*i]=i;
	for (int i=1;i<=100000;i++)
		sqr[1LL*i*i]=i;
	int ans=check_cubic();
	Get_Prime(2500);
	for (int i=1;i<=pcnt;i++)
		psqr[i]=1LL*prime[i]*prime[i]*prime[i];
	cnt.clear();
	for (int i=1;i<=n;i++){
		for (int j=1;j<=pcnt;j++)
			while (a[i]%psqr[j]==0)
				a[i]/=psqr[j];
		cnt[a[i]]++;
	}
	for (int i=1;i<=n;i++){
		if (!cnt[a[i]])
			continue;
		LL b=Get(a[i]);
		ans+=max(cnt[a[i]],cnt[b]);
		cnt[a[i]]=cnt[b]=0;
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 25344
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
 
template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100011; //check the limits, dummy
 
using cd = complex<double>;
const double PI = acos(-1);

int reverse(int num, int lg_n) {
    int res = 0;
    for (int i = 0; i < lg_n; i++) {
        if (num & (1 << i))
            res |= 1 << (lg_n - 1 - i);
    }
    return res;
}

void fft(vector<cd> & a, bool invert) {
    int n = a.size();
    int lg_n = 0;
    while ((1 << lg_n) < n)
        lg_n++;

    for (int i = 0; i < n; i++) {
        if (i < reverse(i, lg_n))
            swap(a[i], a[reverse(i, lg_n)]);
    }

    for (int len = 2; len <= n; len <<= 1) {
        double ang = 2 * PI / len * (invert ? -1 : 1);
        cd wlen(cos(ang), sin(ang));
        for (int i = 0; i < n; i += len) {
            cd w(1);
            for (int j = 0; j < len / 2; j++) {
                cd u = a[i+j], v = a[i+j+len/2] * w;
                a[i+j] = u + v;
                a[i+j+len/2] = u - v;
                w *= wlen;
            }
        }
    }

    if (invert) {
        for (cd & x : a)
            x /= n;
    }
}
vector<ll> multiply(vector<ll> const& a, vector<ll> const& b) {
    vector<cd> fa(a.begin(), a.end()), fb(b.begin(), b.end());
    int n = 1;
    while (n < a.size() + b.size()) 
        n <<= 1;
    fa.resize(n);
    fb.resize(n);

    fft(fa, false);
    fft(fb, false);
    for (int i = 0; i < n; i++)
        fa[i] *= fb[i];
    fft(fa, true);

    vector<ll> result(n);
    for (int i = 0; i < n; i++)
        result[i] = round(fa[i].real());
    return result;
}
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);    
	
    int N; cin >> N;
    ll M; cin >> M;
    vl poly(MX); F0R(i, MX) poly[i] = 0;
    F0R(i, N) {
        int cur; cin >> cur;
        poly[cur]++;
    }

    vl res = multiply(poly, poly);

    ll ans = 0;
    F0Rd(i, sz(res)) {
        ll cur = min(M, res[i]);
        M -= cur;
        ans += cur * i;
    }
    cout << ans << endl;
	return 0;
}
 
// read the question correctly (ll vs int)
// template by bqi343



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

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

    vector<bool> exist(1000001, false);
    exist.at(s) = true;
    int i = 1;
    while (true)
    {
        i++;
        if (s % 2 == 0)
        {
            s /= 2;
        }
        else
        {
            s = 3 * s + 1;
        }

        if (exist.at(s))
        {
            cout << i << endl;
            return 0;
        }
        exist.at(s) = true;
    }
}

Measured memory_bytes: 384
import java.util.*;
 
class Main {
    public static void main(String args[]) {
        Scanner inp = new Scanner(System.in);
        do_(inp);
        inp.close();
    }
    public static void do_(Scanner inp) {
        int a = inp.nextInt();
        int b = inp.nextInt();
        System.out.println(a < 10 && b < 10 ? a * b : -1);
    }
}


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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)

using namespace std;

/////////////////////////////////////////////////////

char S[200];
int i,j,Sl;
char keyence[]="keyence";
int main(){
    scanf("%s",S);
    for(Sl=0;S[Sl]!='\0';Sl++);
    for(i=0;i<8;i++){
        for(j=0;j<i;j++){
            if(S[j]!=keyence[j]){
                break;
            }
        }
        if(j!=i)
            continue;
         for(j=i;j<7;j++){
            if(S[Sl+j-7]!=keyence[j]){
                break;
            }
        }   
         if(j==7){
            printf("YES");
            return 0;
        }
    }
   
    printf("NO");
    return 0;
}

Measured memory_bytes: 256