akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1e9;
const ll LINF = 1e18;
#define rep(i,N) for(int (i)=0;(i)<(N);++(i))
#define rrep(i,N) for(int (i)=(N-1);(i)>0;--i)
#define FOR(i,j,N) for(int (i)=(j);(i)<(N);++(i))
#define put(n) cout<<(n)<<endl;
#define VI vector<int>
#define VII vector<vector<int>>
#define VIII vector<vector<vector<int>>>
#define all(v) (v.begin(),v.end())


int main(){
    double A,B,C,D,E,F,ans=0,s,MAX=-1;
    cin>>A>>B>>C>>D>>E>>F;
    
    for(int i=0;A*i<=30;++i){
        for(int j=0;B*j<=30;j++){
            double x = 100*A*i+100*B*j;
            for(int k=0;C*k<=3000;++k){
                for(int l=0;l*D<=3000;++l){
                    double y = k*C+l*D;
                    if(x+y>F) break;
                    if(y>E*(x/100)) break;
                    
                    if(MAX < 100*y/(x+y)){
                        MAX = 100*y/(x+y);
                        ans = x+y;
                        s = y;
                    }
                }
            }
        }
    }
    
    cout<<ans<<" "<<s<<endl;   
}



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

int main() {
  int N;
  cin >> N;
  vector<int> numbers(N);
  
  for (int i = 0; i < N; i++) {
    cin >> numbers.at(i);
  }

  int count = 0;
  bool judge = true;
  while (judge) {
    for (int i = 0; i < N; i++) {
      if (numbers.at(i) % 2 == 1) {
        judge = false;
        break;
      }
      else
        numbers.at(i) /= 2;      
    }
    if (judge == true)
      count++;
  }

  cout << count << endl;
    
}

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

using namespace std;
using llong = long long;
using ldbl = long double;
using lpair = pair<llong, llong>;

#define ALL(x) x.begin(), x.end()

template<typename T>
constexpr T inf = static_cast<T>(pow(10, static_cast<int>(log10(numeric_limits<T>::max())))) + 7;
constexpr llong mod = 1e9+7;

int main() {
  llong A, B, N;
  cin >> A >> B >> N;

  if (B - 1 <= N) {
    cout << A*(B-1)/B - A*((B-1)/B) << endl;
  }
  else {
    cout << A*N/B - A*(N/B) << endl;
  }

  return 0;
}

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

typedef long long LL;

LL solve(long long N, long long X) {
  if (N == 0) {
    if (X <= 0)
      return 0;
    else
      return 1;
  }
  LL pan = 1;
  LL sum = 1;
  for (int i = 0; i < N - 1; i++) {
    pan = pan * 2 + 1;
    sum = sum * 2 + 3;
  }

  if (X <= sum + 1) {
    return solve(N - 1, X - 1);
  } else
    return pan + 1 + solve(N - 1, X - 2 - sum);
}

int main() {
  long long N;
  scanf("%lld", &N);
  long long X;
  scanf("%lld", &X);
  LL ans = solve(N, X);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
from collections import Counter

n = int(input())
a = Counter(map(int, input().split()))
q = int(input())
s = sum(x * y for x, y in a.items())
for _ in range(q):
  b, c = map(int, input().split())
  s = s + (c - b) * a[b]
  a[c] += a[b]
  a[b] = 0
  print(s)


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

using pii = pair<int, int>;
using vi = vector<int>;
using ll = long long;

int main() {
    int n;
    while(cin >> n, n) {
        int m; cin >> m;
        string s; cin >> s;
        int ans = 0;
        int cnt = 0;
        char next = 'I';
        for(int i = 0; i < m; ++i) {
            if(s[i] == next) {
                cnt++;
                next = (s[i] == 'I' ? 'O' : 'I');
            } else {
                if(cnt >= 2 * n + 1) {
                    ans += (cnt - 2 * n + 1) / 2;
                }
                next = 'I';
                cnt = 0;
                if(s[i] == 'I') {
                    i--;
                }
            }
        }
        if(cnt >= 2 * n + 1) {
            ans += (cnt - 2 * n + 1) / 2;
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 3944
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
	int a, b, c, d, e, ans = 0;
	cin >> a >> b >> c >> d >> e;
	cout << (a > 0 ? e * (b - a) : -a * c + d + e * b) << endl;

	return 0;
}

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

int main() {
	int n;
	cin >> n;
	vector<int> v(n);
	vector<int> c(n);
	for (int i = 0; i < n; i++) {
		cin >> v.at(i);
	}
	for (int i = 0; i < n; i++) {
		cin >> c.at(i);
	}
	int sum = 0;
	for (int i = 0; i < n; i++) {
		if(v.at(i)-c.at(i)>0)sum += v.at(i) - c.at(i);
	}
	cout << sum << endl;
}

Measured memory_bytes: 256
n,m=map(int,input().split())
P=[int(i) for i in input().split()]
PP=[0]*n
for i in range(n):
  PP[P[i]-1]=i+1
par=[-1]*n

def find(x):
  if par[x]<0:
    return x
  else:
    par[x]=find(par[x])
    return par[x]

def unite(x,y):
  x=find(x)
  y=find(y)
  if x==y:
    return False
  else:
    if par[x]>par[y]:
      x,y=y,x
    par[x]+=par[y]
    par[y]=x
    return True

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

def size(x):
  return -par[find(x)]

for i in range(m):
  x,y=map(int,input().split())
  unite(x-1,y-1)
ans=0
for i in range(n):
  if same(i,PP[i]-1):
    ans+=1
print(ans)

Measured memory_bytes: 13880
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))

ans = 0
for i in range(N):
    ans += min(A[i],B[i])
    B[i] -= min(A[i],B[i])
    ans += min(A[i+1],B[i])
    A[i+1] -= min(A[i+1],B[i])
print(ans)    

Measured memory_bytes: 24156
package main

import (
	"fmt"
	"os"
)

func main(){
	var w , h int
	for{
		fmt.Scan(&h, &w)
		if h == 0 && w == 0{
			os.Exit(0)
		}else{
			for i := 0 ; i < h ; i++{
				for j := 0; j < w ; j++{
					fmt.Print("#")
				}
				fmt.Print("\n")
			}
		}
		fmt.Print("\n")
		
	}
	
}


Measured memory_bytes: 1160
S = input()

tmp = 0
atcgmax = 0
for i in range(len(S)):
    if S[i] == 'A' or  S[i] == 'T' or S[i] == 'C' or S[i] == 'G':
        tmp += 1
    else:
        atcgmax = max(tmp,atcgmax)
        tmp = 0
ans = max(tmp,atcgmax)

print(ans)

Measured memory_bytes: 9064
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef pair<ll, ll> PP;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
#define rrep(i, n) for(ll i = n - 1; i > -1; i--)
#define all(v) v.begin(), v.end()
#define pb push_back
#define fi first
#define se second
template <class X> void print(X x) { cout << x << endl; }
void print(vl x) {
    for(ll i : x) {
        cout << i << " ";
    }
    cout << endl;
}
const ll INF = (1LL << 61) - 1;
const ll MOD = 1000000007 /*998244353*/;
const ll MAX_N = 500010;
ll a, b, c, d, e, f, h, x, y, z, p, q, n, t, r, k, w, l, ans, i, j, u, v, m;
ll codeforces = 1;
string S, T;
vl A, B;
void input() { cin >> n; }
void solve() {
    map<string, ll> M;
    rep(i, n) {
        cin >> S;
        M[S]++;
    }
    cout << "AC x ";
    print(M["AC"]);
    cout << "WA x ";
    print(M["WA"]);
    cout << "TLE x ";
    print(M["TLE"]);
    cout << "RE x ";
    print(M["RE"]);
}
int main() {
    // cout<<fixed<<setprecision(15);
    cin.tie(0);
    ios::sync_with_stdio(false);
    input();
    while(codeforces--) {
        solve();
    }
}

Measured memory_bytes: 3668
#include <stdio.h>
#include <vector> 
#include <algorithm>
#include <functional>
#include <iostream>

using namespace std;

int main(void){
  vector <long> v;
  long n, a;
  bool r = false;
  
  cin >> n;
  for(long i = 0; i < n; i++){
    cin >> a;
    v.push_back(a);
  }
  std::sort(v.begin(),v.end());
  
  for(long i = 0; i < n - 1; i++){
    long t = v[i];
    long c = v[i + 1];
    if(t == c)
      r = true;
  }
  
  if(r){
    cout << "NO" << endl;
  }else {
    cout << "YES" << endl;
  }
  
  return 0;
}

Measured memory_bytes: 2420
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using ii=pair<ll,ll>;
using vi=vector<ll>;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define INF (ll)1e18
#define all(x) (x).begin(),(x).end()
#define print(a); for(auto x:a)cout<<x<<" "; cout<<"\n";
#define mset(a); memset(a,0,sizeof(a));

int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);
    ll n;cin>>n;
    string s;
    map<string,ll>m;
    for(int i=0;i<n;i++){
        cin>>s;
        sort(all(s));
        m[s]++;
    }
    ll sum=0;
    for(auto x:m){
        sum+=((x.se-1)*x.se)/2;
    }
    cout<<sum<<"\n";
}


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

int main() { 
	int N,count = 1;
  cin >> N;
	vector<int> a(N);
  for (int i = 0; i < N; i++) {
          cin >> a.at(i);
  }

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

  for (int i = 0; i < N - 1; i++) {

	  if (a[i] != a[i + 1]) {
      count++;
      }
   }
  cout << count << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
 
int N, M, Q, L[200009], R[200009], X[509][509], C[509][509];
 
int main() {
	cin >> N >> M >> Q;
	for (int i = 1; i <= M; i++) {
		cin >> L[i] >> R[i]; X[L[i]][R[i]]++;
	}
	for (int i = 1; i <= N; i++) {
		for (int j = 1; j <= N; j++) C[i][j] = C[i][j - 1] + X[i][j];
	}
	for (int i = 1; i <= Q; i++) {
		int p, q; cin >> p >> q;
		int sum = 0;
		for (int j = p; j <= q; j++) sum += C[j][q] - C[j][p - 1];
		cout << sum << endl;
	}
	return 0;
}


Measured memory_bytes: 4480
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for(int i=0; i<(n); ++i)
#define REP(i, d, n) for(int i=(d); i<(n); ++i)
#define all(v) v.begin(), v.end()
using P = pair<int, int>;

signed main() {

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

    if(k <= a){
        cout << k << endl;
    }
    else if(a + b >= k){
        cout << a << endl;
    }
    else{
        cout << a - (k - (a + b)) << endl;
    }

    return 0;
}


Measured memory_bytes: 3616
#include<stdio.h>

int main(){
 int a,b,i;
  scanf("%d %d",&a,&b);
  if(a>=b){
  for(i=0;i<a;i++)printf("%d",b);
    printf("\n");
  }
  else{
    for(i=0;i<b;i++)printf("%d",a);
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 128
from itertools import accumulate
n = int(input())
a = list(map(int, input().split()))
b = list(accumulate(a))
ans = 100000000000
SUM = sum(a)
for i in b[:-1]:
  tmp = abs(SUM - i * 2)
  if tmp < ans:
    ans = tmp
print(ans)
    


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

using namespace std;

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const ll mod = 1e9+7;

int main()
{
	const int n=50;
	ll k; cin >>k;
	vector<ll> ans(n);
	
	rep(i,n) ans[i] = n -1 + k/n;
	int pk = k%n;
	
	rep(i, pk){
		ans[i] += n+1;
		rep(j, n) ans[j]--;
	}
	
	
	cout << n <<"\n";
	rep(i,n) cout << ans[i] << (i==n-1? "\n":" ");
	return 0;
}


Measured memory_bytes: 256
//---------------------------------------------------------------
#include <bits/stdc++.h>
using namespace std;
#include <cstdlib>
#include <cmath>
#include <math.h>
#include <sstream>
#include <numeric>
#include <cassert>
//---------------------------------------------------------------
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define SIZE 100005
#define INF 1e18
#define all(x) x.begin(),x.end()
#define fi first
#define se second
#define vec vector
using pint = pair<int,int>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
//---------------------------------------------------------------
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const double pi = acos(-1);
//---------------------------------------------------------------
const int mod = 1000000007;
struct mint {
int64_t x;
mint(int64_t x=0):x((x%mod+mod)%mod){}
mint operator-() const { return mint(-x);}
mint& operator+=(const mint a) {if ((x += a.x) >= mod) x -= mod;return *this;}
mint& operator-=(const mint a) {if ((x += mod-a.x) >= mod) x -= mod;return *this;}
mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
mint operator+(const mint a) const { return mint(*this) += a;}
mint operator-(const mint a) const { return mint(*this) -= a;}
mint operator*(const mint a) const { return mint(*this) *= a;}
mint pow(int64_t t) const {if (!t) return 1;mint a = pow(t>>1);a *= a;if (t&1) a *= *this;return a;}
mint inv() const { return pow(mod-2);}
mint& operator/=(const mint a) { return *this *= a.inv();}
mint operator/(const mint a) {return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
//↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓


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

    ll mod=1000000007;
    ll n;
    cin>>n;
    mint n1=1,n2=1,n3=1;
    rep(i,n){
        
        n1*=10;
        n2*=9;
        n3*=8;
    }

    mint ans= n1-mint(2)*n2+n3;

    cout<<ans<<endl;
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
//---------------------------
using namespace std;
//---------------------------
#define REP(i,n) for(int i = 0; i < (n); i++)
#define P(x) cout << (x) << "\n"

#define MOD 1e9+7
#define PI acos(-1.0)
#define ll long long

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

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

  // ifstream in("input.txt");
  // cin.rdbuf(in.rdbuf());

  int N;cin>>N;
  int a[3][101];
  int e[101] ={};
  int ans=0;
  for(int i=1;i<3;i++){
    for(int j=1;j<=N;j++){
      cin>>a[i][j];
    }
  }

  for(int i=1;i<=N;i++){
    for(int j=1;j<=i;j++){
      e[i] += a[1][j];
    }
    for(int k=i;k<=N;k++){
      e[i] += a[2][k];
    }
    ans=max(e[i],ans);
  }
  // P(e[4]);
  P(ans);

  return 0;
}


Measured memory_bytes: 256
from collections import deque
K = int(input())
cost = [-1] * K
deq = deque([(1,1)])
while deq:
    x, d = deq.popleft()
    if cost[x] >= 0: continue
    cost[x] = d
    if x == 0: break
    for y, c in [(10*x%K, 0), ((x+1)%K, 1)]:
        if c: deq.append((y, d + 1))
        else: deq.appendleft((y, d))
print(cost[0])

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

int main(){
    char s[4];
    for(int i=0;i<4;i++){
        cin >> s[i];
    }
    sort(s,s+4);
    if(s[0]==s[1] && s[2]==s[3] && s[0]!=s[2]){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

  public static void main(String args[]) {
    Scanner sc = new Scanner(System.in);
    int r = sc.nextInt();
    int D = sc.nextInt();
    int x2000 = sc.nextInt();
    
    int oldx = x2000;
    int newx = 0;
    
    for (int i=0;i<10;i++) {
    	newx = oldx * r - D;
    	oldx = newx;
    	System.out.println(newx);    	
    }


  }

}

Measured memory_bytes: 21076
/* ex3_4
   urah  */

#include <stdio.h>

int main(void){
    int num, num_init;

    // 入力を受け取る
    scanf("%d", &num);

    // Nの初期値を保持しておく
    num_init = num;

    // ループを使って解く
    for (int i=1; i <= 9; i++) {
        // 一回でも1~9で割り切れた場合
        if (num % i == 0) { 
            num = num / i;
            for (int j = 1; j <= 9; j++){
                // 商は1~9のいずれかであるか
                if (num == j) {
                    printf("Yes\n");
                    return 0;
                }
            }
            // numをiで割っているのでもとに戻す
            num = num_init;
        }
    }

    printf("No\n");
    return 0;
}


Measured memory_bytes: 128
N = int(input())
A = list(map(int,input().split()))

minus_cnt = 0
abs_sum = 0
min_abs_val = 1000000000
for i in range(N):
    val = A[i]
    abs_val = abs(val)
    abs_sum += abs_val
    if abs_val < min_abs_val:
        min_abs_val = abs_val
    if val < 0:
        minus_cnt += 1

B_max_sum = abs_sum
if minus_cnt % 2 != 0:
    B_max_sum -= (min_abs_val * 2)

print(B_max_sum)



Measured memory_bytes: 20076
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
using namespace std;
#define F first
#define S second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define SZ(x) (int)(x).size()
#define int ll

signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  vector<int> a(8);
  for (int i = 1; i <= 7; i++) {
    cin >> a[i];
  }
  int ans = (a[1] - a[1] % 2) + a[2] + (a[4] - a[4] % 2) + (a[5] - a[5] % 2);
  if (a[1] > 0 && a[4] > 0 && a[5] > 0) {
    ans = max(ans, (a[1] - 1 - (a[1] - 1) % 2) + a[2] + (a[4] - 1 - (a[4] - 1) % 2) + ((a[5] - 1) - (a[5] - 1) % 2) + 3);
  }
  cout << ans << '\n';
} 

Measured memory_bytes: 256
a,b,c,d=list(map(str,input()))
def solve(m,n):
    if eval(m)==7:
        print(m+"=7")
        exit(0)
    elif n<7:
        solve(m,n+2)
        solve(m[:n]+"-"+m[n+1:],n+2)
solve(a+"+"+b+"+"+c+"+"+d,1)

Measured memory_bytes: 3064
x,y,a,b,c = map(int,input().split())
List_a = [int(i) for i in input().split()]
List_b = [int(i) for i in input().split()]
List_c = [int(i) for i in input().split()]
List_a.sort()
List_b.sort()
List_c.sort(reverse =True)
List_a = List_a[-x:]
List_b = List_b[-y:]
h = 0
j = 0
r = 0
k = 0
for i in range(c):
    if x == h:
        r = 1
        k = i
        break
    if y == j:
        r = 2
        k = i
        break
    if List_a[h] < List_b[j]:
        if List_a[h] < List_c[i]:
            List_a[h] = List_c[i]
            h += 1
        else:
            break
    else:
        if List_b[j] < List_c[i]:
            List_b[j] = List_c[i]
            j += 1
        else:
            break
if r == 1:
    for i in range(k,c):
        if List_b[j] < List_c[i]:
            List_b[j] = List_c[i]
            j += 1
        else:
            break
if r == 2:
    for i in range(k,c):
        if List_a[h] < List_c[i]:
            List_a[h] = List_c[i]
            h += 1
        else:
            break
print(sum(List_a)+sum(List_b))      

Measured memory_bytes: 23300
def main():
    MOD = 998244353
    n,k = map(int,input().split())
    LR = []
    for _ in range(k):
        LR.append(tuple(map(int,input().split())))
    
    dp = [0]*(n+1)
    dp[1] = 1
    for i in range(1,n):
        temp = 0
        for l,r in LR:
            ll = max(i+1 - r - 1, 0)
            rr = max(i+1 - l, 0)
            temp+=dp[rr]-dp[ll]
        dp[i+1] = (dp[i] + temp)%MOD
    
    print((dp[n]-dp[n-1])%MOD)
main()

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

ll INF = 1000000000;
vector <int> dy = {0, 1, 0, -1};
vector <int> dx = {1, 0, -1, 0};

int main(){
    int h, w; cin >> h >> w;
    vector <string> s(h);
    int black_cnt = 0;
    rep(i, h){
        cin >> s.at(i);
        for(auto c: s.at(i)){
            if(c == '#') black_cnt ++;
        }
    }

    deque <pair <int, int>> d;
    vector <vector<int>> dist(h, vector<int>(w, INF));

    d.push_back(make_pair(0, 0));
    dist.at(0).at(0) = 0;

    while(!d.empty()){
        auto v = d.front();
        d.pop_front();
        int y, x;
        y = v.first; x = v.second;
        rep(i, 4){
            int ny, nx;
            ny = y + dy.at(i);
            nx = x + dx.at(i);

            if(ny < 0 || ny >= h || nx < 0 || nx >= w) continue;
            if(s.at(ny).at(nx) == '#') continue;
            if(dist.at(ny).at(nx) <= dist.at(y).at(x) + 1) continue;

            dist.at(ny).at(nx) = dist.at(y).at(x) + 1;
            d.push_back(make_pair(ny, nx));
        }
    }

    if(dist.at(h - 1).at(w - 1) == INF){
        cout << -1 << endl;
        return 0;
    }

    //cout << dist.at(h - 1).at(w - 1) << endl;
    cout << h * w - black_cnt - dist.at(h - 1).at(w - 1) - 1 << endl;
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
#define   ft  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define   ll  long long
#define   pi  pair<int,int>
#define   pb  push_back
const int N=2e5+2;
string s,p;

int main()
{
    ft
    ll t,i,j,n,m,k;
    cin>>n>>m>>k;
    t=min(n,k);
    n-=t;
    k-=t;
    t=min(m,k);
    m-=t;
    cout<<n<<" "<<m<<"\n";
    return 0;
}


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

int main(){
   int n;
   string s;
   cin >> n >> s;
   bool flag = true;
   int half = s.size()/2;
   
   if(s.size() % 2 != 0) flag = false;

   if(flag){
     for(int i=0;i < (int)(s.size()/2);i++){
       if(s[i] != s[half+i]) flag = false;
     }
   }
   if (flag) cout << "Yes"<< "\n";
   else cout << "No" << endl;
}

Measured memory_bytes: 256
N, M, K = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

A = [0]
B = [0]
for i in range(len(a)):
    A.append(A[i] + a[i])
for i in range(len(b)):
    B.append(B[i] + b[i])

ans = 0
j = len(B) - 1
for i in range(len(A)):
    if A[i] > K:
        break
    while A[i] + B[j] > K:
        j -= 1
    ans = max(ans, i + j)
print(ans)


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

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

int main() {
  int n;
  cin >> n;
  long long a, b, c;
  a = modpow(10, n, 1000000007);
  b = modpow(9, n, 1000000007);
  c = modpow(8, n, 1000000007);
  if ((a - 2*b + c) % 1000000007 < 0) {
    cout << (a - 2*b + c) % 1000000007 + 1000000007 << endl;
  }
  else {
    cout << (a - 2*b + c) % 1000000007 << endl;
  }
}


Measured memory_bytes: 3616
n=int(input())
a=list(map(int,input().split()))
b = [0] * 10**6
ans=0
for i in range(n):
    if a[i]<(2*(10**5)):
        if i-a[i]>=0:
            ans+=b[i-a[i]]
        b[a[i]+i]+=1
print(ans)

Measured memory_bytes: 32364
#include <stdio.h>
#include <string.h>
#define LEN 100005
typedef struct pp{
  char name[100];
  int t;
} P;

int head, tail, n;
P Q[LEN];

void enquene(P x){
  Q[tail]=x;
  tail=(tail+1)%LEN;
}
P dequene(){
  P x;
  x=Q[head];
  head=(head+1)%LEN;
  return x;
}
int min(int a, int b){
  if(a<b)
	return a;
  else
	return b;
}
int main(){
  int n, q;
  int elaps=0, c;
  int i;
  P u;
  scanf("%d %d", &n, &q);
  for(i=0; i<n; ++i){
	scanf("%s", &Q[i].name);
	scanf("%d", &Q[i].t);
}
  head=0;
  tail=n;
  while(head!=tail){
	u=dequene();
	c=min(q, u.t);
	u.t-=c;
	elaps+=c;
	if(u.t>0)
	  enquene(u);
	else
	  printf("%s %d\n", u.name, elaps);
}
  return 0;
}



Measured memory_bytes: 11860
#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 pq priority_queue
#define P pair<int,int>
#define P2 pair<int,P>
#define P3 pair<int,P2>
typedef long long ll; typedef long double ld;
using namespace std;
const int INF=1e9, MOD=1e9+7, around[]={0,1,1,-1,-1,0,-1,1,0,0};
const ll LINF=1e18;
const ld PI=abs(acos(-1));
int n,q,a,b,c;

struct SegmentTree{
	vector<int> data;
	int sz;
	
	SegmentTree(int n){
		sz = getsize(n);
		data.assign(sz*2, unit());
	}
	
	int unit(){
		return (1LL<<31)-1;
	}
	
	int getsize(int n){
		int ret = 0;
		while((1<<ret)<=n) ret++;
		return (1<<ret);
	}
	
	int update(int k,int x){
		k += sz-1;
		data[k] = x;
		while(k){
			k = (k-1)/2;
			data[k] = min(data[2*k+1], data[2*k+2]);
		}
		
		return 0;
	}
	
	int get(int a,int b){
		return _get(a,b,0,0,sz);
	}
	
	int _get(int a, int b, int k, int l, int r){
		if(b<=l||r<=a) return unit();
		if(a<=l&&r<=b) return data[k];
		
		return min(_get(a,b,2*k+1,l,(l+r)/2), _get(a,b,2*k+2,(l+r)/2,r));
	}
	
	int size(){
		return sz;
	}
	
	int find(int k){
		return data[k];
	}
};

int main(){
	cin >> n >> q;
	SegmentTree seg(n);
	REP(i,0,q){
		cin >> a >> b >> c;
		if(a==0) seg.update(b,c);
		else cout << seg.get(b,c+1) << endl;
	}

	return 0;
}



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

int parse(string a){
	int s=0;
	for(char b:a){
		s*=10;
		s+=b-48;
	}
	return s;
	}
int middle(int a){
	a*=a;
string b=to_string(a);
int o=b.length();
for(int c=0;c<8-o;c++)b="0"+b;
string c="    ";
for(int f=0;f<4;f++)c[f]=b[f+2];
return parse(c);
}
int main(){
int a;
cin>>a;
for(int b=0;b<a;b++){
	printf("Case %d:\n",b+1);
	int c;
	cin>>c;
	for(int d=0;d<10;d++){
		c=middle(c);
		printf("%d\n",c);
	}
}
}

Measured memory_bytes: 3204
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#include <bits/stdc++.h>
using namespace std;
template<class t> inline t read(t &x){
	char c=getchar();bool f=0;x=0;
	while(!isdigit(c)) f|=c=='-',c=getchar();
	while(isdigit(c)) x=(x<<1)+(x<<3)+(c^48),c=getchar();
	if(f) x=-x;return x;
}
template<class t,class ...A> inline void read(t &x,A &...a){
	read(x);read(a...);
}
template<class t> inline void write(t x){
	if(x<0) putchar('-'),write(-x);
	else{if(x>9) write(x/10);putchar('0'+x%10);}
}

#define int long long
#define x first
#define y second
#define pii pair<int,int>

map<int,int> f;
int n,a,b,c,d;

void modify(int x,int v){
	if(f.count(x)) f[x]=min(f[x],v);
	else f[x]=v;
}

void doit(){
	read(n,a,b,c,d);
	f.clear();
	f[n]=0;
	while(1){
		auto it=--f.end();
		int n=it->x,v=it->y;
		if(!n){
			write(v);puts("");
			return ;
		}
		for(int x:{2,3,5}){
			int y=x==2?a:x==3?b:c;
			modify(n/x,v+y+d*(n%x));
			modify(n/x+1,v+y+d*(x-n%x));
		}
		if(n<1000000000000000000/d) modify(0,v+n*d);
		f.erase(it);
	}
}

signed main(){
	int t;
	read(t);
	while(t--) doit();
}

Measured memory_bytes: 3692
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <climits>
#include <assert.h>
#include <queue>

using namespace std;

int main()
{
    int a;
    cin >> a;
    cout << a + a * a + a * a * a << "\n";
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
const ll mod=1000000007;
const ll INF=1e15;
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define U_ERASE(V) V.erase(unique(ALL(V)), V.end());
#define pb push_back
#define mp make_pair
typedef pair<ll,ll> P;
vec dx={1,0,-1,0};
vec dy={0,1,0,-1};

int main(){
  ll N; cin>>N;
  vector<string> d(N);
  rep(i,N) cin>>d.at(i);
  sort(ALL(d));

  ll MAX=1;
  string memory="A";
  ll count=0;
  vector<pair<ll,string>> ans;
  rep(i,N){
    if(memory==d.at(i)) count++;
    else{
      ans.pb(mp(count,memory));
      MAX=max(MAX,count);
      memory=d.at(i);
      count=1;      
    }
  }
  ans.pb(mp(count,memory));
  MAX=max(MAX,count);
  sort(ALL(ans));
  reverse(ALL(ans));
  count=0;
  vector<string> ans1;
  while(true){
    ans1.pb(ans.at(count).second);
    count++;
    if(ans.at(count).first<MAX) break;
  }
  sort(ALL(ans1));
  rep(i,ans1.size()) cout<<ans1.at(i)<<endl;
  

 
}

Measured memory_bytes: 21232
#include<iostream>
#include<map>
#include<string>
#include<algorithm>

using namespace std;
typedef pair<int, string> P;
map<P, int> d;

int main(){
    int n, p;
    string c;
    cin >> n;
    for(int i = 0;i < n;i++){
	cin >> c >> p;
	d[P(c.size(), c)] += p;
    }
    map<P, int>::iterator it = d.begin();
    while(it != d.end()){
	cout << (*it).first.second << " " << (*it).second << endl;
	it++;
    }
    return 0;
}

Measured memory_bytes: 1220
//----AUTHOR:kkdrummer----/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include<ext/rope>
using namespace __gnu_cxx;
using namespace __gnu_pbds;
using namespace std;
typedef    long long   ll;
typedef    long double   ld;
//typedef    unordered_set<ll>   usll;
//typedef    unordered_multiset<ll>   umsll;
typedef    multiset<ll>   msll;
typedef    set<ll>   sll;
typedef    vector<ll>   vll;
typedef    pair<ll,ll>   pll;
typedef    vector<pll>   vpll;
typedef    priority_queue<ll>   pqll;
typedef    vector<int>   vi;
typedef    set<int>   si;
typedef    multiset<int>   msi;
//typedef    unordered_multiset<int>   umsi;
//typedef    unordered_set<int>   usi;
typedef     pair<int,int>   pi;
typedef    vector<pi>   vpi;
typedef    pair<double,double>   pd;
typedef    vector<pd>   vpd;
typedef    priority_queue<int>   pqi;
typedef    tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>   ind_set;
typedef    tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>   ind_setll;
#define    in   insert
#define    fi   first
#define    se   second
#define    pb   push_back
#define    mp   make_pair
#define    be   begin
#define    en   end
#define    itr   iterator
#define io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define    mo   1000000007
#define    inf  9223372036854775807
#define    ninf   -inf
#define    ima   2147483647
#define    imi   -ima
#define    oncnt    __builtin_popcount
#define    zerobegin   __builtin_clz
#define    zeroend   __builtin_ctz
#define    parity   __builtin_parity
#define all(x) x.be(),x.en()
#define    eps   1e-9
#define    coutd   cout<<setprecision(10)<<fixed
const    ld   PI=3.14159265359;
inline ll modpow(ll x,ll n){if(n==0)return 1;if(n==1)return(x%mo);ll u=(modpow(x,n/2));u=(u*u)%mo;if(n%2!=0)u=(u*x%mo)%mo;return u;}
inline ll modinv(ll x){return modpow(x,mo-2);}
inline ll mmul(ll a,ll b){    if(a>=mo)a=a%mo;if(b>=mo)b=b%mo;if(a*b>=mo)return(a*b)%mo;return(a*b);}
inline ll madd(ll a, ll b){if(a>=mo)a=a%mo;if(b>=mo)b=b%mo;if(a+b>=mo)return(a+b)%mo;return(a+b);}
inline ll msub(ll a, ll b){if(a>=mo)a=a%mo;if(b>=mo)b=b%mo;return(((a-b)%mo+mo)%mo);}
inline ll mdiv(ll a,ll bb){if(a>=mo)a=a%mo;ll b=modinv(bb);if(b>=mo)b=b%mo;if(a*b>=mo)return(a*b)%mo;return(a*b);}
inline ll gcd(ll a,ll b){return __gcd(a,b);}



int main()
{
io
int testcases=1;//cin>>testcases;
while(testcases--)
{
ld r;
cin>>r;
ld ans=(2*PI*r);
coutd<<ans;











}return 0;}

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

#define FOR(x,n) for(int x=0;x<n;x++)
#define mp make_pair
typedef long long ll;
typedef pair<int,int> iPair;

vector<int>* tree;
int* lazy;

void dfs(int curr, int prev) {
  for(auto x : tree[curr]) {
    if(x == prev) continue;
    lazy[x] += lazy[curr];
    dfs(x, curr);
  }
}

int main() {
  int N,Q;
  scanf("%d%d", &N, &Q);
  
  tree = new vector<int>[N];
  lazy = new int[N];
  memset(lazy, 0, N*sizeof(int));

  FOR(i,N-1) {
    int a,b;
    scanf("%d%d", &a, &b);
    tree[a-1].push_back(b-1);
    tree[b-1].push_back(a-1);
  }

  FOR(i,Q) {
    int a,b;
    scanf("%d%d", &a, &b);
    lazy[a-1] += b;
  }

  dfs(0, -1);
  FOR(i,N) cout << lazy[i] << ' ';
}


Measured memory_bytes: 23424
#include <bits/stdc++.h>
#include <stdio.h>
#include <ctype.h>
#pragma GCC optimize ("Ofast")

#define repk(i,a,b) for(int i=(a);i<=(b);++i)
#define FOR(i,n)  for(int i=0;i<=(n);++i)
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define for1(i,n)  for(int i=1;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
#define ll long long
#define ld long double
#define point pair<double,double>
#define pii pair<int,int>
#define F first
#define S second
#define vi vector<int>
#define vl vector<ll>
const int  inf = INT_MAX;
const int MOD = 1000000007;
const int N = 100100;

using namespace std;


void sol() {
	int x1, x2, x3, x4, x5; cin >> x1 >> x2 >> x3 >> x4 >> x5;
	if (x1 == 0)
		cout << 1;
	else if (x2 == 0)
		cout << 2;
	else if (x3 == 0)
		cout << 3;
	else if (x4 == 0)
		cout << 4;
	else if (x5 == 0)
		cout << 5;



}



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

// #ifndef ONLINE_JUDGE
// 	freopen("input.txt", "r", stdin);
// 	freopen("output.txt", "w", stdout);
// #endif
	int t = 1; // cin >> t;
	while (t--)
		sol();
	return 0;
}


Measured memory_bytes: 3656
O = input()
E = input()
ans = ""
if len(O) - len(E) == 0:
    for i in range(0, len(O)):
        ans += O[i]
        ans += E[i]
else:
    for i in range(0, len(E)):
        ans += O[i]
        ans += E[i]
    ans += O[-1:]

print(ans)


Measured memory_bytes: 2940
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		// TODO ?????????????????????????????????????????????
		BufferedReader insBR = new BufferedReader(new InputStreamReader(System.in));
		
		//?????????????????????????´?????????????
		int[] aryDice = new int[6];
		//????????????????????????
		String[] ary = insBR.readLine().split(" ");
		//int???????????????????????£??\
		for(int i = 0; i < ary.length; i++){
			aryDice[i] = Integer.parseInt(ary[i]);
		}
		 
		//????????????????????????(?????????1????????\?????????)
		String[] aryDirection = insBR.readLine().split("");
		//Dice ????????????????????????
		Dice dice = new Dice();
		//??????????????????????????????????????????
		dice.setAryDice(aryDice);
		for(int i = 0; i < aryDirection.length; i++){
			 dice.roll(aryDirection[i]);
		}
		aryDice = dice.getAryDice();
		//System.out.print("diceTop:");
		System.out.println(aryDice[0]);
	}

////?????????????????????????????????	
	static class Dice {
		
		//?????£?????????
		
		//???????????????????????????????????????????´?????????????
		private int [] aryDice = new int[6];
		
		//?????????????????????Dice
		Dice(){
		}
		//Method ????§?????????°??§??????????????????????????????????????????
		public void roll(String direction){
			//??£??\?????????????????¨??????????????¨
			int temp = 0;
			if("S".equals(direction)){
				temp = aryDice[0];
				aryDice[0] = aryDice[4];
				aryDice[4] = aryDice[5];
				aryDice[5] = aryDice[1];
				aryDice[1] = temp;
			}else if("E".equals(direction)){
				temp = aryDice[0];
				aryDice[0] = aryDice[3];
				aryDice[3] = aryDice[5];
				aryDice[5] = aryDice[2];
				aryDice[2] = temp;
			}else if("W".equals(direction)){
				temp = aryDice[0];
				aryDice[0] = aryDice[2];
				aryDice[2] = aryDice[5];
				aryDice[5] = aryDice[3];
				aryDice[3] = temp;
			}else if("N".equals(direction)){
				temp = aryDice[0];
				aryDice[0] = aryDice[1];
				aryDice[1] = aryDice[5];
				aryDice[5] = aryDice[4];
				aryDice[4] = temp;
			}
		
		}
		//Method set get
		public int[] getAryDice() {
			return aryDice;
		}
		public void setAryDice(int[] aryDice) {
			this.aryDice = aryDice;
		}
		
	}//??????????????????
}

Measured memory_bytes: 17032
#include <iostream> // cin,cout
#include <stdio.h> // printf,scanf (standard input/output)
#include <string>
#include <algorithm> // min,max
using namespace std;

int main(){
    int X, Y;
    
    cin >> X >> Y;
    
    cout << X+Y/2 << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <utility>
#include <tuple>
#define INF 0x3f3f3f3f
#define MOD 1000000007
#define PI 4*atan(1.0)
typedef long long ll;
typedef long double ld;
using namespace std;
int dx[4]={0,0,-1,1};
int dy[4]={-1,1,0,0};

int main(){
	int W,H,N;
	cin>>W>>H>>N;
	bool rec[101][101]={};
	for(int i=0;i<N;i++){
		int x,y,a;
		cin>>x>>y>>a;
		switch(a){
			case 1:
				for(int j=1;j<=H;j++)for(int k=1;k<=W;k++)
					if(k<=x)
						rec[j][k]=1;
				break;
			case 2:
				for(int j=1;j<=H;j++)for(int k=1;k<=W;k++)
					if(k>x)
						rec[j][k]=1;
				break;
			case 3:
				for(int j=1;j<=H;j++)for(int k=1;k<=W;k++)
					if(j<=y)
						rec[j][k]=1;
				break;
			case 4:
				for(int j=1;j<=H;j++)for(int k=1;k<=W;k++)
					if(j>y)
						rec[j][k]=1;
				break;
		}
	}
	int ans=0;
	for(int i=1;i<=H;i++)for(int j=1;j<=W;j++)
		if(!rec[i][j])
			ans++;
	cout<<ans<<endl;
	/*
	for(int i=1;i<=H;i++){
		for(int j=1;j<=W;j++){
			cout<<rec[i][j];
		}
		cout<<endl;
	}
	*/
	return 0;
}

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

using namespace std;

int n;

int main()
{
	int i, t;
	
	scanf("%d", &n);
	
	if(n < 3 || ((~n & 1) && (n & n - 1) == 0)){
		printf("No\n");
		return 0;
	}
	
	printf("Yes\n");
	
	if(n & 1){
		printf("1 2\n2 3\n3 %d\n%d %d\n%d %d\n", n + 1, n + 1, n + 2, n + 2, n + 3);
		
		for(i=4; i<n; i+=2){
			printf("1 %d\n%d %d\n1 %d\n%d %d\n", i, i, i + 1, n + i + 1, n + i + 1, n + i);
		}
	}
	else{
	}
	
	if(~n & 1){
		t = (n & -n);
		
		for(i=2; i<n; i+=2){
			if(i == t){
				printf("1 %d\n%d %d\n%d %d\n%d %d\n%d %d\n", i, i, i + 1, i + 1, n + 1, n + 1, n + i, n + i, n + i + 1);
			}
			else{
				printf("1 %d\n%d %d\n1 %d\n%d %d\n", i, i, i + 1, n + i + 1, n + i + 1, n + i);
			}
		}
		
		printf("%d %d\n%d %d\n", n, n + n - t + 1, t, n + n);
	}
	
	return 0;
}

Measured memory_bytes: 2304
using System;
using System.Linq;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		List<int> input = IO.GetIntList();
		int h = input[0];
		int n = input[1];
		List<int> a= IO.GetIntList();
		
		a.ForEach(x => h -= x);

		Console.WriteLine((h<=0)?"Yes":"No");
	}

}

static class IO
{
    static public string GetString() { return Console.ReadLine(); }
    static public int GetInt() { return int.Parse(Console.ReadLine()); }
    static public long GetLong() { return long.Parse(Console.ReadLine()); }
    static public List<string> GetStringList() { return Console.ReadLine().Split(' ').ToList(); }
    static public List<int> GetIntList() { return Console.ReadLine().Split(' ').Select(int.Parse).ToList(); }
    static public List<long> GetLongList() { return Console.ReadLine().Split(' ').Select(long.Parse).ToList(); }
    static public List<double> GetDoubleList() { return Console.ReadLine().Split(' ').Select(double.Parse).ToList(); }
    static public void WriteStrings<T>(IEnumerable<T> values) { foreach (var o in values) { Console.Write(o + " "); } }
}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

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

signed main(){
    int a,b,x;
    cin>>a>>b>>x;
    if(a<=x&&x<=a+b){
        cout<<"YES"<<endl;
    }
    else{
        cout<<"NO"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
/**
 * @copyright (c) 2020 Daisuke Hashimoto
 */

#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using P = pair<int32_t, int32_t>;

int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  int32_t a[3];
  cin >> a[0] >> a[1] >> a[2];
  sort(a, a + 3);
  std::cout << a[0] << " " << a[1] << " " << a[2] << std::endl;
  return 0;
}



Measured memory_bytes: 3164
from __future__ import division, print_function
import sys
if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip

import os, sys, bisect, copy
from collections import defaultdict, Counter, deque
#from functools import lru_cache   #use @lru_cache(None)
if os.path.exists('in.txt'): sys.stdin=open('in.txt','r')
if os.path.exists('out.txt'): sys.stdout=open('out.txt', 'w')
#
def input(): return sys.stdin.readline()
def mapi(arg=0): return map(int if arg==0 else str,input().split())
#------------------------------------------------------------------

a = list(input().strip())
n = len(a)
for i in range(n):
    if a[i] =="?":
        a[i] = "D"
print("".join(a))


Measured memory_bytes: 72180
#include<bits/stdc++.h>
using namespace std;
string ss;
int w,n,e,s;
inline bool check()
{
    if(w!=0&&e!=0&&n!=0&&s!=0)return 1;
    if(w!=0&&e!=0&&n==0&&s==0)return 1;
    if(w==0&&e==0&&n!=0&&s!=0)return 1;
    if(w==0&&e==0&&n==0&&s==0)return 1;
    return 0;
}
int main()
{
    cin>>ss;
    for(int i=0;i<ss.length();i++){
    	if(ss[i]=='W')w++;
	    else if(ss[i]=='N')n++;
	    else if(ss[i]=='E')e++;
	    else if(ss[i]=='S')s++;
	}
    if(check()){
    	printf("Yes\n");
	}
	else{
		printf("No\n");
	}
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
  int a[5];
  cin >> a[0] >> a[1] >> a[2] >> a[3] >> a[4];
  int add=10;
  int temp=0;
  rep(i,5){
    if(a[i]%10!=0){
      add=min(add,a[i]%10);
      if(add==a[i]%10)temp=i;
    }
  }
  rep(i,5){
    if(i==temp)continue;
   while(a[i]%10!=0)a[i]++; 
  }
  int sum=0;
  rep(i,5){
    sum+=a[i];
  }
  cout << sum << endl;
return 0;}


Measured memory_bytes: 256
s = input()

for i,ch in enumerate(s):
  if ch=='A':
    idx_1 = i
    break
  
for i,ch in enumerate(s[::-1]):
  if ch=='Z':
    idx_2 = len(s) - i - 1
    break
    
print(idx_2 - idx_1 + 1)   

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

int main(){
    int n;
    long long a;
    long long max = -1000000;
    long long min = 1000000;
    long long sum = 0;
    
    cin >> n;
    
    for(int i=1; i<=n; i+=1){
        cin >> a;
        if (a > max) max = a;
        if (a < min) min = a;
        sum = sum + a;
    }
    
    cout << min << " " << max << " " << sum << endl;
    
    return 0;
}


Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
#define ld long double
#define ll long long
#define pb push_back
#define F first
#define S second
#define X real()
#define Y imag()
#define EPS 1e-10
#define pi acos(-1)
#define vec(a,b) (b)-(a)
#define ec_norm(a) (a).X*(a).X+(a).Y*(a).Y
#define norm(a) hypot((a).X,(a).Y)
#define angle(a) atan2((a).Y,(a).X)
#define dot(a,b) (conj(a)*(b)).X
#define cross(a,b) (conj(a)*(b)).Y
#define rotate(a,b,ang) ((b)-(a))*exp(point(0,(ang)))+(a)
#define reflect(p,a,b) conj(((p)-(a))/((b)-(a)))*((b)-(a))+(a)
typedef complex<ld> point;
const int A = 3e3 + 2;
const int mod = 1e9 + 7;
int n;
ld a[A], dp[A][A];
bool vis[A][A];
ld solve(int ind, int rem) {
    if (ind == n) return !rem;
    if (vis[ind][rem])
        return dp[ind][rem];
    vis[ind][rem] = 1;
    ld ret = solve(ind + 1, rem - 1) * a[ind] + solve(ind + 1, rem) * (1 - a[ind]);
    return dp[ind][rem] = ret;
}
int main() {
    ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);

    cin >> n;
    for (int i = 0; i < n; i++)
        cin >> a[i];
    ld ans = 0;
    for (int i = n / 2 + 1; i <= n; i++) {
        ans += solve(0, i);
    }
    cout << setprecision(9) << fixed << ans;
    return 0;
}

Measured memory_bytes: 141316
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int size = Integer.parseInt(scanner.next());
        int quantum = Integer.parseInt(scanner.next());
        int sum = 0;
        Queue queue = new Queue();
        for (int i = 0; i < size; i++) {
            String name = scanner.next();
            int time = Integer.parseInt(scanner.next());
            if (time <= quantum) {
                sum += time;
                System.out.println(name + " " + sum);
            } else {
                sum += quantum;
                queue.enqueue(new Process(name, time - quantum));
            }
        }

        while (!queue.isEmpty()) {
            Process process = queue.dequeue();
            if (process.quantum <= quantum) {
                sum += process.quantum;
                System.out.println(process.name + " " + sum);
            } else {
                sum += quantum;
                queue.enqueue(new Process(process.name, process.quantum - quantum));
            }
        }
    }

    static class Queue {
        static final int SIZE = 100000;
        Process[] array = new Process[SIZE];
        int head = 0;
        int tail = 0;

        Process dequeue() {
            if (isEmpty()) {
                throw new IllegalStateException("You dequeued from empty " +
                        "queue.");
            }
            Process value = array[tail];
            tail += 1;
            if (tail == SIZE) {
                tail -= SIZE;
            }
            return value;
        }

        void enqueue(Process process) {
            if (isFull()) {
                throw new IllegalStateException("You enqueued to full queue.");
            }
            array[head] = process;
            head += 1;
            if (head == SIZE) {
                head -= SIZE;
            }
        }

        boolean isFull() {
            return head + 1 == (tail % SIZE);
        }

        boolean isEmpty() {
            return head == tail;
        }
    }

    static class Process {
        String name;
        int quantum;

        Process(String name, int quantum) {
            this.name = name;
            this.quantum = quantum;
        }
    }
}

Measured memory_bytes: 69252
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

string s;
int cnt;
bool used[26];

int main(void)
{
	cin >> s;
	
	for(int i = 0; i < s.size(); i++){
		used[s[i]-'a'] = true;
		cnt++;
	}
	
	if(cnt < 26){
		for(int i = 0; i < 26; i++){
			if(!used[i]){
				cout << s + (char)('a' + i) << endl;
				return 0;
			}
		}
	}
	
	string t = s;
	if(next_permutation(s.begin(), s.end())){
		for(int i = 0; i < s.size(); i++){
			cout << s[i];
			if(s[i] != t[i]) break;
		}
		cout << endl;
	}else{
		cout << -1 << endl;
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main(String args[]){
    Scanner scan = new Scanner(System.in);
    long x = scan.nextInt();//横
    long y = scan.nextInt();//縦

    double z = (double)x*y/2;
    long answer = (long)Math.round(z);
    if(x == 1 || y == 1){
      answer = 1;
    }
    System.out.println(answer);
  }
}

Measured memory_bytes: 21716
#include <iostream>
using namespace std;
void ABC110(void);
void ABC111(void);
void ABC112(void);
void ABC113(void);
void ABC114(void);
void ABC115(void);
void ABC116(void);
void ABC117(void);
void ABC118(void);
void ABC119(void);

int main(void){
    ABC118();
}

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define N 201
using namespace std;
typedef pair<int,int> P;
int h,w;
int dx[]={0,0,1,-1};
int dy[]={1,-1,0,0};
string mp[N];

int bfs(char s){
  queue<P> Q;
  int D[N][N]={};
  for(int i=0;i<h;i++)
    for(int j=0;j<w;j++) 
      if(mp[i][j]==s)Q.push(P(i,j)),D[i][j]=1;

  while(!Q.empty()){
    P t=Q.front();Q.pop();
    int y=t.first,x=t.second;
    if(mp[y][x]=='\%') return D[y][x];
    for(int i=0;i<4;i++){
      int ny=y+dy[i],nx=x+dx[i];
      if(nx<0||ny<0||nx>=w||ny>=h||D[ny][nx]||mp[ny][nx]=='#')continue;
      Q.push(P(ny,nx));
      D[ny][nx]=D[y][x]+1;
    }
  }
  return 1e9;
}

int main(){
  cin>>h>>w;
  for(int i=0;i<h;i++)cin>>mp[i];
  cout <<((bfs('@')<bfs('$'))? "Yes":"No")<<endl;

  return 0;
}

Measured memory_bytes: 3464