akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,a) for(int i=0;i<(a);++i)
#define MP make_pair
#define INF 1e9
#define F first
#define S second
#define MAXN 100000
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
int N, M, n, a[MAXN], x[2 + MAXN];
int main()
{
	cin >> N;
	REP(i, N)
	cin >> a[i];
	REP(i, N)
		FOR(j, -1, 2)
		{
			if(a[i] + j >= 0)
				x[a[i] + j]--;
		}
	sort(x, x + MAXN + 1);
	cout << x[0] * -1 << endl; 
	return 0;
}


Measured memory_bytes: 1024
n=int(input())
edges=[[] for i in range(n)]
import sys

sys.setrecursionlimit(10**7)
for i in range(n-1):
    a,s,w=map(int,input().split())
    edges[a-1].append([s-1,w]);edges[s-1].append([a-1,w])
colors=[-1]*n
colors[0]=1
def dfs(now):
    for to,cost in edges[now]:
        if colors[to]==-1:
            colors[to]=(cost+colors[now])%2
            dfs(to)

dfs(0)
print(*colors,sep="\n")


Measured memory_bytes: 85180
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        // ABC157C - Guess The Number

        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int m = sc.nextInt();

        int[] s = new int[m];
        int[] c = new int[m];

        for (int i = 0; i < m; i++) {
            s[i] = sc.nextInt();
            c[i] = sc.nextInt();
        }

        int[] ans = new int[n];
        for (int i = 0; i < n; i++) {
            ans[i] = 10;
            for (int j = 0; j < m; j++) {
                if (s[j] == i + 1) {
                    if (ans[i] != 10 && ans[i] != c[j]) {
                        System.out.println("-1");   // 入力の矛盾
                        return;
                    }
                    ans[i] = c[j];
                }
            }
        }

        String a = "";
        if (n == 1 || (n > 1 && ans[0] > 0)) {
            for (int i = 0; i < n; i++) {
                if (ans[i] >= 0 && ans[i] < 10) {
                    a += ans[i];
                } else {
                    if (n > 1 && i == 0) {
                        a += "1";
                    } else {
                        a += "0";
                    }
                }
            }
        } else {
            a = "-1";
        }

        System.out.println(a);
    }
}


Measured memory_bytes: 23892
#include <algorithm>
#include <array>
#include <cstddef>
#include <cstdint>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <vector>

using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<int> xs(n);
    int average = 0;
    for (auto& x : xs)
    {
        cin >> x;
        average += x;
    }
    average /= n;

    auto cost = [&](int p) {
        int sum = 0;
        for (auto& x : xs)
        {
            sum += (x - p) * (x - p);
        }
        return sum;
    };
    cout << (min(cost(average), cost(average + 1))) << endl;
}


Measured memory_bytes: 256
def main():
    import numpy as np
    n, m, x = map(int, input().split())
    in_lis = []
    for _ in range(n):
        in_lis.append(list(map(int, input().split())))
    
    #print(in_lis)
    ans = 10 ** 10
    for i in range(1, 2 ** n):
        tmp = 0
        bag = []
        for j in range(n):
            if ((i >> j)& 1):
                bag.append(in_lis[j])
        a = np.array(bag)
        #print( np.sum(a, axis = 0))
        sum_retsu = np.sum(a, axis = 0)
        cnt = 0
        #print(sum_retsu)
        for k in range(1, m+1):
            if sum_retsu[k] >= x:
                cnt += 1
        if cnt == m:
            tmp = sum_retsu[0]
            ans = min(ans, tmp)
    if ans ==  10 ** 10:
        ans = -1
    print(ans)

    




if __name__ == "__main__":
    main()

Measured memory_bytes: 27336
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const string ln = "\n";
constexpr int INF = 1001001001;
constexpr int MOD = 1000000007;

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

  string s;
  cin >> s;

  int ans = INF;
  for (char c = 'a'; c <= 'z'; c++) {
    string ss = s;
    int cnt = 0;
    while (ss.size() > 1) {
      cnt++;

      string ns = "";
      for (int i = 0; i < ss.size() - 1; i++) {
        if (ss[i] == c) {
          ns += c;
        } else {
          ns += ss[i + 1];
        }
      }

      ss = ns;

      bool ok = true;
      for (int i = 0; i < ss.size(); i++) {
        if (ss[i] != c) {
          ok = false;
        }
      }

      if (ok) {
        break;
      }
    }

    ans = min(ans, cnt);
  }

  set<char> t;
  for (int i = 0; i < s.size(); i++) {
    t.insert(s[i]);
  }

  if (t.size() == 1) {
    ans = 0;
  }

  cout << ans << ln;

  return 0;
}

/*
7
abcdefg
bcddff
cdddf
dddd
3

6 3

5 2

4 2

3 1

2 1

1 0
*/

Measured memory_bytes: 256
#include "stdio.h"


int main()
{
	int w, a, b, dis;
	scanf("%d %d %d", &w, &a, &b);

	dis = b - (a + w);
	if (a > b) dis = a - (b + w);
	if (dis < 0) dis = 0;

	printf("%d\n", dis);

    return 0;
}



Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
    public static boolean debug = true;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] input = new int[n];
        for(int i=0;i<n;i++){
            input[i] = sc.nextInt();
        }

        int temp = 1000000001;
        for(int i=n-1;i>-1;i--){
            int now = input[i];
            //System.out.println("temp=" + temp + " now=" + now);
            if(temp >= now){
                temp = now;
                continue;
            }else if (temp >= now-1){
                temp = now-1;
                continue;
            }else{
                System.out.println("No");
                return;
            }
        }
        System.out.println("Yes");



    }
}

Measured memory_bytes: 50784
def gs
  gets.chomp
end

s = gs

l, r=-1,-1
s.size.times do |i|
  l, r = i+1, i+2 if s[i]==s[i+1]
  l, r = i+1, i+3 if s[i]==s[i+2]
end

puts "#{l} #{r}"


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

using namespace std;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rrep(i, n) for (ll i = (n - 1); i >= 0; --i)
#define blank(ans) cout << (ans) << " ";
#define mp(p, q) make_pair(p, q)
#define mt(p, q, r) make_tuple(p, q, r)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef string str;

typedef vector<ll> vll;
typedef vector<ld> vd;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<str> vs;
typedef vector<vector<ll>> vvll;
typedef vector<vector<ld>> vvd;
typedef vector<vector<bool>> vvb;
typedef vector<vector<char>> vvc;
typedef vector<vector<str>> vvs;
typedef vector<pair<ll, ll>> vpll;
typedef vector<tuple<ll, ll, ll>> vtlll;

const ld PI = acos(-1.0);
const ll MAX = 9000000000000000000;
const ll MIN = -9000000000000000000;
const ld DMAX = 4500;
const ld DMIN = -4500;
const ll MOD = 1000000007;

template <typename T>
void fin(T a)
{
  cout << a << endl;
  exit(0);
}

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

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

//実行部
void Main()
{
  ll n, m; cin >> n >> m;
  vll a(n), b(m), c(m); rep(i, n) cin >> a[i]; rep(i, m) cin >> b[i] >> c[i];
  ll flag = 0;
  vpll d(m); rep(i, m) d[i] = mp(c[i], b[i]);
  sort(all(d));
  reverse(all(d));
  for(ll i = 0;i < m;i++)
  {
    for(ll j = 0;j < d[i].second;j++)
    {
      a.pb(d[i].first);
      flag++;
      if(flag > n) break;
    }
  }
  sort(all(a)), reverse(all(a));
  ll ans = 0;
  for(ll i = 0;i < n;i++)
  {
    ans += a[i];
  }
  fin(ans);
}

//前処理
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(20); //高精度少数表示
  Main();
  return 0;
}

/*
//test時
  g++ test.cpp -o test;./test
*/


Measured memory_bytes: 7664
li = []
for i, s in enumerate(input()):
    if s == "\\":
        li.append([i, 0])
    elif s == "/":
        if li:
            if li[-1][1] == 0:
                li[-1][1] = i - li[-1][0]
            else:
                for j in range(len(li) - 1, -1, -1):
                    if li[j][1] == 0:
                        li = li[:j] + [[li[j][0], sum(tuple(zip(*li[j + 1:]))[1]) + i - li[j][0]]]
                        break
ans = []
for a in li:
    if a[1] != 0:
        ans.append(a[1])
print(sum(ans))
print(len(ans), *ans)



Measured memory_bytes: 7904
#include <iostream>

int main() {
	int n, m;
	std::cin >> n >> m;

	// odd
	int c = 1;
	for (int i = (m - 1) / 2 * 2 + 1; i >= 1; i -= 2, ++c)
		std::cout << c << " " << c + i << std::endl;
	
	// even
	c = (m - 1) / 2 * 2 + 1 + 2;
	for (int i = m / 2 * 2; i >= 1; i -= 2, ++c)
		std::cout << c << " " << c + i << std::endl;
}

Measured memory_bytes: 3632
def solve():
    n = int(input())
    for i in range(1,10):
        if n%i == 0 and (n//i) in (1,2,3,4,5,6,7,8,9):
            return 'Yes'
    else:
        return 'No'

if __name__ == '__main__':
    print(solve())

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vdo=vector<double>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vvdo=vector<vector<double>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using pqin=priority_queue<int>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define _GLIBCXX_DEBUG
int main()
{
    int x;
    cin>>x;
    int ans;
    rep2(i,x,200000){
        bool can=true;
        for(int j=2;j*j<=i;j++){
            if(i%j==0){
                can=false;
                break;
            }
        }
        if(can){
            ans=i;
            break;
        }
    }
    cout<<ans<<endl;
}

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

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

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

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

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

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

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

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

int main(){
    int n;
    cin >> n;
    double p = ((n + 1) / 2) / double(n);
    printf("%.10f\n", p);
    return 0;
}


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

int main(){

    int K, A, B;
    cin >> K >> A >> B;

    int temp, flg=0;
    temp = A;

    while (temp<=B){
        if (temp%K == 0){
            cout << "OK" << endl;
            flg = 1;
            break;
        }
        temp++;
    }

    if (flg == 0){
        cout << "NG" << endl;
    }

    return 0;
}

Measured memory_bytes: 3636
#!/usr/bin/env python
# coding: utf-8

def ri():
    return int(input())

def rl():
    return list(input().split())

def rli():
    return list(map(int, input().split()))

def main():
    n, m = rli()
    if n == m:
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()


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

 	ll mod = 1000000000+7;
 	int arr[200001];
 	int m[200001];
	int main() {

		#ifndef ONLINE_JUDGE
	        freopen("input.txt","r",stdin);
	        // freopen("output.txt","w",stdout);
	    #endif
	    ios::sync_with_stdio(false);
	    cin.tie(0);
	    cout.tie(0);
		int n;
		cin>>n;
		for(int i=0;i<n;i++){
			cin>>arr[i];
		}
		m[0]=arr[0];
	   	for(int i=1;i<n;i++){
	   		m[i]=max(m[i-1],arr[i]);
	   	}
	   	ll sum=0;
	   	for(int i=0;i<n;i++){
	   		sum+=m[i]-arr[i];
	   	}
	   	cout<<sum<<endl;
		
	}

	


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

int main(){
  int a[3];
  cin >> a[0] >> a[1] >> a[2];

  int cnt = 0;
  while(a[0]!=a[1] || a[1]!=a[2]){
    sort(a,a+3);

    if(a[1]<a[2]){
      a[0]++;
      a[1]++;
      cnt++;
      continue;
    }
    else if(a[1]==a[2] && a[0]<a[1]){
      a[0] += 2;
      cnt++;
    }
  }

  cout << cnt << endl;
  return 0;
}

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

int main() {
	int N,A;
	string ans;
	cin >> N >> A;
	if ((N % 500) <= A)
	{
		ans = "Yes";
	}
	else
	{
		ans = "No";
	}
	cout << ans << endl;
}

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

#define IMAX 2147483647

int n,A[500000],c=0;
void marge(int,int,int);

void msort(int left,int right){
  int mid;
  // printf("msort (%d,%d),%d\n",left,right,(int)(3/2));
  
  if(left+1 < right){
    mid=(left+right)/2;
    msort(left,mid);
    msort(mid,right);
    //    printf("|marge| (%d,%d,%d)\n",left,mid,right);    
    marge(left, mid, right);
  }
  // else printf("left=%d,right=%d\n",left,right);
}
void marge(int left,int mid, int right){
  int n1,n2,i,j,k,*L,*R ;
  n1=mid-left;
  n2=right-mid;
  L = (int *) malloc ( sizeof(int) * (n1+1) );
  R = (int *) malloc ( sizeof(int) * (n2+1) );
  for(i=0;i<n1;i++) L[i]=A[left+i];
  for(i=0;i<n2;i++) R[i]=A[mid+i];  
  L[n1]=R[n2]=IMAX;
  i=j=0;
  for(k=left;k<right;k++){
    c++;
    if(L[i]<=R[j]){
      A[k] = L[i];
      i++;
    }
    else{
      A[k] = R[j];
      j++;
    }
    
  }
  //  for(i=0;i<n;i++)  printf("A[%d]=%d\n",i,A[i]);
  free(L);
  free(R);
}
    

int main(){
  int i;

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

  msort(0,n);

  for(i=0;i<n;i++){
    printf("%d",A[i]);
    if(i!=n-1) printf(" ");
  }
  printf("\n%d\n",c);

  return 0;
}

  



Measured memory_bytes: 5468
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        for (int i = 0; i < M; i++) {
            int A = sc.nextInt();
            N -= A;
        }
        System.out.println(N < 0 ? "-1" : N);
    }
}


Measured memory_bytes: 46436
#include <stdio.h>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef vector<vector<int>> v2int;
typedef vector<ll> vll;
typedef vector<vector<ll>> v2ll;
typedef list<int> liint;
typedef pair<int, int> pint;
const int INF = int(2e9);
const ll LINF = ll(2e9) * ll(2e9);
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b) { a > b ? : a = b; }
template<class T, class C> void chmin(T& a, C b) { a < b ? : a = b; }



int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int N;
    cin >> N;
    string S1, S2;
    cin >> S1 >> S2;

    ll ans = 1;
    ll p = 1000000007;
    int s = 0;
    bool is_pre_vert = true;
    if (S1[0] == S2[0]) {
        ans = 3;
        s = 1;
    }
    else {
        ans = 6;
        s = 2;
        is_pre_vert = false;
    }
    int i = s;
    while(i < N) {
        if (S1[i] != S2[i]) {
            if (is_pre_vert) ans *= 2;
            else ans *= 3;
            ans %= p;
            i += 2;
            is_pre_vert = false;
        }
        else {
            if (is_pre_vert) ans *= 2;
            else ans *= 1;
            ans %= p;
            i++;
            is_pre_vert = true;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
from itertools import permutations
n = int(input())
P = tuple(map(int, input().split()))
Q = tuple(map(int, input().split()))
l = [i+1 for i in range(n)]
cnt = 0
for v in permutations(l, n):
    cnt += 1
    if v == P:
        p = cnt
    if v == Q:
        q = cnt
print(abs(p-q))

Measured memory_bytes: 39024
n = int(input())
listV = list(map(int, input().split()))
listC = list(map(int, input().split()))
listXY=[]
index=0
while index < len(listV):
    listXY.append(listV[index]-listC[index])
    index+=1
listXY.sort()
listXY.reverse()
index2=0
maxD=0
while index2 < len(listXY):
    if listXY[index2] > 0:
        maxD+=listXY[index2]
    else:
        break
    index2+=1
print(maxD)

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

using namespace std;
#define PROBLEM "E"

void print_set(multiset<int> s){

	cout << "print set-----------------\n";
	for(auto it : s){

		cout << it << " ";
	}
	cout << "\n--------------------------";
	cout << endl;
	
}

int main(){

	#ifdef DBG
	freopen("problem" PROBLEM ".in", "r", stdin);
	freopen("problem" PROBLEM ".out", "w", stdout);
	#endif

	int n;
	while(cin >> n){

		long long a[100010];
		vector< pair<long long, long long> > v;
		for(long long i = 0 ; i < n ; i++){

			cin >> a[i];
			v.emplace_back(a[i]-1, i);
		}
		sort(v.begin(), v.end());
		reverse(v.begin(), v.end());

		multiset<long long> s = {-1, -1, n, n};
		// print_set(s);
		long long ans = 0;
		for(auto i : v){

			long long index = i.second;
			auto itr = s.lower_bound(index);
			long long pos1 = *itr;

			itr++;

			long long pos2 = *itr;

			itr--;
			itr--;

			long long pos3 = *itr;

			itr--;

			long long pos4 = *itr;

			ans += ((pos3-pos4)*(pos1 - index) + (index-pos3)*(pos2-pos1)) * (i.first+1);
			s.insert(index);
		}
		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 7280
#  =========     /\       /|    |====/|
#      |        /  \       |    |   / |
#      |       /____\      |    |  /  |
#      |      /      \     |    | /   |
#  ========= /        \  =====  |/====|  
#  code

def main():
    a,b,c,d = map(int , input().split())
    k1 = (b + c - 1) // b
    k2 = (d + a - 1) // d
    if k1 > k2:
        print('No')
    else:
        print('Yes')
    return

if __name__ == "__main__":
    main()

Measured memory_bytes: 9096
a,b= map(int, input().split())
z=-1
x=int(a*12.5)
xx=int((a+1)*12.5)
y=b*10
yy=(b+1)*10
if x!=a*12.5:
    x=x+1
if xx==(a+1)*100/8:
    xx=xx-1
xxx= [i for i in range(x,xx+1)]
yyy= [i for i in range(y,yy)]
for i in range(len(xxx)):
    if xxx[i] in yyy:
        z=xxx[i]
        break
print(z)

Measured memory_bytes: 3064
#include <cstdio>
#include <string>
#include <iostream>
#include <math.h>

using namespace std;





int main(void){

    

    long n;
    cin >>n;
    string ans = "";

    int c = 0;
    long t = 1;
    while(n>=t) {
        n-=t;
        t*=26;
        c++;
    }



    string s;
    for(int i = 0 ; i < c; i++) {
        s = "a";
        s[0] = s[0]+n%26;
        ans = s + ans;
        n/=26;
    }


    cout<<ans;


    return 0;
}

Measured memory_bytes: 3624
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll inf = 1000000007;
ll boal[200005] = {};
int main() {
	int n, k;
	cin >> n >> k;
	int boalnumber;
	for (int i = 0; i < n; i++) {
		cin >> boalnumber;
		boal[boalnumber]++;
	}
	sort(boal, boal + n);
	reverse(boal, boal + n);
	ll count = 0;
	int index;
	for (int i = 1; i <= 200000; i++) {
		if (boal[i] > 0) {
			count++;
		}
		if (count == k) {
			index = i;
			break;
		}
	}
	if (count < k) {
		cout << "0" << endl;
		return 0;
	}
	ll ans = 0;
	for (int i = index; i <= 200000; i++) {
		ans += boal[i];
	}
	cout << ans << endl;
	return 0;
}



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

#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 reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))
#define sz(v) ((int) v.size())

using namespace std;

using i64 = long long;
using f80 = long double;
using vi32 = vector<int>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

void yes() { cout << "Yes" << endl; exit(0); }
void no() { cout << "No" << endl; exit(0); }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> void amax(T &x, T y) { x = max(x, y); }
template <typename T> void amin(T &x, T y) { x = min(x, y); }
template <typename T> T exp(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { for (auto &x : v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }

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

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


Measured memory_bytes: 3748
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <cmath>
using namespace std;
int main(){
	int n;
  	long long int res=0;
	cin >> n;
	vector<int> c(n);
	for(int i=0;i<n;++i) cin >> c[i];
	sort(c.begin(), c.end(), greater<int>());
	priority_queue<int> heap;
	heap.push(c[0]);
	for(int i=1;i<n;++i)
	{
		int tmp = heap.top();
		heap.pop();
		res += tmp;
		heap.push(c[i]);
		heap.push(c[i]);
	}
	cout << res;
	return 0;
}

Measured memory_bytes: 5100
#include <algorithm>
#include <bitset>
#include <cctype>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;

void print_all(const vector<int>& as) {
    for (int i = 0; i < as.size(); i++) {
        if (i > 0) {
            cout << " ";
        }
        cout << as[i];
    }
    cout << endl;
}

int main() {
    int n;
    cin >> n;
    vector<int> as(n);
    for (auto& a : as) {
        cin >> a;
    }
    print_all(as);

    for (int i = 1; i < as.size(); i++) {
        int key = as[i];
        int j = i - 1;
        while (j >= 0 && as[j] > key) {
            as[j + 1] = as[j];
            j--;
        }
        as[j + 1] = key;

        print_all(as);
    }
}

Measured memory_bytes: 1200
import java.util.*;

  public class Main {

    public static void main (String[] args) {

      Scanner sc = new Scanner(System.in);

      int N = sc.nextInt();

      int[] a = new int[N+1];
      for (int i = 1; i < N+1; i++) {
        a[i] = sc.nextInt();
      }

      sc.close();

      int[] b = new int[N+1];
  
      for (int i = N; 1 <= i; i--) {
        int count = 0;
        for (int j = i; j <= N; j += i) {
          if (b[j] == 1) {
            count++;
          }
        }
        if (count % 2 == a[i]) {
          b[i] = 0;
        } else {
          b[i] = 1;
        }
      }

      Set<Integer> result = new TreeSet<Integer>();
      for (int i = 1; i < N+1; i++) {
        if (b[i] == 1) {
          result.add(i);
        }
      }

      System.out.println(result.size());

      int count = 0;
      for (Integer value : result) {
        count++;
        System.out.print(value);
        if (count != result.size()) {
          System.out.print(" ");
        } else {
          System.out.println("");
        }
      }

    }

  }

Measured memory_bytes: 87692
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
#define ep emplace_back
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
constexpr int mod=1000000007;
constexpr int mod1=998244353;
vector<int> dx={0,1,0,-1},dy={-1,0,1,0};
bool inside(int y,int x,int h,int w){
	if(y<h && y>=0 && x<w && x>=0) return true;
	return false;
}





int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a,b;cin >> a >> b;
	if(a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0) cout << "Possible" << endl;
	else cout << "Impossible" << endl;
}


Measured memory_bytes: 256
/*
(ai, m - ai)

m = 7
2 5 3 0 6 5

5 2     6
    4 7   2
    
0 2 3 5 5 6

    
max(\sum ai, km - \sum aj)


*/

#include <cstdio>
#include <algorithm>

typedef long long int64;

const int MAXN = 2048 + 10;
const int64 INF = 0x3fffffffffffffff;

int n, k, S;
int a[MAXN];
int d[MAXN], dn;

int64 judge(int m) {
	static int s[MAXN];
	int i, x;
	int64 ans = INF;
	
	for(i=1; i<=n; i++)
		s[i] = a[i] % m;
	std::sort(s+1, s+1+n);
	for(i=1; i<=n; i++) s[i]+=s[i-1];
	for(i=0; i<=n; i++) 
		ans = std::min(ans, std::max(1ll * s[i], 1ll * m * (n - i) - s[n] + s[i]));
	return ans;
}

int main() {
	int i, ans = 0;
	
	scanf("%d %d", &n, &k);
	for(i=1; i<=n; i++) {
		scanf("%d", &a[i]);
		S+=a[i];
	}
	
	for(i=1; i*i<=S; i++) {
		if(!(S%i)) {
			dn++;
			d[dn] = i;
			if(i*i<S) {
				dn++;
				d[dn] = S / i;
			}
		}
	}
	
	for(i=1; i<=dn; i++)
		if(ans < d[i] and judge(d[i]) <= k)
			ans = d[i];
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>

int main(){
    int a, b, c;
    std::cin >> a >> b >> c;
    if(a == b && b == c){
        std::cout << "No" << std::endl;
    }else if(a != b && b != c && c != a){
        std::cout << "No" << std::endl;
    }else{
        std::cout << "Yes" << std::endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 50;
constexpr double pi=3.14159265358979;

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;
}
using namespace std;


void solve(){
    int n;
    cin>>n;
    int minv=1000000;
    for(int i=1;i<=n/2;++i){
        int a=i;
        int b=n-a;
        int sum=0;
        while(a){
            sum+=a%10;
            a/=10;
        }
        while(b){
            sum+=b%10;
            b/=10;
        }
        minv=min(minv,sum);
    }
    cout<<minv<<"\n";
}

signed main(){
	std::ios::sync_with_stdio(false);
    std::cin.tie(0);
	solve();
	return 0;
}


Measured memory_bytes: 256
#include <array>
#include <iostream>
#include <string>
#include <vector>
using namespace std;

const int sigma = 26;
int y;
struct Solver {
    vector<array<int,26>> next_char;
    int n;
    int pos;
    int num_contats;
    bool ok;

    Solver(const string& txt) : next_char(txt.size()), n(txt.size()), pos(-1), num_contats(1), ok(true) {
        Init(txt);
    }

    void Init(const string& txt) {
        for (int i = 0; i < sigma; i += 1) {
            next_char[n - 1][i] = -1;
        }

        for (int i = n - 1; i >= 0; i -= 1) {
            if (i != n - 1) {
                next_char[i] = next_char[i + 1];
            }

            next_char[i][txt[i] - 'a'] = i;
        }

        array<int, 26> first_ap;
        for (int i = 0; i < 26; i += 1) {
            first_ap[i] = -1;
        }

        for (int i = n - 1; i >= 0; i -= 1) {
            first_ap[txt[i] - 'a'] = i;
        }

        for (int i = 0; i < n; i += 1) {
            for (int j = 0; j < 26; j += 1) {
                if (next_char[i][j] == -1) {
                    next_char[i][j] = first_ap[j];
                }
            }
        }
    }

    void Move(char c) {
        c -= 'a';
        if (not ok) {
            return;
        }

        pos++;
        if (pos == n) {
            pos = 0;
            num_contats += 1;
        }

        if (next_char[pos][c] == -1) {
            num_contats = -1;
            ok = false;
            return;
        }

        if (next_char[pos][c] < pos) {
            num_contats += 1;
        }

        pos = next_char[pos][c];
		y=pos;
    }
};



int main() {
    string a, b; cin >> a >> b;
    Solver s(a);

    for (char itr : b) {
        s.Move(itr);
    }
	 int x=a.size()-1;
	 while(x>=0&&a[x]!=b[b.size()-1])
	 {
	 	x--;
	 }
	 if(s.num_contats==-1)
	 {
	 	cout<<"-1";
	 	return 0;
	 }
	 long long ans=1ll*(s.num_contats*a.size());
	 ans-=(a.size());
	 ans+=y;
    cout << ans+1 << '\n';

    return 0;
}

Measured memory_bytes: 10752
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
const ll mod = 1e9+7;

double p[301][301][301];
double ev[301][301][301];
main(){
    int n;
    cin>>n;
    int arr[n];
    vi cnt(4);
    for(int i=0;i<n;i++) {
        cin>>arr[i];
        cnt[arr[i]]++;
    }
    p[cnt[1]][cnt[2]][cnt[3]] = 1;
    for(int c = n;c>=0;c--){
        for(int b = n;b>=0;b--){
            for(int a =n;a>=0;a--){
                if(a == 0 && b == 0 && c == 0) {
                   continue;
                }
                if((a+b+c)>n) continue;
                double p_waste = (double)(n-(a+b+c))/n;
                ev[a][b][c]+= ((p_waste)/(1-p_waste) + 1)*(p[a][b][c]);
                
                if(a!=0){
                    double p_go = (double)a/(a+b+c);
                    p[a-1][b][c]+= p[a][b][c]*p_go;
                    ev[a-1][b][c]+= ev[a][b][c]*p_go;
                }
                if(b!=0){
                    double p_go = (double)b/(a+b+c);
                    p[a+1][b-1][c]+= p[a][b][c]*p_go;
                    ev[a+1][b-1][c]+= ev[a][b][c]*p_go;
                }
                if(c!=0){
                    double p_go = (double)c/(a+b+c);
                    p[a][b+1][c-1]+= p[a][b][c]*p_go;
                    ev[a][b+1][c-1]+= ev[a][b][c]*p_go;
                }
            }
        }
    }
    cout<<setprecision(10)<<fixed<<ev[0][0][0];
}

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

using namespace std;

struct Node {
  int v;
  Node* next;
  Node* prev;
};

Node head;  // list head

void insert(int x) {
  auto next = head.next;
  auto n = new Node;
  n->v = x;
  n->next = next;
  n->prev = &head;
  head.next = n;
  next->prev = n;
}

void del(Node* p) {
  auto next = p->next;
  auto prev = p->prev;
  prev->next = next;
  next->prev = prev;
  delete p;
  p = nullptr;
}

void delete_node(int x) {
  for (auto p = head.next; p != &head; p = p->next) {
    if (p->v == x) {
      del(p);
      return;
    }
  }
}

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

  head.next = &head;
  head.prev = &head;

  int n;
  cin >> n;
  string s;
  for (int i = 0; i < n; i++) {
    cin >> s;
    if (s == "deleteFirst") {
      del(head.next);
    } else if (s == "deleteLast") {
      del(head.prev);
    } else {
      int x;
      cin >> x;
      if (s == "insert") {
        insert(x);
      } else if (s == "delete") {
        delete_node(x);
      }
    }
  }
  for (auto p = head.next; p != &head; p = p->next) {
    if (p != head.next) {
      cout << " ";
    }
    cout << p->v;
  }
  cout << endl;
  return 0;
}



Measured memory_bytes: 34396
/*
ID: 123feli1
TASK: test
LANG: C++
*/
#include <bits/stdc++.h>
#include <fstream>
using namespace std;

int main(){
	int N;
	cin>>N;
	int Arr[N];
	int count=0;
	for(int i=0;i<N;i++){
		cin>>Arr[i];
	}
	for(int i=0;i<N-2;i++){
		for(int j=i+1;j<N-1;j++){
			int a=Arr[i];
			int b=Arr[j];
			for(int k=j+1;k<N;k++){
				int c=Arr[k];
					//cout<<a<<" "<<b<<" "<<Arr[k]<<'\n';
				if(a+b>c&&a!=b&&b!=c&&a!=c&&b+c>a&&a+c>b){
					count++;
				}
			}
		}
	}
	cout<<count<<'\n';
    return 0;
}



Measured memory_bytes: 3620
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <math.h>
#include <numeric>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <functional>
#include <assert.h>
using ll=long long;
#define int ll
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define SZ(x) ((int)x.size())
#define fi first
#define se second
const int INF = 1e15;
using namespace std;

template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;

using pi=pair<int,int>;
using vi=vc<int>;

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

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

    int N; cin >> N;
    int A[N];
    rep(i,N) cin >> A[i];
    int sumx=0;
    rep(i,N) sumx^=A[i];
    rep(i,N) {
        cout << (sumx^A[i]) << endl;
    }
}

Measured memory_bytes: 5164
#include<bits/stdc++.h>
using namespace std;
long long read(){
    long long ret=0,f=1;char ch=getchar();
    while(ch>'9'||ch<'0'){if(ch=='-')f=-f;ch=getchar();}
    while(ch>='0'&&ch<='9') ret=ret*10+ch-'0',ch=getchar();
    return ret*f;
}
int main(){
//	ios::sync_with_stdio(false);
    int a,b,c,o;
	a=read();b=read();c=read();
	a-=b;
	c-=a;
	if(c>=0)
	cout<<c<<endl; 
	else puts("0");
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<string>
#include<map>

using namespace std;

int main(void) {
	int N;
	int ans = 0;
	cin >> N;
	vector<int>A(N);
	vector<int>B(N - 1);
	for (int i = 0; i < N - 1; i++) {
		cin >> B[i];
	}
	if (N == 2) {
		cout << B[0] * 2 << endl;
	}
	else {
		A[0] = B[0];
		for (int i = 1; i < N-1; i++) {
			if (B[i] >= B[i - 1]) {
				A[i] = B[i - 1];
			}
			else {
				A[i] = B[i];
			}
		}
		A[N - 1] = B[N - 2];
		for (int i = 0; i < N; i++) {
			ans += A[i];
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <complex>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <cstring>

#define REP(i,x) for(int i=0 ; i<(int)(x) ; i++)
#define ALL(x) (x).begin(),(x).end()
#define LL long long

using namespace std;

struct Node{
    int to;
};

typedef vector<int> Edge;
typedef vector<Edge> Graph;

int N;
int A[100000];
Graph graph;
bool ok;

int rec(int v, int prev){
    int sum = 0;
    int mx = 0;
    REP(i, graph[v].size()){
        if(graph[v][i] == prev)continue;
        int c = rec(graph[v][i], v);
        sum += c;
        mx = max(mx, c);
    }
    if(sum == 0){
        return A[v];
    }
    int up = 2 * A[v] - sum;

    // check
    ok = ok && (up >= 0);
    ok = ok && (2*max(mx,up) <= up+sum);

    if(v==0){
        if(graph[v].size()==1){
            ok = ok && (up == A[v]);
        }else{
            ok = ok && (up == 0);
        }
    }
    // cout << "v:" << v << ",A[v]:" << A[v] << ",up:" << up << ",ok:" << ok << endl;

    return up;
}

int main(){
    cin >> N;
    REP(i, N)cin >> A[i];
    graph.assign(N, Edge());
    REP(i, N-1){
        int a, b;
        cin >> a >> b;
        a--;b--;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }
    ok = true;
    rec(0, -1);
    cout << (ok ? "YES" : "NO") << endl;

    return 0;
}


Measured memory_bytes: 12800
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
	int a, b;
	cin >> a >> b;
	int result = 1;
	int count = 0;
		while (result < b) {
			result = result + a - 1;
			count++;
		}
		cout << count << endl;
}

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

int main(void){
	int N;
	cin >> N;
	int A[N];
	rep(i,N) cin >> A[i];
	ll cash = 1000;
	ll Ns = 0;
	rep(i,N-1){
		cash += A[i]*Ns;
		if (A[i+1] > A[i]){
			Ns = cash/A[i];
			cash -= A[i]*Ns;
		}
		else {
			Ns = 0;
		}

	}
	cash += A[N-1]*Ns;
	cout << cash << endl;
	return 0;
}


Measured memory_bytes: 3628
//解説の方針B:進む方向を絞る
#include<bits/stdc++.h>
using namespace std;
using ll = long long;

//内積 及び 外積
ll dot(ll x1, ll y1, ll x2, ll y2) { return x1*x2 + y1*y2; }
ll cross(ll x1, ll y1, ll x2, ll y2) { return x1*y2 - x2*y1; }

int main()
{
    int N;
    cin >> N;
    ll X[N], Y[N];
    for(int i = 0; i < N; ++i) cin >> X[i] >> Y[i];

    ll ans = 0;
    for(int i = 0; i < N; ++i) {
        ll gx = X[i], gy = Y[i];
        for(int j = 0; j < 4; ++j) {
            {
                //90度回転
                ll nx = -gy, ny = gx;
                gx = nx, gy = ny;
            }

            ll  sx = 0, sy = 0, // 進む方向から-90<Θ<+90°の範囲のエンジンをすべて足したもの
                px = 0, py = 0, // 進む方向から丁度+90°の角度のエンジンをすべて足したもの
                qx = 0, qy = 0; // 進む方向から丁度-90°の角度のエンジンをすべて足したもの

            for(int k = 0; k < N; ++k){
                if(dot(gx, gy, X[k], Y[k]) < 0) continue;
                if(dot(gx, gy, X[k], Y[k]) > 0) {
                    sx += X[k]; sy += Y[k];
                    continue;
                }
                //dot() == 0,進む方向と直角のX, Yについて
                if(cross(gx, gy, X[k], Y[k]) > 0) {
                    px += X[k]; py += Y[k];
                    continue;
                }
                if(cross(gx, gy, X[k], Y[k]) < 0) {
                    qx += X[k]; qy += Y[k];
                    continue;
                }
            }
            
            // s, s + p, s + q, s + p + qの内もっとも絶対値が大きくなるものを調べる
            for(int s = 0; s < 4; ++s) {
                //ビットで場合分け
                ll bx = sx, by = sy;
                if(s&1) {bx += px; by += py;}
                if(s&2) {bx += qx; by += qy;}
                ans = max(ans, bx*bx + by*by);
            }

        }
    }

    cout << fixed <<setprecision(12) << sqrt(ans) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
const int maxn = 3005;
char Map[maxn][maxn];
int main(){
    int n;
    scanf("%d", &n);
    for(int i = 1; i <= n; i++){
        getchar();
        for(int j = 1; j <= n; j++){
            scanf("%c", &Map[i][j]);
        }
    }
    for(int i = 1; i <= n; i++)
        for(int j = n + 1; j <= n * 2; j++)
            Map[i][j] = Map[i][j - n];
    int no, ans = 0;
    for(int i = 0; i < n; i++){
        no = 0;
        for(int j = 1; j <= n; j++){
            for(int k = 1; k <= n; k++){
                if(Map[j][k + i] != Map[k][j + i]){
                    no = 1;
                    break;
                }
            }
            if(no) break;
        }
        if(!no) ans += n;
    }
    printf("%d\n", ans);


    return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>
int main()
{
    int a,b,c,d,e,f;
    scanf("%d %d %d",&a,&b,&c);
    if(a,b,c>=1  &&  a,b,c<=9 )
    {
        d=((a*10)+b+c);
        e=((b*10)+a+c);
        f=((c*10)+a+b);
        if(d>=e&&d>=f)
        {
            printf("%d",d);
        }
        else if(e>=d&&e>=f)
        {
            printf("%d",e);
        }
        else if(f>=d,e)
        {
            printf("%d",f);
        }
    }
}


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

using llong = long long;

int main() {

    double a, b, x;
    cin >> a >> b >> x;

    double V = a * a * b;
    if (V / 2 < x) {
        cout << setprecision(10) << atan(2 * (V - x) / (a * a * a)) / M_PI * 180.0 << endl;
    } else {
        cout << setprecision(10) << atan((a * b * b) / (2 * x)) / M_PI * 180.0 << endl;
    }

    return 0;
}



Measured memory_bytes: 512
/*
　　　  ∧＿∧　やあ
　　 （´・ω・｀)　　　　　/　　　　　ようこそ、バーボンハウスへ。
　　 ／∇y:::::＼　　　 [￣]　　　　　このテキーラはサービスだから、まず飲んで落ち着いて欲しい。
　　 |:⊃:|:::::|　　　|──|
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|　うん、「また」なんだ。済まない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|￣　  仏の顔もって言うしね、謝って許してもらおうとも思っていない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣／|
　　　　∇　∇　∇　∇　　　／.／|　　　でも、この提出を見たとき、君は、きっと言葉では言い表せない
　　　　┴　┴　┴　┴　／ ／　  |　　　「ときめき」みたいなものを感じてくれたと思う。
￣￣￣￣￣￣￣￣￣￣|／　　  |　　　殺伐としたコンテストの中で、そういう気持ちを忘れないで欲しい
￣￣￣￣￣￣￣￣￣￣　　　　 |　　　そう思って、この提出を投げたんだ。
　　　(⊆⊇)　(⊆⊇)　(⊆⊇)　　|
　    ||　　 ||　　||　　|　　　 じゃあ、判定を聞こうか。
　　.／|＼　／|＼ ／|＼
*/

#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <array>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
#define fst first
#define snd second
#define mp make_pair
#define ALL(obj) (obj).begin(),(obj).end()
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i = (b-1);i>=a;i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n) 
#define SIZE(x) ((int)(x).size())
#define debug(x) cerr << #x << " -> " << x << " (line:" << __LINE__ << ")" << '\n';
#define debugpair(x, y) cerr << "(" << #x << ", " << #y << ") -> (" << x << ", " << y << ") (line:" << __LINE__ << ")" << '\n';
typedef long long lint;
typedef pair<int, int> pint;
typedef pair<lint, lint> plint;
typedef vector<lint> vec;
typedef vector<vector<lint>> matrix;
typedef priority_queue<lint> p_que;
typedef priority_queue<lint, vector<lint>, greater<lint>> p_que_rev;
const lint INF = INT_MAX;
const lint LINF = LLONG_MAX;
const lint MOD = 1000000000 + 7;
const double EPS = 1e-9;
const double PI = acos(-1);
const int di[]{0, -1, 0, 1, -1, -1, 1, 1};
const int dj[]{1, 0, -1, 0, 1, -1, -1, 1};

lint gcd(lint a, lint b) {
    lint r;
    while (b != 0) {
        r = a % b;
        a = b; 
        b = r;
    }
    return a;
}

lint lcm(lint a, lint b) {
    return (a / gcd(a, b)) * b;
}

lint power(lint x, lint n, lint mod = MOD) {
    lint ret = 1;
    while(n > 0) {
        if(n & 1){
            (ret *= x) %= mod;
        }
        (x *= x) %= mod;
        n >>= 1;
    }
    return ret;
}

vector<lint> make_power(int n, lint base){
    lint num = 1;
    vector<lint> ret;
    for (int i=0; i<=n; ++i){
        ret.push_back(num);
        num *= base;
    }
    return ret;
}

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int n;
    cin >> n;
    lint ans = 0;
    REP(i, n){
        ans += i;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<(n);++i)
#define rep2(i,a,b) for (ll i=(a);i<(b);++i)
#define debug(x) cout << #x << '=' << x << endl
#define all(v) (v).begin(),(v).end()
const ll MOD=1e9+7;
//const ll MOD=998244353;
const ll INF=1e9;
const ll IINF=1e18;
const double EPS=1e-8;
const double pi=acos(-1);

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(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,K; cin >> N >> K;
    cout << fixed << setprecision(15);
    vector<double> p(N);
    rep(i,N) cin >> p[i];
    rep(i,N) p[i]=(1+p[i])/2.0;
    double ans=0,sum=0;
    rep(i,N){
        sum+=p[i];
        if (i>=K) sum-=p[i-K];
        chmax(ans,sum);
    }
    cout << ans << endl;
}

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

#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 ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)
#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using ll = long long;
using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using ld = long double;

#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

long int M = 1e+9+7;
int inf = 1e+9;

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

    int h,w,n;
    cin >> h >> w >> n;
    vi a(n+1);
    rrep(i,n){
        cin >> a[i];
    }
    vvi c(h,vi(w));

    int ai=1;
    int j=0;
    while(1){
        //flag = false;
        rep(i,w){
            if(!a[ai]) ai++;
            a[ai]--;
            c[j][i] = ai;
        }
        j++;
        if(j==h) break;
        drep(i,w){
            if(!a[ai]) ai++;
            a[ai]--;
            c[j][i] = ai;
        }
        j++;
        if(j==h) break;
    }

    rep(i,h){
        rep(j,w){
            cout << c[i][j] << " ";
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 384
#include <cstdio>

int main()
{
	int K, S;
	scanf("%d %d", &K, &S);
	int ans = 0;
	for (int i = 0; i <= K; ++i)
		for (int j = 0; j <= K; ++j)
			ans += S - i - j >= 0 && S - i - j <= K;
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 128
n, x = map(int, input().split())

p = [0] * -~n
l = [0] * -~n

p[0] = 1
l[0] = 1
for i in range(1, n + 1):
    p[i] = p[i - 1] * 2 + 1
    l[i] = l[i - 1] * 2 + 3

# バーガーの長さは奇数


def rec(m, y):
    if y == 0:
        return 0
    if m == 0:
        return 1
    h = l[m] // 2  # レベルmの半分より左側の長さ
    if h < y:  # 真ん中含む
        return 1 + p[m - 1] + rec(m - 1, y - h - 1)
    else:
        return rec(m - 1, y - 1)


print(rec(n, x))


Measured memory_bytes: 9140
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    int n;
    cin >> n;
    int d[n];
    rep(i, 0, n) cin >> d[i];
    sort(d, d + n);
    cout << d[n / 2] - d[n / 2 - 1] << endl;
    return 0;
}


Measured memory_bytes: 640