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

#define REP(i, s, n) for (int i = s; i < n; ++i)
#define rep(i, n) REP(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG false

int main()
{
    int n;
    cin >> n;
    vector<int> a;
    vector<int> b;
    rep(i, n)
    {
        int hoge;
        cin >> hoge;
        if (i % 2 == 0)
        {
            a.push_back(hoge);
        }
        else
        {
            b.push_back(hoge);
        }
    }
    if (n % 2 == 1)
    {
        for (int i = a.size() - 1; i >= 0; i--)
        {
            cout << a[i];
            cout << " ";
        }
        for (int i = 0; i < b.size(); i++)
        {
            cout << b[i];
            if (i != b.size() - 1)
            {
                cout << " ";
            }
        }
    }
    else
    {
        for (int i = b.size() - 1; i >= 0; i--)
        {
            cout << b[i];

            cout << " ";
        }
        for (int i = 0; i < a.size(); i++)
        {
            cout << a[i];
            if (i != a.size() - 1)
            {
                cout << " ";
            }
        }
    }
    cout << endl;
    return 0;
}

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

int main(){
    int N, M, C;
    cin >> N >> M >> C;
    vector<int> B(M);
    for (auto& x : B) cin >> x;
    vector<vector<int>> A(N, vector<int>(M, 0));
    for (auto& x : A){
        for (auto& y : x){
            cin >> y;
        }
    }

    int ans = 0;
    for (auto& a : A){
        int s = 0;
        for (int i = 0; i < a.size(); ++i){
            s += a[i] * B[i];
        }
        if (s + C > 0) ++ans;
    }

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

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

// --- FIX begin --- cut here ---
template<typename F>
class FixPoint : private F {
public:
  explicit constexpr FixPoint(F&& f) noexcept : F(forward<F>(f)) {}

  template<typename... Args>
  constexpr decltype(auto) operator()(Args&&... args) const {
    return F::operator()(*this, forward<Args>(args)...);
  }
};

template<typename F>
static inline constexpr decltype(auto) fix(F&& f) noexcept {
  return FixPoint<F>{forward<F>(f)};
}
// --- FIX end --- cut here ---


int main(int argc, char *argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  int N; cin >> N;
  int u, v; cin >> u >> v; u--; v--;
  vector<vector<int>> nbr(N);
  for (int i = 0; i < N-1; i++) {
    int a, b; cin >> a >> b; a--; b--;
    nbr.at(a).push_back(b);
    nbr.at(b).push_back(a);
  }
  
  vector<int> path;
  auto phase1 = fix([&](const auto& recF, int n, int p, int dist) -> bool {
      if (n == u) {
	path.resize(dist+1);
	path.at(dist) = u;
	return true;
      }
      for (int k : nbr.at(n)) {
	if (k == p) continue;
	if (recF(k, n, dist + 1)) {
	  path.at(dist) = n;
	  return true;
	}
      }
      return false;
    });
  bool b = phase1(v, -1, 0);
  assert(b);
  assert(path.size() >= 2);
  int thr = (path.size() - 1) / 2;
  int pp = path.at(thr);
  int tt = path.at(thr+1);
  
  auto phase2 = fix([&](const auto& recF, int n, int p) -> int {
      int dmax = 0;
      for (int k : nbr.at(n)) {
	if (k == p) continue;
	dmax = max(dmax, recF(k, n) + 1);
      }
      return dmax;
    });
  int len2 = phase2(tt, pp);
  int answer = thr + 1 + len2 - 1;
  cout << answer << endl;
  

  return 0;
}



Measured memory_bytes: 8320
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <limits.h>

int cmp(const void* p, const void* q) {
	return *(int*)p - *(int*)q;
}

int main(void) {
	int n;
	int x[200000] = { 0 };
	int temp[200000] = { 0 };

	scanf("%d", &n);
	for (int i = 0; i < n; i++)
		scanf("%d", &x[i]), temp[i] = x[i];
	qsort(temp, n, sizeof(int), cmp);
	for (int i = 0; i < n; i++) {
		if (x[i] <= temp[n / 2 - 1])printf("%d\n", temp[n / 2]);
		else printf("%d\n", temp[n / 2 - 1]);
	}
	return 0;
}


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

const int N = 105;
const int INF = 1000000000;
typedef long long i64;

struct Node{int x, y;}a[N], b[N];
int uN, vN;
int g[N][N], linker[N];
bool used[N];

bool dfs(int u) {
    for (int v = 0; v < vN; v++)
        if (g[u][v] && !used[v]) {
            used[v] = true;
            if (linker[v] == -1 || dfs(linker[v])) {
                linker[v] = u;
                return true;
            }
        }
    return false;
}
int hungary() {
    int res = 0;
    memset(linker, -1, sizeof(linker));
    for (int u = 0; u < uN; ++u) {
        memset(used, false, sizeof(used));
        if (dfs(u)) ++res;
    }
    return res;
}
int main ()
{
    int n;
    cin >> n;
    uN = vN = n;
    for (int i = 0; i < n; ++i) cin >> a[i].x >> a[i].y;
    for (int i = 0; i < n; ++i) cin >> b[i].x >> b[i].y;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            if (a[i].x < b[j].x && a[i].y < b[j].y) g[i][j] = 1;
        }
    }
    printf("%d\n", hungary());
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
struct Card {
	char c;
	int v;
};
bool operator ==(Card c1, Card c2) {
	if ((c1.c == c2.c) && (c1.v = c2.v))
		return true;
	else
		return false;
}
bool operator !=(Card c1, Card c2) {
	if ((c1.c != c2.c) || (c1.v != c2.v))
		return true;
	else
		return false;
}
void Copy(Card c1[], Card c2[], int n) {
	for (int i = 0; i < n; i++) {
		c1[i].c= c2[i].c;
		c1[i].v = c2[i].v;
	}
}
void Bubble(Card c[], int n) {
	for (int i = 0; i < n; i++) {
		for (int j = n - 1; j > i; j--) {
			if (c[j].v < c[j - 1].v)
				swap(c[j], c[j - 1]);
		}
	}
}
void Selection(Card c[], int n) {
	for (int i = 0; i < n; i++) {
		int minv = i,flag=0;
		for (int j = i; j < n; j++) {
			if (c[minv].v > c[j].v) {
				minv = j;
				flag = 1;
			}
		}
		if (flag)
			swap(c[i], c[minv]);
	}
}
void Print(Card c[], int n) {
	for (int i = 0; i < n; i++) {
		cout << c[i].c << c[i].v;
		if (i != n-1)
			cout << ' ';
	}
	cout << endl;
}
int ISstable(Card in[], Card out[],int n) {
	for (int i = 0; i < n; i++) {
		for (int j = i + 1; j < n; j++) {
			for (int a = 0; a < n; a++) {
				for (int b = a + 1; b < n; b++) {
					if ((in[i].v == in[j].v) && (in[i] == out[b]) && (in[j] == out[a])) {
						cout << "Not stable" << endl;
						return 0;
					}
				}
			}
		}
	}
	cout << "Stable" << endl;
	return 0;
}
int ISstable1(Card b[], Card s[], int n) {
	for (int i = 0; i < n; i++) {
		if (b[i] != s[i]) {
			cout << "Not stable" << endl;
			return 0;
		}
	}
	cout << "Stable" << endl;
	return 0;
}
int main() {
	int n;
	cin >> n;
	Card *c = new Card[n];
	for (int i = 0; i < n; i++) {
		cin >> c[i].c >> c[i].v;
	}
	Card *in1 = new Card[n];
	Copy(in1, c,n);
	Card *in2 = new Card[n];
	Copy(in2, c, n);
	Bubble(in1, n);
	Print(in1, n);
	//ISstable(c, in1, n);
	cout << "Stable" << endl;
	Selection(in2, n);
	Print(in2, n);
	//ISstable(c, in2, n);
	ISstable1(in1, in2, n);
	delete[] c,in1,in2;
	return 0;
	//H4 C9 S4 D2 C3
}


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

typedef long long int lli;
typedef pair<lli,lli> pii;

lli n,a[100009],b[100009],c[100009],ct,e[100009],mxd=0;
bool f=true;

int main(){
	scanf("%i",&n);
	for(int i=0;i<n;i++){
		scanf("%i",a+i);
		// if(i && a[i]<a[mn]) mn = i;
	}
	if(n==1 && a[0]>=0) {
		printf("YES");
		return 0;
	}
	b[0] = a[0]-a[n-1];
	mxd = max(mxd,b[0]);
	for(int i=1;i<n;i++){
		b[i] = a[i]-a[i-1];
		mxd = max(mxd,b[i]);
	}
	ct = 0; e[0] = 0;
	for(int i=0;i<n;i++){
		c[i] = (mxd - b[i])/n;
		// printf("%i ",c[i]);
		ct += c[i];
		e[0] += ct;
	}
	e[0] = e[0] + ct - c[0]*n;
	a[0] -= e[0];
	// printf("\n%i ",e[0]);
	for(int i=1;i<n;i++){
		e[i] = e[i-1] + ct - c[i]*n;
		a[i] -= e[i];
		// printf("%i ",e[i]);
	}
	// printf("\n");
	if(a[0] % (n*(n+1)/2) != 0 || a[0]<0) f = 0;
	for(int i=0;i<n;i++){
		// printf("%i ",a[i]);
		if(a[i]!=a[0] || a[i] % (n*(n+1)/2) != 0 || a[i]<0) {
			f = 0; break;
		}
	}
	printf( f ? "YES" : "NO" );
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#include <vector>
using namespace std;
int check(int n){
  int val = 0;
  while(n % 2 == 0){
    n /= 2;
    val++;
  }
  return val;
}
int main(){
  int n;
  cin >> n;
  int ans = 1;
  int maxNum = 0;
  for(int i = n; i > 0; i--){
    if(i % 2 == 0){
      int temp = check(i);
      if(temp > maxNum){
        ans = i;
        maxNum = temp;
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;

  int card[4][13] = {};
  for(int i=0; i<n; i++){
	string suit;
	int num;
	cin>>suit>>num;

	if(suit == "S") card[0][num-1] = 1;
	if(suit == "H") card[1][num-1] = 1;
	if(suit == "C") card[2][num-1] = 1;
	if(suit == "D") card[3][num-1] = 1;
  }

  string str[4] = {"S","H","C","D"};
  for(int i=0;i<4;i++){
    for(int j=0;j<13;j++){
	if(card[i][j] == 1) continue;
	cout<<str[i]<<" "<<j+1<<endl;
    }
  }
 return 0;
}


Measured memory_bytes: 3096
N = int(input())

road = [[0 for i in range(N+1)]]
for i in range(2):
    tmp = list(map(int,input().split()))
    tmp.insert(0,0)
    road.append(tmp)

for i in range(1,3):
    for j in range(1,N+1):
        road[i][j] = max(road[i][j-1], road[i-1][j])+road[i][j]

print(road[2][N])

Measured memory_bytes: 3064
# -*- coding: utf-8 -*-
import sys
# ----------------------------------------------------------------
# Use Solve Function

def solve(lines):
    N,K = map(int, lines.pop(0).split(' '))
    A = list(map(int, lines.pop(0).split(' ')))
    min_a = min(A)
    idx = 0
    re = 0
    while( idx < N - 1):
        if ( all([i == min_a for i in A[idx:idx+K] ]) ):
            idx += K - 1
            continue
        else:
            re += 1
            idx += K - 1
    print(re)



#
# main
#

# 1. use list instead of stdin

#contents = '''\
#3 3
#1 2 3\
#'''
#lines = contents.split('\n')
# 
# 2. use stdin

lines = [x.strip() for x in sys.stdin.readlines()]

#
# solve !!
#
solve(lines)

Measured memory_bytes: 13872
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int[] a = new int[5];
        for(int i=0;i<5;i++){
            a[i] = sc.nextInt();
        }
        int min = 10;
        for(int i=0;i<5;i++){
            int tmp = a[i]%10;
            if(tmp==0){
            }
            else{
                if(tmp<min){min=tmp;}
                a[i] = (int)a[i]/10;
                a[i]++;
                a[i]*=10;
            }
        }
        int result = 0;
        for(int i=0;i<5;i++){
            result += a[i];
        }
        System.out.println(result-10+min);
    }
}

Measured memory_bytes: 23124
fun readString() = readLine()!!
fun readInt() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readIntList() = readLine()!!.split(" ").map(String::toInt)
fun readLongList() = readLine()!!.split(" ").map(String::toLong)
fun <T> Array<Array<T>>.print() {
    this.forEach {
        println(it.joinToString(" "))
    }
}

class Combination(maxNum: Int, private val mod: Int) {
    private val fac = LongArray(maxNum + 1).apply { this[0] = 1L; this[1] = 1L }
    private val fInv = LongArray(maxNum + 1).apply { this[0] = 1L; this[1] = 1L }
    private val inv = LongArray(maxNum + 1).apply { this[1] = 1L }

    init {
        for (i in 2..maxNum) {
            fac[i] = fac[i - 1] * i % mod
            inv[i] = mod - inv[mod % i] * (mod / i) % mod
            fInv[i] = fInv[i - 1] * inv[i] % mod
        }
    }

    fun get(n: Int, k: Int): Long {
        if (n < k) return 0
        if (n < 0 || k < 0) return 0
        return fac[n] * (fInv[k] * fInv[n - k] % mod) % mod
    }
}

fun main() {
    val comb = Combination(101, Int.MAX_VALUE)
    val (n, m) = readIntList()
    println(comb.get(n, 2) + comb.get(m, 2))
}


Measured memory_bytes: 36452
'use strict';

var hasN = false; // has N *only* line
var type = "b";
// a: 2D split
// b: space split
// c: line split
// z: other (only source)
function main(N, p, s) {
  // N, processed data, source
  var a = p[0];
  var b = p[1];
  var t = p[2] + 0.5;
  var n = Math.floor(t / a);
  console.log(n * b);
}
function common(a) {
  var line = a.split('\n').slice(0, a.split('\n').length - 1);
  if (hasN) var N = Number(line.shift());
  switch (type) {
    case "a":
      main(N, line.map(function (e) {
        return e.split(' ').map(function (ee) {
          return Number(ee);
        });
      }), a);
      break;
    case "b":
      main(N, line[0].split(' ').map(function (e) {
        return Number(e);
      }), a);
      break;
    case "c":
      main(N, line, a);
      break;
    case "z":
      main(N, null, a);
  }
}
common(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 21064
#include <iostream>
#include <cstring>
#include<vector>
#include <algorithm>
#include<cstdlib>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0;i<n;i++)

int main()
{
    ll n, d;
    cin >> n >> d;
    vector<vector<ll>> k(n, vector<ll>(2));
    int ans = 0;
    rep(i, n)
    {
        cin >> k[i][0] >> k[i][1];
    }
    rep(i, n)
    {
        if (k[i][0] * k[i][0] + k[i][1] * k[i][1] <= d * d)
        {
            ans++;
        }
    }

    cout << ans << "\n";

    
    return 0;
}

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

using namespace std;

int main(void) {

	int N,ans=0,d=0;

	cin >> N;

	string S;

	cin >> S;

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

		if (S[i] == '(')
			ans++;

		if (S[i] == ')') {

			if (ans > 0) 
				ans--;

			else
				d++;
		}
	}

	for (int i = 0; i < d; i++)
		cout << "(";

	cout << S;

	for (int i = 0; i < ans; i++)

		cout << ")";

}

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, K, C;
  cin >> N >> K >> C;
  string S;
  cin >> S;
  vector<int> left, right;
  left.emplace_back(-(1 << 28));
  for (int i = 0; i < N; i++) {
    if (S[i] == 'o') {
      left.emplace_back(i);
      i += C;
    }
  }
  right.emplace_back(1 << 28);
  for (int i = N - 1; i > -1; i--) {
    if (S[i] == 'o') {
      right.emplace_back(i);
      i -= C;
    }
  }
  reverse(right.begin(), right.end());
  for (int i = 0; i < N; i++) {
    int x = lower_bound(left.begin(), left.end(), i) - left.begin() - 1;
    int y = lower_bound(right.begin(), right.end(), max(left[x] + C, i + 1)) -
            right.begin();
    y = (int)right.size() - 1 - y;
    if (x + y < K) cout << i + 1 << '\n';
  }
  return 0;
}


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


void solve(long long N){
    ll a = N / 1000; // 商
    ll b = N - a * 1000; // 余り
    cout << ((b==0) ? to_string(b) : to_string(1000-b)) << endl;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    solve(N);
    return 0;
}


Measured memory_bytes: 3752
#include<iostream>
#include<cmath>
#include<algorithm>
#include <cassert>
#include<string>
#include<vector>
#include <utility>
#include <math.h>
using namespace std;
char col[1000];
int main() {
	int a = 0;
	cin >> a;
	for (int i = 0; i < a; i++) {
		cin >> col[i];
		if (col[i] == 'Y') {
			cout << "Four" << endl;
			return 0;
		}
	}
	cout << "Three" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll              long long
#define pb              push_back
#define mp              make_pair
#define sz(a)           (int)(a).size()
#define all(x)          (x).begin(), (x).end()
#define fore(i,a,b)     for(int i=a; i<b; i+=1)
#define forr(i,a)       for(int i=a; i>=0; i--)
#define F first
#define S second
 
using namespace std;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef pair<string, int> si;
typedef pair<int, string> is;
typedef vector<string> vs;
const int MAX=1e5+10;

 
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    string cad; cin>>cad;
    if(cad[2]==cad[3] && cad[4]==cad[5]) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define sz(a) a.size()
#define re return
#define all(a) a.begin(),a.end()
#define int long long
using namespace std;
const int dx[4]={-1,1,0,0};
const int dy[4]={0,0,-1,1};
const int mod=1e9+7;
int fac[1000006],inv[1000006];
int pow_mod(int a,int n){
    int cur=1;
    while (n){
        if(n&1) cur=cur*a%mod;
        a=a*a%mod;
        n/=2;
    }
    re cur;
}
void init(){
    fac[0]=1;
    for (int i=1;i<1e6+4;i++)
        fac[i]=fac[i-1]*i%mod;
}
int C(int x, int y){
    return fac[x]*pow_mod(fac[y]*fac[x-y]%mod,mod-2)%mod;
}
int two[1000006];
void f2(){
	two[2]=2;
	for (int i=3;i<1000004;i++)
		two[i]=(two[i-1]*2+2)%mod;
}
int eight[1000006];
void f8(){
	eight[0]=1;
	for (int i=1;i<1000004;i++)
		eight[i]=eight[i-1]*8%mod;
}
signed main()
{
	f2(),f8();
	init();
	int n;
	cin>>n;
	int ans=0;
	for (int i=2;i<=n;i++){
		ans+=(C(n,i)*two[i]%mod)*eight[n-i]%mod;
		ans%=mod;
	}
	cout<<ans;
	re 0;
}


Measured memory_bytes: 27068
// Problem : D - Not Divisible
// Contest : AtCoder - AtCoder Beginner Contest 170
// URL : https://atcoder.jp/contests/abc170/tasks/abc170_d
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>

using namespace std;

int N;
int sieve[1000005], fre[1000005];
int arr[200005];

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin >> N;
	for(int i =1 ; i<=N; i++){
		cin >> arr[i];
		
	}
	sort(arr+1, arr+1+N);
	for(int i = 1; i<=N; i++){
		fre[arr[i]]++;
		for(int j = arr[i]; j<=1000000 && fre[arr[i]] == 1; j+=arr[i]){
			sieve[j]++;
		}
	}
	int cnt = 0;
	for(int i = 1; i<=N; i++){
		if(sieve[arr[i]] == 1 && fre[arr[i]] == 1){
			cnt++;
		}
	}
	cout << cnt << "\n";
}

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


using namespace std;
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define reps(i,n) for (int i = 1; i <= (int)(n); ++i)
#define repd(i,n) for (int i = (int)(n - 1); i >= 0; --i)
#define repds(i,n) for (int i = (int)(n); i > 0; --i)
#define loop(i,x,n) for (int i = (int)(x); i < (n); ++i)
#define loops(i,x,n) for (int i = (int)(x); i <= (n); ++i)
#define loopd(i,x,n) for (int i = (int)(x); i > (n); --i)
#define loopds(i,x,n) for (int i = (int)(x); i >= (n); --i)
#define itrep(i,s) for (auto i = begin(s); i != end(s); ++i)
#define itrepd(i,s) for (auto i = --end(s); i != begin(s); --i)
#define all(f,x,...) [&](decltype(x)& whole) { return (f)(begin(whole), end(whole), ##__VA_ARGS__); }(x)
#define rall(f,x,...) [&](decltype(x)& whole) { return (f)(rbegin(whole), rend(whole), ##__VA_ARGS__); }(x)
using ll = long long;
using ld = long double;
constexpr ll inf = static_cast<ll>(1e17);
constexpr int iinf = static_cast<int>(1e9);
constexpr double dinf = 1e10;
constexpr ld ldinf = 1e17;
ll mod = static_cast<ll>(1e9 + 7);
std::ostream& endn(std::ostream& os) { return os.put(os.widen('\n')); }
template<class T> constexpr int sz(const T& a) { return (int)a.size(); }
template<class T, class ... Args> constexpr void mins(T& a, Args... args) { a = min<T>({ a, args... }); }
template<class T, class... Args> constexpr void maxs(T& a, Args... args) { a = max<T>({ a,args... }); }
template<typename A, size_t N, typename T> constexpr void fillArray(A(&array)[N], const T& val) { std::fill((T*)array, (T*)(array + N), val); }

int n;
ll a[100005];
void solve() {
    cin >> n;

    ll s = 0;
    rep(i, n) {
        cin >> a[i];
        s ^= a[i];
    }

    rep(i, n) a[i] &= ~s;

    int r = 0;
    vector<int> top(n);
    repd(i, 61) {
        bool flag = true;
        loop(j, r, n) {
            if ((a[j] >> i) & 1LL) {
                swap(a[r], a[j]);
                flag = false;
                break;
            }
        }

        if (flag) continue;
        top[r] = i;
        rep(k, n) {
            if (k == r) continue;
            if ((a[k] >> i) & 1LL) a[k] ^= a[r];
        }
        ++r;
    }

    ll x = 0;
    repd(i, 61) {
        auto nx = x | (1LL << i);
        ll b = nx;
        rep(j, r) if ((b >> top[j]) & 1LL) b ^= a[j];
        if ((b & nx) == 0LL) x = nx;
    }

    cout << s + x * 2LL << endn;

}

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

    solve();

    cout << flush;

    return 0;
}


Measured memory_bytes: 1408
package main

import (
    "bufio"
    "fmt"
    "os"
    "strings"
    "strconv"
    // "sort"
    // "regexp"
)

const (
    initialBufSize = 10000
    maxBufSize = 1000000
)
var reader = bufio.NewReaderSize(os.Stdin, maxBufSize)
var writer = bufio.NewWriter(os.Stdout)

func main() {
    var r string
    r  = readLine()
    ios := strAry2intAry(split(r))
    if ios[0] * 500 >= ios[1] {
        fmt.Println("Yes")
    } else {
        fmt.Println("No")
    }
}

func write(s string) {
    writer.WriteString(s)
}

func print() {
    writer.Flush()
}

func readLine() string {
    buf := make([]byte, 0, maxBufSize)
    for {
        l, p, e := reader.ReadLine()
        if e != nil {
            panic(e)
        }
        buf = append(buf, l...)
        if !p {
            break
        }
    }
    return string(buf)
}

func s2i(s string) int {
    var intVal,e = strconv.Atoi(s)
    if e != nil {
        panic(e)
    }
    return intVal
}

func i2s(i int) string {
    var strVal = strconv.Itoa(i)
    return strVal
}

func s2f(s string) float64 {
    var floatVal,e = strconv.ParseFloat(s, 64)
    if e != nil {
        panic(e)
    }
    return floatVal
}

func sum(i []int) int {
    sum := 0
    for _,val := range i {
        sum += val
    }
    return sum
}

func split(s string) []string {
    return strings.Fields(s)
}

func strAry2intAry(strs []string) []int {
    var ret = make([]int, 0, len(strs))
    for _ , str := range strs {
        var intVal, e = strconv.Atoi(string(str));
        if e != nil {
            panic(e)
        }
        ret = append(ret, intVal)
    }
    return ret
}

func intAry2strAry(nums []int) []string {
    var ret = make([]string, 0, len(nums))
    for _ , num := range nums {
        var strVal = strconv.Itoa(num);
        ret = append(ret, strVal)
    }
    return ret
}

func ary2str(strs []string) string {
    return strings.Join(strs, " ")
}

func reverse(res []int) []int {
    for i, j := 0, len(res)-1; i < j; i, j = i+1, j-1 {
        res[i], res[j] = res[j], res[i]
    }
    return res
}

//  
// func regexpExample() {
//     // Your code here!
//     var str = "13:20"
//     r := regexp.MustCompile(`(\d+):(\d+)`)
//     fmt.Println(r.FindStringSubmatch(str))
// }


// type Country struct {
//     gold int
//     silver int
//     blonze int
// }

// // 複数ソートのサンプル
// func stableSortExample() []Country{
//     var country = []Country {
//         {gold:1, silver:2, blonze:3},
//         {gold:1, silver:2, blonze:3},
//         {gold:1, silver:3, blonze:2},
//         {gold:1, silver:3, blonze:3},
//     }
//     sort.SliceStable(country, func(i, j int) bool { return country[i].blonze > country[j].blonze })
//     sort.SliceStable(country, func(i, j int) bool { return country[i].silver > country[j].silver })
//     sort.SliceStable(country, func(i, j int) bool { return country[i].gold > country[j].gold })
//     return country
// }

Measured memory_bytes: 640
#include<stdio.h>

int main(void)
{
    int a, b, ans;
    char op;
    while(1) {
    scanf("%d %c %d", &a, &op, &b);
    switch (op) {
    case '+':
        ans = a + b;
        break;
    case '-':
        ans = a - b;
        break;
    case '*':
        ans = a * b;
        break;
    case '/':
        ans = a / b;
        break;
    case '?':
        exit(0);
    }
    printf("%d\n",  ans);
    }
}



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

int main()
{
  ll a;
  ll b;
  char op;
  
  cin >> a >> op >> b;
  
  if (op == '+')
  {
    cout << a + b << endl;
    return (0);
  }
  else if (op == '-')
  {
    cout << a - b << endl;
    return (0);
  }
  
  return (0);
}

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

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t=1,i,j;
    //cin>>t;
    while(t--)
    {
        int n,m,count=0,sum=0,maxi=0,mini=1e18;
        cin>>n>>m;
        
        if(m>=n) cout<<"unsafe";
        else cout<<"safe";
        
        
    }
}

Measured memory_bytes: 3648
#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 ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
using namespace std;
typedef long long ll;
constexpr ll  MOD = (1e9+7);
constexpr int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
constexpr int lcm(int a, int b) { return a / gcd(a, b) * b; }

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;
}
ll factorial(ll n, ll m=2) {
    // calculate nPm
    m = max(2LL, m);
    ll rtn = 1;
    for (ll i=m; i<=n; i++) {
        rtn = (rtn * i) % MOD;
    }
    return rtn;
}
ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
ll modpow(ll a, ll n) {
    ll res = 1;
    while (n > 0) {
        if (n & 1)
            res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

bool check(string s) { return (s==""); }

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    string a, b, c; cin >> a >> b >> c;
    char tmp = a[0];
    a.erase(0, 1);
    string win = "";
    // cout << a << " " << b << " " << c << endl;
    while (win=="") {
        if (tmp == 'a') {
            if (check(a)) {win = "A"; break;}
            tmp = a[0];
            a.erase(0, 1);
            continue;
        } else if (tmp == 'b') {
            if (check(b)) {win = "B"; break;}
            tmp = b[0];
            b.erase(0, 1);
            continue;
        } else if (tmp == 'c') {
            if (check(c)) {win = "C"; break;}
            tmp = c[0];
            c.erase(0, 1);
            continue;
        }
    }
    cout << win << endl;
    return 0;
}

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

using namespace std;

using ll = long long;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;

long long factrial[10000000];

long long Repeat(long long a, long long cnt) {
    if(cnt == 0) return 1LL;
    if(cnt % 2 == 1) {
        long long x = Repeat(a, cnt / 2);
        return (((a * x) % MOD) * x) % MOD;
    } else {
        long long x = Repeat(a, cnt / 2);
        return (x * x) % MOD;
    }
}

long long fact(long long a) {
    if(a == 0)
        return 1LL;
    else if(factrial[a] != 0)
        return factrial[a];
    else
        return factrial[a] = (a * fact(a - 1)) % MOD;
}

int main() {
    ll n, m, i, j, k;
    cin >> n;
    vector<ll> a(n);
    for(auto &x:a){
        cin >> x;
    }
    ll ret = 0;
    ll cnt = 0;
    for(i=0;i<n-1;i++){
        ret += (((a[i + 1] - a[i]) * fact(n - 1))% MOD);
        ret %= MOD;
        ret += ((a[i+1]-a[i])*cnt);
        ret %=MOD;
        cnt += fact(n-1)*Repeat(i+2,MOD-2);
        cnt %=MOD;
        //cout << cnt << endl;
    }
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 3328
#include<cstdio>
#include<cstring>
 
char s[11], result[11];
 
int main() {
    scanf("%s", s);
    for(int i=0, j=0; i<int(strlen(s)); i++) {
    	if(s[i] == 'B') {
    		if(j > 0) result[--j] = '\0';
    		continue;
    	}
    	result[j++] = s[i];
    }
    printf("%s", result);
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace  std ;
typedef long long  ll;
typedef pair<ll, ll> Pll;
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define rad(X) cout << (X) << endl
#define ASH(X) cout << (X) << " "
#define debug(x) cout << #x << " " << x << endl;
#define debug2(x,y) cout << #x << " " << x << " " << #y << " " << y << endl;
#define FOR(I,A,B) for(ll I = (A); I <= (B); I++)
#define cir(I,B,A) for(ll I = (A); I >=(B); I--)
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define SORT(c) (sort(c.begin(),c.end()))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASES int ___T; cin >> ___T; for(int cs=1;cs<=___T;cs++)
#define FAST()  ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
template<typename T>T gcd(T x, T y){if(y==0)return x;else return gcd(y,x%y);}
ll fx[] = {1, 1, 0, -1, -1, -1, 0, 1};
ll fy[] = {0, 1, 1, 1, 0, -1, -1, -1};
vector<ll>a,b,c;
map<ll,ll>m1,m2,m3;

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

void Execute()
{
      ll n, nb, k, q, a, b, c, l, r, d, x, y, p, m;
      cin >> n >> k;

      ll ar[n];
      ll DP[n];

      FOR(i,0,n-1) cin >> ar[i];

      DP[0]=0;
      ll mn = 1e9;
      FOR(i,1,n)
      {
        mn = 1e18;

        FOR(j,1,k)
        {
          if(i-j<0) break;
          a = abs(ar[i]-ar[i-j]) + DP[i-j];
          mn = min(mn,a);
        }
        DP[i] =  mn;

      }

      std::cout << DP[n-1] << '\n';

}

int32_t main()
{
    //#ifndef ONLINE_JUDGE
    //freopen("atomm.txt", "r", stdin);
    //#endif

    FAST();
    //CASES

        Execute();

}


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

int main()
{
    vector<long long>v;
    long long h,n;
    cin>>h>>n;
    
    long long s=0LL;
    for(long long i=0;i<h;i++){
        long long x;
        cin>>x;
        v.push_back(x);
       // s+=x;
    }
    
    sort(v.begin(),v.end());
    reverse(v.begin(),v.end());
    
    for(long long i=n;i<v.size();i++){
        s+=v[i];
    }
    //if(s>=h) cout<<"Yes"<<"\n";
    //else cout<<"No"<<"\n";
    
    cout<<s<<"\n";
    return 0;
}

Measured memory_bytes: 2420
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

n,k=map(int,input().split())
if 0--n//2>=k:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 38256
#include<bits/stdc++.h>
#define lln long long int
#define llu unsigned lln
#define sc(n) scanf("%d",&n);
#define scl(n) scanf("%lld",&n);
#define scd(n) scanf("%lf",&n);
#define pf(res) printf("%d\n",res);
#define pfl(res) printf("%lld\n",res);
#define pfd(res) printf("%lf\n",res);
#define maxii 100005
using namespace std;
typedef pair<int,int> pii;
typedef pair<lln,lln> pll;
 vector<int> vi[maxii];
 vector<int>:: iterator child;
typedef vector<lln> vl;
typedef vector<pii> vii;
typedef vector<pll> vll;


int arr[maxii];
int arr2[maxii];
bool check[maxii];

bool dfs(int node,int c)
{
    check[node]=true;
    arr2[node]=c;
    for(int child=0;child<vi[node].size();child++)
    {
        if(check[vi[node][child]]==false)
        {
            if(dfs(vi[node][child],c^1)==false)
            {
                return false;
            }
        }
        else if(arr2[node]==arr2[vi[node][child]])
        {
            return false;
        }
        //else if()
    }
    return true;
}

int main()
{
   string a;
   cin>>a;
   int len=a.size();
   for(int i=0;i<len;i++)
   {
       arr[a[i]-'a']++;
   }
   int c=0;
   for(int i=0;i<26;i++)
   {
       if(arr[i]%2!=0)
       {
           c=1;
           break;
       }
   }
   if(c==0)
   {
       printf("Yes\n");
   }
   else cout<<"No";
}



Measured memory_bytes: 5956
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0; i<n; i++)
typedef long long ll;
typedef long long unsigned int llu;
ll MOD = 1000000007;
ll INF = 1000000009;


void solve(){
    string s;
    cin >> s;
    cout << s.substr(0,4) << " " << s.substr(4) << endl;
}

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


Measured memory_bytes: 256
# Here your code !
number=gets.chomp.to_i




    
array=gets.chomp.split

    
array=array.map(&:to_i)

count=0
count2=0
i=0


number.times{
    k=array[i]
    
    if k%4==0
        
        count+=1
        
        
    elsif k%2==0
       count2+=1
   
    end
    i=i+1
    
    
}




if count*2+1>=number
    puts "Yes"
elsif count*2+count2>=number
  puts "Yes"
else 
    puts "No"
end




Measured memory_bytes: 9476
#include <stdio.h>
#include <math.h>

#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <iostream>

#define VARIABLE(x) cerr << #x << "=" << x << endl
#define BINARY(x) cerr << #x << "=" << static_cast<bitset<16> >(x) << endl;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)
#define if_range(x, y, w, h) if (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))

const int INF = 10000000;
int dx[4]={-1, 0, 1, 0}, dy[4]={0, -1, 0, 1};
using namespace std;
typedef pair<int, int> P;

/** Problem 1187 : ICPC Ranking **/

typedef pair<int, pair<int, int> > P3;

bool cmp(const P3 &a, const P3 &b){
	if(a.first != b.first) return a.first > b.first;
	else if(a.second.first != b.second.first) return a.second.first < b.second.first;
	else return a.second.second > b.second.second;
}

int main()
{
	int M, T, PN, R;

	vector<P3> team;
	while (cin>>M>>T>>PN>>R, M||T||PN||R) {
		int WA[51][10]={0};
		team.clear();
		
		rep(i, T+1) {
			team.push_back(P3(0, P(0, i)));
		}
		
		rep(k, R) {
			int m, t, p, j;
			cin >> m >> t >> p >> j;
			p--;
			if (j==0) {
				team[t].first++;
				team[t].second.first+=m + WA[t][p]*20;
			} else {
				WA[t][p]++;
			}
		}
		
		sort(team.begin()+1, team.end(), cmp);
		vector<P3>::iterator it = team.begin()+1;
		for (; it!=team.end()-1; it++) {
			cout << it->second.second;
			if (it->first==(it+1)->first && it->second.first==(it+1)->second.first) {
				cout << "=";
			} else {
				cout << ",";
			}
		}
		cout << it->second.second << endl;
	}
}

Measured memory_bytes: 1200
#include<stdio.h>
bool t[500][500];
int d[500][501];
int min(int a,int b){return a<b?a:b;}
int max(int a,int b){return a>b?a:b;}
int main(){
	int h,w;
	int i,j,k;
	while(1){
	scanf("%d %d",&h,&w);
	if(h==0)return 0;
	for(i=0;i<h;i++)for(j=0;j<w;j++){
		char x;
		scanf(" %c",&x);
		if(x=='*')t[i][j]=false;
		else t[i][j]=true;
	}
	for(i=0;i<h;i++)d[i][0]=0;
	for(i=0;i<h;i++){
		for(j=1;j<=w;j++){
			if(t[i][j-1])d[i][j]=d[i][j-1]+1;
			else d[i][j]=0;
		}
	}
	int ans=0;
	int wid;
	for(i=1;i<=w;i++){
		for(j=0;j<h;j++){
			wid=1000;
			for(k=j;k<h;k++){
				wid=min(wid,d[k][i]);
				if(wid==0)break;
				ans=max(ans,wid*(k-j+1));
			}
		}
	}
	printf("%d\n",ans);
	}
}

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

int main()
{
int x,y;
cin >> x >>y;
int p,q;
p = (4*x)-y;
q = y-(2*x);
if(p%2==0&&q%2==0&&p>=0&&q>=0) cout << "Yes" << endl;
else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3624
import java.util.*;


public class Main {

    private static final int INF = 1000000007;
    private static final int INF1 = Integer.MAX_VALUE;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long l = sc.nextInt();
        long r = sc.nextInt();

        long result = INF1;
        if((l <= 2019 && 2019 <= r)){
            result = 0;
        }else if(r < 2019) {
            result = (r*(r-1)) % 2019;
        } else if(l > 2019) {
            long waru = l / 2019;
            long warur = r / 2019;
            if(waru < warur){
                result = 0;
            }else{

                
                for(long tmp=l; tmp<=r; tmp++){
                    for(long tmp1=tmp+1; tmp1<=r;tmp1++){
                        long a = (tmp*tmp1) % 2019;
                        result = Math.min(a,result);
                    }
                }

            }

        }

        System.out.println(result);

    }
}


Measured memory_bytes: 21076
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5+10;
const int maxm = 2e5+10;
typedef long long LL;
LL A[maxn]; int n, edgecnt, head[maxn];
struct edge{int v, nxt;} E[maxm];
inline int read()
{
    int x = 0 , f = 1; char ch = getchar();
    while(ch<'0'||ch>'9') {if(ch=='-')f*=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=(x<<3)+(x<<1)+(ch-48);ch=getchar();}
    return x * f;
}
inline void addedge(int u, int v)
{
    E[++edgecnt].v = v, E[edgecnt].nxt = head[u], head[u] = edgecnt;
    E[++edgecnt].v = u, E[edgecnt].nxt = head[v], head[v] = edgecnt;
}
LL dfs(int u, int fa)
{
    int cnt = 0;
    for(int i = head[u]; ~i; i = E[i].nxt)
        if(u != E[i].v && fa != E[i].v) cnt++;
    if(!cnt)
        return A[u];
    LL tot = 0, x1 = 0, x2 = 0, maxw = 0, sumw;
    for(int i = head[u]; ~i; i = E[i].nxt){
        int v = E[i].v;
        if(v == fa) continue;
        sumw = dfs(v, u);
        maxw = max(maxw, sumw);
        tot += sumw;
    }
    x2 = tot - A[u];
    x1 = A[u] - x2;
    if(x1 < 0 || x2 < 0 || A[u] < maxw || (x1 > 0 && fa == -1))
    {
        puts("NO");
        exit(0);
    }
    return x1;
}
int main(){
    memset(head,-1,sizeof head);
    n = read();
    for(int i = 1; i <= n; i++)
        scanf("%lld", &A[i]);
    for(int i = 1; i < n; i++)
        addedge(read(),read());
    if(n == 2)
        if(A[1] == A[2])
            printf("YES\n");
        else
            printf("NO\n");
    else
    {
        for(int i = 1; i <= n; i++)
        {
            int num = 0;
            for(int j = head[i]; ~j; j = E[j].nxt)
                if(E[j].v != i)
                    num++;
            if(num > 1){
                dfs(i, -1);
                break;
            }
        }
        printf("YES\n");
    }
    return 0;
}

Measured memory_bytes: 8320
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>

#define PI 3.141592653589793238
#define INF 1050000000

using namespace std;



//cout << fixed << setprecision(15) << << endl;
//cout << << endl;

int main() {

	int A,B;

	cin >> A >> B;

	cout << (A + B) % 24 << endl;

	return 0;
}

Measured memory_bytes: 256
/**
*    author:  souzai32
*    created: 07.08.2020 23:25:51
**/

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

int main() {

    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a.at(i);

    vector<int> ans(n);
    bool check=true;

    rep(i,n){
        for(int j=n-i; j>=0; j--){
            if(j==0) {
                check=false;
                break;
            }
            if(a.at(j-1)==j){
                ans.at(i)=j;
                a.erase(a.begin()+(j-1));
                break;
            }
            if(!check) break;
        }
        //cout << i << endl;
    }

    reverse(ans.begin(),ans.end());
    if(check) rep(i,n) cout << ans.at(i) << endl;
    else cout << -1 << endl;

    return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <cmath>
#include <stdio.h>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <cstring>

using namespace std;

#define f first
#define s second
#define pb push_back
#define mp make_pair
#define ll long long
#define pii pair < int, int >
#define pll pair < long long, long long>
#define ull unsigned long long
#define vi vector < int >
#define vll vector < long long >
#define sz(a) (int)a.size()
#define forit(it, s) for(__typeof(s.begin()) it = s.begin(); it != s.end(); it++)
#define all(a) a.begin(), a.end()
#define sqr(x) ((x) * (x))
#define fname "searching"

const int inf = (int)1e9;
const ll INF = (ll)1e18;
const double eps = 1e-9;
const double pi = acos(-1.0);
const int mod = (int)1e9 + 7;

string s;
bool dp[100100];

string solve(){
    cin >> s;
    dp[0] = 1;
    for(int i = 0; i < s.size(); ++i){
        if(!dp[i]) continue;
        if(i + 5 <= s.size() && s.substr(i, 5) == "dream") dp[i + 5] = 1;
        if(i + 5 <= s.size() && s.substr(i, 5) == "erase") dp[i + 5] = 1;
        if(i + 6 <= s.size() && s.substr(i, 6) == "eraser") dp[i + 6] = 1;
        if(i + 7 <= s.size() && s.substr(i, 7) == "dreamer") dp[i + 7] = 1;
    }
    return dp[s.size()] ? "YES" : "NO";
}

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

    cout << solve() << "\n";
    
    return 0;
}


Measured memory_bytes: 592
/**
 *    Coded by : lucky_21
 *               --------Lokesh Singh
**/

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

#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template<class T> using oset=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

#define     F           first
#define     S           second
#define     pb          push_back
#define     lb          lower_bound
#define     ub          upper_bound
#define     pii         pair<int,int>
#define     all(x)      x.begin(),x.end()
#define     fix         fixed<<setprecision(10)
#define     rep(i,a,b)  for(int i=int(a);i<=int(b);i++)
#define     repb(i,b,a) for(int i=int(b);i>=int(a);i--)
#define     FastIO      ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)

typedef double db;
typedef long long ll;

const int N=2e5+5;
const int mod=1e9+7;

int n,m,ok[N];
set<int>v[N];
int dfs(int x){
    int cnt=1;
    ok[x]=1;
    for(int u:v[x]) if(!ok[u]) cnt+=dfs(u);
    return cnt;
}
signed main(){
    FastIO;
    cin>>n>>m;
    rep(i,1,m){
        int a,b;
        cin>>a>>b;
        v[a].insert(b);
        v[b].insert(a);
    }
    int ans=0;
    rep(i,1,n) if(!ok[i]) ans=max(ans,dfs(i));
    cout<<ans;
    return 0;
}


Measured memory_bytes: 41932
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
template<class T> inline bool chmin(T&x,T y){if(x>y){x=y;return true;}return false;}
template<class T> inline bool chmax(T&x,T y){if(x<y){x=y;return true;}return false;}
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    string s;
    set<string> st;
    fr(i,n){
        cin>>s;
        st.insert(s);

    }
    cout<<st.size()<<endl;
}

Measured memory_bytes: 19212
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<queue>
#include<stack>
#include<map>

using namespace std;

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

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

int main(){
  int sum = 0,n;
  cin >> n;
  vector<int> d(n);
  for (int i = 0; i < n; i++){
    cin >> d[i];
  }
  for (int i = 0; i < n; i++){
    for (int j = i + 1; j < n; j++){
      sum += d[i] * d[j];
    }
  }
  cout << sum << '\n';
  return 0;
}

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

typedef long long ll;

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

    ll leng = 0, half1 = 0, half2 = 0, num;
    for(int i = 0; i < n; i++) leng += a[i];
    for(int i = 0; i < n; i++) {
        half2 += a[i];
        if(half2 >= leng / 2) {
            half1 = half2 - a[i];
            num = i;
            break;
        }
    }

    ll d1, d2;
    d1 = leng / 2 - half1;
    d2 = half2 - leng / 2;

    if(leng % 2 == 0){
        ans = (d1 < d2 ? d1 : d2) * 2;
        if(num == 1) ans = d2 * 2;
        if(num == n - 1) ans = d1 * 2;
    }
    else{
        ans = (d1 < d2 ? d1 * 2 + 1 : d2 * 2 - 1);
        if(num == 1) ans = d2 * 2 - 1;
        if(num == n - 1) ans = d1 * 2 + 1;
    }

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

Measured memory_bytes: 1792
n, q = [int(temp) for temp in input().split()]
tim  = 0
dat  = []

for mak in range(n) :
    tem = [temp for temp in input().split()]
    tem[1] = int(tem[1])
    if tem[1] > q :
        tim += q
        dat.append(tem[0])
        dat.append(tem[1] - q)
    else :
        tim += tem[1]
        print(tem[0], tim)

while dat != [] :
    for mak in range(len(dat) // 2) :
        tem = [dat[0], dat[1]]
        if tem[1] > q :
            tim += q
            dat.append(tem[0])
            dat.append(tem[1] - q)
        else :
            tim += tem[1]
            print(tem[0], tim)
        dat.pop(0)
        dat.pop(0)

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

/*
提出前に確認!
- setとmultisetを間違えない
*/

int	main(void)
{
	int n, m, k;
	cin >> n >> m >> k;
	vector<int> a(n);
	for (int i = 0; i < n; i++) cin >> a[i];
	vector<int> b(m);
	for (int i = 0; i < m; i++) cin >> b[i];
	vector<long long> acc(n + 1, 0);
	for (int i = 0; i < n; i++) acc[i + 1] = a[i] + acc[i];
	vector<long long> bcc(m + 1, 0);
	for (int i = 0; i < m; i++) bcc[i + 1] = b[i] + bcc[i];
	int ans = 0;
	for (int i = 0; i <= n; i++)
	{
		if (acc[i] > k) break ;
		int ok = 0;
		int ng = m + 1;
		while (abs(ok - ng) > 1)
		{
			int mid = (ok + ng) / 2;
			if (acc[i] + bcc[mid] <= k) ok = mid;
			else ng = mid;
		}
		ans = max(ans, i + ok);
	}
	cout << ans << endl;
	return (0);
}


Measured memory_bytes: 7936
import java.util.*;
public class Main{
    public static void main(String[] args){
	new Main().run();
    }
    Scanner sc = new Scanner(System.in);
    boolean[] prime;
    int n;
    int count;

    void run(){
	prime = new boolean[1000001];
	setPrime();
	while(sc.hasNext()){
	    n = sc.nextInt();
	    count = 0;
	    if(n!=0) solve();
	}
    }

    void solve(){
	for(int i=2; i<=n/2; i++){
	    if(prime[i] && prime[n-i])
		count++;
	}
	System.out.println(count);
    }

    void setPrime(){
	Arrays.fill(prime, true);
	prime[0] = prime[1] = false;
	for(int i=2; i<prime.length; i++){
	    for(int j=i+i; j<prime.length; j+=i){
		prime[j] = false;
	    }
	}
    }
}

Measured memory_bytes: 23132
#include "iostream"
#include <stdio.h>
#include <algorithm>
#include <stdlib.h>
#include <string>
#include <cctype>
#include <stack>
#include <vector>
#include <list>
#include <queue>
using namespace std;
using ll=long long;
#define mod  1000000007

int main(int argc, char const *argv[]) {
  int a,b;
  std::cin >> a >> b;
  if(a%3==0 || b%3==0 || (a+b)%3==0)printf("Possible\n");
  else printf("Impossible\n");
  return 0;
}

Measured memory_bytes: 256