akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <limits>
#include <map>
#define REP(i,n) for(long (i)=0;(i)<(n);(i)++)
#define REPI(i,a,b) for(long (i)=(a);(i)<(b);(i)++)
#define INF numeric_limits<double>::infinity()
constexpr long MOD = 1e9 + 7;
using namespace std;
using P = pair<long, long>;
using VI = vector<long>;

int find(int x, VI *par) {
    if (x == (*par)[x]) {
        return x;
    }
    return (*par)[x] = find((*par)[x], par);
}

int same(int x, int y, VI *par) {
    return find(x, par) == find(y, par);
}

void unyon(int x, int y, VI *par) {
    int xr = find(x, par);
    int yr = find(y, par);
    if (xr != yr) (*par)[yr] = xr;
}

int main() {
    int n;
    cin >> n;
    vector<P> xs, ys;
    REP(i,n) {
        long x, y;
        cin >> x >> y;
        x--;
        y--;
        xs.push_back(P(x,i));
        ys.push_back(P(y,i));
    }
    sort(xs.begin(), xs.end());
    sort(ys.begin(), ys.end());
    
    using T = pair<int, P>;
    vector<T> v;
    REP(i,n-1) {
        v.push_back(T(xs[i+1].first - xs[i].first, P(xs[i+1].second, xs[i].second)));
    }
    REP(i,n-1) {
        v.push_back(T(ys[i+1].first - ys[i].first, P(ys[i+1].second, ys[i].second)));
    }
    sort(v.begin(), v.end());
    int cnt = 0, i = 0;
    long ans = 0;
    VI par(n);
    REP(i,n) par[i] = i;
    while (cnt != n - 1) {
        int xr = v[i].second.first;
        int yr = v[i].second.second;
        if (!same(xr, yr, &par)) {
            unyon(xr, yr, &par);
            ans += v[i].first;
            cnt++;
        }
        i++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 13024
/*Function Template*/
#include<bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
#define rep(i, n) for(int i = 0; i < (n); i++)


int Len(int n) {
  int s=0;
  while(n!=0) s++, n/=10;
  return s;
}


int Sint(int n) {
  int m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(int i=s-1;i>=0;i--) m+=n/((int)pow(10,i))-(n/((int)pow(10,i+1)))*10;
  return m;
}


int Svec(vector<int> v){
  int n=0;
  for(int i=0;i<v.size();i++) n+=v[i];
  return n;
}


int GCD(int a,int b){
  int r,tmp;
/*自然数 a > b を確認・入替*/
  if(a<b){
    tmp=a,a=b,b=tmp;
  }
/*ユークリッドの互除法*/
  r=a%b;
  while(r!=0){
    a=b,b=r,r=a%b;
  }
  return b;
}


int LCM(int a,int b){
  int c=a,d=b,r,tmp;
/*自然数 a > b を確認・入替*/
  if(a<b){
    tmp=a,a=b,b=tmp;
  }
/*ユークリッドの互除法*/
  r=a%b;
  while(r!=0){
    a=b,b=r,r=a%b;
  }
  return c/b*d;
}


int Factorial(int n){
  int m=1;
  while(n>=1) m*=n,n--;
  return m;
}


/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
int main() {
  long long int n,m;
  cin>>n>>m;
  cout<<(m*1900+(n-m)*100)*(long long int)pow(2,m)<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>

main(){
  double xa,ya,xb,yb,xc,yc,xd,yd;
  double xab,yab,xcd,ycd;
  double ans;

  while(1){
    if(scanf("%lf %lf %lf %lf %lf %lf %lf %lf", &xa,&ya,&xb,&yb,&xc,&yc,&xd,&yd)==EOF) break;

    xab=xa-xb;
    yab=ya-yb;
    xcd=xc-xd;
    ycd=yc-yd;

    ans=xab*xcd+yab*ycd;

    if(ans==0.0) printf("YES\n");
    else printf("NO\n");
  }
  return 0;
}

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

int main(void){
    int n, t, a[100010], min = 2000000000, max = 0, cnt=0;
    cin >> n >> t;
    for(int i=0;i<n;++i){
        cin >> a[i];
    }
    for(int i=0;i<n;++i){
        if(min > a[i]) min = a[i];
        int dif = a[i] - min;
        if(max < dif){
            cnt = 1;
            max = dif;
        }else if(max==dif){
            ++cnt;
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 640
#include<iostream>
using namespace std;
#include<vector>
struct SCC{
	int n;
	vector<int>comp,order;
	vector<bool>used;
	vector<vector<int> >G,RG;
	SCC(int _n=0):n(_n),comp(_n,-1),used(_n,false),G(_n),RG(_n){}
	void add_edge(int from,int to)
	{
		G[from].push_back(to);
		RG[to].push_back(from);
	}
	void copy(vector<vector<int> >&H)
	{
		for(int i=0;i<H.size();i++)
		{
			for(int j=0;j<H[i].size();j++)
			{
				G[i].push_back(H[i][j]);
				RG[H[i][j]].push_back(i);
			}
		}
	}
	int operator[](int u){return comp[u];}
	void dfs(int u)
	{
		used[u]=true;
		for(int i=0;i<G[u].size();i++)if(!used[G[u][i]])dfs(G[u][i]);
		order.push_back(u);
	}
	void rdfs(int u,int cnt)
	{
		comp[u]=cnt;
		for(int i=0;i<RG[u].size();i++)if(comp[RG[u][i]]==-1)rdfs(RG[u][i],cnt);
	}
	int build()
	{
		for(int i=0;i<n;i++)if(!used[i])dfs(i);
		int cnt=0;
		for(int i=n-1;i>=0;i--)if(comp[order[i]]==-1)rdfs(order[i],cnt++);
		return cnt;
	}
	int build(vector<vector<int> >&H)
	{
		int ret=build();
		for(int i=0;i<n;i++)
		{
			for(int j=0;j<G[i].size();j++)
			{
				if(comp[i]!=comp[G[i][j]])
					H[comp[i]].push_back(comp[G[i][j]]);
			}
		}
		return ret;
	}
};
main()
{
	int n,m;cin>>n>>m;
	SCC scc(n);
	for(int i=0;i<m;i++)
	{
		int a,b;cin>>a>>b;
		scc.add_edge(a,b);
	}
	scc.build();
	int q;cin>>q;
	for(int i=0;i<q;i++)
	{
		int a,b;cin>>a>>b;
		cout<<(scc[a]==scc[b])<<endl;
	}
}



Measured memory_bytes: 4180
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
    int N; cin >> N;
    vector<ll> A(N),B(N),C(N);
    for (int i=0;i<N;i++) cin >> A[i];
    for (int i=0;i<N;i++) cin >> B[i];
    for (int i=0;i<N;i++) cin >> C[i];
    sort(A.begin(),A.end());
    sort(B.begin(),B.end());
    sort(C.begin(),C.end());
    ll res = 0;
    for (int j=0;j<N;j++){
        ll i = lower_bound(A.begin(),A.end(),B[j]) - A.begin();
        ll k = C.end() - upper_bound(C.begin(),C.end(),B[j]);
        res += i * k;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 2560
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder.Abc
{
    class QuestionC
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            decimal[] list = Console.ReadLine().Split(' ').Select(i => decimal.Parse(i)).ToArray();
            decimal X = list[0], Y = list[1];
            Console.WriteLine((long)(X * Y));

            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 28252
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <set>
#include <iostream>
#include <cassert>
#include <queue>
using namespace std;


int main()
{
    int n;
    cin >> n;
    int x = 0, y = 0;
    vector<int> A(n);
    vector<int> B(n);
    for (int i = 0; i < n; ++i) {
        int t = 0;
        cin >> t;
        A[i] = t;
        x = x*10 + t;
    }
    for (int i = 0; i < n; ++i) {
        int t = 0;
        cin >> t;
        B[i] = t;
        y = y*10 + t;
    }

    if (x == y) {
        cout << 0;
        return 0;
    }
    if (x > y) {
        swap(A, B);
    }
    int ans = 0;
    while (A != B && next_permutation(A.begin(), A.end())) {
        ans++;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
#define rep(i, n) for (int i = 0, i##_len = (int)(n); i < i##_len; i++)
#define reps(i, n) for (int i = 1, i##_len = (int)(n); i <= i##_len; i++)
#define ALL(v) (v).begin(), (v).end()
#define PUTS(x) cout << (x) << endl;
#define SZ(x) ((int)(x).size())
#define PB push_back
#define MP make_pair
#define F first
#define S second
const int MOD = 2019;

template <typename T>
struct countmap {
    std::map<T, long long> dict;

    countmap() {
        dict = map<T, long long>();
    }

    bool contains(T key) {
        return (dict.find(key) != dict.end());
    }

    long long operator[](T key) {
        if (dict.find(key) != dict.end()) {
            return dict[key];
        } else {
            return 0;
        }
    }

    // key に対応する値があれば inc 増加させる，なければキーを新設して inc をセット
    void incrementFor(T key, long long inc = 1) {
        if (dict.find(key) != dict.end()) {
            dict[key] += inc;
        } else {
            dict.emplace(key, inc);
        }
    }

    // for (auto &p: dict) でループできるように
    auto begin() const {
        return dict.begin();
    }

    auto end() const {
        return dict.end();
    }
};

int main() {
    string s;
    cin >> s;
    auto a = countmap<Int>();
    Int x = 0;
    Int p = 1;
    Int n = s.size();
    rep(i, n) {
        auto j = n - 1 - i;
        auto c = s[j] - '0';
        p %= MOD;
        x += (p * c) % MOD;
        p *= 10;
        x %= MOD;
        a.incrementFor(x);
    }
    Int ans = 0;
    for (auto &p : a) {
        auto k = p.first;
        auto v = p.second;
        if (k == 0) {
            ans += v;
        }
        ans += v * (v - 1) / 2;
    }
    PUTS(ans)
}


Measured memory_bytes: 3728
import java.util.*;
    public class Main {
     
    	public static void main(String[] args) {
    			
    		Scanner scan =new Scanner(System.in);
    		
    		int a=Integer.parseInt(scan.next());
    		int b=Integer.parseInt(scan.next());
    		int c=Integer.parseInt(scan.next());
    		int d=Integer.parseInt(scan.next());
    		
    		if ((Math.abs(a-b)<=d&&Math.abs(c-b)<=d)||Math.abs(a-c)<=d) {
    			System.out.print("Yes");
    		}else {
    			System.out.print("No");
    		}
    	


    		
     
    }
    }
// end 

Measured memory_bytes: 21972
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
/* clang-format off */
#define MOD 1000000007
#define INF 1000000000
#define REP(i, n) for (ll i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(a) (a).begin(), (a).end()
#define __DEBUG__
#ifdef __DEBUG__
#define CH_P(a) cout <<"check_point("<<#a<<")" << "\n";
#define DEBUG(x) cout<<#x<<":"<<x<<"\n"
#define DEBUGS(v) cout << #v << ":";for(auto x:v){cout<<x<<" ";}cout<<"\n"
#endif
#ifndef __DEBUG__
#define CH_P(a) 
#define DEBUG(x) 
#define DEBUGS(v) 
#endif
#define TIMER_S(start) chrono::system_clock::time_point start = chrono::system_clock::now();
#define TIMER_E(end) chrono::system_clock::time_point end = chrono::system_clock::now();
#define TIME(start, end) cout << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count()) << "ms" << "\n";
/* clang-format on */

int main() {
  ll n,ans=0;
  cin >> n;
  for (int i = 1; i <= n;i++) {
    ll a = (ll)n / i;
    ans += a * (a + 1) / 2 * i;
  }
  cout << ans << "\n";
  return 0;
}


Measured memory_bytes: 3612
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <sstream>
#include <map>
#include <set>

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<30
#define pb push_back
#define mp make_pair

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

int main() {
	int n, p, q;
	while(cin >> n >> p >> q) {
		if(n == 0 && p == 0 && q == 0) break;

		p = (p / 100) * 60 + p % 100;
		q = (q / 100) * 60 + q % 100;

		int cnt[5005];
		memset(cnt, 0, sizeof(cnt));

		rep(i,n) {
			int t;
			cin >> t;

			rep(j,t) {
				int a, b;
				cin >> a >> b;

				a = (a / 100) * 60 + a % 100;
				b = (b / 100) * 60 + b % 100;

				REP(k,a,b) {
					cnt[k]++;
				}
			}
		}

		int ans = 0, len = 0;
		REP(i,p,q) {
			if(cnt[i] == n) {
				len = 0;
				continue;
			}

			len++;
			ans = max(ans, len);
		}

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

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

public class Main {

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

  public void run() {

    try(BufferedReader in = new BufferedReader(new InputStreamReader(System.in))) {

      int n = Integer.parseInt(in.readLine());
      char[] ch = {'M','A','R','C','H'};
      long[] cnt = new long[5];
      String ln;
      for(int i=0; i<n; i++) {
        ln = in.readLine();
        char sf = ln.charAt(0);
        for (int j=0; j<ch.length; j++) {
          if(sf == ch[j]) {
            cnt[j]++;
            break;
          }
        }
      }

      long ans=0;
      for (int i=0; i<5; i++) {
        for (int j=i+1; j<5; j++) {
          for (int k=j+1; k<5; k++) {
            ans += cnt[i] * cnt[j] * cnt[k];
          }
        }
      }

      System.out.println(ans);
    }
    catch(IOException e) {
      System.err.println(e);
    }
  }
}

Measured memory_bytes: 30372
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>

using namespace std;

const int MOD = 1000000007;
typedef pair<int, int> P;
typedef long long ll;
#define rep(i, m, n) for(int i=m;i<n;i++)
#define rrep(i, n, m) for(int i=n;i>=m;i--)


int main() {
    ll H, W;
    cin >> H >> W;
    string s[H];
    rep(i, 0, H) {
        cin >> s[i];
    }

    int tate[W][H];
    int yoko[H][W];
    for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W; ++j) {
            if (s[i][j] == '#') {
                yoko[i][j] = 0;
            } else {
                yoko[i][j] = 1;
            }
        }
        for (int j = 0; j < W; ++j) {
            if (yoko[i][j] == 1 && j > 0) {
                yoko[i][j] += yoko[i][j - 1];
            }
        }
        for (int j = W - 1; j >= 0; --j) {
            if (yoko[i][j] != 0 && j - 1 >= 0 && yoko[i][j - 1] != 0) {
                yoko[i][j - 1] = yoko[i][j];
            }
        }
    }

    for (int j = 0; j < W; ++j) {
        for (int i = 0; i < H; ++i) {
            if (s[i][j] == '#') {
                tate[j][i] = 0;
            } else {
                tate[j][i] = 1;
            }
        }
        for (int i = 0; i < H; ++i) {
            if (tate[j][i] == 1 && i > 0) {
                tate[j][i] += tate[j][i - 1];
            }
        }
        for (int i = H - 1; i >= 0; --i) {
            if (tate[j][i] != 0 && i - 1 >= 0 && tate[j][i - 1] != 0) {
                tate[j][i - 1] = tate[j][i];
            }
        }
    }
    int ans = 0;
    rep(i, 0, H) {
        rep(j, 0, W) {
            ans = max(ans, tate[j][i] + yoko[i][j] - 1);
        }
    }
    cout << ans << endl;

}

Measured memory_bytes: 35584
N = int(input())
A = []
for i in range(2**N):
    A.append(int(input()))
i = 2**N
while i > 1:
    i //= 2
    for j in range(i):
        l = 2*j
        r = 2*j+1
        if A[l] < A[r]:
            A[j] = A[r]-A[l]
        elif A[l] > A[r]:
            A[j] = A[l]-A[r]
        else:
            A[j] = A[r]
print(A[0])

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

using namespace std;

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = long long;
using P = std::tuple<int,int>;

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

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

    ll X, Y;
    std::cin >> X >> Y;

    int t = 0;
    while(X <= Y){
        X <<= 1;
        ++t;
    }

    std::cout << t << std::endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string a;
    cin>>a;
    int l=a.length();
    int n=0,m=0;
    for(int i=0; i<(l/2); i++)
    {
        if(a[i]==a[l-1-i])
            n++;
    }
    if(n==(l/2))
    {
        for(int i=0; i<(l/4); i++)
        {
            if(a[i]==a[(l/2)-1-i])
                m++;
        }
    }
    if(m==(l/4))
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;


}


Measured memory_bytes: 256
#include <stdio.h>
#include <ctype.h>
int main(void)
{
	int i,count[26],num;
	char ch,low;
	for(i=0;i<26;i++){
		count[i]=0;
	}
	while(scanf("%c",&ch) != EOF){
		if(isalpha(ch)){
			low=tolower(ch);
			num=low-'a';
			count[num]++;
		}
	}
	for(i=0;i<26;i++){
		printf("%c : %d\n",'a'+i,count[i]);
	}
    return 0;
}

Measured memory_bytes: 548
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		//List<String> list= new ArrayList<String>(Arrays.asList(s.split("")));
		List<Integer> list=new ArrayList<Integer>();
		//Integer[] array = new Integer[m];
		int n = sc.nextInt();
		list.add(n);
		int i=1;
		loop :while(true) {
			i++;
			if(n%2==0) {
				n=n/2;
			}
			else {
				n=3*n+1;
			}
			for(int j=0;list.size()>j;j++) {
				if(n==list.get(j)) {
					break loop;
				}
			}
			list.add(n);
		}
		System.out.println(i);
		//System.out.println(list);
	}
}

Measured memory_bytes: 23764
import sys
readline = sys.stdin.buffer.readline
def even(n): return 1 if n%2==0 else 0

s = readline().rstrip().decode('utf-8')
res = int(s[-1])
if res == 2 or res==4 or res==5 or res== 7 or res==9:
    print("hon")
elif res == 3:
    print("bon")
else:
    print("pon")

Measured memory_bytes: 61896
#include <bits/stdc++.h>
using namespace std;
const int maxn = 50 + 10;
const double eps = 1e-8;
int n;
struct Point
{
	double x, y;
}p[maxn];
double xl, xr, yl, yr;
inline double sqr(const double & x) { return x * x;}
double dis(const Point & a, const Point & b)
{
	return sqr(a.x - b.x) + sqr(a.y - b.y);
}
double f2(double x, double y)
{
	auto Now = Point{x, y};
	double ret = 0;
	for(int i = 1; i <= n; ++i)
		ret = max(ret, dis(Now, p[i]));
	return ret;
}
double f(double x)
{
	yl = 0, yr = 1000;
	while(yr - yl >= eps)
	{
		double lmid = yl + (yr - yl) / 3;
		double rmid = yr - (yr - yl) / 3;
		if(f2(x, lmid) < f2(x, rmid))
			yr = rmid;
		else
			yl = lmid;
	}
	return f2(x, yl);
}
int main()
{
	scanf("%d", &n);
	for(int i = 1; i <= n; ++i)
		scanf("%lf%lf", &p[i].x, &p[i].y);
	xl = 0, xr = 1000;
	while(xr - xl >= eps)
	{
		double lmid = xl + (xr - xl) / 3;
		double rmid = xr - (xr - xl) / 3;
		if(f(lmid) < f(rmid))
			xr = rmid;
		else
			xl = lmid;
	}
	printf("%.7f\n", sqrt(f(xl)));
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}

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

  ll a, b, c, d;
  cin >> a >> b >> c >> d;
  cout << max(a*b, c*d)<< endl;
  
  
  //cout << fixed << setprecision(16) << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>

using namespace std;

int main(){
  const int size=50022;
  bool composite[size]={0};
  composite[0]=composite[1]=true;
  for(int i=0;i<size;i++){
    if(!composite[i]){
      for(int j=i*2;j<size;j+=i){
        composite[j]=true;
      }
    }
  }
  vector<int> array;
  int n;
  while(cin>>n){
    array.push_back(n);
  }

  for(auto number:array){
    int i=0;
    for(i=number-1;composite[i];i--);
    cout<<i<<" ";
    for(i=number+1;composite[i];i++);
    cout<<i<<endl;
  }
}

Measured memory_bytes: 1260
h, w = map(int, input().split())
a = []
for _ in range(h):
    aa = list(input())
    a.append(aa)
b = []
for i in range(h):
    if "#" in a[i]:
       b.append(a[i])
tra = list(map(list, zip(*b)))
ans = []
for i in range(len(tra)):
    if "#" in tra[i]:
       ans.append(tra[i])
ans = list(map(list, zip(*ans)))
for j in ans:
    print("".join(j))

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

#ifdef LOCAL
#include "dump.hpp"
#else
#define dump(...)
#define dumpv(...)
#endif

#define rep(i, n) for (int i = 0; i < (n); i++)
#define mins(x, y) (x = min(x, y))
#define maxs(x, y) (x = max(x, y))
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using P = pair<int, int>;
const int MOD = 1e9 + 7;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;

void solve() {
  string t;
  cin >> t;
  rep(i, t.size()) {
    if (t[i] == '?') t[i] = 'D';
  }
  cout << t << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  // freopen("temp.1", "r", stdin);
  solve();
  return 0;
}

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

int main(){
  int A, B;
  cin >> A >> B;
  if(13<=A){
    cout << B << endl;
  }
  else if(6 <= A && A <= 12){
    cout << B/2 << endl;
  }
  else{
    cout << 0 << endl;
  }
  
  return 0;
}


Measured memory_bytes: 256
def InsertionSort(A):
    i = 0
    j = 0
    print(' '.join([str(x) for x in A]))
    for i in range(1, N):
        movenum = A[i]
        j = i - 1
        while j >= 0 and movenum < A[j] : 
            
            A[j+1] = A[j]
        
            j -= 1

        A[j + 1] = movenum
        print(' '.join([str(x) for x in A]))

    
        
N = int(input())
A = [int(x) for x in input().split()]
InsertionSort(A)



Measured memory_bytes: 5612
#include <iostream>
#include <cstdio>
#include <cmath>
#define ll long long
using namespace std;
inline int read()
{
	int x = 0, f = 1; char ch = getchar();
	while(ch < '0' || ch > '9') {if(ch == '-') f = -1; ch = getchar();}
	while(ch >= '0' && ch <= '9') {x = (x << 3) + (x << 1) + (ch ^ 48); ch = getchar();}
	return x * f;
}
int n,m;
int main()
{
	cin >> n; m = log2(n);
	if(n == (1 << m)) {puts("No"); return 0;}
	puts("Yes");
	printf("%d %d\n",1,2);
	printf("%d %d\n",2,3);
	printf("%d %d\n",3,n + 1);
	printf("%d %d\n",n + 1,n + 2);
	printf("%d %d\n",n + 2,n + 3);
	for(int i = 2;i * 2 + 1 <= n;i ++)
	{
		printf("%d %d\n",1,2 * i);
		printf("%d %d\n",1,2 * i + 1);
		printf("%d %d\n",2 * i,2 * i + n + 1);
		printf("%d %d\n",2 * i + 1,2 * i + n);
	}
	if((n & 1) == 0)
	{
		for(int i = 2;i <= n;i ++)
		{
			if(i == 3) continue;
			int y = (i ^ n ^ 1);
			if(y == 3 || y > n) continue;
			printf("%d %d\n",n,i);
			printf("%d %d\n",2 * n,y);
			break;
		}
	}
	return 0;
}

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


public class Main {
	public static void main(String args[]) throws IOException{
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder builder = new StringBuilder();
		int num = Integer.parseInt(reader.readLine());
		String data[] = reader.readLine().split(" ");
		int[] ints = new int[num];
		for(int i=0; i<num; i++){
			ints[i] = Integer.parseInt(data[i]);
		}
		
		builder.append(Integer.toString(ints[num-1]));
		for(int i=2; i<=num; i++){
			builder.append(" ").append(Integer.toString(ints[num-i]));
		}
		
		System.out.println(builder);
		
	}
}

Measured memory_bytes: 16904
#import<bits/stdc++.h>
#define endl '\n'
using namespace std;
typedef long long LL;
LL i,j,k,l,m=-1e9,n,s,w,z,c[5040],p[5040],v[5040],x[5040],y[5040];
main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin>>n>>k;
	for(;i++<n;)cin>>p[i];
	for(i=0;i++<n;)
	{
		cin>>c[i];
		m=max(m,c[i]);
	}
	for(i=0;i++<n;)
	{
		if(!v[i])
		{
			for(j=i,s=w=0;!v[j];j=p[j])
			{
				w++;
				s+=c[j];
				v[j]=1;
			}
			s=max(s,0LL);
			for(j=i,l=0;l<w;j=p[j],l++)
			{
				x[j]=w;
				y[j]=s;
			}
		}
	}
	for(i=0;i++<n;)
	{
		for(j=i,l=s=0,z=min(x[i],k);l++<z;j=p[j])
		{
			s+=c[j];
			m=max(m,s+(k-l)/x[i]*y[i]);
		}
	}
	cout<<m;
}

Measured memory_bytes: 3848
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cmath>
using namespace std;
using ll = long long;

template <class T>
void chmin(T &a, T b) {
    if (b < a) a = b;
}

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

    int m = n - k;
    if (m == 0) {
        cout << 0 << endl;
        exit(0);
    }

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

    //dp[i]:l個の塊で最後の高さがh[i]のときの最小
    vector<ll> dp(n);
    for (int i = 0; i < n; i++) {
        dp[i] = h[i];
    }
    for (int l = 1; l < m; l++) {
        for (int i = n - 1; i >= l; i--) {
            ll t = 1LL << 60;
            for (int j = l - 1; j < i; j++) {
                chmin(t, dp[j] + max(h[i] - h[j], 0));
            }
            dp[i] = t;
        }
    }

    cout << *min_element(dp.begin() + m - 1, dp.end()) << endl;

    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i=0;i<((int)(n));i++)
#define reg(i,a,b) for(int i=((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i=((int)(n))-1;i>=0;i--)
#define ireg(i,a,b) for(int i=((int)(b));i>=((int)(a));i--)
typedef long long int lli;
typedef pair<int,int> mp;
#define fir first
#define sec second
#define IINF INT_MAX
#define LINF LLONG_MAX
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define pque(type) priority_queue<type,vector<type>,greater<type> >
#define memst(a,b) memset(a,b,sizeof(a))
#define iter(v,ite) for(auto ite=(v).begin();ite!=(v).end();ite++)
#define mimunum(v,x) distance((v).begin(),lower_bound((v).begin(),(v).end(),x))

int iv[200005];
vector<int> vs[200005];

int g[200005]={};
int dn[200005]={};


int gn(int p){
	int ng=0;
	vector<int> ds;
	rep(i,vs[p].size()){
		ds.push_back(g[vs[p][i]]);
	}
	sort(ds.begin(),ds.end());
	rep(i,ds.size()){
		if(ds[i]==ng)ng++;
	}
	return ng;
}

int main(void){
	int n;
	scanf("%d",&n);
	rep(i,n){
		int a;
		scanf("%d",&a); a--;
		vs[a].push_back(i);
		iv[i] = a;
		dn[a]++;
	}
	queue<int> que;
	rep(i,n){
		if(dn[i]==0)que.push(i);
	}
	
	memset(g,-1,sizeof(g));
	while(!que.empty()){
		int p=que.front();
		que.pop();
		g[p]=gn(p);
		int pa = iv[p];
		dn[pa]--;
		if(dn[pa]==0){
			que.push(pa);
		}
	}
	
	int st=-1;
	rep(i,n){
		if(g[i]<0)st=i;
	}
	
	vector<int> ds;
	rep(i,vs[st].size()){
		int to=g[vs[st][i]];
		if(to<0)continue;
		ds.push_back(to);
	}
	sort(ds.begin(),ds.end());
	
	ds.push_back(-1);
	ds.push_back(-1);
	ds.push_back(-1);
	int x=0;
	int ndp=0;
	int nd[2];
	rep(i,ds.size()){
		//printf("%d ",ds[i]);
		if(ds[i]==x)x++;
		else{
			nd[ndp]=x; ndp++;
			x++;
			if(ndp>=2)break;
		}
	}
	
	//printf("st %d : %d %d\n",st,nd[0],nd[1]);
	
	bool ok = false;
	rep(k,2){
		bool nok = false;
		g[st]=nd[k];
		int no=iv[st];
		for(;;){
			g[no] = gn(no);
			int to=iv[no];
			if(to==st)break;
			no = to;
		}
		if(k==0 && g[no]!=g[st])nok=true;
		if(k==1 && g[no]==nd[0])nok=true;
		
		if(nok){
			ok=true;
			//rep(i,n)printf("%d : %d\n",i,g[i]);
		}
		
		no=st;
		for(;;){
			g[no] = -1;
			no = iv[no];
			if(no==st)break;
		}
		
	}
	
	puts(ok?"POSSIBLE":"IMPOSSIBLE");
		
	return 0;
}






Measured memory_bytes: 12672
#include <stdio.h>
int main(){
  int a,b,c;
  scanf("%d%d%d",&a,&b,&c);
  if (c>a && b>c) printf("Yes\n");
  else if (c<a && b<c) printf("Yes\n");
  else printf("No\n");
  return 0;
}


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

int main(){
    int n;
    int a;
    int b;
    int t_cost;
    cin >> n >> a >> b;
    t_cost = n * a;
    if(t_cost > b){
        cout << b << endl;
    }else{
        cout << t_cost << endl;
    }
}

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

using namespace std;

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

	while(n--)
	{
		string str;
		string kp;
		string set;
		int flag=0;
		int count=0;
		int count_b=0;
		int i=0;

		cin >> str;
		for(i=0;i<2;i++)kp+=str[i]++;
		
		if(kp==">'")
		{
			while(str[i]!='#')
			{
				if(str[i]=='=')count++;
				else flag=-1;

				if(flag==-1)break;
				i++;	
			}
			i++;
			while(str[i]!='~')
			{
				if(str[i]=='=')count_b++;
				else flag=-1;

				if(flag==-1)break;
				i++;
			}
			if(flag!=-1 && count==count_b && count>=1)flag=1;

			count=0;
			for(int j=i;j<str.length();j++)
			{
				if(str[i]!='~')flag=-1;
				else count++;

				if(flag==-1)break;
			}
			if(count!=1)flag=-1;
		}
		else if(kp==">^")
		{
			while(i<str.length()-2)
			{
				count=2;
				while(count--)
				{
					set+=str[i];
					i++;
				}
				if(set=="Q=")flag=2;
				else flag=-1;

				set.erase(set.begin(),set.end());
				if(flag==-1)break;
			}
			for(i=str.length()-2;i<str.length();i++)set+=str[i];
			if(set=="~~" && flag==2)flag=2;
			else flag=-1;
		}

		if(flag==1) cout << "A" << endl;
		else if(flag==2)cout << "B" << endl;
		else cout << "NA" << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1212
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int A[] = new int[N];
		for (int i = 0; i < N; i++) {
			A[i] = sc.nextInt();
		}
		int count = 0;
		for (int i = 0; i < N; i++) {
			int min = i;
			for (int j = i; j < N; j++) {
				if (A[min] > A[j]) {
					min = j;
				}
			}
			if (A[i] != A[min]) {
				count++;
			}
			int temp = A[i];
			A[i] = A[min];
			A[min] = temp;
		}
		for (int i = 0; i < N; i++) {
			if (i == N - 1) {
				System.out.println(A[i]);
			} else {
				System.out.print(A[i] + " ");
			}
		}
		System.out.println(count);
	}
}


Measured memory_bytes: 26364
//
// Created by yuu on 2019-06-29.
//

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <utility>
#include <math.h>
#include <stack>
#include <queue>
#include <cstdio>

using namespace std;


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

    if(s[0]==s[1] && s[2]==s[3] && s[0] != s[2] && s[0] != s[3]){
        cout<<"Yes"<<endl;
        return 0;
    }else if(s[1]==s[2] && s[0]==s[3] && s[0] != s[1] && s[0] != s[2]){
        cout<<"Yes"<<endl;
        return 0;
    }else if(s[0]==s[2] && s[1]==s[3] && s[0] != s[1] && s[0] != s[3]) {
        cout<<"Yes"<<endl;
        return 0;
    }
    else{
        cout<<"No"<<endl;
        return 0;
    }



    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
string t,s[] = {"Rock", "Fire", "Scissors", "Snake", "Human","Tree", "Wolf", "Sponge", "Paper", "Air","Water", "Dragon", "Devil", "Lightning", "Gun" };
int a[30],b[30];
main(){
	int n;
	while(cin>>n,n){
		set<int>st;
		r(i,30)a[i]=b[i]=0;
		r(i,n){
			cin>>t;
			r(j,15)if(s[j]==t){
				st.insert(j);
				r(k,7){
				  b[j]++;
			  	  a[(j+k+1)%15]++;
			  	}
			 }
		}
		vector<string>v;
		r(i,15)if(b[i]&&!a[i])v.push_back(s[i]);
		if(v.size()==1&&st.size()!=1)cout<<v[0]<<endl;
		else cout<<"Draw"<<endl;
	}
}

Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(ll i=(a); i<(b); i++)
double l;
int main() {
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    cout<<fixed;
    cout<<setprecision(7);
    cin>>l;
    cout<<l*l*l/27<<"\n";
}


Measured memory_bytes: 256
H,W = map(int,input().split())
L = []
for i in range(H):
  L.append(list(input()))
dy_dx = [[1,0],[-1,0],[0,1],[0,-1]]
cnt = 0
for i in range(H):
  for j in range(W):
    d = 0
    if L[i][j] == '#':
      for p in range(4):
        if 0 <= i+dy_dx[p][0] <= H-1 and 0 <= j+dy_dx[p][1] <= W-1:
          if L[i+dy_dx[p][0]][j+dy_dx[p][1]] == '.':
            d += 1
      if 1 <= i <= H-2 and 1 <= j <= W-2:
        if d == 4:
          cnt += 1
      elif i == 0 and j == 0:
        if d == 2:
          cnt += 1
      elif i == 0 and j == W-1:
        if d == 2:
          cnt += 1
      elif i == H-1 and j == 0:
        if d == 2:
          cnt += 1
      elif i == H-1 and j == W-1:
        if d == 2:
          cnt += 1
      else:
        if d == 3:
          cnt += 1
if cnt == 0:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3064
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int top,S[1000];
void push(int x){
	S[++top]=x;//top???1?¶?????????????????????????????????\
}

int pop(){
	top--;
	return S[top+1];
}

int main(){
	int a, b;
	top =0;
	char s[100];
	while(scanf("%s",s)!=EOF){
		if(s[0]=='+'){
			a=pop();
			b=pop();
			push(a+b);
		}
		else if(s[0] == '-'){
			b=pop();
			a=pop();
			push(a-b);//???????????§???
		}
		else if(s[0] =='*'){
			a=pop();
			b=pop();
			push(a*b);
		}
		else push(atoi(s));//()??????int?????????????????????push
	}
	printf("%d\n",pop());

	return 0;
}

Measured memory_bytes: 2708
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cstdint>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <chrono>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
#include <random>
#include <utility>
#include <limits>
#include <list>
#include <type_traits>

/* template start */
 
#define rep(i, a, b) for (long long i = (a); (i) < (b); (i)++)
#define all(i) i.begin(), i.end()

#ifdef LOCAL
#define debug(...) std::cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

void debug_out(){std::cerr<<std::endl;}

template<typename Head,typename... Tail>
void debug_out(Head h,Tail... t){
  std::cerr<<" "<<h;
  if(sizeof...(t)>0)std::cout<<" :";
  debug_out(t...);
}
 
template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2> pa) {
  return os << pa.first << " " << pa.second;
}
 
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (std::size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}
 
template<typename T1,typename T2>
inline bool chmax(T1& a,T2 b){return a<b && (a=b,true);}
 
template<typename T1,typename T2>
inline bool chmin(T1& a,T2 b){return a>b && (a=b,true);}

template<typename Num>
constexpr Num mypow(Num a, long long b) {
  if(b==0)return 1;
  if (a==0)return 0;
  Num x = 1;
  while (b > 0) {
    if(b & 1)x*=a;
    a*=a;
    b >>= 1;
  }
  return x;
}

/* template end */

using ll = long long;

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

  ll x;
  std::cin>>x;

  std::cout<<10-x/200<<"\n";

  return 0;
}

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


int main() {
  int64_t N;
  cin >> N;
  int64_t ans = 0;
  for(int i = 1; i <= N; i++) {
    int64_t y = N / i;
    ans += y * (y + 1) * i / 2;
  }
  cout << ans << endl;
}

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

int main(){
    int N ,K;
    cin >> N >> K;

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

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

    int sum = 0;
    for(int i=0; i<K; i++){
        sum += vec.at(i);
    }
    cout << sum << endl;
}

Measured memory_bytes: 3624
#include<iostream>
#include<iomanip>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
 
using namespace std;
 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return
#define C(i) cin>>i
#define C2(i,j) cin>>i>>j
#define C3(i,j,k) cin>>i>>j>>k
#define C4(i,j,k,m) cin>>i>>j>>k>>m
////////////////////////////////////////////////////////////

int minc[10] = {};
int cost[10][10] = {};
int m = 0xFFFF;

void solve(int start,int now, map<int,bool> mp , int bef , int c){
  if(c > m)
    ret;

  if(now == 1 ){
    m = min(c,m);
  }
  else{
    mp[now] = true;
    rep(i,0,10){
      if(!mp[i]){
        if(bef != 11){
          if(minc[i] != -1)
            solve(start,1,mp,now,c+ cost[now][i] + minc[i]);
          else
            solve(start,i,mp,now,c+cost[now][i]);
        }
        else
          solve(start,i,mp,now,c+cost[now][i]);
      }
    }
  }

  ret;
}

int main(){
  int h,w;
  cin >> h >> w;
  
  rep(i,0,10)
    rep(j,0,10)
      cin >> cost[i][j];
  
  int a[h][w];

  rep(i,0,h)
    rep(j,0,w)
      cin >> a[i][j];
  
  rep(i,0,10){
      minc[i] = -1;
  }
  minc[1] = 0;  
  
  map<int,bool> mp;
  rep(i,0,10){
    if(i!=1){
      solve(i,i,mp,11,0);
      minc[i]=m;
      m=0xFFFF;
    }
  }

  long ans = 0;

  rep(i,0,h){
    rep(j,0,w){
      if(a[i][j] != -1){
        ans += minc[ a[i][j] ];
      }
    }
  }

  P(ans);

  ret 0;
}

Measured memory_bytes: 384
#include <stdio.h>
main()
{
    int a, b;
    scanf("%d%d", &a, &b);
    if (a>b)
	printf("a > b");
	if (a<b)
	printf("a < b");
	if (a==b)
	printf("a == b");
	printf("\n");
	return 0;
}


Measured memory_bytes: 2080
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            char[] oddcode = Console.ReadLine().ToCharArray();
            char[] evencode = Console.ReadLine().ToCharArray();
            string code = "";
            for (int i = 0; i < evencode.Length; i++)
            {
                code = code + oddcode[i] + evencode[i];
            }
            if (oddcode.Length != evencode.Length)
            {
                code = code + oddcode.Last();
            }
            Console.WriteLine(code);
        }
    }
}

Measured memory_bytes: 13268
l = int(input())
while l != 0:
	k = 0
	A = []
	B = []
	for l in range(0,l):
		li = input().split()
		if li[0] in A:
			i = A.index(li[0])
			B[i] = B[i] + (int(li[1]) * int(li[2]))
		else:
			A.append(li[0])
			B.append(int(li[1]) * int(li[2]))
	for j,b in enumerate(B):
		if b >= 10**6:
			print(A[j])
			k = 1
		
	if k == 0:
		print("NA")
	l = int(input())

Measured memory_bytes: 7884
#include <iostream>
#include <vector>

/*
          /a + /b < /c
  a + b + 2 * /ab < c
          2 * /ab < c - a - b
           4 * ab < (c - a - b) ** 2
*/

int main(int argc, char *argv[]) {
  long long a, b, c;
  std::cin >> a >> b >> c;
  long long d = c - a - b;
  if (d <= 0) {
    std::cout << "No" << std::endl;
    return 0;
  }

  if (4 * a * b < d * d)
    std::cout << "Yes" << std::endl;
  else
    std::cout << "No" << std::endl;
}


Measured memory_bytes: 888
function Main(input){
	input = input.split("\n")[0].split("").map(a=>~~a);
  var A = input[0];
  var B = input[1];
  var C = input[2];
  var D = input[3];
 	var hoge = {"1":"+","-1":"-"};
  var seven = "=7"
  for(var i = -1; i < 2; i+=2){
  for(var j = -1; j < 2; j+=2){
  for(var k = -1; k < 2; k+=2){
  	if(A+i*B+j*C+k*D==7){
    	return [A,hoge[i],B,hoge[j],C,hoge[k],D,seven].join("")
    }
  }
  }
  }
  
}

console.log(Main(require("fs").readFileSync("/dev/stdin", "utf8")));

Measured memory_bytes: 7500
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			String s = sc.next();
			int k = sc.nextInt();
			String[] arr = new String[k];
			int len = s.length();
			for (int i = 0; i < len; i++) {
				for (int j = i + 1; j <= len && j <= i + k; j++) {
					String next = s.substring(i, j);
					for (int at = 0; at < k; at++) {
						if (arr[at] == null) {
							arr[at] = next;
							break;
						}
						if (next.compareTo(arr[at]) > 0) {
							continue;
						} else if (next.compareTo(arr[at]) == 0) {
							break;
						} else {
							for (int mv = k - 1; mv > at; mv--) {
								arr[mv] = arr[mv - 1];
							}
							arr[at] = next;
							break;
						}
					}
				}
			}
			System.out.println(arr[k - 1]);
		}
	}
}

Measured memory_bytes: 38328
H,W=map(int,input().split())

s=[]

for r in range(H):
    s.append(list(input()))

c=[[200]*W for i in range(H)]
if s[0][0]==".":
    c[0][0]=0
else:
    c[0][0]=1

def rec(y,x):
    if c[y][x]!=200:
        return c[y][x]
    elif y==0 and x!=0:
        temp=rec(y,x-1)
        if s[y][x]!=s[y][x-1]:
            if s[y][x]=="#":
                temp+=1
        c[y][x]=temp
        return temp
    elif y!=0 and x==0:
        temp=rec(y-1,x)
        if s[y][x]!=s[y-1][x]:
            if s[y][x]=="#":
                temp+=1
        c[y][x]=temp
        return temp
    else:
        temp1 = rec(y, x - 1)
        if s[y][x] != s[y][x-1]:
            if s[y][x] == "#":
                temp1 += 1
        temp2 = rec(y - 1, x)
        if s[y][x] != s[y - 1][x]:
            if s[y][x] == "#":
                temp2 += 1
        temp=min(temp1,temp2)
        c[y][x]=temp
        return temp

ans=rec(H-1,W-1)

print(ans)



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

int main() {
    int a, b;
    cin >> a >> b;
    string c = to_string(a);
    string s = c;
    string d = to_string(b);
    string t = d;
    for (int i = 0; i < b - 1; ++i) {
        c.append(s);
    }
    for (int j = 0; j < a - 1; ++j) {
        d.append(t);
    }
    cout << min(c, d) << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define ALL(A) A.begin(),A.end()
const long long mod=1000000007;
const int INF=1000000;
int A,B,C,l[100],n;

//dfsの関数は４変数それぞれに対し値を変える(値を持っている)ことを意識する
/*dfsが竹0から竹n-1に向けて、A,B,Cそれぞれに竹を加える場合
、加えない場合を試していく。
竹n-1の全パターンを試した後それぞれのdfs関数に1ずつ伸縮しなきゃいけない値
を計算してminを返しつつ戻っていく
つまりdfsという関数が返す値はbam本目までの竹を使って
a、b、cという３本の竹を作るときの
最小の使用MPである
*/
int dfs(int bam,int a,int b,int c)
{
    if(bam==n)
    {
        if(a==0||b==0||c==0)
        return INF;
        else
        {
            return(abs(a-A)+abs(b-B)+abs(c-C)-30);
        }
        
    }   

    int x1=dfs(bam+1,a,b,c);
    int x2=dfs(bam+1,a+l[bam],b,c)+10;
    int x3=dfs(bam+1,a,b+l[bam],c)+10;
    int x4=dfs(bam+1,a,b,c+l[bam])+10;
    return(min({x1,x2,x3,x4}));
}
int main(){
    cin>>n>>A>>B>>C;
    for(int i=0;i<n;i++)
    cin>>l[i];
    cout<<dfs(0,0,0,0);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;

int a[200000];
map<ll, ll> dp;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    ll sum = 0;
    dp[0] = 1;
    ll sol = 0;
    for (int i = 0; i < n; ++i)
    {
        cin >> a[i];
        sum += a[i];
        sol += dp[sum];
        dp[sum]++;
    }
    cout << sol;
}


Measured memory_bytes: 13568
#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>;

void Main()
{
  vector<char> v;
  string S;
  cin >> S;
  int N = S.size();
  rep(i,N) {
    v.push_back(S[i]);
  }
  int removed = 0;
  int idx = 0;
  int vsize = v.size();
  while (idx < vsize-1) {
    //cout << idx << ", " << v.size() << endl;
    if (v[idx] != v[idx+1]) {
      v.erase(v.begin()+idx); v.erase(v.begin()+idx);
      idx = 0; //最初からチェックし直し
      removed += 2;
    } else idx++;
    vsize = v.size();
  }
  cout << removed << endl;
}

int main()
{
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  Main();
  return 0;
}

Measured memory_bytes: 640
#include<stdio.h>
#include<stdlib.h>
#define N 2e6
#define K 10000

void CountingSort(int*, int*, int);

void CountingSort(int *A, int *B, int n){

  int i;

  int *C=(int*)malloc(sizeof(int)*K);

  for(i=0;i<=K;i++) C[i]=0;

  for(i=1;i<=n;i++) C[A[i]]++;

  for(i=1;i<=K;i++) C[i]+=C[i-1];

  for(i=n;i>0;i--){

    B[C[A[i]]]=A[i];

    C[A[i]]--;

  }free(C);

  return;

}

int main(){

  int i, n;

  scanf("%d", &n);

  int *A=(int*)malloc(sizeof(int)*N);

  int *B=(int*)malloc(sizeof(int)*N);

  for(i=1;i<=n;i++) scanf("%d", &A[i]);

  CountingSort(A, B, n);

  printf("%d", B[1]);

  for(i=2;i<=n;i++) printf(" %d", B[i]);

  printf("\n");

  free(A);
  free(B);

  return 0;

}



Measured memory_bytes: 17068
n=gets.chomp.split.map(&:to_f)
num=0
for i in 1..n[0] do
 if i>=1&&i<=9
 num=num+1
 end
 if i>=100&&i<=999
 num=num+1
 end
 if i>=10000&&i<=99999
 num=num+1
 end
 
end
puts num

Measured memory_bytes: 1916
#include <bits/stdc++.h>
#define rep(i,l,n) for(int i=l;i<n;i++)
#define rer(i,l,n) for(int i=l;i<=n;i++)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int,int> pii;


int days(int y,int m,int d){
	if(m<=2){
		y--; m+=12;
	}
	return 365*y+y/4-y/100+y/400+306*(m+1)/10+d-429;
}

int main(){
	int y1,m1,d1,y2,m2,d2;
	while(1){
		cin>>y1>>m1>>d1>>y2>>m2>>d2;
		if(y1<0||m1<0||d1<0||y2<0||m2<0||d2<0) break;
		o(days(y2,m2,d2)-days(y1,m1,d1));
	}
}

Measured memory_bytes: 1160
use std::io::*;

fn read() -> String {
    let s = stdin();
    let b = s.bytes()
        .map(|c| c.unwrap() as char)
        .take_while(|c| !c.is_whitespace())
        //.collect::<Vec<char>>();
		.collect::<String>();
	b
}

fn main() {
	let n = read().parse::<u64>().unwrap();
	let ch = false;
	let mut b = 1;
	let mut bb = 1;

	while bb <= n {
		b += 1;
		bb = b * b;
	}
	println!("{}", (b - 1) * (b - 1));
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb(x) push_back(x)
#define mp make_pair
#define sz(x) ((int)(x).size())
#define endl "\n"
#define fastio ios_base::sync_with_stdio(false); cin.tie(nullptr);
#define all(x) x.begin(),x.end()
#define y1 omg
#define INF 1000000010
#define FOR(x, n) for(int x=0; x<n; x++)
#define ini(x, n) memset(x, n, sizeof(x));
#define MOD (int)1e9 + 7
#define atoi(x) ((x)-'0')
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;

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

char c;

int main() {
	cin >> c;
	if ('A' <= c && c <= 'Z') cout << 'A';
	else cout << 'a';
}

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

int main()
{
    int a[1000],b[1000];
    int n;
    cin>>n;
    int i;
    for(i=0;i<n;i++)
    {
        cin>>a[i];
        b[i]=a[i];
    }
    sort(b,b+n);
    int num=0;
    for(i=0;i<n;i++)
    {
        if(a[i]!=b[i])
            num++;
    }
    if(num>2)
        cout<<"NO"<<endl;
    else
        cout<<"YES"<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.StringTokenizer;

public class Main {


  private void solve(InputReader in, PrintWriter out) {
    String s = in.next();
    char[] chars = s.toCharArray();
    long b = 0;
    long count = 0;
    for (int i = 0; i < chars.length; i++) {
      if (chars[i] == 'B') {
        b++;
      } else {
        count += b;
      }
    }
    out.print(count);

  }


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

  private void run() {

    try (InputReader in = new InputReader(System.in);
         PrintWriter out = new PrintWriter(System.out)) {
      solve(in, out);
    }
  }


  static class InputReader implements AutoCloseable {
    private BufferedReader reader;
    private StringTokenizer tokenizer;

    InputReader(InputStream stream) {
      //reader = new BufferedReader(new FileReader(stream), 32768);
      reader = new BufferedReader(new InputStreamReader(stream), 32768);
      tokenizer = null;
    }

    String next() {
      while (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          tokenizer = new StringTokenizer(reader.readLine());
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }
      return tokenizer.nextToken();
    }

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

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

    public double nextDouble() {
      return Double.parseDouble(next());
    }

    @Override
    public void close() {
    }
  }

}


Measured memory_bytes: 26196