akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<queue>
#include<bitset>
using namespace std;
template<typename __T>
inline void read(__T &x)
{
    x=0;
    int f=1;char c=getchar();
    while(!isdigit(c)){if(c=='-')	f=-1;c=getchar();}
    while(isdigit(c))	{x=x*10+c-'0';c=getchar();}
    x*=f;
}
int son[100005][2];
int cnt=1;
int n;
long long l;
char str[100005];
long long ans;
long long lowbit(long long x)
{
	return x&-x;
}
void dfs(int now,int dep)
{
	if(son[now][0]==0 && son[now][1]==0)	return;
	if(son[now][0]==0)	ans^=lowbit(l-dep);
	if(son[now][1]==0)	ans^=lowbit(l-dep);
	if(son[now][0])	dfs(son[now][0],dep+1);
	if(son[now][1])	dfs(son[now][1],dep+1);
}
int main()
{
	read(n);
	read(l);
	for(int i=0;i<n;i++)
	{
		scanf("%s",str);
		int len=strlen(str);
		int now=1;
		for(int i=0;i<len;i++)
		{
			if(!son[now][str[i]-'0'])	son[now][str[i]-'0']=++cnt;
			now=son[now][str[i]-'0'];
		}
	}
	dfs(1,0);
	if(ans)
		printf("Alice\n");
	else
		printf("Bob\n");
	return 0;
}

Measured memory_bytes: 3456
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 2e5+7;
int n,x,ans;
signed main(){
    scanf("%d%d",&n,&x);
    ans = x;
    for(int i=2;i<=n;i++)
        scanf("%d",&x),ans = __gcd(x,ans);
    printf("%d\n",ans);
    return 0;
}


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

using namespace std;

#define ll long long
const int M=1e9+7;
const int mxN=2e5;
ll mod(ll x){
	return ((x%M+M)%M);
}
ll add(ll a,ll b){
	return mod(mod(a)+mod(b));
}
ll mul(ll a,ll b){
	return mod(mod(a)*mod(b));
}

int main(){
//#ifndef ONLINE_JUGDE
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
//#endif

	ios::sync_with_stdio(0);
    cin.tie(0);
    
    string big,small;
    cin>>big;
    cin>>small;
    int l1=big.size();
    int l2=small.size();
    int ans=INT_MAX;
    bool flag=0;
    for(int i=0;i<l1;i++){
    	int count=0;
    	for(int j=0;j<l2;j++){
    		if(i+j>=l1){
    			flag=1;
    			break;
			}
    		if(big[i+j]!=small[j])
    			count++;
		}
		if(flag==1)
			break;
		ans=min(ans,count);
	}
	cout<<ans;
    return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <unordered_set>
#define llint unsigned long long
#define H 1000000007

using namespace std;

string s, t;
unordered_set<llint> S;
llint bekiH[4005], sumH[4005];

llint get(llint cnt[])
{
  llint ret = 0;
  for(int i = 0; i < 26; i++){
    ret *= bekiH[cnt[i]];
    ret += sumH[cnt[i]]*(i+'a');
  }
  return ret;
}

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

  bekiH[0] = 1;
  for(int i = 1; i < 4005; i++) bekiH[i] = bekiH[i-1]*H;
  for(int i = 1; i < 4005; i++) sumH[i] = sumH[i-1] + bekiH[i];

  llint cnt[26];
  llint ans = 0;
  for(int l = 1; l <= s.size(); l++){

    S.clear();
    for(int j = 0; j < 26; j++) cnt[j] = 0;
    for(int j = 0; j < l-1; j++) cnt[t[j]-'a']++;
    for(int i = 0; i < t.size(); i++){
      int j = i+l-1;
      if(j >= t.size()) break;
      cnt[t[j]-'a']++;
      llint hash = get(cnt);
      S.insert(hash);
      cnt[t[i]-'a']--;
    }

    for(int j = 0; j < 26; j++) cnt[j] = 0;
    for(int j = 0; j < l-1; j++) cnt[s[j]-'a']++;
    for(int i = 0; i < s.size(); i++){
      int j = i+l-1;
      if(j >= s.size()) break;
      cnt[s[j]-'a']++;
      llint hash = get(cnt);
      if(S.count(hash)){
        ans = l;
        break;
      }
      cnt[s[i]-'a']--;
    }
  }
  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 3392
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
set<ll> st= {1,2,3,4,5,6,7,8,9};
vector<ll> v;
const int MAX = 100005;
void solve()
{
    priority_queue< ll,vector<ll>,greater<ll> >  q;
    for(auto &x:st)
    {
        q.emplace(x);
    }
    while(!q.empty())
    {
        if(st.size()>=MAX)
            break;
        auto x=q.top();
        q.pop();
        int t[]= {0,1,-1};
        for(int i=0; i<3; i++)
        {
            ll y=x*10+x%10-t[i];
            if(abs(y%10-x%10)<=1)
            {
                if(!st.count(y))
                {
                    st.insert(y);
                    q.push(y);
                }
            }
        }
    }
    for(auto &x:st)
        v.emplace_back(x);
}
int main()
{
    int x;
    cin>>x;
    solve();
    int i=0;
    for(auto it=st.begin(); it!=st.end(); it++,i++)
    {
        if(i==x-1)
        {
             cout<<*it<<endl;
             break;
        }
    }
}


Measured memory_bytes: 7028
using System;

public class Program
{
	public static void Main(string[] args)
	{
		var ss = new StreamScanner();
		//---------------------------------

		//var y = ss.Next<int>();
		var x = ss.Next<int>();


		for (int i = 3; i <= x; i++)
		{
			if (Check(i))
			{
				Console.Write(" " + i);
			}
		}

		Console.WriteLine("");
		/*
		//????????????int, double, string?????????????????£????????????
		int i = ss.Next<int>();
		double d = ss.Next<double>();
		string s = ss.Next<string>();

		//?????°???????????????????????¨?????????????????????????????????????????????????´???????
		int[] array = ss.Next<int>(10);
		*/
		//---------------------------------
	}

	public static void Write()
	{
		Console.Write("hello world!");
	}

	public static bool Check(int num)
	{
		int checknum = num;
		if (num % 3 == 0)
		{
			return true;
		}

		while (checknum != 0)
		{
			if (checknum % 10 == 3)
			{
				return true;
			}

			checknum = checknum / 10;

		}
		return false;
	}
}




public class StreamScanner
{
	private readonly char[] _c = { ' ' };
	private int _index = -1;
	private string[] _input = new string[0];
	private readonly System.IO.StreamReader _sr = new System.IO.StreamReader(Console.OpenStandardInput());

	public T Next<T>()
	{
		if (_index == _input.Length - 1)
		{
			_index = -1;
			while (true)
			{
				string rl = _sr.ReadLine();
				if (rl == null)
				{
					if (typeof(T).IsClass) return default(T);
					return (T)typeof(T).GetField("MinValue").GetValue(null);
				}
				if (rl != "")
				{
					_input = rl.Split(_c, StringSplitOptions.RemoveEmptyEntries);
					break;
				}
			}
		}
		return (T)Convert.ChangeType(_input[++_index], typeof(T), System.Globalization.CultureInfo.InvariantCulture);
	}

	public T[] Next<T>(int x)
	{
		var ret = new T[x];
		for (var i = 0; i < x; ++i) ret[i] = Next<T>();
		return ret;
	}

	public T[][] Next<T>(int x, int y)
	{
		var ret = new T[y][];
		for (var i = 0; i < y; ++i) ret[i] = Next<T>(x);
		return ret;
	}
}

Measured memory_bytes: 9912
#line 1 "/workspaces/compro/lib/template.hpp"


#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define coutd(n) cout << fixed << setprecision(n)
#define ll long long int
#define vl vector<ll>
#define vi vector<int>
#define MM << " " <<

using namespace std;

template <class T> void say(bool val, T yes, T no) { cout << (val ? yes : no) << "\n"; }

void say(bool val, string yes = "Yes", string no = "No") { say<string>(val, yes, no); }

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

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

// C++ 17に完全移行したら消す
// 最大公約数を求める
template <class T> T gcd(T n, T m) { return n ? gcd(m % n, n) : m; }

// 最小公倍数を求める
template <class T> T lcm(T n, T m) {
  int g = gcd(n, m);
  return n * m / g;
}

// 重複を消す。計算量はO(NlogN)
template <class T> void unique(std::vector<T> &v) {
  std::sort(v.begin(), v.end());
  v.erase(std::unique(v.begin(), v.end()), v.end());
}


#line 2 "abc172_a.cpp"

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

  int a;
  cin >> a;
  cout << a + a * a + a * a * a << endl;
  return 0;
}


Measured memory_bytes: 3648
import std.stdio;

void main() {
	uint[uint] set;
	uint n;

	readf(" %s", &n);

	foreach (i;0..n) {
		uint x;
		readf(" %s", &x);

		if (x in set) {
			writeln("NO");
			return;
		} else {
			set[x] = 1;
		}
	}

	writeln("YES");
}


Measured memory_bytes: 18300
from collections import* 
n=int(input())

d=defaultdict(int)

for i in range(1,n+1):
    d[(str(i)[0],str(i)[-1])]+=1

ans=0
for i in range(1,10):
    for j in range(1,10):
        ans+=d[(str(i),str(j))]*d[(str(j),str(i))]
print(ans)

Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define int long long
#define moder (int)(1e9+7)
#define inf (int)(3e18+7)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define all(v) v.begin(),v.end()
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;

int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1)*x;
}
int mod_pow(int x, int y, int mod) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x%mod;
		}
		x = x * x%mod;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	return kai(x)*mod_pow(kai(x - y), moder - 2, moder) % moder*mod_pow(kai(y), moder - 2, moder) % moder;
}
/*--------Library Zone!--------*/


signed main() {
	char c; cin >> c;
	if (c == 'A')cout << "T" << endl;
	else if (c == 'T')cout << "A" << endl;
	else if (c == 'C')cout << "G" << endl;
	else cout << "C" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll ;
#define fast ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
 const ll inf=1e9+7;

int main()
{
    fast;

string s;

cin>>s;
s+='0';
ll ans=0,g=0,p=0;
for(ll i=0;i<s.size();i++)
{
	if(s[i]=='g')g++;
	else 
	{
		
		if(s[i]=='p')
		p++;
		//if(p==g)g=0,p=0;
		if(g-p>=2)
		{
			ll x=(g-p)/2;
			
			g-=x;
			p+=x;
			
			ans+=x;
		}
		if(p>g)
		{
			p--;
			g++;
			ans--;
		}
		
	}
	
//	cout<<g<<" "<<p<<" "<<ans<<"\n";
	
	
	
}

cout<<ans;



 
    
   
}

		
	
	
	
	


Measured memory_bytes: 3776
#include <iostream>
#include<iomanip>
#include <map>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#define INF 1e9+7
#define rep(i,n) for(int i=0;i<n;i++)
#define NO cout<<"NO"<<endl;
#define YES cout<< "YES"<<endl;
#define No cout<< "No"<<endl;
#define Yes cout<< "Yes"<<endl;
#define all(a) a.begin(),a.end()
#define P pair<int,int>
#define space ' '
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

//(int)'a'は97 (int)'A'は65 (int)'1'は49
//おまじない

const int maxn = 100000;

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


Measured memory_bytes: 256
fun main (args: Array<String>) {
    val n = readLine()!!.toInt()
    val sList = List(n) {
        readLine()!!.toString()
    }

    var acNum = 0
    var waNum = 0
    var tleNum = 0
    var reNum = 0

    sList.forEach {
        when (it) {
            "AC" -> acNum++
            "WA" -> waNum++
            "TLE" -> tleNum++
            "RE" -> reNum++
            else -> {}
        }
    }

    println("AC x $acNum")
    println("WA x $waNum")
    println("TLE x $tleNum")
    println("RE x $reNum")
}

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


int main() {
    int k, x;
    cin >> k >> x;
    int minimum = max(-1000000, x - k + 1);
    int maximum = min(1000000, x + k - 1);
    for (int i = minimum; i <= maximum; i++) {
        cout << i;
        if (i != maximum) cout << " ";
        else cout << endl;
    }
    return 0;
}


Measured memory_bytes: 256
N = int(input())
s = input()
t = input()

if s == t:
    print(N)
    exit(0)

for i in range(1, N):
    if s[i:] == t[:-i]:
        ans = s[:i] + s[i:] + t[-i:]
        print(len(ans))
        exit(0)

print(2 * N)


Measured memory_bytes: 38384
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
#include<cmath>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int,int> pii;
const int inf = 0x3f3f3f3f,oo = inf;
#define Rep(i,a,b) for(RG int i=(a);i<=int(b);++i)
#define Dep(i,a,b) for(RG int i=(a);i>=int(b);--i)
#define rep(i,a,b) for(RG int i=(a);i<int(b);++i)
#define pi 3.14159265358979323846
#define IL inline
#define pc putchar
#define RG register
#define gc getchar
#define fi first
#define se second
#define debug(x) printf(#x" = %d\n",x);
//char __wzp[1<<15|1],*__S=__wzp+32768;
//#define gc() (__S>=__wzp+32768?(__wzp[fread(__wzp,sizeof(char),1<<15,stdin)]=EOF),*((__S=__wzp)++):*(__S++))
#define rd read
#define mem(x,v) memset(x,v,sizeof(x))
#define sqr(x) ((x)*(x))
#define lowbit(x) ((x)&(-(x)))
inline ll read(){
	RG ll x=0,f=1;RG char c=gc();
	for(;!isdigit(c);c=gc())if(c=='-')f=-1;
	for(;isdigit(c);c=gc())x=(x<<1)+(x<<3)+(c^48);
	return x*f;
}
IL double readdb(){
    RG double x=0,p=0.1;RG char f=0,c=gc();
    for(;!isdigit(c);c=gc())f|=(c=='-');
    for(;isdigit(c);c=gc())x=x*10+(c^48);
    if(c=='.')for(c=gc();isdigit(c);c=gc(),p/=10)x=x+(c^48)*p;
    return f?-x:x;
}
#define rdb() readdb()
void write(ll x){if(x<0)x=-x,pc('-');if(x>=10)write(x/10);putchar(x%10+'0');}
void writeln(ll x){write(x);puts("");}
int color[2][1005][1005];
int db[2<<17],n;
const int dx[] = {1,1,-1,-1};
const int dy[] = {1,-1,1,-1};
void dfs(int x,int y,int d,int col,int c){
	color[c][x][y] = col;
	for(int i=0;i*i<=d;i++){
		if(db[d-i*i]<0)continue;
		int j = db[d-i*i];
		rep(r,0,4){
			int tx = x+dx[r]*i;
			int ty = y+dy[r]*j;
			if(tx<0||ty<0||tx>=2*n||ty>=2*n||color[c][tx][ty]) continue;
			dfs(tx,ty,d,col==1?2:1,c);
		}
	}
}
int main(){
	n = rd();
	rep(i,0,2<<17) db[i] = -1;
	for(int i=0;i*i<(2<<17);++i) db[i*i] = i;
	rep(i,0,2){
		int d = rd();
		rep(x,0,2*n)
			rep(y,0,2*n)
				if(!color[i][x][y])
					dfs(x,y,d,1,i);
	}
	vector<pair<int,int> > a;
	rep(x,0,2*n)
		rep(y,0,2*n)
			if(color[0][x][y]==1&&color[1][x][y]==1)
				a.push_back(make_pair(x,y)); 
	rep(i,0,n*n)
		printf("%d %d\n",a[i].fi,a[i].se);
}















Measured memory_bytes: 23156
n=int(input())
lista = [int(i) for i in input().split()]

#2数の最大公約数を返す関数
#ユークリッドの互除法より
def gcd(a,b):
    if b>a:
        a,b = b,a
    if a%b == 0:
        return b
    else:
        return gcd(b,a%b)
    
#頭からとおしりから順にそこまでの最大公約数を計算する
head = lista[0]
tail = lista[n-1]
headlist,taillist = [],[]
for i in range(n):
    headlist.append(gcd(head,lista[i]))
    head = headlist[i]
    taillist.append(gcd(tail,lista[-1*(i+1)]))
    tail = taillist[i]
    
#print(headlist)
#print(taillist)

if n==2:
    print(max(lista[0],lista[1]))
else:
    mhead = taillist[-2]
    mtail = headlist[-2]
    maxval=max(mhead,mtail)
    for i in range(1,n-1):
        maxtemp = gcd(headlist[i-1],taillist[-1*i-2])
        if maxtemp>maxval:
            maxval= maxtemp
    print(maxval)

Measured memory_bytes: 14428
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt(); // 参加者数
        int[] points = new int[n];
        int k = sc.nextInt(); // 初期ポイント
        int q = sc.nextInt(); // 問題数
        for (int i = 0; i < q; i++) {
            int ok_i = (sc.nextInt() - 1); // 正解者ID
            points[ok_i]++;
        }
        // 通過check
        for (int i = 0; i < n; i++) {
            if (q - points[i] >= k) {
                System.out.println("No");
            } else {
                System.out.println("Yes");
            }
        }
    }
}

Measured memory_bytes: 55732
#include<bits/stdc++.h>
#define debug(x) cerr << "[" << #x <<": " << (x) <<"]"<< endl
#define pii pair<int,int>
#define clr(a,b) memset((a),b,sizeof(a))
#define rep(i,a,b) for(int i = a;i < b;i ++)
#define pb push_back
#define MP make_pair
#define LL long long
#define ull unsigned LL
#define ls i << 1
#define rs (i << 1) + 1
#define fi first
#define se second
#define ptch putchar
#define CLR(a) while(!(a).empty()) a.pop()

using namespace std;
inline LL read() {
    LL s = 0,w = 1;
    char ch = getchar();
    while(!isdigit(ch)) {
        if(ch == '-')
            w = -1;
        ch = getchar();
    }
    while(isdigit(ch))
        s = s * 10 + ch - '0',ch = getchar();
    return s * w;
}
inline void write(LL x) {
    if(x < 0)
        putchar('-'), x = -x;
    if(x > 9)
        write(x / 10);
    putchar(x % 10 + '0');
}
#ifndef ONLINE_JUDGE
clock_t prostart = clock();
#endif

int main() {
#ifndef ONLINE_JUDGE
//    freopen("in.txt", "r", stdin);
//    freopen("out.txt", "w", stdout);
#endif

    string s; cin >> s;
    list<char> lst(s.begin(),s.end());
    int q; cin >> q;
    int x = 0;
    while(q --) {
        int t; cin >> t;
        if(t == 1) ++ x;
        else {
            int f; char c; cin >> f >> c;
            if(x % 2 == 1) {
                if(f == 1) lst.push_back(c);
                else lst.push_front(c);
            }
            else {
                if(f == 1) lst.push_front(c);
                else lst.push_back(c);
            }
        }
    }
    if(x % 2) lst.reverse();
    for(auto x : lst) cout << x; cout << endl;

#ifndef ONLINE_JUDGE
    cerr << "time: " << 1.0 * (clock() - prostart) / CLOCKS_PER_SEC << " s" << endl;
#endif
    return 0;
}


Measured memory_bytes: 9984
#include<stdio.h>

int main(void)
{
  char str[3][11] = {0};
  int i;//ループに使う

  for(i=0; i<3; i++){
    scanf("%s", str[i]);
  }

  for(i=0; i<3; i++){
    printf("%c", str[i][0] - 32);
  }
  printf("\n");

  return 0;
}


Measured memory_bytes: 128
#include<cstdio>

int main(){
    int m,d;
    scanf("%d%d",&m,&d);
    int ans = 0;
    for(int i = 1; i <= m; i++){
        for(int j = 1; j <= d; j++){
            int a = j/10, b = j%10;
            if(a>=2 && b>=2 && a*b==i) ans++;
        }
    }
    printf("%d\n",ans);
    return 0;
}

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

#define MOD_1_000_000_007 (1000000007LL)
#define LINF (1LL<<60)
#define rep(i, n)   for (long long i = 0; i <  (long long)(n); i++)
#define rep1(i, n)  for (long long i = 1; i <  (long long)(n); i++)
#define rep2(i, n)  for (long long i = 2; i <  (long long)(n); i++)
#define rep0c(i, n) for (long long i = 0; i <= (long long)(n); i++)
#define rep1c(i, n) for (long long i = 1; i <= (long long)(n); i++)
#define rep2c(i, n) for (long long i = 2; i <= (long long)(n); i++)
#define repc0(n, i) for (long long i = (long long)(n); i >= 0; i--)
#define repc1(n, i) for (long long i = (long long)(n); i >= 1; i--)
#define repc2(n, i) for (long long i = (long long)(n); i >= 2; i--)

namespace solver {
  using namespace std;
  typedef long long ll;

  ll N;
  map<ll, ll> A;

  void init() {
    scanf("%lld", &N);
    ll a;
    rep(i, N-1) {
      scanf("%lld", &a);
      A[a]++;
    }
  }

  void solve() {
    rep1c(i, N) printf("%lld\n", A[i]);
  }
}

int main() {
  solver::init();
  solver::solve();
  return 0;
}

Measured memory_bytes: 16264
N,M = map(int,input().split())
data = [[i,list(map(int,input().split()))] for i in range(M)]

# print(data)
sortdata = sorted(data, key=lambda data:data[1])
# print(sortdata)

cnt = 1
sortdata[0].append(1)
for i in range(1,M):
    if sortdata[i][1][0] == sortdata[i-1][1][0]:
        cnt += 1
    else:
        cnt = 1
    sortdata[i].append(cnt)

sortdata = sorted(sortdata, key=lambda data:data[0])
for i in range(M):
    print(str(sortdata[i][1][0]).rjust(6,'0'),end = "")
    print(str(sortdata[i][2]).rjust(6,'0'))

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

int main(){
  int  N, t, c;
  cin >> N;
  t=N;
  c=0;
 
  
  while (t>0){
    c += t%10;
    t /= 10;
  }
  
  if (N%c == 0){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }

  
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <string>
#include <queue>
#include <cmath>
#include <numeric>
#include <list>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <climits>
#include <set>
#include <memory.h>
#include <memory>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <map>
#include <cassert>
#define _USE_MATH_DEFINES
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, P> PP;
typedef vector<int> vec;
typedef vector<vec> mat;
const int INF = 1 << 30;
const double EPS = 1e-9;

int nums[200];

int main(){
	int n, q;
	while(cin >> n >> q && (n || q)){
		fill(nums, nums + 200, 0);
		for(int i = 0; i < n; i++){
			int num, date;
			cin >> num;
			for(int j = 0; j < num; j++){
				cin >> date;
				nums[date]++;
			}
		}
		int t = -1;
		int id = 0;
		vector<int> res;
		for(int i = 0; i < 200; i++){
			if(nums[i] >= q){
				if(nums[i] > t){
					t = nums[i];
					id = i;
				}
			}
		}
		if(t == -1){
			cout << 0 << endl;
		}else{
			cout << id << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second
 
#define bit(n,k) ((n>>k)&1) //*n no k bit me 1 or 0*/

const int mx=100010;
const ll mod=1e9+7;

int main(){
  string s;
  int n,p;
  cin >> n >> p >> s;
  
  ll ans = 0;
  if(p==2||p==5){
    rep(i,n){
      int d = s[i]-'0';
      if(d%p==0){ ans += i+1; }
    }
  } else {
    vector<int> num(p,0);
    int base=1, sum=0;
    num[0]=1;
    for(int i=n-1; i>=0; i--){
      int d = s[i]-'0';
      sum = (sum + base*d) % p;
      ans += num[sum];
      num[sum]++;
      base = base*10%p;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 640
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class DrawingLots
    {
        char[][] map;
        int[] lines;

        int line, startPos, target, depth;

        public DrawingLots(int n, int m, int t, int d)
        {
            line = n;
            startPos = m;
            target = t;
            depth = d;

            map = new char[depth][];
        }

        public void MakeMap(string source, int i)
        {
            string temp = "0" + source + "0";

            map[i] = temp.ToCharArray();
        }

        public string Solve()
        {
            if (isTarget()) return "0";

            for (int i = 0; i < depth; i++)
            {
                for (int j = 1; j < line; j++)
                {
                    if (map[i][j] == '1') continue;

                    if (map[i][j - 1] == '0' && map[i][j + 1] == '0')
                    {
                        map[i][j] = '1';

                        if (isTarget()) return string.Format("{0} {1}", i + 1, j);

                        map[i][j] = '0';
                    }
                }
            }
            return "1";
        }

        private bool isTarget()
        {
            lines = Enumerable.Range(0, line + 1).ToArray();

            for (int i = 0; i < depth; i++)
            {
                for (int j = 1; j < line; j++)
                {
                    if (map[i][j] == '1')
                    {
                        int temp = lines[j];
                        lines[j] = lines[j + 1];
                        lines[j + 1] = temp;
                    }
                }
            }
            return lines[target] == startPos;
        }
    }

    class Program
    {
        static void Main()
        {
            StringBuilder sb = new StringBuilder();

            while (true)
            {
                int n = int.Parse(Console.ReadLine());

                if (n == 0) break;

                int m = int.Parse(Console.ReadLine());
                int t = int.Parse(Console.ReadLine());
                int d = int.Parse(Console.ReadLine());

                DrawingLots DL = new DrawingLots(n, m, t, d);

                for (int i = 0; i < d; i++)
                {
                    string input = Console.ReadLine();

                    DL.MakeMap(input, i);
                }

                sb.AppendLine(DL.Solve());
            }
            Console.Write(sb);
        }
    }
}

Measured memory_bytes: 9644
#include <cstdio>
#include <algorithm>
#include <queue>
using namespace std;

priority_queue <double ,vector <double>,greater <double> > que;
int n;
double a,ans; 

int main(void){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%lf",&a);
		que.push(a);
	}
	while(!que.empty()){
		double u1=que.top();
		que.pop();
		if(que.empty()){
			printf("%.6lf\n",u1);
			return 0;
		}
		double u2=que.top();
		que.pop();
		que.push((u1+u2+0.0)/2.0);
	}
}

Measured memory_bytes: 256
def main():
    N, M = map(int, input().split())
    X = sorted(map(int, input().split()))
    if N >= M:
        print(0)
        return
    D = [0]*(M-1)
    for i in range(M-1):
        D[i] = X[i + 1] - X[i]
    D.sort()
    ans = sum(D[:M-N])
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 13968
import java.util.*;
import java.lang.*;


public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int[] h = new int[n + 1];
        for (int i = 1; i <= n; i++) {
            h[i] = sc.nextInt();
        }
        int[] dp = new int[n + 1];
        dp[0] = 1000000000;
        for (int i = 2; i <= n; i++) {
            int min = 1000000000;
            for (int j = 1; j <= k && j < i; j++) {
                min = Math.min(dp[i - j] + Math.abs(h[i - j] - h[i]), min);
            }
            dp[i] = min;
        }
        System.out.println(dp[n]);
    }
}

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


def main():
    K = input().replace("\n", "")
    D = int(input())
    
    mod = pow(10, 9)+7
    n = len(K)
    dp = [[0]*D for _ in range(n+1)]
    
    dp[0][0] = 1
    sub = 0
    
    if D == 1:
        ans = 0
        for i in range(n):
            ans = (ans*10+int(K[i]))%mod
        print(ans)
        sys.exit()


    for i in range(n):
        if i != 0:
            for j in range(10):
                for k in range(D):
                    dp[i+1][(k+j)%D] += dp[i][k]
                    dp[i+1][(k+j)%D] %= mod
            for j in range(1, 10):
                dp[i+1][j%D] += 1
                dp[i+1][j%D] %= mod
        
        
        for j in range(int(K[i])):
            if i == 0 and j == 0:
                continue
            dp[i+1][(j+sub)%D] += 1
            dp[i+1][(j+sub)%D] %= mod
        sub = (sub+int(K[i]))%D
    
    sub = 0
    for i in range(n):
        sub = (sub+int(K[i]))%D
    if sub == 0:
        dp[n][0] += 1
        dp[n][0] %= mod
        
    
    print(dp[n][0])
    
    
if __name__ == "__main__":
    main()


Measured memory_bytes: 82732
#include <iostream>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
using namespace std;



int main()
{
	int X,a,b;
	cin >> X >> a >> b;
	cout << (a >= b ? "delicious" : (a + X >= b ? "safe": "dangerous")) << endl;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val (n, d) = readIntList()
    val p = List(n) { readLongList() }

    val dd = d.toLong() * d.toLong()
    var ans = 0
    p.forEach {
        val dis = it[0] * it[0] + it[1] * it[1]
        if (dis <= dd) ans++
    }
    println(ans)
}

// Tools
fun readString() = readLine()!!
fun readInt() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntList() = readLine()!!.split(" ").map(String::toInt)
fun readLongList() = readLine()!!.split(" ").map(String::toLong)


Measured memory_bytes: 78864
N = int(input())
A = list(map(int, input().split()))

min_idx = 0
min_val = float('inf')

for i, a in enumerate(A):
    if abs(a) < min_val:
        min_idx = i
        min_val = abs(a)


for i in range(min_idx):
    if A[i] < 0:
        A[i] *= -1
        A[i + 1] *= -1


for i in range(N - 2, min_idx - 1, -1):
    if A[i + 1] < 0:
        A[i] *= -1
        A[i + 1] *= -1


print(sum(A))


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

int a[100000+10];
main(){
    int n,m;cin>>n>>m;int sum=0;
    for(int i=1;i<=n;i++)
        cin>>a[i],sum+=a[i];
    int cnt=0;
    for(int i=1;i<=n;i++)
        if(a[i]*4*m>=(sum))
            cnt++;
    if(cnt>=m)
        cout<<"Yes";
    else
        cout<<"No";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define IO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
const int N = 1e4 + 5;
long double ans[N][N];
ll mod = 1e9 + 7;
int main() {
	IO
	int n;
	cin >> n;
	long double arr[n + 1];
	for (int i = 1; i <= n; i++)
		cin >> arr[i];
	for (int i = 1; i <= n; i++)
		for (int j = 0; j <= n; j++)
			ans[i][j] = 0;
	ans[1][1] = arr[1];
	ans[1][0] = 1 - arr[1];
	for (int i = 2; i <= n; i++){
		for (int j = 0; j <= i; j++){
			ans[i][j] += ans[i - 1][j] * (1 - arr[i]);
			if (j)
				ans[i][j] += ans[i - 1][j - 1] * arr[i];
		}
	}
	long double final = 0;
	for (int i = (n +1 ) / 2; i <= n; i++)
		final += ans[n][i];
	cout << fixed << setprecision(12) << final;
	return 0;
}


Measured memory_bytes: 156336
#include<stdio.h>
int main(){
  int N,n,sum;

  scanf("%d",&N);
  sum = 0;
  n = N;
  while(n>0){
    sum += n%10;
    n /= 10;
  }

  if(N%sum == 0) printf("Yes");
  else printf("No");
}

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

int main() {
    int N;
    cin >> N;
    vector<int> h(N);
    rep(i,N) cin >> h[i];
    reverse(h.begin(),h.end());
    int ans = 0;
    int val = 0;
    for(int i =1;i<N;i++){
        if(h[i-1]<=h[i])val++;
        else val = 0;
        ans = max(ans,val);
    }
    
    cout<< ans <<endl;
    return 0;    
}

Measured memory_bytes: 640
#include<algorithm>//everybody dies in their nightmares
#include<iostream>
#include<cstring>
#include<cstdio>
#include<set>
#include<map>
#include<queue>
#include<deque>
#include<string>
#include<vector>
#include<sstream>
#include<cmath>
//#include<unordered_set>
//#include<unordered_map>
#include<bitset>
#define f(i,a,b) for(register int i=a;i<=b;++i)
#define ff(i,a,b) for(register int i=a;i>=b;--i)
#define debug(x) cerr << #x << " : " << x << " " << endl
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<string, string> pss;
const ll mod = 1e9 + 7;
const double tiaohe = 0.57721566490153286060651209;
ll oula(ll x) { ll res = x;f(i, 2, x / i) { if (x % i == 0) { res = res / i * (i - 1);while (x % i == 0) x /= i; } }if (x > 1) res = res / x * (x - 1);return res; }
ll quickmod(ll a, ll n, ll m) { ll s = 1;while (n) { if (n & 1) { s = s * a % m; }a = (a*a) % m;n = n / 2; }return s; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
void ex_gcd(ll a, ll b, ll &x, ll &y, ll &d) { if (!b) { d = a, x = 1, y = 0; } else { ex_gcd(b, a % b, y, x, d);y -= x * (a / b); } }
ll inv(ll t, ll p) { ll d, x, y;ex_gcd(t, p, x, y, d);return d == 1 ? (x % p + p) % p : -1; }
bool isPrime(ll x) { if (x == 2)return true;if (x % 2 == 0)return false;for (ll i = 2;i*i <= x;i++) if (x % i == 0)return false; return true; }
//double a = log(n) +tiaohe + 1.0 / (2 * n);
double eqa = (1 + sqrt(5.0)) / 2.0;

const int N = 6e5 + 5;
int t;

int main()
{
	string s;
	while (cin >> s)
	{
		if (s == "ABC")puts("ARC");
		else puts("ABC");
	}
	return 0;
}


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

#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define set0(k,n) for(int nn=0;nn<(n);nn++){ (k).push_back(0); }
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define vecsize(b,size) vector<int> (b)((size));
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsl(s) vector<pair<ll,ll>> (s);
#define pairss(s) vector<pair<string,string>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairspl(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsps(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsREV(s) (s).push_back(make_pair(bb,aa));
#define pairslREV(s) (s).push_back(make_pair(bb,aa));
#define pairssREV(s) (s).push_back(make_pair(bb,aa));
#define MOD 1000000007

int main()
{
string S;
	cin >> S;
	bool flag = false;

	for (int x = 0; x < S.size();x++) {
		for (int y = 0; y < S.size();y++) {
			string s = S.substr(0,x)+S.substr(y);
			if (s=="keyence") {
				flag = true;
			}
		}
	}
	if (flag) {
		ce("YES")
	}
	else {
		ce("NO")
	}
    return 0;
}



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

string a[3];
int k[3];

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> a[0] >> a[1] >> a[2];
    int x = 0;
    while (a[x].size() > k[x])
        x = a[x][k[x]++] - 'a';
    cout << char('A' + x);
}


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


Measured memory_bytes: 2148
N = int(input())
Ls = list(map(int, input().split()))
 
# print(N)
# print(Ls)
count = 0 
for i in range(N):
  for j in range(N - (i + 1)):
    # print(i + j)
    for k in range(N - (i + j + 2)):
      # print ( i + j + k)
      # print(i, i + j + 1, i + j + k + 2)
      # print(Ls[i], Ls[i + j + 1], Ls[i + j + k + 2])
      # count += 1
      Ss = sorted([Ls[i],Ls[i + j + 1], Ls[i + j + k + 2]])
      if (Ss[0] + Ss[1] > Ss[2]) and (Ss[0] != Ss[1]) and (Ss[1] != Ss[2]):
        # print(Ss)
        count += 1
print(count)

Measured memory_bytes: 74052
import math
n=int(input())
i=1
k=0
ans=0
while True:
    zan=n-3*i
    if zan<0:
        break
    ans+=math.factorial(zan+k)//(math.factorial(zan)*math.factorial(k))
    i+=1
    k+=1
print(ans%(10**9+7))

Measured memory_bytes: 79620
def main():
    S = input()

    if (
        S.count(S[0]) is 2
        and S.count(S[1]) is 2
        and S.count(S[2]) is 2
        and S.count(S[3]) is 2
    ):
        print("Yes")
    else:
        print("No")

    return


if __name__ == "__main__":
    main()


Measured memory_bytes: 2940
#include<bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define pb push_back
int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define mp make_pair
#define fi first
#define sc second
char s[100];
char t[100];
int main(){
	cin >> s;
	int n = strlen(s);

	cin >> t;
	int m = strlen(t);
	if(n < m) {
		cout << "UNRESTORABLE" << endl;
		return 0;
	}

	bool f = false;
	RREP(i,n - m + 1) {
		bool f2 = true;
		REP(j,m) {
			if(s[i + j] != t[j] && s[i + j] != '?') {
				f2 = false;
				break;
			}
		}
		if(f2) {
			f = true;
			REP(j,m) {
				s[i + j] = t[j];
			}
			break;
		}
	}

	if(f) {
		REP(i,n) {
			cout << ((s[i] != '?') ? s[i] : 'a');
		}
		cout << endl;
	}else {
		cout << "UNRESTORABLE" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const ll MOD = 1000000007;

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

    int s = 0;
    for(int i=0;i<N;i++){
        int a;
        cin >> a;
        s ^= a;
    }
    if(s == 0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
# include <iostream>
# include <string>
# include <algorithm>
using namespace std;
int main()
{
	string a,b;
	cin>>a>>b;
	int x=a.size(),y=b.size();
	int c[x],d[y];
	for(int i=0;i<x;i++)
	{
		c[i]=a[i]-'a';
	}
		for(int i=0;i<y;i++)
	{
		d[i]=b[i]-'a';
	}
	sort(c,c+x);
	sort(d,d+y);
	reverse(d,d+y);
	for(int i=0;i<min(x,y);i++)
	{
		if(c[i]<d[i])
		{
			cout<<"Yes";
			return 0;
		}
		if(c[i]>d[i])
		{
			cout<<"No";
			return 0;
		}
		else
		continue;
	}
	if(x<y)
	cout<<"Yes";
	else
	cout<<"No";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>

using ll = long long;

using namespace std;

using P = pair<ll, ll>;
#define fi first
#define se second

#define INF ((ll)3e9)

bool in_range(ll val, P range) {
    return range.fi <= val && val <= range.se;
}

#define amin(a, b) a = min(a, b)
#define amax(a, b) a = max(a, b)

int main() {
    int n;
    cin >> n;
    vector<P> points(n);
    for (auto &pi:points) {
        cin >> pi.fi >> pi.se;
    }
    ll l = -1, r = INF;
    while (r - l > 1) {
        ll m = (l + r + 1) / 2;
        P plus = {-INF, +INF}, minus = plus;
        bool yes = true;
        for (auto &pi:points) {
            int pl = pi.fi + pi.se,
                mi = pi.fi - pi.se;
            if (!in_range(pl, plus) || !in_range(mi, minus)) {
                yes = false;
                break;
            }
            amax(plus.fi,  pl - m);
            amin(plus.se,  pl + m);
            amax(minus.fi, mi - m);
            amin(minus.se, mi + m);
        }
        if (yes) {
            r = m;
        } else {
            l = m;
        }
    }
    cout << r << '\n';
    return 0;
}

Measured memory_bytes: 6420
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long X=1000000000+7;

int main() {
  int n,m;
  cin>>n>>m;
  Graph ab(n);
  rep(i,m){
    int a,b;
    cin>>a>>b;
    ab[a-1].push_back(b-1);
    ab[b-1].push_back(a-1);
  }
  rep(i,n)
    cout<<ab[i].size()<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdint.h> // uint64_t

#define STR_MAX 3000
#define BUF_SIZE (STR_MAX+50)

// size: specify sizeof(str)
int get_str(char *str, int size) {
    if(!fgets(str, size, stdin)) return -1;
    return 0;
}

#define max(a,b) ((a) > (b) ? (a) : (b))

int main(void) {
    char astr[BUF_SIZE];
    char bstr[BUF_SIZE];
    static int dp[STR_MAX+1][STR_MAX+1];
    static char trace[STR_MAX+1][STR_MAX+1];
    get_str(&astr[1], BUF_SIZE-1);
    get_str(&bstr[1], BUF_SIZE-1);
    int alen = strlen(&astr[1])-1; int blen = strlen(&bstr[1])-1;
    int i, j;
#ifdef DEBUG
    printf("%d %d\n", alen, blen);
#endif

    for(i = 1; i <= alen; i++) {
        for(j = 1; j <= blen; j++) {
            if(dp[i-1][j] >= dp[i][j-1]) {
                dp[i][j] = dp[i-1][j];
                trace[i][j] = 1;
            } else { dp[i][j] = dp[i][j-1]; }
            if(astr[i] == bstr[j]) {
                dp[i][j] = dp[i-1][j-1] + 1;
                trace[i][j] = astr[i];
            }
        }
    }
#ifdef DEBUG
    printf("%d\n", dp[alen][blen]); // length(LCS)
#endif
    int ait = alen; int bit = blen;
    char stack[BUF_SIZE];
    int sidx = 0;
    while(ait >= 1 && bit >= 1) {
#ifdef DEBUG
        printf("(%d, %d): %d\n", ait, bit, trace[ait][bit]);
#endif
        if(trace[ait][bit]>1) {
            stack[sidx++] = trace[ait][bit];
            ait--; bit--;
        } else if(trace[ait][bit] == 1) {
            ait--;
        } else { bit--; }
    }
    // presentation
    for(i = sidx-1; i >= 0; i--) {
        putchar(stack[i]);
    }
    putchar('\n');
    return 0;
}

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

int main(){
  string S;
  long N, K;
  cin >> N >> K >> S;
  char c = S[0];
  bool flag=false;
  long count=0;
  for(long i=1; i<S.size(); i++){
    if(flag && c!=S[i]){
      S[i]=c;
      continue;
    }else if(!flag && c!=S[i]){
      S[i]=c;
      flag=true;
    }else if(flag && c==S[i]){
      flag = false;
      count++;
    }else{
      flag = false;
    }
    if(count==K) break;
  }
  char pre = S[0];
  long ans =0;
  for(long i=1; i<S.size(); i++){
    if(pre==S[i]) ans++;
    else{
      pre=S[i];
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 512
//即最少加多少个位置满足：选取一个集合S，有|S| - Pre[max{li}] - Suf[min{ri}] <= 0
//考虑枚举max{li}，用线段树维护|S| - Suf[min{ri}]的最大值
//加座位可以加在最左边或者最右边 
#include <cstdio>
#include <algorithm>

using namespace std;

void Get_Val(int &Ret)
{
	Ret = 0;
	char ch;
	while (ch = getchar(), ch > '9' || ch < '0')
		;
	do
	{
		(Ret *= 10) += ch - '0';
	}
	while (ch = getchar(), ch >= '0' && ch <= '9');
}

const int Max_N(200050);
const int Max_M(200050);

#define LEFT  (segt[cur].l)
#define RIGHT (segt[cur].r)
#define MID   (segt[cur].mid)
#define TAG   (segt[cur].Tag)
#define MAX   (segt[cur].Max)
#define LCH   (cur << 1)
#define RCH   ((cur << 1) | 1)

struct node
{
	int l, r, mid, Tag, Max;
};
node segt[Max_M << 2];

inline void pushup(const int &cur)
{
	MAX = max(segt[LCH].Max, segt[RCH].Max);
}

inline void Add(const int &cur, const int &v)
{
	TAG += v, MAX += v;
}

inline void pushdown(const int &cur)
{
	if (TAG)
		Add(LCH, TAG), Add(RCH, TAG), TAG = 0;
}

void build_tree(const int &cur, const int &l, const int &r)
{
	LEFT = l, RIGHT = r, MID = l + ((r - l) >> 1), TAG = MAX = 0;
	if (l == r)
		return;
	build_tree(LCH, l, MID), build_tree(RCH, MID + 1, r);
}

void insert(const int &cur, const int &l, const int &r, const int &v)
{
	if (LEFT == l && RIGHT == r)
	{
		Add(cur, v);
		return;
	}
	pushdown(cur);
	if (r <= MID)
		insert(LCH, l, r, v);
	else
		if (l > MID)
			insert(RCH, l, r, v);
		else
			insert(LCH, l, MID, v), insert(RCH, MID + 1, r, v);
	pushup(cur);
}

int query(const int &cur, const int &l, const int &r)
{
	if (LEFT == l && RIGHT == r)
		return MAX;
	pushdown(cur);
	if (r <= MID)
		return query(LCH, l, r);
	else
		if (l > MID)
			return query(RCH, l, r);
		else
			return max(query(LCH, l, MID), query(RCH, MID + 1, r));
}

struct qwq
{
	int L, R;
};
int N, M;
qwq V[Max_N];

inline bool comp(const qwq &a, const qwq &b)
{
	return a.L < b.L;
}

void init()
{
	Get_Val(N), Get_Val(M);
	for (int i = 1;i <= N;++i)
		Get_Val(V[i].L), Get_Val(V[i].R);
}

void work()
{
	build_tree(1, 0, M + 1);
	for (int i = 1;i <= M;++i)
		insert(1, i, i, -(M - i + 1));
	int Ans(0);
	Ans = max(Ans, N - M);
	sort(V + 1, V + 1 + N, comp);
	for (int i = 1;i <= N;++i)
	{
		insert(1, 0, V[i].R, +1);
		Ans = max(Ans, query(1, V[i].L + 1, M + 1) - V[i].L);
	}
	printf("%d", Ans);
}

int main()
{
	init();
	work();
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  rep(i,N){
    cin >> a.at(i);
  }
  int M=N/2+1;
  vector<int> b(M);
  b.at(M-1)=0;
  int j;
  rep(i,N){
    if(i%2==0){
      j=i/2;
      b.at(j)=a.at(i);
    }
  }
  int S=0;
  rep(i,M){
    if(b.at(i)%2==1){
      S++;
    }
  }
  cout << S << endl;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

template<typename T>
void print(const vector<T> &x) {
    int n = x.size();
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x) {
    int n = x.size();
    rep(i,n) {
        rep(j,x[i].size()) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<typename T>
void print(const vector<T> &x, int n) {
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x, int n, int m) {
    rep(i,n) {
        rep(j,m) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

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

void input_init() {
    cin.tie(0); ios::sync_with_stdio(false);
}

int main(int argc, char const *argv[]) {
    int n; cin>>n;
    string s; cin>>s;

    int ans = 0;
    vector<int> idx;
    for (int i = n-1; i >= 0; --i) {
        if (s[i] == 'R') idx.push_back(i);
    }
    reverse(idx.begin(), idx.end());

    if (idx.empty()) {
        cout << 0 << '\n';
        return 0;
    }

    rep(i,n) {
        if (s[i] == 'W') {
            if (i < idx.back()) {
                idx.pop_back();
                ans++;
            }
        }
    }

    cout << ans << '\n';
    return 0;
}

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

using namespace std;

int main()
{
	long double ld;
	long long int n,m,d;
	cin >> n >> m >> d;
	if(n>d*2)
	{
		if(d>0)
			ld = (long double)((n-2*d)*2+d*2)*(m-1)/(n*n);
		else
			ld = (long double)(n)*(m-1)/(n*n);
	}
	else
	{
		ld=(long double)(n-d)*2*(m-1)/(n*n);
	}
	printf("%Lf\n",ld);
}

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

int main() {
  
  int n,k;
  cin >> n >> k;
  
  vector<int> a(n);
  
  for ( int i = 0; i < n; i++){
    cin >> a[i];
  }
  
  sort(a.begin(),a.end());
  
  int goukei = 0;
  
  for ( int i = 0; i < k; i++){
    goukei += a[i];
  }
  
  cout << goukei << endl;  
  
}



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

#define MAX_NUM 100000
#define DAMMY 1000000

int main(){
    /*
    int N;  cin>>N;
    vector<int> A(MAX_NUM,DAMMY);
    vector<int> Order(MAX_NUM);
    for(int i=0;i<N;i++){
        cin>>A[i]; 
    }
    for(int i=0;i<N;i++){
        std::vector<int>::iterator iter = std::min_element(A.begin(), A.end());
        size_t min_index = std::distance(A.begin(), iter);
        //cout<<min_index<<endl;
        Order[i] = min_index+1; //push_backだとOrder内の添え字MAX_NUM以降に追加される
        A[min_index] = DAMMY;
    }

    for(int i=0;i<N;i++){
        cout<<Order[i]<<" ";
    }
    cout<<endl;
    */

    int N; cin>>N;
    vector<int> A(N);
    for(int i=0;i<N;i++)
        cin>>A[i];
    
    vector<int> rev(N);
    for(int i=0;i<N;i++)
        rev[A[i]-1] = i+1;
    for(int i=0;i<N;i++)
        cout<<rev[i]<<" ";
    cout<<endl;    
    return 0;
}

Measured memory_bytes: 1664
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
typedef unsigned long long int ull;
typedef long long lint;

int main(void){
  int N,A,B;
  cin >> N >> A >> B;
  int P[N];
  rep(i,N) cin >> P[i];
  int count[3]={};
  rep(i,N){
    if(P[i]<=A) count[0]++;
    else if(P[i]<=B) count[1]++;
    else count[2]++;
  }
  cout << *min_element(count,count+3) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
int main() {
  ll a, b, c, d;
  cin >> a >> b >> c >> d;
  ll ans = -1e18 - 1;
  ans = max(ans, a * c);
  ans = max(ans, a * d);
  ans = max(ans, b * c);
  ans = max(ans, b * d);
  cout << ans;
}


Measured memory_bytes: 3632