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

typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;

template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
 
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

const ll INF = 1e18;
const ll MOD = 998244353;
const ll MX = 1000001;

ll H;

void solve() {
    cin >> H;
    ll monsters = 1, ans = 0;
    while (H >= 1) {
		ans += monsters;
		monsters *= 2;
		H /= 2;
	}
	cout << ans;
}

int main() {
	cin.sync_with_stdio(0); cin.tie(0);
    ll T = 1; // cin >> T;
    while (T--) solve();
    return 0;
    // You should actually read the stuff at the bottom
}

/* Stuff to Look For
 * -----------------
 * Int overflow, array bounds
 * Initializing all variables, avoid weird behavior
 * Edge cases(n = 0, n = 1)
 * Just return 0 after result
 */


Measured memory_bytes: 3652
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/









int N, Q; string S;
char T[201010], D[201010];
//---------------------------------------------------------------------------------------------------
int check(int x) {
	rep(i, 0, Q) {
		if (T[i] == S[x]) {
			if (D[i] == 'L') x--;
			else x++;
		}

		if (x < 0 or N <= x) return x;
	}
	return x;
}
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> N >> Q >> S;
	rep(q, 0, Q) cin >> T[q] >> D[q];

	int ans = N;

	if (check(0) < 0) {
		int ok = 0, ng = N;
		while (ok + 1 != ng) {
			int md = (ok + ng) / 2;
			if (check(md) < 0) ok = md;
			else ng = md;
		}
		ans -= ok + 1;
	}

	if (N <= check(N - 1)) {
		int ng = -1, ok = N - 1;
		while (ng + 1 != ok) {
			int md = (ok + ng) / 2;
			if (N <= check(md)) ok = md;
			else ng = md;
		}
		ans -= N - ok;
	}

	cout << ans << endl;
}


Measured memory_bytes: 976
def main():
    import sys
    def input():
        return sys.stdin.readline()[:-1]
    A=list(map(int,input().split()))
    i=0
    X=A[0]
    Y=A[1]
    for b in range(X+1):
        if 2*(X+b)==Y:
            print("Yes")
            sys.exit()
    print("No")


    
if __name__ == '__main__':
    main()


Measured memory_bytes: 9184
#include<iostream>
#include<cmath>
#include<vector>
using namespace std;
typedef long long ll;

const int MNUM = 12, leapMNUM = 12;
const int ML[] = {31,28,31,30,31,30,31,31,30,31,30,31};      //day/month in usual year
const int leapML[] = {31,29,31,30,31,30,31,31,30,31,30,31};  //day/month in leap year
const string days[] = {"Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"};

struct date{
  int y,m,d;

  date(void):y(0),m(1),d(1){}
  date(int a,int b,int c):y(a),m(b),d(c){}
  
  bool isLeap(void){
    if(y%400==0)return true;
    if(y%100==0)return false;
    if(y%4==0)return true;
    return false;
  }

  date next(void){
    d++;
    if(isLeap()){
      if(leapML[m-1]<d){ d=1; m++; }
      if(leapMNUM<m){ m=1; y++; }
    }else{
      if(ML[m-1]<d){ d=1; m++; }
      if(MNUM<m){ m=1; y++; }
    }
    return *this;
  }

  bool operator==(const date x)const{return (y==x.y && m==x.m && d==x.d);}

  bool operator<(const date x)const{
    if(y!=x.y)return y<x.y;
    if(m!=x.m)return m<x.m;
    return d<x.d;
  }

  bool operator<=(const date x)const{return (*this==x || *this<x); }
  bool operator>(const date x)const{return !(*this<=x);}
  bool operator>=(const date x)const{return !(*this<x);}

  ll dayCount(void)const{
    date tmp;
    for(ll res=0;;res++){
      if(tmp==*this)return res;
      tmp.next();
    }
    return 0;
  }

  ll operator-(const date x)const{
    return dayCount() - x.dayCount();
  }

  //calculate days from Julian Day(-4713/01/01) using Fliegel's formula.
  ll Fliegel(void){
    int a = (14-m)/12, Y = y+4800-a, M = m+12*a-3;
    return (ll)d + (153*M+2)/5 + 365*Y + Y/4 - Y/100 + Y/400 - 32045;
  }

  //calculate day of week using Zeller congruence.
  int Zeller(void){
    int Y = y, M = m;
    if(M<3){ Y--; M+=12; }
    return (Y + Y/4 - Y/100 + Y/400 + (13*M+8)/5 + d)%7;
  }
};

int main(){
  int m,d;
  while(cin >> m >> d,m||d)
    cout << days[date(2004,m,d).Zeller()] << endl;
}

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

int main(){

    int a,b,c;
    cin >> a >> b >> c;

    double n = (double)(a + b + c)/2;
    if((double)a == n || (double)b == n || (double)c == n){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
def main():
    N = int(input())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))
    ans = 0
    for i, b in enumerate(B):
        if A[i] <= b:
            ans += A[i]
            remain = b - A[i]
        else:
            ans += b
            remain = 0
        if remain > 0:
            if A[i+1] < remain:
                ans += A[i+1]
                A[i+1] = 0
            else:
                ans += remain
                A[i+1] -= remain
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 97348
#include <bits/stdc++.h> 
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define size_of_array(array) (sizeof(array)/sizeof(array[0]))
using ll =long long;
using namespace std;
using Graph=vector<vector<int>>;
using Field=vector<vector<int>>;

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

const double PI=(acos(-1));

int main(){
    int a,b;
    cin>>a>>b;
    if(b%a==0)cout<<a+b<<endl;
    else cout<<b-a<<endl;
}


Measured memory_bytes: 3652
import unittest


def solve(t):
    t = t.replace('?', 'D')

    return t


def main():
    t = input()
    result = solve(t)
    print(result)


class Test(unittest.TestCase):
    def test_solve(self):
        self.assertEqual(1, 1)


if __name__ == "__main__":
    main()


Measured memory_bytes: 16592
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <sstream>
#include <vector>
#include <set>
#include <stack>
#include <map>
#include <cmath>
#include <queue>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
typedef unsigned long long ll;

struct edge{
	int to;
	int cost;
};

typedef vector<vector<struct edge>> AdjList;
AdjList graph;
typedef pair<int,int> P;
const int INF = 1e9;
vector<int> dist;
vector<int> prever;

void dijkstra(int n,int s){
	dist = vector<int>(n,INF);
	prever = vector<int>(n-1);
	dist[s] = 0;
	priority_queue<P,vector<P>,greater<P>> que;
	que.push(P(0,s));
	while(!que.empty()){
		P p = que.top();
		que.pop();
		int v = p.second;
		if( dist[v] < p.first){
			continue;
		}
		for(int i = 0; i < graph[v].size(); i++){
			struct edge e = graph[v][i];
			if( dist[e.to] > dist[v] + e.cost){
				dist[e.to] = dist[v] + e.cost;
				//prever[e.to] = v;
				que.push(P(dist[e.to],e.to));
			}
		}
	}
}


int main()
{
	int V,E,r;
	cin>>V>>E>>r;
	graph = vector<vector<edge>>(V);
	for(int i = 0; i < E; i++){
		int s,t,d;
		cin>>s>>t>>d;
		edge e;
		e.to = t;
		e.cost = d;
		graph[s].push_back(e);
	}
	dijkstra(V,r);
	for(int i = 0; i < V; i++){
		if(dist[i] == INF){
			cout<<"INF"<<endl;
		}else{
			cout<<dist[i]<<endl;
		}
	}
	return 0;
}




Measured memory_bytes: 13468
import bisect
N = int(input())
A = list(map(int, input().split()))

A.sort()
i = A[-1]
middle = i/2
j_right = bisect.bisect_right(A, middle)
left = A[j_right - 1]
right = A[j_right]
if abs(middle - left) <= abs(middle - right):
    j = left
else:
    j = right
print(i, j)

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




int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
  ll a,b,c,k,n,m,temp,count=0,ans=0,i;
  string s;
  cin>>n>>m;
  ll arr[n];
for(i=0;i<n;i++)
{
  cin>>arr[i];
  count+=arr[i];
}
double temp1=(double)(count)/(4*m);

for(i=0;i<n;i++)
{
  if(arr[i]>=temp1)ans++;
}

if(ans<m)cout<<"No"<<endl;
else cout<<"Yes"<<endl;
return 0;
}


Measured memory_bytes: 256
class UnionFind():
    # 作りたい要素数nで初期化
    # 使用するインスタンス変数の初期化
    def __init__(self, n):
        self.n = n
        # root[x]<0ならそのノードが根かつその値が木の要素数
        # rootノードでその木の要素数を記録する
        self.root = [-1]*(n+1)
        # 木をくっつける時にアンバランスにならないように調整する
        self.rnk = [0]*(n+1)
 
    # ノードxのrootノードを見つける
    def Find_Root(self, x):
        if(self.root[x] < 0):
            return x
        else:
            # ここで代入しておくことで、後の繰り返しを避ける
            self.root[x] = self.Find_Root(self.root[x])
            return self.root[x]
    # 木の併合、入力は併合したい各ノード
    def Unite(self, x, y):
        # 入力ノードのrootノードを見つける
        x = self.Find_Root(x)
        y = self.Find_Root(y)
        # すでに同じ木に属していた場合
        if(x == y):
            return 
        # 違う木に属していた場合rnkを見てくっつける方を決める
        elif(self.rnk[x] > self.rnk[y]):
            self.root[x] += self.root[y]
            self.root[y] = x
 
        else:
            self.root[y] += self.root[x]
            self.root[x] = y
            # rnkが同じ（深さに差がない場合）は1増やす
            if(self.rnk[x] == self.rnk[y]):
                self.rnk[y] += 1
    # xとyが同じグループに属するか判断
    def isSameGroup(self, x, y):
        return self.Find_Root(x) == self.Find_Root(y)
 
    # ノードxが属する木のサイズを返す
    def Count(self, x):
        return -self.root[self.Find_Root(x)]
        
n=int(input())
xlist=[]
ylist=[]
rlist=[]
for i in range(n):
  x,y=map(int,input().split())
  xlist.append([x,i])
  ylist.append([y,i])
xlist=sorted(xlist,key=lambda x:x[0])
ylist=sorted(ylist,key=lambda x:x[0])
for i in range(1,n):
  cost=xlist[i][0]-xlist[i-1][0]
  rlist.append([cost,xlist[i][1],xlist[i-1][1]])
  cost=ylist[i][0]-ylist[i-1][0]
  rlist.append([cost,ylist[i][1],ylist[i-1][1]])
rlist=sorted(rlist,key=lambda x:x[0])
cost=0
t=UnionFind(n)
for c,p1,p2 in rlist:
  if t.isSameGroup(p1,p2):
    continue
  else:
    cost+=c
    t.Unite(p1,p2)
print(cost)

Measured memory_bytes: 124672
N,X=map(int,input().split())
x=list(map(int,input().split()))
x.append(X)
x=sorted(x)
dif=[0]*(len(x)-1)
for i in range(len(x)-1):
  dif[i]=x[i+1]-x[i]

def gcd(a,b):
  if b>a:
    a,b=b,a
  while True:
    if a%b==0:
      return b
    else:
      a,b=b,a%b

ans=dif[0]
for i in range(1,len(dif)):
  ans=gcd(ans,dif[i])

print(ans)

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

const int LIMIT = 10000000;

char in[LIMIT], *p = in;

__inline int nextInt(void) {
		
	register int res = 0;
	
	while (*p < '0' || *p > '9')p++;
	
	while (*p >= '0' && *p <= '9')
		res = res * 10 + *p++ - '0';
		
	return res;
		
}

int max(int x, int y) {
	return x > y ? x : y;	
}

int min(int x, int y) {
	return x < y ? x : y;	
}

const int N = 100005;
const int INIT = 2147483647;

int n, m;

struct Node {
	
	int lt, rt, minimum;
	
}tree[N << 2];

void buildTree(int p, int l, int r) {
	
	tree[p].lt = l;
	tree[p].rt = r;
	tree[p].minimum = INIT;
	
	if (l == r)return;
	
	int mid = (l + r) >> 1;
	
	buildTree(p << 1, l, mid);
	buildTree(p << 1 | 1, mid + 1, r);
	
	return;

}

int query(int p, int l, int r) {
	
	if (tree[p].lt == l && tree[p].rt == r)
		return tree[p].minimum;
		
	int mid = (tree[p].lt + tree[p].rt) >> 1;
	
	if (r <= mid)
		return query(p << 1, l, r);
	if (l > mid)
		return query(p << 1 | 1, l, r);
	return min(
		query(p << 1, l, mid),
		query(p << 1 | 1, mid + 1, r)
	);
	
}

void change(int p, int x, int y) {
	
	if (tree[p].lt == tree[p].rt) {
		tree[p].minimum = y;
		return;
	}
	
	int mid = (tree[p].lt + tree[p].rt) >> 1;
	
	if (x <= mid)
		change(p << 1, x, y);
	else
		change(p << 1 | 1, x, y);
		
	tree[p].minimum = min(
		tree[p << 1].minimum,
		tree[p << 1 | 1].minimum
	);
	
	return;
	
}

signed main(void) {

	fread(p, 1, LIMIT, stdin);
	
	n = nextInt();
	m = nextInt();
	
	buildTree(1, 1, n);
	
	for (register int i = 1; i <= m; ++i) {
		
		int k = nextInt();
		int x = nextInt();
		int y = nextInt();
		
		if (k)
			printf("%d\n", query(1, x + 1, y + 1));
		else
			change(1, x + 1, y);
		
	}
	
	return 0;
	
}

Measured memory_bytes: 7232
x,y,z,w = input()

l = []
l.append(x)
l.append(y)
l.append(z)
l.append(w)
new_l = sorted(l)

if new_l[0] == new_l[1] and new_l[1] != new_l[2] and new_l[2] == new_l[3]:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9064
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		long[] dp = new long[2];
		dp[0] = 1;
		for(int i=0;i<N;i++){
			long[] nxt = new long[2];
			nxt[0] += dp[0];
			nxt[1] += dp[1];
			nxt[(0 + A[i])%2] += dp[0];
			nxt[(1 + A[i])%2] += dp[1];
			dp  = nxt;
		}
		Console.WriteLine(dp[P]);
		
		
	}
	int N,P;
	int[] A;
	public Sol(){
		var d = ria();
		N = d[0]; P = d[1];
		A = ria();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


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

const int INF_32 = 1LL << 30;
const int64_t INF_64 = 1LL << 60;

typedef long long ll;

ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }

ll LCM(ll x, ll y)
{
    return x * y / GCD(x, y);
}

typedef pair<int, int> P;

//
int dp[3010][3010];
// dp[i+1][j+1]は，sのi文字目まで，tのj文字目までによって得られるLCSで最長のものの長さ

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

    for (int i = 0; i < s.size(); i++) {
        for (int j = 0; j < t.size(); j++) {
            if (s.at(i) == t.at(j)) {
                dp[i + 1][j + 1] = dp[i][j] + 1;
            } else {
                if (dp[i][j + 1] > dp[i + 1][j]) {
                    dp[i + 1][j + 1] = dp[i][j + 1];
                } else {
                    dp[i + 1][j + 1] = dp[i + 1][j];
                }
            }
        }
    }

    // 答えはdp[s.size()][t.size()]

    // int s_size = s.size();
    // int t_size = t.size();

    // int i = s_size;
    // int j = t_size;
    // string ans;
    // while (i >= 1 && j >= 1) {
    //     if (dp[i][j] == dp[i - 1][j - 1] + 1) {
    //         ans = s.at(i - 1) + ans;
    //         i--, j--;
    //     } else if (dp[i][j] == dp[i - 1][j]) {
    //         i--;
    //     } else {
    //         j--;
    //     }
    // }

    // cout << ans << endl;

    // 復元
    string res = "";
    int i = (int)s.size(), j = (int)t.size();

    while (i > 0 && j > 0) {
        // (i-1, j) -> (i, j)と更新されていた場合
        if (dp[i][j] == dp[i - 1][j])
            --i; // dpの遷移をたどる
        // (i, j-1) -> (i, j)と更新されていた場合
        else if (dp[i][j] == dp[i][j - 1])
            --j; // dpの遷移をたどる
        // (i-1,j-1) -> (i,j)と更新されていた場合
        else {
            res = s[i - 1] + res; // s[i-1] == t[j-1]なのでどっちでもよい
            --i, --j; // dpの遷移をたどる
        }
    }

    cout << res << endl;
}


Measured memory_bytes: 35712
#include<bits/stdc++.h>
using namespace std;
const long long INF = 1e7 + 1;
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
typedef long long int ll;
typedef vector<ll> vi;
typedef vector < pair<ll, ll > > vp;
typedef vector <string> vs;
typedef vector <char> vc;
typedef list <ll> lst;

ll n, m, k, ans = 0, sum = 0, cnt = 0;
string s;
char c;

#define Endl endl

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


int main(void)
{
	ll sx, sy, tx, ty;
	cin >> sx >> sy >> tx >> ty;

	const ll dx = tx - sx, dy = ty - sy;

	cout << string(dy, 'U') << string(dx, 'R');

	cout << string(dy, 'D') << string(dx, 'L');

	cout << 'L' << string(dy + 1, 'U') << string(dx + 1, 'R') << 'D';

	cout << 'R' << string(dy + 1, 'D') << string(dx + 1, 'L') << 'U';

	cout << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <ctime>
#include <sstream>
#include <algorithm>
#include <functional>
#include <numeric>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>

using namespace std;

#define f first
#define s second
#define pb push_back
#define mp make_pair
#define ll long long
#define pii pair < int, int >
#define pll pair < long long, long long>
#define ull unsigned long long
#define y1 stupid_cmath
#define left stupid_left
#define right stupid_right
#define vi vector <int>
#define sz(a) (int)a.size()
#define forit(it, s) for(__typeof(s.begin()) it = s.begin(); it != s.end(); it++)
#define all(a) a.begin(), a.end()
#define sqr(x) ((x) * (x))

const int inf = (int)1e9;
const int mod = inf + 7;
const double eps = 1e-9;
const double pi = acos(-1.0);

ll read_long() {
    ll ans = 0;
    char c;
    bool started = false;
    bool is_negative = false;
    while (true) {
        c = getchar();
        if ((c < '0' || c > '9') && c != '-' && !started) continue;
        if ((c < '0' || c > '9') && c != '-' && started) break;
        if (started) {
            ans = ans * 10;
        }
        started = true;
        if (c == '-') is_negative = true;
        else ans += c - '0';
    }
    if (is_negative) ans *= -1;
    return ans;
}

int n, a[100100];
ll S = 0;
int d[100100];

int main(){

    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        scanf("%d", a + i);
        S += a[i];
    }
    for (int i = 0; i < n; i++) {
        d[i] = (a[(i + 1) % n] - a[i]);
    }

    // -1 -1 -1 -1 (n-1)
    // d[i] + x * (n - 1) - (k-x)
    // d[i] + x * (n - 1) + x - k = 0
    // x = (k - d[i]) / n

    if (n == 1) {
        printf("YES\n");
        return 0;
    }

    if (S % (n * 1ll * (n + 1) / 2)) {
        printf("NO\n");
        return 0;
    }

    ll k = S / (n * 1ll * (n + 1) / 2);
    ll rest = k;
    for (int i = 0; i < n; i++) {
        if ((k - d[i]) % n) {
            printf("NO\n");
            return 0;
        }
        ll x = (k - d[i]) / n;
        if (x < 0 || x > k) {
            printf("NO\n");
            return 0;
        }
        rest -= x;
    }

    if (rest == 0) printf("YES\n");
    else printf("NO\n");

    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
using namespace std;
int main() 
{
	int n,l[100001],r[100001],ans=0,i;
	cin >> n;

	for(i=0;i<n;i++){
		cin >> l[i] >> r[i];
		ans += r[i]-l[i]+1;
	} 

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

Measured memory_bytes: 764
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <stack>
#include <queue>
using namespace std;
using ll = long long;
int main(){
    int A, B;
    cin >> A >> B;
    cout << max({A+B, A-B, A*B}) << endl;
    return 0;
}

Measured memory_bytes: 256
from collections import defaultdict
from itertools import permutations
N, M = [int(i) for i in input().split()]

dd = defaultdict(list)
ans = 0
for _ in range(M):
    po = [int(i) for i in input().split()]
    dd[po[0]].append(po[1])
    dd[po[1]].append(po[0])
for route in permutations(range(1,N+1)):
    can = True
    if route[0] != 1:
        continue
    for i in range(N-1):
        if route[i+1] not in dd[route[i]]:
            can = False
            break
    if can:
        ans += 1

print(ans)

Measured memory_bytes: 3316
#include<string>
#include<iostream>

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

string LCS(const string &s,const string &t){
	const int LMAX=300;
	int m=s.length(),n=t.length();
	static int dp[LMAX+1][LMAX+1],from[LMAX+1][LMAX+1];

	rep(i,m+1) dp[i][0]=0, from[i][0]=-1;
	rep(j,n+1) dp[0][j]=0, from[0][j]=-1;

	rep(i,m) rep(j,n) {
		if(s[i]==t[j]){
			dp[i+1][j+1]=dp[i][j]+1;
			from[i+1][j+1]=2;
		}
		else{
			if(dp[i][j+1]<dp[i+1][j]){
				dp[i+1][j+1]=dp[i+1][j];
				from[i+1][j+1]=1;
			}
			else{
				dp[i+1][j+1]=dp[i][j+1];
				from[i+1][j+1]=0;
			}
		}
	}

	int idx=dp[m][n];
	string ans(idx,'@');
	for(int i=m,j=n;~from[i][j];){
		switch(from[i][j]){
			case 0: i--; break;
			case 1: j--; break;
			case 2: i--; j--; idx--; ans[idx]=s[i]; break;
		}
	}

	return ans;
}

int main(){
	for(string s;cin>>s,s!="#END";){
		int len=s.length();
		string ans;
		for(int i=1;i<len;i++){
			if(min(i,len-i)<=ans.length()) break;
			string tmp=LCS(s.substr(0,i),s.substr(i));
			if(ans.length()<tmp.length()) ans=tmp;
		}
		cout<<ans<<endl;
	}

	return 0;
}

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

int N,M;

bitset<40> G[44];
int B[44];
int idx[44];

int checkstr( map<string,int> &mp, const string &s,int &cnt ){
  if( mp.count(s) == 0 )
    mp[s] = cnt++;
  return mp[s];
}

bitset<40> ok;
bitset<40> used;
bitset<40> sele;
bool check(int id){
  int cnt = 0;
  for(int i=0;i<id;i++){
    if( !ok[idx[i]] && !used[idx[i]] && !sele[idx[i]] ) cnt++;
  }
  //cout << id << " "<< cnt << " "<< M << endl;
  //return cnt > M;
  return false;
}
int solve(int num){
  int id = idx[num];
  if( num == N ) return 0;
  if( sele[id] || ok[id] || used[id] ) return solve(num+1);
  //if( check(num) ) return 0;
  
  bitset<40> tmp = used;
  sele[id] = true;
  used |= G[id];
  int res = solve(num+1)+B[id];

  //cout << "view" << endl;
  //cout << ok << endl;
  //cout << used << endl;
  //cout << sele << endl;
  //for(int i=0;i<N;i++) { cout << ok[i] << " " << used[i] << " " << sele[i] << 
  //cout << id << " " << res << endl;

  used = tmp;
  sele[id] = false;
  
  int sum = 0;
  //for(int i=id;i<N;i++) if( !sele[i] && !ok[i] && !used[i] ) sum += B[i];
  for(int i=num+1;i<N;i++) if( !sele[idx[i]] && !ok[idx[i]] && !used[idx[i]] ) sum += B[idx[i]];


  if( sum > res )
    res = max( res,solve(num+1) );
  return res;
}

int main(){
  while( cin >> N && N ){
    int cnt = 0;
    map<string,int> mp;    
    vector<pair<int,int>> point;
    for(int i=0;i<N;i++){
      string s; cin >> s;
      int id = checkstr( mp, s, cnt );
      int c; 
      cin >> B[id] >> c;      
      G[id]=0;
      point.push_back( make_pair( B[id], id ) );
      assert( id < N );
      for(int j=0;j<c;j++){
        string d; cin >> d;
        int nd = checkstr( mp, d, cnt );
        G[id][nd] = true;
      }
    }

    sort( point.rbegin(), point.rend() );
    for(int i=0;i<(int)point.size();i++)
      idx[i] = point[i].second;

    int res = 0;
    for(int i=0;i<N;i++){
      ok[i] = false;
      if( G[i]==bitset<40>(0) ){
        ok[i] = true;
        res += B[i];
      }
    }
    used = bitset<40>(0);
    sele = bitset<40>(0);
    if( G[0]!=bitset<40>(0) ) res += B[0];
    sele[0] = true;
    used |= G[0];
    res += solve(0);
    cout << res << endl;
  }
}

Measured memory_bytes: 3208
gets
while gets
    m = 0
    can0 = $_.split.map(&:to_i)
    (0 .. can0.min).each do |x|
        can1 = can0.map {|k| k - x}
        (0 .. can1[0]/3).each do |y|
            can2 = can1.dup
            can2[0] -= 3 * y
            z = [can2[0]/2, can2[1]].min
            m = x + y + z if x + y + z > m
        end
    end
    p m
end

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

int n, k, h[100119], dp[100119];
int main() {
	cin >> n >> k;
	for (int i = 1; i <= n; i++)
		cin >> h[i], dp[i] = 1000000000;
	dp[1] = 0;
	for (int i = 1; i <= n; i++)
		for(int j = 1; j <= k; j++)
		dp[i + j] = min(dp[i + j], dp[i] + abs(h[i] - h[i + j]));
	cout << dp[n];
	return 0;
}


Measured memory_bytes: 1024
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <functional>
#include <cmath>
#include <iostream>
#define SIZE 25
#define MX (1<<21)+2

using namespace std;
typedef long long int ll;
typedef pair <int,int> P;
typedef pair <int,string> PS;

vector < vector <int> > cnt[SIZE];
P nxt[SIZE][MX][2];
char str[MX];
int N,K;

int main(){
  cin >> N;
  
  int res = N ;
  for ( int i =0; i <= N ; i ++)
  {
    int cc =0;
    int t = i ;
    while (t >0){
      cc += t %6;
      t /=6;
    }
    t=N - i ;
    while (t >0){
      cc += t %9;
      t /=9;
    }
    if ( res > cc ) res = cc ;
  }
  
  cout << res << endl;
  return 0;
}





Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
  int N;
  cin >> N;

  vector<int> vnNum(N);

  for (int i = 0; i < N; i++)
    cin >> vnNum[i];

  int nCount = -1;
  bool bLoop = true;

  while (bLoop)
  {
    nCount++;
    for (int& num : vnNum)
    {
      if (num % 2 != 0)
      {
        bLoop = false;
        break;
      }
      else
        num /= 2;
    }
  }

  cout << nCount << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
#include <functional>
#define inf 1000000000
using namespace std;
typedef long long ll;
const int MAXN=1e9+10;
const int MAX=1e3+10;
const int MOD=1e9+7;
const double eps=1e-6;



int main(){
    #ifdef ONLINE_JUDGE
    #else

    //freopen("output.txt","w",stdout);
    #endif

    int a,b,c,x,y;
    cin>>a>>b>>c>>x>>y;
    int flag=0;
    if((a+b)<c*2)   flag=-1;
    else    flag=1;
    int temp=min(x,y);
    int ans=0,ans1;
    ans1=min(max(x,y)*2*c,a*x+b*y);
    if(flag==-1)
        ans+=(a+b)*temp;
    else
        ans+=c*2*temp;
    x-=temp;y-=temp;
    ans+=x*a;
    ans+=y*b;
    cout<<min(ans,ans1)<<endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int k = sc.nextInt();
		int x = sc.nextInt();
		sc.close();

		int l = x - k + 1;
		int r = x + k;
		StringBuilder sb = new StringBuilder();
		for (int i = l; i < r; i++) {
			sb.append(i).append(' ');
		}
		sb.deleteCharAt(sb.length() - 1);
		System.out.println(sb.toString());
	}
}


Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxx = 1e5 + 7;
const int Inf = 1 << 30;
const ll INF = 1ll << 60;
ll a, b;
ll ans = 1ll; //1一定满足要求, 初始化自身为一个

int main() {
	cin >> a >> b;
	ll x = __gcd(a, b);
	for(ll i = 2; i * i <= x; i++) {
		if(x % i == 0) ans++;
		while(x % i == 0) { x /= i; }
		if(x == 1) break;
	}
	if(x > 1) ans++;
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
	int x,p; 
	scanf("%d",&x);
	scanf("%d",&p);
	int a[100]; 
	int count=0;
	do{
		a[count++]=x%p;
		x=x/p;
	}while(x!=0);
	
		printf("%d",count);

}


Measured memory_bytes: 128
N = int(input()) #文字列の長さ
S = input() #受け取る文字列
li = list(S) #一文字づつ配列に分割
judge = True
n = int(N/2)
if N%2==1:
  judge = False
else:
  for number in range(n):
    if not li[number]==li[number+n]:
      judge = False
if judge:
  print('Yes')
else:
  print('No')

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

int main(){
    int n,c;
    cin >> n >> c;
    n++;
    int sum = 0;
    REP(i,c){
        int k;
        cin >> k;
        sum += k;
    }
    cout << (sum+n-1)/n << endl;
}


Measured memory_bytes: 3132
#include <iostream>
#include <vector>
#include <math.h>

using namespace std;

int lcm(vector<int> ns) {
	int m = 1;
	for (int i = 2; ns.size() != 0; ++i) {
		int count_max = 0;
		for (vector<int>::iterator it = ns.begin(); it != ns.end();) {
			int count = 0;
			while (*it % i == 0) {
				++count;
				*it /= i;
			}
			if (count_max < count) count_max = count;

			if (*it == 1) ns.erase(it);
			else ++it;
		}
		m *= pow(i, count_max);
	}
	return m;
}

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

	vector<int> ns;
	while (n--) {
		int a;
		cin >> a;
		ns.push_back(a);
	}
	cout << lcm(ns) << endl;
	return 0;
}

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

int a[105], b[105];

int main(){
	int n, m, x, y; cin >> n >> m >> x >> y;
	for(int i = 0; i < n; ++i) cin >> a[i];
	for(int i = 0; i < m; ++i) cin >> b[i];
	
	bool ok1 = 0;
	for(int z = x + 1; z <= y; ++z){
		bool ok2 = 1;
		for(int i = 0; i < n; ++i) if(a[i] >= z){
			ok2 = 0;
			break;
		}
		
		if(ok2){
			for(int i = 0; i < m; ++i) if(b[i] < z){
				ok2 = 0;
				break;
			}
		}
		if(ok2){
			ok1 = 1;
			break;
		}
	}
	cout << (ok1 ? "No War" : "War") << "\n";
	return 0;
}

Measured memory_bytes: 256
from itertools import accumulate
import sys
input = sys.stdin.readline

N, C = map(int, input().split())
x = [0] * N
v = [0] * N
for i in range(N):
    x[i], v[i] = map(int, input().split())
clockwise = list(accumulate(v))
counterclockwise = list(accumulate(v[::-1]))[::-1]
for i in range(N):
    clockwise[i] -= x[i]
    counterclockwise[i] -= C-x[i]
clockwise_max = [0] * N
for i in range(1, N):
    clockwise_max[i] = max(clockwise_max[i-1], clockwise[i-1])
counterclockwise_max = [0] * N
for i in range(N-1)[::-1]:
    counterclockwise_max[i] = max(counterclockwise_max[i+1], counterclockwise[i+1])
ans = 0
for i in range(N):
    ans = max(ans, clockwise[i])
    ans = max(ans, clockwise[i]-x[i]+counterclockwise_max[i])
for i in range(N)[::-1]:
    ans = max(ans, counterclockwise[i])
    ans = max(ans, counterclockwise[i]-(C-x[i])+clockwise_max[i])
print(ans)


Measured memory_bytes: 22124
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;

public class Equation
{
	public static void Main(string[] args)
	{
		BindingList<string> outputList = new BindingList<string>();	
		do 
		{
			string read = Console.ReadLine();
			if (string.IsNullOrEmpty(read))
			{
				break;
			}
			string[] line = read.Split(' ');
			decimal a = int.Parse(line[0]);
			decimal b = int.Parse(line[1]);
			decimal c = int.Parse(line[2]);
			decimal d = int.Parse(line[3]);
			decimal e = int.Parse(line[4]);
			decimal f = int.Parse(line[5]);
			decimal y = Math.Round((a*f-c*d)/(a*e-b*d), 3);
			decimal x = Math.Round((c-b*y)/a, 3);
			outputList.Add(x + " " + y);
		} while(true);
		foreach (string output in outputList)
		{
			Console.WriteLine(output);
		}
	}
}

Measured memory_bytes: 6676
from sys import stdin
import sys
import math
from functools import reduce
import functools
import itertools
from collections import deque,Counter,defaultdict
from operator import mul
import copy
# ! /usr/bin/env python
# -*- coding: utf-8 -*-
import heapq
sys.setrecursionlimit(10**6)
INF =  float("inf")
import bisect

N = int(input())
v = list(map(int, input().split()))

e = defaultdict(int)
o = defaultdict(int)

e[INF] = 0
o[INF] = 0

ae = (N+1) // 2
ao = N - ae

for i in range(N):
    if i % 2 == 0:
        e[v[i]] += 1
    else:
        o[v[i]] += 1

e_list = sorted(e.items(), key=lambda x:x[1], reverse=True)
o_list = sorted(o.items(), key=lambda x:x[1], reverse=True)

if e_list[0][0] != o_list[0][0]:
    print(N-e_list[0][1]-o_list[0][1])
else:
    print(min(N-e_list[0][1]-o_list[1][1], N-e_list[1][1]-o_list[0][1]))


Measured memory_bytes: 108076
n,m,l=map(int,input().split())
a=[[]for i in range(n)]
b=[[]for i in range(m)]
c=[[0]*l for i in range(n)]
for i in range(n):
    a[i]=list(map(int,input().split()))
for i in range(m):
    b[i]=list(map(int,input().split()))
for i in range(n):
    for j in range(l):
        for k in range(m):
            c[i][j]+=a[i][k]*b[k][j]
for e in c:
    print(*e)


Measured memory_bytes: 7064
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	scanInit()

	n := nextInt()
	m := nextInt()
	r := map[int]int{}

	for i := 0; i < m; i++ {
		r[nextInt()]++
		r[nextInt()]++
	}

	for i := 1; i <= n; i++ {
		fmt.Println(r[i])
	}
}

// ---- readfunc
func scanInit() {
	const cap = 200 * 1024 // Default=64
	var buf = make([]byte, cap)
	sc.Buffer(buf, cap)
	sc.Split(bufio.ScanWords)
	return
}
func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}
func nextStr() string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 1808
#include<iostream>
using namespace std;
int main()
{
	int house[4][3][10] = { 0 };
	int n;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		int b, f, r, v;
		cin >> b >> f >> r >> v;
		house[b - 1][f - 1][r - 1] += v;
	}
	for (int i = 0; i < 4; i++)
	{
		for (int j = 0; j < 3; j++)
		{
			for (int k = 0; k < 10; k++)
				cout << " " << house[i][j][k];
			cout << endl;
		}
		if (i < 3)
		{
			for (int m = 0; m < 20; m++)
				cout << '#';
			cout << endl;
		}
	}
}


Measured memory_bytes: 3044
#include <cstdio>
#include <iostream>
#include <algorithm>

using namespace std;
const int MAXN = 2e6 + 5;


char ans[MAXN];
//int main() {
//	long long n;
//	while (~scanf("%lld", &n)) {
//		printf("%lld\n", n * (n + 1) / 2); 
//	}
//	return 0;
//}

int main() {
	long long n; scanf("%lld", &n); int l = 0;
	while (n) {n--;
		ans[++l] = n % 26 + 'a'; n /= 26; 
	}
	for (int i = l; i >= 1; i--) putchar(ans[i]);
	return 0;
}

Measured memory_bytes: 3160
alphabet = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W','X', 'Y', 'Z']

num = int(input())
letter = list(input())
for i in range(len(letter)):
    n = alphabet.index(letter[i])
    o = n + num
    if o > 25:
        letter[i] = alphabet[o - 26]
    else:
        letter[i] = alphabet[o]
print(''.join(letter))

Measured memory_bytes: 3064
# review
x1, y1, x2, y2 = map(int, input().split())
dx, dy = x2-x1, y2-y1 # bector
x3 = x2 - dy
y3 = y2 + dx
x4 = x3 - dx
y4 = y3 - dy
print(x3,y3,x4,y4)

Measured memory_bytes: 3060
/*

                              Jai Shree Krishna !!
                                 Radhe Radhe !!
                                 
             उद्यमेन हि सिद्ध्यन्ति कार्याणि न मनोरथैः। नहि सुप्तस्य सिंहस्य मुखे प्रविशन्ति मृगाः।।
             
*/
   
   
#include <bits/stdc++.h>
using namespace std;
 
#define int long long
typedef long long ll;
#define loop(i,n)  for(int i=0;i<n;i++)
#define read(a) int a; cin >>a;
#define readarr(a,n) int a[n] ; for(int i=0;i<n;i++) cin >> a[i];
#define readmat(a,n,m) int a[n][m]; for(int i=0;i<n;i++) for(int j=0;j<m;j++) cin >> a[i][j];
#define pb push_back
#define ff first
#define ss second
#define vi vector<int>
#define pi pair<int,int>
#define vvi vector<vector<int>>
#define sti set<int>
#define vpi vector<pair<int,int>>
#define print(a,n) for(int i=0;i<n;i++) cout<<a[i]<<" "; cout<<endl;
#define printmat(a,n,m) for(int i=0;i<n;i++) {for(int j=0;j<m;j++) cout<<a[i][j]<<" "; cout<<endl;}
#define fast ios_base::sync_with_stdio(false);  cin.tie(NULL);
#define endl "\n"
#define mp make_pair
#define ins insert
#define rep(i,s,e) int i; for(int i=s;i<=e;i++)
#define repd(i,s,e) int i; for(int i=e;i>=s;i--)
#define vb vector<bool>
#define read2(n,m) int n,m; cin >> n >> m;
#define range(v) v.begin(),v.end()
#define sortd(v) sort(v.begin(),v.end(),greater<int>())
#define sorti(v) sort(v.begin(),v.end())

const ll inf = 1e18;
const ll mod = 1e9 + 7;
 
 


signed main()
{
 
    fast;
    read(n);
    string s,t;
    cin >> s >> t;
    loop(i,n) cout<<s[i]<<t[i];
    cout<<endl;
    return 0;
}

/* Pooja Yadav */

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
#ABC139C
import sys
#sys.setrecursionlimit(100000)


n=int(input())
tmp = input().split()
h = list(map(lambda a: int(a), tmp))

maxh=0
count=0
for i in range(0,n-1):
	if(h[i]>=h[i+1]):
		count+=1
		maxh=max(maxh,count)
	else:
		count=0

print(maxh)



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

int main() {
	string g; int y, m, d;
	while (cin >> g && g != "#") {
		cin >> y >> m >> d;
		if (y > 31 || (y == 31 && m > 4)) {
			cout << "? " << y - 30 << " " << m << " " << d << endl;
		}
		else cout << g << " " << y << " " << m << " " << d << endl;
	}
	return 0;
}


Measured memory_bytes: 3176
from itertools import permutations
from math import sqrt


def dis(i, j):
    ret = float((i[0] - j[0]) ** 2 + (i[1] - j[1]) ** 2)
    return sqrt(ret)


n = int(input())
xy = [list(map(float, input().split())) for i in range(n)]

p = list(permutations(list(range(n))))
sums = 0

for i in p:
    for j in range(len(i) - 1):
        sums += dis(xy[i[j]], xy[i[j + 1]])

print(sums / len(p))

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

#define int long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x) cout << #x << " = " << (x) << endl;
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define SP << " " <<

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
typedef vector<int> vec;
typedef vector<P> pvec;
typedef vector<vector<int>> vvec;
typedef vector<vector<P>> pvvec;
typedef priority_queue<int> PQI;
typedef priority_queue<P> PQP;
typedef priority_queue<int,vector<int>,greater<int>> PQIG;
typedef priority_queue<P,vector<P>,greater<P>> PQPG;

const vector<int> DX = {0, -1, 0, 1, 1, 1, -1, -1};
const vector<int> DY = {1, 0, -1, 0, 1, -1, 1, -1};
constexpr int MOD = (1000000007);
// const int MOD = (998244353);
// const int INF = (1 << 30); // 1073741824
const ll INF = (1LL << 60); // 1152921504606846976
const double PI = (3.141592653589794);
const double EPS = (0.0000000001); // 10^(-10)

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}
template<class T> inline T ceil(T a, T b) {return T((a + b - 1) / b);}
template<class T> inline T round(T a, T b) {return T(a / b);}
template< typename T1, typename T2 > istream &operator>>(istream &is, pair< T1, T2 > &p) { is >> p.first >> p.second; return is; }
template <class T> inline void out(T &a) { bool flag=true; for(auto&x:a){if(flag) {flag=false;} else{ cout << ' '; } cout<<x; } cout << endl; }



//----------------------------------------------------------------
int nmax=200000; // 2*(10^5)
vvec G(nmax);





void solve4ts()
{
    
    string s;
    cin>>s;
    int cnt=0;

    int n=s.size();
    rep(i,n){
        if(s[i]=='?') s[i]='D';
        if(s[i]=='D') cnt++;
    }
    rep(i,n-1){
        if(s[i]=='P'&s[i+1]=='D') cnt++;
    }
    cout<<s<<endl;
}
//-----------------------------------------------------------------

signed main(){ ios::sync_with_stdio(false); cin.tie(0); cout << fixed << setprecision(15);
    int repeat = 1;
    // cin >> repeat;
    while(repeat--) solve4ts();
}

Measured memory_bytes: 8316
#include <iostream>
#include <vector>
#include <queue>
#include <initializer_list>
#include <memory>
using namespace std;
#define INF 1000001
int main()
{
int n,x,y;

cin>>n>>x>>y;
x--;y--;
vector<int>ans(n);
for (int sv=0;sv<n;sv++)
{
vector <int> dist(n,INF);
queue <int>q;


auto push= [&](int v,int d)
{
if(dist[v]!=INF)return;
dist[v]=d;
q.push(v);
};

push(sv,0);
while(!q.empty())
{
int v =q.front();q.pop();
int d=dist[v];
if(v-1>=0)push(v-1,d+1);
if(v+1<n)push(v+1,d+1);
if(v==x)push(y,d+1);
if(v==y)push(x,d+1);
}

for (int i=0;i<n;i++)
ans[dist[i]]++;

}

for (int i=0;i<n;i++)
ans[i]/=2;

for (int i=1;i<n;i++)
cout <<ans[i]<<endl;

return 0;
}

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

// 定義
typedef long long         ll;
typedef pair<ll, ll>      P;
#define ALL(x)            (x).begin(),(x).end()
#define REP(i, n)         for(ll i = 0 ; i < (ll)n ; ++i)
#define REPN(i, m, n)     for(ll i = m ; i < (ll)n ; ++i)
#define VL                vector<ll>
#define VVL               vector<vector<ll>>
#define VVVL              vector<vector<vector<ll>>>
#define VC                vector<char>
#define VVC               vector<vector<char>>
#define INF               (ll)2e9
#define INF_LL            1LL<<60
//#define MOD             998244353
#define MOD               1000000007

ll Ceil(ll val, ll div)   { return (val + div - 1) / div; }
ll CeilN(ll val, ll div)  { return Ceil(val, div) * div; }
ll FloorN(ll x, ll n)     { return (x - x % n); }
bool IsOdd(ll x)          { return ((x & 1) == 1); }
bool IsEven(ll x)         { return ((x & 1) == 0); }
template<class T> bool chmax(T& a, T b) { if (a <= b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T& a, T b) { if (a >= b) { a = b; return 1; } return 0; }

void Solve()
{
	ll N;
	cin >> N;
	VL x(N), y(N);
	VL sum1(N);
	VL sum2(N);
	REP(i, N) {
		cin >> x[i] >> y[i];
		sum1[i] = x[i] + y[i];
		sum2[i] = x[i] - y[i];
	}
	sort(ALL(sum1));
	sort(ALL(sum2));
	ll ans = max(sum1[N - 1] - sum1[0], sum2[N - 1] - sum2[0]);
	cout << ans << endl;
}

// メイン
int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Solve();
	return 0;
}


Measured memory_bytes: 9480
Option Strict On
Module Module1

    Sub Main()
        Dim l() As String = Split(Console.ReadLine())
        Dim A As Integer = Convert.ToInt32(l(0))
        Dim B As Integer = Convert.ToInt32(l(1))
        If A = B Then
            Console.WriteLine(A + B)
        ElseIf A > B Then
            Console.WriteLine(A + A - 1)
        Else : Console.WriteLine(B + B - 1)
        End If
        Console.ReadLine()
    End Sub

End Module

Measured memory_bytes: 11488
using System;
using System.Linq;

// 2 つの数の交換

public class ITP1_3_C
{
    public static void Main(string[] args)
    {
        //var exStdIn = new System.IO.StreamReader( "input.txt" );
        //System.Console.SetIn( exStdIn );

        while (true)
        {
            int[] input = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            if (input[0] == 0 && input[1] == 0)
            {
                break;
            }
            if (input[0] < input[1])
            {
                Console.WriteLine($"{input[0]} {input[1]}");
            }
            else
            {
                Console.WriteLine($"{input[1]} {input[0]}");
            }
        }
    }
}



Measured memory_bytes: 16320
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <unordered_set>
#include <cmath>
#include <queue>
#include <stdio.h>

using namespace std;
using ll = long long;
using ld = long double;
template <class T> using v = std::vector<T>;
template <class T> using vv = std::vector<std::vector<T>>;

#define REP(i, s, e) for (ll i = s; i < e; ++i)

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

    int a; cin >> a;
    string s; cin >> s;
    if(a >= 3200) cout << s << endl;
    else cout << "red" << endl;

    return 0;
}


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

ll N, A[200000], ruiseki[200000];

ll nibun1(ll x, ll y, ll sum){
	if(2*A[0] >= sum){
		return sum - A[0];
	}
	if(y-x == 1){
		if(sum - 2*ruiseki[x] < 2*ruiseki[y] - sum){
			return ruiseki[x];
		}else{
			return sum - ruiseki[y];
		}
	}
	ll med = (x+y)/2;
	if(2*ruiseki[med] == sum){
		return sum/2;
	}else if(2*ruiseki[med] > sum){
		return nibun1(x, med, sum);
	}else{
		return nibun1(med, y, sum);
	}
}

ll nibun2(ll x, ll y, ll sum){
	if(y-x == 1){
		if(2*ruiseki[N-1] - 2*ruiseki[x] - sum < sum - 2*ruiseki[N-1] + 2*ruiseki[y]){
			return sum - ruiseki[N-1] + ruiseki[x];
		}else{
			return ruiseki[N-1] - ruiseki[y];
		}
	}
	int med = (x+y)/2;
	if(2*ruiseki[N-1] - 2*ruiseki[med] == sum){
		return ruiseki[N-1] - ruiseki[med];
	}else if(2*ruiseki[N-1] - 2*ruiseki[med] > sum){
		return nibun2(med, y, sum);
	}else{
		return nibun2(x, med, sum);
	}
}

int main(){
	cin >> N;
	ll ans[N-3];
	for(int i=0; i<N; i++){
		cin >> A[i];
		if(i == 0){
			ruiseki[0] = A[0];
		}else{
			ruiseki[i] = ruiseki[i-1] + A[i];
		}
	}
	ll n = ruiseki[N-1];
	for(int i=1; i<N-2; i++){
		ll a = ruiseki[i];
		if(2*A[i+1] >= ruiseki[N-1] - ruiseki[i]){
			ans[i-1] = max(a - nibun1(0, i, a), A[i+1]) - min(nibun1(0, i, a), ruiseki[N-1] - ruiseki[i+1]);
		}else{
			ans[i-1] = max(a - nibun1(0, i, a), n - a - nibun2(i+1, N-1, n-a)) - min(nibun1(0, i, a), nibun2(i+1, N-1, n-a));
		}
	}
	sort(ans, ans+N-3);
	cout << ans[0] << endl;
	return 0;
}

Measured memory_bytes: 4992
/*********************************************JMD**********************************************/
//                                  |\  |     | |   |   /\                                   //
    //                              | \ |     | |---|  /--\                              //
        //                          |  \| |___| |   | /    \1999                     //
/*******************************************************************************************/
#include <bits/stdc++.h>
using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;

#define mp make_pair
#define pb push_back
#define pf push_front
#define ss second
#define ff first
#define mem(x,val) memset(x,val,sizeof(x))
#define forr(i,a,b) for(ll i=a;i<b;i++)
#define f(i,n) forr(i,0,n)
#define sz(x) ll((x).size())
#define all(x) ((x).begin(),(x).end())
#define asc(x) ((int)(x))
#define precision(x) cout<<fixed<<setprecision((x));

const ll mod=1e9 + 7;

/*******************************************************************************************/

void solve()
{
    ll a,b;
    cin>>a>>b;
  
  if((a+b)%2) cout<<"IMPOSSIBLE";
  else cout<<(a+b)/2;
    
    return;
}

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

    ll t=1;
    //cin>>t;
    clock_t launch=clock();

    while(t--)
    {
        solve();
    }

    clog<<((long double)(clock()-launch)/CLOCKS_PER_SEC)<<"\n";
}

Measured memory_bytes: 256
def add(dp, n, l):
    t = 0
    for v in range(1, len(l)):
        y = l[v]
        x = l[v-1]
        while t != y:
            dp[n][t] += y - 1 - x
            t += 1
        t += 1


H,W = [int(_) for _ in input().split()]
s = []
b = []
c = []
for _ in range(H):
    s.append(input())
for i in range(H):
    a = []
    a.append(0)
    for j in range(W):
        if s[i][j] == '#':
            a.append(j+1)
    a.append(W+1)
    b.append(a)
for j in range(W):
    a = []
    a.append(0)
    for i in range(H):
        if s[i][j] == '#':
            a.append(i+1)
    a.append(H+1)
    c.append(a)
dp = [[0 for _ in range(W+2)] for _ in range(H+2)]
dp2 = [[0 for _ in range(H+2)] for _ in range(W+2)]
for i in range(len(b)):
    add(dp, i+1, b[i])
for i in range(W+2):
    for j in range(H+2):
        dp2[i][j] = dp[j][i]
for i in range(len(c)):
    add(dp2, i+1, c[i])
ans = 0
for i in range(1, W+1):
    for j in range(1, H+1):
        ans = max(ans, dp2[i][j])
print(ans-1)



Measured memory_bytes: 183940
#include<iostream>
using namespace std;
int m,D[1401][1401]={m=0},h,w,f,i,j;
main(){
	cin>>h>>w;
	for(i=0;i<h;i++)for(j=0;j<w;j++){
		cin>>f;
		m=max(m,D[i+1][j+1]=(min(D[i][j],min(D[i+1][j],D[i][j+1]))+1)*(!f));
	}
	cout<<m*m<<endl;
}


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

int main(){
	int N;
	int S,prevB,lastB;
	cin >> N;
	cin >> prevB;
	lastB=prevB;
	S=prevB;
	for(int i=1;i<N-1;i++){
		int B;
		cin >> B;
		if(prevB<B){
			S+=prevB;
		}else{
			S+=B;
		}
		if(i==N-2){
			lastB=B;
		}
		prevB=B;
	}
	S+=lastB;

	cout << S << endl;
	return 0;
}


Measured memory_bytes: 256