akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
using namespace std;
using ll = long long;
using P = pair<int,int>;

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

Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
typedef long long ll;
typedef vector<int> BigDecimal;

int n,k,m,r;
BigDecimal tmp(10010);

void Div(ll x){
  ll now = 1LL;
  for(int i=0;i<r+10;i++){
    tmp[i] = now/x;
    now %= x;
    now *= 10;
  }
}

void print(const BigDecimal &b){
  cout << b[0] << ".";
  for(int i=1;i<=r;i++)cout << b[i];
  cout << endl;
}

int main(){
  while(cin >> n >> k >> m >> r,n){
    Div(n);
    BigDecimal res = tmp;
    if(m==1){
      for(ll i=1;i<n;i++){
	Div(i*n);
	for(int j=0;j<r+10;j++)res[j] += tmp[j];
      }
      for(int j=r+10-1;j>0;j--){
	res[j-1] += res[j]/10;
	res[j] %= 10;
      }
    }

    print(res);
  }
}

    

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

using namespace std;

typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;

int main() {
    ll n, m, i, j, k;
    string s;
    cin >>s;
    vector<ll> a(27,0);
    for(i=0;i<s.size();i++){
        a[s[i]-'a']++;
    }
    ll ret = s.length();
    ret = ret*(ret-1)/2;
    for(i=0;i<27;i++){
        ret -= a[i]*(a[i]-1)/2;
    }
    cout << ret+1 << endl;
    return 0;
}

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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repp(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perr(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD 1000003
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
#define CFS cin.tie(0);ios::sync_with_stdio(false)

typedef long long LL;
typedef long double LD;

LL modpow(LL x, LL a){
  LL ans=1;
  while(a){
    if(a&1) ans=ans*x%MOD;
    a>>=1;
    x=x*x%MOD;
  }
  return ans;
}

LL inv(LL x){
  return modpow(x, MOD-2);
}

int main(){
  int q;
  cin >> q;
  LL x,d,n;
  vector<LL> fact(MOD);
  fact[0]=1;
  repp(i,1,MOD) fact[i]=fact[i-1]*i%MOD;
  rep(t,q){
    cin >> x >> d >> n;
    if(d==0){
      cout << modpow(x,n) << endl;
      continue;
    }
    LL p = x*inv(d)%MOD;
    if(MOD<=p+n-1||p==0){
      cout << 0 << endl;
      continue;
    }
    cout << fact[p+n-1]*inv(fact[p-1])%MOD*modpow(d,n)%MOD << endl;
  }
  return 0;
}


Measured memory_bytes: 8704
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int h = sc.nextInt();
		int w = sc.nextInt();
		int K = sc.nextInt();

		int[][] input = new int[h][w];
		for(int i = 0; i < h; i++){
			String tmp = sc.next();
			for(int j = 0; j < w; j++){
				input[i][j] = tmp.charAt(j) - '0';
			}
		}
		int[][] sumWhite = new int[h + 1][w + 1];

		for(int i = 1; i <= h; i++){
			for(int j = 1; j <= w; j++){
				sumWhite[i][j] = sumWhite[i - 1][j] + sumWhite[i][j - 1] - sumWhite[i - 1][j - 1];
				if(input[i - 1][j - 1] == 1){
					sumWhite[i][j]++;
				}
//				System.out.print(sumWhite[i][j]+" ");
			}
//			System.out.println();
		}

		int result = Integer.MAX_VALUE;
loop:		for(int i = 0; i < Math.pow(2, h - 1) ; i++){
			boolean[] horizon = new boolean[h - 1];

			int tmpI = i;
			int cut = 0;
			for(int j = 0; j < h - 1; j++){
				if(tmpI % 2 == 1){
					horizon[j] = true;
					cut++;
				}
				tmpI /= 2;
//				System.out.print(horizon[j]+ " ");
			}
//			System.out.println();

			int prevVert = 0;

			for(int j = 0; j < w; j++){
				int prevHor = 0;
				for(int k = 0; k < h; k++){
					if(k == h - 1 || horizon[k]){
//						System.out.println("check at "+k+","+j);
						int white = sumWhite[k + 1][j + 1] - sumWhite[prevHor][j + 1]
								- sumWhite[k + 1][prevVert] + sumWhite[prevHor][prevVert];
//						System.out.println("white "+white);
						prevHor = k + 1;
						if(white > K){
							if(prevVert == j){
//								System.out.println("abort");
								continue loop;
							}
							else {
//								System.out.println("cut vertical at "+j);
								prevVert = j;
								cut++;
								break;
							}
						}
					}
				}
			}
			result = Math.min(result, cut);
		}

		System.out.println(result);

	}

}


Measured memory_bytes: 28628
#include<bits/stdc++.h>
#define mo 998244353
#define ny 499122177
#define maxn 1000000000000000000LL
#define pi 3.1415926535898
#define eps 1e-9 
using namespace std;
long long read(){
    long long xx=0,flagg=1;
    char ch=getchar();
    while((ch<'0'||ch>'9')&&ch!='-')
        ch=getchar();
    if(ch=='-'){
        flagg=-1;
        ch=getchar();
    }
    while(ch>='0'&&ch<='9'){
        xx=xx*10+ch-'0';
        ch=getchar();
    }
    return xx*flagg;
}
void pus(long long xx,long long flagg){
    if(xx<0){
        putchar('-');
        xx=-xx;
    }
    if(xx>=10)
        pus(xx/10,0);
    putchar(xx%10+'0');
    if(flagg==1)
        putchar(' ');
    if(flagg==2)
        putchar('\n');
    return;
}
long long n,i,x,zz[100005],sum[100005],sum2[100005];
struct nyh{
	long long x,id;
}o[100005];
map<long long,long long> mp;
bool cmp(nyh u,nyh v){
	return u.x<v.x;
}
int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	n=read();
	for(i=1;i<=n;i++){
		o[i].x=read();
		o[i].id=i;
	}
	sort(o+1,o+n+1,cmp);
	for(i=1;i<=n;i++){
		mp[o[i].x]=i;
		sum[i]=1;
	}
	for(i=n;i>=2;i--){
		x=o[i].x-n+sum[i]*2;
		if(mp[x]!=0&&mp[x]<i){
			zz[i]=mp[x];
			sum[zz[i]]+=sum[i];
			sum2[zz[i]]+=sum[i]+sum2[i];
		}
		else{
			pus(-1,2);
			return 0;
		}
	}
	if(sum2[1]!=o[1].x){
		pus(-1,2);
		return 0;
	}
	for(i=n;i>=2;i--){
		pus(o[zz[i]].id,1);
		pus(o[i].id,2);
	}
	return 0;
}

Measured memory_bytes: 11520
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<ll,ll> ii;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define RST(i,n) memset(i,n,sizeof i)
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(),a.end()
#define X first
#define Y second
#define mkp make_pair
#define pb push_back
#define eb emplace_back
#define pob pop_back
#ifdef cold66
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<", ";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // cold66
//}
template<class T> inline bool chkmax(T &a, const T &b) { return b > a ? a = b, true : false; }
template<class T> inline bool chkmin(T &a, const T &b) { return b < a ? a = b, true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;

const ll MAXn=1e5+5,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=0x3f3f3f3f;

vector<ii> ans;
int main(){
    IOS();
    ll n;
    cin >> n;
    if (n&1) {
        REP1 (i,n) for (ll j=i+1;j<=n;j++) {
            if (j == n-i) continue;
            ans.eb(i,j);
        }
    }
    else {
        REP1 (i,n) for (ll j=i+1;j<=n;j++) {
            if (j == n-i+1) continue;
            ans.eb(i,j);
        }
    }
    cout << SZ(ans) << endl;
    REP (i,SZ(ans)) cout << ans[i].X << ' ' << ans[i].Y << endl;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,ans=0;
    cin>>n;
    int arr[n];
    for(int i=0; i<n; i++)
        cin>>arr[i];
    sort(arr,arr+n);
    for(int i=0; i<n-1; i++)
        ans+=abs(arr[i]-arr[i+1]);
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

int main()
{
	char a[200], b[200];
	int i, j, k, x, y, z;
	scanf("%s", a);
	for(i = 0 ; i < 200 ; i++)
	{
		if(a[i] == 0)
		{
			x = i;
			//printf("%d\n", i);
			break;
		}
	}
	scanf("%s", b);
	for(i = 0 ; i < 200 ; i++)
	{
		if(b[i] == 0)
		{
			y = i;
			//printf("%d\n", i);
			break;
		}
	}
	for(i = 0 ; i < x ; i++)
	{
		z = 0;
		if(a[i] == b[0])
		{
			for(j = 0, k = i; j < y ; j++, k++)
			{
				if(a[k] != b[j])
				{
					z = 1;
					break;
				}
				if(k == (x-1))
				{
					k = -1;
				}
			}
			if(z == 0)
			{
				printf("Yes\n");
				exit(0);
			}
		}
	}
	printf("No\n");
	return 0;
}


Measured memory_bytes: 2092
#include <bits/stdc++.h>
#define int long long
#define bp __builtin_popcountll
#define pb push_back
#define in(s) freopen(s, "r", stdin);
#define inout(s, end1, end2) freopen((string(s) + "." + end1).c_str(), "r", stdin),\
		freopen((string(s) + "." + end2).c_str(), "w", stdout);
#define fi first
#define se second
#define bw(i, r, l) for (int i = r - 1; i >= l; i--)
#define fw(i, l, r) for (int i = l; i < r; i++)
#define fa(i, x) for (auto i: x)
using namespace std;
const int mod = 1e9 + 7, inf = 1061109567;
const long long infll = 4557430888798830399;
string s;
signed main() {
	#ifdef BLU
	in("blu.inp");
	#endif
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> s;
	int cur = s.length() - 1, ans = 0;
	bw (i, s.length(), 0) if (s[i] == 'B') {
		ans += cur - i;
		cur--;
	}
	cur = 0;
	fw (i, 0, s.length()) if (s[i] == 'W') {
		ans += i - cur;
		cur++;
	}
	cout << ans / 2;
	return 0;
}

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


int main (){
    int Max=-1,Min=1e9+7;
    int tmp;
    int n;scanf("%d",&n);
    for(int i=0;i<n;i++) {
        scanf("%d",&tmp);
        Min=min(Min,tmp);
        Max=max(Max,tmp);
    }
    cout<<Max-Min<<endl;
    return 0;
}


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

long long ara[200003],tra[200003];

int main()
{


    long long n,m,a,b,c,d,e,f,g,h,p,q,r,fr,sc,tr,sz,tz,i,j,k,mx=LLONG_MIN,mn=LLONG_MAX;
    long long x=0,y=0,cnt=0,res=0,ttl=0,ans=0,sum=0;long long flg=0,flag=1,na=0,as=1;
    vector<long long>u,v,w;vector< pair<long long,long long> >vct;vector<string>vst;
    set<long long>st,nt,tt;map<long long,long long>mp,nq,qr;string str,ttr,ntr;

    scanf("%lld %lld %lld",&n,&m,&k);

    for(i=1; i<=n; i++)
    {
        scanf("%lld",&a);
        cnt=cnt+a;
        ara[i]=cnt;
    }

    for(i=1; i<=m; i++)
    {
        scanf("%lld",&a);
        sum=sum+a;
        tra[i]=sum;
    }

    if(n<=m)x=1;
    else
    {
        x=2;
    }


    long long lo,hi,mid;
    lo=0;
    hi=n+m;

    while(lo<hi)
    {


        mid=(lo+hi)/2;
        flg=0;

        if(x==1)
        {

            fr=min(n,mid);

            for(i=fr; i>=0; i--)
            {
                f=ara[i];

                if(mid-i>m)break;

                g=tra[mid-i];

                sc=f+g;

                if(sc<=k)
                {
                    flg=1;
                    break;
                }
            }



        }
        else
        {

            fr=min(m,mid);

            for(i=fr; i>=0; i--)
            {
                f=tra[i];

                if(mid-i>n)break;

                g=ara[mid-i];

                sc=f+g;

                if(sc<=k)
                {
                    flg=1;
                    break;
                }

            }


        }


        if(flg==1)
        {
            ans=mid;
            lo=mid+1;

            if(lo==hi)
            {
                ///

                mid=(lo+hi)/2;
                flg=0;

                if(x==1)
                {

                    fr=min(n,mid);

                    for(i=fr; i>=0; i--)
                    {
                        f=ara[i];

                        if(mid-i>m)break;

                        g=tra[mid-i];

                        sc=f+g;

                        if(sc<=k)
                        {
                            flg=1;
                            break;
                        }

                    }



                }
                else
                {

                    fr=min(m,mid);

                    for(i=fr; i>=0; i--)
                    {
                        f=tra[i];

                        if(mid-i>n)break;
                        g=ara[mid-i];

                        sc=f+g;

                        if(sc<=k)
                        {
                            flg=1;
                            break;
                        }

                    }


                }


                if(flg==1)
                {
                    ans=mid;
                }


                ///


            }

        }
        else
        {
            hi=mid;
        }




    }




    printf("%lld\n",ans);






    return 0;
}





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

int main() {
	string s;
	cin >> s >> s;
	cout << 'A' << s[0] << 'C';
	return 0;
}
/*
31536000のコメント解説欄
ここテンプレで用意してるから、A問題とかだとこの先空欄の危険あり

要するに2個目の要素だけ取り出せればいいので、2番目の先頭文字を取得して合成して終わり
*/

Measured memory_bytes: 256
from heapq import heappush, heappop
from collections import deque
import re
import math
import functools


def sRaw():
    return input().rstrip("\r")


def iRaw():
    return int(input())


def ssRaw():
    return input().split()


def isRaw():
    return list(map(int, ssRaw()))


INF = 1 << 29


def make1d_arr(n, val=INF):
    return [val for i in range(n)]


def make2d_arr(h, w, val=INF):
    return [[val for i in range(w)]for i in range(h)]


def gcd(a, b):
    if(b == 0):
        return a
    return gcd(b, a % b)


def BFord(n, es):
    v_cost = [INF]*n
    v_cost[0] = 0
    for v in range(n*2):
        for e in es:
            frm = e[0]
            to = e[1]
            if v_cost[to] > v_cost[frm]+e[2]:
                v_cost[to] = v_cost[frm]+e[2]
                if v >= n:
                    v_cost[to] = -INF
        if v == n-1:
            prev = v_cost[:]
    v_cost = [-INF if prev[idx] != v_cost[idx] else v_cost[idx]
              for idx in range(n)]
    return v_cost


def ZAlgo(s):
    l = len(s)
    A = [0]*l
    i = 1
    j = 0
    A[0] = l
    while i < l:
        while i+j < l and s[j] == s[i+j]:
            j += 1
        if j == 0:
            i += 1
            continue
        A[i] = j
        k = 1
        while (i+k < l) and (k+A[k] < j):
            A[i+k] = A[k]
            k += 1
        i += k
        j -= k
    return A


DIV = 998244353


def main():
    A, B, K = isRaw()
    if K <= A:
        return (A-K, B)
    else:
        return (0, max(B-K+A, 0))


if __name__ == "__main__":

    print(" ".join([str(v) for v in main()]))


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

ll gcd(ll s, ll t){
    if(t == 0)  return s;
    return gcd(t, s%t);
}

ll prime_factor(){
    return (a/gcd(a, b)) * b;
}

void solve(){
    cout << gcd(a, b) << " " << prime_factor() << endl;

}

int main(){
    while (cin >> a >> b, cin.eof() != true){
    if(b>a) swap(a, b);
    solve();
    }
    
    return 0;
}



Measured memory_bytes: 3116
#include <iostream>
#include <math.h>
using namespace std;

int main(){
	int num, buf, digit = 0;
	double result = 0;
	int element[4096];
	cin >> num;
	while(num  !=  0){
		if(num < 0){
			buf = num;
			if(num % -2 != 0)
				num = (num / -2) + 1;
			else
				num = (num / -2);
			element[digit++] = (buf - num * -2 );
		}else{
			element[digit++] = (num % -2);
			num /= -2;
		}
	}
	if(digit == 0)
		cout << 0;
	for(;digit > 0;){
		cout << element[--digit];
	}

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>
#include <queue>
#include <deque>

using namespace std;
using ll = long long;

void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
ll gcd(ll a, ll b){ return (b == 0) ? a : gcd(b, a % b); }
template<typename S, typename T> ostream& operator<<(ostream &os, const pair<S, T> &p){ cout << "[" << p.first << ", " << p.second << "]"; return os; }

#define Sq(x) (x)*(x)
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Reverse(c) reverse(Range(c))
#define Unique(a) a.erase(unique(Range(a)), a.end())
#define Cusum(T, xs, sxs) vector<T> sxs(xs.size()+1); For(i, (int)xs.size()) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) { for(const auto &e : xs) cout << e << " "; cout << "\n"; }
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")
#define Return(expr) { Cout(expr); return 0; }
#define vc vector
#define Mini(a, x) a = min(a, x)
#define Maxi(a, x) a = max(a, x)

// constexpr int MOD = 1e9+7;

int main(void){
    Cin(int, n);
    Cins(int, n, a);
    Sort(a);

    constexpr int m = 1e6+10;
    vc<bool> p(m);
    
    int ans = 0;
    For(i, n){
        if(p[a[i]]) continue;
        for(int j = 1; j*a[i] < m; j ++) p[j*a[i]] = true;
        if(i == n-1 || a[i] != a[i+1]) ans ++;
        while(i < n-1 && a[i] == a[i+1]) i ++;
    }
    Cout(ans);
}


Measured memory_bytes: 4052
#include <stdio.h>

typedef struct {
	int key, id;
} data;

void merge_sort(data x[], int n)
{
	static data y[100001] = {};
	if (n <= 1) return;
	merge_sort(&(x[0]), n/2);
	merge_sort(&(x[n/2]), (n+1)/2);
	
	int i, p, q;
	for (i = 0, p = 0, q = n/2; i < n; i++) {
		if (p >= n/2) y[i] = x[q++];
		else if (q >= n) y[i] = x[p++];
		else y[i] = (x[p].key < x[q].key)? x[p++]: x[q++];
	}
	for (i = 0; i < n; i++) x[i] = y[i];
}

int main()
{	
	int i, N, K;
	data s[100001];
	scanf("%d %d", &N, &K);
	for (i = 0; i < N; i++) scanf("%d %d", &(s[i].id), &(s[i].key));
	merge_sort(s, N);
	
	int j, k, t, count[100001] = {}, flag[100001] = {};
	long long ans = 0;
	for (i = N - 1, k = 0; i >= 0 && k < K; i--) {
		if (count[s[i].id] == 0) {
			count[s[i].id]++;
			flag[i] = 1;
			ans += s[i].key;
			k++;
		}
	}
	t = k;
	for (i = N - 1, j = 0; k < K; i--) {
		if (flag[i] == 0) {
			count[s[i].id]++;
			flag[i] = 1;
			ans += s[i].key;
			k++;
		}
	}
	while (1) {
		for (; j < i && flag[j] == 0; j++);
		if (j >= i || count[s[j].id] > 1) break;
		for (; i > j && flag[i] == 1; i--);
		if (i <= j) break;
		if (s[j].key + t * 2 - 1 < s[i].key) {
			count[s[i].id]++;
			count[s[j].id]--;
			flag[i] = 1;
			flag[j] = 0;
			ans += s[i].key - s[j].key;
			t--;
		} else break;
	}
	
	printf("%lld\n", ans + (long long)t * t);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 4020
#include <iostream>
#include <cstring>

int main ()
{

  std::string taro;
  std::string hanako;
  int n;

  int score_taro = 0;
  int score_hanako = 0;
  
  std::cin >> n;
  
  while(n--)
	{
	  std::cin >> taro;
	  std::cin >> hanako;
	  
	  if (taro > hanako)
		{
		  score_taro += 3;
		}
	  else if (taro < hanako)
		{
		  score_hanako += 3;
		}
	  else
		{
		  score_taro += 1;
		  score_hanako += 1;
		}
	}
  std::cout << score_taro << ' ' << score_hanako << std::endl;

  return 0;
  
}

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

int main() {
    int N;
    cin>>N;
    int P[N];
    for(int i=0;i<N;++i){
        cin>>P[i];
    }
    int tmp = P[0];
    int ans = 1;
    for(int i=1;i<N;++i){
        if(tmp > P[i]){
            ans++;
            tmp = P[i];
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 1024
N, M = map(int, input().split())

ab = [map(int, input().split()) for _ in range(N)]
cd = [list(map(int, input().split())) for _ in range(M)]

for n in range(N):
    ans = []
    a, b = ab[n]
    for m in range(M):
        c, d = cd[m]
        distance = abs(a - c) + abs(b - d)
        ans.append(distance)
    print(ans.index(min(ans)) + 1)


Measured memory_bytes: 3064
/*
貪欲
後ろから見る
DP
順位表をチェック



*/
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
#include <cmath>
#include <limits>
#include <iostream>
#include<set>
#include<tuple>
using namespace std;
#define INF 3e18+7
#define MAX 100000
#define MOD 1000000007
typedef long long ll;
typedef pair<int,int> P;
typedef pair<pair<int,ll>,ll> p;
#define bit(n,k) ((n>>k)&1) /*nのk bit目*/
#define rad_to_deg(rad) (((rad)/2/M_PI)*360)
struct edge{ll to,cost,val;};
template<class T,class U>bool chmin(T&a,const U&b){if(a<=b)return false;a=b;return true;}
template<class T,class U>bool chmax(T&a,const U&b){if(a>=b)return false;a=b;return true;}
//__builtin_popcount(S);


int main(){
    int M;
    cin>>M;
    ll sum=0,sumc=0;
    for(int i=0;i<M;i++){
        int d; ll c;
        cin>>d>>c;
        sum+=d*c;
        sumc+=c;
    }
    ll ans=sumc-1;
    if(sum>10){
        ans++;
        sum-=10;
    }
    cout<<ans+sum/9<<endl;
    
}


Measured memory_bytes: 256
n = gets.chomp.to_i
a = gets.chomp.to_i
b = gets.chomp.to_i
c = gets.chomp.to_i
d = gets.chomp.to_i
e = gets.chomp.to_i
min = [a,b,c,d,e].min

if (min >= n)
  puts '5'
  exit
end

puts (n/min.to_f).ceil + 4

Measured memory_bytes: 1788
#include <stdio.h>
#define N 8
#define MAX 10000

int cc(int y, int x);
void printBoard();
int recursive(int d);

int a[N][N];

int main(){
	int n, i, j, x, y;
	int d = 0;
	
	scanf("%d", &n);
	for( i = 0; i < n; i++) {
		scanf("%d %d",&y,&x);
		
		a[y][x]=1;
	}
	
	i = recursive(d);
	return 0;
}


void printBoard() { 
	int i, j;
	for( i = 0; i < N; i++ ){
		for( j = 0; j < N; j++ ){
			if( a[i][j]==1) {
				printf("Q");
			} else {
				printf(".");
			}
		}
		printf("\n");
	}	
}


int cc(int y, int x) {
	int i, j;
	
	for(i = 0; i < N; i++ ) {
		if(i != y && a[i][x] == 1)return 0;
	}
	
	for( i = 0; i < N; i++ ) {
		if( i != x && a[y][i] ==1 )return 0;
	}

	
	
	j = x +1 ;
	i= y - 1; 
	while(i >= 0 && j < N){
		if( a[i--][j++] ==1) return 0;
	}
	
	
	 j = x - 1;
	 i = y - 1;
	while(i >= 0 && j >= 0){
		if(a[i--][j--]==1)return 0;
	}
	
	
	 j = x + 1;
	 i = y + 1;
	while( i < N &&  j < N)  {
		if( a[i++][j++] ==1)return 0;
	}

	
	
	 j = x - 1;
	 i = y + 1;
	while( i < N && j >= 0){
		if(a[i++][j--]==1)return 0;
	}
	
	return 5;
}


int recursive(int d) {
	int i;
	
	for(i=0;i<N;i++){
		if(a[d][i]==1){
			if(!recursive(d+1))return 0;
		}
	}
	

	if(d == N){
		printBoard();
		return 1;
	} else {
		for(i = 0; i < N; i++ ) {
			if(a[d][i] == 0 && cc(d, i) == 5){
				a[d][i]=1;
				if( !recursive(d+1) ){
					a[d][i]=0;
				}
			}
		}
	}
	
	
	return 0;

}





Measured memory_bytes: 2148
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VRSORT(v) sort(v.rbegin(), v.rend());//vectorの降順ソート
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

int lcs(string X,string Y){
    int c[1050][1050];
    int m = X.size();
    int n = Y.size();
    int maxl = 0;
    X = ' ' + X;
    Y = ' ' + Y;
    REP(i,m+1) c[i][0] = 0;
    for(int j=1;j<=n;j++) c[0][j] = 0;
    for(int i=1;i<=m;++i){
        for(int j=1;j<=n;++j){
            if(X[i] == Y[j]) c[i][j] = c[i-1][j-1] + 1;
            else c[i][j] = max(c[i-1][j],c[i][j-1]);
            maxl = max(maxl,c[i][j]);
        }
    }
    return maxl;
}
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int q;
  cin >> q;
  while(q--){
      string a,b;
      cin >> a >> b;
      cout << lcs(a,b) << endl;
  }
}


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

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for (long long i = 0; i < (int64_t)(n); i++)
#define all(v) v.begin(), v.end()
using ll = long long;
using namespace std;


int main(){
  ll n,k;cin>>n>>k;
  vector<ll>a(n),b(n,0);
  rep(i,n){
    cin>>a[i];
    a[i]--;
  }

  ll next=0,lp=0;
  bool l=1;
  rep(i,k){
    b[next]++;
    next=a[next];
    if(l){
      if(b[next]==1)lp++;
      if(b[next]==2){
        lp=(k-i-1)%lp;
        i=k-lp-1;
        l=0;
      }
    }

  }
  cout<<next+1<<endl;  
}

Measured memory_bytes: 6428
def main():
    N = int(input())
    h_list = [int(h) for h in input().split()]
    cost = [0] * N
    cost[1] = abs(h_list[1] - h_list[0])

    for i in range(2, N):
        cost[i] = min(cost[i-1] + abs(h_list[i] - h_list[i-1]),
                      cost[i-2] + abs(h_list[i] - h_list[i-2]))

    print(cost[N-1])


if __name__ == '__main__':
    main()

Measured memory_bytes: 52208
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace  std;
 
typedef pair<int,int>P;
#define fi first
#define se second
 
 
int n,k ;
 
vector<P>A;
 
void dfs(vector<int> v,int now){
  r(i,v.size()){
    A.push_back(P(v[i],now));
  }
  if(now*2+1<n){
    vector<int>nex=v;
    nex.push_back(now);
    dfs(nex,now*2+1);
  }
  if(now*2+2<n){
    vector<int>nex=v;
    nex.push_back(now);
    dfs(nex,now*2+2);
  }
}
 
//int x=0;
 
string output(int num){
 
  //cerr<<"aaa:"<<num<<endl;
  //if(x++==10)exit(0);
 
  cout<<num<<endl;
 
  string s;
/*
  const int atari = 3;
 
  if(atari == num)return "Yes";
 
  r(i,A.size()){
    if(A[i].fi==num-1 && A[i].se+1 == atari)return "Near";
    if(A[i].se==num-1 && A[i].fi+1 == atari)return "Near";
  }
  return "No";
*/
  cin>>s;
  return s;
}
 
int main(){
 
  cin>>n>>k;
 
  vector<int>init;
 
  dfs(init,0);
 
  cout<<A.size()<<'\n';
 
  r(i,A.size()){
    cout<<A[i].fi+1<<' '<<A[i].se+1;
    if(i!=(int)A.size())cout<<'\n';
    else cout<<endl;
  }
 
  while(k--){
 
    int idx=0,p=0,F=-1,S=0;
 
    while(1){
 
      if(!p){
        string s=output(idx+1);
        if(s=="Yes"){
          S++;
          break;
        }
        p++;
      }
 
      int nex=idx*2+1;
 
      if(nex>=n)break;
 
      string s=output(nex+1);
 
      if(s=="No"){
        F=nex+1;
        idx=idx*2+2;
      }
 
      else if(s=="Yes"){
        S++;
        break;
      }
 
      else{
        idx=idx*2+1;
      }
      if(idx>=n)break;
    }
 
    if(!S){
 
      //cout<<F<<endl;
 
      if(F+1<=n){
        string s=output(F+1);
        //cout<<s<<endl;
        if(s=="Yes")continue;
      }
 
      if(F-1>=1){
        string s=output(F-1);
        if(s=="Yes")continue;
      }
      //cout<<"ERROR"<<endl;
      //exit(1);
    }
 
  }
 
}


Measured memory_bytes: 3340
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int N=100100,oo=1000000000;
int i,j,k,n,m,ch,x,y,rt,Fg,En;
int l[N],r[N],a[N],h[N];
struct edge { int s,n;} E[N<<1];
void R(int &x) {
	x=0;ch=getchar();
	while (ch<'0' || '9'<ch) ch=getchar();
	while ('0'<=ch && ch<='9') x=x*10+ch-'0',ch=getchar();
}
void W(int x) {
	if (x<0) putchar('-'),x=-x;
	if (x>=10) W(x/10);
	putchar(x%10+'0');
}
void E_add(int x,int y) {
	E[++En].s=y;E[En].n=h[x];h[x]=En;
	E[++En].s=x;E[En].n=h[y];h[y]=En;
}
void dfs(int x,int F,int dp) {
	if (a[x]!=-1 && (a[x]&1)!=dp) Fg=1;
	for (int k=h[x];k;k=E[k].n) if (E[k].s!=F) dfs(E[k].s,x,dp^1);
	l[x]=-oo;r[x]=oo;
	for (int k=h[x];k;k=E[k].n) if (E[k].s!=F) {
		l[x]=max(l[x],l[E[k].s]-1);
		r[x]=min(r[x],r[E[k].s]+1);
	}
	if (a[x]!=-1) {
		if (a[x]<l[x] || r[x]<a[x]) Fg=1;
		l[x]=r[x]=a[x];
	}
}
void dfs(int x,int F) {
	if (a[x]==-1) {
		if (l[x]<=a[F]-1 && a[F]-1<=r[x]) a[x]=a[F]-1;
		else a[x]=a[F]+1;
		if (a[x]<l[x] || r[x]<a[x]) Fg=1;
	}
	for (int k=h[x];k;k=E[k].n) if (E[k].s!=F) dfs(E[k].s,x);
}
int main() {
	R(n);
	for (i=1;i<n;i++) {
		R(x);R(y);
		E_add(x,y);
	}
	R(m);
	memset(a,-1,sizeof a);
	for (i=1;i<=m;i++) {
		R(x);R(y);
		a[x]=y;
		rt=x;
	}
	dfs(rt,-1,a[rt]&1);
	dfs(rt,-1);
	if (Fg) return puts("No"),0;
	puts("Yes");
	for (i=1;i<=n;i++) W(a[i]),puts("");
}

Measured memory_bytes: 8704
#include<stdio.h>

int main(void){
  int N,X;
  scanf("%d %d",&N,&X);
  int L[N],D=0,count=1,i;
  for(i=0;i<N;i++){
    scanf("%d",&L[i]);
  }

  for(i=0;i<N;i++){
    D = D + L[i];
    if(D<=X){
      count++;
    }
  }
  printf("%d\n",count);
return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define REPL(i,m,n) for(ll i=(ll)(m); i<(ll)(n); i++)
#define repl(i,n) REPL(i,0,n)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
int char2int(char c) {
  return int(c-'0');
}
int main() {
  int N, P;
  string S;
  cin >> N >> P >> S;
  vector<ll> U(P+1);
  U[0] = 1;
  ll rem = 0;
  ll pow = 1;
  ll ans = 0;
  if(P == 2 || P == 5) {
    rrep(i, N) if(char2int(S[i]) % P == 0) ans += i+1;
    cout << ans << endl;
  } else {
    rrep(i, N) {
      rem = (rem + char2int(S[i]) * pow % P) % P;
      ans += U[rem];
      U[rem]++;
      pow = pow * 10 % P;
    }
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <map>

#define rep(i,x) for(int i = 0; i < x; i++)
#define rrep(i,x) for(int i = 1; i <= x; i++)
#define srep(i,s,t) for (int i = s; i < t; ++i)
using ll = long long;
using namespace std;
const int INF = 1001001001;
const ll LINF = 1002003004005006007;

int main(){
    string s; cin >> s;
    string ans = "No";
    string rev = s;
    reverse(rev.begin(), rev.end());
    string t = s.substr(0, (s.size() - 1) / 2);
    string rev_t = t;
    reverse(rev_t.begin(), rev_t.end());
    if (s == rev and t == rev_t){
        ans = "Yes";
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>
#include <stack>



#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 repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(x) (x).begin(),(x).end()

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; }

typedef long long ll;

using namespace std;


class UnionFind
{
public:
  UnionFind(int n)
  {
    parent=vector<int>(n,-1);
  }
  int root(int a)
  {
    if(parent[a]<0)return a;
    return parent[a]=root(parent[a]);
  }
  int size(int a)
  {
    return -parent[root(a)];
  }
  bool connect(int a,int b)
  {
    int A=root(a);
    int B=root(b);
    if(A==B)return false;
    if(size(A)>size(B))swap(A,B);
    parent[B]+=parent[A];
    parent[A]=B;
    return true;
  }
private:
  vector<int> parent;

};

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n;cin>>n;
  vector<ll>x(n),y(n);
  rep(i,n){
    cin>>x[i]>>y[i];
  }
  ll ma=2e5+7;
  UnionFind uf(ma);
  rep(i,n){
    uf.connect(x[i]*2,y[i]*2+1);
  }
  vector<vector<ll>>rec(ma,vector<ll>(2));
  rep(i,ma){
    rec[uf.root(i)][i%2]++;
  }
  ll res=0;
  rep(i,ma){
    res+=rec[i][0]*rec[i][1];
    //cout<<rec[i][0]<<" "<<rec[i][1]<<endl;
  }
  cout<<res-n<<endl;



  return 0;

}


Measured memory_bytes: 13568
package main

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

func main() {
	var n, m int
	fmt.Scan(&n)
	fmt.Scan(&m)
	g := make(map[int][]int)

	for i := 1; i <= n; i++ {
		g[i] = []int{}
	}

	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	for i := 0; i < m; i++ {
		sc.Scan()
		a, _ := strconv.Atoi(sc.Text())
		sc.Scan()
		b, _ := strconv.Atoi(sc.Text())

		g[a] = append(g[a], b)
		g[b] = append(g[b], a)
	}

	q := []int{1}
	v := make([]int, n+1, n+1)
	v[1] = n + 1
	for len(q) > 0 {
		i := q[0]
		q = q[1:]

		for _, j := range g[i] {
			if v[j] == 0 {
				v[j] = i
				q = append(q, j)
			}
		}
	}

	fmt.Println("Yes")
	for i := 2; i <= n; i++ {
		fmt.Println(v[i])
	}
}


Measured memory_bytes: 24128
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;

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

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

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

  int ans = 0;
  int temp = 1;
  while (temp < B) {
    ans++;
    temp += A - 1;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main() {
  char str[21];
  int i, j;
  scanf("%s", str);
  for (i = 0; str[i] != 0; i ++);
  for (j = i - 1; j >= 0; j --) {
    printf("%c", str[j]);
  }
  printf("\n");
  return 0;
}

Measured memory_bytes: 524
#dpがやや特殊なので、1次元的に走査したほうがよさそう。initializeもいらないし。
n,m = map(int, input().split())

inf = 10**9

dp =[inf for _ in range(2**n)]
dp[0] = 0

for i in range(m):
    a,b = map(int, input().split())
    d = sum((1<<(i-1)) for i in map(int, input().split()))
  
    for j in range(2**n):
        jord = j | d
        dp[jord] = min(dp[jord], dp[j] + a)
            
if dp[-1] == inf:
    print(-1)
else:
    print(dp[-1])

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

#define rep(i, n) for(long long i=0;i<(long long)(n);i++)
#define rep2(i, s, n) for(long long i=(s);i<(long long)(n);i++)
#define repi(i, n) for(int i=0;i<(int)(n);i++)
#define rep2i(i, s, n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(), v.end()

#define deg2rad(deg) (((deg)/360)*2*M_PI)
#define rad2deg(rad) (((rad)/2/M_PI)*360)

using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;

const ll INF = (1LL<<60);
const int INFi = (1<<29);

/*素数判定*/
bool is_prime(ll n){
    if(n==1) return false;
    for(ll i=2;i*i<=n;i++){
        if(n%i==0) return false;
    }
    return true;
}

/*約数列挙*/
vll enum_divisors(ll n){
    vll l;
    for(ll i=1;i*i<=n;i++){
        if(n%i==0){
            l.push_back(i);
            if(n/i != i) l.push_back(n/i);
        }
    }
   sort(all(l));
   return l;
}

/*素因数分解*/
vector<P> prime_factorize(ll n){
    vector<P> l;
    for(ll i=2;i*i<=n;i++){
        if(n%i!=0) continue;
        ll e = 0;
        while(n%i==0){
            e++;
            n /= i;
        }
        l.push_back({i, e});
    }
    if(n!=1) l.push_back({n, 1});
    return l;
}

/*最小公倍数*/
ll lcm(ll a, ll b){
    return a*b/__gcd(a,b);
}

/*最大公約数*/
ll gcd(ll a, ll b){
    return __gcd(a,b);
}

int main(){

    ll n; cin >> n;
    ll in, ans = 1;
    rep(i, n){
        cin >> in;
        ans = ans/gcd(ans, in) * in;
    }

    cout << ans << endl;

    return 0;
}

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

int main()
{
	vector<int> x(5);
	for (int i = 0; i < 5; i++) {
		cin >> x[i];
		if (x[i] == 0)
			cout << (i + 1) << endl;
	}
	return 0;
}

Measured memory_bytes: 3596
#include <iostream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <random>
#include <chrono>
#include <string>
#include <cstring>
#include <bitset>
#include <cassert>
#include <queue>
#include <deque>
#include <memory>

//#pragma comment(linker, "/STACK:16777216")
//#pragma GCC optimize("O3")
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC optimize("unswitch-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.1,sse4.2,abm,mmx,avx,avx2,popcnt,tune=native")

using namespace std;

mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

#define ll long long
#define ull unsigned long long
//#define double long double
//#define int ll
//#define int ull
//#define int short
//#define int unsigned short
//#define int unsigned int
#define mp make_pair
#define F first
#define S second
#define pii pair<int, int>
#define pdd pair<double, double>
#define pid pair<int, double>
#define pdi pair<double, int>
#define hash hash228
const int SZ = 5e5 + 4;
const double EPS = 1e-7;
const int mod = 998244353;
const int hashpow = 2;
const int inf = 2e9;

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

string t;

inline void read() {
    cin >> t;
}

inline void solve() {
    for (char &c : t) {
        if (c == '?') c = 'D';
    }
    cout << t << "\n";
}

signed main() {

#ifdef __LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#else
    ios_base::sync_with_stdio(0);
    cin.tie(0);
#endif

//    int t;
//    cin >> t;
//    for (int i = 0; i < t; ++i) {
    read();
    solve();
//    }

    return 0;
}

Measured memory_bytes: 3772
package main

import (
	"fmt"
)

func main() {
	for {
		var a, b int
		if _, err := fmt.Scan(&a, &b); err != nil {
			panic(err)
		}
		if a == 0 && b == 0 {
			break
		}

		if a < b {
			fmt.Printf("%d %d\n", a, b)
		} else {
			fmt.Printf("%d %d\n", b, a)
		}
	}
}



Measured memory_bytes: 1296
// atcoder/abc166/C/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; for (auto& i: v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { for (auto& i: v) is >> i; return is; }
template<typename T> ostream& operator << (ostream& os, set<T> s) { os << "#{"; for (auto& i: s) os << i << ","; os << "}"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; for (auto& i: m) os << i << ","; os << "}"; return os; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

using lli = long long int;
using ull = unsigned long long;
using point = complex<double>;
using str = string;
template<typename T> using vec = vector<T>;

constexpr array<int, 8> di({0, 1, -1, 0, 1, -1, 1, -1});
constexpr array<int, 8> dj({1, 0, 0, -1, 1, -1, -1, 1});
constexpr lli mod = 1e9 + 7;

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.setf(ios_base::fixed);
  cout.precision(15);

  int n, m;
  while (cin >> n >> m) {
    vec<int> h(n);
    cin >> h;
    vec<int> g[n];
    for (int i = 0; i < m; ++i) {
      int a, b;
      cin >> a >> b;
      --a;
      --b;
      g[a].push_back(b);
      g[b].push_back(a);
    }

    int cnt = 0;
    for (int i = 0; i < n; ++i) {
      bool f = true;
      each (j, g[i]) {
        f = f && (h[i] > h[j]);
      }
      cnt += f;
    }
    cout << cnt << endl;
  }

  return 0;
}


Measured memory_bytes: 8752
//#include "debug.h"
#include <string.h>
#include <limits.h>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
using namespace std;

#define MAXN 200000
#define M 1000000007
typedef long long i64;
typedef i64 T;

int n;
int x, y;

/* ax+by=gcd(a,b) */
T gcd_ext(T a, T b, T *x, T *y) {
	if (a == 0) {
		*x = 0;
		*y = 1;
		return b;
	}
	T x1, y1;
	T gcd = gcd_ext(b%a, a, &x1, &y1);
	*x = y1 - (b/a) * x1;
	*y = x1;
	return gcd;
}

T mod_norm(T a, T m) {
	return (a % m + m) % m;
}

T mod_div(T a, T b, T m) {
	T x, y;
	T g = gcd_ext(b, m, &x, &y);
	T d = (g!=1) ? 0 : mod_norm(x, m);
	return (a * d) % m;
}

int input() {
	if (scanf("%d %d", &x, &y) < 0) return 0;
	return 1;
}

void init() {
}

int solve() {
	if ((x+y)% 3 || x*2<y || y*2<x) return 0;
	i64 r = 1, n = (x+y)/3;
	for (i64 k=1; k<=x-n; k++) {
		r = mod_div(r * (n-k+1) % M, k, M);
	}
	return r;
}

void output(int ans) {
	printf("%d\n", ans);
}

void cleanup() {
}

int main() {
	//precalc();
	//int ca; scanf("%d", &ca);
	while (input()) {
		init();
		output(solve());
		cleanup();
		//break;
	}
}




Measured memory_bytes: 128
#include<iostream>
using namespace std;
int main()
{
  
  int x,y,z,temp;
  
  cin>>x>>y>>z;
  
  temp=x;
  
  x=y;
  
  y=temp;
  
  temp=x;
  
  x=z;
  
  z=temp;
  
 cout<<x<<" "<<y<<" "<<z<<endl;
  
} 

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(){
	int dh,dm,ds;
	int eh,em,es;
	int a,b,c;
	for(int i=0;i<3;i++){
		cin>>eh>>em>>es;
		cin>>dh>>dm>>ds;
		if(i==0)
		a=dh*3600+dm*60+ds-eh*3600-em*60-es;
		if(i==1)
		b=dh*3600+dm*60+ds-eh*3600-em*60-es;
		if(i==2)
		c=dh*3600+dm*60+ds-eh*3600-em*60-es;
	}
	cout<<a/3600<<" "<<(a-a/3600*3600)/60<<" "<<a-a/3600*3600-(a-a/3600*3600)/60*60<<endl;
	cout<<b/3600<<" "<<(b-b/3600*3600)/60<<" "<<b-b/3600*3600-(b-b/3600*3600)/60*60<<endl;
	cout<<c/3600<<" "<<(c-c/3600*3600)/60<<" "<<c-c/3600*3600-(c-c/3600*3600)/60*60<<endl;
	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <list>
#include <cstring>
#include <map>
#include <queue>
#include <ctime>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <cmath>

#define pb push_back
#define mp make_pair
#define ll long long
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ull unsigned long long
#define iloop(a,b) for(ll i = a; i < b; ++i)
#define jloop(a,b) for(ll j = a; j < b; ++j)
#define sz(a) int((a).size()) 
#define pb push_back 
#define all(c) (c).begin(),(c).end() 
#define tr(c,i) for(typeofa((c).begin() i = (c).begin(); i != (c).end(); i++) 
#define present(c,x) ((c).find(x) != (c).end()) 
#define cpresent(c,x) (find(all(c),x) != (c).end()) 
#define p(a) cout << a << "\n";
#define p1(a) cout << a << " ";

#define PI 3.141592653589793
#define MOD (ll)(1e9 + 7)

using namespace std;
typedef vector<int> vi; 
typedef vector<vi> vvi; 
typedef pair<int,int> ii; 

void solve()
{
	int a,b;
	cin >> a >> b;
	if(a%3 == 0 || b%3 == 0 || (a+b)%3 == 0)
	{
		p("Possible")
	}
	else
		p("Impossible")
}
int main()
{
	bool testing = false;
	IOS
	if(testing)
	{
		freopen("test.txt","rt",stdin);
		int start = clock();
		solve();
		int end = clock();
		cout << "time: " << (end - start)/(double)(CLOCKS_PER_SEC)*1000 << " milliseconds\n";
	}
	else
	{
		solve();
	}
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
#define ll long long
#define cpp boost::multiprecision::cpp_int
#define dequeue deque
#define rep(i, n) for(int i = 0; i < n; i++)
#define rrep(i, n) for(int i = 1; i <= n; i++)
#define drep(i, n) for(int i = n-1; i >= 0; i--)
#define srep(i, s, t) for (int i = s; i < t; i++)
#define vi vector<int>
#define P pair<ll, ll>
int mod = 1'000'000'000 + 7;
const double PI = 3.1415926535897932384626433832795;
struct edge {
	int to;
	ll cost;
};
void reverse(string* s) {
	reverse((*s).begin(), (*s).end());
}
ll gcd(ll a, ll b) {
	if (b == 0)return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}
void COME_LET_THE_GAMES_BEGIN() {
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << setprecision(20);
}
int main() {
	COME_LET_THE_GAMES_BEGIN();
	int N;
	cin >> N;
	int d[100000] = {};
	rep(i, N) {
		int a;
		cin >> a;
		d[a - 1]++;
	}
	int ans = 0;
	N /= 2;
	if (d[0] == N)ans++;
	rrep(i, 100000 - 1) {
		d[i] += d[i - 1];
		if (d[i] == N) {
			ans++;
		}
		else if (d[i] > N) {
			break;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 640
/*Bismillahir Rahmanir Rahim
->>Code by Ashraful Islam Paran
->>CUET,CSE
*/
#include <bits/stdc++.h>
using namespace std;
typedef int64_t ll;
typedef unsigned long long ull;
typedef vector<int> vi;
const int MX=2e5+5;
#define f(i,x,n) for(int i=x;i<n;i++)
#define pb push_back
#define endl "\n"
#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl

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

    char a;
    cin>>a;
    if(isupper(a))
    {
        cout<<"A"<<endl;
    }
    else
        cout<<"a"<<endl;

    return 0;
}



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

using namespace std;

string str;
int ap[256];

int main ()
{
    cin >> str;

    for (int i = 0; i < str.size (); ++i)
        ++ap[str[i]];

    long long ans = 1LL * str.size () * (str.size () - 1) / 2LL;
    for (int i = 'a'; i <= 'z'; ++i)
        ans -= 1LL * ap[i] * (ap[i] - 1) / 2LL;

    cout << ans + 1 << '\n';

    return 0;
}


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

using namespace std;

int main()
{  string s;
 cin>>s;
  for(int i=0;i<19;i++)
  {
      if(i==5 || i==13)
       {

        cout<<" ";}
      else
      {
          cout<<s[i];
      }
  }

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
 
int main(void)
{
  int n;
  long long a[100000];
  cin>>n;
  for(int i=0; i<n; i++) {
    cin>>a[i];
  }
  sort(a, a+n, greater<int>());
  long long x[2];
  int it=0;
  x[it]=a[0];
  for(int i=1; i<n; i++) {
    if(x[it]==a[i]) {
      x[it]=a[i];
      it++; 
    } else {
      x[it]=a[i];
    }
    if(it==2) {
      cout<<x[0]*x[1]<<endl;
      return 0;
    }
  }
  cout<<0<<endl;
  return 0;
}


Measured memory_bytes: 1152