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

int main(void)
{
    char ch;
    cin>>ch;
    int a=ch-48;
    cin>>ch;
    int b=ch-48;
    cin>>ch;
    int c=ch-48;
    cin>>ch;
    int d=ch-48;
    if(a+b+c+d==7)
    {
        cout <<a<<"+"<<b<<"+"<<c<<"+"<<d<<"=7"<<endl;
    }
    else if(a+b+c-d==7)
    {
        cout <<a<<"+"<<b<<"+"<<c<<"-"<<d<<"=7"<<endl;
    }
    else if(a+b-c+d==7)
    {
        cout <<a<<"+"<<b<<"-"<<c<<"+"<<d<<"=7"<<endl;
    }
     else if(a+b-c-d==7)
    {
        cout <<a<<"+"<<b<<"-"<<c<<"-"<<d<<"=7"<<endl;
    }
     else if(a-b+c+d==7)
    {
        cout <<a<<"-"<<b<<"+"<<c<<"+"<<d<<"=7"<<endl;
    }
    else if(a-b+c-d==7)
    {
        cout <<a<<"-"<<b<<"+"<<c<<"-"<<d<<"=7"<<endl;
    }
      else if(a-b-c+d==7)
    {
        cout <<a<<"-"<<b<<"-"<<c<<"+"<<d<<"=7"<<endl;
    }
      else if(a-b-c-d==7)
    {
        cout <<a<<"-"<<b<<"-"<<c<<"-"<<d<<"=7"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
N, M = [int(_) for _ in input().split()]
A = [input() for i in range(N)]
B = [input() for i in range(M)]

def check(N, M, A, B):
    for i in range(N - M + 1):
        for j in range(N - M + 1):
            if all(a[j:j+M] == b for a, b in zip(A[i:i+M], B)):
                return True
    return False

if check(N, M, A, B):
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define int long long int
#define ld long double
#define getFaster ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define rep(i,init,n) for(int i=init;i<n;i++)
#define rev(i,n,init) for(int i=n;i>=init;i--)
#define MAXN 200005
#define MOD2 998244353
#define MOD1 1e9+7
#define f first
#define s second
#define endl '\n'
#define pii pair<int,int>
#define piii pair<pii,int>
#define precise(i) cout<<fixed<<setprecision(i)
using namespace std;
const long double PI = atan(1.0)*4;
const int64_t INF=INT64_MAX;
const int32_t LOG=21;
const int MOD=MOD2;


int32_t main()
{ 
      getFaster;
      int tests=1;
      //cin>>tests;
      rep(ii,0,tests)
      {
            int ans=0;
            int k;
            cin>>k;
            rep(a,1,k+1)
            {
                  rep(b,1,k+1)
                  {
                      rep(c,1,k+1)
                      {
                          ans+=__gcd(a,__gcd(b,c));
                      }  
                  }
            }
            cout<<ans<<endl;  
      }

      return 0;                         
}

/*
 TIPS(FOR ME):
 1.) Check for corner cases (like 0 is exception case)
 2.) Check for global memory sizes,memory refreshments and its complexity 
 3.) Check for sorting criteria (if used 1-based indexing)
 4.) Check for numbers overflow (while multiplying and doing MOD)
 5.) Check for typecasting issues like int to float( while dividing numbers)
*/


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
const int N = 505, M = N * N;
int n, m, a[M], id[M], pos[N], pre[M], nxt[M];
inline void del(int x) {
  nxt[pre[x]] = nxt[x];
  pre[nxt[x]] = pre[x];
}
int main() {
  scanf("%d", &n);
  m = n * n;
  nxt[0] = 1, pre[m + 1] = m;
  for (int i = 1; i <= m; ++i) {
    pre[i] = i - 1;
    nxt[i] = i + 1;
  }
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &pos[i]);
    for (int j = 1; j < i; ++j) {
      if (pos[i] == pos[j]) {
        puts("No");
        return 0;
      }
    }
    id[pos[i]] = i;
    a[pos[i]] = i;
    del(pos[i]);
  }
  sort(pos + 1, pos + n + 1);
  for (int i = 1; i <= n; ++i) {
    int rev = id[pos[i]];
    for (int j = 1, cur = 0; j < rev; ++j) {
      cur = nxt[cur];
      if (cur >= pos[i]) {
        puts("No");
        return 0;
      }
      a[cur] = rev;
      del(cur);
    } 
  }
  for (int i = n; i; --i) {
    int rev = id[pos[i]];
    for (int j = 1, cur = m + 1; j <= n - rev; ++j) {
      cur = pre[cur];
      if (cur <= pos[i]) {
        puts("No");
        return 0;
      }
      a[cur] = rev;
      del(cur);
    }
  }
  puts("Yes");
  for (int i = 1; i <= m; ++i) {
    printf("%d%c", a[i], i < m ? ' ' : '\n');
  }
  return 0;
}

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

#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

int main() {
    int64_t h, w, a, b;
    cin >> h >> w >> a >> b;

    constexpr auto M = 1000000007L;

    vector<int64_t> fact(200001, 1), ifact(200001, 1), inv(200001, 1);
    for (auto i : irange(2L, 200001L)) {
        fact[i] = (fact[i - 1] * i) % M;
        inv[i] = M - inv[M % i] * (M / i) % M;
        ifact[i] = ifact[i - 1] * inv[i] % M;

        assert(fact[i] * ifact[i] % M == 1);
    }

    int64_t ans = 0;
    for (auto i : irange(0L, h - a)) {
        // C(i + b - 1, i) * C(h - i - 1 + w - b - 1, h - i - 1)
        ans += fact[i + b - 1] * ifact[i] % M * ifact[b - 1] % M *
               fact[h - i - 1 + w - b - 1] % M * ifact[h - i - 1] % M *
               ifact[w - b - 1] % M;
        ans %= M;
    }

    cout << ans << endl;
}

Measured memory_bytes: 4992
package main

import (
	"fmt"
)

func merge(a, b []int) []int {
	ret := []int{a[0] + b[0], a[1]}
	if ret[1] < b[1] {
		ret[1] = b[1]
	}
	return ret
}

func main() {
	var s string
	fmt.Scan(&s)
	areas := [][]int{}
	st := []int{}
	lv := 0

	for i := 0; i < len(s); i++ {
		switch s[i] {
		case '\\':
			lv--
			st = append(st, i)
		case '/':
			lv++
			if len(st) > 0 {
				x := st[len(st)-1]
				st = st[:len(st)-1]
				a := []int{i - x, lv}
				for j := len(areas) - 1; j >= 0; j-- {
					if areas[j][1] >= lv {
						break
					}
					a = merge(a, areas[j])
					areas = areas[:j]
				}
				areas = append(areas, a)
			}
			if len(areas) > 0 && areas[len(areas)-1][1] < lv {
				areas[len(areas)-1][1] = lv
			}
		}

	}

	sum := 0
	for i := 0; i < len(areas); i++ {
		sum += areas[i][0]
	}
	fmt.Println(sum)
	fmt.Print(len(areas))
	for i := 0; i < len(areas); i++ {
		fmt.Print(" ", areas[i][0])
	}
	fmt.Println()
}



Measured memory_bytes: 2112
#include<stdio.h>
#include<string.h>
#define LEN 100005
 
typedef struct pp{
  char name[100];
  int t;
} P;
 
P Q[LEN+1];
int head, tail, n;
 
void enqueue(P x){
  Q[tail] = x;
  if ( tail + 1 == LEN ) {
    tail = 0;
  } else {
    tail++;
  }
}
 
P dequeue(){
  P x = Q[head];
  if ( head + 1 == LEN ) {
    head = 0;
  } else {
    head++;
  }
  return x;
}
 
int min(int a, int b) { return a < b ? a : b; }
 
int main(){
  int elaps = 0, c;
  int i, q;
  P u;
  scanf("%d %d", &n, &q);
 
  for ( i = 1; i <= n; i++){
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].t);
  }
  head = 1; tail = n + 1;
 
  while (head != tail ) {
    u = dequeue();
    c = min(q, u.t);
    u.t -= c;
    elaps += c;
    if ( u.t > 0 ) enqueue(u);
    else {
      printf("%s %d\n", u.name, elaps);
    }
  }
 
  return 0;
}


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

template<class Type>
Type solve(Type res = Type()){
    int A,B; cin >> A >> B;
    res = max({A+B,A-B,A*B});
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    // solve(0);
    cout << fixed << setprecision(15) << solve<ll>() << endl;
    return 0;
}


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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m; cin >> n >> m;
  vector<int> h(n);
  for (int i = 0; i < n; i++) {
    cin >> h[i];
  }
  vector<vector<int>> surround(n, vector<int>(0));
  for (int i = 0; i < m; i++) {
    int a, b; cin >> a >> b; a--; b--;
    surround[a].push_back(h[b]);
    surround[b].push_back(h[a]);
  }
  int tot = 0;
  for (int i = 0; i < n; i++) {
    if (surround[i].empty()) {
      tot++;
    } else if (h[i] > *max_element(surround[i].begin(), surround[i].end())) {
      tot++;
    }
  }
  cout << tot << '\n';
  return 0;
}

Measured memory_bytes: 8744
from collections import deque, defaultdict
import sys


def input():
    return sys.stdin.readline().strip()


N, M = map(int, input().split())
graph = defaultdict(set)
for _ in range(M):
    A, B = map(lambda x: int(x) - 1, input().split())
    graph[A].add(B)
    graph[B].add(A)
if len(set(graph.keys())) != N:
    print('No')
    exit()

tokens = [-1] * N
visited = {0}
q = deque([0])
while q:
    v = q.popleft()
    visited.add(v)
    for nv in graph[v]:
        if nv in visited:
            continue
        if tokens[nv] < 0:
            tokens[nv] = v
            q.append(nv)

print('Yes')
[print(t + 1) for t in tokens[1:]]


Measured memory_bytes: 135244
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>; 
using pll = pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1001001001LL;
constexpr long long LINF = 1001001001001001001;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define rept(i, j, n) for(int i=(j); i<(n); i++)
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; }


int main(){
    string s; int k; cin >> s >> k;
    rep(i, (int)s.size()){
        if(s[i]=='a')continue;
        int cost = 'z'-s[i]+1;
        if(cost <= k){
            s[i] = 'a';
            k -= cost;
        }
    }
    if(k>0){
        k %= 26;
        s.back() += k;
    }

    cout << s << ln;
}


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

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

    int mod = n % 10;

    if (mod == 3)
        puts("bon");
    else if (mod == 0 || mod == 1 || mod == 6 || mod == 8)
        puts("pon");
    else
        puts("hon");
}

Measured memory_bytes: 3636
program Project1;

{$APPTYPE CONSOLE}

uses
  SysUtils,Classes;
var
  a,h,w,i,j,count,x,y,sw,m,n,b,c,soeji,sum,max,k,min:Integer;
  //l:array[0..6] of Integer = (1,2,4,8,16,32,64);
  s,s123,s1,s2,s3:string;
  tf:Boolean;
  nyu:TStringList;
begin
  try
    { TODO -oUser -cConsole Main : ここにコードを記述してください }
    Readln(s);

    Writeln(s[1]+IntToStr(Length(s)-2)+s[Length(s)]);
    Readln;
  except
    on E: Exception do
      Writeln(E.ClassName, ': ', E.Message);
  end;
end.

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>
#include <functional>

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 RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define EB emplace_back
#define GREATER(T) T, VT<T> greater<T>
template<typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

int main(void) {
    string T;
    cin >> T;

    REP(i, T.size()) if (T[i] == '?') T[i] = 'D';

    cout << T << endl;
}


Measured memory_bytes: 3720
//...Bismillahir Rahmanir Rahim...
// Code by    Asad Bin Saber
// 04 04 2020

#include <stdio.h>
#include <string.h>
#include <vector>
#include <algorithm>
#include <math.h>
#include <iostream>

using namespace std;

void task()
{
    int x, y, z;
    cin>>x>>y>>z;

    cout<<z<<' '<<x<<' '<<y<<endl;
}

int main()
{
    task();

    return 0;
}


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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;

int main(){
    int n, k, q;
    cin >> n >> k >> q;
    map<int, int> mp;
    int a;
    for (int i = 0; i < q; ++i) {
        cin >> a;
        a--;
        mp[a]++;
    }

    for (int i = 0; i < n; ++i) {
        if(k - q + mp[i] > 0) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
}

Measured memory_bytes: 5376
#include<stdio.h>
 int main()
 {
   char a[3],b[3];
   int i,count=0;
    /*for(i=0;i<3;i++)
     scanf("%c",&a[i]);
    for(i=0;i<3;i++)
     scanf("%c",&b[i]);*/
     gets(a);
     gets(b);
    for(i=0;i<3;i++)
      if(a[i]== b[i])
        count=count+1;
   printf("%d",count);
 }


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

typedef long long ll;

ll N;
ll ans=0;

int main(){
	scanf("%lld",&N);
	if(N%2==1){
		printf("0\n");
		return 0;
	}
	N/=2;
	while(N>0){
		ans+=N/5ll;
		N/=5ll;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
from fractions import gcd
A,B,C,D = map(int, input().split())

A =A-1
CD = C * D // gcd(C, D)
num_A_C = A // C
num_A_D = A // D
num_A_CD = A // CD
num_B_C = B // C
num_B_D = B // D
num_B_CD = B // CD

num_B = B - (num_B_C + num_B_D - num_B_CD)
num_A = A - (num_A_C + num_A_D - num_A_CD)
ans = num_B - num_A
print(ans)

Measured memory_bytes: 5076
import sys,queue,math,copy,itertools,bisect,collections,heapq
sys.setrecursionlimit(10**7)
INF = 10**18
MOD = 10**9 + 7
LI = lambda : [int(x) for x in sys.stdin.readline().split()]
NI = lambda : int(sys.stdin.readline())
N,K = LI()
a = LI()
dp = [0 for _ in range(K+1)]

for i in range(K,-1,-1):
    if dp[i]: continue
    for x in a: dp[i-x] = 1
if dp[0] == 1:
    print('First')
else:
    print('Second')

Measured memory_bytes: 47340
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int D = sc.nextInt();
        int X = sc.nextInt();
        int[] A = new int[N];
        for (int i = 0; i < A.length; ++i) {
            A[i] = sc.nextInt();
        }

        System.out.println(solve(A, D, X));

        sc.close();
    }

    static int solve(int[] A, int D, int X) {
        int result = X;
        for (int i = 1; i <= D; ++i) {
            for (int a : A) {
                if ((i - 1) % a == 0) {
                    ++result;
                }
            }
        }

        return result;
    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
const int INF = 2147483647;//int max
const int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int,int>;

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

ll lcm(ll a, ll b) {
    return a / _gcd(a, b) * b;
}


int main() {
    ll n;
    cin >> n;
    vector<ll> a(n,0);
    rep(i,n)cin >> a[i];
    ll ans = 0;
    for(ll bit = 1; bit < (1LL<<n);bit++){//bit = 1からで必ず誰かがさんかすることになる
        vector<ll> stage;
        ll lc = 1;
        for(ll i = 0;i<n;i++)if(bit & (1LL << i))lc = lcm(lc,a[i]);
        bool b = true;
        for(ll i = 0;i<n;i++)if(!(bit & (1LL << i)))if(lc%a[i] == 0)b = 0;
        if(b)ans++;
    }
    cout << ans << endl;
    return 0;
}
/*
やっほい！
　　　　　　　やほほい！
　　　　+　　 　*
　　　 ∧∧　　. ∧∞∧　*
*　ヽ(=´ω｀)人(´ω｀*)ﾉ
　.～（ O x.） （ 　 O)～　+
。*　 　∪　　　　∪
*/


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

int main(){
  int N,K;
  cin >> N >> K;
  int num = 1;
  for(int i = 0; i < N; ++i){
    if(K < num) num += K;
    else num += num;
  }
  cout << num << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <cmath>
#include <vector>

typedef long long ll;

using namespace std;

int main()
{
    ll a, b;
    cin >> a >> b;

    for (ll i=0; i<=20; i++)
    {
        //cout << "test" << a*i - (i-1) << endl;
        if (a*i-(i-1) >= b)
        {
            cout << i << endl;
            return 0;
        }
    }

    return 0;
}


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


int main() {
  int H,N;
  cin>>H>>N;
  vector<int> A(N),B(N);
  rep(i,N) cin>>A[i]>>B[i];

  vector<vector<long long>> dp(N+1, vector<long long>(H+1, INF));
  dp[0][0]=0;
  for(int i=0;i<N;i++){
    for(int j=0;j<=H;j++){
      dp[i+1][j]=min(dp[i+1][j],dp[i][j]);
      dp[i+1][min(j+A[i],H)]=min(dp[i+1][min(j+A[i],H)],dp[i+1][j]+B[i]);
    }
  }
  cout<<dp[N][H]<<endl;
}

Measured memory_bytes: 78592
import java.util.ArrayList;
import java.util.Scanner;

public class Main{

	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();

		String[] a_ = sc.next().split("");
		String[] b_ = sc.next().split("");

		ArrayList<String> aa= new ArrayList<String>();

		for(int i=0;i<N;i++){
			aa.add(a_[i]);
			aa.add(b_[i]);
		}
		sc.close();
		for(int i=0;i<aa.size();++i){
			System.out.print(aa.get(i));
		}
	}
}


Measured memory_bytes: 22740
#include <algorithm>
#include <cmath>
#include <complex>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
#include <functional>
#include <cstring>
#include <regex>
#include <random>
#include <cassert>
#include <stack>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, s, n) for (int i = (s); i < (int)(n); i++)
#define revrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define revrepr(i, s, n) for (int i = (n) - 1; i >= s; i--)
#define debug(x) cerr << #x << ": " << x << "\n"
#define popcnt(x) __builtin_popcount(x)

const double PI = acos(-1.0);

using ll = long long;
using P = pair<int, int>;

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

template<class T>
istream& operator >>(istream &is, vector<T> &v) {
    for (int i = 0; i < (int)v.size(); i++) cin >> v.at(i);
    return is;
}

template<class T, class U>
ostream& operator <<(ostream &os, pair<T, U> p) {
    cout << '(' << p.first << ", " << p.second << ')';
    return os;
}

template<class T>
void print(const vector<T> &v, const string &delimiter) { rep(i, v.size()) cout << (0 < i ? delimiter : "") << v.at(i); cout << endl; }

template<class T>
void print(const vector<vector<T>> &vv, const string &delimiter) { for (const auto &v: vv) print(v, delimiter); }

pair<bool, ll> is_ok(ll n) {
    if (n < 0) {
        for (ll k = -1; pow(k, 5) >= n; k--) {
            if ((ll)pow(k, 5) == n) return make_pair(true, k);
        }
        return make_pair(false, 0);
    }
    else {
        for (ll k = 0; pow(k, 5) <= n; k++) {
            if ((ll)pow(k, 5) == n) return make_pair(true, k);
        }
        return make_pair(false, 0);
    }
}

int main() {
    ll x;
    cin >> x;
    repr(b, -3000, 3001) {
        auto res = is_ok(x + (ll)pow((ll)b, 5));
        if (res.first) {
            cout << res.second << " " << b << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 4204
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long int ll;
 
#define pii pair<int, int>
#define F first
#define S second
#define pb push_back
 
const int N = 1e5 + 5;
const int mod = 1e9+7;
const ll INF = (ll)1e18;

vector<int> g[N];
vector<ll> dpw(N, 1), dpb(N, 1);

void dfs(int s, int p){
    ll &w = dpw[s], &b = dpb[s];
    for(auto i : g[s])
        if(i != p){
            dfs(i, s);
            w = (w * (dpw[i] + dpb[i])) % mod;
            b = (b * dpw[i]) % mod;
        }
}

int main(){
    ios_base :: sync_with_stdio(0);
    cin.tie(0);
 
    int n;
    cin >> n;
    for(int j = 0; j < n-1; j++){
        int u, v;
        cin >> u >> v;
        g[u].pb(v);
        g[v].pb(u);
    }
    dfs(1, 0);
    cout << (dpw[1] + dpb[1]) % mod;
    return 0;
}


Measured memory_bytes: 14208
#include <iostream>
#include <vector>
#include <numeric>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <string>
#include <cstring>
#include <queue>
#define myfor(i,N) for(i=0;i<N;i++)
#define myforFL(i,f,l) for(i=f;i<l;i++)
#define myforInv(i,N) for(i=N;i>=0;i--)
#define myforFLInv(i,f,l) for(i=f;i>l;i--)
#define ifMeetBoundaryCondition(x,xMax,xMin,y,yMax,yMin) if(x < xMax && x >= xMin &&y < yMax && y >= yMin)
#define INF pow(10,9)
using namespace std;

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

int main(){
	int H,W,N,i,j,y,x,sh=0,sw=0;
	vector<pair<int,int> >black_p;
	cin >> H >> W;
	vector<vector<int> >dist(H,vector<int>(W,INF));
	vector<string> s(H);

	myfor(i,H){
		cin >> s[i];
	}
	myfor(i,H)myfor(j,W)if(s[i][j] == '#')black_p.push_back(pair<int,int>(i,j));
	
	queue<pair<int, int> >q;
	myfor(i,black_p.size()){
		sh = black_p[i].first, sw=black_p[i].second;
		q.push(pair<int,int>(sh,sw));
		dist[sh][sw] = 0;
	}
	vector<vector<bool> >done(H,vector<bool>(W,false));
	while(!q.empty()){
		y = q.front().first;
		x = q.front().second;
		q.pop();
		if(done[y][x])continue;
		done[y][x] = true;
		myfor(j,4){
			ifMeetBoundaryCondition(x+dx[j],W,0,y+dy[j],H,0){
				if(s[y+dy[j]][x+dx[j]] != '#' && !done[y+dy[j]][x+dx[j]]){
					q.push(pair<int,int>(y+dy[j],x+dx[j]));
					dist[y+dy[j]][x+dx[j]] = min(dist[y][x] + 1,dist[y+dy[j]][x+dx[j]]);
				}
			}
		}
	}
	
	int ans=0;
	myfor(i,H){
		 ans = max(ans,*max_element(dist[i].begin(), dist[i].end()));
	}
	cout << ans << endl;


	return 0;
}

Measured memory_bytes: 21612
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


N, M = [int(i) for i in input().split()]
ABS = [[int(i) for i in input().split()] for _ in range(M)]

cnt = 0
for i in range(M):
  uf = UnionFind(N+1)
  for a, b in [*ABS[:i], *ABS[i+1:]]:
    uf.union(a, b)
  if uf.group_count() > 2:
    cnt += 1

print(cnt)


Measured memory_bytes: 9320
#include<iostream>

using namespace std;

int min(int s[], int n) {
    int tmp = 100;


    for (int i = 0; i < n; i++) {
        if (tmp > s[i] && s[i] % 10 != 0) {
            tmp = s[i];
        }
    }
    return tmp;
}

int main() {
    int n;
    int *s;
    int score = 0;
    int m;


    cin >> n;
    s = new int[n];

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

    for(int i = 0; i < n; i++) {
        score += s[i];
    }

    if (score % 10 != 0) {
        cout << score << endl;
    } else {
        int m;
        m = min(s, n);
        if(m < 100) {
            cout << score - m << endl;
        } else {
            cout << 0 << endl;
        }
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
bool ok(string S){
  int N = S.size();
  string T;
  int X = 0;
  for (int i = 0; i < N; i++){
    if (i <= N - 3){
      if (S.substr(i, 3) == "ABC"){
        T += "X";
        i += 2;
        X++;
      } else {
        T += S[i];
      }
    } else {
      T += S[i];
    }
  }
  if (X == 0){
    return false;
  }
  int M = T.size();
  int A = 0, B = 0, C = 0;
  for (int i = 0; i < M; i++){
    if (T[i] == 'A'){
      A++;
    }
    if (T[i] == 'B'){
      B++;
    }
    if (T[i] == 'C'){
      C++;
    }
  }
  if (A == 0 && B == 0 && C == 0){
    if (X == 1){
      return true;
    } else {
      return false;
    }
  }
  char c = '.';
  if (A == 0 && B != 0 && C != 0){
    c = 'A';
  }
  if (A != 0 && B == 0 && C != 0){
    c = 'B';
  }
  if (A != 0 && B != 0 && C == 0){
    c = 'C';
  }
  if (c == '.'){
    return false;
  }
  for (int i = 0; i < M; i++){
    if (T[i] == 'X'){
      T[i] = c;
    }
  }
  return ok(T);
}
int main(){
  string S;
  cin >> S;
  if (ok(S)){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 21848
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

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

    Scanner sc = new Scanner(System.in);

    void solve() {
        String W =  sc.nextLine().toLowerCase();
        int cnt = 0;
        while (true) {
            String[] arr = sc.nextLine().split(" ");
            if (arr[0].equals("END_OF_TEXT")) break;
            for (int i = 0; i < arr.length; ++i) {
                if (arr[i].toLowerCase().equals(W)) {
                    cnt++;
                }
            }
        }
        System.out.println(cnt);
    }
}






Measured memory_bytes: 26228
import java.util.*;
class Main{
    final int N=123456+10;
    boolean[] pn=new boolean[N*2];
    void run(){
	Scanner sc=new Scanner(System.in);
	Arrays.fill(pn,true);
	setPN();
	while(true){
	    int n=sc.nextInt();
	    if(n==0)break;
	    int ans=0;
	    for(int i=n+1;i<=2*n;i++){
		if(pn[i])ans++;
	    }
	    System.out.println(ans);
	}
    }
    void setPN(){
	pn[0]=false;pn[1]=false;
	for(int i=2;i*i<2*N;i++){
	    if(pn[i]){
		for(int j=i+i;j<2*N;j+=i){
		    pn[j]=false;
		}
	    }
	}
    }
    public static void main(String[] args){
	new Main().run();
    }
}

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

typedef long long int ll;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define all(v) (v).begin(), (v).end()
#define sz(x) int(x.size())
const int INF = 1001001001;
const ll mod = 998244353;
const ll INFL = 1001001001001001000;



int main() {
    int n; cin >> n;
    rep(i,n) printf("ACL");
    printf("\n");
    return 0;
}

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

int main(){
    int n, k;
    cin >> n >> k;
    vector<int> v(n);
    for(int i = 0; i < n; i++){
        cin >> v[i];
    }
    int one;
    for(int i = 0; i < n; i++){
        if(v[i] == 1){
            one = i;
        }
    }
    int ans = 0;
    int I = one + 1;
        while(n > 0){
            n -= k;
            if(n != 0){
                n++;
            }
            ans++;
        }
    cout << ans << endl;
    return 0;
}

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

/* メモリ食い過ぎ注意 */
#define int long long

typedef long long ll;

ll gcd(ll a, ll b)
{
    if (a < b)
        gcd(b, a);
    if (b == 0)
        return a;
    int r;
    while ((r = a % b))
    {
        a = b;
        b = r;
    }
    return b;
}

/* define const */
const ll INF = (1ll << 60);
const ll MOD = (ll)1e9 + 7;
/* end defineing */

signed main()
{
    int a, b, c, d;
    cin >> a >> b >> c >> d;

    cout << min(a, b) + min(c, d) << endl;
}


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

ll p[51], b[51];

ll solve(ll N, ll X) {
    if (N == 0) {
        return X >= 1;
    }
    else if (X <= b[N-1] + 1) {
        return solve(N-1, X-1);
    }
    else {
        return p[N-1]+1+solve(N-1, X-2-b[N-1]);
    }
}

int main() {
    ll N, X;
    cin >> N >> X;
    p[0] = b[0] = 1LL;
    for (int i=1; i<=N; ++i) {
        p[i] = p[i-1] * 2 + 1;
        b[i] = b[i-1] * 2 + 3;
    }
    cout << solve(N, X) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <functional>
#include <numeric>
#include <iomanip>
#define fi first
#define se second
#define fcout(n) cout<<fixed<<setprecision((n))
#define cinl(str) getline(cin,(str))
using namespace std;
bool value(int y,int x,int R,int C){return 0<=y&&y<R&&0<=x&&x<C;}
typedef pair<int,int> pii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long > vll;
typedef vector< vi > vvi;
double pie=acos(-1);
int INF=1000000007;
int dx[4] = { 0,-1,0,1 };
int dy[4] = { -1,0,1,0 };


int main() {
	int n;
	ll a[105],ans;

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

	sort(a,a+n);
	ans=abs(a[n-1]-a[0]);
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(void){
    int n,flg=0;
    cin>>n;
    vector<string> s(n);
    for(int i=0;i<n;i++){
        cin>>s[i];   
    }
    sort(s.begin(),s.end());
    for(int i=1;i<n;i++){
        if(s[i-1]!=s[i]){
        flg++;
        }
    }
    cout<<flg+1<<endl;
}

Measured memory_bytes: 9544
#include<iostream>
 #include<stdio.h>
 #include<cstdlib>
 #include<cstdio>
 #include<string>
 #include<math.h>
 #include<time.h>
 #include<iomanip>
 #include<algorithm>
 #include<string.h>
 #include<cctype>
 #include<fstream> 
 #include<map>
 #include<set>
 #include<vector>
 #include<sstream>
 #include<stack>
 #include<queue>
 #include<deque>
 #include<functional>
 #include<utility>
 #include<list>
 #include<memory>
 
 using namespace std;

 int main()
 {
   char x,y;
   while(cin>>x>>y)
   {
     int kk=(x-'A')-(y-'A');
     if(kk>0) cout<<">"<<endl;
     else if(kk==0) cout<<"="<<endl;
     else cout<<"<"<<endl;  
   }
   return 0;
 }
 

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

int main() {
  int N;
  cin >> N;
  vector<pair<int, int>> V(N);
  for (int i = 0, a, b; cin >> a >> b; i++) V.at(i) = {b, -a};
  sort(V.begin(), V.end());

  int now = 0;
  for (int i = 0; i < N; i++) {
    now += -V.at(i).second;
    if (now > V.at(i).first) return cout << "No" << "\n", 0;
  }

  cout << "Yes" << "\n";
}

Measured memory_bytes: 1792
K, S = map(int, input().split())
ans = 0
for x in range(K + 1):
    remainder = S - x
    if remainder < 0:
        break
    elif remainder > K * 2:
        continue
    else:
        ans += remainder + 1 - 2 * max(remainder - K, 0)
print(ans)

Measured memory_bytes: 2940
n = int(input())
a = [int(e) for e in input().split()]
b = [int(e) for e in input().split()]
result = 0
for i in range(n):
  if a[i] > b[i]:
    result += b[i]
    a[i] -= b[i]
    b[i] = 0
  else:
    result += a[i]
    b[i] -= a[i]
    a[i] = 0
    if a[i + 1] > b[i]:
      result += b[i]
      a[i + 1] -= b[i]
      b[i] = 0
    else:
      result += a[i + 1]
      b[i] -= a[i + 1]
      a[i + 1] = 0
print(result)

Measured memory_bytes: 19004
#include<cstdio>
#include<cstring>
#include<algorithm>
#define LL long long
using namespace std;
const LL maxn=200010;
const LL inf=1e18;;
char s[maxn];
LL len[1000],nt[1000],cnt1[1000][27],cnt2[1000][27],o[27],ans[27];
LL nxt[maxn];
LL k,t,n,m,tot,top;
LL l,r;
void kmp()
{
    LL j=0;
    for(LL i=2;i<=n;i++)
	{
        while(j&&s[j+1]!=s[i]) j=nxt[j];
        if(s[j+1]==s[i]) j++;
        nxt[i]=j;
    }
}
void work(LL n,LL f)
{
    for(int i=top;i>=1;i--)
        if (n>=len[i])
		{
            for(int j=0;j<26;j++) ans[j]+=f*(cnt1[i][j]*2+cnt2[i][j]);
            n-=len[i];
        }
    if (n>=len[0])
	{
        for(int j=0;j<26;j++) ans[j]+=f*o[j];
        n-=len[0];
    }
    for(int i=1;i<=n;i++) ans[s[i]-'a']+=f;
}
void solve(LL n,LL f)
{
    for(int i=0;i<26;i++) ans[i]+=(LL)f*(n/tot)*o[i];
    n%=tot;
    for(int i=1;i<=n;i++) ans[s[i]-'a']+=f;
}
int main()
{
    scanf("%s",s+1);
    n=strlen(s+1);
    n/=2;
    kmp();
    if (n%(n-nxt[n]))
	{
        for(int i=1;i<=nxt[n];i++) cnt1[0][s[i]-'a']++;
        for(int i=nxt[n]+1;i<=n-nxt[n];i++) cnt2[0][s[i]-'a']++;
        for(int i=1;i<=n;i++) o[s[i]-'a']++;
        len[0]=n;nt[0]=nxt[n];
        if (nxt[n]>=(n+1)/2)
		{
            top++;
            len[top]=len[top-1]*2-nt[top-1];
            nt[top]=len[top-1]-nt[top-1];
            for(int i=1;i<=nt[top];i++) cnt1[top][s[i]-'a']++;
            for(int i=n-nxt[n]+1;i<=n;i++) cnt2[top][s[i]-'a']++;
        }
        while(len[top]<inf)
		{
            top++;
            len[top]=len[top-1]*2-nt[top-1];
            nt[top]=len[top-1]-nt[top-1];
            for(int i=0;i<26;i++)
			{
                cnt1[top][i]=cnt1[top-1][i]+cnt2[top-1][i];
                cnt2[top][i]=cnt1[top-1][i];
            }
        }
        scanf("%lld%lld",&l,&r);
        work(r,1);work(l-1,-1);
        for(int i=0;i<26;i++) printf("%lld ",ans[i]);
    }
    else
	{
        tot=n-nxt[n];
        for(int i=1;i<=tot;i++) o[s[i]-'a']++;
        scanf("%lld%lld",&l,&r);
        solve(r,1);solve(l-1,-1);
        for(int i=0;i<26;i++) printf("%lld ",ans[i]);
    }
}

Measured memory_bytes: 1152
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

ll gcd(ll a, ll b){
  if(b == 0LL) return a;
  return gcd(b, a % b);
}

int main(){
    ll N, M;
    cin >> N >> M;

    ll a[N];
    for(int i = 0; i < N; i++){
        cin >> a[i];
        a[i] /= 2;
    }

    int cnt[N];
    fill(cnt, cnt + N, 0);
    for(int i = 0; i < N; i++){
        ll tmp = a[i];
        while(tmp % 2 == 0){
            cnt[i]++;
            tmp /= 2;
        }
    }

    bool check = true;
    for(int i = 0; i < N - 1; i++){
        if(cnt[i] != cnt[i + 1]) check = false;
    }

    if(!check){
        cout << 0 << endl;
        return 0;
    }

    ll lcm = a[0];
    for(int i = 1; i < N; i++){
        ll g = gcd(lcm, a[i]);
        lcm = lcm / g * a[i];
        if(lcm > M){
            cout << 0 << endl;
            return 0;
        }
    }

    //cout << lcm << endl;

    ll ans = M / lcm;
    ans = (ans + 1) / 2;

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

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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    int n;
    cin >> n;
    vi h(n);
    rep(i, n) cin >> h[i];
    int cnt = 0, ans = 0;
    for (int i=1; i<n; ++i) {
        if (h[i]<=h[i-1]) ++cnt;
        else cnt = 0;
        ans = max(ans, cnt);
    }
    cout << ans << endl;
    return 0;
}


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

int main()
{

	int n = 1;
	
	while (cin >> n) {
		int ans = 1000001;
		if (n == 0)
			break;
		int a[1000];
		for (int i = 0;i < n;i++) {
			cin >> a[i];
		}
		for (int i = 0;i < n - 1;i++) {
			for (int j = i + 1;j < n;j++) {
				if (ans > abs(a[i] - a[j]))
					ans = abs(a[i] - a[j]);
			}
		}
			cout << ans << endl;

	}
	return 0;
}

Measured memory_bytes: 3080
#include <stdio.h>
#include <math.h>

int main(void) {
    int a, b;
    scanf("%d%d", &a, &b);
    /* 和が奇数なら IMPOSSIBLE */
    if ( (a + b) % 2 == 1 ) {
        printf("IMPOSSIBLE\n");
    }
    else {
        printf("%d\n", (a + b) / 2);
    }
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
#define repitr(itr,a) for(auto itr=a.begin();itr!=a.end();++itr)
#define P pair<int,int>
const int MOD=1e9+7;
const int INF=2e9;
 
 
int main() {
    ios_base::sync_with_stdio(false);
 
    ll n,k; 
    cin >> n >> k;
    ll ans=k;
    rep(i,n-1) ans*=(k-1);
    cout << ans << endl;
 
    return 0;   
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>

#define FOR(i,a,b) for(int i=(a);i<(b);++(i))
#define REP(i,n) FOR(i,0,n)

#define dump(x) cerr << #x << " = " <<(x)<<endl;
#define debug(x) cerr << #x << " = " <<(x) << "(L" << __LINE__ << ")" << __FILE__ << endl;

using namespace std;

int main(void){
  int a,b,c;
  cin >> a >> b >> c;
  int seki = a*b*c;
  int add = a+b+c;
  int s = 5*5*7;
  int ad = 5+5+7;
  if(s==seki and ad== add){
    cout <<"YES"<<endl;
  }
  else{
    cout << "NO" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define big 1000000007
#define all(a) sort((a).begin(),(a).end()) //ソートのマクロ
#define Re(a) reverse((a).begin(),(a).end())
#define YN(a) if(a){cout<<"Yes"<<endl;}else cout<<"No"<<endl;//条件によってYes、Noを出力する
const int MOD=1000000007;
const double pi = 3.141592653589793;
int main(){
    string t;
    string a ="";
    cin>>t;
    int n=t.length();
    rep(i,n){
        if(t[i]=='?'){
            a+='D';
        }
        else{
            a += t[i];
        }
    }
    cout<<a<<endl;
}

Measured memory_bytes: 3844
N,Q = map(int,input().split())
 
S = [x for x in input()]

cnt =[0]
for a,b in zip(S,S[1:]):
  if a == 'A' and b == 'C':
    cnt.append(cnt[-1] + 1)    
  else:
    cnt.append(cnt[-1])

    
for _ in range(Q):
  l,r = map(int,input().split())
  print(cnt[r-1]-cnt[l-1])

Measured memory_bytes: 7192
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long a = sc.nextLong();
        long b = sc.nextLong();
        List<Long> h = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            h.add(sc.nextLong());
        }
        long ok = 1000000000;
        long ng = 0;
        while (Math.abs(ok - ng) > 1) {
            long mid = (ok + ng) / 2;
            if (solve(h, mid, a, b)) {
                ok = mid;
            } else {
                ng = mid;
            }
        }
        System.out.println(ok);
    }
    public static boolean solve(List<Long> h, long t, long a, long b) {
        long ans = 0;
        for (long hi : h) {
            if (hi - b * t <= 0) {
                continue;
            }
            if ((hi - b * t) % (a - b) == 0) {
                ans += (hi - b * t) / (a - b);
                continue;
            }
            ans += (hi - b * t) / (a - b) + 1;
        }
        if (ans <= t) {
            return true;
        }
        return false;
    }
}


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

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

    s += "0";
    bool iscat = true;
    int cm=0, ce=0, cw=0;
    for(int i=0; i<(int)s.length(); i++){
        if(s[i]=='m') cm++;
        if(s[i]=='e') ce++;
        if(s[i]=='w') cw++;
        if(cm<ce || cm<cw || ce<cw){
            iscat=false;
            break;
        }
        if((s[i]=='m' && s[i+1]=='w')
           || (s[i]=='e' && s[i+1]=='e')
           || (s[i]=='w' && s[i+1]=='m')){
            iscat=false;
            break;
        }
    }
    if(cm!=ce || cm!=cw){
        iscat=false;
    }
    
    if(iscat){
        cout << "Cat" << endl;
    }else{
        cout << "Rabbit" << endl;
    }
    return 0;
}

Measured memory_bytes: 3196
#include <bits/stdc++.h>
using namespace std;
 
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(a)     (a).begin(),(a).end()
#define VI         vector<int>
#define MOD 1000000007
 
typedef long long int ll;
 
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; }
 
const ll INF=(ll)1e19;
//const int INF=(1<<30);
 
int main(){
  int n,k;
  cin >> n >> k;
 
  VI a(n);
  REP(i,n)cin >> a[i];
 
  int mx = a[0];
  int cnt=1;
  FOR(i,1,n){
    if(mx < a[i]){
      mx = a[i];
      cnt++;
    }
  }
 
  if(k<=cnt){
    cout << 0 << endl;
    return(0);
  }
 
  ll ans=INF;
  REP(i,(1<<n)){
    mx = a[0];
    cnt = 1;
    ll cost = 0;
    FOR(j,1,n){
      if(cnt==k)break;
 
      if(mx < a[j]){
        cnt++;
        mx = a[j];
        continue;
      }
      if((i>>j)&1){
        if(mx >= a[j]){
          cost += mx - a[j] + 1;
          mx++;
          cnt++;          
        }
      }
    }
 
    if(cnt>=k)chmin(ans, cost);
  }
 
  cout << ans << endl;
}

Measured memory_bytes: 256
//master
import java.io.*;
import java.util.*;
public class Main {
    static int[][] memo;
    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        String str = sc.next();
        str = str.replace("?","D");
        p(str);
    }

    public static <T> void p(T message) {
        System.out.println(message);
    }

    public static <T> void pe(T message) {
        System.err.println(message);
    }

    public static <T> void pp(T message) {
        System.out.print(message);
    }
    
}
class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
 
    private int readByte() {
        if (hasNextByte())
            return buffer[ptr++];
        else
            return -1;
    }
 
    private boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }
 
    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr]))
            ptr++;
        return hasNextByte();
    }
 
    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
 
    public long nextLong() {
        if (!hasNext())
            throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
 
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
            throw new NumberFormatException();
        return (int) nl;
    }
 
    public double nextDouble() {
        return Double.parseDouble(next());
    }
}


Measured memory_bytes: 44832
import Data.Array

main = do
  li <- getLine
  let n = read li
  li <- getLine
  let as = map read $ words li
  let ans = compute n as
  print (length ans)
  putStrLn $ unwords $ map show ans

compute :: Int -> [Int] -> [Int]
compute n as = [i | (i,1) <- assocs ca]
  where
    aa = listArray (1,n) as
    ca = listArray (1,n) (map c [1..n])
    c i = (aa ! i + x) `mod` 2
      where
        x = sum [ ca ! k | k <- [2*i,3*i..n] ]


Measured memory_bytes: 102396