akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(unique(all(x)), x.end());
typedef long long ll;
typedef complex<double> Complex;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
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;
}
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

int main() {
    string s;
    int k;
    cin >> s >> k;
    int n = sz(s);
    auto dp0 = make_vec<int>(n + 10, 10);
    auto dp1 = make_vec<int>(n + 10, 10);
    dp1[0][0] = 1;
    rep(i, n) {
        rep(j, 4) {
            // 0以外のとき
            dp0[i + 1][j + 1] += 9 * dp0[i][j];
            // 0のとき
            dp0[i + 1][j] += dp0[i][j];

            int d = s[i] - '0';
            if (d == 0) {
                dp1[i + 1][j] += dp1[i][j];
            } else {
                // 0のとき
                dp0[i + 1][j] += dp1[i][j];
                // 1以上d未満のとき
                dp0[i + 1][j + 1] += (d - 1) * dp1[i][j];
                // dのとき
                dp1[i + 1][j + 1] += dp1[i][j];
            }
        }
    }
    cout << dp0[n][k] + dp1[n][k] << endl;
}

Measured memory_bytes: 256
def main():
    # 下、右、上、左
    dy = [1, 0, -1, 0]
    dx = [0, 1, 0, -1]
    H, W = map(int, input().split())
    s = ["." * (W + 2)]
    s += ["." + input() + "." for i in range(H)]
    s.append("." * (W + 2))
    for y in range(1, H + 1):
        for x in range(1, W + 1):
            if s[y][x] == ".":
                continue
            if "." == s[y + dy[0]][x + dx[0]]\
                    == s[y + dy[1]][x + dx[1]]\
                    == s[y + dy[2]][x + dx[2]]\
                    == s[y + dy[3]][x + dx[3]]:
                print("No")
                return
    print("Yes")
    return


main()


Measured memory_bytes: 3064
<?php
list($num,$score,$correct)=explode(" ",trim(fgets(STDIN)));
$array=[];
$result=array_pad($array,$num,$score-$correct);


for($i=0;$i<$correct;$i++){
     $human=trim(fgets(STDIN));
     $result[$human-1]++;
}

for($j=0;$j<count($result);$j++){
    echo ($result[$j]>0)? "Yes"."\n":"No"."\n";
}
?>

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

typedef struct{
  int ai = 0,b = 0,c = 0,d = 0;
}ten;

int main (void){
  int n = 0,m = 0,q = 0,s = 0,max = 0;
  cin >> n >> m >> q;
  int a[10];
  vector<ten> t(q);
  a[0] = 1;

  for(int i = 0;i < q;i++){
    cin >> t[i].ai >> t[i].b >> t[i].c >> t[i].d;
    }

  for(int i = 1;i <= m;i++){
    a[1] = i;
    for(int j = i;j <= m;j++){
      a[2] = j;
      for(int k = j;k <= m;k++){
        a[3] = k;
        for(int l = k;l <= m;l++){
          a[4] = l;
          for(int o = l;o <= m;o++){
            a[5] = o;
            for(int p = o;p <= m;p++){
              a[6] = p;
              for(int r = p;r <= m;r++){
                a[7] = r;
                for(int u = r;u <= m;u++){
                  a[8] = u;
                  for(int v = u;v <= m;v++){
                    a[9] = v;
                    for(int w = 0;w < q;w++){
                      if(a[t[w].b -1+10-n] - a[t[w].ai -1+10-n] == t[w].c){
                        s = s + t[w].d;
                      }
                    }
                    if(max < s){
                      max = s;
                    }
                    s = 0;
                  }
                  if(n <= 2){break;}
                }
                if(n <= 3){break;}
              }
              if(n <= 4){break;}
            }
            if(n <= 5){break;}
          }
          if(n <= 6){break;}
        }
        if(n <= 7){break;}
      }
      if(n <= 8){break;}
    }
    if(n <= 9){break;}
  }

  cout << max << endl;
  return 0;
}


Measured memory_bytes: 3584
#include<bits/stdc++.h>
using namespace std;
const int N = 2e5+5;
int fa[N];
int num[N];

int getfa(int x)
{
    return fa[x]==x?x:(fa[x]=getfa(fa[x]));
}
int main()
{
    int n,m,x,y,fx,fy,res=1;
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++)fa[i]=i,num[i]=1;
    for(int i=1;i<=m;i++)
    {
        scanf("%d%d",&x,&y);
        if(x>y)swap(x,y);
        fx=getfa(x),fy=getfa(y);
        if(fx!=fy)
        {
            num[fx]+=num[fy];
            res=max(res,num[fx]);
            fa[fy]=fx;
        }
    }
    printf("%d\n",res);
    return 0;
}


Measured memory_bytes: 5372
#include<bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define INF LLONG_MAX
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
#define IN(a,n) rep(i,n){ cin>>a[i]; }
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
#define vi vector<int>
#define IP pair<int,P>
#define PP pair<P,P>
#define Yes(f){cout<<(f?"Yes":"No")<<endl;}
#define YES(f){cout<<(f?"YES":"NO")<<endl;}

int a[510][510];

void f(int l,int r,int k){
  if(r-l==1) return;
  int m=(l+r)/2;

  FOR(i,l,m){
    FOR(j,m,r){
      a[i][j]=k;
    }
  }

  f(l,m,k+1);
  f(m,r,k+1);
}

signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);

  int n;
  cin>>n;

  f(0,n,1);

  rep(i,n){
    FOR(j,i+1,n){
      cout<<a[i][j]<<' ';
    }
    cout<<endl;
  }


}

Measured memory_bytes: 2432
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
int main(){
    string s,t;
    cin>>s;
    cin>>t;
    for(int i=0;i<s.size();i++){
        if(s[i]!=t[i]){
            cout<<"No";
            return 0;
        }
    }
    cout<<"Yes";
    }


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define int long long
#define F first
#define S second
/*#define F second
#define S first*/
using namespace std;
const int N=1e5+1;
int dp[101][N];
pair<int ,int> a[N];
main()
{
    int n,m;
    scanf("%lld%lld",&n,&m);
    for(int i=1;i<=n;i++){
        scanf("%lld%lld",&a[i].F,&a[i].S);
    }
    sort(a+1,a+n+1);
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            if(j<a[i].F){
                dp[i][j]=dp[i-1][j];
            }
            else{
                dp[i][j]=max(a[i].S+dp[i-1][j-a[i].F],dp[i-1][j]);
            }
        }
    }
    printf("%lld",dp[n][m]);
}


Measured memory_bytes: 78720
import math

N=int(input())
P=list(map(int,input().split()))
Q=list(map(int,input().split()))

p=0
q=0

for i in range(N):
  n = P[i]-1
  
  for j in range(i):
    if P[j]<P[i]:
      n -= 1
  
  p += n*math.factorial(N-(i+1))

for i in range(N):
  n = Q[i]-1
  
  for j in range(i):
    if Q[j]<Q[i]:
      n -= 1
  
  q += n*math.factorial(N-(i+1))

print(abs(p-q))

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

using namespace std;

int main() {
    string s, t;
    int count =0;
    cin >> s >> t;
    if (s[0] == t[0])
        count++;
    if (s[1] == t[1])
        count++;
    if (s[2] == t[2])
        count++;
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 888
#include <iostream>
#include <climits>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
 
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

#define MOD 1000000007LL

int n;
ll d;

int main()
{
  ll ans=0;
  ll x,y;

  cin >> n >> d;

  for (int i=0; i<n; i++) {
    cin >> x >> y;
//printf("d^2 = %lld x^2 = %lld, y^2 = %lld\n", d*d, x*x, y*y);
    if (d*d >= x*x+y*y) ans++;
  }

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


Measured memory_bytes: 3620
#include <bits/stdc++.h>
#include <cassert>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
/*
struct Edge
{
    int to;
    int weight;
    Edge(int t, int w) : to(t), weight(w) {}
};
using Graph = vector<vector<Edge>>;
*/
using Graph = vector<vector<int>>;

const long long INF = 1LL << 60;
const int INT_INF = 1000000000;

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

vector<vector<int>> d(210, vector<int>(210, INT_INF));

void warshallFloyd(int n)
{
    for (int k = 0; k < n; k++) // 経由する頂点
    {
        for (int i = 0; i < n; i++) // 始点
        {
            for (int j = 0; j < n; j++) // 終点
            {
                d[i][j] = min(d[i][j], d[i][k] + d[k][j]); // 距離
            }
        }
    }
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N, M, R;
    cin >> N >> M >> R;
    vector<int> r(R);
    for (auto &it : r) {
        cin >> it;
        it--;
    }
    for (int i = 0; i < M; i++)
    {
        int A, B, C;
        cin >> A >> B >> C;
        A--, B--;
        d[A][B] = d[B][A] = C;
    }

    for (int i = 0; i < N; i++)
        d[i][i] = 0;
    warshallFloyd(N);

    int ans = INT_INF;
    vector<int> v(R);
    iota(v.begin(), v.end(), 0);
    do
    {
        int tmp = 0;
        for (int i = 1; i < R; i++)
            tmp += d[r[v[i]]][r[v[i - 1]]];
        ans = min(ans, tmp);
    } while (next_permutation(v.begin(), v.end()));
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3780
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(int i=0;i<N;++i)
typedef long long int LL;

int N;

int main()
{
	in >> N;
	rep(loop, N)
	{
		int K, P;
		in >> K >> P;
		out << (K%P == 0 ? P : K % P) << std::endl;
	}
	return 0;
}


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

int main(void){
  int n;
  cin >> n;
  int ans = 1e9;
  int a[n];
  for(int i = 0; i < n; i++) cin >> a[i];
  sort(a, a + n);
  for(int i = a[0]; i <= a[n- 1]; i++){
    long long sum = 0;
    for(int j = 0; j < n; j++){
      sum += pow((i - a[j]), 2);
    }
    ans = (ans < sum) ? ans : sum;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <array>
#include <cassert>
#include <bitset>
#include <cstdint>
using namespace std;
using LL = long long;

int N, K;
string S;

int main() {
	cin >> N >> K;
	cin >> S;
	S.push_back('X');
	int G = 0;
	for (int i = 0; i < N; ++i) {
		if (S[i] != S[i + 1]) {
			G++;
		}
	}
	for (int j = 0; j < K; ++j) {
		if (G >= 3) {
			G -= 2;
		}
		else if(G == 2){
			G--;
		}
	}
	cout << N - G << endl;
	return 0;
}

Measured memory_bytes: 512
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val h = readLine()!!.split(' ').map { it.toInt() }.toMutableList()
    for (i in n - 2 downTo 0) {
        if (h[i] - 1 > h[i + 1]) {
            println("No")
            return
        } else if (h[i] - 1 == h[i + 1]) {
            h[i]--
        }
    }
    println("Yes")
}

Measured memory_bytes: 57888
main = do
    ss <- getLine
    let (a,op,b) = readExpr $ words ss
    if op == "?"
        then return ()
        else do
            print $ calc op a b
            main

calc x y z
  | x == "+" = y+z
  | x == "-" = y-z
  | x == "*" = y*z
  | x == "/" = y `div` z
  | otherwise = 0

readExpr :: [String] -> (Int, String, Int)
readExpr ws = (a, op, b)
    where
        a = read (head ws) :: Int
        b = read (last ws) :: Int
        op = (head . tail) ws


Measured memory_bytes: 4024
#include <string>
#include <iostream>
#include <stack>
#include <queue> // priority_queue も入ってる
#include <set>   // 要素数は size() で取得 multisetもある
#include <map>
#include <array> // sizeはコンパイル時定数で固定
#include <vector>
#include <numeric>   // accumulate, gcd
#include <algorithm> // count_ifに必要
#include <iomanip>   // cout << setprecision(15) << x で小数の出力精度を指定
#include <tuple>
#include <utility> //pair
#include <cmath>
#include <random>

using namespace std;
// 問題が起こるまでintは使用禁止2020-04-13
using ll = long long;

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

template <class InputIterator, class T>
bool contains_itr(InputIterator iterator, const T &value)
{
    if (find(iterator.begin(), iterator.end(), value) == iterator.end())
        return false;
    else
        return true;
}

template <class T>
bool contains_set(set<T> st, const T &value)
{
    if (st.find(value) == st.end())
    {
        return false;
    }
    else
    {
        return true;
    }
}

template <class InputIterator>
auto sum(InputIterator iterator)
{
    return accumulate(iterator.begin(), iterator.end(), 0);
}

// endは排他的(exclusive)なので注意
vector<ll> range(ll begin, ll end)
{
    vector<ll> result;
    for (ll i = begin; i < end; ++i)
    {
        result.push_back(i);
    }
    return result;
}

random_device seed_gen;
mt19937 engine(seed_gen());
// 0, 1, 2 のどれかが得られる一様分布
// uniform_int_distribution<> dist(0, 2);
// cout << dist(engine) << endl;
// みたいに、先に確率分布を宣言して、そこにengineを与えて使う。

// =========ここまでテンプレ============

int main()
{
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << max(a * c, max(a * d, max(b * c, b * d))) << endl;
    return 0;
}

Measured memory_bytes: 3192
#include<stdio.h>
int main(void)
{
	char a[100][100];
	int b[100],c[100],x[100];
	int i,j;
    for(i=0;i<9;i++){
        scanf("%s %d %d",a[i],&b[i],&c[i]);
    }  
	for(i=0;i<9;i++){
		x[i]=b[i]+c[i];
		c[i]=b[i]*200+c[i]*300;
	}
	for(i=0;i<9;i++) printf("%s %d %d\n",a[i],x[i],c[i]);
	return 0;
}

Measured memory_bytes: 2572
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second
#define mp make_pair
 
const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll INF = 1ll << 60;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int N, A[int(2e5 + 5)];
vector <int> Graph[int(2e5 + 5)];
int DP[int(2e5 + 5)], ans[int(2e5 + 5)];


int DFS(int node){
  int Index, Before;
  if (A[node] <= DP[0]){
    Index = 0; Before = DP[0];
    DP[0] = A[node];
  }else{
    int L = 0, R = N;
    while (R - L > 1){
      int Mid = (L + R) / 2;
      if (DP[Mid] < A[node]) L = Mid;
      else R = Mid;
    }
    Index = R; Before = DP[R];
    DP[R] = A[node];
  }

  int L = 0, R = N;
  while (R - L > 1){
    int Mid = (L + R) / 2;
    if (DP[Mid] > 1e9) R = Mid;
    else L = Mid;
  }
  ans[node] = L + 1;

  for (int i = 0; i < Graph[node].size(); i++){
    int next = Graph[node][i];
    if (ans[next] != 0) continue;
    DFS(next);
  }
  
  DP[Index] = Before;
  return 0;
}

int main(){
  cin >> N;
  for (int i = 0; i < N; i++) cin >> A[i];

  for (int i = 0; i < N - 1; i++){
    int U, V; cin >> U >> V;
    U--; V--;
    Graph[U].push_back(V);
    Graph[V].push_back(U);
  }

  fill(DP, DP + N + 1, 2e9);
  DFS(0);

  for (int i = 0; i < N; i++){
    cout << ans[i] << endl;
  }

  return 0;
}


Measured memory_bytes: 28332
import sys
input = sys.stdin.readline
mod = 10**9+7

n = int(input())
S = [s=="W" for s in input().rstrip()]
B = []
l, r = 0, 0
ans = 1
for i in range(n):
  ans *= i+1
  ans %= mod
for s in S:
  if (l+r+s)%2:
    if l == r or r == n:
      print(0)
      exit()
    ans *= (l-r)
    ans %= mod
    r += 1
  else:
    if l == n:
      print(0)
      exit()
    l += 1
print(ans)

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



int main()

{
    int n,m,i,j,a;
    scanf("%d%d",&n,&m);
    long long int aras1[n];
    long long int aras2[n];
    long long int arac1[m],arac2[m],ara1[n*m],ara2[n*m];
    for(i=0;i<n;i++) scanf("%lld%lld",&aras1[i],&aras2[i]);
    for(i=0;i<m;i++) scanf("%lld%lld",&arac1[i],&arac2[i]);

    for(a=0;a<n;a++){
        for(j=0;j<m;j++){
            ara1[j]=fabs(aras1[a]-arac1[j])+fabs(aras2[a]-arac2[j]);

        }
        for(i=0;i<m;i++) ara2[i]=ara1[i];
        sort(ara1,ara1+m);
        for(i=0;i<m;i++){
            if(ara2[i]==ara1[0]){
                printf("%d\n",i+1);
                break;
            }
        }
    }



}


Measured memory_bytes: 256
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define ALL(a) (a).begin(),(a).end()
#define SET(a,c) memset(a,c,sizeof a)
#define CLR(a) memset(a,0,sizeof a)
#define OUT(x) cout<<x<<endl;

#define I(x) int x; cin>>x;
#define LI(x) long long x; cin>>x;
#define VI(v,n) vector<int> v(n); REP(i,n) cin>>v[i];
#define VLI(v,n) vector<lint> v(n); REP(i,n) cin>>v[i];
#define D(x) double x; cin>>x;
#define VD(v,n) vector<double> v(n); REP(i,n) cin>>v[i];
#define STR(x) string x; cin>>x;

#define INF INT_MAX/3
#define LL long long

#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <string>

using namespace std;

int main()
{
	I(N);
	LL A = 0;
	LL C = 0;
	REP(i, N) { cin >> A; if (A % 2 != 0) C++; }
	if (C % 2 == 0)
	{
		OUT("YES");
	}
	else
	{
		OUT("NO");
	}

	return 0;
}

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

using namespace std;

#define fi first
#define se second
#define eb emplace_back
#define mt make_tuple
#define all(x) (x).begin(), (x).end() 
#define MOD 1000000007

typedef long long ll;
typedef pair <int, int> ii;
typedef pair <ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef long double ld;

const ll INF=LLONG_MAX;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    //freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
	string s; cin >> s;
	bool f1=1,f2=0,f3=1;
	int n=s.length();
	if(s[0]!='A')f1=0;
	for(int i=2; i<=n-2; i++){
		if(s[i]=='C'){
			if(f2){
				f2=0;
				break;
			}
			f2=1;
		}
	}
	int cnt = 0;
	for(int i=1; i<n; i++){
		if('A'<=s[i]&&s[i]<='Z'){
			if(s[i]=='C')cnt++;
			else{
				 f3=0; break;
			}
		}
	}
	if(cnt!=1)f2=0,f3=0;
	if(f1&&f2&&f3)cout << "AC";
	else cout << "WA";
}
	
// READ & UNDERSTAND
// ll, int overflow, array bounds, memset(0)
// special cases (n=1?), n+1 (1-index)
// do smth instead of nothing & stay organized
// WRITE STUFF DOWN


Measured memory_bytes: 256
package main

import "fmt"

func main() {
        var n int
        fmt.Scan(&n)

        m := map[int]int{}
        var a int
        for i := 0; i < n; i++ {
                fmt.Scan(&a)
                inc(m, a-1)
                inc(m, a)
                inc(m, a+1)
        }

        answer := 0
        for _, v := range m {
                if answer < v {
                        answer = v
                }
        }

        fmt.Printf("%d\n", answer)
}

func inc(m map[int]int, k int) {
        v, ok := m[k]
        if ok {
                m[k] = v + 1
        } else {
                m[k] = 1
        }
}


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

int main(){
	int a,b,c;
	int ans;
	int cnt=-1;
	
	while(cin>>a>>b){
		cnt++;
		//-----test-----
		if(cnt==0){cout<<7<<endl;continue;}
		
		//--------------
		c=a+b;
		ans=1;
		while(10<=c){
			c/=10;
			ans++;
		}
		cout<<ans<<endl;
	}
	
	return 0;
}

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

int main(){
  int n, m;
  string s[101], t[101];
  
  cin >> n;
  for(int i = 0; i < n; i++){
    cin >> s[i];
  }
  cin >> m;
  for(int i = 0; i < m; i++){
    cin >> t[i];
  }
  
  int sum,ans = 0;
  string x;
  for(int i = 0; i < n; i++){
    x = s[i];
    sum = 0;
    
    for(int j = 0; j < n; j++){
      if(x == s[j]){
        sum ++;
      }
    }
    
    for(int j = 0; j < m; j++){
      if(x == t[j]){
        sum --;
      }
    }
    
    ans = max(ans, sum);
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int lli;
 
int main()
{
	ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    #ifndef ONLINE_JUDGE
        freopen("input.txt" , "r" , stdin) ;
        freopen("output.txt" , "w" , stdout) ;
    #endif
    int a,b;
    cin>>b>>a;
    if(a>=b)
        cout<<"unsafe";
    else
        cout<<"safe";
    return 0;
}

Measured memory_bytes: 3652
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// using namespace __gnu_pbds;
// gp_hash_table<int, int> mapka;

using namespace std;
#define PB push_back
#define MP make_pair
#define LL long long
#define int LL
#define FOR(i,a,b) for(int i = (a); i <= (b); i++)
#define RE(i,n) FOR(i,1,n)
#define REP(i,n) FOR(i,0,(int)(n)-1)
#define R(i,n) REP(i,n)
#define VI vector<int>
#define PII pair<int,int>
#define LD long double
#define FI first
#define SE second
#define st FI
#define nd SE
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())

template<class C> void mini(C &a4, C b4) { a4 = min(a4, b4); }
template<class C> void maxi(C &a4, C b4) { a4 = max(a4, b4); }

template<class TH> void _dbg(const char *sdbg, TH h){ cerr<<sdbg<<'='<<h<<endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;
  cerr<<'='<<h<<','; _dbg(sdbg+1, a...);
}

template<class T> ostream &operator<<(ostream& os, vector<T> V) {
  os << "["; for (auto vv : V) os << vv << ","; return os << "]";
}
template<class L, class R> ostream &operator<<(ostream &os, pair<L,R> P) {
  return os << "(" << P.st << "," << P.nd << ")";
}

#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) (__VA_ARGS__)
#define cerr if(0)cout
#endif

int n,a,b;
int res = 3e18;
void licz(){
  mini(res, (a + b - 1) / 2);
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(11);
  cerr << fixed << setprecision(6);
  cin >> n >> a >> b;
  if(a % 2 == b % 2){
    cout << abs(a - b) / 2 << "\n";
    return 0;
  }
  licz();
  a = n - a + 1;
  b = n - b + 1;
  licz();
  cout << res << "\n";
}


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

int main(){
  int n;
  cin >> n;
  double a[n];
  for ( int i = 0; i < n; i++){
    cin >> a[i];
  }
  double sum = 0;
  for ( int i = 0; i < n; i++){
    sum += 1/a[i];
  }

  cout << setprecision(15) << 1/sum << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define forn(i, n) for(int i = 0; i < int(n); i++)
#define fore(i, l, r) for(int i = int(l); i < int(r); i++)
#define pb push_back
#define deb(x) cout<<#x<<" "<<x<<endl;
#define deb2(x, y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<endl;
#define deb3(x, y, z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<endl;
#define all(x) x.begin(), x.end()
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> pii;
const int mod = 1e9 + 7;
template<class T, class U> inline void add_self(T &a, U b){a += b;if (a >= mod) a -= mod;if (a < 0) a += mod;}
template<class T, class U> inline void sub_self(T &a, U b){a -= b; if (a >= mod) a -= mod;if (a < 0) a += mod;}
template<class T, class U> inline void min_self(T &x, U y) { if (y < x) x = y; }
template<class T, class U> inline void max_self(T &x, U y) { if (y > x) x = y; }

template <typename T>void print(T v, bool show_index = false){int w = 2;if(show_index){for(int i=0; i<v.size(); i++)cout<<setw(w)<<i<<" ";cout<<endl;}for(auto i= v.begin(); i!=v.end(); i++)cout<<setw(w)<<*i<<" ";cout<<endl;}
template <typename T>void print_vv(T v){if(v.size()==0) {cout<<"Empty"<<endl; return;} int w = 3;cout<<setw(w)<<" ";for(int j=0; j<v[0].size(); j++)cout<<setw(w)<<j<<" ";cout<<endl;for(auto i= 0; i<v.size(); i++){cout<<i<<" {";for(auto j = 0; j!=v[i].size(); j++){cout<<setw(w)<<v[i][j]<<",";}cout<<"},"<<endl;}cout<<endl;}
template <class T, class U> void print_m(map<T,U> m, int w=3){if(m.empty()){cout<<"Empty"<<endl; return;}for(auto x: m)cout<<"("<<x.first<<": "<<x.second<<"),"<<endl;cout<<endl;}

int main(){
    int n,k;
    while(cin>>n>>k){
        vi dp(k+1); // number of ways to use i candies so far
        vi a(n); forn(i,n) cin>>a[i];
    
        dp[0] = 1;
    
        // for(auto up_limit: a){
        //     for(int used = k; used>=0; --used){
        //         for(int here = 1; here<=min(up_limit, k-used); ++here){
        //             add_self(dp[here+used], dp[used]);
        //         }
        //     }
        // }

        for(auto up_limit: a){
            vi fake(k+1);
            for(int used = k; used>=0; --used){
                int l = used + 1;
                int r = used + min(up_limit, k - used);

                if(l<=r)
                    add_self(fake[l], dp[used]);
                if(r+1<=k)
                    sub_self(fake[r+1], dp[used]);
            }

            int prefix_sum = 0;
            forn(i,k+1){
                add_self(prefix_sum, fake[i]);
                add_self(dp[i], prefix_sum);
            }

        }

        cout<<dp[k]<<endl;
    
    }
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
#include <iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<P,P> PP;
const ll MOD=1000000007;
const ll MAX_N=500010;
const ll INF=4999999996000000001;
int Z[6001][6001];
void z_alg(int l, int n, string s){
    Z[l][l]=n-l;
    int j=0;
    for(int i=l+1;i<n;i++){
        while(i+j<n && s[l+j]==s[i+j]) j++;
        Z[l][i]=j;
        if(j==0) continue;
        int k=1;
        while(k<j && Z[l][l+k]+k<j){
            Z[l][i+k]=Z[l][l+k];
            k++;
        }
        i+=k-1;
        j-=k;
    }
}

int main(){
    int n;
    string s;
    cin>>n>>s;
    for(int i=0;i<n;i++){
        z_alg(i,n,s);
    }
    int ans=0;
    for(int i=0;i<n-1;i++){
        for(int j=i+1;j<n;j++){
            int buf=min(j-i,Z[i][j]);
            ans=max(ans,buf);
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 71900
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int y = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		long p[] = new long[a];
		long q[] = new long[b];
		long r[] = new long[c];

		for (int i = 0; i < a; i++) {
			p[i] = sc.nextLong();
		}

		for (int i = 0; i < b; i++) {
			q[i] = sc.nextLong();
		}

		for (int i = 0; i < c; i++) {
			r[i] = sc.nextLong();
		}

		Arrays.sort(p);
		Arrays.sort(q);
		Arrays.sort(r);

		long newP[] = new long[a];
		long newQ[] = new long[b];

		for (int i = a - 1; a - x <= i; i--) {
			newP[a - i - 1] = p[i];
		}

		for (int i = b - 1; b - y <= i; i--) {
			newQ[b - i - 1] = q[i];
		}

		long[] hoge = new long[x + y + c];

		System.arraycopy(newP, 0, hoge, 0, x);
		System.arraycopy(newQ, 0, hoge, x, y);
		System.arraycopy(r, 0, hoge, x + y, r.length);

		long answer = 0;
		Arrays.sort(hoge);

		for (int i = 0; i < x + y; i++) {
			answer += hoge[x + y + c - i - 1];
		}

		System.out.println(answer);
		sc.close();

	}
}

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

int main() {
  int n,k,h;
  cin >> n >> k;
  int ans = 0;
  
  for(int i=0; i<n; i++){
    cin >> h;
    if(h>=k)ans++;
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;
int cl(int a, int b) {
	return (a - (a%b)) / b;//b=0だと積む
}
int up(int a, int b) {
	return cl(a + b - 1, b);//b=0だと積む
}
int ord(int a, int p) {
	if (a%p == 0) {
		return ord(a / p, p) + 1;
	}
	else {
		return 0;
	}
}
int main() {
    int az=0;
    while(az==0){
    int n, k; int ans = 0; int si = 0;
	cin >> n >> k;
	if(n*n+k*k==0){
	    az=1;
	}
	else{
	 vector<int> c(k);
	vector<int> d(k);
	vector<int> e(k);
	vector<int> answ(k,0);
	for (int i = 0; i < k; i++) {
		int bi = 0;
		cin >> bi;
		if(bi == 1) {
			int x, y;
			cin >> x >> y;
			c[si] = x - 1;
			d[si] = y - 1;
			cin >>  e[si];
			si++;
		}
		else {
			int a, b;
			cin >> a >> b;
			a = a - 1;
			b = b - 1;
			int mi = 1;
			vector<int> di(n, 1000000 * 100);
			vector<int> yobi(n);
			di[a] = 0;
			while (mi != 0) {
				mi = 0;
				for(int j = 0; j < si; j++) {
					if (di[c[j]] > di[d[j]] + e[j]) {
						mi = 1;
						di[c[j]] = di[d[j]] + e[j];
					}
					if (di[d[j]] > di[c[j]] + e[j]) {
						mi = 1;
						di[d[j]] = di[c[j]] + e[j];
					}
				}
			}
			if (di[b] != 1000000 * 100) {
				answ[i] = di[b];
			}
			else {
				answ[i] = -1;
			}
		}
	}
	for (int i = 0; i < k; i++) {
		if (answ[i] != 0) {
			cout << answ[i]<<endl;
		}
	}   
    }   
	}
	return 0;
}



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

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

using namespace std;

typedef long long ll;
const ll mod = 998244353;

ll table[100005];

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 () {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(20) << fixed;

  ll n; cin >> n;
  vector<ll> d(n, 0);

  rep(i, n) {
    cin >> d[i];
    table[d[i]]++;
  }

  if (d[0] != 0 || table[0] != 1) {
    cout << 0 << endl;
    return 0;
  }
  for (int i = 1; i <= n; i++) {
    if (table[i] != 0 && table[i-1] == 0) {
      cout << 0 << endl;
      return 0;
    }
  }

  ll ans = 1;
  
  for (int i = 1; i <= n; i++) {
    ll prev = table[i-1];
    ll cur = table[i];
    ans *= modpow(prev, cur, mod);
    ans %= mod;
  }

  cout << ans % mod<< endl;

  return 0;
}


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

ll dp[202020][22][2],dp2[202020][2];

int main(){
  int N; cin>>N;
  ll A[N]; rep(i,N) cin>>A[i];
  rep(i,N-1) rep(j,2) dp2[i][j]=1e18;
  
  rep(k,2){
    rep(j,16) dp[N-1][j][k]=j;
    for(int i=N-2;i>=0;i--){
      for(int j=0;j<=15;j++){
        ll a=A[i]<<(2*j);
        int j2=0;
        while(a>(A[i+1]<<(2*j2))) j2++;
        if(j2<=15){
          dp[i][j][k]=dp[i+1][j2][k]+j;
        }else{
          dp[i][j][k]=dp[i+1][15][k]+j+(N-1-i)*(j2-15);
        }
        dp2[i][k]=min(dp2[i][k],dp[i][j][k]);
      }
    }
    reverse(A,A+N);
  }
  ll ans=1e18;
  for(int i=0;i<=N;i++){
    ll res=i+2*(dp2[i][0]+dp2[N-i][1]);
    ans=min(ans,res);
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 73728
#include <stdio.h>

int s[10];
int c = 0;

void push(int x)
{
    s[c++] = x;
}

int pop(void)
{
    return s[--c];
}

int main(void)
{
    int x;

    while (scanf("%d", &x) != EOF) {
        if (x == 0) {
            printf("%d\n", pop());
        } else {
            push(x);
        }
    }

    return 0;
}

Measured memory_bytes: 600
// 1_7_A
#include <iostream>
using namespace std;

int main(){
  int m, f, r;
  while(true){
    cin >> m >> f >> r;
    if(m == -1 && f == -1 && r == -1) return 0;

    if(m == -1 || f == -1){
      cout << 'F' << endl;
    } else if(m + f >= 80){
      cout << 'A' << endl;
    } else if(m + f < 80 && m + f >= 65){
      cout << 'B' << endl;
    } else if(m + f < 65 && m + f >= 50){
      cout << 'C' << endl;
    } else if(m + f < 50 && m + f >= 30){
      if(r >= 50){
        cout << 'C' << endl;
      } else{
        cout << 'D' << endl;
      }
    } else if(m + f < 30){
      cout << 'F' << endl;
    }
  }
}

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

string S;

bool memo[26];

int main() {
	cin >> S;
	memset(memo, false, sizeof(memo));
	for (int i = 0; i < S.size(); i++) {
		memo[S[i] - 'a'] = true;
	}

	for (int i = 0; i < 26; i++) {
		if (!memo[i]) {
			cout << (char)('a' + i) << endl;
			return 0;
		}
	}
	cout << "None" << endl;
}


Measured memory_bytes: 512
//実装が重そうな問題はある程度考えてから書く
//初期化を忘れずに（特に二分探索とか）
//コーナーケースを考えて（特に場合分けとか）
//不可解すぎるバグは配列外参照（配列の長さ）を検討
#include <bits/stdc++.h>
#define YES "YES"
#define NO "NO"
#define YESNO OUT(three(solve(),YES,NO))
#define ECHO OUT(solve())
#define three(A,B,C) ((A)?(B):(C))
#define FOR(i,a,b)  for(LL i=(a);i< (LL)(b);i++)
#define EFOR(i,a,b) for(LL i=(a);i<=(LL)(b);i++)
#define RFOR(i,a,b) for(LL i=(a);i>=(LL)(b);i--)
#define REP(i,b) FOR(i,zero,b)
#define EREP(i,b) EFOR(i,zero,b)
#define RREP(i,b) RFOR(i,b,zero)
#define ALL(c) c.begin(),c.end()
#define UNIQUE(c) sort(ALL(c));c.erase(unique(ALL(c)),c.end())
#define MAX(c) (*max_element(ALL(c)))
#define MIN(c) (*min_element(ALL(c)))
#define MP make_pair
#define FI first
#define SE second
#define SI(x) (LL(x.size()))
#define PB push_back
#define DEBUG(a) OUT(a)
#define DEBUG2(a,b) OUT2(a,b)
#define cat cout << __LINE__ << endl
#define OUT(a) cout << (a) << endl
#define OUT2(a,b) cout << (a) <<" "<<(b) << endl
#define int LL
#define zero 0LL
using namespace std;
template<typename T> inline void maximize(T &a,T b){a=max(a,b);}
template<typename T> inline void minimize(T &a,T b){a=min(a,b);}
template<typename T> inline bool middle(T a,T b,T c){return b<=a && a<=c;}
typedef long long LL;
typedef double ld;
typedef LL ut;
typedef vector<ut> VI;
typedef vector<VI> VII;
typedef pair<ut,ut> pr;
typedef pair<ut,pr> ppr;
typedef vector<pr> Vpr;
typedef vector<ppr> Vppr;
typedef priority_queue<pr,Vpr,greater<pr> > PQ;
inline void outputVI(VI x){REP(i,SI(x)){cout << three(i," ","") << x[i];}OUT("");}
const int SIZE1=5*1e5+1000;
const int SIZE2=5010;
const int SIZE3=400;
const int SIZE=SIZE1;
const LL p=7+1e9;
const LL INF=1LL<<60;
const long double EPS=1e-7;
string s;
ut N,M,K,X,L,Y;
// ut A,B,C,D,E,F,G,H,I,J,O,P,Q,R,T,U;
VI edges[SIZE];
LL vals[SIZE],nums[SIZE],maps[SIZE2][SIZE2],answer=zero;
 
////////////////////////////////////////////////////////////////////////////////////////////
 
////////////////////////////////////////////////////////////////////////////////////////////
void init(){
 
}
int A[SIZE];
LL solve(){
	cin >> N;
	REP(i,N){
		cin >> A[i];
		if(i && A[i]>A[i-1]+1) return -1;
		if(i==0 && A[i]) return -1;
	}
	int ans=0;
	REP(i,N){
		int x=N-i-1;
		if(i && A[x]+1==A[x+1]) continue; 
		ans+=A[x];
		
	}
	return ans;
}
signed main(){
	cout << solve() << endl;
	return 0;
}

Measured memory_bytes: 14592
#include <stdio.h>
#include <iostream>
using namespace std;
int main(){
    int n,max=0,min=0;
    cin>>n;
    long long int sum=0;
    int a[n-1];
    for(int i=0;i<n;i++){
        cin>>a[i];
        sum+=a[i];
        if(i==0){
            min=a[0];
            max=a[0];
        }else if(a[i]>max){
            max=a[i];
        }else if(a[i]<min){
            min=a[i];
        }
    }
    cout<<min<<" "<<max<<" "<<sum<<endl;
    
}

Measured memory_bytes: 3136
#include<iostream>
using namespace std;
int main()
{
	string a;
	int k;
	cin>>k;
	cin>>a;
	int len=a.size();
	if(len<=k)
	 cout<<a<<endl;
	else
	{
		for(int i=0;i<k;++i)
		 cout<<a[i];
		cout<<"..."<<endl;
	}
	return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
#define SZ(x) (int)(x.size())
#define REP(i, n) for(int i=0;i<(n);++i)
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RREP(i, n) for(int i=(int)(n)-1;i>=0;--i)
#define RFOR(i, a, b) for(int i=(int)(b)-1;i>=(a);--i)
#define ALL(a) a.begin(),a.end()
#define DUMP(x) cerr<<#x<<" = "<<(x)<<endl
#define DEBUG(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<< endl;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<int, int>;
const double eps = 1e-8;
const ll MOD = 1000000007;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;
template <typename T1, typename T2>
bool chmax(T1 &a, const T2 &b) {
    if (a < b) { a = b; return true; }
    return false;
}
template <typename T1, typename T2>
bool chmin(T1 &a, const T2 &b) {
    if (a > b) { a = b; return true; }
    return false;
}
template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
    os << "[";
    REP(i, SZ(v)) {
        if (i) os << ", ";
        os << v[i];
    }
    return os << "]";
}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const map<T1, T2> &mp) {
    os << "{";
    int a = 0;
    for (auto &tp : mp) {
        if (a) os << ", ";
        a = 1;
        os << tp;
    }
    return os << "}";
}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) {
    os << p.first << ":" << p.second;
    return os;
}

int eval(const vector<string>& s, int &i, int depth) {
    int ret;
    if (s[i][depth] == '*') {
        ret = 1;
        ++i;
        while (i < s.size()) {
            int valid = 1;
            REP(j, depth+1) {
                if (j >= s[i].size() or s[i][j] != '.') valid = 0;
            }
            if (!valid) break;
            ret *= eval(s, i, depth + 1);
        }
        return ret;
    }
    else if (s[i][depth] == '+') {
        ret = 0;
        ++i;
        while (i < s.size()) {
            int valid = 1;
            REP(j, depth+1) {
                if (j >= s[i].size() or s[i][j] != '.') valid = 0;
            }
            if (!valid) break;
            ret += eval(s, i, depth + 1);
        }
        return ret;
    }
    else {
        ret = s[i][depth] - '0';
        ++i;
    }
    return ret;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    for (;;) {
        int n; cin >> n;
        if (n == 0) break;

        vector<string> S(n);
        REP(i, n) cin >> S[i];

        int i = 0;
        int ans = eval(S, i, 0);
        cout << ans << endl;
    }

    return 0;
}



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

int main() {
  string S;
  cin >> S;
  
  int l = S.size();
  rep(i,l){
   if(S.at(i) == '?')
     S.at(i) = 'D';
  }
  cout << S << endl;
  return 0;
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long long int n,c=0;
  cin>>n;
  map<string,int> m ;
  for(int i=0;i<n;i++)
  {
    string s;
    cin>>s;
    sort(s.begin(),s.end());
    c+=m[s]++;
  }
  cout<<c;
  return 0;
}
        

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

int main() {
    int N, max=-1, maxi=-1, semimax=-1;
    cin >> N;
    vector<int> A(N);
    for(int i=0; i<N; i++) {
        cin >> A[i];
    }

    for(int i=0; i<N; i++) {
        if(A[i] > semimax) {
            if(A[i] > max) {
                semimax = max;
                max = A[i];
                maxi = i;
            } else {
                semimax = A[i];
            }
        } 
    }

    for(int i=0; i<N; i++) {
        if(i == maxi) {
            cout << semimax << endl;
        }
        else cout << max << endl;
    }

    return 0;
}

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

using namespace std;

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

  int n;
  cin >> n;
  char s;
  set<char> hash;
  for (int i = 0; i < n; ++i) {
    cin >> s;
    hash.insert(s);
  }
  cout << (hash.size() == 3 ? "Three" : "Four") << endl;

  return 0;
}



Measured memory_bytes: 256
#include "bits/stdc++.h"
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define mFOR(i, a, b) for (int i = a; i > b; i--)
#define MP make_pair
#define PB push_back
#define ALL(v) v.begin(), v.end()
#define N 200007
#define INF 1000000007
using namespace std;

typedef long long ll;

ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll fceil(ll a, ll b) { return (a % b == 0 ? a / b : a / b + 1); }
int main()
{
   int n, a[N] = {}, mx1 = 0, mx2 = 0, ctr1 = 0, ctr2 = 0;
   cin >> n;
   for (int i = 0; i < n; i++)
      cin >> a[i];

   for (int i = 0; i < n; i++)
   {
      if (mx1 < a[i])
      {
         mx2 = mx1;
         ctr2 = ctr1;
         mx1 = a[i];
         ctr1 = 1;
      }
      else if (mx1 == a[i])
      {
         ctr1++;
      }
      else if (mx2 < a[i])
      {
         mx2 = a[i];
         ctr2 = 1;
      }
      else if (mx2 == a[i])
      {
         ctr2++;
      }
   }
   for (int i = 0; i < n; i++)
   {
      if (a[i] != mx1 || ctr1 > 1)
         cout << mx1 << endl;
      else
         cout << mx2 << endl;
   }
   return 0;
}


Measured memory_bytes: 2432
#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);}
}

const int N=2e5+5;
int a[N],m,cnt[N],n,b[5];

void GG(){
	puts("No");
	exit(0);
}

void OK(){
	puts("Yes");
	exit(0);
}

signed main(){
	read(n);
	for(int i=1;i<=n;i++) read(a[i]);
	sort(a+1,a+1+n);
	a[0]=-1;
	for(int i=1;i<=n;i++) a[i]==a[i-1]?cnt[m]++:cnt[++m]++;
	if(m>3) GG();
	m=0;for(int i=1;i<=n;i++) if(a[i]!=a[i-1]) b[++m]=a[i];
	if(m==1&&!b[1]) OK();
	if(n%3) GG();
	if(m==2&&!b[1]&&cnt[1]==n/3) OK();
	if(m<3) GG();
	if(cnt[1]!=n/3||cnt[2]!=n/3||cnt[3]!=n/3) GG();
//	printf("#%d %d %d %d %d %d\n",b[1],b[2],b[3],b[1]^b[2],b[2]^b[3],b[1]^b[3]);
	if((b[1]^b[2])==b[3]) OK();
	if((b[1]^b[3])==b[2]) OK();
	if((b[2]^b[3])==b[1]) OK();
	GG();
}

Measured memory_bytes: 4024
#include <bits/stdc++.h>
//#include <mylib.h>
using namespace std;
//cin.sync_with_stdio(false);

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define FOR_EQ(i,a,b) for(int i = (a); i <= (b); ++i)
#define FOR_RE(i,a,b) for(int i = (a); i > (b); --i)
#define rep(i,n) FOR(i,0,n)
#define rep_eq(i,n) FOR_EQ(i,0,n)
//1個上から時計周り
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
//上右下左
const int dx[4] = {0, 1, 0, -1};
const int dy[4] = {1, 0, -1, 0};

typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> Vector;
typedef vector<Vector>	DVector;
int n;

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll power = 1;
    ll divisor = pow(10, 9) + 7;
    cin >> n;
    FOR_EQ(i, 1, n){
        power = power * i;
        power = power % divisor;
    }
    cout << power << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
// 40min
int main(void){
  int n, d;
  int x[11][11];
  int ans = 0;
  double sum = 0;
  scanf("%d%d", &n, &d);

  for(int i = 1; i <= n; i++){
    for(int j = 1; j <= d; j++){
      scanf("%d", &x[i][j]);
    }
  }

  for(int i = 1; i <= n; i++){
    for(int k = 1; k <= n; k++){
      if(i == k){
	    break;
      }
      sum = 0;
      for(int j = 1; j <= d; j++){
    	//sum += pow(x[i][j] - x[k][j], 2.0);
        int a = x[i][j] - x[k][j];
        sum += a * a;
      }
      //if(ceil(sqrt(sum)) == floor(sqrt(sum))){
	  //  ans++;
      //}
      //int r = sqrt(sum) + 0.5;
      //if (r * r == sum) {
      //    ans++;
      //}
      for (int r = 1; r * r <= sum; r++) {
        if (r * r == sum) {
          ans++;
          break;
        }
      }
    }
  }
  
  printf("%d\n", ans);

  return 0;
}


Measured memory_bytes: 128
import sys
n=int(input())
nl=list(map(int, input().split(" ")))

for i in range(n):
 if nl[i]%2==0:
  #print(nl[i]%6,nl[i]%10)
  if nl[i]%6 !=0 and nl[i]%10!=0:
   print("DENIED")
   sys.exit()
print("APPROVED")


Measured memory_bytes: 2940
N, x = gets.split.map &:to_i
a = gets.split.map &:to_i
cnt = 0
a.sort.each do |i|
  if x - i < 0
    puts cnt
    exit
  else
    cnt += 1
    x -= i
  end
end
if x == 0
  puts cnt
else
  puts cnt - 1
end

Measured memory_bytes: 14368
#include<bits/stdc++.h>
using namespace std;
int power(int m,int n)
{
	int i,j=1;
	for(int i=0;i<n;i++) j*=m;
	return j;
}
int main()
{
	int x,max;
	cin>>x;
	int min=x;
	for(int b=1;b*b<=x;b++)
	{
		for(int p=2;p<11;p++)
		{
			if(x-power(b,p)>=0&&power(b,p)>0&&x-power(b,p)<min)
			{
				min=x-power(b,p);
				max=power(b,p);
			}
		}
	}
	cout<<max;
	return 0;
}

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


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

	reverse(s.begin(), s.end());
	vector<int64_t> amari(s.size() + 1);
	vector<int64_t> matome(2019);

	int64_t temp = 1;	// 10^xのmod2019
	matome.at(0) += 1;	// 一番下の位の分
	for (int64_t i = 0; i < s.size(); i++) {
		int64_t num = s[i] - '0';
		if (i == 0) {
			amari.at(i) = num;
		} else {
			amari.at(i) = (amari.at(i - 1) + temp * num) % 2019;
		}
		matome.at(amari.at(i)) += 1;
		temp = (temp * 10) % 2019;
	}

	int64_t ans = 0;
	for (int i = 0; i < 2019; i++) {
		int64_t num = matome.at(i);
		ans += num * (num - 1) / 2;
	}

	cout << ans << endl;

}

Measured memory_bytes: 5148
#encoding:utf-8 No.0045 2014.10.5
sum = 0
average = 0.0
count = 0.0

while gets
  count += 1.0
  data = $_.chomp.split(/,/).map{|item| item = item.to_i}
  sum += data[0]*data[1]
  average += data[1].to_f
end

puts sum
puts (average/count).round

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

int main() {
	int n,m,k;
  cin>>n>>m>>k;
  
  int a[n];
  int b[m];
  
  rep(i,n)cin>>a[i];
  rep(i,m)cin>>b[i];
  
  int p;
  int s=0;
  
	for(p=0;p<n;p++){
    	if(s+a[p]<=k)s +=a[p];
      else break;
    }
  
  int ans=p;
  int q=0;
  
  while(true){
    while(q<m&&s+b[q]<=k){
    	s+= b[q];
      q++;
    }
    ans = max(ans,p+q);
    if(p<=0) break;
    p--;
    s -= a[p];
  }
    cout << ans <<endl;
}

Measured memory_bytes: 5200