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

void rc(int[], int[], int[], int, int, int);
static bool flag;

int main()
{
	int pre[41], in[41], revi[41], n;
	flag = false;
	scanf("%d", &n);
	for (int i = 1; i <= n; i++)
		scanf("%d", pre + i);
	for (int i = 1; i <= n; i++)
	{
		scanf("%d", in + i);
		revi[in[i]] = i;
	}

	rc(pre, in, revi, 1, n + 1, 1);
	printf("\n");

	return 0;
}

void rc(int pre[], int in[], int revi[], int ileft, int iright, int pleft)
{
	if (ileft < iright)
	{
		int imid = revi[pre[pleft]];
		rc(pre, in, revi, ileft, imid, pleft + 1);
		rc(pre, in, revi, imid + 1, iright, pleft + imid - ileft + 1);
		if (flag)
			printf(" ");
		else
			flag = true;
		printf("%d", pre[pleft]);
	}
	return;
}


Measured memory_bytes: 2720
#include <bits/stdc++.h>
 
using namespace std;
#define repr(i,a,b) for (int i=a; i<b; i++)
#define rep(i,n) for (int i=0; i< (int) n; i++)
#define PI  3.14159265358979323846264338327950
 
 
int main () {
    string S;
    cin >> S;

    vector<bool>mozi(26,false);

    for(int  i=0; S[i]!= '\0';i++){
        mozi[S[i]- 'a'] = true;
    }
    rep(i,26){
        if(!mozi[i]){
            cout << (char) (i+'a') << endl;
            return 0;
        }
    }
    cout << "None" << endl;
    return 0;

}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define all(v) v.begin(),v.end()
using namespace std;
typedef long long ll;
const ll INF=1000000010;
const ll MOD=1000000007;
const ll LINF=4000000000000000000;
const long double EPS=1e-9;
typedef pair<int,int> P;
int main(){
    int d,l;cin>>d>>l;
    cout<<(d/l)+(d%l)<<endl;
}   



Measured memory_bytes: 3100
#include <iostream>
    #include <algorithm>
    #include <vector>
    #include <string>
    #include <cstring>
    #include <cmath>
    #include <queue> 
    using namespace std;
     
    int a[300010];
    long long ls[300010], rs[300010];
    long long sum[300010];
     
    int main() {
    	int n; cin >> n;
    	for (int i = 1; i <= 3*n; i ++) cin >> a[i];
    	memset(ls, 0, sizeof(ls));
    	
    	priority_queue <int, vector<int>, greater<int> > pq_small;
    	long long sum = 0;
    	for (int i = 1; i <= 3*n; i ++) {
    		sum += a[i];
    		pq_small.push(a[i]);
    		while (pq_small.size() > n) {
    			sum -= pq_small.top();
    			pq_small.pop();
    		}
    		ls[i] = sum;
    	}
    	
    	sum = 0;
    	priority_queue <int> pq_big;
    	memset(rs, 0, sizeof(rs));
    	for (int i = 3*n; i > 0; i --) {
    		sum += a[i];
    		pq_big.push(a[i]);
    		while (pq_big.size() > n) {
    			sum -= pq_big.top();
    			pq_big.pop();
    		}
    		rs[i] = sum;
    	}
    	
    	long long ans = -1e18;
    	for (int i = n; i <= 2*n; i ++) 
    		ans = max(ans, ls[i] - rs[i+1]);
    	cout << ans << endl;
    	
    	return 0;
    }

Measured memory_bytes: 7544
import sys

N = int(input())
txy = [[int(i) for i in input().split()] for j in range(N)]

txy.insert(0, [0, 0, 0])

for i in range(1, N+1):
    t = txy[i][0] - txy[i-1][0]
    x = abs(txy[i][1] - txy[i-1][1])
    y = abs(txy[i][2] - txy[i-1][2])
    dis = x + y
    if dis > t:
        print('No')
        sys.exit()
    if (t - dis) % 2:
        print('No')
        sys.exit()

print('Yes')


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

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine();
            var dict = new Dictionary<char, int>();

            for (var i = 0; i < s.Length; i++)
            {
                if (dict.ContainsKey(s[i]))
                    dict[s[i]]++;
                else
                    dict[s[i]] = 1;
            }

            var max = dict.Values.Max();
            Console.WriteLine(max == 1 ? "yes" : "no");
        }
    }
}


Measured memory_bytes: 13280
from math import ceil

def f(x,h):
    hp = h
    hp = [hh-(b*x)  for hh in hp]
    count = 0
    for hh in hp:
        if hh <=0: continue
        count += ceil(hh/(a-b))
    return x >= count

n,a,b = map(int,input().split())
h = [int(input()) for i in range(n)]

ng = 0
ok = 10**9
while abs(ok-ng)>1:
    m = (ok+ng)//2
    if f(m,h):
        ok = m
    else:
        ng = m

print(ok)

Measured memory_bytes: 16936
/******************************************************************************

                            Online Java Compiler.
                Code, Compile, Run and Debug java program online.
Write your code in this editor and press "Run" button to execute it.

*******************************************************************************/
import java.io.*;
public class Main
{
	public static void main(String[] args) throws IOException{
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		//long a = System.currentTimeMillis();
		System.out.println(solve(Integer.parseInt(reader.readLine())));
		//long b = System.currentTimeMillis();
		//System.out.println(b-a);
		
	}
	public static boolean isPrime(int n){
	    if(n==2) return true;
	    if(n%2==0) return false;
	    else{
	        int i = 3;
	        while(i*i<=n){
	            if(n%i==0) return false;
	            i++;
	        }
	        return true;
	    }
	}
	public static int solve(int n){
	    if(isPrime(n)) return n;
	    else return solve(n+1); 
	}
}


Measured memory_bytes: 21204
#include<stdio.h>
int main()
{
    char str[4][4];
    int i;
            for(i=0; i<2; i++)
        scanf("%s",str[i]);
    if(str[0][0]==str[1][2]&&str[0][1]==str[1][1]&&str[0][2]==str[1][0])
        printf("YES\n");
    else
            printf("NO\n");
}


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

int main() {
  string A,x,C;
  cin >> A>>x>>C;
char c1 = A.at(0);
char c2 = x.at(0);
char c3 = C.at(0);
  cout << c1  << c2<<c3<< endl;

}


Measured memory_bytes: 256
//コンパイラ最適化用
#pragma GCC optimize("Ofast")

//インクルード(アルファベット順)
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<climits>//INT_MAXなど
#include<chrono>//実行時間計測
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm,accumulate
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//順序保持しないmap
#include<unordered_set>//順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;

// clang++ main.cc -std=c++11 -stdlib=libc++

/*
  cin >> N;
  vector<int> a(N);
  for (int i = 0; i < N; i++)
    cin >> a[i];
*/

signed main(){
  int N, M, C;
  cin >> N >> M >> C;

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

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

  int res = 0;
  for (int i = 0; i < N; i++) {
    int score = C;
    for (int j = 0; j < M; j++) {
      score += B[j] * A[i][j];
    }
    if (score > 0) res++;
  }
  cout << res << endl;

  return 0;
}

Measured memory_bytes: 3616
from copy import *
from sys import *
import math
import queue
from collections import defaultdict,Counter,deque
from fractions import Fraction as frac

setrecursionlimit(1000000)

#s[i] is linked with t[len(s)-i-1]
def main():
	n = int(input())
	d = list(map(int,input().split()))
	d.sort()
	print(max(d[n//2] - d[n//2-1],0))


def zip(a):
	mae = a[0]
	ziparray = [mae]
	for i in range(1,len(a)):
		if(mae != a[i]):
			ziparray.append(a[i])
			mae = a[i]
	return ziparray

def is_prime(n):
	if n < 2: return False

	for k in range(2, int(math.sqrt(n)) + 1):
		if n % k == 0:
			return False

	return True

def list_replace(n,f,t):
	return [t if i==f else i for i in n]

def base_10_to_n(X, n):
	X_dumy = X
	out = ''
	while X_dumy>0:
		out = str(X_dumy%n)+out
		X_dumy = int(X_dumy/n)
	if(out == ''): return '0'
	return out

def gcd(m,n):
	x = max(m,n)
	y = min(m,n)
	while(x%y!=0):
		z = x%y
		x = y
		y = z
	return y

class Queue():
	def __init__(self):
		self.q = deque([])
	def push(self,i):
		self.q.append(i)
	def pop(self):
		return self.q.popleft()
	def size(self):
		return len(self.q)
	def debug(self):
		return self.q

class Stack():
	def __init__(self):
		self.q = []
	def push(self,i):
		self.q.append(i)
	def pop(self):
		return self.q.pop()
	def size(self):
		return len(self.q)
	def debug(self):
		return self.q

class graph():
	def __init__(self):
		self.graph = defaultdict(list)
	def addnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].append(t)
		self.graph[t].append(f)
	def rmnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].remove(t)
		self.graph[t].remove(f)
	def linked(self,f):
		return self.graph[f]

class dgraph():
	def __init__(self):
		self.graph = defaultdict(set)
	def addnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].append(t)
	def rmnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].remove(t)
	def linked(self,f):
		return self.graph[f]

main()

Measured memory_bytes: 77136
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
#define int long long
#define double long double
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define ggr getchar();getchar();return 0;
#define prique priority_queue
constexpr auto mod = 1000000007;
#define inf 1e15
#define key 1e9
using namespace std;
typedef pair<int, int>P;
template<class T> inline void chmax(T& a, T b) {
	a = std::max(a, b);
}
template<class T> inline void chmin(T& a, T b) {
	a = std::min(a, b);
}
//combination(Nが小さい時はこれを使う
const int MAX = 330000;
int fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % mod;
		inv[i] = mod - inv[mod % i] * (mod / i) % mod;
		finv[i] = finv[i - 1] * inv[i] % mod;
	}
}

// 二項係数計算
long long COMB(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
bool prime(int n) {
	int cnt = 0;
	for (int i = 1; i <= sqrt(n); i++) {
		if (n % i == 0)cnt++;
	}
	if (cnt != 1)return false;
	else return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}

//繰り返し二乗法（Nが大きい時の場合のcombination)
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= (i % mod); res %= mod;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}
//UnionFind
class UnionFind {
protected:
	int* par, * rank, * size;
public:
	UnionFind(unsigned int size) {
		par = new int[size];
		rank = new int[size];
		this->size = new int[size];
		rep(i, size) {
			par[i] = i;
			rank[i] = 0;
			this->size[i] = 1;
		}
	}
	int find(int n) {
		if (par[n] == n)return n;
		return par[n] = find(par[n]);
	}
	void unite(int n, int m) {
		n = find(n);
		m = find(m);
		if (n == m)return;
		if (rank[n] < rank[m]) {
			par[n] = m;
			size[m] += size[n];
		}
		else {
			par[m] = n;
			size[n] += size[m];
			if (rank[n] == rank[m])rank[n]++;
		}
	}
	bool same(int n, int m) {
		return find(n) == find(m);
	}
	int getsize(int n) {
		return size[find(n)];
	}
};
int dight(int n) {
	int ans = 1;
	while (n >= 10) {
		n /= 10;
		ans++;
	}
	return ans;
}
int dight_sum(int n) {
	int sum = 0;
	rep(i, 20)sum += (n % (int)pow(10, i + 1)) / (pow(10, i));
	return sum;
}
int dight_min(int n) {
	int ans = 9;
	while (n >= 10) {
		ans = min(ans, n % 10);
		n /= 10;
	}
	ans = min(ans, n);
	return ans;
}
int dight_max(int n) {
	int ans = 0;
	while (n >= 10) {
		ans = max(ans, n % 10);
		n /= 10;
	}
	ans = max(ans, n);
	return ans;
}
signed main() {
	int a, b;
	cin >> a >> b;
	double q = a, r = b;
	double p = q / r;
	cout << a / b << " " << a % b << " ";
	cout << fixed << setprecision(10) << p << endl;
	ggr
}



Measured memory_bytes: 3288
#include<stdio.h>
#include<math.h>
#include<stdlib.h>

int main(void){
	int a,b,c,d;
	double r,l;

	scanf("%d %d %d %d",&a,&b,&c,&d);

	do{
		if( c - b <=0){
			printf("Yes\n");
			break;
		}
		c -= b;
		if( a - d <=0){
			printf("No\n");
			break;
		}
		a -= d;
	}while(1);

	return 0;
}

Measured memory_bytes: 1648
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <iomanip>
#include <map>
#include <set>
#include <list>
#include <limits>
#include <numeric>
#include <utility>
#include <deque>
#include <valarray>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#include <array>
#include <bitset>
#include <complex>
#include <string>
#include <tuple>

using namespace std;
using ll = long long;
const int INF = 1e9;
const ll MOD = 1e9 + 7;

int main()
{
  int n;
  cin >> n;
  vector<pair<string, pair<int, int>>> v(n);
  for (int i = 0; i < n; ++i)
  {
    cin >> v[i].first >> v[i].second.first;
    v[i].second.first *= -1;
    v[i].second.second = i + 1;
  }
  sort(v.begin(), v.end());
  for (auto &e : v)
    cout << e.second.second << endl;

  return 0;
}


Measured memory_bytes: 256
using namespace std;
#define _CRT_SECURE_NO_WARNINGS
#pragma target("avx")
#pragma optimize("O3")
#pragma optimize("unroll-loops")
#include<iostream>
#include<algorithm>
#include<ctime>
#include<vector>
#include<string>
#include<cmath>
#include<map>
#include<iomanip>
#include<numeric>
#include<queue>
#include<deque>
#include<cfloat>
#include<functional>
#include<tuple>
#include<math.h>
#include<bitset>
#include<stack>
#include<set>
#include<random>
#include<stdlib.h>
#define rip(i,n) for(ll i=0;i<n;i++)
#define Rip(i,n) for(ll i=1;i<n;i++)
#define all(V) V.begin(),V.end()
#define ll long long
#define ld long double
#define MOD 998244353
#define mod MOD
#define sec setprecision
constexpr double eps = 1e-9;
constexpr double PI = 3.141592653589793238462643383279;
ll gcd(ll a, ll b) {
	if (a % b == 0)	return(b);
	else return(gcd(b, a % b));
}
ll lcm(ll a, ll b)
{
	return a * b / gcd(a, b);
}
const int MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];
void cominit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (ll i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}
vector<ll> soinnsuubunnkai(ll n) {
	vector<ll>a;
	while (n % 2 == 0) {
		a.push_back(2);
		n /= 2;
	}
	ll f = 3;
	while (f * f <= n) {
		if (n % f == 0) {
			a.push_back(f);
			n /= f;
		}
		else f += 2;
	}
	if (n != 1)
		a.push_back(n);
	return(a);
}
// 二項係数計算
long long com(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
ll pow(ll a, ll b) {
	a = a % mod;
	if (b == 0)return(1);
	else if (b % 2 == 0)return(pow((a * a) % mod, b / 2));
	else return(a * (pow(a, b - 1)));
}
void solve() {
    int n;
	cin >> n;
	ld p = 1;
	ld s = 2;
	ld r = n; ld i = (n / 2) + 1;
	if (n % 2 == 0)cout << fixed << sec(20) << p / s << endl;
	else cout << fixed << sec(20) << i / r << endl;
}
int main() {
	solve();
}

Measured memory_bytes: 256
s=input()
t=list(set(s))
if len(t)==2:
  cnt1=0
  cnt2=0
  for i in s:
    if i==t[0]:
      cnt1+=1
      
    elif i==t[1]:
      cnt2+=1
      
  if cnt1==2 and cnt2==2:
    print('Yes')
    exit()
    
print('No')
    

Measured memory_bytes: 2940
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <limits>

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

using namespace std;

int rint() {
  int n;
  scanf("%lld", &n);
  return n;
}

void wint(int n) {
  printf("%lld\n", n);
}

signed main() {
  const int V = rint();
  const int E = rint();
  double dp[V][V];
  dotimes(s, V)
    dotimes(t, V)
      dp[s][t] = s == t ? 0 : numeric_limits<double>::infinity();
  dotimes(i, E) {
    int s = rint();
    int t = rint();
    dp[s][t] = static_cast<double>(rint());
  }
  dotimes(k, V) dotimes(i, V) dotimes(j, V)
    dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j]);
  dotimes(i, V)
    if (dp[i][i] < 0.0) {
      puts("NEGATIVE CYCLE");
      return 0;
    }
  dotimes(s, V) dotimes(t, V) {
    if (::isinf(dp[s][t]))
      printf("INF");
    else
      printf("%lld", static_cast<int>(dp[s][t]));
    putchar(t == V - 1 ? '\n' : ' ');
  }
  return 0;
}



Measured memory_bytes: 2808
N = int(input())
X = list(map(int, input().split()))

ans = 10**9
for i in range(max(X)+1):
    tmp = 0
    i += 1
    for j in range(N):
        tmp += pow(X[j] - i, 2)
        # print(X[j])
    # print(tmp)
    if tmp < ans:
        ans = tmp

print(ans)

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

// pより西の花の総数がK以上であるか判定する関数
// 最大でcount=N*p(N<=1e5, p<=2e18) なのでオーバーフロー対策が必要
bool check(long long p, long long K, const vector<long long>& w, const vector<long long>& d) {
  int N = (int)w.size();
  long long count = 0;
  // 各花iのpより西にある数を求める
  for (int i = 0; i < N; i++) {
    if (p >= w[i]) {
      count += (p - w[i]) / d[i] + 1; // w[i]から，d[i]間隔であるので，d[i]で割れば良い
      if (count >= K) return true;    // オーバーフロー対策
    }
  }
  return count >= K;
}

int main(void) {
  long long N, K;
  cin >> N >> K;
  vector<long long> w(N), d(N);
  for (int i = 0; i < N; i++) {
    cin >> w[i] >> d[i];
  }

  long long ng = 0;
  long long ok = 2e18; // ok側の最大値を見積もる
                       // 1つの花が10^18の位置から10^9間隔であると
                       // K=10^9番目の位置は，10^18 + (10^9 * 10^9)となる → 2e18
  // 二分探索
  while (abs(ok - ng) > 1) {
    long long mid = (ok + ng) / 2;
    if (check(mid, K, w, d)) {
      ok = mid;  // Kを超えていればok側を縮める
    }
    else {
      ng = mid;
    }
  }
  cout << ok << endl;
  return 0;
}

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

int main() {
    string S;
    cin >> S;
    int res = 1001001001;
    for(int i=0; i+2<S.size(); ++i) {
        stringstream ss;
        ss << S.substr(i, 3);
        int tmp;
        ss >> tmp;
        res = min(res, abs(tmp - 753));
    }
    cout << res << endl;
}

Measured memory_bytes: 256
use std::io;
use std::cmp;
use std::collections::BinaryHeap;
use std::collections::HashMap;
use std::collections::HashSet;
use std::f64::consts::PI;

fn read_line() -> String {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).ok();
    buf
}

fn calc(a: &Vec<usize>, qs: &Vec<(usize,usize,usize,usize)>) -> usize {
    let mut res = 0;
    for &q in qs.iter() {
        if a[q.1] -  a[q.0] == q.2 {
            res += q.3;
        }
    }

    res
}

fn next(a: &mut Vec<usize>, m: usize) -> bool {
    for i in (0..a.len()).rev() {
        if a[i] < m {
            a[i] += 1;
            for j in i+1..a.len() {
                a[j] = a[i];
            }

            return true;
        }
    }
    false
}


fn main() {
    let line: Vec<usize> = read_line().split_whitespace().map(|s| s.parse().unwrap()).collect();
    let n = line[0];
    let m = line[1];
    let q = line[2];
    let mut qs = Vec::new();
    for i in 0..q {
        let line: Vec<usize> = read_line().split_whitespace().map(|s| s.parse().unwrap()).collect();
        let a = line[0]-1;
        let b = line[1]-1;
        let c = line[2];
        let d = line[3];

        qs.push((a,b,c,d));
    }

    let mut a = vec![1; n];
    let mut ans = 0;
    loop {

        ans = cmp::max(ans, calc(&a, &qs));
        if !next(&mut a, m) {
            break;
        }
    }

    println!("{}", ans);
}


Measured memory_bytes: 2172
import java.util.*;

class Main {
    static int mod = 1000000007;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long l[] = new long[n];
        for (int i=0; i<n; i++) {
            l[i] = sc.nextLong();
        }

        int ones[] = new int[60];
 
        for (int i=0; i<n; i++) {
            long x = l[i];
            for (int j=0; j<60; j++) {
                if (((x>>j)&1)==1) {
                    ones[j] ++;
                }
            }
        }
        long ans = 0;
        long base = 1;
        for (int j=0; j<60; j++) {
            long tmp = (long) (n-ones[j])*ones[j] % mod;
            ans += tmp * base % mod;
            ans %= mod;
            base *= 2;
            base %= mod;
        }
        System.out.println(ans);
        sc.close();
    }
}

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

#define SZ(x) (int)((x).size())
#define xx first
#define yy second
#define pii pair<int, int>

const int N = 101;

int a[N];

void solve() {
    int n;
    cin >> n;
    for (int i = 0; i < n; i++)
        cin >> a[i];
    int ans = 0;
    sort(a, a + n);
    for (int i = 0; i < n; i++)
        for (int j = i + 1; j < n; j++)
            for (int k = j + 1; k < n; k++) {
                if (a[i] == a[j]) continue;
                if (a[j] == a[k]) continue;
                if (a[k] == a[i]) continue;
                if (a[i] + a[j] > a[k])
                    ans++;
            }
    cout << ans << '\n';
}
int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    // int _; cin >> _; while (_--)
    solve();
    return 0;
}


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

using namespace std;

int main() {
	int N, T, A;
	cin >> N >> T >> A;
	double best = numeric_limits<double>::max();
	int besti = 0;
	for (auto i = 1; i <= N; ++i) {
		int H;
		cin >> H;
		auto d = abs(A - (T - H * 0.006));
		if (d < best) {
			best = d;
			besti = i;
		}
	}
	cout << besti;
}

Measured memory_bytes: 256
#!/usr/bin/env python
import sys

def _i(): return int(sys.stdin.readline().strip())
def _s(): return sys.stdin.readline().strip()

n = _i()
s = _s()

cnt=0
for i in range(100):
    a = str(i//10)
    b = str(i%10)
    #
    try: j = s.index(a)+1
    except: continue
    if j==n: continue
    #
    try: k = s.index(b,start=j)+1
    except: continue
    if k==n: continue
    #
    ss= s[k:]
    for i in "0123456789":
        if i in ss: cnt+=1
#
print(cnt)


Measured memory_bytes: 38676
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define GET_ARRAY_SIZE(a)   (sizeof(a)/sizeof(a[0]))
#define LL long long
LL facctorialMethod(int k);
int main(){
//襲われる場合  ->unsafe
//襲われない場合->safe
    LL s,w;
    cin >> s >> w;
    if(s > w) cout << "safe" << endl;
    else cout << "unsafe" << endl;

    return 0;
}

LL facctorialMethod(int k){
    int sum = 1;
    for (int i = 1; i <= k; ++i){
        sum *= i;
    }
    return sum;
}


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

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rep2(i, a, b) for (ll i = (a); i < (b); i++)
typedef uint64_t ull;
typedef int64_t ll;
typedef std::pair<ll, ll> PLL;

using namespace std;

signed main() {
  ll N;
  string s;
  cin >> N >> s;

  ll i=0,ans=0;
  while(i<N) {
    ll j = i+1;
    while(j<N && s[j] == s[i])
      j++;
    ans++;
    i = j;
  }
  cout << ans << endl;
}


Measured memory_bytes: 512
A, B, C, D = map(int, input().split())

alice = [1 if A <= t < B else 0 for t in range(0, 110)]
bob = [1 if C <= t < D else 0 for t in range(0, 110)]

overlap = [1 for a, b in zip(alice, bob) if a > 0 and b > 0]

print(len(overlap))


Measured memory_bytes: 9188
N=int(input())
S=input()
n=int(len(S))
l=int(n/2)
a=""
b=""
if n%2==0:
    for i in range(l):
        a+=S[i]
    for i in range(l,n):
        b+=S[i]
    if a==b:
        print("Yes")
    else:
        print("No")
else:
    print("No")


Measured memory_bytes: 3064
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <queue>
#include <sstream>
#include <stack>
#include <time.h>
#include <vector>
#include <complex>
#include <map>
#include <set>
#include <iomanip>
#include <math.h>
#include <stdlib.h>
#include <list>
#include <utility>
#include <memory>
#include <cstring>
#include <fstream>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <ios> 
#include <bits/stdc++.h>
using namespace std;
int n;
string s[10004];
int d[3],ans=0;
int main(){
	cin>>n;
	for (int i=0;i<n;i++){
		cin>>s[i];
		for (int j=0;j<s[i].size()-1;j++)
			if (s[i].substr(j,2)=="AB")
				ans++; 
		if (s[i][0]=='B' && s[i][s[i].size()-1]=='A') d[0]++;
		else if (s[i][0]=='B') d[1]++;
		else if (s[i][s[i].size()-1]=='A') d[2]++;
	}
	if (d[0]){
		ans+=d[0]-1;
		if (d[1]) ans++,d[1]--;
		if (d[2]) ans++,d[2]--;
		ans+=min(d[1],d[2]);
	}
	else if (d[1] && d[2])ans+=min(d[1],d[2]);
	cout<<ans;
}

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

int n;
const int MAX_N = 1000001;
vector<int> d(MAX_N); //添字が入力された回数

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

int main() {
  cin >> n;
  vector<int> a(n);
  
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    d[a[i]]++;
  }
  
  bool pairwise = true;
  for (int i = 2; i <= MAX_N; i++) {
    int cnt = 0;
   	for (int j = i; j <= MAX_N; j += i) {
      cnt += d[j];
    }
    
    if (cnt > 1) {
      pairwise = false;
      break;
    }
  }
  
  if (pairwise) {
    cout << "pairwise coprime";
    return 0;
  }
  
  int g = 0;
  for (int i = 0; i < n; i++) {
    g = gcd(a[i], g);
  }
  
  if (g == 1) {
    cout << "setwise coprime";
    return 0;
  }
  
  cout << "not coprime";
  return 0;
}

Measured memory_bytes: 10688
#include <bits/stdc++.h>
using namespace std;
#define int         long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define sd(t)       scanf("%d",&(t))
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define hii         cout << "hii" << endl
#define okay        cout << "okay" << endl
#define hey         cout << "hey" << endl
const int INF = 1e16;
const int MOD = 998244353;
const int mod = 1e9+7;


template <class T> ostream& operator << (ostream &os, const vector<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T> ostream& operator << (ostream &os, const set<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T, class S> ostream& operator << (ostream &os, const pair<T, S> &v) { os << v.x << ' ' << v.y; return os; }
template <class T, class S> ostream& operator << (ostream &os, const unordered_map<T, S> &v) { for (auto i : v) os << '(' << i.x << "=>" << i.y << ')' << ' '; return os; } 
 
 
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <class Arg1> void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 << endl; }
    template <class Arg1, class... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args) {
        const char* sep = strchr(names + 1, ',');
        cerr.write(names, sep - names) << " : " << arg1 << "  ";
        __f(sep + 1, args...);
    }
#else
#define trace(...) 
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("avx2,sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS
#endif // ifndef ONLINE_JUDGE


clock_t time_p=clock();
void starboy1299()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}

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

inline int mul(int a, int b, int m = mod) { return (a * b) % m; }
inline int add(int a, int b, int m = mod) { return (a + b) % m; }
inline int sub(int a, int b, int m = mod) { return (a - b + m) % m; }

const int N = 2e5+5;

void solve()
{
    string s;
    cin >> s;
    string ans = s.substr(0, 3);

    cout << ans << endl;
}                            

int32_t main(){
    fast();
    int t = 1;
    // cin>> t;
    for(int i=1; i<=t; i++){
        // cout << "Case #" << i << ": ";
        solve();
    }
    starboy1299();
}

Measured memory_bytes: 3844
//
//  main.cpp
//  ABC167E
#include <iostream>
#include <cassert>
#include <vector>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
//const int mod = 1000000007;
const int mod = 998244353;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
//istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

// Combination
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
}c(200005); // ←これを追記する
// 使い方
// nCxなら c(n,x) とする
int main(int argc, const char * argv[]) {
    int n,m,k;
    cin >> n >> m >> k;
    mint ans=0;
    mint col=m;
    mint combi=0;
    for(int x=n-1;x>=0;--x){ // xはグループ数
        mint now=col;
        combi=c(n-1,x); // combination
        now *= combi;
        if (x <= k) {
            ans+=now;
        }
        col *= m-1;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 5824
import sys
sys.setrecursionlimit(2**25)

n = int(input())
pre_ls = list(map(int, input().split()))
in_ls = list(map(int, input().split()))

pos = 0
post_ls = []

def rec(left: int, right: int):
    global pos
    if left >= right:
        return
    tmp_root = pre_ls[pos]
    pos += 1
    mid = in_ls.index(tmp_root)
    # 右部分木->左部分木->根の後方順巡回になっている
    rec(left, mid)
    rec(mid+1, right)
    post_ls.append(tmp_root)


def solve():
    pos = 0
    rec(0, len(pre_ls))
    print(*post_ls)
solve()


Measured memory_bytes: 5604
#include <stdio.h>
 int main (void){
int a ,b ;
scanf("%d\n",&a) ;
scanf("%d\n",&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: 584
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<functional>
using namespace std;

int main() {
	int a;
	while (cin >> a, a) {
		bool b[99][99]{};
		int c[100][100]{};
		int d, e; cin >> d >> e;
		for (int f = 0; f < a; f++) {
			int g, h;
			scanf("%d%d", &g, &h);
			g--; h--;
			b[g][h] = true;
		}
		for (int f = 1; f <= d; f++) {
			for (int g = 1; g <= e; g++) {
				c[f][g] = c[f - 1][g] + c[f][g - 1] - c[f - 1][g - 1];
				if (b[f - 1][g - 1])c[f][g]++;
			}
		}
		int MAX = 0;
		int x, y; cin >> x >> y;
		for (int f = 0; f <= d-x; f++) {
			for (int g = 0; g <= e-y; g++) {
				MAX = max(MAX, c[f + x][g + y] - c[f + x][g] - c[f][g + y] + c[f][g]);
			}
		}
		cout << MAX << endl;
	}
}

Measured memory_bytes: 3056
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define f(i,x,n) for(int i=x;i<n;i++)
#define all(c) c.begin(),c.end()
#define int ll
#define print(x) cerr << (#x) << "is "<< x << "\n"
using ll = long long;
using ld = long double;
using pii = pair<int,int>;
const int MOD = 1e9+7, N = 50 + 10;
 
int a[N],sum[N];
 
int32_t main(){
   ios::sync_with_stdio(false);
   cin.tie(NULL);
   int n;
   cin >> n;
   multiset<ld> s;
   f(i,0,n){
      int x;
      cin >> x;
      s.insert(x);
   }
   while(s.size()!=1){
      ld x = *s.begin();
      s.erase(s.begin());
      ld y = *s.begin();
      s.erase(s.begin());
      s.insert((x+y)/2);
   }
   cout << *s.begin() << '\n';
   return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 2147483647
#define INF_LL 9223372036854775807
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

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

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define all(v) begin(v), end(v)
#define pb(a) push_back(a)
#define fr first
#define sc second
#define INF 2000000000
#define int long long int

#define X real()
#define Y imag()
#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) ( EQ((a).X, (b).X) && EQ((a).Y, (b).Y) )
#define LE(n, m) ((n) < (m) + EPS)
#define LEQ(n, m) ((n) <= (m) + EPS)
#define GE(n, m) ((n) + EPS > (m))
#define GEQ(n, m) ((n) + EPS >= (m))

typedef vector<int> VI;
typedef vector<VI> MAT;
typedef pair<int, int> pii;
typedef long long ll;

typedef complex<double> P;
typedef pair<P, P> L;
typedef pair<P, double> C;

int dx[]={1, -1, 0, 0};
int dy[]={0, 0, 1, -1};
int const MOD = 1000000007;
ll mod_pow(ll x, ll n) {return (!n)?1:(mod_pow((x*x)%MOD,n/2)*((n&1)?x:1))%MOD;}
int madd(int a, int b) {return (a + b) % MOD;}
int msub(int a, int b) {return (a - b + MOD) % MOD;}
int mmul(int a, int b) {return (a * b) % MOD;}
int minv(int a) {return mod_pow(a, MOD-2);}
int mdiv(int a, int b) {return mmul(a, minv(b));}

namespace std {
    bool operator<(const P& a, const P& b) {
        return a.X != b.X ? a.X < b.X : a.Y < b.Y;
    }
}

int n, l, q;
int x[100010];
int table[100010][20];
signed main() {
    cin >> n;
    rep(i,0,n) cin >> x[i];
    cin >> l >> q;
    int cur = 0;
    rep(i,0,n) table[i][0] = upper_bound(x, x+n, x[i]+l) - x - 1;
    rep(j,1,20) rep(i,0,n) {
        table[i][j] = table[table[i][j-1]][j-1];
        // printf("table[%lld][%lld] = %lld\n", i, j, table[i][j]);
    }
    rep(i,0,q) {
        int a, b; cin >> a >> b;
        a--; b--;
        if(a > b) swap(a, b);
        int ans = 1, idx = a;
        repr(j,19,0) {
            if(table[idx][j] < b) {
                idx = table[idx][j];
                ans += (1 << j);
            }
        }
        cout << ans << endl;
    }
    return 0;
}

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

import re
a = []
b = []
for i in range(5):
    x = int(input())
    a.append(x)
    x = x%10
    b.append(x)

count = 0
min = 123
k = 0
for i in range(5):
    if(b[i] != 0 and min > b[i]):
        min = b[i]
        k = i

for i in range(5):
    if(i != k and b[i] != 0):
        count += a[i] + 10 - b[i]
    elif(i == k or b[i] == 0):
        count += a[i]
print(count)


Measured memory_bytes: 3188
#include <bits/stdc++.h>
#include <string.h>
//#include <queue>
using namespace std;
#define ll long long
#define ld long double
#define itvector(it,x) for(auto it:x)
#define FOR(x,a,b) for(int x=a; x<=b ;++x)
#define FOD(x,a,b) for(int x=a; x>=b ;--x)
//#define Phuong // <3 love my GF
// still learning :C; can't even do Div 2 C and D
// this is so sad
typedef pair<int,int> ii;

int main()
{
#ifdef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
#endif // ONLINE_JUDGE
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    int n;
    cin >> n;
    vector<int> a(n+1);
    FOR(i,0,n) cin >>a[i];
    ll res=0;
    FOR(i,0,n-1)
    {
        int k;
        cin >> k;
        if (a[i]<=k)
        {
            res+=a[i];
            k-=a[i];
        } else
        {
            res+=k;
            k=0;
        }
        if (a[i+1]<=k)
        {
            res+=a[i+1];
            a[i+1]=0;
        } else
        {
            res+=k;
            a[i+1]-=k;
        }
    }
    cout << res;
    return(0);
}


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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))
#define sz(v) ((int) v.size())

using namespace std;

using i64 = long long;
using f80 = long double;
using vi32 = vector<int>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << endl; exit(0); }
inline void no() { cout << "No" << endl; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); return a / gcd(a, b) * b; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { x = max(x, y); }
template <typename T> inline void amin(T &x, T y) { x = min(x, y); }
template <typename T> inline T exp(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }



void solve() {
  int n, a, b;
  cin >> n >> a >> b;
  vi64 v(n);
  cin >> v;
  sort(all(v));
  reverse(all(v));
  if (v[0] != v[a - 1]) {
    int k = 0;
    int x = 0;
    rep(i, n) k += v[a - 1] == v[i];
    rep(i, a) x += v[a - 1] == v[i];
    i64 ans = 1;
    reps(i, x) {
      ans *= k - i + 1;
      ans /= i;
    }
    f80 val = 0;
    rep(i, a) val += v[i];
    cout << val / a << endl;
    cout << ans << endl;
    return;
  }
  int k = 0;
  rep(i, n) k += v[i] == v[0];
  i64 ans = 0;
  repic(i, a, min(b, k)) {
    i64 temp = 1;
    reps(j, min(i, k - i)) {
      temp *= k - j + 1;
      temp /= j;
    }
    ans += temp;
  }
  f80 val = 0;
  rep(i, a) val += v[i];
  cout << val / a << endl;
  cout << ans << endl;
}


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

public class RecerseSequence
{
	public static void Main(string[] args)
	{
		char[] inputChar = Console.ReadLine().ToCharArray();
		StringBuilder sb = new StringBuilder();
		for (int i = inputChar.Length; i > 0; i--)
		{
			sb.Append(inputChar[i - 1]);
		}
		Console.WriteLine(sb.ToString());
	}
}

Measured memory_bytes: 5292
S=input()
i=3
while i<=len(S):
    if i==3:
        if S[-3:]=="eam":
            i+=2
            if S[-i:-i+2]=="dr":
                i+=3
            else:
                print("NO")
                break
        elif S[-3:]=="mer":
            i+=4
            if S[-i:-i+4]=="drea":
                i+=3
            else:
                print("NO")
                break
        elif S[-3:]=="ase":
            i+=2
            if S[-i:-i+2]=="er":
                i+=3
            else:
                print("NO")
                break
        elif S[-3:]=="ser":
            i+=3
            if S[-i:-i+3]=="era":
                i+=3
            else:
                print("NO")
                break
        else:
            print("NO")
            break
    else:
        if S[-i:-i+3]=="eam":
            i+=2
            if S[-i:-i+2]=="dr":
                i+=3
            else:
                print("NO")
                break
        elif S[-i:-i+3]=="mer":
            i+=4
            if S[-i:-i+4]=="drea":
                i+=3
            else:
                print("NO")
                break
        elif S[-i:-i+3]=="ase":
            i+=2
            if S[-i:-i+2]=="er":
                i+=3
            else:
                print("NO")
                break
        elif S[-i:-i+3]=="ser":
            i+=3
            if S[-i:-i+3]=="era":
                i+=3
        
        else:
            print("NO")
            break
else:
    print("YES")

Measured memory_bytes: 3444
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using static MyIO;


public class A
{
	public static void Main() => (new Solver()).Solve();
}


public class Solver
{
	public void Solve()
	{
		string S = GetString();

		int N = S.Length + 1;
		long[] l = new long[N];
		for(int i = 0; i < N - 1; i++)
		{
			if(S[i] == '<')
				l[i + 1] = l[i] + 1;
		}

		long[] g = new long[N];
		for(int i = N - 2; i >= 0; i--)
		{
			if(S[i] == '>')
				g[i] = g[i + 1] + 1;
		}

		long sum = 0;
		for(int i = 0; i < N; i++)
			sum += Math.Max(l[i], g[i]);

		Console.WriteLine(sum);
	}
}


public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt() => int.Parse(getArg());
	public static long GetLong() => long.Parse(getArg());
	public static double GetDouble() => double.Parse(getArg());
	public static string GetString() => getArg();
	public static char GetChar() => getArg()[0];
	public static int[] GetInts(int N) => Enumerable.Range(0, N).Select(_ => GetInt()).ToArray();
	public static long[] GetLongs(int N) => Enumerable.Range(0, N).Select(_ => GetLong()).ToArray();
	public static double[] GetDoubles(int N) => Enumerable.Range(0, N).Select(_ => GetDouble()).ToArray();
	public static string[] GetStrings(int N) => Enumerable.Range(0, N).Select(_ => GetString()).ToArray();
}


Measured memory_bytes: 20704
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
#define endl '\n'
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;}
template<class T> inline void printv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << (i == n - 1 ? endl : ' ');}
template<class T> inline void printlnv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << endl;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    ll a, b;
    cin >> a >> b;
    REP(i, 2000) {
        if (i * 8 / 100 == a && i * 10 / 100 == b) {
            cout << i << endl;
            return;
        }
    }
    cout << -1 << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,tui;
	cin>>n>>tui;
    for(int i=0;i<=n;i++)
    {
    	int s=n-i;
    	if(i*2+s*4==tui)
    	{
    		cout<<"Yes";
    		return 0;
		}
	}
    for(int i=0;i<=n;i++)
    {
    	int s=n-i;
    	if(i*4+s*2==tui)
    	{
    		cout<<"Yes";
    		return 0;
		}
	}
	cout<<"No";
	return 0;	
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main()
{
    string S;
    cin >> S;
    int sum{};
    REP( i, (int)S.size() )
    {
        sum += abs( '0' - S[ i ] );
    }
    int N = stoi( S );
    cout << ( N % sum == 0 ? "Yes" : "No" ) << endl;
    return 0;
}

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

using namespace std;

const int max_n = 200000;
int n;
int a[max_n + 1];

int main(){
  cin >> n;
  // for (int i = 0; i < n; i++) cin >> a[i];

  // int map[max_n+1] = {0};
  // vector<int> map(max_n+1, 0);
  map<long long, int> M;

  long long counter = 0;
  for(int i = 0; i < n; i++){
    int a;
    cin >> a;
    counter += M[i-a];
    M[i+a] ++;
  }

  cout << counter << endl;


  return 0;
}

Measured memory_bytes: 26164
Scanf.scanf "%d %d" (fun x y ->
    let a2 = 4 * x - y in
    let b2 = y - 2 * x in

    print_endline @@ if a2 mod 2 = 0 && b2 mod 2 = 0 && a2 >=0 && b2 >= 0 then "Yes" else "No"
)

Measured memory_bytes: 3724
var lines = [];
var readline = require('readline');

var rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout,
});

rl.on('line', function (x) {
    lines.push(x);
});

rl.on('close', function () {
    var N = Number(lines[0].split(" ")[0]);
    var X = lines[1].split(" ").map(i => Number(i));
    var ans = 0;

    var x = X.concat().sort((a, b) => a - b);

    // 削除するX[i]がx[N/2]以下なら，中央値はx[N/2]
    // 削除するX[i]がx[N/2]以上なら，中央値はx[N/2-1]
    for (var i = 0; i < N; i++) {
        if (X[i] < x[N / 2]) { ans = x[N / 2] }
        else { ans = x[N / 2 - 1] }

        console.log(ans)
    }
});

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

int main(){
  int H,W;
  cin >> H >> W;
  if (H%3==0||W%3==0){
    cout << 0 << endl;
  }
  else {
    cout << min(min(min(min(min(H,W),H*((W+2)/3)-(H/2)*((2*W)/3)),W*((H+2)/3)-(W/2)*((2*H)/3)),abs(H*((W+2)/3-1)-((H+1)/2)*((2*W)/3+1))),abs(W*((H+2)/3-1)-((W+1)/2)*((2*H)/3+1)));
  }
}

Measured memory_bytes: 256