akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

#define N_TIMES(i, n)     for (ulli i = 0;     i <  n; ++i)
#define N_TIMES_REV(i, n) for (slli i = n - 1; i >= 0; --i)

#ifdef __DEBUG__

template<typename T, typename U>
ostream& operator<<(ostream &os, const pair<T, U> &pair)
{
  os << pair.first << ": " << pair.second;
  return os;
}

template<class ForwardIterator>
ostream& _iterator_to_display(
  ostream &os, 
  ForwardIterator begin, ForwardIterator end, 
  const string &delim = ", "
)
{
  auto itr = begin;
  while (itr != end) {
    os << *itr;
    ++itr;
    if (itr != end) os << delim;
  }
  return os;
}

template<typename T>
ostream& operator<<(ostream &os, const list<T> &list)
{
  os << '[';
  _iterator_to_display(os, list.begin(), list.end());
  os << ']';
  return os;
}

template<typename T>
ostream& operator<<(ostream &os, const vector<T> &vector)
{
  os << '[';
  _iterator_to_display(os, vector.begin(), vector.end());
  os << ']';
  return os;
}

template<typename T, class C=less<T>>
ostream& operator<<(ostream &os, const set<T> &set)
{
  os << '{';
  _iterator_to_display(os, set.begin(), set.end());
  os << '}';
  return os;
}

template<typename T, class C=less<T>>
ostream& operator<<(ostream &os, const multiset<T> &set)
{
  os << '{';
  _iterator_to_display(os, set.begin(), set.end());
  os << '}';
  return os;
}

template<typename T, typename U, class C=less<T>>
ostream& operator<<(ostream &os, const map<T, U> &map)
{
  os << '{';
  _iterator_to_display(os, map.begin(), map.end());
  os << '}';
  return os;
}

template<typename T, typename U, class C=less<T>>
ostream& operator<<(ostream &os, const multimap<T, U> &map)
{
  os << '{';
  _iterator_to_display(os, map.begin(), map.end());
  os << '}';
  return os;
}

#define debug(var) cerr << #var" = " << var << endl

#endif /* __DEBUG__ */

int main(int argc, char **argv)
{
  uint64_t N, K;
  string S;
  
  cin >> N >> S >> K;
  
  string T = S;
  char c = S[K - 1];
  
  for (uint64_t i = 0; i < S.size(); ++i) {
    T[i] = (S[i] != c) ? '*' : S[i];
  }
  
  cout << T << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    int A,B;
    cin>>A>>B;
   if((A+B)>(A-B) && (A+B)>(A*B))
    {
        cout<<(A+B)<<endl;
    }
    else if((A*B)>(A+B)&&(A*B)>(A-B))
    {
        cout<<(A*B);
    }
    else if((A-B)>(A*B)||(A-B)>(A+B))
    {
        cout<<(A-B);
    }
    else
    {
        cout<<'0';
    }

}


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

using namespace std;

#define pb push_back
#define eb emplace_back
#define ll long long
#define pii pair < int, int >
#define fr first
#define sc second
#define mk make_pair
#define sz(s) (int)s.size()
#define all(s) s.begin(), s.end()
#define OK puts("ok");
#define whatis(x) cerr << #x << " = " << x << endl;
#define pause system("pause");
#define int long long

const int N = (int)5e5 + 7;
const int inf = (int)1e9 + 7;

int shift = 2e5;

struct fen {
  int tree[N];
  void init() {
    memset(tree, 0, sizeof tree);
  }
  void upd(int pos, int val) {
    for (; pos < N; pos += pos & -pos) {
      tree[pos] += val;
    }
  }
  int get(int r) {
    int res = 0;
    for (; r > 0; r -= r & -r) {
      res += tree[r];
    }
    return res;
  }
  int get(int l, int r) {
    return get(r) - get(l - 1);
  }
};
fen tree;

int a[N], b[N];
int n;
ll lim;

bool check(int x) {
  tree.init();
  ll res = 0;
  int sum = shift;
  tree.upd(sum, 1);
  for (int i = 1; i <= n; i++) {
    b[i] = ((a[i] < x) ? -1 : 1);
    sum += b[i];
    res += tree.get(sum);
    tree.upd(sum, 1);
  }
  return res >= (lim + 1) / 2;
}

main() {
  tree.init();
  scanf("%lld", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%lld", &a[i]);
  }
  lim = n * (n + 1) / 2;
  int l = 0;
  int r = inf;
  while (r - l > 1) {
    int mid = (l + r) >> 1;
    if (check(mid)) {
      l = mid;
    } else {
      r = mid;
    }
  }
  cout << l;
}


Measured memory_bytes: 10752
import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.lang.AssertionError
import java.util.*
import kotlin.math.abs
import kotlin.math.max
import kotlin.math.min

val MOD = 1_000_000_007L

class Solver(stream: InputStream, private val out: java.io.PrintWriter) {
  fun solve() {
    fun calcEven(X: Long, K: Long, D: Long): Long {
      val fstK = min(K, X / D)
      val x1 = X - fstK * D
      val sndK = K - fstK
      debug{"$fstK $sndK $x1"}
      return if (sndK == 0L) {
        abs(x1)
      } else {
        min(abs(x1), abs(x1 - D))
      }
    }

    val X = abs(nl())
    val K = nl()
    val D = nl()

    val ans = if (K % 2 == 0L) {
      calcEven(X, K/2, D*2)
    } else {
      min(calcEven(abs(X - D), (K - 1)/2, D*2), calcEven(abs(X + D), (K - 1)/2, D*2))
    }

    out.println(ans)
  }













































  private val isDebug = try {
    // なんか本番でエラーでる
    System.getenv("MY_DEBUG") != null
  } catch (t: Throwable) {
    false
  }

  private var tokenizer: StringTokenizer? = null
  private val reader = BufferedReader(InputStreamReader(stream), 32768)
  private fun next(): String {
    while (tokenizer == null || !tokenizer!!.hasMoreTokens()) {
      tokenizer = StringTokenizer(reader.readLine())
    }
    return tokenizer!!.nextToken()
  }

  private fun ni() = next().toInt()
  private fun nl() = next().toLong()
  private fun ns() = next()
  private fun na(n: Int, offset: Int = 0): IntArray {
    return map(n) { ni() + offset }
  }
  private fun nal(n: Int, offset: Int = 0): LongArray {
    val res = LongArray(n)
    for (i in 0 until n) {
      res[i] = nl() + offset
    }
    return res
  }

  private fun na2(n: Int, offset: Int = 0): Array<IntArray> {
    val a  = Array(2){IntArray(n)}
    for (i in 0 until n) {
      for (e in a) {
        e[i] = ni() + offset
      }
    }
    return a
  }

  private inline fun map(n: Int, f: (Int) -> Int): IntArray {
    val res = IntArray(n)
    for (i in 0 until n) {
      res[i] = f(i)
    }
    return res
  }

  private inline fun debug(msg: () -> String) {
    if (isDebug) System.err.println(msg())
  }

  private inline fun debug(a: LongArray) {
    debug { a.joinToString(" ") }
  }

  private inline fun debug(a: IntArray) {
    debug { a.joinToString(" ") }
  }

  private inline fun debug(a: BooleanArray) {
    debug { a.map { if (it) 1 else 0 }.joinToString("") }
  }

  private inline fun debugDim(A: Array<LongArray>) {
    if (isDebug) {
      for (a in A) {
        debug(a)
      }
    }
  }
  private inline fun debugDim(A: Array<IntArray>) {
    if (isDebug) {
      for (a in A) {
        debug(a)
      }
    }
  }

  /**
   * 勝手にimport消されるのを防ぎたい
   */
  private fun hoge() {
    min(1, 2)
    max(1, 2)
    abs(-10)
  }

  private inline fun assert(b: Boolean) = run{if (!b) throw AssertionError()}
}

fun main() {
  val out = java.io.PrintWriter(System.out)
  Solver(System.`in`, out).solve()
  out.flush()
}

Measured memory_bytes: 34736
n=int(input())
s=[]
for _ in range(n):
    s.append(input())
for i in range(n):
    s[i]=sorted(s[i])
s.sort()
num=0
last=1
counter=[]
while num<n-1:
    if s[num]!=s[num+1]:
        num+=1
        counter.append(last)
        last=1
    elif s[num]==s[num+1]:
        num+=1
        last+=1
if last>1: counter.append(last)

b=[i for i in counter if i>1]
ans=0
for v in b:
    ans+=int(v*(v-1)/2)
print(ans)

Measured memory_bytes: 25296
import java.io.*;
import java.util.*;
class Main {
	public static void main(String[] args) throws IOException{
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		//BufferedReader in = new BufferedReader(new FileReader("prob.in"));
		
		PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
		//PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter("prob.out")));
		
		
		
		StringTokenizer st = new StringTokenizer(in.readLine());
		
		long A = Long.parseLong(st.nextToken());
		long B = Long.parseLong(st.nextToken());
		
		long curr = A;
		int count = 0;
		while(curr <= B){
			count++;
			curr = curr * 2;
		}
		
		out.println(count);
		
		
		in.close();
		out.close();
		
	}
}


Measured memory_bytes: 21332
#include <iostream>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<ctime>
#include<set>
#include<queue>
#define sqr(x) ((x)*(x))
#define fz1(i,n) for ((i)=1;(i)<=(n);++(i))
#define fd1(i,n) for ((i)=(n);(i)>=1;--(i))
#define fz0g(i,n) for ((i)=0;(i)<=(n);++(i))
#define fd0g(i,n) for ((i)=(n);(i)>=0;--(i))
#define fz0k(i,n) for ((i)=0;(i)<(n);++(i))
#define fd0k(i,n) for ((i)=(long long)((n)-1);(i)>=0;--(i))
#define fz(i,x,y) for ((i)=(x);(i)<=(y);++(i))
#define fd(i,y,x) for ((i)=(y);(i)>=(x);--(i))
#define ff(c,itr) for (__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
#define rdst(st,len){static char ss[len];scanf(" %s",ss);(st)=ss;}
using namespace std;
int n,m,i,j,lc[200005],rc[200005],a[200005],sz[200005],rnd[200005],rt[400005],dep[200005],lst[400005];
struct bit
{
	int a[200005];
	void add(int x,int y)
	{
		int i;
		for(i=x;i;i-=(i&-i)) a[i]=max(a[i],y);
	}
	int query(int x)
	{
		int i,s=0;
		for(i=x;i<=n;i+=(i&-i)) s=max(s,a[i]);
		return s;
	}
}tr;
void pushup(int x)
{
	sz[x]=sz[x+x]+sz[x+x+1]+1;
}
int rst(int x)
{
	while(rc[x]) x=rc[x];
	return a[x];
}
void split(int x,int y,int &l,int &r)
{
	if(!x){
		l=r=0;
		return;
	}
	if(y<=a[x]){
		split(lc[x],y,l,lc[x]);r=x;
		pushup(r); 
	}
	else{
		split(rc[x],y,rc[x],r);l=x;
		pushup(l);
	}
}
int merge(int x,int y)
{
	if(!x||!y) return x+y;
	if(rnd[x]>rnd[y]){
		rc[x]=merge(rc[x],y);
		pushup(x);
		return x;
	}
	else{
		lc[y]=merge(x,lc[y]);
		pushup(y);
		return y;
	}
}
int main()
{
	scanf("%d",&n);
	fz1(i,n){
		scanf("%d",&a[i]);
		dep[i]=tr.query(a[i])+1;m=max(m,dep[i]);
		tr.add(a[i],dep[i]);
		sz[i]=1;rnd[i]=rand()*32768+rand();
		rt[dep[i]]=merge(rt[dep[i]],i);
	}
	fz1(i,m){
		lst[i]=rst(rt[i]);
	}
	fz1(i,m-1){
		while(rt[i]){
			int t=rst(rt[i]),l=i+1,r=m+1,mid,ans=i;
			while(l<r){
				mid=(l+r)/2;
				if(lst[mid]>t){
					l=mid+1;
					ans=mid;
				}
				else r=mid;
			}
			if(ans==m){
				m++;
			}
			int t1,t2;
			split(rt[i],lst[ans+1],t1,t2);
			rt[i]=t1;rt[ans+1]=merge(rt[ans+1],t2);
			lst[i]=rst(rt[i]);lst[ans+1]=rst(rt[ans+1]);
		}
	}
	printf("%d\n",m-1);
	return 0;
}

Measured memory_bytes: 8320
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep1(i,n) for(int i=1; i<=(n); ++i)
#define repi(i,a,b) for(int i=a; i<=(b); ++i)
#define rrep(i,n) for(int i=(n-1); i>=0; --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define pb push_back
#define mp make_pair
#define to_s to_string
#define sz(v) (int)v.size()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define pr(x) cout<<(x)<<'\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
#define yes "Yes"
#define no "No"
using ll = long long;
using namespace std;
typedef pair<int,int> P;
struct aaa{aaa(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};}aaaaaaa;
int MOD = 1e9 + 7;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return (a*b)/gcd(a,b);}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

string S;

bool check(string S){
    bool flag = true;
    rep(i,sz(S)/2) if(S[i] != S[i+sz(S)/2]) flag = false;
    return flag;
}

int main(){
    cin>>S;
    int ct = sz(S);
    rep(i,ct) {
        rep(j,2) S.pop_back();
        if(check(S)) break;
    }
    pr(sz(S));
}

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

using namespace std;


#define reps(i,f,n) for(int i=f;i<int(n);i++)
#define rep(i,n) reps(i,0,n)

typedef complex<double> P;

vector<P> point;

const double EPS = 0.0000000001;


void init(){
  point.clear();
}


bool input(){
  int n;
  cin>>n;
  if(n==0)return false;

  rep(i,n){
    double a ,b;
    cin>>a>>b;
    point.push_back(P(a,b));
  }
  return true;
}

vector<P> make_cand(){
  vector<P> ret;
  rep(i,point.size()){
    reps(j,i+1,point.size()){
      P dist = point[j]-point[i];
      double d = abs(dist)/2;

      if(d>1)continue;
      double h = sqrt(1-d*d);
      P e = dist/(d*2);

      P e1 = e*P(0,1);
      P e2 = e*P(0,-1);

      P c1 = point[i]+e*d+h*e1;
      P c2 = point[i]+e*d+h*e2;

      //cout<<"d="<<d<<" h="<<h<<endl;
      //cout<<point[i]<<" "<<point[j]<<" "<<c1<<" "<<c2<<endl;
      ret.push_back(c1);
      ret.push_back(c2);
    }
  }
  rep(i,point.size()){
    ret.push_back(point[i]);
  }
  return ret;
}

int count_in(P p){
  int sum = 0;
  rep(i,point.size()){
    P d  = point[i]-p;
    if(abs(d)<=1+EPS)sum++;
  }
  return sum;
}
int solve(){
  vector<P> cand = make_cand();
  int ans = 0;
  rep(i,cand.size()){
    ans = max(ans, count_in(cand[i]));
  }
  return ans;
}

int main(){
  while(init(),input()){
    printf("%d\n",solve());
  }
}

Measured memory_bytes: 1904
#include<bits/stdc++.h>
#define int long long
#define mod 1000000007
#define trace(x) cerr<<#x<<": "<<x<<" "<<endl
#define tarce(x) cerr<<#x<<": "<<x<<" "<<endl
#define trace2(x, y) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z) cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define sa(a,n) for(int i =0 ; i<n ; i++) cin>>a[i]
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define pb push_back
#define inf 2e18
#define scan() int n; cin>>n ; int a[n+1]; for(int i = 1 ; i<=n ; i++) cin>>a[i]
#define scan2() int n,k; cin>>n>>k ; int a[n+1]; for(int i = 1 ; i<=n ; i++) cin>>a[i]
#define print(a,n) for(int i = 0 ; i < n ; i++) cout<<a[i]<<' '
#define mem(a,v) memset(a,v,sizeof(a))
#define pii pair<int,int>
#define mkp make_pair
using namespace std;
#define N 200005

void solve(){
    int n;
    cin >> n;
    int i,j;
    string ans="";
    n--;
    while(n!=-1){
        int x=(n%26);
        ans+=('a'+x);
        n=n/26-1;
    }
    reverse(ans.begin(),ans.end());
    cout << ans << '\n';
}

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

        int tt;
        tt=1;
    //    cin >> tt;
        while(tt--){
            solve();
        }
        

}

Measured memory_bytes: 3656
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

int main(void) {
    int D, G;
    cin >> D >> G;
    vector<int> p(D), c(D);
    for (int i = 0; i < D; i++) {
        cin >> p[i] >> c[i];
    }

    int sum, count, max_d;
    int ans = 1 << 30;
    for (int bit = 0; bit < (2 << (D-1)); bit++) {
        sum = 0;
        count = 0;
        max_d = D-1;
        for (int d = bit, i = 0; d > 0; d = d >> 1, i++) {
            if (d % 2 == 1) {
                sum += 100 * (i+1) * p[i] + c[i];
                count += p[i];
            }
            else {
                max_d = i;
            }
        }
        // cout << sum << " " << count << " " << max_d << endl;
        if (sum < G) {
            if (100 * (max_d+1) * (p[max_d]-1) + sum >= G) {
                count += ceil((G - sum) / (100.0 * (max_d+1)));
            }
            else {
                // cout << bit << " continue" << endl;
                continue;
            }
        }
        if (count < ans) {
            ans = count;
        }
        // cout << bit << " " << count << endl;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
ll n,m;
char s[105][105];
bool S[105][105];
int main(void){
    cin>>n>>m;
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            cin>>s[i][j];
            S[i][j]=true;
        }
    }
    bool t;
    for(int i=0;i<n;i++){
        t=true;
        for(int j=0;j<m;j++){
            if(s[i][j]=='#'){
                t=false;
            }
        }
        if(t==true){
            for(int j=0;j<m;j++){
                S[i][j]=false;
            }
        }
    }
    for(int i=0;i<m;i++){
        t=true;
        for(int j=0;j<n;j++){
            if(s[j][i]=='#'){
                t=false;
            }
        }
        if(t==true){
            for(int j=0;j<n;j++){
                S[j][i]=false;
            }
        }
    }
    for(int i=0;i<n;i++){
        t=false;
        for(int j=0;j<m;j++){
            if(S[i][j]){
                cout<<s[i][j];
                t=true;
            }
        }
        if(t) cout<<endl;
    }
    
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string>
#include <utility>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define loop(i, x, n) for (int i = (x); i < (n); i++)
#define all(v) (v).begin(), (v).end()
#define int long long
using namespace std;
const int MOD = 1e9 + 7;
const int INF = 1e9;
template<typename T> void cmax(T &a, T b) { a = max(a, b); }
template<typename T> void cmin(T &a, T b) { a = min(a, b); }

int modinv(int a, int m) {
  int b = m, u = 1, v = 0;
  while (b) {
    int t = a / b;
    a -= t * b;
    swap(a, b);
    u -= t * v;
    swap(u, v);
  }
  u %= m;
  if (u < 0) u += m;
  return u;
}

map<int, int> prime_fac(int n) {
  map<int, int> ret;
  for (int i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if (n != 1) ret[n] = 1;
  return ret;
}
int fact[200005];
int inv[200005];

signed main() {
  int n, m;
  cin >> n >> m;

  map<int, int> mp = prime_fac(m);
  fact[0] = 1;
  inv[0] = 1;
  loop(i, 1, 200005) {
    fact[i] = fact[i - 1] * i;
    fact[i] %= MOD;
    inv[i] = modinv(fact[i], MOD);
  }

  int ans = 1;
  for (auto x : mp) {
    int t = x.second;
    // cout << x.first << ' ' << t << endl;
    (ans *= fact[t + n - 1] * inv[t] % MOD * inv[n - 1] % MOD) %= MOD;
  }
  cout << ans % MOD << endl;
  return 0;
}


Measured memory_bytes: 3328
N=int(input())
l,r=0,N
now=-1
print(0)
a=input()
li=['Male','Famale']
if(a=='Vacant'):
    print(0)
    exit()
elif(a=='Male'):
    now=0
else:
    now=1
for _ in range(19):
    Q=((l+r)//2)%N
    print(Q)
    ans=input()
    if(ans=='Vacant'):
        print(Q%N)
        exit()
    res=-1
    if(ans=='Male'):
        res=0
    else:
        res=1
    if((Q-l-1)%2==1 and res!=now) or ((Q-l-1)%2==0 and res==now):
        r=Q
    else:
        l=Q
        now=res
print((l+r)//2%N)

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

#define INF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define MODA 1000000007 

int main() {
    int ans = 0;
    string s;
    cin >> s;
    if(s[0] == 'S') cout << "Cloudy" << endl;
    else if(s[0] == 'C') cout << "Rainy" << endl;
    else if(s[0] == 'R') cout << "Sunny" << endl;
}

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

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

  if (K > (A+B)) cout << 2*A + B - K << endl;
  else if (K > A) cout << A << endl;
  else  cout << K << endl;
}


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

struct point {
    double x;
    double y;
};

int main(void) {
    struct point A, B, C, D;
    
    while(cin >> A.x >> A.y >> B.x >> B.y >> C.x >> C.y >> D.x >> D.y) {
        if(A.x - B.x == 0 || C.x - D.x == 0) {
            if((A.x - B.x == C.y - D.y) || (A.y - B.y == C.x - D.x)) {
                cout << "YES" << endl;
            } else {
                cout << "NO" << endl;
            }
        } else {
            double slopeAB = (A.y - B.y) / (A.x - B.x);
            double slopeCD = (C.y - D.y) / (C.x - D.x);
            if(fabs(slopeAB * slopeCD + 1) < 0.0000001) {
                cout << "YES" << endl;
            } else {
                cout << "NO" << endl;
            }
        }
    }
    
    return 0;
}


Measured memory_bytes: 3184
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9+7;
int c[100001];
ll dp[(ll)1e5+1] = {1};
ll pow(ll a, ll b){return (b ? (b % 2 ? a : 1) * pow(a * a % MOD, b / 2) % MOD : 1);}
ll comb(ll n, ll k){return (n < k ? 0 : dp[n] % MOD * pow(dp[n - k] * dp[k] % MOD, MOD - 2) % MOD);}
int main(){
	ll n; cin >> n;
	fill(c, c+n+1, -1);
	for(ll i = 1; i <= n + 1; ++i) dp[i] = i * dp[i - 1] % MOD;
	ll a[n + 1];
	for(ll i = 0; i <= n; ++i)cin >> a[i];
	int L, R;
	for(int i=0; i<n+1; i++){
		if(c[a[i]] != -1){
			L = c[a[i]];
			R = i;
		}else{
			c[a[i]] = i;
		}
	}
	for(ll i = 1; i <= n + 1; ++i) cout << (comb(n + 1, i) - comb(n + 1 - (R - L + 1), i - 1) + MOD) % MOD << endl;
	return 0;
}


Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> ii;
typedef vector<int>   vi;
typedef vector<long long> vll;
typedef vector<pair<int,int> > vii;
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define pq priority_queue
#define sf1(x) scanf("%d",&x)
#define sf2(x,y) scanf("%d %d",&x,&y)
#define sf3(x,y,z) scanf("%d %d %d",&x,&y,&z)
int inf = (1e9) + 7;
int mod = 998244353;


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

	string ans = "";
	for (int i = 0; i < s.size() - 8; ++i)
	{
		ans += s[i];
	}
	
	cout << ans << endl;
}

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

int main(){
  string N;
  cin >> N;
  if( N[0]==N[1] && N[0]==N[2] ){
  cout << "Yes" << endl;
  }
  else if( N[1]==N[2] && N[2]==N[3] ){
  cout << "Yes" << endl;
  }
  else{
  cout << "No" << endl;
  }
}
  

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void _main()
{
    int A, B, X;
    cin >> A >> B >> X;
    if (X >= A && X <= A + B)
    {
        cout << "YES" << endl;
    }
    else
    {
        cout << "NO" << endl;
    }
}


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

using namespace std;

typedef long long ll;

ll A[200001], S[200001];


int main() {
    ll N;
    ll MOD = 1000000007;

    cin >> N;
    for (ll i = 1; i <= N; i++) {
        cin >> A[i];
        A[i] %= MOD;
    }

    S[N] = A[N];
    for (ll i = N - 1; i >= 2; i--) {
        S[i] = (S[i+1] + A[i]) % MOD;
    }
    /*
    for (ll i = 1; i <= N; i++) {
        printf("%ld: %ld, %ld\n", i, A[i], S[i]);
    }
    */
    ll sum = 0;
    for (ll i = 1; i <= N-1; i++) {
        ll tmp = (A[i] * S[i+1]) % MOD;
        sum += tmp;
        //printf("%ld * %ld = %ld, %ld\n", A[i], S[i+1], tmp, sum);
        sum %= MOD;
    }

    cout << sum << endl;
}

Measured memory_bytes: 6724
#include <iostream>
#include <algorithm>
#include <vector>
#include <list>
#include <string>
#include <sstream>
#include <climits>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <cctype>
using namespace std;

typedef long long ll;
int main() {
    string a, b;
    cin>>a;
    cin>>b;
    if (a.length()<b.length()) {
        cout<<"LESS"; return 0;
    }
    else if (a.length()>b.length()) {
        cout<<"GREATER"; return 0;
    }
    else {
        for (int i=0; i<a.length(); ++i) {
            if ((a[i]-'0')>(b[i]-'0')) {
                cout<<"GREATER";
                return 0;
            }
            else if ((a[i]-'0')<(b[i]-'0')) {
                cout<<"LESS";
                return 0;
            }
        }
        cout<<"EQUAL";
    }
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
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 see(vector<vector<int>> &a){
	rep(i,a.size()){
		rep(j,5) cout << a[i][j] << " ";
		cout << endl;
	}
	cout << endl;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	while(true){
		int h;
		cin >> h;
		if(h == 0) break;
		vector<vector<int>> a(h, vector<int>(5, 0));
		rep(i,h)rep(j,5) cin >> a[i][j];
		bool changed = true;
		int ans = 0;
		while(changed){
			//see(a);
			changed = false;
			rep(i,h){
				vector<bool> used(5, false);
				rep(j,3){
					if(a[i][j] == 0) continue;
					if(a[i][j] == a[i][j+1] && a[i][j+1] == a[i][j+2]){
						used[j] = true;
						used[j+1] = true;
						used[j+2] = true;
					}
				}
				rep(j,5){
					if(used[j]){
						ans += a[i][j];
						a[i][j] = 0;
						changed = true;
					}
				}
			}
			rep(j,5){
				for(int i = h-1; i > 0; i--){
					if(a[i][j] == 0){
						int cur = i-1;
						while(cur > 0 && a[cur][j] == 0) cur--;
						a[i][j] = a[cur][j];
						a[cur][j] = 0;
					}
				}
			}
		}
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 3180
var
i,x,s,min:longint;
begin
min:=233;
s:=0;
for i:=1 to 5 do
begin
read(x);
 if (x-1) mod 10+1<min then
 min:=(x-1) mod 10+1;
inc(s,x+9-(x-1) mod 10);
end;
writeln(s-10+min);
end.

Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>
#include <bitset>
#include<stack>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;

template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

template<typename T>
map<T, T> getPrimeFactor(T n) {
	map<T, T> res;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			res[i] ++;
			n /= i;
		}
	}
	if (n != 1) res[n] = 1;
	return res;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	if (num <= 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	return true;
}

long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}


#define in(x) cin >> x
#define out(x) cout << x
#define outn(x) cout << x << '\n'
#define outs(x) cout << x << ' '
#define rep(i,s,e) for(ll i=s;i<e;i++)
#define repeq(i,s,e) for(ll i=s;i<=e;i++)


int main() {
	ll h, a,ans;
	std::cin >> h >> a;
	ans = h / a;
	if (h % a != 0) {
		ans++;
	}
	outn(ans);
	return 0;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
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; }
template<typename T> T gcd(T a,T b){return b?gcd(b,a%b):a;}
const LL mod=1000000007;
const LL LINF=1LL<<62;
const int INF=1<<30;
int dx[]={1,0,-1,0,1,-1,1,-1};
int dy[]={0,1,0,-1,1,-1,-1,1};


int main(){
    int k;cin >> k;
    LL ans = 0;
    for (int a = 1; a <= k; a++) {
        for (int b = 1; b <= k; b++) {
            for (int c = 1; c <= k; c++) {
                ans += gcd(gcd(a,b),c);
            }
        }
    }
    cout << ans << endl;
    return 0;
}



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

using namespace std;


void solve() {
    long long x,y;
    cin >> x >> y;
    int e = 0;
    while (x <= y) {
        x<<=1;
        e++;
    }
    cout << e;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    cout << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0; i<(n); i++)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

int main(){
    ll n; cin>>n;
    ll mod=1e9+7;
    if(n%2==1){
        vector<int> num((n+1)/2);
        rep(i,n){
            int a; cin>>a;
            num[a/2]++;
        }
        bool x=true;
        rep(i,(n+1)/2){
            if(i==0){
                if(num[i]!=1) x=false;
            }else{
                if(num[i]!=2) x=false;
            }
        }
        if(x){
            ll ans=1;
            rep(i,(n-1)/2){ans*=2; ans%=mod;}
            cout<<ans<<endl;
        }else{
            cout<<0<<endl;
        }
    }else{
        vector<int> num(n/2);
        rep(i,n){
            int a; cin>>a;
            num[(a-1)/2]++;
        }
        bool x=true;
        rep(i,n/2){
            if(num[i]!=2) x=false;
        }
        if(x){
            ll ans=1;
            rep(i,n/2){ans=(ans*2)%mod;}
            cout<<ans<<endl;
        }else{
            cout<<0<<endl;
        }
    }
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <iomanip>
#include <map>
#include <set>
#include <tuple>
#include <unordered_map>
#include <iterator>
#include <string>
#include <limits>

using namespace std;

using i64 = int64_t;
using P = pair<i64, i64>;
i64 mod = 1000000007;
int int_max = 2147483647;
int max_n = 1e5;

bool is_runrun(i64 num) {
    i64 prev = -1;
    while(num) {
        int j = num%10;
        num /= 10;
        if (prev == -1) {
            prev = j;
            continue;
        }
        if (abs(j-prev) > 1) return false;
        prev = j;
    }
    return true;
}

i64 make_next_runrun(i64 num) {
    i64 next = num+1;
    if (is_runrun(next)) return next;

    next = make_next_runrun(num/10);
    int next_lsd = next%10;
    if (next_lsd != 0) --next_lsd;
    next = next*10 + next_lsd;

    return next;
}

int main(int argc, char **argv) {
    i64 k;
    cin >> k;

    std::vector<i64> map, map2;
    i64 prev{0};
    map.push_back(0);
    map2.push_back(0);
    for (int i=0; i<100001; ++i) {
        i64 next = make_next_runrun(prev);
        map.push_back(next);
        prev = next;
    }

    cout << map[k] << endl;

    return 0;
}


Measured memory_bytes: 1400
A = int(input())
B = int(input())
C = int(input())
X = int(input())
cnt = 0
for a in range(A+1):
  for b in range(B+1):
    for c in range(C+1):
      if a*500+b*100+c*50 == X:
        cnt += 1
print(cnt)

Measured memory_bytes: 3060
fun main(args: Array<String>) {

    var (a, b) = readLine()!!.split(" ").map { it.toInt() }
    val astr = (1..b).map { a }.joinToString("")
    val bstr = (1..a).map { b }.joinToString("")
    println(
        if (astr < bstr) {
            astr
        } else {
            bstr
        }
    )
}

Measured memory_bytes: 35944
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
int dis[2002];
int main(){
  int n,x,y;
  scanf("%d%d%d",&n,&x,&y);
  for(int i=1;i<n;i++){
    for(int j=i+1;j<=n;j++){
      int cache;
      cache=min(j-i,abs(i-x)+abs(j-y)+1);
      if(cache<n)dis[cache]++;
	}
  }
  for(int i=1;i<n;i++) printf("%d\n",dis[i]);
  return 0;
}


Measured memory_bytes: 128
use std::str::FromStr;
use std::fmt::Debug;

fn read_line<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()
}

fn main() {
    let vec: Vec<i32> = read_line();
    let n = vec[0];
    let mut cnt: i32 = 0;
    for i in 1..n+1 {
        if i.to_string().chars().count() % 2 != 0 {
            cnt += 1 
        };
    };
    println!("{}", cnt);
}

Measured memory_bytes: 4352
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
vector<long long> number(3, 0);
long long mini;
int main() {
	long long int A, B;
	cin >> A >> B;

	if (A + B >= 10) {
		cout << "error" << endl;
	}
	else {
		cout << A + B << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define ld long double
int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }    //最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }     //最小公倍数
using Graph = vector<vector<ll>>;
ll inf=300000000000000000;
const double PI = 3.14159265358979323846;
int main(){
  string s;
  cin >> s;
  ll p=1000000007;
  ll n=s.size();
  ll dp[n+1][13];
  rep(i,n+1)rep(j,13)dp[i][j]=0;
  ll m=13;
  dp[0][0]=1;
  rep(i,n){
    if(s[i]=='?'){
      rep(j,10){
        rep(o,13){
          dp[i+1][(o*10+j)%m]=(dp[i+1][(o*10+j)%m]+dp[i][o])%p;
        }
      }
    }
    else{
      int y=(s[i]-'0');
      rep(o,13){
        dp[i+1][(o*10+y)%m]=(dp[i+1][(o*10+y)%m]+dp[i][o])%p;
      }
    }
  }
  ll ans=dp[n][5];
  cout << ans%p << endl;
} 


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

int forward_match(string s, string t) {
  return s.size() >= t.size() && equal(begin(t), end(t), begin(s));
}

int main() {
  string s;
  string s1 = "maerd";
  string s2 = "remaerd";
  string s3 = "esare";
  string s4 = "resare";
  cin >> s;
  reverse(s.begin(), s.end());
  int solved=0;
  while(!solved) {
    if (forward_match(s, s1)) {
      s.erase(0, 5);
    } else if (forward_match(s, s2)) {
      s.erase(0, 7);
    } else if (forward_match(s, s3)) {
      s.erase(0, 5);
    } else if (forward_match(s, s4)) {
      s.erase(0, 6);
    } else {
      break;
    }
    if (s.size() == 0) {
      solved = 1;
      break;
    }
  }
  if (solved) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  return 0;
}


Measured memory_bytes: 512
import math

def fact(x):
    return math.factorial(x)

N, P = map(int, raw_input().split())
A = map(int, raw_input().split())
ec = sum(map(lambda n: 1 - (n & 1), A))
oc = sum(map(lambda n: (n & 1), A))
ocv = [i for i in range(oc + 1)]
ocv = map(lambda n: fact(oc) / (fact(n) * fact(oc - n)), ocv)
print pow(2, ec) * sum(ocv[P::2])


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

#define FOR(i, l, r) for(size_t i = (l); i < (r); i = i + 1)
#define REP(i, n) FOR(i, 0, n)
using ll = long long;

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

    for(int i = A; i <= B; i++) {
        if(i % K == 0) {
            cout << "OK" << endl;
            return 0;
        }
    }
    cout << "NG" << endl;
    return 0;
}

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

int main(){

    long long n; cin >> n;
    vector<long long> a(n, 0);
    for(int i = 0; i < n; i++){
        cin >> a[i];
        if(i != 0) a[i] += a[i - 1];
    }

    /*for(int i = 0; i < n; i++){
        cout << a[i] << " ";
    }*/

    long long ans;


    //+ から始まる
    long long temp = 0;
    long long sa = 0;
    for(int i = 0; i < n; i++){

        //+
        if(i % 2 == 0){
            if(a[i] + sa > 0){}
            else{
                temp += -(a[i] + sa) + 1;
                sa += -(a[i] + sa) + 1;
            }
        }else{  //-
            if(a[i] + sa < 0){}
            else{
                temp += a[i] + sa + 1;
                sa -= a[i] + sa + 1;
            }
        }
    }
    ans = temp;

    //- から始まる
    temp = 0;
    sa = 0;
    for(int i = 0; i < n; i++){

        //+
        if(i % 2 == 1){
            if(a[i] + sa > 0){}
            else{
                temp += -(a[i] + sa) + 1;
                sa += -(a[i] + sa) + 1;
            }
        }else{  //-
            if(a[i] + sa < 0){}
            else{
                temp += a[i] + sa + 1;
                sa -= a[i] + sa + 1;
            }
        }

    }

    ans = (long long)min(ans, temp);
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1024
fun main(arr:Array<String>) {
    val (w,h,x,y) =  readLine()!!.split(" ").map { it.toLong() }
    val ans = (h*w).toDouble() / 2
    var ans2 = 0
    if(h%2 ==0L && w%2 == 0L && h/2 == y && w/2 == x) {
        ans2 = 1
    }
    println("%s %s".format(ans, ans2))
}




Measured memory_bytes: 37800
#include<bits/stdc++.h>
using namespace std;
#define rep(i ,a, n) for (long long int i=a;i<=n;i++)
#define pb  push_back
#define mp make_pair
#define fp first
#define sp second
#define be(v) v.begin(),v.end()
typedef long long ll;
typedef vector<ll> vi ;
typedef vector<pair<ll , ll > >  vpi ;
const int ma1=3e5+5;
string no="NO",yes="YES";
#define MOD 1000000007
int max_char=26;
ll max1=1e15;
vector<ll> v[100005];
bool visited[100005];
ll dp[100005];

void dfs(int n)
{
    visited[n]=true;
    for(int i=0;i<v[n].size();i++)
    {
        if(visited[v[n][i]]==false)
            dfs(v[n][i]);
        dp[n]=max(dp[n],1+dp[v[n][i]]);
    }

}

int main()
{
      ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll t=1;
    while(t--)
    {
         ll n,m;
         cin>>n>>m;
         memset(visited,false,sizeof(visited));
         for(int i=0;i<m;i++)
         {
             ll x,y;
             cin>>x>>y;
             v[x].push_back(y);
         }
         for(int i=1;i<=n;i++)
         {
             if(!visited[i])
                dfs(i);
         }
         ll ans=0;
         for(int i=1;i<=n;i++)
         {
             ans=max(ans,dp[i]);
         }
         cout<<ans<<endl;
    }
    return 0;
}
















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

using namespace std;

const int MaxN = 200005;
const long long Mod = 1000000007;

int n, h, w;
pair<int, int> a[3005];
long long dp[MaxN];
long long fct[MaxN], ifct[MaxN];

long long Power(long long a, long long b)
{
    long long Resuft = 1;
    while (b)
    {
        if (b & 1)
        {
            Resuft = Resuft * a % Mod;
        }
        b /= 2;
        a = a * a % Mod;
    }
    return Resuft;
}

void Init()
{
    fct[0] = 1;
    for (int i = 1; i < MaxN; i++)
    {
        fct[i] = (fct[i - 1] * i) % Mod;
    }
    ifct[MaxN - 1] = Power(fct[MaxN - 1], Mod - 2);
    for (int i = MaxN - 2; i >= 0; i--)
    {
        ifct[i] = (ifct[i + 1] * (i + 1)) % Mod;
    }
}

long long C(int n, int k)
{
    return (((fct[n] * ifct[k]) % Mod) * ifct[n - k]) % Mod;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    Init();
    cin >> h >> w >> n;
    for (int i = 1; i <= n; i++)
    {
        cin >> a[i].first >> a[i].second;
        a[i].first--;
        a[i].second--;
    }
    n++;
    a[n] = make_pair(h - 1, w - 1);
    sort(a + 1, a + n + 1);
    for (int i = 1; i <= n; i++)
    {
        dp[i] = C(a[i].first + a[i].second, a[i].first);
        for (int j = 1; j < i; j++)
        {
            if (a[j].first <= a[i].first && a[j].second <= a[i].second)
            {
                dp[i] = (dp[i] - dp[j] * C(a[i].first + a[i].second - a[j].first - a[j].second, a[i].first - a[j].first) + Mod * Mod) % Mod;
            }
        }
    }
    cout << dp[n];
    return 0;
}

Measured memory_bytes: 6780
///============================================================================
/// Name        : Faisal.cpp
/// Author      : Faisal Ahmed
/// Version     :
/// Copyright   : Your copyright notice
/// Description : C++, Ansi-style
///============================================================================

#include <bits/stdc++.h>

using namespace std;

typedef long long int ll;
typedef long double ld;

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

	string s, t = "";

	cin >> s;

	int len = s.size();

	for(int i = 0; i < len; i++){

        if(s[i] == 'e'){
            string temp = "";
            for(int j = 0; j < 5 && i < len; j++){
                temp += s[i++];
            }

            if(i < len && s[i] == 'r'){
                temp += s[i++];
            }
            i--;

            if(temp == "erase" || temp == "eraser"){
                t += temp;
            }
            else{
                cout << "NO" << endl;
                return 0;
            }
        }
        else if(s[i] == 'd'){
            string temp = "";
            for(int j = 0; j < 5 && i < len; j++){
                temp += s[i++];
            }

            if(i + 2 < len && s[i + 2] != 'a' && s[i] == 'e' && s[i + 1] == 'r'){
                temp += s[i++], temp += s[i++];
            }
            else if(i + 2 >= len){
                if(i < len){
                    temp += s[i++];
                }
                if(i < len){
                    temp += s[i++];
                }
            }

   ///         cout << "tt = " << temp << endl;

            if(temp == "dream" || temp == "dreamer"){
                t += temp;
            }
            else{
                cout << "NO" << endl;
                return 0;
            }

            i--;
        }
	}

///	cout << "t = " << t << endl;

	if(s == t){
        cout << "YES" << endl;
	}
	else{
        cout << "NO" << endl;
	}

	return 0;
}



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

#define int long long
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define SORT(x) sort(x.begin(), x.end())
#define RS(x) rsort(x.begin(),x,end()))
#define REVE(x) reverse(x.begin(), x.end())
#define ALL(x) (x).begin(), (x).end()
#define pb push_back
#define pob pop_back
#define vint(v,n) vector<int> v(n); REP(i,n) scanf("%d", &v[i]);
int INF = 1e9 + 1;
int MOD = 1e9+7;
struct initon
{
    initon()
    {
        cin.tie(0);
        ios::sync_with_stdio(false);
    };
};
unsigned GetDigit(unsigned num){
    return log10(num)+1;
}

signed main(){
 int a,b,ans;
cin >> a >> b;
if(a==1){
  if(b==2){
   cout << "3";
  }else if(b==3){
  cout << "2";
  }
}else if(a==2){
     if(b==1){
        cout << "3";
     }else{
        cout << "1";
     }
  }else{
   if(b==1){
   cout << "2";
   }else{
   cout << "1";
   }
}
 
             }



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

s = []
c = []
for i in range(M):
    _s, _c = input().split(' ')
    s.append(int(_s)-1)
    c.append(_c)

first = (0 if N==1 else 10**(N-1))
lst = list(range(first, (10 ** N)))

ans = []
for num in lst:
    ok = True
    s_num = str(num)
    for i in range(M):
        if (s_num[s[i]] != c[i]):
            ok = False
            break
    if (ok):
        ans.append(num)

print (min(ans) if len(ans)>0 else -1)


Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<utility>
#include<cmath>
#include<string>
#include<cstring>
#include<map>
#include<queue>
#include<set>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define prin(arg) std::cout<<arg<<"\n"
#define prin2(arg1,arg2) std::cout<<arg1<<" "<<arg2<<"\n"
#define fill(arg,n) std::memset(arg,n,sizeof(arg))
#define mp(a,b) std::make_pair(a,b)
#define pb push_back
using std::cin;
typedef long long ll;
typedef std::pair<int,int> pi;
typedef std::vector<int> vi;
typedef std::set<int> si;
typedef std::string str;
const int INF=1e+9;
const ll INFLL=1e+17;
const ll MOD=1e+9+7;
str X;
int main(){
  cin>>X;
  int xs=X.size();
  int cnt=0;
  rep(i,xs){
    if(X[i]=='S') cnt++;
    else if(cnt!=0) cnt--;
  }
  prin(cnt*2);
  return 0;
}


Measured memory_bytes: 640
#![allow(non_snake_case)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!(
        n: usize,
        bn: [u64; n-1],
    );
    // println!("n:{}", n);
    let mut an = vec![std::u64::MAX; n];
    for i in 0..(n-1) {
        // println!("{}", i);
        let bi = bn[i];
        if bi < an[i] {
            an[i] = bi;
        }
        if bi < an[i+1] {
            an[i+1] = bi;
        }
    }
    let sum: u64 = an.iter().fold(0, |sum, a| sum + a);
    println!("{}", sum);
}


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

int main(){
    int N;
    double A[110];
    double sum=0, ans;

    cin >> N;
    for(int i=0; i<N; i++){
        cin >> A[i];
        sum += 1.0/A[i];
    }
    ans = 1.0/sum;

    cout << fixed << setprecision(10) << ans << endl;

    return 0;
}

Measured memory_bytes: 256
N, K = map(int, input().split())


def f(x): return x + x * (x - 1) * 3 + x * (x - 1) * (x - 2)


if K % 2 == 0:
    a = N // K
    b = N // (K // 2) - a
    ans = f(a) + f(b)
else:
    ans = f((2 * N) // (K * 2))
print(ans)


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

const int MAX = 1e5+20;
set<int> primes;

void sieve() {
    bitset<MAX> bs;
    for(int i=2;i*i<MAX;i++) {
        if(!bs[i]) {
            primes.insert(i);
            for(int j=2*i;j<MAX;j+=i) {
                bs.set(j);
            }
        }
    }

    for(int i=2;i<MAX;i++) {
        if(!bs[i]) primes.insert(i);
    }
}

int32_t main() {

    sieve();

    int a,b;
    cin>>a>>b;

    int freq1[MAX]={};
    int freq2[MAX]={};

    for(auto e : primes) {
        if(a==1) {
            break;
        }

        while(a%e==0) {
            freq1[e]++;
            a/=e;
        }
    }

    for(auto e : primes) {
        if(b==1) {
            break;
        }

        while(b%e==0) {
            freq2[e]++;
            b/=e;
        }
    }

    int ans=1;
    for(int i=1;i<MAX;i++) {
        int x = max(freq2[i],freq1[i]);
        while(x--) {
            ans*=i;
        }
    }

    cout<<ans<<'\n';

    return 0;
}


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

int main() {
  int A, B, i,cnt;
  cin >> A >> B;
  cnt = 0;
  for(i=A; i<=B; i++){
    if(i/10000 == i%10 && (i % 10000) / 1000 == (((i % 10000) % 1000) % 100) / 10)
      cnt++;
  }
  cout << cnt << endl;
}

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

int ascSort(const void* v1, const void* v2) {
    const int _v1 = *((const int*)v1);
    const int _v2 = *((const int*)v2);
 
    if ( _v1 > _v2 ) {
        return 1;
    } else if ( _v1 < _v2 ) {
        return -1;
    } else {
        return 0;
    }
}


int main()
{
  	int N;
   scanf("%d", &N);
  int i=0;
  int a[N];
  for(i=0;i<N;i++){
    scanf("%d", &a[i]);
  }
  
  qsort(a, N, sizeof(a[0]), ascSort);
    for(int j = 0; j < N; j++) {
        if(a[j] == a[j+1]){
			printf("NO");
          return 0;
        }
    }  
  
    // 出力
    //printf("%s",s);//printf("%c",s[0])//文字一つ分のみを出力
	printf("YES");
    return 0;
}

Measured memory_bytes: 1788