akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector> 
#include <cstring>
#include <queue>
#include <stack>
#include <ctime>
#include <set>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef pair<int,ll> pil;


namespace io{
    const int L = (1 << 20) + 1;
    
    char buf[L], *S , *T, c;
     
    char getchar() {
        if(S == T) {
            T = (S = buf) + fread(buf, 1, L, stdin);
            return (S == T ? EOF : *S++);
        }
        return *S++;
    }
    
    int inp() {
        int x = 0, f = 1; char ch;
        for(ch = getchar(); !isdigit(ch); ch = getchar())
            if(ch == '-') f = -1;
        for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
        return x * f;
    }
    
    ll inp_ll() {
        ll x = 0; int f = 1; char ch;
        for(ch = getchar(); !isdigit(ch); ch = getchar())
            if(ch == '-') f = -1;
        for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
        return x * f;
    }
    
    char B[25], *outs=B+20, *outr=B+20;
    template<class T>
    inline void print(register T a,register char x=0){
        if(x) *--outs = x, x = 0;
        
        if(!a)*--outs = '0';
        else 
            while(a)
                *--outs = (a % 10) + 48, a /= 10;
        
        if(x)
            *--outs = x;
        
        fwrite(outs, outr - outs , 1, stdout);
        outs = outr;
    }
};

using io :: print;
using io :: inp;
using io :: inp_ll;
const int maxN = 1e5 + 5;
const int MOD = 1e9 + 7;
vector<pii> node;
int tree[maxN];
int n,m;
int a[maxN];
int b[maxN];
int lowbit(int x)
{
	return x&-x;
}
void add(int x,int p)
{
	int i = x;
	for(;i<=n;i+=lowbit(i))
	{
		(tree[i] += p) %= MOD;
	}
}
ll sum(int x)
{
	int i = x;
	ll s = 0;
	for(;i;i-=lowbit(i))
	{
		(s += tree[i])%=MOD;
	}
	return s;
}

int main()
{
	n = inp();
	m = inp();
	if(m == 1)
	{
		puts("1");
		return 0;
	}
	for(int i=1;i<=n;i++)
	{
		a[i] = inp();
	}
	for(int i=1;i<=m;i++)
	{
		b[i] = inp();
	}
	for(int i=1;i<=n;i++)
	{
		int pos = lower_bound(b+1,b+1+m,a[i]) - (b+1);
		if(pos >=1 && pos< m)
			node.emplace_back(pii(a[i] - b[pos],a[i] - b[pos+1]));
	}
	sort(node.begin(),node.end());
	node.erase(unique(node.begin(),node.end()),node.end());
	vector<int> val;
	for(auto y: node)
	{
		val.emplace_back(-y.second);
	}
	sort(val.begin(),val.end());
	val.erase(unique(val.begin(),val.end()),val.end());
	ll ans = 1;
	for(int i=0;i<node.size();i++)
	{
		int p = lower_bound(val.begin(),val.end(),-node[i].second) - val.begin() + 1;
		int tmp = 1;
		(tmp += sum(p-1))%=MOD;
		add(p,tmp);
		
		(ans += tmp)%= MOD;
	}
	printf("%lld",ans);
    return 0;
}

Measured memory_bytes: 3828
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;


void main()
{
  auto n = readln.chomp.to!int;
  auto s = readln.chomp;
  auto t = readln.chomp;
  int res = 2 * n;
  if (s == t) {
    res = n;
  } else {
    foreach (int i; 0..n) {
      if (s[$-i-1..$] == t[0..i+1]) {
        res = 2 * n - i - 1;
      }
    }
  }
  res.writeln;
}


Measured memory_bytes: 256
import numpy as np
N = int(input())
X = list(map(int, input().split()))
x = np.array(X)
ans = 100000000000
for i in range (0,101):
    b = np.array([i]*N)
    c = x -b
    tem = np.square(c)
    tem_ans = np.sum(tem)
    if ans >= tem_ans:
        ans = tem_ans
print(ans)


Measured memory_bytes: 14404
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;


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

	int n, m, i, j, k, x, y, minn, maxx;
	cin >> n >> m;
	minn = n + 1, maxx = 0;
	for (i = 0; i < m; i++) {
		cin >> x >> y;
		maxx = max(maxx, x);
		minn = min(minn, y);
	}

	if (maxx > minn) cout << "0\n";
	else cout << minn + 1 - maxx << "\n";


	return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  long long a,b,c;
  cin >> a >> b >> c;
  long long ans;
  //long long  tmp = (a-1) % c ? 1 :0,tmp2 = b%c ? 1:0;
  if(a != 0) ans = b/c  - (a-1)/c;
  else ans = b/c + 1;
  cout << ans << endl;
  
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) cout << x << endl;
#define println(x) cout << x << endl;
using namespace std;
int main()
{
    int n, m;
    cin >> n >> m;

    vector<int> v(m);
    rep(i, m) v[i] = 0;

    rep(i, n) {
        int k;
        cin >> k;
        vector<int> a(k);
        rep(j, k) cin >> a[j];
        rep(j, k) {
            v[a[j]-1] ++;
        }
    }

    int cnt = 0;
    rep(j, m) {
        if (v[j] == n) {
cnt ++;
        }
    }
    put(cnt)


    return 0;
}

Measured memory_bytes: 3576
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        A solver = new A();
        solver.solve(1, in, out);
        out.close();
    }

    static class A {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            int n = Integer.parseInt(in.next());
            int k = Integer.parseInt(in.next());
            int ans = n - k + 1;

            // 出力
            out.println(ans);

        }

    }
}



Measured memory_bytes: 21588
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<iomanip>
#include<map>
#include<utility>
#include<string>
#include<unordered_map>
#include<queue>

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

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
int gcd(int a, int b){return b ? gcd(b, a%b) : a;}
int lcm(int a, int b){return a*b / gcd(a, b);}

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    vector<bool> right(n, false), left(n, false);
    for(int i = 0; i < n; i++){
        cin >> a[i];
        a[i]--;
    }
    
    int ans = 0;
    for(int i = 0; i < n; i++){
        if(i == a[a[i]] && i < a[i]) ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vl;
typedef pair<ll,ll> pll;
#define vbi vector<bool> 
#define mod 1000000007
#define INF 1000000000
#define all(x) x.begin(),x.end()
#define mp make_pair
#define pb push_back
#define sd second
#define ft first
#define ms(x,v)    memset(x, v, sizeof x)
#define endl '\n'
#define cnl cout<<endl;
#define fr(i,b) for(ll i=0; i<=b; i++)
#define frr(i,b) for(ll i=0;i<b;i++)
#define fb(i,b) for(ll i=b-1; i>=0; i--)
#define pi  3.141592653589793238
ll i,j;
int main(){
      
  ll n ;cin>>n;
  vl v(n);
  frr(i,n) cin>>v[i];
   sort(all(v));
    float x=(v[0]+v[1]);
    x=x/2;
   //cout<<x<<endl;
  for(i=2;i<n;i++){
    x=(x+v[i])/2;
   
  }
  cout<<setprecision(9)<<x<<fixed<<endl;


return 0;
}
 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using pi = pair<int, int>;
using lint = long long;
const int MAXN = 2005;
const int MAXK = 10005;

int n, k;
string s[MAXN];
bool dp2[MAXN][MAXK];
bool opt[MAXN][MAXK]; // which prefix of opts[i] is optimal at this moment?
string opts[MAXN];
char buf[MAXK];

int main(){
	scanf("%d %d",&n,&k);
	for(int i=1; i<=n; i++){
		scanf("%s", buf);
		s[i] = buf;
	}
	dp2[n+1][k] = 1;
	for(int i=n; i; i--){
		memcpy(dp2[i], dp2[i+1], sizeof(dp2[i]));
		for(int j=0; j+s[i].size()<=k; j++){
			dp2[i][j] |= dp2[i+1][j+s[i].size()];
		}
	}
	opt[0][0] = 1;
	for(int i=1; i<=n; i++){
		vector<int> vect(k + 1);
		for(int j=0; j<=k; j++){
			int transitable = 0;
			if(dp2[i+1][j] && opt[i-1][j]) transitable |= 1;
			if(dp2[i+1][j] && j >= s[i].size() && opt[i-1][j - s[i].size()]) transitable |= 2;
			if(transitable == 3){
				if(opts[i-1].substr(j - s[i].size(), s[i].size()) <= s[i]) transitable = 1;
				else transitable = 2;
			}
			vect[j] = transitable;
		}
		int lst = 0;
		for(int j=0; j<=k; j++){
			if(vect[j] == 1){
				lst = j;
			}
		}
		string cnd1 = opts[i-1].substr(0, lst);
		string cnd2 ="";
		for(int j=k; j>=s[i].size(); j--){
			if(vect[j] == 2){
				string this_part = opts[i-1].substr(0, j - s[i].size()) + s[i];
				if(cnd2.empty() || cnd2.substr(0, this_part.size()) > this_part){
					cnd2 = this_part;
				}
			}
		}
		if(cnd1.size() > cnd2.size()) swap(cnd1, cnd2);
		opts[i] = min(cnd1, cnd2);
		if(cnd2.substr(0, cnd1.size()) == cnd1) opts[i] = cnd2;

		vector<int> fail(s[i].size() + 1);
		vector<int> mtch(opts[i].size() + 1);
		int p = 0;
		for(int j=1; j<s[i].size(); j++){
			if(p && s[i][j] != s[i][p]) p = fail[p];
			if(s[i][j] == s[i][p]) p++;
			fail[j + 1] = p;
		}
		p = 0;
		for(int j=0; j<opts[i].size(); j++){
			while(p && opts[i][j] != s[i][p]) p = fail[p];
			if(opts[i][j] == s[i][p]) p++;
			if(s[i].size() == p){
				mtch[j + 1] = 1;
				p = fail[p];
			}
		}

		int lcp = 0;
		while(lcp < opts[i].size() && lcp < opts[i-1].size() && opts[i][lcp] == opts[i-1][lcp]) lcp++;
		for(int j=0; j<=lcp; j++){
			if(vect[j] == 1) opt[i][j] = 1;
			if(j + s[i].size() <= opts[i].size() && vect[j + s[i].size()] == 2 && mtch[j + s[i].size()]){
				opt[i][j + s[i].size()] = 1;
			}
		}
	}
	puts(opts[n].c_str());
}


Measured memory_bytes: 61824
#include <bits/stdc++.h>
using namespace std;
#define fix(f,n) std::fixed<<std::setprecision(n)<<f
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long int ll;
typedef unsigned long long int ull;
#define vi vector<int>
#define pii pair<int,int>
#define vii vector<pii>
#define max(a,b) ((a>b)?a:b)
#define min(a,b) ((a>b)?b:a)
#define max3(a,b,c) ((a>b)?(a>c)?a:c:(b>c)?b:c)
#define min3(a,b,c) ((a<b)?(a<c)?a:c:(b<c)?b:c)
#define REP(i,a,n) for(ll i=a;i<n;i++)
#define pb push_back
#define mp make_pair

int n;
bool c[21][21]={};
ll dp[1<<21];

ll dfs(int ind,int mask){
    if(ind==n){
        return 1;
    }
    if(dp[mask]!=-1){
        return dp[mask]%1000000007;
    }
    ll ans=0;
    for(int i=0 ; i<n ; i++){
        if(c[ind][i] && ((1<<i)&mask)==0){
            ans+=dfs(ind+1,mask|(1<<i));
            ans%=1000000007;
        }
    }
    return dp[mask]=ans%1000000007;
}

int main(){
	fast;
	int test=1;
	//cin >> test;
	while(test--){
	    cin >> n;
	    memset(dp,-1,sizeof dp);
	    for(int i=0 ; i<n ; i++){
	        for(int j=0 ; j<n ; j++){
	            cin >> c[i][j];
	        }
	    }
	    dfs(0,0);
	    cout << dp[0] << endl;
	}
	return 0;
}

Measured memory_bytes: 20032
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <math.h>
#include <deque>
using ll = long long;
using namespace std;

int main(){
    int n, m, t, sum = 0;
    cin >> n;
    vector<int> T;
    for (int i = 0; i < n; i++) {
        cin >> t;
        T.push_back(t);
        sum += t;
    }
    cin >> m;
    int p, x;
    for (int i = 0; i < m; i++) {
        int ans = sum;
        cin >> p >> x;
        p--;
        ans = ans - T[p] + x;
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 256
import sys
import collections

def solve():
    N=int(sys.stdin.readline().rstrip())
    S=list(sys.stdin.readline().rstrip())
    whites=[0]*(N+1)
    blacks=[0]*(N+1)
    for i,c in enumerate(S):
        if c=='.':
            whites[i+1]=whites[i]+1
            blacks[i+1]=blacks[i]
        else:
            whites[i+1]=whites[i]
            blacks[i+1]=blacks[i]+1

    # 左からi番目から左を白に、右を黒にする
    inf=1<<60
    ans=inf
    #print(whites)
    #print(blacks)
    all_whites=whites[N]
    for i in range(N+1):
        ans1=blacks[i] + (all_whites-whites[i])
        #print(ans1)
        ans=min(ans,ans1)
    return ans

print(solve())


Measured memory_bytes: 65648
n,x = gets.split.map(&:to_i)
if x == 1 || x == 2*n-1
    puts "No"
elsif n == 2
    puts "Yes"
    puts [1,2,3]
else
    puts "Yes"
    ans = Array.new(4)
    used = Array.new(2*n,false)
    ans[1] = x
    if x > 2
        ans[0] = x-2
        ans[2] = x+1
        ans[3] = x-1
        used[x-2] = true
    else
        ans[0] = x+1
        ans[2] = x-1
        ans[3] = x+2
        used[x+2] = true
    end
    used[x-1] = used[x] = used[x+1] = true
    j = 1
    (n-2).times do
        while used[j]
            j += 1
        end
        puts j
        used[j] = true
    end
    puts ans
    (n-3).times do
        while used[j]
            j += 1
        end
        puts j
        used[j] = true
    end
end

Measured memory_bytes: 4604
#include<stdio.h>
#include<iostream>
#include<string.h>
using namespace std;
typedef long long ll;
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define FORR(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define CHMIN(a,b) (a) = min((a),(b))
#define CHMAX(a,b) (a) = max((a),(b))

int main()
{
    int a,b;
    scanf("%d %d",&a,&b);
    int ans=a*b-a-b+1;
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <climits>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>

using namespace std;
#define TOSTRING(x) #x
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REPR(i,n) for(int i=(n)-1;i>=0;i--)
#define ALL(s) (s).begin(), (s).end()
#define so(V) sort(ALL(V))
#define rev(V) reverse(ALL(V))
#define uni(v) v.erase( unique(ALL(v)) , v.end());
#define PAU system("pause")

typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<vb> vvb;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;
const int INF = (1 << 28);
const ll LINF = 1e18;
const double PI = acos(-1);

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	string S;
	cin >> S;
	ll ans = 0;
	ll cnt = 0;
	REP(i, SZ(S)) {
		if (S[i] == 'W') {
			ans += cnt;
		}
		else {
			cnt++;
		}
	}
	cout << ans << endl; 
	PAU;
	return 0;
}


Measured memory_bytes: 780
# -*- coding: utf-8 -*-
sheet = []
for _ in range(3):
    sheet.append(list(map(int, input().split())))

n = int(input())
for _ in range(n):
    b = int(input())
    for i, row in enumerate(sheet):
        for j, v in enumerate(row):
            if v == b:
                sheet[i][j] = 0

flag = False
for i in range(3):
    if sheet[i][0] == 0 and sheet[i][1] == 0 and sheet[i][2] == 0:
        flag = True
        break
    elif sheet[0][i] == 0 and sheet[1][i] == 0 and sheet[2][i] == 0:
        flag = True
        break

if sheet[0][0] == 0 and sheet[1][1] == 0 and sheet[2][2] == 0:
    flag = True

if sheet[2][0] == 0 and sheet[1][1] == 0 and sheet[0][2] == 0:
    flag = True

if flag:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3064
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;

//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/rope>
//using namespace __gnu_pbds;
//using namespace __gnu_cxx;
//
//template<class T> using Tree = tree<T, null_type, less<T>, rb_t_tag,t_order_statistics_node_update>;
/***********************************************/
/* Dear online judge:
 * I've read the problem, and tried to solve it.
 * Even if you don't accept my solution, you should respect my effort.
 * I hope my code compiles and gets accepted.
 *  ___  __     _______    _______      
 * |\  \|\  \  |\  ___ \  |\  ___ \     
 * \ \  \/  /|_\ \   __/| \ \   __/|    
 *  \ \   ___  \\ \  \_|/__\ \  \_|/__  
 *   \ \  \\ \  \\ \  \_|\ \\ \  \_|\ \ 
 *    \ \__\\ \__\\ \_______\\ \_______\
 *     \|__| \|__| \|_______| \|_______|
 */
//const long long mod = 1000000007;
const long long mod = 998244353;
// watch this
//using ll = long long;
//typedef long long LL
#define ll long long
#undef ll

const int mxN = 200010;

int A[mxN], C[mxN];
int N;

bool check(int md) {
	int st = 0, en = N - 1;
	for (int i = 0; i < N; i++) {
		C[i] = A[i] >= md;
	}
	int x = N >> 1;
	for (int i = x; i > 0; i--) {
		if (C[i] == C[i - 1]) {
			st = i;
			break;
		}
	}
	for (int i = x; i + 1 < N; i++) {
		if (C[i] == C[i + 1]) {
			en = i;
			break;
		}
	}
//	cerr << md << ' ' << st << ' ' << en << '\n';
	if (x - st <= en - x)
		return C[st];
	return C[en];
}

int main(int argc, char** argv) {
#ifdef ONLINE_JUDGE
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
#endif

//	int N;
	cin >> N;
	N = (N << 1) - 1;
	for (int i = 0; i < N; i++)
		cin >> A[i];
	int lo = 1, hi = N, res = -1;
	while (lo <= hi) {
		int md = (lo + hi) >> 1;
		if (check(md))
			res = md, lo = md + 1;
		else
			hi = md - 1;
	}
	cout << res << '\n';
	return 0;
}


Measured memory_bytes: 1792
def solve():
    from sys import stdin
    f_i = stdin
    
    N = int(f_i.readline())
    
    for i in range(N):
        r, t = map(int, f_i.readline().split())
        rq, rr = divmod(r, 100)
        tq, tr = divmod(t, 30)
        p = 5 * tq + rq
        
        if rr == 0:
            if tr == 0:
                print(p)
            else:
                print(p, p + 5)
        else:
            if tr == 0:
                print(p, p + 1)
            else:
                print(p, p + 1, p + 5, p + 6)

solve()


Measured memory_bytes: 5632
import           Control.Exception (assert)

main :: IO ()
main = do
  n <- readLn
  ps <- map read . words <$> getLine
  assert (length ps == n) $
    putStrLn $ if solve n ps then "YES" else "NO"

solve :: Int -> [Int] -> Bool
solve n ps = (<= 2) $ length $ filter not $ zipWith (==) [1..n] ps


Measured memory_bytes: 764
w, h, n = map(int, input().split())
minx, maxx, miny, maxy = 0, w, 0, h
for _ in range(n):
    x, y, a = map(int, input().split())
    if a == 1:
        minx = max(minx, x)
    if a == 2:
        maxx = min(maxx, x)
    if a == 3:
        miny = max(miny, y)
    if a == 4:
        maxy = min(maxy, y)

print(max(0, maxx - minx) * max(0, maxy - miny))


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
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() {
  ios::sync_with_stdio(false);
  cin.tie(0);

  int n, k;
  string s;
  cin >> n >> k >> s;

  vector<int> v;
  int score = 0;
  rep(i, 0, n - 1) {
    if (s[i] == s[i + 1])
      score++;
  }

  cout << min(score + 2 * k, n - 1) << endl;
}


Measured memory_bytes: 3712
t = list(str(input()))
if len(t) == 1:
    if t[0] == "?":
        print("D")
        exit()
for i in range(1,len(t)):
    if t[i] == "?":
        if t[i-1] == "P":
            t[i] = "D"
        elif t[i-1] == "?":
            t[i-1] = "P"
            t[i] = "D"
for i in range(len(t)-1):
    if t[i] == "?":
        if t[i+1] == "D":
            t[i] = "P"
        elif t[i+1] == "P":
            t[i] = "D"
if t[-1] == "?":
    t[-1] = "D"
ans = "".join(t)
print(ans)

Measured memory_bytes: 10636
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <deque>
#include <cctype>
#include <cstdio>
#include <math.h>
using namespace std;
int main(){
    string s;
    cin >> s;
    long long ans=0;
    long long cnt=0;
    for(int i=s.length()-1;i>=0;i--){
        if(s[i]=='B'){
            ans += s.length()-1-i-cnt;
            cnt++;
        }
    }
    cout << ans <<  endl;
}


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

#define REP(i, m, n) for (int i = (m); i < (int)(n); i++)
#define REPS(i, m, n) for (int i = (m); i <= (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define reps(i, n) for (int i = 0; i <= (int)(n); i++)
#define rrep(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define rreps(i, x) for (int i = (int)(x); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int, int> P;
const int inf = INT_MAX;
const ll INF = 1LL << 60;
const ll mod = 1e9 + 7;
const double EPS = 1e-10;
const double PI = acos(-1.0);
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<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val) { fill( (T*)array, (T*)(array+N), val ); }


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

    ll N; cin >> N;
    vector<ll> A(N);
    rep(i, N) cin >> A[i];

    ll ans = 0;
    rep(i, 60) {
        ll msk = 1LL << i;
        ll zero = 0, one = 0;
        rep(i, N) {
            if (A[i] & msk) one++;
            else zero++;
        }
        ans += msk % mod * zero % mod * one;
        ans %= mod;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2560
a, b, c, x, y = (int(x) for x in input().split())
ans = 10**18
ans = min(ans, a * x + b * y)
z = min(x, y)
ans = min(ans, 2 * c * z + a * (x - z) + b * (y - z))
ans = min(ans, 2 * c * max(x, y))
print(ans)


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

using namespace std;

int main(){
	int n;
	string a, b;
	cin >> n >> a >> b;
	string ta(a), tb(b);
	for (int i = n; i >= 0; --i){
		if (ta == tb){
			cout << n * 2 - i << endl;
			break;
		}
		ta.erase(ta.begin());
		tb.erase(tb.end() - 1);
	}
	return 0;
}


Measured memory_bytes: 256
// Solution for 0525: Osenbei
#include <iostream>
#include <algorithm>
using namespace std;
int r, c, ans, sum;
int cracker[11][10001], save[11][10001];
void solve(int i){
	sum = 0;
	for (int j = 1; j <= c; j++){
		save[i][j] = cracker[i][j];
		if (cracker[i][j])
			cracker[i][j] = 0;
		else
			cracker[i][j] = 1;
		int count = 0;
		for (int k = 1; k <= r; k++){
			if (cracker[k][j])
				count++;
		}
		if (count > r / 2)
			sum += count;
		else
			sum += r - count;
	}
	ans = max(ans, sum);
	if (i == r)
		return;
	for (int j = i + 1; j <= r; j++){
		solve(j);
		for (int k = 1; k <= c; k++){
			cracker[j][k] = save[j][k];
		}
	}
}
int main(){
	while (true){
		cin >> r >> c;
		if (!r && !c)
			return 0;
		ans = 0;
		for (int i = 1; i <= r; i++){
			for (int j = 1; j <= c; j++){
				cin >> cracker[i][j];
			}
		}
		for (int i = 1; i <= r; i++){
			solve(i);
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 1948
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
    int k;
    cin >> k;
    
    int n = 7;
    for (int i = 1; i < 1000000; i++) {
        if (n % k == 0) {
            cout << i << endl;
            return 0;
        }
        n *= 10;
        n += 7;
        n %= k;
    }
    
    cout << -1 << endl;
    
    return 0;
}


Measured memory_bytes: 3588
N,Y = map(int,input().split())
flag = False
for i in range(N+1):
    for j in range(N+1):
        if Y<(10000*i+5000*j):
            break
        elif (Y-(10000*i+5000*j))/1000==N-i-j:

            print(str(i)+" "+str(j)+" "+str(N-i-j))
            flag = True
            break
    if flag == True:
        break
else:
    print("-1 -1 -1")


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

#define int long long int
#define fi first
#define so second
#define ps push_back
#define ld long double
#define mod 1000000007

int modInverse(int a,int m)
{
    int m0 = m;
    int y = 0, x = 1;

    if (m == 1)
      return 0;

    while (a > 1)
    {
        // q is quotient
        int q = a / m;
        int t = m;

        // m is remainder now, process same as
        // Euclid's algo
        m = a % m, a = t;
        t = y;

        // Update y and x
        y = x - q * y;
        x = t;
    }

    // Make x positive
    if (x < 0)
       x += m0;

    return x;
}

signed main()
{
    int n,k,i,j;
    cin>>n>>k;
    int a[n];
    for(i=0;i<n;i++) cin>>a[i];
    sort(a,a+n);
    int k1[n]={0},k2[n]={0};
    if(k==1)
    {cout<<0;return 0;}
    for(i=0;i<n;i++)
    {
        if(i<k-2) {k2[i]=0;continue;}
        if(i==k-2) {k2[i]=1;continue;}
        k2[i] = ((k2[i-1]%mod)*(i%mod))%mod;
        k2[i] = ((k2[i]%mod)*(modInverse(i-(k-2),mod)%mod))%mod;
    }
    //for(i=0;i<n;i++) cout<<i<<"C"<<k-2<<" = "<<k2[i]<<endl;
    for(i=0;i<n;i++)
    {
        if(i<k-1) {k1[i]=0;continue;}
        if(i==k-1) {k1[i]=1;continue;}
        k1[i] = ((k1[i-1]%mod)*(i%mod))%mod;
        k1[i] = ((k1[i]%mod)*(modInverse(i-(k-1),mod)%mod))%mod;
    }
    //for(i=0;i<n;i++) cout<<i<<"C"<<k-1<<" = "<<k1[i]<<endl;
    for(i=1;i<n;i++) k2[i] = ((k2[i]%mod) + (k2[i-1]%mod))%mod;
    int sum=0;
    for(i=1;i<n;i++) sum = ((sum%mod) + (((a[i]%mod)*(k1[i]%mod))%mod))%mod;
    for(i=0;i<n-1;i++) sum = ((sum%mod) - (((a[i]%mod)*(k2[n-i-2]%mod))%mod) + mod)%mod;
    cout<<sum%mod;

}


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

bool Comp(pair<int,int>a,pair<int,int>b)
{
    return a.second < b.second;
}
int main()
{
   int N;
   cin >> N;
   vector<pair<int,int>>ab(N);
   rep(i,0,N){
       cin >> ab[i].first >> ab[i].second;
   }

   sort(ab.begin(),ab.end(),Comp);
   
   ll now=0;
   rep(i,0,N){
       now+=ab[i].first;
       if(now>ab[i].second){
           cout << "No" << endl;
           return 0;
       }
   }

   cout << "Yes" << endl;
   return 0;
}

Measured memory_bytes: 1792
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.util.InputMismatchException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author amotoma3
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskD solver = new TaskD();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskD {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            long a = in.nextLong(), b = in.nextLong();
            long[] x = in.nextLongArray(n);

            long sum = 0;
            for (int i = 0; i < n - 1; i++) {
                sum += Math.min(a * (x[i + 1] - x[i]), b);
            }

            out.println(sum);
        }

    }

    static class InputReader {
        BufferedReader in;
        StringTokenizer tok;

        public String nextString() {
            while (!tok.hasMoreTokens()) {
                try {
                    tok = new StringTokenizer(in.readLine(), " ");
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
            }
            return tok.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(nextString());
        }

        public long nextLong() {
            return Long.parseLong(nextString());
        }

        public long[] nextLongArray(int n) {
            long[] res = new long[n];
            for (int i = 0; i < n; i++) {
                res[i] = nextLong();
            }
            return res;
        }

        public InputReader(InputStream inputStream) {
            in = new BufferedReader(new InputStreamReader(inputStream));
            tok = new StringTokenizer("");
        }

    }
}



Measured memory_bytes: 38040
x = int(input())
ans = 1
if x < 4:
    print(1)
else:
    for i in range(2,int(x**(1/2)+1)):
        j = 2
        a = -1
        while a <= x:
            ans = max(ans,a)
            a = i**j
            j += 1
    print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int N;
int A[101];

int main(){
  cin>>N;
  for(int i=0;i<N;i++){
    int p;
    cin>>p;
    A[p]++;
  }
  int sum=0;
  for(int i=100;i>=0;i--){
    sum+=A[i];
    if(sum>=i){
      cout<<i<<endl;
      break;
    }
  }
  return 0;
}

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

int N;
int A[100005][3];
int dp[100005][3]; // [0] used A last round, [1] used B, [2] used C

int main() {
  cin >> N;
  
  for (int i = 0; i < N; i++) {
    cin >> A[i][0] >> A[i][1] >> A[i][2];
  }
  
  dp[0][0] = A[0][0];
  dp[0][1] = A[0][1];
  dp[0][2] = A[0][2];
  dp[1][0] = max(dp[0][1], dp[0][2]) + A[1][0];
  dp[1][1] = max(dp[0][0], dp[0][2]) + A[1][1];
  dp[1][2] = max(dp[0][0], dp[0][1]) + A[1][2];
  
  for (int i = 2; i < N; i++) {
    dp[i][0] = max(dp[i-2][0], max(dp[i-1][1], dp[i-1][2])) + A[i][0];
    dp[i][1] = max(dp[i-2][1], max(dp[i-1][0], dp[i-1][2])) + A[i][1];
    dp[i][2] = max(dp[i-2][2], max(dp[i-1][0], dp[i-1][1])) + A[i][2];
  }
  
  cout << max(dp[N - 1][0], max(dp[N - 1][1], dp[N - 1][2]));
  
  return 0;
}

Measured memory_bytes: 2560
#include<iostream>
#include<algorithm>
#include<math.h>
#include<string.h>
#include<stdio.h>
using namespace std;
int n,m,sum=0;
int mp[16][16];
int cost[1<<16][16],dp[1<<16][16];//dp[s][x]记录达到某点集s,最后“末端”（继续连接其余点的唯一点）为x时余下权值和最大的边的情况
int inner[1<<16];//内部的边
int main(){
    cin>>n>>m;
    for(int i=1;i<=m;i++){
        int x,y,price;
        cin>>x>>y>>price;
        sum+=price;
        mp[x-1][y-1]=mp[y-1][x-1]=price;
    }
    for(int i=0;i<1<<n;i++){//计算某点集内部所有边权值之和
        for(int a=0;a<n;a++){
            if(i&(1<<a)){
                for(int b=0;b<a;b++){
                    if(i&(1<<b)&&(mp[a][b])){
                    	inner[i]+=mp[a][b];
					}
				}
			}else{
				for(int b=0;b<n;b++){//计算某点集到点集外某点所有边的权值之和
        			if((i&(1<<b))&&mp[a][b]){
                    	cost[i][a]+=mp[a][b];
					}
				}
			}
		}
    }
    memset(dp,-1,sizeof(dp));
    dp[1][0]=0;//只有1个点的集合dp值显然为0
    for(int i=0;i<1<<n;i++){
        for(int a=0;a<n;a++){
            if((i&(1<<a))&&dp[i][a]!=-1){
                for(int b=0;b<n;b++){
                	if(!(i&(1<<b))){/*只加入一个点*/
                        if(mp[a][b]){
                        	dp[i|(1<<b)][b]=max(dp[i|(1<<b)][b],dp[i][a]+mp[a][b]);
						}
					}
				}
                /*加入一个点集*/
                int left=(1<<n)-1-i;
                for(int now=left;now!=0;now=(now-1)&left){//用此循环得到所有子集
                    int num=inner[now]+cost[now][a];
                    dp[i|now][a]=max(dp[i|now][a],dp[i][a]+num);
                }
            }
        }
    }
    cout<<sum-dp[(1<<n)-1][n-1]<<endl;
    return 0;
}
/*

in:
4 6
1 2 100
3 1 100
2 4 100
4 3 100
1 4 100
3 2 100

out:
200

*/

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

const int MAX = 200001;
int main() {
	int N;
	static int P[MAX];
	cin >> N;
	int isCheck[MAX];
	isCheck[0] = 0;
	for (int i = 0;i < N;i ++) {
		cin >> P[i];
		isCheck[i + 1] = 0;
	}
	
	int max = 0;
	for (int i = 0;i < N;i ++) {
		isCheck[P[i]] = isCheck[P[i] - 1] + 1;
		if (max < isCheck[P[i]]) max = isCheck[P[i]];
	}
	cout << N - max;
	return 0;
}
/*
31536000のコメント解説欄
ここテンプレで用意してるから、A問題とかだとこの先空欄の危険あり

まず、符号が逆転している数だけ動かす必要がある
どう動かそうと逆転だけは直せないからねぇ

1 3 2 4だと1<3>2<4で、まず2か3を動かしたい
3 2 5 1 4 6だと3<2>5<1>4>6で、まず2、1、4を動かしたい
ところで、まずどちらか動かさないことに固定してみよう
両側を固定は不可能だからね
そこで、先頭を固定してみようか
すると、次のように考えることができる
先頭から見て、i < jに対しa_i < a_jを満たさないようなものの内最小のものを動かせばいい
例えば、1 2 3 8 7 6 4 5なら1 2 3 4 5固定して8 7 6を動かしてしまえば良い
逆に1 3 2 6 4 5 7 8だと6 7 8固定してやればおｋ
じゃ、それ以外を動かさなくて良いパターンがあるか考えてみるか
ここで、そのようなパターンは全ての固定の前に、固定していない最大の数がある場合だけど、それは上の時に固定パターンに数えられてる
つまりそんなパターンはない！
次に、両側を動かした方が良いパターン
2 1 3 4 5 6 8 7 
これは2手だけど、検出できない
つまり、必要なのは連続した数値が最大何個連続するか、だね！(上だと2 ? 3 4 5 6 ? 7で6個連続)
*/

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

int main(){
    ll a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;
    ll ans1 = max(x, y) * 2 * c;
    ll ans2 = a * x + b * y;
    ll ans3;
    if(x < y) ans3 = c * 2 * x + b * (y - x);
    else ans3 = c * 2 * y + a * (x - y);
    cout << min({ans1, ans2, ans3}) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll arr[100100],n,p,ans,temp,k,m,a,b;
int main()
{
    cin>>a>>b;
    if((a+b)%3==0 || a%3==0 || b%3==0)
        cout<<"Possible"<<endl;
    else
        cout<<"Impossible"<<endl;

return 0;
}


Measured memory_bytes: 256
n, k = map(int, input().split())
MOD = 10**9+7
dp = [0]*(k+1)
for i in range(k, 0, -1):
  dp[i] = pow((k//i), n, MOD)
  for j in range(i+i, k+1, i):
    dp[i] -= dp[j]
ans = sum([i*dp[i] for i in range(k+1)])
ans %= MOD
print(ans)

Measured memory_bytes: 15588
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        sc.close();
        init(k);
        for(int i=1;i<k;i++){
            unite(i, (i*10)%k);
        }
        HashSet<Integer>[] edges=new HashSet[k];
        for(int i=0;i<k;edges[i++]=new HashSet<>());
        for(int i=0;i<k;i++){
            if(!same(i, (i+1)%k)){
                edges[root(i)].add(root((i+1)%k));
            }
        }
        ArrayDeque<Integer> dq=new ArrayDeque<>();
        dq.add(root(1));
        int[] d=new int[k];
        for(int i=0;i<k;d[i++]=-1);
        d[root(1)]=0;
        while(dq.size()>0){
            int now=dq.pollFirst();
            for(int next:edges[now]){
                if(d[next]<0){
                    d[next]=d[now]+1;
                    dq.addLast(next);
                }
            }
        }
        System.out.println(d[root(0)]+1);
    }

    static int[] parent, rank, num;
    public static void init(int n){
        parent=new int[n];
        rank=new int[n];
        num=new int[n];
        for(int i=0;i<n;i++){
            parent[i]=i;
            num[i]=1;
        }
    }
    public static int root(int x){
        if(parent[x]==x) return x;
        parent[x]=root(parent[x]);
        return parent[x];
    }
    public static boolean same(int x, int y){
        return root(x)==root(y);
    }
    public static boolean unite(int x, int y){
        int xr=root(x);
        int yr=root(y);
        if(xr==yr) return false;
        if(rank[xr]<rank[yr]){
            parent[xr]=yr;
            num[yr]+=num[xr];
        }
        else{
            parent[yr]=xr;
            num[xr]+=num[yr];
            if(rank[xr]==rank[yr]) rank[xr]++;
        }
        return true;
    }
    public static int size(int x){
        return num[root(x)];
    }
}


Measured memory_bytes: 50788
#include<iostream>
#include<string>
using namespace std;
static const int MAX_M=10e5;
int ans[MAX_M];
int take[MAX_M];
int main(void){
	int N,M;
		cin >> N >> M;
	string S;
		cin >> S;
		
	for(int i=1;i<N;i++){
		if(S[i-1]=='A' && S[i]=='C')
			take[i]=take[i-1]+1;
		else
			take[i]=take[i-1];
	}
	for(int i=0;i<M;i++){
		int x,y;
			cin >> x >> y;
		x--;y--;
		ans[i]=take[y]-take[x];
	}
		
		
	for(int i=0;i<M;i++)
		cout << ans[i] << endl;
	return 0;
}

Measured memory_bytes: 5504
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	N := nextInt()
	M := nextInt()
	K := nextInt64()
	A := make([]int64, N)
	B := make([]int64, M)
	for i := 0; i < N; i++ {
		A[i] = nextInt64()
	}
	for i := 0; i < M; i++ {
		B[i] = nextInt64()
	}
	maxValue := 0
	restTime := K
	currentA := -1
	currentB := -1
	currentValue := 0
	for i, v := range A {
		if v > restTime {
			break
		}
		restTime -= v
		currentA = i
		currentValue++
	}
	for i, v := range B {
		if v > restTime {
			break
		}
		restTime -= v
		currentB = i
		currentValue++
	}
	maxValue = currentValue

	if currentA == -1 {
		fmt.Println(maxValue)
		return
	}

	for i := currentA; i >= 0; i-- {
		restTime += A[i]
		currentValue--
		for j := currentB + 1; j < M; j++ {
			if restTime < B[j] {
				break
			}
			restTime -= B[j]
			currentValue++
			currentB = j
		}
		if currentValue > maxValue {
			maxValue = currentValue
		}
	}
	fmt.Println(maxValue)
}

func nextInt() int {
	v, _ := strconv.Atoi(nextReader())
	return v
}

func nextInt64() int64 {
	v, _ := strconv.ParseInt(nextReader(), 10, 64)
	return v
}

func nextString() string {
	return nextReader()
}

func nextInts(n int) []int {
	r := make([]int, n)
	for i := 0; i < n; i++ {
		r[i] = nextInt()
	}
	return r
}

func nextInt64s(n int) []int64 {
	r := make([]int64, n)
	for i := 0; i < n; i++ {
		r[i] = nextInt64()
	}
	return r
}

var nextReader func() string

func init() {
	nextReader = NewScanner()
}

func NewScanner() func() string {
	r := bufio.NewScanner(os.Stdin)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)
	return func() string {
		r.Scan()
		return r.Text()
	}
}

func Min(a int, b int) int {
	if a > b {
		return b
	}
	return a
}

func Max(a int, b int) int {
	if a > b {
		return a
	}
	return b
}

func MinA(arg ...int) int {
	var s = arg[0]
	for _, v := range arg {
		s = Min(s, v)
	}
	return s
}

func MaxA(arg ...int) int {
	var s = arg[0]
	for _, v := range arg {
		s = Max(s, v)
	}
	return s
}

func Abs(a int) int {
	if a < 0 {
		return a * -1
	}
	return a
}


Measured memory_bytes: 8260
N = int(input())
abc = [list(map(int,input().split())) for _ in range(N)]
dp = [[0]*3 for _ in range(N)]
a,b,c = abc[0]
dp[0][0] = a
dp[0][1] = b
dp[0][2] = c

for i in range(N-1):
    a,b,c = abc[i+1]
    dp[i+1][0] = max(dp[i+1][0],dp[i][1] + a ,dp[i][2] + a )
    dp[i+1][1] = max(dp[i+1][1],dp[i][0] + b ,dp[i][2] + b )
    dp[i+1][2] = max(dp[i+1][2],dp[i][0] + c ,dp[i][1] + c )
print(max(dp[-1]))

Measured memory_bytes: 76376
s = str(input())
l = len(s)
ans = 0

for bit in range(1 << (l-1)):
    f = s[0]

    for i in range(l-1):
        if bit & (1 << i):
            f += "+"
        f += s[i+1]

    ans += sum(map(int,f.split("+")))

print(ans)


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

int solve(int H, vector<int> &A) {
  for (auto x : A) {
    H -= x;
    if (H <= 0) return 1;
  }
  return 0;
}

int main() {
  int H, N;
  cin >> H >> N;
  vector<int> A(N);

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

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

  int ans = solve(H, A);

  if (ans==1) cout << "Yes" << endl;
  else if (ans==0) cout << "No" << endl;

}



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

using namespace std;

static const int INF = 1e9 + 7;

template<typename T>
using Vec = vector<T>;

template<typename T, typename T2>
using P = pair<T, T2>;

template<typename... Args>
using Tup = tuple<Args...>;

template<typename T>
using qp = priority_queue<T, Vec<T>, greater<T> >;

template<typename T>
using pq = priority_queue<T>;

using llong = long long;
using ullong = unsigned long long;
using uint = unsigned int;

template<typename T>
T gcd(T x, T y)
{
	return y ? gcd(y, x % y) : x;
}

void hawawa()
{
	string str;
	cin >> str;
	int s, e;
	for (s = 0; str[s] != 'A'; s++);
	for (e = str.size() - 1; str[e] != 'Z'; e--);
	cout << e - s + 1 << "\n";
}

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


Measured memory_bytes: 720
#include <iostream>

#define INFL (1LL << 60)

using namespace std;

typedef long long ll;

int main() {
    ios::sync_with_stdio(false);
    ll n, ans = INFL;
    cin >> n;
    for (ll i = 1; i * i <= n; ++i) if (n % i == 0) ans = min(ans, i + n / i);
    cout << ans - 2 << endl;
    return 0;
}


Measured memory_bytes: 256
/* Atcoder abc171a
 * See tasks at: https://atcoder.jp/contests/abc171/tasks/abc171_a
 */
#include <bits/stdc++.h>

#define until(symbol, max) for (int symbol = 0; (symbol) < (max); (symbol)++)

using namespace std;
using ll = long long;
int main()
{
    char c;
    cin >> c;

    if ('A' <= c && c <= 'Z')
    {
        cout << "A";
    }
    else
    {
        cout << "a";
    }
    return 0;
}


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

#define st first
#define nd second
#define ll long long
#define ld long double
#define pb push_back
#define emp emplace_back
#define pii pair<int, int>
#define usg unsigned
#define sg signed
#define mp make_pair

using namespace std;

void setIO(){
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
}

const ld PI = 4*atan((ld)1);
const int INF = 1e9+7;

int main(){
	setIO();
	int ans = 0;
	for (int i = 1; i <= 5; i++){
		int x; cin >> x;
		if (x == 0) ans = i;
	}
	cout << ans << endl;
}

Measured memory_bytes: 3640
N, K = map(int, input().split())
hlist = []
for i in range(N):
    hlist.append(int(input()))

import numpy as np
hlist = np.sort(hlist)

ans = 10**10
for i in range(N-K+1):
    ans = min(ans, hlist[i+K-1]-hlist[i])
print(ans)

Measured memory_bytes: 17784
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <cmath>

using namespace std;
#define PI 3.1415926535897932384626433832795
#define MOD (1000000007)
#define EPS (1e-15)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
#define bet(x, a, b) (a) <= (x) && (x) < (b)
typedef long long ll;
typedef unsigned long long ull;

#define NMAX (300)
#define p(a, b) make_pair(a, b)
typedef pair<int, int> pi;

struct pc {
	int chg;
	int rem;
	int idx;
};

int N, M, L, Q;
int s[NMAX * (NMAX - 1)];
int t[NMAX * (NMAX - 1)];

vector<pi> G[NMAX + 1];
bool done[NMAX + 1] = { false };
int ans[NMAX + 1][NMAX + 1];

void setAns(int root)
{
	auto comp = [](pc& a, pc& b) {
		return (a.chg != b.chg ? a.chg > b.chg : a.rem < b.rem);
	};

	priority_queue<pc, vector<pc>, decltype(comp)> pq{comp};
	pc item;

	repc(i, 1, N) done[i] = false;

	item.chg = 0, item.rem = L, item.idx = root;
	pq.push(item);

	while (!pq.empty()) {
		item = pq.top(); pq.pop();
		int chg = item.chg;
		int rem = item.rem;
		int current = item.idx;
		int size = G[current].size();

		if (done[current]) continue;
		done[current] = true;
		ans[root][current] = chg;

		rep(i, size) {
			pi info = G[current][i];
			int next = info.first;
			int len = info.second;

			if (done[next]) continue;

			if (rem >= len) {
				item.chg = chg;
				item.rem = rem - len;
			}
			else {
				item.chg = chg + 1;
				item.rem = L - len;
			}
			item.idx = next;
			pq.push(item);
		}
	}
}

int main()
{
	int A, B, C;

	cin >> N >> M >> L;
	rep(i, M) {
		cin >> A >> B >> C;
		if (C > L) continue;
		G[A].push_back(p(B, C));
		G[B].push_back(p(A, C));
	}
	cin >> Q;
	rep(i, Q) cin >> s[i] >> t[i];

	repc(i, 1, N) repc(j, 1, N) ans[i][j] = -1;
	repc(i, 1, N) setAns(i);

	rep(i, Q) cout << ans[s[i]][t[i]] << endl;

	return 0;
}


Measured memory_bytes: 3880
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main() {
    int a, b;
    cin >> a >> b;
    cout << (b % a == 0 ? a + b : b - a) << endl;

    return 0;
}


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

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> VI;
#define db double
ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }	
const int maxn=18;
char s[maxn];
int main()
{
	int n,m,k;
	while(scanf("%d%d%d",&n,&m,&k)==3)
	{
		if(n>m)	swap(n,m);
		bool flag=false;
		REPE(i,m){
			if(i*n==k)	flag=true;
			int sk=k-i*n;
			if(sk<0)	break;
			if(m-i*2==0)	continue;
			if(sk%(m-i*2)==0&&sk/(m-i*2)<=n&&sk/(m-i*2)>0)	flag=true;
		}
		REPE(i,n){
			if(i*m==k)	flag=true;
			int sk=k-i*m;
			if(sk<0)	break;
			if(n-i*2==0)	continue;
			if(sk%(n-i*2)==0&&sk/(n-i*2)<=m&&sk/(n-i*2)>0)	flag=true;
		}
		if(flag)	printf("Yes\n");
		else	printf("No\n");
	}
	return 0;
}

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

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

    vector<int> v(n);
    for (int i=0; i<n; i++){
        cin >> v.at(i);
    }

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

    int total = 0;
    for (int j=0; j<k; j++){
        total += v.at(j);
    }
    cout << total << endl;
}

Measured memory_bytes: 3628
import math

n=int(input())
count,cnt=0,0

for i in range(1,n+1,2):
  for j in range(1,math.ceil(i/2)):
    if i%j==0:
      count+=1
      
  if count+1==8:
    cnt+=1
    
  count=0
  
print(cnt)

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

int main(){
	int n = 0, sB = 0, eA = 0,count = 0,flag=0;
	bool b = false;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		b = false;
		string s;
		cin >> s;
		if (s[0] == 'B' && s.back() == 'A')
		{
			flag++;
		}
		if (s[0] == 'B')
		{
			sB++;
		}
		if (s.back()== 'A')
		{
			eA++;
		}
		for (int k = 0; k < s.size(); k++)
		{
			if (s[k] == 'A')
			{
				b = true;
			}
			else if ((s[k] == 'B') && b)
			{
				count++;
				b = false;
				//cout << "S:" << s << endl;
			}
			else b = false;
		}
	}
	if (sB == flag && eA == flag && flag!=0)
	{
		sB--;
	}
	cout << count + min(sB,eA) << endl;
	//cout << sB << "," << eA << "," << count;
	
}

Measured memory_bytes: 256
a = int(input())
b = int(input())
c = int(input())
x = int(input())
ans = 0

for i in range(a+1):
    for j in range(b+1):
        for n in range(c+1):
              if i*500 + j*100+n*50 == x:
                ans+=1

print(ans)


Measured memory_bytes: 3060
A,B=map(int,input().split())
G=[['.']*100 for i in range(100)]

for i in range(50):
    for j in range(100):
        G[i][j]='#'




white,black=1,1

for i in range(0,50,2):
    for j in range(0,100,2):
        if white==A:
            break
        G[i][j]='.'
        white+=1

for i in range(51,100,2):
    for j in range(0,100,2):
        if black==B:
            break
        G[i][j]='#'
        black+=1

print(100,100)
for i in range(100):
    print(*G[i],sep='')

Measured memory_bytes: 4468