akhauriyash/Code-Regression huggingface dataset:
#include <iostream>

using namespace std;

int main() {
	int n;
	int *S;
	int q;
	int *T;
	cin >> n;
	//S = new int[n];
	S = new int[n+1];
	for (int i = 0; i < n; ++i) {
		cin >> S[i];
	}

	cin >> q;
	T = new int[q];
	for (int i = 0; i < q; ++i) {
		cin >> T[i];
	}

	int count = 0;
	//for (int i = 0; i < q; ++i) {
	//	for (int j = 0; j < n; ++j) {
	//		if (S[j] == T[i]) {
	//			++count;
	//			break;
	//		}
	//	}
	//}
	for (int i = 0; i < q; ++i) {
		S[n] = T[i];
		int j = -1;
		while (S[++j] != T[i]) {
			;
		}
		if (j != n) {
			++count;
		}
	}

	cout << count << endl;

	return 0;
}

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

#if MYDEBUG
#include "lib/cp_debug.hpp"
#else
#define DBG(...) ;
#endif
#if __cplusplus <= 201402L
template <typename T>
T gcd(T a, T b) { return ((a % b == 0) ? b : gcd(b, a % b)); }
template <typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }
#endif
using LL = long long;
constexpr LL LINF = 334ll << 53;
constexpr int INF = 15 << 26;
constexpr LL MOD = 1E9 + 7;

namespace Problem {
using namespace std;

class Solver {
 public:
  void solve() {
    set<string> S;
    string s = "";
    for (int i = 0; i < 5; ++i) {
      s += "hi";
      S.insert(s);
    }
    string sin;
    cin >> sin;
    if (S.count(sin)) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  }
};
class Solver2 {
 public:
  int n, m;
  Solver2(LL n, LL m) : n(n), m(m){};

  void solve() {
  }
};
}  // namespace Problem

int main() {
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(false);
  // std::cout << std::fixed << std::setprecision(12);

  Problem::Solver sol;
  sol.solve();
  return 0;
}


Measured memory_bytes: 256
n, m = gets.chomp.split.map(&:to_i)
x = gets.chomp.split.map(&:to_i)

if n >= m
  p 0
  exit
end

x.sort!

l = []
(m-1).times do |i|
  l[i] = x[i+1] - x[i]
end

l.sort!

k = m - n

ans = 0
k.times do |i|
  ans += l[i]
end
p ans


Measured memory_bytes: 10480
#include<string>
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define RREP(i, n) for(ll i = (ll)(n-1); i >= 0; i--)
#define ALL(vector) vector.begin(), vector.end()

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, M, K;
    cin >> N >> M >> K;
    vector<ll> A(N,-1);
    vector<ll> B(M,-1);
    REP(i,N){
        cin >> A[i];
    }
    REP(i,M){
        cin >> B[i];
    }
    vector<ll> sumA(N+1, -1);
    vector<ll> sumB(M+1, -1);
    vector<ll> cand(N+1, 0);
    sumA[0] = 0;
    REP(i,N){
        sumA[i+1] = sumA[i] + A[i];
    }
    sumB[0]=0;
    REP(i,M){
        sumB[i+1] = sumB[i] + B[i];
    }
    ll j = 0;
    RREP(i,N+1){
        if(sumA[i]>K) continue;
        while(true){
            if(j+1>=M+1) break;
            if(sumA[i]+sumB[j+1]>K) break;
            j++;
        }
        cand[i] = i+j;
    }
    // for(auto x: cand){
    //     cout<<x<<endl;
    // }
    cout << *max_element( ALL(cand) ) << endl;
    return 0;
}

Measured memory_bytes: 11112
#include <stdio.h>
int main(){
    int i,j,n,a[100],tmp,counter;
    while(1){
        scanf("%d",&n);
        if(n == 0){
            break;
        }
        counter=0;
        for(i=0;i<n;i++){
            scanf("%d",&a[i]);
        }
        for(i=0;i<n-1;i++){
            for(j=n-1;j>i;j--){
                if(a[j] < a[j-1]){
                    tmp=a[j];
                    a[j]=a[j-1];
                    a[j-1]=tmp;
                    counter++;
                }
            }
        }
        printf("%d\n",counter);
    }
    return (0);
}

Measured memory_bytes: 600
#include "bits/stdc++.h"
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define mFOR(i, a, b) for (int i = a; i > b; i--)
#define MP make_pair
#define PB push_back
#define N 107
#define INF 1000000000
using namespace std;

typedef long long ll;

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

int main()
{
    int n, h[N] = {};
    cin >> n;
    FOR(i, 1, n + 1)
    {
        cin >> h[i];
    }

    int ctr = 1;
    bool flag;
    FOR(i, 1, n + 1)
    {
        FOR(j, 1, i)
        {
            if(h[j]>h[i])
                break;
            if(j==i-1)
                ctr++;
        }
    }
    cout << ctr << endl;
    return 0;
}

Measured memory_bytes: 384
#include <stdio.h>

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

if(a<b){
printf("a < b\n");
}
else if(a>b){
printf("a > b\n");
}
else{
printf("a == b\n");
}
return 0;
}

Measured memory_bytes: 1780
#include <bits/stdc++.h>
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define showvp(p) rep(i,p.size()) printf("%d %d\n", p[i].first, p[i].second);
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define incl(v,x) find(rng(v),x)!=v.end()
#define incls(s,c) s.find(c)!=string::npos
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define bit(n,k) ((n>>k)&1) // nのk bit目
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vs = vector<string>;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using vp = vector<P>;
using vt = vector<T>;
const int mod = 1000000007;
const double EPS = 1e-9;
//const long double EPS = 1e-14;
const int INF = (1<<30)-1;
const ll LINF = (1LL<<62)-1;
#define dame { puts("No"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
inline int in() { int x; scanf("%d",&x); return x;}
inline ll lin() { ll x; scanf("%lld",&x); return x;}
inline char chin() { char x; scanf("%c",&x); return x;}
inline string stin() { string x; cin >> x; return x;}
inline double din() { double x; scanf("%lf",&x); return x;}
//template<class T = int> inline T in() { T x; cin >> x; return (x);}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
char itoa(int n) { return n + '0';}
ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main () {
  ll x = lin();
  for (ll a = -118; a <= 119; ++a) {
    for (ll b = -119; b <= 118; ++b) {
      if (a*a*a*a*a - b*b*b*b*b == x) {
        cout << a SP b << endl;
        return 0;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 3736
#include <bits/stdc++.h>    //vectorを使う
using namespace std;


int main(void){
    int a,b;
    cin >> a >> b;
    
    int mx=max(a,b);
    int mn=min(a,b);
    if(mx-mn>=1){
        cout << 2*mx-1 << endl;
    }else{
        cout << 2*mx << endl;
    }
}

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

int main(){
	int n;
	cin >> n;
	int u, L, k[n][n], a;
	for(int i = 0; i < n; i++){
		for(int j = 0; j < n; j++){
			k[i][j] = 0;
		}
	}
	
	for(int i = 0; i < n; i++){
		cin >> a;
		cin >> u;
		for(int j = 0; j < u; j++){
			cin >> L;
			k[a-1][L-1] = 1;
		}
	}
	
	for(int i = 0; i < n; i++){
		for(int j = 0; j < n; j++){
                        if(j)cout << " ";
			 cout << k[i][j];
		}
		cout << endl;
	}
}


Measured memory_bytes: 3136
import sys
x=50000
sys.setrecursionlimit(x)

n=int(input())
arr = list(map(float,input().split()))
dp = [[-1]*(3001) for i in range(3001)]

def func(n,x):
    if x==0:
        return 1
    if dp[n][x]>-0.9:
        return dp[n][x]  
    if n==0:
        return 0
    
    dp[n][x] = (arr[n-1])*func(n-1,x-1) + (1-arr[n-1])*func(n-1,x)
    return dp[n][x]

print("%0.10f"%func(n,(n+1)//2))


Measured memory_bytes: 247472
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
int n, m, p[11];
vector<int> X[12];
int main()
{
    cin >> n >> m;
    rep(i, 0, m)
    {
        int k;
        cin >> k;
        rep(j, 0, k)
        {
            int a;
            cin >> a;
            a--;
            X[i].push_back(a);
        }
    }
    rep(i, 0, m)
    {
        cin >> p[i];
    }
    ll cnt = 0;
    for (int i = 0; i < (1 << n); i++)
    {
        bool ans = true;
        for (int j = 0; j < m; j++)
        {
            int con = 0;
            for (auto v : X[j])
            {
                // cout << "i: " << i << " v: " << (1 << v) << " con: " << (i & (1 << v)) << endl;
                //ビットiではv番目のスイッチがonであるか
                if (i & (1 << v))
                    con++;
            }
            if (con % 2 != p[j])
            {
                ans = false;
            }
        }
        if (ans)
        {
            cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}


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

typedef long long ll;
#define PI 2 * acos (0.0)

int main()
{
  ll n, val ;
  string s ;
  char x = 'A' ;
  cin >> n >> s ;
  n %= 26 ;

  for(int i = 0; i < s.size(); i++) {
    if(s[i] + n > 'Z') {
      val = s[i] - 'Z' + n - 1;
      s[i] = x + val ;
    }
    else  s[i] += n ;
  }
  cout << s << endl ;
}


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

#include <math.h>
#include <stdlib.h>


#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

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

// const int INF = 1001001001;
// long long max => LLONG_MAX

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    int w, a, b; cin >> w >> a >> b;
    if(a > b) swap(a,b);

    cout << max(0, b-a-w) << endl;

    return 0;
}


Measured memory_bytes: 256
n, m = map(int, input().split())
a = [list(input()) for _ in range(n)]
b = [list(input()) for _ in range(m)]
for i in range(n - m + 1):
    for j in range(n - m + 1):
        bb = True
        for k in range(i, i + m):
            for l in range(j, j + m):
                if a[k][l] != b[k-i][l-j]:
                    bb = False
        if bb:
            print("Yes")
            exit()
print("No")


Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <random>

using namespace std;

#define int long long

const int INF = 100000000000000239;

int safe_mul(int a, int b) {
    a = min(a, INF);
    b = min(b, INF);
    if (a >= (INF) / b) return INF;
    else return min(INF, a * b);
}
 
int safe_add(int a, int b) {
    a = min(a, INF);
    b = min(b, INF);
    return min(INF, a + b);
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);


    int n, add;
    cin >> n >> add;
    vector<int> a(n);
    for (auto &t : a) {
        cin >> t;
    }
    reverse(a.begin(), a.end());
    vector<int> psum(n + 1);
    for (int i = 0; i < n; i++) {
        psum[i + 1] = a[i] + psum[i];
    }
    int ans = INF;
    for (int cnt = 1; cnt <= n; cnt++) {
        int lol = (n + cnt) * add;
        int grlen = cnt;
        int pnt = 0;
        int num = 0;
        for (; pnt < n; num++) {
            int rl = (grlen);
            int val = (3 + 2 * (num));
            if (!num) val += 2;
            int sm = psum[min(n, pnt + rl)] - psum[pnt];
            lol = safe_add(lol, safe_mul(val, sm));
            pnt += rl;
        }
        ans = min(ans, lol);
    }
    cout << ans << endl;
}   


Measured memory_bytes: 3456
import java.lang.Math.*

const val MOD = 1000000007L

fun main(args: Array<String>) {
    val s = readList().first()
    val ans = Array(s.length) {
        return@Array 0
    }

    val mem = mutableListOf<Int>()
    s.forEachIndexed { index, c ->
        if (c == 'R') {
            mem.add(index)
        } else {
            mem.forEach { memIndex ->
                if ((index - memIndex) % 2 == 0) {
                    ans[index] += 1
                } else {
                    ans[index - 1] += 1
                }
            }
            mem.clear()
        }
    }
    s.reversed().forEachIndexed { index, c ->
        if (c == 'L') {
            mem.add(index)
        } else {
            mem.forEach { memIndex ->
                if ((index - memIndex) % 2 == 0) {
                    ans[s.length - index - 1] += 1
                } else {
                    ans[s.length - (index - 1) - 1] += 1
                }
            }
            mem.clear()
        }
    }

    ans.forEach {
        print(it)
        print(" ")
    }

}


fun readList() = readLine()!!.split(' ')
fun readInt() = readLine()!!.split(' ').map(String::toInt).first()
fun readIntList() = readList().map(String::toInt)
fun readLongList() = readList().map(String::toLong)
fun readDoubleList() = readList().map(String::toDouble)

fun readPair(): Pair<String, String> {
    val splite = readLine()!!.split(' ')
    return Pair(splite[0], splite[1])
}

fun <T> List<T>.copy() = this.map { it }

// 速度のためforEachは避ける
inline fun Int.rep(start: Int = 0, body: (Int) -> Unit) {
    for (i in start until this + start) {
        body(i)
    }
}

inline fun Long.rep(start: Long = 0, body: (Long) -> Unit) {
    for (i in start until this + start) {
        body(i)
    }
}

// 約数のList
fun divisor(value: Long): List<Long> {
    val max = sqrt(value.toDouble()).toLong()
    return (1..max)
        .filter { value % it == 0L }
        .map { listOf(it, value / it) }
        .flatten()
        .sorted()
}

// 範囲内の素数を取得
// fromだけ指定すると戻り値の個数で素数判定ができる
fun prime(from: Long, to: Long = from): List<Long> {
    return (from..to).filter { i ->
        val max = Math.sqrt(i.toDouble()).toLong()
        (2..max).all { j -> i % j != 0L }
    }
}

// 素因数分解
fun decom(value: Long): List<Long> {
    if (value == 1L) return listOf(1)
    val max = Math.sqrt(value.toDouble()).toLong()
    return prime(2, max).filter { value % it == 0L }
}

// 最大公約数
fun gcd(a: Long, b: Long): Long {
    return if (a % b == 0L) b else gcd(b, a % b)
}

// 文字列を入れ替え
fun swap(base: String, a: String, b: String): String {
    return base.map {
        when (it) {
            a.toCharArray()[0] -> b
            b.toCharArray()[0] -> a
            else -> it.toString()
        }
    }.joinToString()
}

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

#define fastIO                      \
  ios_base::sync_with_stdio(false); \
  cin.tie(NULL)
#define here cout << "here\n" // debug
#define int long long int
#define pb push_back
#define mp make_pair
#define pi pair<int, int>
#define sl(x) cin >> x
#define pfl(x) printf("%lld\n", x)
#define pf printf //debug
#define mod 1000000007
#define modu(x) x % 1000000007
#define isEqualf(a, b) (abs(a - b) < 1e-9) // comapre 2 float nums
#define inputVec(v, n)        \
  for (int i = 0; i < n; i++) \
  {                           \
    int d;                    \
    sl(d);                    \
    v[i] = d;                 \
  }

int32_t main()
{
  fastIO;

  int a;
  sl(a);
  string s;
  cin >> s;
  if (a < 3200)
    pf("red\n");
  else
    pf("%s\n", s.c_str());
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef int64_t ll;
struct Solution {
    void solve(std::istream& in, std::ostream& out) {
        ll n, a, b;
        in >> n >> a >> b;
        out << ((a - b) % 2 ? "Borys" : "Alice") << '\n';
    }
};
void solve(std::istream& in, std::ostream& out) {
    out << std::setprecision(12);
    Solution solution;
    solution.solve(in, out);
}
#include <fstream>
#include <iostream>
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    istream& in = cin;
    ostream& out = cout;
    solve(in, out);
    return 0;
}


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

using namespace std;

int calc(long long v) {
  int k = 1;
  while (v >= 10) {
    v /= 10;
    k++;
  }
  return k;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long n; cin >> n;
  int ans = 1e9;
  for (long long i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      long long v = n / i;
      ans = min(ans, max(calc(i), calc(v)));
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1e9 + 7, MOD = 1e9 + 7;
const long long LINF = 1e18;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
signed main() {
	int n;
	cin >> n;
	pair<int, int> P[n + 1];
	int ans[n] = {};
	for (int i = 0; i < n; i++) {
		int x;
		cin >> x;
		P[i] = make_pair(x, i);
	}
	sort(P, P + n);
	reverse(P, P + n);
	int Cmp = INF, Pos;
	P[n].first = 0;
	for (int i = 0; i < n; i++) {
		Cmp = min(Cmp, P[i].second);
		Pos = P[i].first - P[i + 1].first;
		ans[Cmp] += (i + 1) * Pos;
	}
	for (int i = 0; i < n; i++) {
		cout << ans[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 3456
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<functional>
#include<math.h>
using namespace std;
#define N (1000000000+7)
#define INF 1e16
typedef long long ll;
typedef pair<ll,ll> P;
 

ll dp[(1LL<<16)-1][16];
ll n,e;
ll d[20][20];

ll rec(ll S,ll v){
    if(dp[S][v]>=0)return dp[S][v];
    if((S==(1<<n)-1)&& v==0){
        return dp[S][v]=0;
    }
    ll ans = (ll)INF;
    for(ll u=0;u<n;u++){
        if(!((S>>u)&1)){
            ans = min(ans,rec(S|(1<<u),u)+d[v][u]);
        }
    }
    return dp[S][v]=ans;
}

int main(void){
    for(ll i=0;i<20;i++){
        for(ll j=0;j<20;j++){
            d[i][j]=(ll)INF;
        }
    }
    cin>>n>>e;
    for(ll i=0;i<(1<<n);i++){
        for(ll j=0;j<=n;j++){
            dp[i][j]=-1;
        }
    }
    for(ll i=0;i<e;i++){
        ll s,t,di;
        cin>>s>>t>>di;
        d[s][t]=di;
    }
    dp[0][0] = rec(0,0);
    if(dp[0][0]==(ll)INF)cout<<-1<<endl;
    else cout<<dp[0][0]<<endl;;
    return 0;
}




Measured memory_bytes: 7208
n = int(input())
A = []
D = []
for i in range(n):
  a = int(input())
  A.append(a)
  l = []
  for j in range(a):
    k = list(map(int, input().split()))
    l.append(k)
  D.append(l)
  
def jud(s):
  fl = True
  for i in range(n):
    if s[i] == "1":
      for item in D[i]:
        if int(s[item[0]-1]) != item[1]:
          fl = False
  if fl:
    return s.count("1")
  else:
    return 0

cans = 0
  
for i in range(2**n):
  s = bin(i)
  s = s[2:]
  s = "0000000000000000" + s
  s = s[-n:]
  cans = max(cans,jud(s))
print(cans)

Measured memory_bytes: 3064
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
using namespace std;
int main()
{
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    if(a+b==c+d) cout<<"Balanced"<<endl;
    else if(a+b<c+d) cout<<"Right"<<endl;
    else cout<<"Left"<<endl;
    return 0;
}


Measured memory_bytes: 256
import numpy as np
N = int(input())
l = list(map(int, input().split()))
l.sort()
L = np.array(l)
flag = False
if N%2==1:
    if np.all(L-np.arange(N)-np.array([0]+[1,0]*(N//2))==0):
        flag = True
    else:
        print(0)
else:
    if np.all(L-np.arange(N)-np.array([1,0]*(N//2))==0):
        flag = True
    else:
        print(0)
if flag:
    a=1
    for i in range(N//2):
        a = (a*2)%(10**9+7)
    print(a)

Measured memory_bytes: 23444
//In the Name of God
//Ya Ali

#include<bits/stdc++.h>

#define int long long

#define pb push_back

#define err(A) cout<<#A<<" = "<<(A)<<endl

using namespace std;

const int M=1e9+7;
const int maxn=100100;

int n;

int a[maxn];

vector<int> g[maxn];

bool vis[maxn];

int cnt[maxn];

int dp[maxn];

int ans=1;

void gn()
{
  cout<<ans<<endl;
  exit(0);
}

int len(int v)
{
  int ret=1;
  int c=0;
  vis[v]=true;
  for(int u:g[v])
    if(!vis[u])
      {
	c++;
	ret+=len(u);
      }
  if(c>1)
    ans=0;
  return ret;
}

void solve(int v)
{
  vector<int> q,p;
  while(!vis[v])
    {
      vis[v]=true;
      q.pb(v);
      v=a[v];
    }
  for(int u:q)
    vis[u]=false;
  q.resize(0);
  while(!vis[v])
    {
      vis[v]=true;
      q.pb(v);
      v=a[v];
    }
  p.resize(q.size());
  int prv=-1;
  for(int i=0;i<q.size();i++)
    if(g[q[i]].size()==2)
      prv=i;
  if(prv==-1)
    {
      cnt[q.size()]++;
      return;
    }
  for(int i=0;i<q.size();i++)
    {
      p[i]=prv;
      if(g[q[i]].size()==2)
	{
	  int l1=len(q[i])-1;
	  int l2=(i-prv+q.size())%q.size();
	  if(l2==0) l2=q.size();
	  if(l1>l2)
	    ans=0;
	  if(l1<l2)
	    ans=ans*2%M;
	  prv=i;
	}
    }
}

int32_t main()
{
  ios::sync_with_stdio(0);cin.tie(0);
  
  cin>>n;

  for(int i=0;i<n;i++)
    cin>>a[i],a[i]--;
  
  for(int i=0;i<n;i++)
    g[a[i]].pb(i);

  for(int i=0;i<n;i++)
    if(g[i].size()>2)
      ans=0,gn();

  for(int i=0;i<n;i++)
    if(!vis[i])
      solve(i);
  
  for(int i=1;i<=n;i++)
    {
      dp[0]=1;  
      dp[1]=1+(i>2 and i&1);
      for(int j=2;j<=cnt[i];j++)
	dp[j]=(dp[j-1]*dp[1]+dp[j-2]*(j-1)*i)%M;
      ans=ans*dp[cnt[i]]%M;
    }
  
  gn();
  
  return 0;
}


Measured memory_bytes: 9972
A, B, K = map(int, input().split())
for i in range(K):
    if i % 2 == 0: 
        if A % 2 == 1:
            A -= 1
        temp1 = int(A / 2)
        A = A - temp1
        B = B + temp1
    else:
        if B % 2 == 1:
            B -= 1
        temp2 = int(B / 2)
        A = A + temp2
        B = B - temp2
print(A, B)

Measured memory_bytes: 3060
n = int(input())
divide = 10 ** 9 + 7

a = [format(i, '060b') for i in map(int, input().split())]
ans = []

for i in range(60):
    bit_list = [b[59-i] for b in a]
    val = bit_list.count('0') * bit_list.count('1')
    ans.append((val * 2 ** i))

print(sum(ans)%divide)

Measured memory_bytes: 65708
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using vpii = vector<pair<int, int>>;
using vpll = vector<pair<ll, ll>>;

int		main(void)
{
	int N;

	cin >> N;
	vector<int> E(N);
	vpii D(N);

	for (int i = 0; i < N; i++)
	{
		int A;

		cin >> A;
		E[i] = A - 1;
	}
	for (int i = 0; i < N; i++)
	{
		cin >> D[i].first;
	}
	for (int i = 0; i < N - 1; i++)
	{
		cin >> D[i].second;
	}
	int ans = 0;
	int bf;

	for (int i = 0; i < N; i++)
	{
		if(i != 0 && bf == E[i] - 1)
			ans += D[bf].second;
		ans += D[E[i]].first;
		bf = E[i];
	}
	cout << ans << endl;
}



Measured memory_bytes: 256
a,b,c,d=map(int,input().split())
def gcd(a, b):
	while b:
		a, b = b, a % b
	return a
p=c*d//gcd(c,d)

x = (a-1) - ((a-1)//c + (a-1)//d - (a-1)//p)
y = b - (b//c + b//d - b//p)


print(y-x)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)n; ++i)
#define all(obj) (obj).begin(), (obj).end()
static const int dx[4] = {0, 1, 0, -1};
static const int dy[4] = {1, 0, -1, 0};
static const char dir[4] = {'u', 'r', 'd', 'l'};
static const ll INF = 1 << 21;
static const ll MOD = 1e9 + 7;
ll N, A, B, C, D;

signed main() {
  cin >> N >> A >> B >> C >> D;

  // 初期値を0とする
  B -= A;
  A -= A;

  // x回の操作で正に足すと値は[Cx, Dx]の範囲と成る
  // x回の操作で負に足すと値は[D(N-x-1), C(N-x-1)]の範囲となる
  rep(i, N) {
    ll rest = N - (i + 1);
    // [small1, large1]
    ll small1 = C * i;
    ll large1 = D * i;
    // [small2, large2]
    ll small2 = C * rest;
    ll large2 = D * rest;
    if (small1 - large2 <= B && B <= large1 - small2) {
      puts("YES");
      return 0;
    }
  }
  puts("NO");
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main() {
  int a, b, c;
  scanf("%d %d %d", &a, &b, &c);
  if( a==b){
    printf("%d\n",c);
  }
   else if( a==c){
    printf("%d\n",b);
  } 
   else if( b==c){
    printf("%d\n",a);
   }




  return 0;
}

Measured memory_bytes: 128
X = sorted(list(map(int, input().split())))

if X[0] % 2 == X[1] % 2 == X[2] % 2:
    print((X[2] - X[0]) // 2 + (X[2] - X[1]) // 2)
elif X[0] % 2 == X[1] % 2:
    print((X[2] - X[0]) // 2 + (X[2] - X[1]) // 2 + 1)
else:
    print((X[2] - X[0]) // 2 + (X[2] - X[1]) // 2 + 2)


Measured memory_bytes: 3064
#include <iostream>

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

int main()
{
  int n;
  cin >> n;
  long long sum = 1;
  for(int i = 1; i <= n; i++) {
    sum *= i;
    sum = sum % 1000000007;
  }
  cout << sum << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = int64_t;
int main(){
    ll H, W;
    cin >> H >> W;
    ll po[26] = {};
    for(ll i = 0; i < H; i++) for(ll j = 0; j < W; j++){
        char c;
        cin >> c;
        po[c - 'a']++;
    }
    ll yo = 0, sina = 0;
    for(ll i = 0; i < 26; i++){
        yo += po[i] / 4;
        sina += po[i] % 4 / 2;
    }
    if(yo >= (H / 2) * (W / 2)){
        sina += 2 * (yo - (H / 2) * (W / 2));
        if(sina >= ((H & 1 ? W / 2 : 0) + (W & 1 ? H / 2 : 0))){
            cout << "Yes\n";
            return 0;
        }
    }
    cout << "No\n";
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

int main(){
	int n,k,p;
	cin>>n;
	rep(z,n){
		cin>>k>>p;
		k%=p;
		if(k==0)cout<<p<<endl;
		else cout<<k<<endl;
	}
	return 0;
}

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

long long gcd(long long a, long long b){
  if(b==0)return a;
  else return gcd(b,a%b);
}

int main() {
  ll n,a,b,c,d,k=1;
  cin >> n>>a>>b;
  if(n==2){
    d=gcd(a,b);
    while(d>=k){
      if(d%k==0)cout<<k<<endl;
      k++;
    }
  }
    else {
      cin>>c;
      d=gcd(gcd(a,b),c);
      while(d>=k){
        if(d%k==0)cout<<k<<endl;
        k++;
      }
    }
}


Measured memory_bytes: 3120
#include <iostream>

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

int main() {

    int N; std::cin >> N;
    int initial; std::cin >> initial;
    int initial2; std::cin >> initial2;
    int ans = gcd(initial, initial2);
    for (int i = 2; i < N; ++i) {
        int A; std::cin >> A;
        ans = gcd(ans, A);
    }
    std::cout << ans << std::endl;
}


Measured memory_bytes: 256
import sys

CharToSign = {
    "A": "00000", "B": "00001", "C": "00010", "D": "00011",
    "E": "00100", "F": "00101", "G": "00110", "H": "00111",
    "I": "01000", "J": "01001", "K": "01010", "L": "01011",
    "M": "01100", "N": "01101", "O": "01110", "P": "01111",
    "Q": "10000", "R": "10001", "S": "10010", "T": "10011",
    "U": "10100", "V": "10101", "W": "10110", "X": "10111",
    "Y": "11000", "Z": "11001", " ": "11010", ".": "11011",
    ",": "11100", "-": "11101", "'": "11110", "?": "11111",
}
SignToChar = {
    "101": " ", "000000": "'", "000011": ",", "10010001": "-",
    "010001": ".", "000001": "?", "100101": "A", "10011010": "B",
    "0101": "C", "0001": "D", "110": "E", "01001": "F",
    "10011011": "G", "010000": "H", "0111": "I", "10011000": "J",
    "0110": "K", "00100": "L", "10011001": "M", "10011110": "N",
    "00101": "O", "111": "P", "10011111": "Q", "1000": "R",
    "00110": "S", "00111": "T", "10011100": "U", "10011101": "V",
    "000010": "W", "10010010": "X", "10010011": "Y", "10010000": "Z",
}

for line in sys.stdin:
    line = line[:-1]

    sign = []
    for char in line:
        convert = CharToSign[char]
        sign.append(convert)

    sign = "".join(sign)

    startIndex = 0
    endIndex = 3

    string = []

    length = len(sign)
    while endIndex <= length:

        part = sign[startIndex:endIndex]
        if part in SignToChar:
            convert = SignToChar[part]
            string.append(convert)
            startIndex = endIndex
            endIndex += 3
        else:
            endIndex += 1

    string = "".join(string)
    print(string)



Measured memory_bytes: 5608
n = int(input())
a = list(map(int,input().split()))
def f(i):
    n = 0
    while True:
        if i%2==0:
            i//=2
            n+=1
        else:
            break
    return n
ans = 10**9
for a_ in a:
    ans = min(ans,f(a_))
print(ans)

Measured memory_bytes: 3060
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] sa = br.readLine().split(" ");
		int n = Integer.parseInt(sa[0]);
		int k = Integer.parseInt(sa[1]);
		int q = Integer.parseInt(sa[2]);
		sa = br.readLine().split(" ");
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = Integer.parseInt(sa[i]);
		}
		br.close();

		int ans = Integer.MAX_VALUE;
		for (int x = 0; x < n; x++) {
			int min = a[x];
			List<Integer> list = new ArrayList<>();
			List<Integer> list2 = new ArrayList<>();
			for (int i = 0; i < n; i++) {
				if (a[i] >= min) {
					list.add(a[i]);
				} else {
					if (list.size() - k + 1 > 0) {
						Collections.sort(list);
						for (int j = 0; j < list.size() - k + 1; j++) {
							list2.add(list.get(j));
						}
					}
					list.clear();
				}
			}
			if (list.size() - k + 1 > 0) {
				Collections.sort(list);
				for (int j = 0; j < list.size() - k + 1; j++) {
					list2.add(list.get(j));
				}
			}
			if (list2.size() >= q) {
				Collections.sort(list2);
				if (list2.get(0) == min) {
					int val = list2.get(q - 1) - min;
					ans = Math.min(ans, val);
				}
			}
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 90188
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    char a[10];
    int n;
    cin >> n;
    for(int j=0;j<n;j++){
        scanf("%s",a);
        int b[8];
        for(int i=0;i<8;i++){
            b[i]=a[i]-'0';
        }
        sort(b,b+8);
        int max=0,min=0;
        for(int i=0;i<8;i++){
            max=max*10+b[7-i];
            min=min*10+b[i];
        }
        cout << max-min << endl;
    }
}


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

int main() {
    int N, M, X, Y;
    cin >> N >> M >> X >> Y;
    vector<int> x(N), y(M);
    for (int i = 0; i < N; ++i) {
        cin >> x[i];
    }
    for (int i = 0; i < M; ++i) {
        cin >> y[i];
    }
    sort(x.begin(), x.end(), greater<>());
    sort(y.begin(), y.end());
    for (int i = X + 1; i <= Y; ++i) {
        if (x[0] < i && y[0] >= i) {
            cout << "No War" << endl;
            return 0;
        }
    }
    cout << "War" << endl;
    return 0;
}


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

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


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

namespace AOJ
{
	class Program
	{
		static void Main(string[] args)
		{
			string line = "";
			while ((line = Console.ReadLine()) != null)
			{
				int[] l = line.ToCharArray().Select(i => i - '0').ToArray();
				f(l);
			}
		}

		static void f(int[] pai)
		{
			int[] count = new int[10];
			foreach (int p in pai)
				count[p]++;
			var a = new List<int>();

			for (int i = 1; i <= 9; i++)
			{
				if (count[i] < 4)
				{
					count[i] += 1;
					for (int j = 1; j <= 9; j++)
					{
						if (count[j] >= 2)
						{
							count[j] -= 2;
							solve(count, i, a);
							count[j] += 2;
						}
					}
					count[i] -= 1;
				}
			}
			a.Sort();

			if (a.Count == 0)
				Console.WriteLine("0");
			else
				Console.WriteLine(a.Select(i => i + " ").Aggregate((s, t) => s + t).TrimEnd(' '));
		}

		static void solve(int[] count, int num, List<int> a)
		{
			if (count.Sum() == 0)
			{
				if (!a.Contains(num))
					a.Add(num);
				return;
			}

			for (int i = 1; i <= 9; i++)
			{
				if (count[i] >= 3)
				{
					count[i] -= 3;
					solve(count, num, a);
					count[i] += 3;
				}
			}
			for (int i = 1; i <= 7; i++)
			{
				if (count[i] >= 1 && count[i + 1] >= 1 && count[i + 2] >= 1)
				{
					count[i] -= 1;
					count[i + 1] -= 1;
					count[i + 2] -= 1;
					solve(count, num, a);
					count[i] += 1;
					count[i + 1] += 1;
					count[i + 2] += 1;
				}
			}
		}
	}
}

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

int main() {
  long long int N, C;
  cin >> N >> C;
  vector<long long int> x(N), v(N);
  for (int i = 0; i < N; i++) {
    cin >> x[i] >> v[i];
  }

  vector<long long int> cx(N + 2), cv(N + 1);
  cx[0] = 0, cv[0] = 0;
  for (int i = 1; i <= N; i++) {
    cx[i] = x[i - 1];
    cv[i] = cv[i - 1] + v[i - 1];
  }
  cx[N + 1] = C;

  vector<long long int> a(N + 1), b(N + 1);
  a[0] = 0, b[0] = 0;
  for (int i = 1; i <= N; i++) {
    a[i] = max(a[i - 1], cv[i] - cx[i]);
    b[i] = max(b[i - 1], (cv[N] - cv[N - i]) - (C - cx[N - i + 1]));
  }

  long long int ans = 0;
  for (int i = 0; i <= N; i++) {
    ans = max(ans, cv[i] - 2 * cx[i] + b[N - i]);
    ans = max(ans, (cv[N] - cv[N - i]) - 2 * (C - cx[N - i + 1]) + a[N - i]);
  }
  cout << ans << endl;
}

Measured memory_bytes: 4992
'use strict'
const Main = (arg) => {
  let input = arg.trim().split('\n');
  let A = parseInt(input[0]);
  let B = parseInt(input[1]);
  let Ans = 0;
  if (A !== 1 && B !== 1) {
    Ans = 1;
  } else if (A !== 2 && B !== 2) {
    Ans = 2;   
  } else {
    Ans = 3;   
  }

  console.log(Ans);

}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

using namespace std;

class Dice{
  public:
    int a[6], tmp, i;
    /*
    Dice(int input[6]){
      for (i = 0; i < 6; i++) {
        a[i] = input[i];
      }
    }
    */

    void e() {
      tmp = a[2]; a[2] = a[0]; a[0] = a[3]; a[3] = a[5]; a[5] = tmp;
    }

    void n() {
      tmp = a[0]; a[0] = a[1]; a[1] = a[5]; a[5] = a[4]; a[4] = tmp;
    }

    void w() {
      tmp = a[0]; a[0] = a[2]; a[2] = a[5]; a[5] = a[3]; a[3] = tmp;
    }

    void s() {
      tmp = a[0]; a[0] = a[4]; a[4] = a[5]; a[5] = a[1]; a[1] = tmp;
    }
    bool ismatch(int a2[6]) {
      int count1 = 0, count2 = 0;
      while (1) {
        if (a[0] == a2[0]) {
          count2 = 0;
          while (1) {
            if (a[1] == a2[1]) {
              if (a[2] == a2[2] && a[3] == a2[3] && a[4] == a2[4] && a[5] == a2[5])
                return true;
              else break;
            }
            e();
            n();
            w();
            count2++;
            if (count2 >= 4) break;
          }
        }
        if (count1 < 3 ) e();
        else n();
        count1++;
        if (count1 > 6) return false;
      }
    }
};


int main(void)
{
  int i, j, in[6], n;
  cin >> n;
  Dice d[n];
  for (i = 0; i < n; i++) {
    for (j = 0; j < 6; j++) cin >> d[i].a[j];
  }
  for (i = 0; i < n - 1; i++) {
    for (j = i + 1; j < n; j++) {
      if (d[i].ismatch(d[j].a)) {
        cout << "No" << endl;;
        return 0;
      }
    }
  }
  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 1160
H,W,N = map(int,input().split())
ssr,ssc = map(int,input().split())
S = input()
T = input()

ssr -= 1
ssc -= 1

A = ["L", "R", "U", "D"]

A2 = {"L": -1, "R": 1, "U": -1, "D": 1}

D ={"L": "R", "R": "L", "U": "D", "D": "U"}

ans = "YES"

flg = 0

for a in A :
    
    sr = ssr
    sc = ssc
    
    if flg :
        break
        
    for i in range(N) :
        if (a in ["L", "R"]) and (a == S[i]) :
            sc += A2[a]
            
            if (sc < 0) or (sc >= W) :
                ans = "NO"
                flg = 1
                break

        elif (a in ["U", "D"]) and (a == S[i]) :
            sr += A2[a]
            
            if (sr < 0) or (sr >= H) :
                ans = "NO"
                flg = 1
                break
            
        if (a in ["L", "R"]) and (D[a] == T[i]) :
            if (sc == 0) and (D[a] == "L") :
                continue
            elif (sc == W-1) and (D[a] == "R") :
                continue
            sc += A2[D[a]]
            

            
        elif (a in ["U", "D"]) and (T[i] == D[a]) :
            if (sr == 0) and (D[a] == "U") :
                continue
            elif (sr == H-1) and (D[a] == "D") :
                continue
            sr += A2[D[a]]
        #print((sr,sc))
print(ans)
        

Measured memory_bytes: 3896
A, B, C = map(int, input().split())
K = int(input())

if A < B and B < C :
  print('Yes')
  exit()

for i in range(K):
  if A <= C and C <= B:
    C = C * 2
    if A < B and B < C:
      print('Yes')
      exit()
  elif B <= A and A <= C:
    B = B * 2
    if A < B and B < C:
      print('Yes')
      exit()
  elif B <= C and C <= A:
    C = C * 2
    if A < B and B < C:
      print('Yes')
      exit()
  elif C <= A and A <= B:
    C = C * 2
    if A < B and B < C:
      print('Yes')
      exit()
  elif C <= B and B <= A:
    C = C * 2
    if A < B and B < C:
      print('Yes')
      exit()
print('No')


Measured memory_bytes: 9232
N, C, K = map(int, input().split())
inputs = [int(input()) for _ in range(N)]

inputs.sort()

start = inputs[0]
capa = 1
ans = 1
for i in range(1, N):
    capa += 1
    if start + K < inputs[i] or capa > C:
        ans += 1
        capa = 1
        start = inputs[i]

print(ans)


Measured memory_bytes: 7440
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>

using namespace std;

int main() {
	int n;
	cin >> n;
	cout << (int)pow((int)(sqrt(n)), 2) << endl;
	return 0;
}

Measured memory_bytes: 256
from collections import deque

n = int(input())
graph = []

for _ in range(n):
    u = list(map(int, input().split()))

    if u[1] == 0:
        graph.append([])
    else:
        graph.append(list(map(lambda x: x - 1, u[2: u[1] + 2])))

dist = [-1] * n


def bfs(x):
    q = deque([])
    dist[x] = 0
    q.append(x)

    while q:
        x = q.popleft()

        for nx in graph[x]:
            if dist[nx] != -1:
                continue
            else:
                dist[nx] = dist[x] + 1
                q.append(nx)


bfs(0)

for i in range(n):
    print(i + 1, dist[i])



Measured memory_bytes: 6032
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector <int> vi;
typedef vector <ll> vl;

#define F           first
#define S           second
#define pb          push_back
#define P           push


int main() {
    #ifdef LU_Serious
       // freopen("in.txt", "r", stdin);
    #endif /// LU_Serious

    int n, m, i;
    string s;
    bool f;
    vector <int> v;

    while(cin >> s) {
        n = s.size();
        v.clear();
        f = 1;
        s += "abcdefgh";
        for(i = 0; i < s.size(); i++) {
            if(s[i] == 'e' && s[i+1] == 'r' && s[i+2] == 'a' && s[i+3] == 's' && s[i+4] == 'e' && s[i+5] == 'r')
            {
                s[i] = s[i+1] = s[i+2] = s[i+3] = s[i+4] = s[i+5] = '5';
                i += 4;
            }
            else if(s[i] == 'e' && s[i+1] == 'r' && s[i+2] == 'a' && s[i+3] == 's' && s[i+4] == 'e')
            {
                s[i] = s[i+1] = s[i+2] = s[i+3] = s[i+4] = '5';
                i += 3;
            }
            else if(s[i] == 'd' && s[i+1] == 'r' && s[i+2] == 'e' && s[i+3] == 'a' && s[i+4] == 'm' && s[i+5] == 'e' && s[i+6] == 'r')
            {
                v.push_back(i+5);
                v.push_back(i+6);
                s[i] = s[i+1] = s[i+2] = s[i+3] = s[i+4] = '5';
                i += 3;
            }
            else if(s[i] == 'd' && s[i+1] == 'r' && s[i+2] == 'e' && s[i+3] == 'a' && s[i+4] == 'm')
            {
                s[i] = s[i+1] = s[i+2] = s[i+3] = s[i+4] = '5';
                i += 3;
            }
        }
        for(auto it: v) s[it] = '5';
        for(i = 0; i < n; i++) {
            if(s[i] != '5') {
                f = 0;
                break;
            }
        }
        if(f) cout << "YES\n";
        else cout << "NO\n";
    }

    return 0;
}


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

class modint {
  public:
    using ll = long long;
    ll num;
    static const ll MOD = 1e9+7;
    static vector<modint> factorial;

    modint(): num(0) {};
    modint(ll n_): num((n_ + MOD) % MOD) {}
    modint(const modint &r): num(r.num) {}
    operator ll() const { return (num+MOD)%MOD; }
    friend istream& operator>>(istream& is, modint &r){
        ll num_;
        is >> num_;
        r = num_;
        return is;
    }
    modint operator+(const modint &r) const { return modint(num + r.num); }
    modint operator-(const modint &r) const { return modint(num - r.num); }
    modint operator*(const modint &r) const { return modint(num * r.num); }

    template<typename T>
    modint operator^(const T &r) const {
        if(r == 0) return 1;
        return (((*this)*(*this)) ^ (r/2)) * modint(r&1 ? num : 1);
    }
    modint operator/(const modint &r) const { return num * (r^(MOD-2)); }

    modint operator+=(const modint &r) { return *this = *this + r; }
    modint operator-=(const modint &r) { return *this = *this - r; }
    modint operator*=(const modint &r) { return *this = *this * r; }
    modint operator/=(const modint &r) { return *this = *this / r; }

    template<typename T>
    modint operator^=(const T &r) { return *this = *this ^ r; }

    static modint pow(const modint x, ll r) {
        return x^r;
    }

    static modint fact(int n){
        if((int)factorial.size() <= n) {
            int size = factorial.size();
            factorial.resize(n+1);
            for (int i = size; i <= n; i++) {
                factorial[i] = fact(i-1) * modint(i);
            }
        }
        return factorial[n];
    }

    static modint C(ll n,ll r){
        return n >= r ? fact(n)/(fact(n-r)*fact(r)) : modint(0);
    }
};
vector<modint> modint::factorial = {1};
#define fact(n) modint::fact(n)
#define C(n,r) modint::C(n,r)
#define H(a,b) C(a+b, a)

ll sum(ll n){
    return n*(n+1)/2;
}

int main(void){
    ll n, k;
    cin >> n >> k;
    modint res = 0;
    for (ll x = k; x <= n+1; x++) {
        res += sum(n+1) - sum(n+1-x) - sum(x) + 1;
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 3628
/*
 * main.c
 *
 *  Created on: 2019/07/21
 *      Author: family
 */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int main()
{
	int N = 0;
	scanf("%d", &N);
	printf("%d\n", (int)pow(N,3));
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int bin[100005];
int du[100005];
int numid[100005];
int ic[100005];
int fin_bi(int id);
int main(void)
{
    for(int i = 0;i < 100005;i++)
        bin[i] = i,du[i] = 1;
    int n,m;
    scanf("%d %d",&n,&m);
    for(int i = 1;i <= n;i++)
        scanf("%d",&numid[i]);
    for(int i = 0;i < m;i++)
    {
        int x,y;
        scanf("%d %d",&x,&y);
        int idx = fin_bi(x);
        int idy = fin_bi(y);
        if(idx != idy)
        {
            if(du[idx] > du[idy])
                du[idx] += du[idy],bin[idy] = idx;
            else 
            {
                du[idy] += du[idx];
                bin[idx] = idy;
            }
        }
    }
    int cnt = 0;
    for(int i = 1;i <= n;i++)
    {
       int icx = fin_bi(i);
       int icy = fin_bi(numid[i]);
       if(icx == icy)
       {
          cnt++;
       }
    }
    printf("%d\n",cnt);
    return 0;
}
int fin_bi(int id)
{
    while(bin[id] != id)
        id = bin[id];
    return id;
}

Measured memory_bytes: 1408
#include <cstdio>
#include <cstring>
#include <vector>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define clr(a,v) memset((a),(v),sizeof(a))

constexpr int MAX_N = 100000;

int N;
std::vector<int> G[MAX_N];
int d[2][MAX_N];
bool used[MAX_N];
int cnt[2];

void dfs( int v, int idx )
{
  used[v] = true;

  rep( i, G[v].size() ) if( !used[G[v][i]] )
  {
    d[idx][G[v][i]] = d[idx][v]+1;
    dfs( G[v][i], idx );
  }

  return;
}

int main()
{
  scanf( "%d", &N );
  rep( i, N-1 )
  {
    int a, b;
    scanf( "%d%d", &a, &b );
    --a; --b;
    G[a].push_back( b );
    G[b].push_back( a );
  }

  dfs( 0, 0 );

  clr( used, false );
  dfs( N-1, 1 );

  rep( i, N )
  {
    if( d[0][i] <= d[1][i] )
      ++cnt[0];
    else
      ++cnt[1];
  }

  puts( cnt[0] > cnt[1] ? "Fennec" : "Snuke" );

  return 0;
}

Measured memory_bytes: 12928
using System;
class p
{
  static void Main()
  {
    long X = long.Parse(Console.ReadLine());
    long price = 100;
    int year = 0;
    do {
      price = (long)Math.Floor(price * 1.01);
      year++;
    } while (price < X);
    Console.WriteLine(year);
  }
}

Measured memory_bytes: 27400
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include <functional>
#include<time.h>
#include <stack>
#include<iomanip>
using namespace std;
#define rep(i,a,n) for(llint i=(a);i<(n);i++)
#define ll long long
#define llint long long int
#define reverse(v)  reverse(v.begin(), v.end());
#define Yes(ans) if(ans)cout<<"Yes"<<endl; else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl; else cout<<"NO"<<endl;
#define hei(a) vector<a>
#define whei(a) vector<vector<a>>
#define UF  UnionFind 
#define Pint pair<int,int>
#define Pll pair<llint,llint>
#define keta(a)  fixed << setprecision(a)
const ll mod = 1000000007;
//辞書順はnext_permutation( begin( v ), end( v ) );やで！
const ll INF = 1000000000;

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

// mod. m での a の逆元 a^{-1} を計算するよ！
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;
}


//aCbをmod.mで割った余りを求める
llint C(llint n, llint r, llint m) {
	llint ans = 1;
	for (llint i = 0; i < r; i++) {
		ans *= n - i;
		ans %= m;
	}
	for (llint i = 1; i <= r; i++) {
		ans *= modinv(i, m);
		ans %= m;
	}
	return ans;
}


int main() {
	int n;
	cin >> n;
	int ans = 0;
	rep(i, 1, n) {
		int x = n - i;
		for (int j = 1; j * j <= x; j++) {
			if (x % j == 0) {
				if (x / j == j)ans++;
				else ans += 2;
			}
		}
	}
	cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3636
#!/usr/bin/env python3

#import
#import math
#import numpy as np
K = int(input())
#= map(int, input().split())
#= list(map(int, input().split()))
#= [input(), input()]
#= [list(map(int, input().split())) for _ in range(N)]
#= [int(input()) for _ in range(N)]
#= {i:[] for i in range(N)}

t = "ACL" * K

print(t)

Measured memory_bytes: 9132
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007

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

  vector<long long> A(N);
  for(int i =0 ;i < N;i++) cin >> A[i];

  for(int i = K;i < N;i++) {
    
      if(A[i] > A[i-K]) cout << "Yes" << endl;
      else cout << "No" << endl;
    
  }



}


Measured memory_bytes: 4764