akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;

int main(){ 
  vector<int> a(5);
  int res = 0;
  rep(i,5) {
    cin >> a[i];
    if (a[i] == 0) res = i + 1;
  }
  cout << res << endl;
  return 0;
} 

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

int64_t	modpow(int64_t a, int64_t n, const int64_t mod)
{
	int64_t	result = 1;
	while (n) {
		if (n & 1) result = result * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return result;
}

pair<int64_t, int64_t>	make_anti_pair(pair<int64_t, int64_t> pr)
{
	int64_t	A = pr.first, B = pr.second;
	if (A == 0)
	   return {1, 0};	
	int64_t	anti_A = -B, anti_B = A;
	if (anti_B < 0) {
		anti_A *= -1;
		anti_B *= -1;
	}
	return {anti_A, anti_B};
}

int	main()
{
	int	N;
	cin >> N;
	map<pair<int64_t, int64_t>, int>	cnt_map;
	int64_t	A, B;
	int64_t	num_00 = 0;
	for (int i = 0; i < N; ++i) {
		cin >> A >> B;
		if (A == 0 && B == 0) {
			++num_00;
			continue;
		}
		int64_t	divisor = __gcd(A, B);
		A /= divisor;
		B /= divisor;
		if (B < 0) {
			A *= -1;
			B *= -1;
		}
		auto	pr = make_pair(A, B);
		if (cnt_map.count(pr))
			++cnt_map.at(pr);
		else
			cnt_map[pr] = 1;
	}
	int64_t	mod = 1000000007;
	int64_t	total = 1;
	set<pair<int64_t, int64_t>>	appeared;
	for (auto pr : cnt_map) {
		auto anti = make_anti_pair(pr.first);
		if (appeared.count(anti))
			continue;
		int64_t	cnt0 = pr.second;
		if (cnt_map.count(anti)) {
			int64_t	cnt1 = cnt_map.at(anti);
			int64_t	tmp = modpow(2, cnt0, mod) + modpow(2, cnt1, mod) - 1;
			tmp = tmp % mod;
			if (tmp < 0) tmp += mod;
			total = total * tmp  % mod;
			appeared.insert(pr.first);
		} else {
			total = total * modpow(2, cnt0, mod) % mod;
		}
	}
	total = (total - 1 + num_00) % mod;
	if (total < 0)
		total += mod;
	cout << total << endl;
}


Measured memory_bytes: 16036
#include <bits/stdc++.h>
#include <string>
#include <iostream>
#include <iomanip>
using namespace std;
#define rep(i, N) for (ll i = 0; i < (N); i++)
typedef long long ll;

int main()
{
    string S;
    cin >> S;
    string ans = "No";
    if (S.at(2) == S.at(3) && S.at(4) == S.at(5))
    {
        ans = "Yes";
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <functional>

const int N = 200000 + 10, MOD = 1000000007;

int n;
std::pair<int, int> a[N], b[N];

void init() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) scanf("%d%d", &a[i].second, &a[i].first);
  std::sort(a + 1, a + n + 1);
  static std::pair<int, int> stk[N];
  static int l[N], r[N];
  for (int i = 1, top = 0; i <= n; ++i) {
    if (!top || a[i].second > stk[top].first) stk[++top] = {a[i].second, i};
    l[i] = std::lower_bound(stk + 1, stk + top + 1, std::make_pair(a[i].second, i))->second;
  }
  for (int i = n, top = 0; i > 0; --i) {
    if (!top || a[i].second < stk[top].first) stk[++top] = {a[i].second, i};
    r[i] = std::lower_bound(stk + 1, stk + top + 1, std::make_pair(a[i].second, i), std::greater< std::pair<int, int> >())->second;
  }
  for (int i = 1; i <= n; ++i) b[i] = {l[i], r[i]};
  std::sort(b + 1, b + n + 1);
}

int main() {
  init();
  static int f[N], sum[N];
  f[0] = 1;
  int ans = 0;
  for (int i = 1, j = 0; i <= n; ++i) {
    sum[i] = (sum[i - 1] + f[i - 1]) % MOD;
    while (j <= n && b[j].second < b[i].first - 1) ++j;
    f[i] = (sum[i] - sum[j]) % MOD;
    if (b[i].second == n) ans = (ans + f[i]) % MOD;
  }
  printf("%d\n", (ans + MOD) % MOD);
  return 0;
}


Measured memory_bytes: 7936
#include<cstdio>

int main(){
	int N, Q;
	scanf("%d %d\n", &N, &Q);
	char S[N + 1];
	scanf("%s", S);
	int ruiseki[N];
	ruiseki[0] = 1;
	for (int i = 0; i < N - 1; ++i){
		ruiseki[i + 1] = ruiseki[i];
		if(S[i] == 'A' && S[i + 1] == 'C') ruiseki[i + 1]++;
	}
	for (int i = 0; i < Q; ++i){
		int l, r;
		scanf("%d %d", &l, &r);
		printf("%d\n", ruiseki[r - 1] - ruiseki[l - 1]);
	}
	return 0;
}

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

static int num =0;
void swap(int &a,int &b){
    int tmp;
    tmp =a;
    a = b;
    b = tmp;
    num++;
}

void bubbleSort(int a[],int n){
    int flag = 1;
    while(flag){
        flag =0;
        for(int i=n-1;i>0;i--){
            if(a[i]<a[i-1]){
                swap(a[i],a[i-1]);
                flag =1;
            }
        }
    }
}

int main(){
    int n; cin >>n;
    int a[n];
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    bubbleSort(a,n);
    for(int i=0;i<n-1;i++){
        cout << a[i] << " ";
    }
    cout << a[n-1] << endl;
    cout << num << endl;

}

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

int main(){
  int H,W;cin>>H>>W;
  vector<string>S(H);
  for(int i=0;i<H;i++)cin>>S[i];
  int ans=-1;
  for(int sy=0;sy<H;sy++)for(int sx=0;sx<W;sx++){
    if(S[sy][sx]=='#')continue;
    vector<vector<int>>D(H,vector<int>(W,-1));
    queue<pair<int,int>>q;
    q.push(pair<int,int>(sy,sx));
    D[sy][sx]=0;
    while(q.size()){
      pair<int,int>f=q.front();q.pop();
      int y=f.first,x=f.second;
      if(y-1>=0&&S[y-1][x]=='.'&&D[y-1][x]==-1){D[y-1][x]=D[y][x]+1;q.push(pair<int,int>(y-1,x));}
      if(y+1<H&&S[y+1][x]=='.'&&D[y+1][x]==-1){D[y+1][x]=D[y][x]+1;q.push(pair<int,int>(y+1,x));}
      if(x-1>=0&&S[y][x-1]=='.'&&D[y][x-1]==-1){D[y][x-1]=D[y][x]+1;q.push(pair<int,int>(y,x-1));}
      if(x+1<W&&S[y][x+1]=='.'&&D[y][x+1]==-1){D[y][x+1]=D[y][x]+1;q.push(pair<int,int>(y,x+1));}
    }
    for(int y=0;y<H;y++)for(int x=0;x<W;x++)ans=max(ans,D[y][x]);
  }
  cout<<ans;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#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 rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

int fs[26],ft[26];
  
int main() {
  string s,t;
  cin >> s>> t;
  if(s ==t){
    cout<<"No"<<endl;
    return 0;
  }
  int n = sz(s);
  int m = sz(t);
  rep(i,n)fs[s[i]-'a']++;  
  rep(i,m)ft[t[i]-'a']++;
  
  string sa ="",ta="";
  rep(i,26){
    rep(k,fs[i])sa+='a'+i;
  }
  rep(i,26){
    rep(k,ft[25-i])ta+='z'-i;
  }
  vector<string> l;
  //cout<<sa<<endl;
  //cout<<ta<<endl;
  l.push_back(sa);
  l.push_back(ta);
  sort(rng(l));
  if(sa == l[0]){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
  return 0;
}

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

int n;

void dfs(string s, char mx) {
  
  if(s.length() == n){
    cout << s << endl;
  } else {
    for(char c = 'a'; c <= mx+1; ++c) {
      dfs(s + c, (c==mx+1)? c: mx);
    }
  }
  
}

int main() {
  cin >> n;
  dfs("", 'a'-1);

  return 0;
}

Measured memory_bytes: 1536
import sys
input = sys.stdin.readline

H, W, M = map(int, input().split())
st = set()
row = [0] * H
col = [0] * W
for _ in range(M):
    h, w = map(lambda x: int(x) - 1, input().split())
    st.add((h, w))
    row[h] += 1
    col[w] += 1
maxrow = []
maxcol = []
mr = max(row)
for i, r in enumerate(row):
    if r == mr:
        maxrow.append(i)
mc = max(col)
for j, c in enumerate(col):
    if c == mc:
        maxcol.append(j)
if len(maxrow) * len(maxcol) > M:
    print(mr + mc)
else:
    ok = False
    for r in maxrow:
        for c in maxcol:
            if (r, c) not in st:
                print(mr + mc)
                ok = True
                break
        if ok:
            break
    if not ok:
        print(mr + mc - 1)


Measured memory_bytes: 169316
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
using System.Text;//テキストの高速出力に必要
class Program
{
	static void Main()
	{
		string[] input = Console.ReadLine().Split(' ');//Splitで区切り文字を指定して複数個受け取る。
		int n = int.Parse(input[0]);
		int m = int.Parse(input[1]);
    int[,] vertexes = new int[m,2];//ここに受け取る
    int answer = 0;
    for(int i = 0; i < m; i++)
    {
      int[] nums = Array.ConvertAll(Console.ReadLine().Split(' '),int.Parse);//１行ごとに受け取る
      vertexes[i,0] = nums[0]-1;
      vertexes[i,1] = nums[1]-1;
    }

    int[] counts = new int[n];//ボールの個数
    bool[] reds = new bool[n];//赤が入っている可能性のある箱
    reds[0] = true;
    for(int i = 0; i < n; i++)
    {
      counts[i] = 1;
    }

    for(int i = 0; i < m; i++)
    {
      counts[vertexes[i,0]]--;
      counts[vertexes[i,1]]++;
      if(reds[vertexes[i,0]]) reds[vertexes[i,1]] = true;
      if(counts[vertexes[i,0]] == 0) reds[vertexes[i,0]] = false;
    }

    for(int i = 0; i < n; i++)
    {
      if(reds[i]) answer++;
    }
    
		Console.WriteLine(answer);//WriteLineをWriteとすると、改行なしで出力。
	}
}


Measured memory_bytes: 17324
def inv(x, mod=1):
    return pow(x, mod-2, mod)

def fact(x, mod=1):
    res = 1 
    for i in range(1, x + 1): 
        res *= i
        res %= mod    
    return res

def comb(n, k, mod=1):
    return (fact(n, mod) * inv(fact(n-k, mod), mod) * inv(fact(k, mod), mod)) % mod

div = 10 ** 9 + 7
X, Y = map(int, input().split())

if (X+Y) % 3 != 0:
    print(0)
    exit()

n = (X+Y) // 3
X -= n
Y -= n
if X < 0 or Y < 0:
    print(0)
    exit()

ans = comb(X+Y, X, div)
print(ans)

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

namespace Contest_01_Valeo_P4
{
    class Program
    {

        static void Main(string[] args)
        {
            //while (true)
            //{
            //    Console.WriteLine("start problem");
                string input = Console.ReadLine();
                long h = long.Parse(input.Split(' ')[0]);
                long result = getNumberOfAttacks(h);
                Console.WriteLine(result);
            //    Console.Write("press y to exit : ");
            //    if (Console.ReadLine() == "y")
            //        return;
            //}
        }

        private static long getNumberOfAttacks(long h)
        {
            long health = h;
            long count = 0;
            do
            {
                count++;
                if (health == 1)
                    health = 0;
                else
                {
                    health = health % 2 == 0 ? health / 2 : (health - 1) / 2;
                    count += getNumberOfAttacks(health) * 2;
                    health = 0;
                }
            } while (health > 0);
            return count;
        }
    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:1024000000,1024000000")
#define mem(a,b) memset((a),(b),sizeof(a))
#define MP make_pair
#define pb push_back
#define fi first
#define se second
#define sz(x) x.size()
#define all(x) x.begin(),x.end()
using namespace std;
#define _GLIBCXX_PERMIT_BACKWARD_HASH
#include <ext/hash_map>
using namespace __gnu_cxx;
struct str_hash{size_t operator()(const string& str)const{return __stl_hash_string(str.c_str());}};
typedef long long ll;
typedef unsigned long long ull;
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define PDD pair<double,double>
const int INF=0x3f3f3f3f;
const ll LLINF=0x3f3f3f3f3f3f3f3f;
const double PI=acos(-1.0);
const double eps=1e-6;
const int MAX=200000+10;
const ll mod=1e9+7;
int main()
{
	int n,k,i,x,ans,now;
	while(~scanf("%d%d",&n,&k))
	{
		map<int,int> mp;
		map<int,int> ::iterator it;
		for(i=0;i<n;i++)
		{
			scanf("%d",&x);
			mp[x]++;
		}
		vector<PII > res;
		for(it=mp.begin();it!=mp.end();it++)
		{
			res.pb(MP(it->se,it->fi));
		}
		if(sz(res)<=k)
		{
			puts("0");
			continue;
		}
		sort(all(res));
		ans=0;
		now=sz(res);
		for(i=0;i<sz(res);i++)
		{
			ans+=res[i].fi;
			now--;
			if(now<=k) break;
		}
		printf("%d\n",ans);
	}
	return 0;
}


Measured memory_bytes: 11768
using System;
using System.Collections.Generic;
using System.Linq;

namespace abc148_f
{
  class Program
  {
    static void Main(string[] args)
    {
      var n = CIn.ReadInt();
      var uv = CIn.ReadIntArray(2).Select(e => e - 1).ToArray();

      var tree = new List<int>[n];

      for (var i = 0; i < n; i++)
      {
        tree[i] = new List<int>();
      }

      for (var i = 0; i < n - 1; i++)
      {
        var a = CIn.ReadInt() - 1;
        var b = CIn.ReadInt() - 1;

        tree[a].Add(b);
        tree[b].Add(a);
      }

      var dist = new int[2, n];

      for (var i = 0; i < 2; i++)
      {
        var stack = new Stack<SearchRoute>();
        var searched = new bool[n];

        stack.Push(new SearchRoute(uv[i], 0));

        while (stack.Count > 0)
        {
          var sr = stack.Pop();
          searched[sr.Node] = true;
          dist[i, sr.Node] = sr.Depth;

          foreach (var d in tree[sr.Node])
          {
            if (!searched[d]) stack.Push(new SearchRoute(d, sr.Depth + 1));
          }
        }
      }

      var max = 0;

      for (var i = 0; i < n; i++)
      {
        if (dist[0, i] < dist[1, i]) max = Math.Max(max, dist[1, i]);
      }

      Console.WriteLine(max - 1);
    }
  }

  class SearchRoute
  {
    public int Node { get; }
    public int Depth { get; }

    public SearchRoute(int n, int d)
    {
      Node = n;
      Depth = d;
    }
  }

  class CIn
  {
    private static readonly Queue<string> fieldBuffer = new Queue<string>();

    public static string Read()
    {
      if (fieldBuffer.Count == 0)
      {
        foreach (var field in Console.ReadLine().Split())
        {
          fieldBuffer.Enqueue(field);
        }
      }
      return fieldBuffer.Dequeue();
    }

    public static int ReadInt() => int.Parse(Read());
    public static long ReadLong() => long.Parse(Read());
    public static double ReadDouble() => double.Parse(Read());

    public static string[] ReadStringArray(long n)
    {
      var array = new string[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = Read();
      }
      return array;
    }

    public static int[] ReadIntArray(long n)
    {
      var array = new int[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = ReadInt();
      }
      return array;
    }

    public static long[] ReadLongArray(long n)
    {
      var array = new long[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = ReadLong();
      }
      return array;
    }

    public static double[] ReadDoubleArray(long n)
    {
      var array = new double[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = ReadDouble();
      }
      return array;
    }
  }
}

Measured memory_bytes: 33420
# 2019/04/14
# AtCoder Beginner Contest 116 - B

# Input
s = int(input())

# Init
sl = list()
lflg = True
sl.append(s)
cnt = 1

# Calc and Output
while(lflg):
    cnt += 1
    if s % 2 == 0:
        s = int(s / 2)
    else:
        s = 3 * s + 1

    for i in range(len(sl)):
        if s == sl[i]:
            print(cnt)
            lflg = False
            break
        
    sl.append(s)


Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include<random>
#include<math.h>
#include<limits.h>
#include<iterator>
#include<queue>
#include<functional>
#define rep(i,a) for(int i=0;i<a;i++)
#define nrep(i,a,b) for(int i=a;i<b;i++)
#define mrep(i,a) for(int i=a;i>=0;i--)
#define ll long long
#define vl vector<ll> 
#define vvl vector<vector<ll> > 
#define vb vector<bool> 
#define vvb vector<vector<bool> > 
#define INF 11234567890123456789
using namespace std;


int main(){
	ll r, g, a; cin >> r >> g;
	cout << (double)(2 * g) - r << endl;
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")

#include "bits/stdc++.h"
using namespace std;

#define pb push_back
#define F first
#define S second
#define f(i,a,b)  for(int i = a; i < b; i++)
#define endl '\n'

using ll = long long;
using db = long double;
using ii = pair<int, int>;

const int N = 1e5 + 5, LG = 19, MOD = 1e9 + 7;
const int SQ =225;
const long double EPS = 1e-7;

int32_t main(){
#ifdef ONLINE_JUDGE
    ios_base::sync_with_stdio(0);
    cin.tie(0);
#endif

  ll H;
  cin >> H;
  ll cnt= 1;
  ll ans = 0;
  while(H){
    ans+=cnt;
    cnt+=cnt;
    H/=2;
  }

  cout<<ans<<'\n';


  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define rep2(i, l, r) for (int i = (l); i < (r); i++)
#define ALL(x) (x).begin(), (x).end()     //昇順
#define RALL(x) (x).rbegin(), (x).rend()  // 降順
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"
const long long mod = 1e9 + 7;
typedef long long ll;
typedef priority_queue<int> PQ;
typedef vector<long long> VL;
typedef vector<bool> VB;
typedef vector<int> VI;  // VI a(n);
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<char> VC;
typedef vector<VS> VSS;
typedef vector<VC> VCC;
typedef vector<VI> VII;  // VII a(n,VI(m)) n * m
typedef vector<VL> VLL;
typedef pair<int, int> PII;
typedef map<int, int> MP;  // MP a;
typedef vector<pair<ll, ll>> PS;

template <class T, class U>
bool chmax(T &a, U b) {
  if (a <= b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T, class U>
bool chmin(T &a, U b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) { os << v[i] << (i < v.size() - 1 ? ", " : ""); }
  os << "}";
  return os;
}

// g++ -std=c++11 prac.cpp
// operator << (cout,a);
// chmin(min,a)

int main() {
  ll n, m, k, x, y , z = 0, h, ans=0, w, sum = 0, Max = -1, Min = 1e9+1;
  string u= "";
  bool ok=true;
  cin >> n >> k;
  VL a(100001);
  rep(i,n){
    cin >> x >> y; 
    a[x] += y;
  }
  rep2(i,1,100001){
    if(k <= a[i]){
      pri(i); return 0;
    }
    k -= a[i];
  }
  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define Rep(i,s,n) for(int i=s;i<n;i++)
#define fi first
#define sc second
#define all(c) c.begin(),c.end()
typedef long long int ll;
typedef pair<int, int> P;
typedef long double ld;
void Ans(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}

const ll INF=1001001001;
const ll mod=10000000007;

int main(){
  ll k;cin>>k;
  vector<ll> a;

  Rep(i,1,10) a.push_back(i);
  while(1){
    if(a.size()>=k){
      cout<<a[k-1]<<endl;
      break;
    }
    k-=a.size();
    vector<ll> old;
    swap(a,old);
    for(ll x:old){
      
    for(int i=-1;i<=1;i++){
      int d=x%10+i;
      if(d<0||d>9) continue;
      ll nx=x*10+d;
      a.push_back(nx);
    }
      
    }
  }
  
}

Measured memory_bytes: 1712
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cfloat>
#include<climits>
#include<cmath>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

#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 llong long long
#define pb(a) push_back(a)

using namespace std;

typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;


template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T& t, const V& v) { t = v; }
template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T& t, const V& v) {
	for (auto& e : t) fill_v(e, v);
}


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


#define ARRAY_MAX 100005
const int INF = 1e9 + 7;
const ll MOD = 1e9 + 7;

int dx4[4] = { 1,0,0,-1 };
int dy4[4] = { 0,1,-1,0 };
int dx2[2] = { 1,0 };
int dy2[2] = { 0,1 };

/******************************************************************************************/


int main() {

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


	ll k, n;
	cin >> k >> n;
	vector<ll> a(n);
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
	}

	for (int i = 0; i < n; i++)
	{
		a.push_back(a[i] + k);
	}

	ll mini = INF;
	for (int i = 0; i < n; i++)
	{
		mini = min(mini, a[i + n - 1] - a[i]);
	}

	cout << mini << endl;




	return 0;
}



Measured memory_bytes: 4864
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define ld long double
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; }
using P=pair<long long,long long>;
#define rep(i,n) for(long long i=0; i<(long long)n; i++)
#define req(i,n) for(long long i=n-1; i>=0; i--)
#define range(i,a,b) for(long long i=a; i<b; i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((long long)(x).size())
#define COUT(x) cout << x << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define onBoard(y,x) (y>=0 && y<h && x>=0 && x<w)
#define pri_que priority_queue
#define vint vector<int>
#define vvint vector<vector<int>>
#define vi vector<int>
#define vvi vector<vector<int>>
#define vs vector<string>
#define vvc vector<vector<char>>
#define vc vector<char>
#define vp vector<pair<int,int>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define show(x) cout<<#x<<"="<<x<<endl;
#define SUM(x) accumulate(x.begin(),x.end(),0)
#define MAX(x) *max_element(x.begin(),x.end())
#define MIN(x) *min_element(x.begin(),x.end())
#define couty cout<<"Yes"<<endl
#define coutn cout<<"No"<<endl
#define coutY cout<<"YES"<<endl
#define coutN cout<<"NO"<<endl
#define yn(x) cout<<(x?"Yes":"No")<<endl
#define YN(x) cout<<(x?"YES":"NO")<<endl
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a, long long b){return a/gcd(a,b)*b;}
const long long dx[8]={1,0,-1,0,1,-1,-1,1};
const long long dy[8]={0,1,0,-1,1,1,-1,-1};
const long long INF = 1e15;
const long long MOD = 1e9+7;

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

    int n,m,x;cin>>n>>m>>x;
    set<int> set;
    rep(i,m){
        int a;cin>>a;
        set.insert(a);
    }
    int res1=0,res2=0;
    for(int i=x+1; i<n; i++){
        if(set.count(i)) res1++;
    }
    for(int i=x; i>0; i--){
        if(set.count(i)) res2++;
    }
    cout<<min(res1,res2)<<endl;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  int h[n+1],i,j;
  for(i=1;i<=n;i++)
    cin>>h[i];
  int dp[n+1];
  for(i=0;i<=n;i++)
    dp[i]=INT_MAX;
  dp[1]=0;
  for(i=1;i<=n;i++)
  {
    for(j=1;j<=2 && (i+j)<=n;j++)
    {
      dp[i+j]=min(dp[i+j],dp[i]+abs(h[i+j]-h[i]));
    }
  }
  cout<<dp[n]<<endl;
  return 0;
}


Measured memory_bytes: 4336
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <map>
#include <iomanip>
#include <math.h> 
#include <stack>
#include <queue>
#include <bitset>
#include <cstdlib>
#include <tuple>
#include <cctype>
#include <ctype.h>
#include <set>
#include <sstream>
#include <time.h>
using namespace std;
//#define int long long
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define fi first
#define se second
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))
typedef long long ll;
typedef pair<int, int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
typedef pair<pint, int> P1;
typedef pair<int, pint> P2;
typedef pair<pint, pint> PP;
static const ll maxLL = (ll)1 << 62;
const ll MOD = 1000000007;
const ll INF = 1e18;
const double PI = 3.14159265;
int ca[12] = { 31,28,31,30,31,30,31,31,30,31,30,31 };




signed main() {
	int i, j;
	int n, k;
	vector<int>list;


	cin >> n;

	rep(i, 0, n) {
		int num;
		cin >> num;
		list.push_back(num);
	}

	sort(list.begin(), list.end(), greater<int>());

	int sum = list[0] / 2;

	for (i = 1; i < n; i++) {
		sum += list[i];
	}
	cout << sum << endl;













	getchar();
	getchar();
	return 0;
}

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

int main()
{
	long long N, M;
	cin >> N >> M;

	long long  ans = min( N, M / 2 );
	long long m = M - 2 * N;
	if( m >= 0 ) ans += m / 4;

	cout << ans << endl;
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define f first
#define s second
#define fore(i,a,b) for(int i = (a), ThxMK = (b); i < ThxMK; ++i)
#define pb push_back
#define all(s) begin(s), end(s)
#define lb(c, x) distance((c).begin(), lower_bound(all(c), (x)))
#define ub(c, x) distance((c).begin(), upper_bound(all(c), (x)))
#define _ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define sz(s) int(s.size())
#define ENDL '\n'
#define vv(type, name, h, ...) vector<vector<type>> name(h, vector<type>(__VA_ARGS__))
#define vvv(type, name, h, w, ...) vector<vector<vector<type>>> name(h, vector<vector<type>>(w, vector<type>(__VA_ARGS__)))
using namespace std;
typedef long double ld;
typedef long long lli;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<lli> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<ii> vii;

#define deb(x) cout << #x": " << (x) << endl;

const int N = 1e3;
const lli INF = 1e18;
const lli MOD = 1e9+7;
const ld EPS = 1e-4;

vi primes(1,2);
vector<vector<ld>>nk;
void sieve(){
	vi m(N+1,0);
	for(int i = 4; i<N; i+=2)m[i]=1;
	for(int i = 3; i*i<=N; i+=2)if(!m[i])for(int j = i*i; j<N; j+=i)m[j]=1;
	for(int i = 3; i<N; i+=2)if(!m[i])primes.pb(i);
}

void pascal(){
	nk =vector<vector<ld>>(N,vector<ld>(N,0.0));
	fore(i,0,N)nk[i][0]=nk[i][i]=1.0;
	fore(i,1,N)fore(j,1,i)nk[i][j]=nk[i-1][j-1]+nk[i-1][j];
}

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

lli lcm(lli a, lli b){
	if(a<b)swap(a,b);
	lli c = gcd(a,b);
	a/=c;
	return a*b;
}

int popcount(lli x) { return __builtin_popcountll(x); }

lli poww(lli a, lli b){
	lli res =1;
	while(b){
		if(b&1) res = res * a;
		a = a*a;
		b/=2;
	}
	return res;
}

lli powm(lli a, lli b){
	lli res =1;
	while(b){
		if(b&1) res = (res * a)%MOD;
		a = (a*a)%MOD;
		b/=2;
	}
	return res;
}

bool isPrime(lli x){
	if(x==1)return 0;
	for(auto i:primes){
		if(i*i>x)return 1;
		if(x%i==0)return 0;
	}
	return 1;
}


lli SUM(lli a, lli b, lli mod=MOD){
	return (a+b+mod)%mod;
}

lli PROD(lli a, lli b, lli mod=MOD){
	a%=mod; b%=mod;
	return a*b % mod;
}

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

vvi graph(int n, int m){
	vv(int,v,n+1,0);
	fore(i,0,m){
		int a,b; cin>>a>>b;
		v[a].pb(b);
		v[b].pb(a);
	}
	return v;
}

// ---- コーディングはここから！ ('-')7


void solve(){
	int n; cin>>n;
	vii v(n);
	vl mn(4,INF), mx(4,-INF);
	fore(i,0,n){
		cin>>v[i].f>>v[i].s;
		fore(j,0,4){
			lli res = v[i].f*dx[j]+v[i].s*dy[j];
			mn[j] = min(mn[j],res);
			mx[j] = max(mx[j],res);
		}
	}
	lli res = 0;
	fore(i,0,4)res=max(res,mx[i]-mn[i]);
	cout<<res<<ENDL;
}
int main(){_
	//int t; cin>>t; while(t--)
	solve();
}


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

using namespace std;

const int MaxN = 1e2 + 12;

int a[MaxN][MaxN];
bool used[MaxN];
int n;

vector <pair<int, int> > ans;

void dfs(int x)
{
    used[x] = true;
    for(int i = 1; i <= n; ++i)
        if(!used[i])
            if(a[x][i])
                dfs(i);
}

bool good()
{
    for(int i = 1; i <= n; ++i)
        used[i] = false;

    dfs(1);

    for(int i = 1; i <= n; ++i)
        if(!used[i])
            return false;


    int s = 0;
    for(int i = 1; i <= n; ++i)
    {
        int c = 0;

        for(int j = 1; j <= n; ++j)
            if(a[i][j] == 1)
                c += j;

        if(s == 0)
            s = c;
        else
            if(s != c)
                return false;
    }

    return true;
}

void rec(int x, int y)
{
    if(x > n)
    {
        if(good())
        {
            for(int i = 1; i <= n; ++i)
            {
                for(int j = 1; j <= n; ++j)
                    cout << a[i][j] << ' ';
                cout << '\n';
            }
            cout << '\n';
        }
        return;
    }
    a[x][y] = a[y][x] = 1;

    if(y < n)
        rec(x, y + 1);
    else
        rec(x + 1, x + 2);

    a[x][y] = a[y][x] = 0;

    if(y < n)
        rec(x, y + 1);
    else
        rec(x + 1, x + 2);
}

void fillAll(int n)
{
    for(int i = 1; i <= n; ++i)
        for(int j = i + 1; j <= n; ++j)
            if((i != j) && (i + j) != n + 1)
                ans.push_back({i, j});
}

int main()
{
    cin >> n;

    //rec(1, 2);

    fillAll(n - n % 2);

    if(n % 2)
        for(int i = 1; i < n; ++i)
            ans.push_back({i, n});

    cout << ans.size() << '\n';

    for(auto p : ans)
        cout << p.first << ' ' << p.second << '\n';

    return 0;
}


Measured memory_bytes: 384
#from heapq import heapify,heappush,heappop
N = int(input())

D = {}
for i in range(N):
  s = input()
  if s in D:
    D[s] += 1
  else:
    D[s] = 1
  
M = int(input())
for i in range(M):
  t = input()
  if t in D:
    D[t] -= 1
  else:
    D[t] = 1

print(max(max(D.values()),0))

Measured memory_bytes: 9136
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int r,c;
string str[130];
int dp[2][1<<17];
vector<int> pat[17];

int main(void){
	scanf("%d%d",&r,&c);
	for(int i=0;i<r;i++){
		cin >> str[i];
	}
	int now=1,prev=0;
	memset(dp,-1,sizeof(dp));
	dp[0][0]=0;
	for(int i=0;i<r;i++){
		for(int j=0;j<c;j++){
			for(int bit=0;bit<(1<<c);bit++){
				if(dp[prev][bit]>=0){
					if(j==0 && i>0){
						if(__builtin_popcount(bit)!=(int)str[i-1].size())continue;
					}
					int nbit=bit<<1;
					bool flag=false;
					if(nbit>=(1<<c)){
						nbit-=(1<<c);
						flag=true;
					}
					dp[now][nbit]=max(dp[now][nbit],dp[prev][bit]);
					int sc=0;
					int cnt=0;
					for(int k=0;k<j;k++){
						if(bit>>k & 1)cnt++;
					}
					if(j>0 && (bit>>0 & 1)){
						if(cnt>0 && str[i][cnt-1]==str[i][cnt])sc++;
					}
					if(flag){
						int v=__builtin_popcount(bit)-cnt;
						if(v>0){
							if(str[i-1][(int)str[i-1].size()-v]==str[i][cnt])sc++;
						}
					}
					dp[now][nbit+1]=max(dp[now][nbit+1],dp[prev][bit]+sc);
				}
			}
			swap(now,prev);
			memset(dp[now],-1,sizeof(dp[now]));
		}
	}
	int ans=0;
	for(int i=0;i<(1<<c);i++){
		if(__builtin_popcount(i)==(int)str[r-1].size()){
			ans=max(ans,dp[prev][i]);
		}
	}
	printf("%d\n",ans*2);
	return 0;
}

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

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define inv(n, a) for(int i = 0; i < n; i++) cin >> a[i]
#define MOD 1000000007
#define INF 1e7
#define LINF 1e15
typedef long long ll;
typedef long double ld;
using Graph = vector<vector<int>>;
// 'a' = 97 'z' = 122 => 'a' = 0 'z' = 25

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

long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}

int main() {
    int x, y;
    cin >> x >> y;
    int a, b; // a = (i+1, j+2) b = (i+2, j+1)
    if(((2*x-y)%3) != 0) {
        cout << 0 << endl;
        return 0;
    }
    b = (2*x-y)/3;
    a = x - 2*b;

    ll u = 1;
    ll mab = max(a, b);
    ll d = 1;
    for(ll i = a+b; i > (a+b)-mab; i--){
        u *= i;
        u%=MOD;
    }
    for(ll i = mab; i > 0; i--){
        d *= i;
        d%= MOD;
    }

    cout << u * modinv(d, MOD) % MOD << endl;
}



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

struct mint {
  ll x;
  mint(ll x=0):x(x%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

const int MAX = 510000;
ll fac[MAX], finv[MAX], inv[MAX];

void cominit()
{
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (ll i=2; i<MAX; i++) {
    fac[i] = fac[i-1] * i % mod;
    inv[i] = mod - inv[mod%i] * (mod/i) % mod;
    finv[i] = finv[i-1] * inv[i] % mod;
  }
}

ll com(ll n, ll k)
{
  if (n<k) return 0;
  if (n<0 || k<0) return 0;
  return fac[n] * (finv[k] * finv[n-k] % mod) % mod;
}

int main()
{
  ll N; cin >> N;
  ll K; cin >> K;
  vector<ll> A(N);
  for (int i=0; i<N; i++){
    cin >> A[i];
  }
  sort(A.begin(),A.end());
  cominit();

  ll p=0, m=0;
  for (int i=0; i<N; i++) {
    m = m + (A[i]*com(N-i-1, K-1))%mod;
    p = p + (A[i]*com(i, K-1))%mod;
  }
  mint ans = p-m;
  cout << ans.x << endl;

  return 0;
}


Measured memory_bytes: 12928
// Bismillah .Ya Allah...
#include<bits/stdc++.h>
using namespace std;
typedef long long int  ll;
typedef pair<int,int> PII;
const int mod = 1e9+7,INF = 1e9;
const ll mx = 1e18;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    ll a,ans;
    double b;
    cin>>a>>b;
    ll b1 = (b*100)+0.001;
    ans = (a*b1)/100;
    //ans = (ll)ans;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3708
from random import *
D=int(input())
C=list(map(int,input().split()))
S=[list(map(int,input().split())) for i in range(D)]
X=[0]*26
XX=X[:]
Y=X[:]
YY=X[:]
P=[]
SC=0
N,M=0,0
for i in range(D):
  for j in range(26):
    X[j]+=C[j]
    XX[j]+=X[j]
  N,M=-1,-10**20
  for j in range(26):
    if Y==-1:
      N,M=0,X[0]+S[i][0]
    if M<X[j]+S[i][j]:
      N,M=j,X[j]+S[i][j]
  XX[N]-=X[N]
  X[N]=0
  P.append(N)
  SC+=X[N]
SC2=0
for i in range(10**4):
  SC2=SC
  d,q=randrange(0,D),randrange(0,26)
  SC2-=S[d][P[d]]
  SC2+=S[d][q]
  for j in range(26):
    Y[j]=0
  YY[P[d]],YY[q]=0,0
  for j in range(D):
    if j==d:
      Z=q
    else:
      Z=P[j]
    Y[P[d]]+=C[P[d]]
    Y[q]+=C[q]
    Y[Z]=0
    YY[P[d]]+=Y[P[d]]
    YY[q]+=Y[q]
  if SC2-sum(YY)>=SC-sum(XX) or randrange(0,20)==0:
    P[d]=q
    XX=YY[:]
    SC=SC2
for i in range(10**5):
  SC2=SC
  d,q=randrange(0,D),randrange(0,26)
  SC2-=S[d][P[d]]
  SC2+=S[d][q]
  for j in range(26):
    Y[j]=0
  YY[P[d]],YY[q]=0,0
  for j in range(D):
    if j==d:
      Z=q
    else:
      Z=P[j]
    Y[P[d]]+=C[P[d]]
    Y[q]+=C[q]
    Y[Z]=0
    YY[P[d]]+=Y[P[d]]
    YY[q]+=Y[q]
  if SC2-sum(YY)>=SC-sum(XX):
    P[d]=q
    XX=YY[:]
    SC=SC2
for i in range(D):
  print(P[i]+1)

Measured memory_bytes: 86868
n = int(input())
l = list(map(int,input().split()))

res = 0
for t0 in range(0,len(l)-2):
    for t1 in range(t0+1,len(l)-1):
        for t2 in range(t1+1,len(l)):

             if (l[t0] + l[t1] > l[t2] and l[t0] + l[t2] > l[t1] and l[t1] + l[t2] > l[t0] and l[t0]!=l[t1] and l[t1]!=l[t2] and l[t0]!=l[t2]):
                 res += 1

print(res)


Measured memory_bytes: 9064
#include <cstdio>
#include <iostream>
// #define DEBUG

using namespace std;

const int Maxn = 1e5+7;
const int INF = 1e9;

int n, k, ans = INF;
int a[Maxn], p = -1;

int main()
{
    scanf("%d%d", &n, &k);
    for(int i = 1; i <= n; ++i)
    {
        scanf("%d", a+i);
        if(a[i] == 0)
        {
            k--;
            i--;
            n--;
        }
        else if(p == -1 && a[i] > 0) p = i-1;
    }
    if(p == -1) p = n;
    // a[p] < 0, a[p+1] > 0
    if(p+k <= n) ans = min(ans, a[p+k]);
    if(p-k+1 >= 1) ans = min(ans, -a[p-k+1]);
#ifdef DEBUG
    printf("%d %d\n", p, ans);
#endif
    // p+i <= n, p-(k-i)+1 >= 1
    for(int i = 1; i < k; ++i)
    {
        if(p+i <= n && p-(k-i)+1 >= 1)
            ans = min(ans, min(a[p+i], -a[p-(k-i)+1])+a[p+i]-a[p-(k-i)+1]);
#ifdef DEBUG
        printf("%d %d\n", i, ans);
#endif
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 640
//#include<bits/stdc++.h>
#include<set>
#include<map>
#include<list>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<complex>
#include<sstream>
#include<iostream>
#include<fstream>
#include<algorithm>
#include<numeric>
#include<utility>
#include<functional>
#include<stdio.h>
#include<assert.h>
#include<memory.h>
#include<bitset>
#include<stdio.h>
#include <cstdio>
#include <cstring>
#include <string>


using namespace std;

#define ld long double
#define ll long long
#define ff first
#define ss second
#define sz(a) (int)a.size()
#define mem(a, b) memset((a), (b), sizeof(a))
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define pii pair<int ,int >
#define pll pair<ll ,ll >
#define mp make_pair
#define vi vector<int >
#define vii vector<pii>
#define vvi vector < vi >
#define vll vector < ll >
#define vllll vector < pll >
#define vvll vector < vll >
#define forn(i,n) for(int i=0;i<(n);i++)
#define fori(i,s,e) for(int i=s,i<n;i++)
#define qi  queue <int >
#define qll  queue <ll >
#define in_r(x,y,n,m) (x>=0 && x<n && y>=0 && y<m)
#define maxn 1000009


void fast(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
}

const ll MOD = 1e9 + 7;
const double EPS = (1e-8);
const int OO = (int) 1e9 + 7;
const ll OOO = (ll) 1e15 + 7;
//double const PI = 3.1415926535897932384626433832795;
const int mxn = 1000009;
char c1, c2, c3, c4;
string s, s1, s2, s3;
int   n, m, k, t = 1, q, a, b, c, d, e, x, y, z; int sol = 0;

bool pri[8198];
int cnt[8198];

void pre(){}


void solve() {
	
	cin >> s;
	n = sz(s);
	for (int i = 0; i < n; i++){
		if (s[i] == '?') cout << "D";
		else cout << s[i];
	}
	
}


int main(){
	fast();
	pre();
	


	//cin >> t; 
	while (t--){

		solve();

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

Measured memory_bytes: 3788
#include <stdio.h>
int main(void)
{
  int x,y;
  scanf("%d", &x);
  scanf("%d", &y);

if(x > 100 || y > 100 || x < 1 || y < 1)
printf("No");


 if(4*x-y < 0 || y-2*x < 0){
 printf("No");
}else if(y % 2 == 1){
printf("No");
}else{
  printf("Yes");
}

  return 0;
}


Measured memory_bytes: 1728
import java.io.*;
import java.util.*;
 
public class Main {
    
    class Answer {
        String A, B;
        
        public String solve() {
            int a = A.charAt(0)-'A';
            int b = B.charAt(0)-'A';
            if (a > b) return ">";
            else if (a < b) return "<";
            else return "=";
        }
        
        public void main(FastScanner in, PrintWriter out) {
            A = in.next();
            B = in.next();
            out.println( solve() );
        }
        
        public void p(Object o) { System.out.print(o); }
        public void pl(Object o) { System.out.println(o); }
        public void arp(int[] o) { pl( Arrays.toString(o) ); }
        public void arpp(int[][] o) { 
            for (int i = 0; i < o.length; i++) {
                for (int j = 0; j < o[0].length; j++) { p(o[i][j] + " "); }
                pl("");
            }
        }
        public void ck(Object o1, Object o2) { pl(o1 + " " + o2); }
        public void ckk(Object o1, Object o2, Object o3) { pl(o1 + " " + o2 + " " + o3); }
        public void ckkk(Object o1, Object o2, Object o3, Object o4) { 
            pl(o1 + " " + o2 + " " + o3 + " " + o4);
        }
    }
 
    public static void main(String[] args) throws Exception {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastScanner in = new FastScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        
       Main problem = new Main();
        Answer ans = problem.new Answer();
        ans.main(in, out);
        
        out.close();
        in.close();
    }
    
    static class FastScanner {
        BufferedReader br;
        StringTokenizer st;
        public FastScanner(InputStream in) { br = new BufferedReader(new InputStreamReader(in)); }
        public int nextInt() { return Integer.parseInt(next()); }
        public long nextLong() { return Long.parseLong(next()); }
        public double nextDouble() { return Double.parseDouble(next()); }
        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try { st = new StringTokenizer(br.readLine()); } 
                catch (IOException e) { e.printStackTrace(); }
            }
            return st.nextToken();
        }
        public String nextLine() {
            String str = "";
            try { str = br.readLine();
            } catch (IOException e) { e.printStackTrace(); }
            return str;
        }
        public void close() throws IOException { br.close(); }
    }
}

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

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

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

    set<int> S;
    REP(i, n) {
        int a;
        cin >> a;
        if (S.count(a)) {
            S.erase(a);
        } else {
            S.insert(a);
        }
    }

    cout << S.size();
}


Measured memory_bytes: 4864
o=input()
e=input()
s=[]
i=1
j=0
while True:
    if i%2==0:
        s.append(e[j])
        i+=1
        j+=1
    else:
        s.append(o[j])
        i+=1
    if i>=len(o)+len(e)+1:
        break
for i in range(len(s)):
    print(s[i],end="")

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

using namespace std;

typedef long long ll;

const int INF = 1e9+7;


int main()
{
    int n;
    cin >> n;
    vector <ll> a(n);
    vector <vector <ll>> dp(n, vector <ll> (n, 0));
    for (int i=0; i<n; ++i)
        cin >> a[i];

    for (int len=1; len<=n; ++len)
    {
        for (int i=0; i+len<=n; ++i)
        {
            int j = i + len - 1;
            if (i == j)
                dp[i][j] = a[i];
            else
                dp[i][j] = max(a[j] - dp[i][j-1], a[i] - dp[i+1][j]);
        }
    }

    cout << dp[0][n-1];
    return 0;
}

Measured memory_bytes: 70656
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <iomanip>
#include <math.h>
#include <utility>
#include <vector>
#include <map>
#include <unordered_map>
#include <cstdlib>
#define div1 1000000007
const long long INF = 1LL << 60;
using namespace std;
using ll = long long;
// a>b -> a==b;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
// a<b -> a==b;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

template <class T> void swap(T& a, T& b) { T t = std::move(a); a = std::move(b); b = std::move(t); }

int main(void)
{
    ll N, A, B, C, D, i, h=-1, d2=-1;
    string S;

    cin >> N >> A >> B >> C >> D >> S;

    for(i=0; i<N-1; i++){
        if(S[i]=='#' && S[i+1]=='#' && i+1<D){
            h = i;
        }
        if(i>=1 && S[i-1]=='.' && S[i]=='.' && S[i+1]=='.' && i+1<=D){
            d2 = i;
        }
    }

    if(C < D){
        if(h+1>=A && h+1<=D-2){
            cout << "No" << endl;
        }
        else{
            cout << "Yes" << endl;
        }
    }

    else if(C > D){
        if(B-1<=d2 && d2<=D-1){
            cout << "Yes" << endl;
        }
        else{
            cout << "No" << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 644
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define f(i,n) for(i=0;i<n;i++)


using namespace std;

int main() {
   ll i,j,k=0;
   string s,t;
   
   cin>>s>>t;j=s.size();
   
   f(i,j)
   {
       if(s[i]!=t[i])k++;
   }
   cout<<k;
}

Measured memory_bytes: 3848
def dfs(cc,t):
    global ans
    if t >= ans:
        return -1
    if t < ans:
        for i in range(6, 0, -1):
            if cc >= 9**i and t + cc//(9**i) < ans: 
                dfs(cc - 9**i, t + 1)
            if cc >= 6**i and t + cc//(6**i) < ans:
                dfs(cc - 6**i, t + 1)
    if ans > t + cc:
        ans = t + cc
        
N = int(input())
ans = N
dfs(N, 0)
print(ans)


Measured memory_bytes: 3060
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<math.h>
#define ll long long
using namespace std;
ll int power(ll int x, ll int y,ll int p)
{
    ll int res = 1;      // Initialize result
 
    x = x % p;  // Update x if it is more than or 
                // equal to p
 
    while (y > 0)
    {
        // If y is odd, multiply x with result
        if (y & 1)
            res = (res*x) % p;
 
        // y must be even now
        y = y>>1; // y = y/2
        x = (x*x) % p;  
    }
    return res;
}
int main()
{
	int n,x;
	int count[100009]={0};
	int a[100009];
	ll int ans=1;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&x);
		count[x]++;
	}
	ll int c=0;
	for(int i=1;i<=n;i++)
	{
		int rem=abs((i-1)-(n-i));
		if(count[rem]==2)
		c++;
		count[rem]--;
		if(count[rem]<0)
		ans=0;
	}
	if(!ans)
	{
		printf("0\n");
		return 0;
	}
	else
	{
		ans=power(2,c,1000000000+7);
		printf("%lld\n",ans);
	}
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <algorithm>
#include <map>
#include <fstream>
 
using namespace std;
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef priority_queue<int> pqi;
typedef priority_queue<ii> pqii;
typedef map<int, int> mii;
typedef map<int, string> mis;
typedef map<string, int> msi;
typedef set<int> si;
typedef set<ll> sl;
typedef map<ll, ll> mll;
typedef queue<int> qi;
typedef queue<ii> qii;
typedef vector<string> vs;
typedef pair<ll, ll> iil;
typedef vector<iil> viil;
 
#define pb push_back
#define mp make_pair
#define rep(i, n) for (int i = 0 ; i < n ; i++)
#define INF 1000000000

ll MOD = 1000000007;
 
void solve() {
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    int pos = min(a, k);
    int neg = max(0, min(c, k - (a + b)));
    cout << pos - neg << endl;
}
 
void querySolve() {
    int t;
    cin >> t;
    while (t--) {
        solve();
    }
}
 
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    solve();
    //querySolve();
}



Measured memory_bytes: 3652
#include<iostream>

using namespace std;

int main()
{ int a,b,sum;
	cin >> a >> b;
	if(a>b)
	{
		sum = sum + a;
		a--;
	}
	else 
	{
		sum = sum + b;
		b--;
	}
		if(a>b)
	{
		sum = sum + a;
		a--;
	}
	else 
	{
		sum = sum + b;
		b--;
	}
	cout << sum << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <iomanip>
#include <cmath>
#include <stack>

using namespace std;
using ll = long long int;

template <class T> ostream &operator<<(ostream &os, vector<T> &v) {
  for (auto i = v.begin(); i != v.end(); i++) {
    os << *i << " ";
  }
  return os;
}


void solve(long long L){
  double l = (double)L;
  std::cout <<setprecision(10)<< l*l*l / (double)27 << std::endl;
}

int main(){
  long long L;
  scanf("%lld",&L);
  solve(L);
  return 0;
}



Measured memory_bytes: 256