akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i, n) for (ll i=0; i<n; ++i)
#define all(obj) (obj).begin(),(obj).end()
using namespace std;
typedef long long ll;
long long GCD(long long x, long long y) { return y ? GCD(y, x%y) : x; }

int main(){
    ll X, t;
    cin >> X >> t;
    cout << max(X-t, (ll)0) << endl;
    return 0;
}


Measured memory_bytes: 3568
""" B
    https://atcoder.jp/contests/m-solutions2020/tasks/m_solutions2020_b
"""
import sys
import math
from functools import reduce
from bisect import bisect_left

def readString():
    return sys.stdin.readline()

def readInteger():
    return int(readString())

def readStringSet(n):
    return sys.stdin.readline().split(" ")[:n]

def readIntegerSet(n):
    return list(map(int, readStringSet(n)))

def readIntegerMatrix(n, m):
    return reduce(lambda acc, _: acc + [readIntegerSet(m)], range(0, n), [])

def main(A, B, C, K):
    while A >= B:
        if K == 0:
            return "No"
        B *= 2
        K -= 1
    while B >= C:
        if K == 0:
            return "No"
        C *= 2
        K -= 1

    return "Yes"

if __name__ == "__main__":
    _A, _B, _C = readIntegerSet(3)
    _K = readInteger()

    print(main(_A, _B, _C, _K))

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

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define st first
#define nd second
#define endl '\n'
#define int long long
// #define pow mypow
#define mp make_pair

typedef pair<int,int> pii;
const int N = 2e5+5;
const int INF = 1e9+5;
const int MOD = 1e9+7;

int n, d, a;
pii m[N];
int Tree[4*N], Lazy[4*N];

void build(int node, int st, int en){
    if (st == en) {
        Tree[node] = m[st].nd;
        return;
    }
    build(2*node, st, (st+en)/2);
    build(2*node+1, (st+en)/2+1, en);
    Tree[node] = Tree[2*node] + Tree[2*node+1];
}

int get(int node, int st, int en, int L, int R) {
    if (Lazy[node] != 0) {
        Tree[node] += (en-st+1)*Lazy[node];
        if (st != en){
            Lazy[2*node] += Lazy[node];
            Lazy[2*node+1] += Lazy[node];
        }
        Lazy[node] = 0;
    }
    if (en < L || st > R) return 0;
    if (st >= L && en <= R) return Tree[node];
    int p1 = get(2*node, st, (st+en)/2, L, R);
    int p2 = get(2*node+1, (st+en)/2+1, en, L, R);
    return (p1+p2);
}

void update(int node, int st, int en, int L, int R, int v) {
    if (Lazy[node] != 0) {
        Tree[node] += (en-st+1)*Lazy[node];
        if (st != en) {
            Lazy[2*node] += Lazy[node];
            Lazy[2*node+1] += Lazy[node];
        }
        Lazy[node] = 0;
    }
    if (en < L || st > R) return;
    if (st >= L && en <= R) {
        Tree[node] += (en-st+1)*v;
        if (st != en) {
            Lazy[2*node] += v;
            Lazy[2*node+1] += v;
        }
        return;
    }
    update(2*node, st, (st+en)/2, L, R, v);
    update(2*node+1, (st+en)/2+1, en, L, R, v);
    Tree[node] = Tree[2*node] + Tree[2*node+1];
}

int32_t main()
{
    IOS
    // freopen("input.txt", "r", stdin);
    
    cin >> n >> d >> a;
    for(int i=0; i<n; i++) cin >> m[i].st >> m[i].nd;
    sort(m, m+n);
    build(1, 0, n-1);
    int left_most = 0;
    int ans = 0;
    while(left_most < n) {
        if (get(1, 0, n-1, left_most, left_most) <= 0) {
            left_most++;
            continue;
        }
        int upto = upper_bound(m, m+n, mp(m[left_most].st + 2*d, INF)) - m - 1;
        int lm_power = get(1, 0, n-1, left_most, left_most);  //left_most power
        int times = lm_power / a + (lm_power % a != 0);
        ans += times;       
        update(1, 0, n-1, left_most, upto, -a*times);
    }
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 15872
#include<bits/stdc++.h>
//cervello|Phoenix
using namespace std;
#define ll long long int
#define eb emplace_back
#define mk make_pair
#define all(x) x.begin(),x.end()
#define mod 1000000007

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int x; cin>>x;
  if(x>=30)
    cout<<"Yes\n";
  else
    cout<<"No\n";
  return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
const int MOD=1e9+7;


int main() {
    int x,y;
    cin >> x >> y;
    vector<int> c(3);
    vector<ll> p,q,r;
    rep(i,3) cin >> c[i];
    rep(j,c[0]) {
        int in;
        cin >> in;
        p.push_back(in);
    }
    rep(j,c[1]) {
        int in;
        cin >> in;
        q.push_back(in);
    }
    rep(j,c[2]) {
        int in;
        cin >> in;
        r.push_back(in);
    }
    sort(p.begin(),p.end());
    sort(q.begin(),q.end());
    sort(r.begin(),r.end());
    vector<ll> tp(c[0]+1),tq(c[1]+1),tr(c[2]+1);
    rep(i,3) {
        rep(j,c[i]) {
            if (i==0) tp[j+1]=p[j]+tp[j];
            else if (i==1) tq[j+1]=q[j]+tq[j];
            else tr[j+1]=r[j]+tr[j];
        }
    }
    sort(tp.begin(),tp.end(),greater<>());
    sort(tq.begin(),tq.end(),greater<>());
    sort(tr.begin(),tr.end(),greater<>());
    reverse(p.begin(),p.end());
    reverse(q.begin(),q.end());
    reverse(r.begin(),r.end());
    ll ans=0;
    repr(i,max(x-c[2],0),x+1) {
        ll tans=0;
        tans+=tp[0]-tp[i];
        tans+=tr[0]-tr[x-i];
        // cout << i << tans << endl;
        int ng=max(-1,y-(c[2]-(x-i))-1);
        int ok=y;
        // cout << ng << ok << endl;
        while (ok-ng>1) {
            int mid=(ok+ng)/2;
            // cout << mid << x-i+y-mid << endl;
            if (q[mid]<r[x-i+y-mid-1]) ok=mid;
            else ng=mid;
        }
        // cout << ok << endl;
        tans+=tq[0]-tq[ok];
        tans+=tr[x-i]-tr[x-i+y-ok]; 
        // cout << i << tans << endl;
        ans=max(ans,tans);
    }
    cout << ans << endl;
}

Measured memory_bytes: 5108
D,N = map(int,input().split(" "))
if D == 0:
    if N == 100:
        print(N+N//100)
    else: 
        print(N)
elif D == 1:
    if N  == 100: 
        print(100*N+(N//100)*100)
    else:
        print(100*N)
elif D == 2:
    if N == 100:
        print(10000*N+(N//100)*10000 )
    else:
        print(10000*N)

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

#ifndef ONLINE_JUDGE
#define W(x) cerr << "\033[31m" << #x << " = " << x << "\033[0m" << "\n";
#else
#define W(x) 42;
#endif
 
int n, m, k, hist[1000100], ans;

int main(){
	
	scanf("%d %d", &n, &m);

	for(int i=0; i<n; i++){
		scanf("%d", &k);
		while(k--){
			int aux;
			scanf("%d", &aux);
			hist[aux]++;
			if(hist[aux]==n) ans++;
		}
	}

	printf("%d\n", ans);
	return 0;
}

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

struct edge{int from;int to;long long cost;};

int N,M;
long long P;
vector<edge> gra;
vector<long long> d(2525,9999999999999LL);
vector<bool> neg(2525,false);

int main(){
	cin >> N >> M >> P;
	for(int i=0;i<M;i++){
		int A,B;
		long long C;
		cin >> A >> B >> C;
		A--;
		B--;
		C-=P;
		C*=-1;
		edge e;
		e.from=A;e.to=B;e.cost=C;
		gra.push_back(e);
	}
	d[0]=0;
	for(int k=0;k<N*2;k++){
		for(int i=0;i<M;i++){
			if(neg[gra[i].from])neg[gra[i].to]=true;
			if(d[gra[i].from]!=9999999999999LL && d[gra[i].to]>d[gra[i].from]+gra[i].cost){
				d[gra[i].to]=d[gra[i].from]+gra[i].cost;
				if(k>=N)neg[gra[i].to]=true;
			}
		}
	}
	if(neg[N-1])cout << "-1" << endl;
	else cout << max(-d[N-1],0LL) << endl;
	return 0;
}

Measured memory_bytes: 512
package main

import "fmt"

func main() {
  var n int
  fmt.Scan(&n)
  h := make([]int, n)
  for i := 0; i < n; i++ {
    fmt.Scan(&h[i])
  }
  count := 0
  max := h[0]
  for _, v := range h {
    if v >= max {
      max = v
      count++
    }
  }
  fmt.Println(count)
}


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

vector<char> v;

int main(){
	char c;
	while(scanf("%c",&c) != EOF){
		if(c == '0'){
			v.push_back(c);
		}
		else if(c == '1'){
			v.push_back(c);
		}
		else if(c == 'B'){
			if(!v.empty()){
				v.pop_back();
			}
		}
	}
	for(int i = 0; i < v.size(); i++){
		cout << v[i];
	}
	cout << endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define LL long long
#define Mod 1000000007
using namespace std;
int n,m;
int f[2][5005];
int main(){
	char*str=new char[5005];
	scanf("%d%s",&n,str);
	m=strlen(str);
	delete [] str;
	f[0][0]=1;
	for(int i=1;i<=n;++i){
		int I=i&1;
		f[I][0]=(f[I^1][0]+f[I^1][1])%Mod;
		for(int j=1;j<=n;++j)
			f[I][j]=((LL)f[I^1][j-1]+f[I^1][j-1]+f[I^1][j+1])%Mod;
	}
	int Ans=f[n&1][m];
	for(int i=1;i<=m;++i) Ans=(LL)Ans*500000004%Mod;
	printf("%d",Ans);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long
#define pb push_back
#define fi first
#define se second 
#define mp make_pair
#define int long long
int dig(int n)
{
    int ans = 0;
    while(n)
    {
        ans++;
        n /= 10;
    }
    return ans;
}
signed main()
{
    IOS
    int count = 0;
    int n; cin>>n;
    for(int i=1;i<=n;i++)
    {
        if(dig(i) % 2) count++;
    }
    cout<<count;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
 
class Main {
	public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long X = sc.nextLong();
		int ansA = 0, ansB = 0;
		sc.close();
		
        
        for(int i=-1000; i<1000; i++) {
        	for(int j = -1000; j < 1000; j++){
				if(Math.pow(i,5) - Math.pow(j,5) == X){
					ansA = i;
					ansB = j;
				}
			}
		}
		System.out.println(ansA + " " + ansB);

	}
}



Measured memory_bytes: 38816
#include <cstdio>
#include <algorithm>
using namespace std;
int main(){
	int n;
	scanf("%d", &n);
	bool same = true;
	int a[n];
	for (int i = 0; i < n; i++){
		scanf("%d", &a[i]);
		if (a[i] != a[0]){
			same = false;
		}
	}
	if (a[0] == 0 && same){
		printf("Yes\n");
		return 0;
	}
	if (n % 3 != 0){
		printf("No\n");
		return 0;
	}
	sort(a, a + n);
	int b[3];
	for (int i = 0; i < 3; i++){
		b[i] = a[(n / 3) * i];
		for (int j = (n / 3) * i; j < (n / 3) * (i + 1); j++){
			if (a[j] != b[i]){
				printf("No\n");
				return 0;
			}
		}
	}
	if ((b[0] ^ b[1]) == b[2]){
		printf("Yes\n");
	}else{
		printf("No\n");
	}
}

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

int main(){
	
	int N,ans;
	ans=1;
	string S;
	cin >>N >>S;
	
	for(int i=0; i<N-1; i++){
		
		if(S.at(i)!=S.at(i+1)){
			
			ans++;
			
		}
		
	}
	
	cout <<ans <<endl;
	
}



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

#define ll long long 

int main(void){
    int n;
    cin >> n;
    for(int i=1;i<=9;i++){
        int ans = 111 * i;
        if(n <= ans){
            cout << ans << endl;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
	int a[5][4][11] = { {{}} };
	int i, j, k, b, f, r, v, n;
	cin >> n;
	while (n--)
	{
		cin >> b >> f >> r >> v;
		a[b][f][r] += v;
	}
	for (i = 1; i <= 4; i++)
	{
		for (j = 1; j <= 3; j++)
		{
			for (k = 1; k <= 10; k++)
			{
				cout << " " << a[i][j][k];
			}
			
			cout << endl;
		}
		if (i != 4)cout << "####################" << endl;
	}
	return 0;
}


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

int main()
{
	int coun=1;
	int u;
	while (true)
	{
		cin >> u;
		if (u == 0)
		{
			break;
		}
		cout << "Case " << coun << ": " << u << endl;
		coun++;
	}	
}

Measured memory_bytes: 3060
n = gets.to_i
a = gets.split.map(&:to_f)
b = gets.split.map(&:to_f)

res = [0.0]*4
a.zip(b).each do |x,y|
  3.times do |i|
    res[i] += (x-y).abs**(i+1)
  end
  res[3] = [res[3], (x-y).abs].max
end

3.times do |i|
  puts res[i]**(1.0/(i+1))
end
puts res[3]

Measured memory_bytes: 8860
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[][] abc = new int[n][3];
		int[][] dp = new int[n][3];
		for(int i = 0; i < n; i++) {
			abc[i][0] = sc.nextInt();
			abc[i][1] = sc.nextInt();
			abc[i][2] = sc.nextInt();
		}

		dp[0][0] = abc[0][0];
		dp[0][1] = abc[0][1];
		dp[0][2] = abc[0][2];

		for(int i = 1; i < n; i++) {
			for(int j = 0; j < 3; j++) {
				dp[i][j] = Math.max(dp[i][j], dp[i - 1][(j + 1) % 3] + abc[i][j]);
				dp[i][j] = Math.max(dp[i][j], dp[i - 1][(j + 2) % 3] + abc[i][j]);
			}
		}
		System.out.println(Math.max(Math.max(dp[n - 1][0], dp[n - 1][1]), dp[n - 1][2]));
		sc.close();
	}
}


Measured memory_bytes: 102164
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cmath>
#include<cstdio>
#include<tuple>
#include<bitset>
#include<map>

using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
using P=pair<int,int>;
using lint=long long;
using ll=long long;
const lint inf=1e18+7;
const int MOD=1000000007;
signed main(){
  int n;cin>>n;
  vector<int> a(n);
  rep(i,n)cin>>a[i];
  sort(a.begin(),a.end());
  reverse(ALL(a));
  int last=0;
  int res=0;
  if(n%2==0){
    rep(i,n/2){
      res+=a[i];
      if(i>0)res+=a[i];
    }
  }
  else{
    rep(i,n/2){
      res+=a[i]+a[i+1];
    }
  }
  cout<<res<<"\n";
  return 0;
}


Measured memory_bytes: 4828
#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, m, n) for(int i=(m); i<(n); ++i)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define Cout(x) cout << (x) << endl
#define Cout2(x, y) cout << (x) << " " << (y) << endl
#define dump(x) cerr << #x << " = " << (x) << endl;
typedef long long LL;
typedef vector<int> VI;
typedef vector<long long> VL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
const int inf = 1e9;
const double pi = acos(-1.0);

//エラトステネスの篩
int Num = 10000009;
vector<bool> p(Num, true);
void Eratosthenes() {
	p[0] = false;
	p[1] = false;
	for (int i = 0; i < Num; ++i)if (p[i])
		for (int j = i * 2; j < Num; j += i)p[j] = false;
}

bool Check(LL a) {
	return p[a] && p[a - 2] && p[a - 6] && p[a - 8];
}

int main() {
	Eratosthenes();

	LL n;
	while (cin >> n && n) {
		if (n % 2 == 0)n--;
		int ans;
		for (LL i = n; true; i -= 2) {
			if (Check(i)) { ans = i; break; }
		}
		Cout(ans);
	}
}


Measured memory_bytes: 3904
H, W = map(int, input().split())
g = [list("." * (W + 2))]
for _ in range(H):
    g += [list("." + input() + ".")]
g += [list("." * (W + 2))]

d = [(-1, -1), (-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1)]

for i in range(1, H + 1):
    for j in range(1, W + 1):
        if g[i][j] == ".":
            c = 0
            for (dx, dy) in d:
                if g[i + dx][j + dy] == "#":
                    c += 1
            g[i][j] = c
for i in range(1, H + 1):
    print(*g[i][1:(W + 1)], sep="")
        

Measured memory_bytes: 3444
#include <iostream>
#include <cstdio>
#include <sstream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <cctype>
#include <stack>
#include <bitset>
#include <unordered_set>
#include <map>
#include <set>
#include <cmath>
//#include <bits/stdc++.h>

using namespace std;
typedef long long lolo;
typedef pair<int,int> pii;
typedef pair<double,double> pdd;
typedef unsigned long long ulolo;

const int maxn = (int)1e5 + 5;
const lolo maxx = (lolo)10000001;
const int maxm =(int)2e3 + 5;
const int INF = 0x3f3f3f3f;
const lolo inf = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-6;
const int MOD = (int)1e6 + 3;

template<class T>
inline void read(T &x) {
    x = 0; T flag = 1;char c;
    do { c = (char) getchar(); if (c == '-') break; } while (c < '0' || c > '9');
    if (c == '-') { c = '0', flag = -1;}
    do { x = x * 10 + c - '0';c = (char) getchar();} while (c >= '0' && c <= '9');
    x *= flag;
}
template<class T>
inline void out(T x) {
    if (x > 9) out(x / 10);
    x = x % 10;
    putchar('0' + x);
}

int a[maxn], preS[maxn], nextS[maxn];
int main() {
//    freopen("../in.txt", "r", stdin);
    int n;
    read(n);
    int ans = 1;
    for (int i = 1; i < n+1; ++i) {
        read(a[i]);
        preS[i] = __gcd(preS[i-1], a[i]);
    }
    for (int i = n; i > 0; --i) {
        nextS[i] = __gcd(nextS[i+1], a[i]);
    }
    for (int i = 2; i < n; ++i) {
        int tmp = __gcd(preS[i-1], nextS[i+1]);
        if (ans < tmp) {
            ans = tmp;
        }
    }
    if (preS[n-1] > ans) {
        ans = preS[n-1];
    }
    if (nextS[2] > ans) {
        ans = nextS[2];
    }
    printf("%d\n", ans);
    return 0;
}


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

#define X first
#define Y second
#define eb push_back
#define siz(a) int(a.size())
#define endl "\n"

#define trace2(x, y)             cerr <<#x<<": "<<x<<" | "<<#y<<": "<<y<< endl;
#define trace3(x, y, z)          cerr <<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl;
#define trace4(a, b, c, d)       cerr <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl;
#define trace5(a, b, c, d, e)    cerr <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<<": "<<e<<endl;

using namespace std;

typedef long long int ll;
typedef vector < int > vi;
typedef vector < ll > vll;

const int mod=1e9+7;
const int maxn=1e6+5;

/*	finding inverse upto n
 * for i in xrange(2, N):
    ifc[i] = -(mod / i) * ifc[mod % i] % mod
 * 
*/
ll power(ll base, ll exp, ll mod){ll res = 1; while(exp){if(exp%2)res*=base;base*=base;res%=mod;base%=mod;exp/=2;}return res;}

ll n, arr[105];

int main(){
	ios_base::sync_with_stdio(false);cin.tie(NULL); cout.tie(NULL);
	//freopen("input.in", "r", stdin);freopen("output.out", "w", stdout);	
	
	cin >> n;
	ll ans = 0;
	for(ll i = 1; i<=n; i++){
		cin >> arr[i];
		
		if(arr[i] == arr[i-1])
			arr[i] = 0, ans++;
	}
	
	cout << ans;
	
	
	return 0;
}


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

Int solve(string s, Int p){
	vector<Int> z(s.size());
	z[p] = s.size() - p;
	Int l = p, r = p;
	for(Int i=p+1; i<(Int)s.size(); ++i){
		if(i > r){
			l = r = i;
			while(r < (Int)s.size() && s[p+r-l] == s[r]) ++r;
			z[i] = r-l;
			--r;
		}else{
			Int k = i-l;
			if(z[p+k] < r-i+1){
				z[i] = z[p+k];
				continue;
			}
			l = i;
			while(r < (Int)s.size() && s[p+r-l] == s[r]) ++r;
			z[i] = r-l;
			--r;
		}
	}
	Int res = 0;
	for(size_t i=p; i<s.size(); ++i){
		res = max(res, min<Int>(i-p, z[i]));
	}
//	cerr << p << "\n";
//	for(size_t i=0; i<s.size(); ++i)
//		cerr << i << " " << z[i] << "\n";
	return res;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	Int n;
	string s;
	cin >> n >> s;
	Int ans = 0;
	for(Int i=0; i<n; ++i)
		ans = max(ans, solve(s, i));
	cout << ans << "\n";
}

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

int main() {
    string s;
    cin >> s;
    vector<string> strs = {"dream", "dreamer", "erase", "eraser"};
    reverse(all(s));
    rep(i, strs.size()) { reverse(all(strs[i])); }

    int pos = 0;
    while (true) {
        bool judge = false;
        rep(i, strs.size()) {
            if (s.substr(pos, strs[i].size()) == strs[i]) {
                judge = true;
                pos += strs[i].size();
                break;
            }
        }
        if (!judge) {
            break;
        }
    }

    if (pos == s.size())
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for(int i = a; i < b; ++i)
#define REP(i, n) FOR(i, 0, n)
#define _ << " " <<
#define pb push_back
#define fi first
#define se second

typedef double lf;
typedef long long ll;
typedef pair<int, int> pii;

const int mod = 998244353;
int add(int x, int y) {x += y; if(x >= mod) return x - mod; return x;}
int sub(int x, int y) {x -= y; if(x < 0) return x + mod; return x;}
int mul(int x, int y) {return (ll) x * y % mod;}

const int MAXN = 2e5 + 5;

int dp[MAXN][2];

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

  string s; cin >> s;
  int n = s.size();

  dp[0][0] = 1;
  FOR(i, 1, n) {
    dp[i][0] = dp[i - 1][1] + 1;
    if(s[i] != s[i - 1]) dp[i][0] = max(dp[i][0], dp[i - 1][0] + 1);
    dp[i][1] = 1;
    if(i >= 2) dp[i][1] = dp[i - 2][0] + 1;
  }

  cout << max(dp[n - 1][0], dp[n - 1][1]) << endl;
}


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

int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	a += b;
	c += d;
	if (a < c) {
		cout << "Right" << endl;
	}
	if (a > c) {
		cout << "Left" << endl;
	}
	if(a==c) {
		cout << "Balanced" << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define WHATIS(x) cout << #x << " is " << x << endl;
#define ERROR(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x

using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<II, int> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << *it << " = " << a << endl;
    err(++it, args...);
}

const ll MODBASE = 1000000007LL;
const int MAXN = 510;
const int MAXM = 200010;
const int MAXK = 110;
const int MAXQ = 200010;

int n, k, a[MAXN], d[MAXN];
vector<int> b, c;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    cin >> n >> k;
    FOR(i,1,n) cin >> a[i];
    int s = 0;
    FOR(i,1,n) s += a[i];
    FOR(i,1,int(sqrt(s))) {
        if (s % i) continue;
        b.emplace_back(i);
        if (i != s / i) b.emplace_back(s / i);
    }
    sort(ALL(b));
    FORE(i,SZ(b)-1,0) {
        int times = s / b[i];
        c.clear();
        FOR(j,1,n) c.emplace_back(a[j]);
        FOR(j,0,n-1) {
            times -= c[j] / b[i];
            c[j] %= b[i];
        }
        sort(ALL(c));
        int cnt = 0;
        FORE(j,n-1,0)
            if (times) times--;
            else cnt += c[j];
        if (cnt <= k) {
            cout << b[i];
            return 0;
        }
    }
    
    return 0;
}


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

l_list.sort()

result = 0

for i in range(0, 2*N, 2):
    l1 = l_list[i]
    l2 = l_list[i+1]

    min_l = min(l1, l2)
    result += min_l
print(result)

Measured memory_bytes: 3060
#!usr/bin/env pypy3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect


def LI(): return [int(x) for x in sys.stdin.readline().split()]


def I(): return int(sys.stdin.readline())


def LS(): return [list(x) for x in sys.stdin.readline().split()]


def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res


def IR(n):
    return [I() for i in range(n)]


def LIR(n):
    return [LI() for i in range(n)]


def SR(n):
    return [S() for i in range(n)]


def LSR(n):
    return [LS() for i in range(n)]


sys.setrecursionlimit(1000000)


def main():
    a = list(input())
    print("Yes" if "7" in a else "No")


main()


Measured memory_bytes: 9352
#include<iostream>
#include<algorithm>
#include<vector>
#include<set>
using namespace std;
using P = pair<int,int>;
using ll = long long;
const int INF = 1e9;
#define rep(i,N) for(int (i) = 0; (i) < (N);++(i))

int res(ll x,ll y){return (x<=y?y-x:INF*2+3);}

int main(){
    int X,Y;
    cin >> X >> Y;
    cout << min({res(X,Y),res(-X,Y)+1,res(X,-Y)+1,res(-X,-Y)+2}) << endl;
    
}

Measured memory_bytes: 256
n = input()

cnt = 0
prec = ''
for c in n:
  if cnt == 0:
    cnt += 1
  elif cnt >= 3:
    break
  elif prec == c:
    cnt += 1
  else:
    cnt = 1
  prec = c

print('Yes' if cnt >= 3 else 'No')

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

int main() {
	int n;
	cin >> n;
	vector<int> t(n), v(n);
	for (auto &i : t) {
		cin >> i;
	}
	for (auto &i : v) {
		cin >> i;
	}
	int m = 2 * accumulate(t.begin(), t.end(), 0) + 1;
	double a[m];
	for (int i = 0, s = 0; i < n; i++) {
		a[2 * s] = min(a[2 * s], double(v[i]));
		for (int j = 0; j < t[i]; j++) {
			a[2 * (s + j) + 1] = v[i];
			a[2 * (s + j) + 2] = v[i];
		}
		s += t[i];
	}
	a[0] = a[m - 1] = 0;
	for (int i = 1; i < m; i++) {
		a[i] = min(a[i], a[i - 1] + 0.5);
	}
	for (int i = m - 1; i; i--) {
		a[i - 1] = min(a[i - 1], a[i] + 0.5);
	}
	double ans = 0;
	for (int i = 0; i < m - 1; i++) {
		ans += (a[i] + a[i + 1]) / 4;
	}
	cout << fixed << setprecision(17) << ans << endl;
	return 0;
}

Measured memory_bytes: 512
#include <cstdio>

void bubbleSort(int a[], int n)
{
  int i, j;
  int cnt = 0;
  bool flag = true;
  for (i = 0; i < n || flag; i++) {
    flag = false;
    for (j = n - 1; j > i; j--) {
      if (a[j - 1] > a[j]) {
	int temp = a[j];
	a[j] = a[j - 1];
	a[j - 1] = temp;
	flag = true;
	cnt++;
      }
    }
  }
  for (i = 0; i < n - 1; i++) 
    printf("%d ", a[i]);
  printf("%d\n", a[i]);
     
  printf("%d\n", cnt);
}

int main()
{
  int a[100];
  int n;
  
  scanf("%d", &n);
  for (int i = 0; i < n; i++) 
    scanf("%d", &a[i]);
  
  bubbleSort(a, n);

  return 0;
}



Measured memory_bytes: 2732
import java.util.*;

public class Main {
    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        String now = "A";
        while(true) {
            String line;
            try {
                line = sc.nextLine();
            }catch(Exception e) {
                break;
            }
            String[] linesp = line.split(",");
            String x = linesp[0];
            String y = linesp[1];
            if(x.equals(now)) {
                now = y;
            }else if(y.equals(now)) {
                now = x;
            }
        }
        System.out.println(now);
    }
}



Measured memory_bytes: 25936
#define __USE_MINGW_ANSI_STDIO
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#include <unordered_set>
#include <unordered_map>

using namespace std;

typedef long long ll;
typedef long long ull;
typedef pair<ll, ll> ii;

#define all(v)		((v).begin()), ((v).end())
#define sz(v)		((int)((v).size()))
#define endl		"\n"
#define fx(n)		fixed<<setprecision(n)
#define mk			make_pair	

void File()
{
#ifndef ONLINE_JUDGE
	freopen("output.txt", "w", stdout);
	freopen("input.txt", "r", stdin);
#endif
#ifdef ONLINE_JUDGE
	/*freopen("output.txt", "w", stdout);
	freopen("commandos.in", "r", stdin);*/
#endif
}
void fast()
{
	ios::sync_with_stdio(NULL);
	cout.tie(NULL);
	cin.tie(NULL);
	//File();
}
const double pi = acos(-1.0);
const ll oo = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
const int nn = 1e5 + 15;
int dx[8] = { 1, 0, -1, 0, 1, -1, 1, -1 };
int dy[8] = { 0, 1, 0, -1, 1, -1, -1, 1 };

ll dp[nn][4], n;
vector < pair<int, pair<int, int> > > arr;
ll solve(int idx, int cur)
{
	if (idx >= n)
		return 0;
	ll &ret = dp[idx][cur];
	if (~ret)
		return ret;
	if (cur != 0)
		ret = max(ret, solve(idx + 1, 0) + arr[idx].first);
	if (cur != 1)
		ret = max(ret, solve(idx + 1, 1) + arr[idx].second.first);
	if (cur != 2)
		ret = max(ret, solve(idx + 1, 2) + arr[idx].second.second);
	return ret;
}
int main()
{
	fast();
	cin >> n;
	memset(dp, -1, sizeof dp);
	arr.resize(n + 1);
	for (int i = 0; i < n; i++)
	{
		cin >> arr[i].first >> arr[i].second.first >> arr[i].second.second;
	}
	cout << solve(0, 3) << endl;
	return 0;
}

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

const long long INF = 1LL << 60;

int main() {
  long long n,x,digit=0,res=INF;
  cin >> n;
  
  for(long long i=1;i*i<=n;i++){
    if(n%i == 0){
        x=max(i,n/i);
        while(x !=0 ){
          x /= 10;
          digit++;
        }
      	res = min(res,digit);
        digit=0;
    }
  }
          
  
  cout << res << endl;
}

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

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

// a^{-1} mod を計算する
long modinv(long a, long mod) {
    return modpow(a, mod - 2, mod);
}

struct compare1 { 
    bool operator()(const pair<long, long>& value,  
                                const long& key) 
    { 
        return (value.first < key); 
    } 
    bool operator()(const long& key,  
                    const pair<long, long>& value) 
    { 
        return (key < value.first); 
    } 
}; 

int main()
{
    int L; cin >> L;
    double vl = (double)L;
    cout << fixed;
    cout << setprecision(8) << vl*vl*vl/27.0 << endl;

    return 0;
}



Measured memory_bytes: 256
# This Python file uses the following encoding: utf-8

# if __name__ == "__main__":
#     pass
a, b, c, d = map(int, input().split())
'''
while a > 0 and c > 0:
    c -= b
    a -= d
if c <= 0:
    print("Yes")
else:
    print("No")
'''
if  -(-c//b) <= -(-a//d):
    print("Yes")
else:
    print("No")


Measured memory_bytes: 9068
import java.util.Scanner;

public class Main {
    
    static Pair[] queue;
    static int head;
    static int tail;

    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        int n = Integer.parseInt(sc.next());
        int q = Integer.parseInt(sc.next());
        
        queue = new Pair[100010];
        initialize();
        for(int i = 0; i < n; i++){
            enqueue(new Pair(sc.next(), Integer.parseInt(sc.next())));
        }
        
        int t = 0;
        StringBuilder sb = new StringBuilder();
        while(!isEmpty()){
            Pair x = dequeue();
            if(x.time <= q){
                t += x.time;
                sb.append(x.name).append(" ").append(t).append(System.lineSeparator());
            }else{
                t += q;
                x.time -= q;
                enqueue(x);
            }
        }
        
        System.out.print(sb);
    }
    
    static void initialize(){
        head = tail = 0;
    }
    
    static boolean isEmpty(){
        return head == tail;
    }
    
    static void enqueue(Pair x){
        
        queue[tail] = x;
        if(tail+1 == queue.length){
            tail = 0;
        }else{
            tail++;
        }
    }
    
    static Pair dequeue(){
        
        Pair x = queue[head];
        if(head+1 == queue.length){
            head = 0;
        }else{
            head++;
        }
        return x;
    }
    
    static class Pair{
        String name;
        int time;

        public Pair(String name, int time) {
            this.name = name;
            this.time = time;
        }
    }
}


Measured memory_bytes: 73040
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int ans=700;
	char a[3];
	for(int i=0;i<3;i++)
	{
		cin>>a[i];
		if(a[i]=='o')
		ans+=100;
	}
	cout<<ans; 
	return 0;
}

Measured memory_bytes: 256
#Nは木の本数を示す。
N,D = map(int, input().split())
#一人の監視員がみることができる木の数
can_see = 2*D+1
#必要となる監視員の人数
number = 0

number =int( N / can_see)

if (N % can_see != 0):
    number += 1
print(number)

Measured memory_bytes: 3316
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;
#define MOD 1000000007
#define ADD(X,Y) ((X) = ((X) + (Y)%MOD) % MOD)
typedef long long i64; typedef vector<int> ivec; typedef vector<string> svec;

char S[303030];
int N;

i64 dp[2][8];

int main()
{
	scanf("%s", S);
	N = strlen(S);

	int t = 0;
	for (int i = 0; i < 8; ++i) dp[t][i] = 0;

	dp[t][0] = 1;

	for (int i = 0; i < N; ++i) {
		for (int j = 0; j < 8; ++j) dp[1 - t][j] = 0;

		for (int j = 0; j < 8; ++j) {
			for (int k = 0; k < 2; ++k) {
				if (k == 0 && S[i] == '1') continue;
				if (k == 1 && S[i] == '0') continue;

				int j2 = (j & 6) | k;
				if (k == 1) {
					if (i == 0) j2 |= 4;
					if (i == N - 1) j2 |= 2;
					if (j & 1) {
						if (i % 2 == 0) j2 |= 4;
						else j2 |= 2;
					}
				}

				if (!(j2 & 4)) j2 &= ~2;
				ADD(dp[1 - t][j2], dp[t][j]);
			}
		}

		t = 1 - t;
	}

	i64 ret = (dp[t][6] + dp[t][7]) % MOD;
	printf("%lld\n", ret);

	return 0;
}


Measured memory_bytes: 512
S = list(input())
ans = 0
N = len(S)
flag = False
cntb = 0
cnt = 0
for i in range(N):
    if S[i] == 'B':
        cntb += 1
    elif S[i] =='W':
        cnt += cntb
        
print(cnt)
        
        
    


Measured memory_bytes: 4840
#include<iostream>
#include<algorithm>
using namespace std;
int main(){

	long long int A[5001]={0};
	long long int n,MAX = -100000;

		while(1){

			cin >> n;

			if( n == 0 ) break;

			for(int i = 1; i <= n; i++){

				cin >> A[i];
	
			}

			MAX = -100000;
		
			for(int i = 1; i <= n; i++){

				A[i] = max(A[i], A[i] + A[i-1]);
				MAX = max(A[i], MAX);

			}
	
			cout  << MAX << endl;

		}
	return 0;
}

Measured memory_bytes: 1200
#include <iostream>
using namespace std;
int main(void){
    int n;
    cin>>n;
    for (int i =0;i<=n/4;i++){
        if ((n-i*4)%7==0){
            cout<<"Yes";
            exit(0);
        }
    }
    cout<<"No";
    exit(0);
}


Measured memory_bytes: 3576
#include <iostream>
#include <vector>
#include <string>
#include <cstdlib>
#include<algorithm> 
#include <iomanip>
#include <math.h>
#include <iostream>
#include <bitset>
#include <map>

#define db double
#define vi vector<int>
#define pb push_back
#define popb pop_back
#define fi first
#define se second
#define ll long long
#define ld long double
#define maxn 5005
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vll vector<ll>
#define vpi vector<pii>
#define vpll vector<pll>
#define vv vector<vector<int> >
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(c) begin(c),end(c)
#define pp pair<int,int>
#define fix(n) fixed << setprecision(n)
#define gmax(a,b) __gcd(a,b)
#define gmin(a,b) a/__gcd(a,b)*b
using namespace std;
const int mod = 1000000007;
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, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}



int main(){
    int h,w;cin>>h>>w;
    vector<vector<char> >a(h,vector<char>(w));
    vi x(9);
    vi y(9); 
    x={-1,0,1,-1,0,1,-1,0,1};
     y={-1,-1,-1,0,0,0,1,1,1,};
    vv b(h,vi (w));

    rep(i,h)rep(j,w){
      char an;
      cin>>an;
      if(an=='#'){
        rep(k,9){
          int xn=i+x.at(k);
          int yn=j+y.at(k);
        if(xn<0||yn<0)continue;
        else if(xn>=h||yn>=w)continue; 
        else if(xn==i&&yn==j)b.at(xn).at(yn)=-1;
        else if(b.at(xn).at(yn)==-1)continue;
        else b.at(xn).at(yn)+=1;
      }
      }
    }
    rep(i,h){
      rep(j,w){
      if(b.at(i).at(j)==-1)cout<<"#";
      else cout<<b.at(i).at(j);
    }
    cout<<endl;
    }


return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define FOR(i, a, b) for (int i = a; i < (b + a); i++)
#define W1 while (1)
#define COUT(x) cout << x << endl
using namespace std;
using ll = long long;
using ld = long double;
#define ALL(x) x.begin(),x.end()
#define P pair<int,int>
#define mod 1000000007
#define PB push_back
#define F first
#define S second
const int INF = 1001001001;

int main() {
  int h, w;
  cin >> h >> w;
  char ways[h][w];
  int dx[4] = {-1, 0, 1, 0};
  int dy[4] = {0, -1, 0, 1};
  int ans = 0;
  rep(i, h) {
    rep(j, w) {
      cin >> ways[i][j];
    }
  }
  rep(i, h) {
    rep(j, w) {
      if (ways[i][j] == '#') continue;
      int dist[h][w];
      rep(k, h) {
        rep(l, w) {
          if (ways[k][l] == '.') dist[k][l] = INF;
          else dist[k][l] = -2;
        }
      }
      queue<P> que;
      int maxdist = 0;
      que.push(P(i, j));
      dist[i][j] = 0;
      while (!que.empty()) {
        int x = que.front().F;
        int y = que.front().S;
        que.pop();
        rep(a, 4) {
          int nx = x + dx[a];
          int ny = y + dy[a];
          if (nx < 0 || nx >= h || ny < 0 || ny >= w) continue;
          if (dist[nx][ny] == INF) {
            que.push(P(nx, ny));
            dist[nx][ny] = dist[x][y] + 1;
            maxdist = dist[x][y] + 1;
          }
        }
      }
      ans = max(ans, maxdist);
    }
  }
  COUT(ans);

  return 0;
}


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

int main(){
  double a,b,x;
  cin >> a >> b >> x;
  double r1 = atan((a*b*b)/(2*x)) * (180 / M_PI);
  double r2 = atan((2*a*a*b-2*x)/(a*a*a)) * (180 / M_PI);
  int c = a*a*b;

  if(2*x >= a*a*b)printf("%.8f\n",r2);
  else printf("%.8f\n",r1);
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    long a=sc.nextLong(),b=sc.nextLong(),c=sc.nextLong(),count=0;
    
    while(check(a,b,c)) {
    	long buffa=a/2,buffb=b/2,buffc=c/2;
    	a=buffb+buffc;
    	b=buffa+buffc;
    	c=buffa+buffb;
    	count++;
    }
    System.out.println(count);
  }
	public static boolean check(long a,long b,long c) {
		if(a%2==0&&a==b&&a==c) {
			System.out.println(-1);
			System.exit(0);
			return false;
		}else {
			if(a%2==0&&b%2==0&&c%2==0) {
				return true;
			}else {
				return false;
			}
		}
	}
}


Measured memory_bytes: 21844
#include <iostream>

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

int main(){
    char c;
    cin >> c;
    char aeiou[] = {'a', 'e', 'i', 'o', 'u'};
    for(int i = 0; i < 5; ++i){
        if(c == aeiou[i]){
            cout << "vowel" << endl;
            return 0;
        }
    }
    cout << "consonant" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v) sort(v.begin(), v.end(), greater<pair<ll, ll>>())
#define ll long long
#define rep(i, s, g) for (ll i = (s); i < (g); i++)
#define MOD 1000000007
#define vfind(v, target) find(v.begin(), v.end(), target)
#define notFound(v, target) (vfind(v, target) == v.end())

using namespace std;

int main()
{
  ll N, ans; cin >> N;
  vector<ll> V(N);
  rep(i, 0, N) {
  	cin >> V[i]; V[i]--;
  }
  vector<pair<ll, ll>> odd(100005), even(100005);
  rep(i, 0, 100005) {
  	odd[i] = make_pair(0, i);
    even[i] = make_pair(0, i);
  }
  rep(i, 0, N) {
  	if (i % 2) {
    	odd[V[i]].first++;
    } else {
    	even[V[i]].first++;
    }
  }
  rvsort(odd);
  rvsort(even);
  if (odd[0].second != even[0].second) {
    ans = N - odd[0].first - even[0].first;
  } else {
  	ans = min(N - odd[0].first - even[1].first, N - odd[1].first - even[0].first); 
  }
  cout << ans << endl;
}

Measured memory_bytes: 4096
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define SORT(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define EQ(a,b) (abs((a)-(b))<eps)
int N;
vector<int> p[105];
vector<int> L;
int main()
{
	while(1)
	{
		for(int i=0;i<105;i++)p[i].clear();
		L.clear();
		cin >> N;
		if(N==0)break;
		for(int i=0;i<N;i++)
		{
			int k;
			cin >> k;
			for(int j=0;j<k;j++)
			{
				int a;
				cin >> a;
				p[i].pb(a);
			}
		}
		int k;
		cin >> k;
		for(int i=0;i<k;i++)
		{
			int a;
			cin >> a;
			L.pb(a);
		}
		sort(L.begin(),L.end());
		for(int i=0;i<N;i++)sort(p[i].begin(),p[i].end());
		int cnt = 0,num;
		for(int i=0;i<N;i++)
		{
			bool flag = true;
			for(int j=0;j<L.size();j++)
			{
				if(!(binary_search(p[i].begin(),p[i].end(),L[j])))
				{
					flag = false;
					break;
				}
			}
			if(flag)
			{
				cnt++;
				num = i+1;
			}
		}
		if(cnt!=1)cout << -1 << endl;
		else cout << num << endl;
	}
	return 0;
}

Measured memory_bytes: 1276
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
ios_base::sync_with_stdio(false);
  cin.tie(NULL);
#ifndef ONLINE_JUDGE
  //freopen("input.txt","r",stdin);
#endif

  int n,m;
  cin>>n>>m;
  vector<int> a(n);
  int sum=0;
  for(int i=0;i<n;i++)
  {
    cin>>a[i];
    sum+=a[i];
  }

  sort(a.begin(),a.end(),greater<int>());

  bool flag=1;

  double temp=sum/double(4*m);

  for(int i=0;i<m;i++)
  {
    if(a[i]<temp)
    {
      flag=0;
      break;
    }
  }


  if(!flag)
  {
    cout<<"No"<<endl;
  }
  else
  {
    cout<<"Yes"<<endl;
  }

  return 0;
}

Measured memory_bytes: 3660
#include <stdio.h>
#include <string.h>
#include <vector>
#include <numeric>
#include <algorithm>
#include <functional>
#include <math.h>

using namespace std;


int main() {
  double a, b, h, m;
  scanf("%lf %lf %lf %lf", &a, &b, &h, &m);

  double h_angle = (h + m / 60.0f) * 1.0f / 12.0f * 2.0f * M_PI;
  double m_angle = m * 1.0f / 60.0f * 2.0f * M_PI;

  double angle = h_angle - m_angle;

  printf("%.9lf", sqrt(a * a + b * b - 2.0f * a * b * cos(angle)));

  return 0;
}


Measured memory_bytes: 2604
#include<bits/stdc++.h>
using namespace std;
typedef vector<int>V;
int main(void){
	int box[10];
	int box1[10];
	int flg[10]={0};
	int a,b,c,d;
	V v;
	int i,j;
	int cnt;
	for(i=1;i<=9;i++){
		cin>>box[i];
		flg[box[i]]=1;
	}
	for(i=1;i<=9;i++){
		if(flg[i]==0){
			v.push_back(i);
		}
	}
	cnt=0;
	do{
		//for(i=0;i<(int)v.size();i++)	cout<<v[i]<<" ";	cout<<endl;
		for(i=1;i<=9;i++)	box1[i]=box[i];
		j=0;
		for(i=1;i<=9;i++){
			if(box1[i]==-1){
				box1[i]=v[j];
				j++;
			}
		}
		a=box1[1];
		b=box1[2]*10+box1[3];
		c=box1[4]*100+box1[5]*10+box1[6];
		d=box1[7]*100+box1[8]*10+box1[9];
		if(a+b+c==d)	cnt++;
	}while(next_permutation(v.begin(),v.end()));
	cout<<cnt<<endl;
	return 0;
}


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

dp = [1] * (N+100)
dp[0] = 0
dp[1] = 1

for i in range(2,1+N):
    for j in range(i, 1+N, i):
        dp[j] += 1


#print(dp)
ans = 0
for i in range(1,N+1):
    ans += i * dp[i]
print(ans)


Measured memory_bytes: 146080
import java.util.*;
import java.io.*;
public class Main{
	public static void main(String[] args)
	{
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int k=sc.nextInt();
		int arr[]=new int[n];
		int sum=0;
		if(n<k)
		{
			System.out.println(-1);
		}
	    for(int i=0;i<n;i++)
	    {
	    	arr[i]=sc.nextInt();
	    }
	    Arrays.sort(arr);
	    for(int i=0;i<k;i++)
	    {
	    	sum=sum+arr[i];
	    }
	    System.out.println(sum);
		
	}

}


Measured memory_bytes: 38752
S = gets.chomp
f, l = S[0,2].to_i, S[2,2].to_i

if f.between?(1,12)
  if l.between?(1,12)
    puts "AMBIGUOUS"
  else
    puts "MMYY"
  end
else
  if l.between?(1,12)
    puts "YYMM"
  else
    puts "NA"
  end
end

Measured memory_bytes: 1788
import sys
import itertools
import numpy as np
import time
import math
import re

sys.setrecursionlimit(10**7)

from collections import defaultdict
from collections import Counter

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

def main():
    S = input()[::-1]
    MOD = 2019
    
    X = [0]
    for i, s in enumerate(S):
        X.append((X[-1] + int(s) * pow(10, i, MOD)) % MOD)
    
    C = Counter(X)
    ans = 0
    for v in C.values():
        ans += v * (v - 1) // 2
    print(ans)




if __name__ == "__main__":
    main()
    pass

Measured memory_bytes: 34516
#include<stdio.h>
#include<algorithm>
#include<iostream>
#include<math.h>
#include<set>
#include<map>
#include<time.h>
#include<stack>
#include<queue>
#include<stdlib.h>
#include<string.h>
#include<vector>
#define LL long long
#define mem(a,b) memset(a,b,sizeof(a))
using namespace std;
const LL mod=998244353;
const int inf=1e9;
const double INF=1e9;
const int maxn=120;
int min(int a,int b) {return a<b?a:b;}
int main()
{
    int n;
    scanf("%d",&n);
    int ans;
    scanf("%d",&ans);
    for(int i=2;i<=n;i++)
    {
        int x;
        scanf("%d",&x);
        ans=__gcd(ans,x);
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 256
def solve():
    n = int(input())
    a = list(map(int, input().split()))

    ans = set()
    
    for i in range(n, 0, -1):
        now = 0
        for j in range(2*i, n+1, i):
            if j in ans:
                now += 1
        if now % 2 != a[i-1]:
            ans.add(i)
    
    return ans

if __name__ == '__main__':
    x = solve()
    print(len(x))
    print(*x, sep=' ')

Measured memory_bytes: 19576
import java.util.Scanner;


class Main{


public static void main(String[] args){

Scanner sc = new Scanner(System.in);

int a = sc.nextInt();

int b = sc.nextInt();

int c = sc.nextInt();

if((a < b) && (b < c)){
System.out.println("Yes");

}else{
System.out.println("No");

}
}
}



Measured memory_bytes: 26324
// Ennichi
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		new Main().run();
	}

	private void run() {
		Scanner sc = new Scanner(System.in);
		while (true) {
			int n = sc.nextInt();
			if (n == 0)
				break;
			String cipher = sc.next();
			int[] a = new int[n];
			int[] b = new int[n];
			for (int i = 0; i < n; i++) {
				a[i] = sc.nextInt() - 1;
				b[i] = sc.nextInt() - 1;
			}
			for (int i = n - 1; i >= 0; i--) {
				StringBuilder sb = new StringBuilder();
				int ca = cipher.charAt(a[i]) - 'a';
				int cb = cipher.charAt(b[i]) - 'a';
				int diff = b[i] - a[i];
				ca += diff;
				cb += diff;
				ca %= 26;
				cb %= 26;
				cipher = sb.append(cipher.substring(0, a[i]))
						.append((char) ('a' + cb))
						.append(cipher.substring(a[i] + 1, b[i]))
						.append((char) ('a' + ca))
						.append(cipher.substring(b[i] + 1)).toString();
			}
			System.out.println(cipher);
		}
		sc.close();
	}

}

Measured memory_bytes: 23524
using System;
using System.Collections.Generic;

namespace HelloWorld
{

    class MainClass
    {
        public static void Main(string[] args)
        {
            var data = Console.ReadLine().Split();
            var x = int.Parse(data[0]);
            var y = int.Parse(data[1]);

            Console.WriteLine(x + y / 2);
        }
    }
}


Measured memory_bytes: 11092